[cig-commits] r16175 - in short/3D/PyLith/trunk: applications libsrc libsrc/meshio modulesrc/meshio pylith pylith/apps pylith/meshio pylith/topology
brad at geodynamics.org
brad at geodynamics.org
Mon Jan 25 15:25:28 PST 2010
Author: brad
Date: 2010-01-25 15:25:27 -0800 (Mon, 25 Jan 2010)
New Revision: 16175
Added:
short/3D/PyLith/trunk/applications/pylith_prepmesh.in
short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.icc
short/3D/PyLith/trunk/modulesrc/meshio/MeshIOSieve.i
short/3D/PyLith/trunk/pylith/apps/PrepMeshApp.py
short/3D/PyLith/trunk/pylith/meshio/MeshIOSieve.py
short/3D/PyLith/trunk/pylith/topology/MeshImporterDist.py
Modified:
short/3D/PyLith/trunk/applications/Makefile.am
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh
short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
short/3D/PyLith/trunk/pylith/Makefile.am
Log:
Created PrepMeshApp object for mesh serialization application. Also added related MeshIOSieve and MeshImporterDist objects.
Modified: short/3D/PyLith/trunk/applications/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/applications/Makefile.am 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/applications/Makefile.am 2010-01-25 23:25:27 UTC (rev 16175)
@@ -15,12 +15,21 @@
INTERPRETER = $(PYTHON)
noinstINTERPRETER = $(PYTHON)
-bin_SCRIPTS = pylith
+bin_SCRIPTS = \
+ pylith \
+ pylith_prepmesh
+
do_build = sed -e s%[@]INTERPRETER[@]%$(noinstINTERPRETER)%g -e s%[@]PYTHONPATH[@]%$(noinstPYTHONPATH)%g
do_install = sed -e s%[@]INTERPRETER[@]%$(INTERPRETER)%g -e s%[@]PYTHONPATH[@]%$(PYTHONPATH)%g
+
pylith: $(srcdir)/pylith.in Makefile
$(do_build) < $(srcdir)/pylith.in > $@ || (rm -f $@ && exit 1)
chmod +x $@
+
+pylith_prepmesh: $(srcdir)/pylith_prepmesh.in Makefile
+ $(do_build) < $(srcdir)/pylith_prepmesh.in > $@ || (rm -f $@ && exit 1)
+ chmod +x $@
+
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@@ -34,7 +43,11 @@
chmod +x "$(DESTDIR)$(bindir)/$$f"; \
else :; fi; \
done
-EXTRA_DIST = pylith.in
+
+EXTRA_DIST = \
+ pylith.in \
+ pylith_prepmesh.in
+
CLEANFILES = $(bin_SCRIPTS)
Added: short/3D/PyLith/trunk/applications/pylith_prepmesh.in
===================================================================
--- short/3D/PyLith/trunk/applications/pylith_prepmesh.in (rev 0)
+++ short/3D/PyLith/trunk/applications/pylith_prepmesh.in 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,36 @@
+#!@INTERPRETER@
+# -*- Python -*-
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file applications/pylith_prepmesh
+## @brief Python PyLith application driver
+
+__requires__ = "PyLith"
+
+if __name__ == "__main__":
+
+ # re-create the PYTHONPATH at 'configure' time
+ import os.path, sys, site
+ path = '@PYTHONPATH@'.split(':')
+ path.reverse()
+ for directory in path:
+ if directory:
+ directory = os.path.abspath(directory)
+ sys.path.insert(1, directory)
+ site.addsitedir(directory)
+
+ from pylith.apps.PrepMeshApp import PrepMeshApp
+ from pyre.applications import start
+ start(applicationClass=PrepMeshApp)
+
+
+# End of file
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2010-01-25 23:25:27 UTC (rev 16175)
@@ -100,6 +100,7 @@
meshio/MeshIO.cc \
meshio/MeshIOAscii.cc \
meshio/MeshIOLagrit.cc \
+ meshio/MeshIOSieve.cc \
meshio/PsetFile.cc \
meshio/PsetFileAscii.cc \
meshio/PsetFileBinary.cc \
Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2010-01-25 23:25:27 UTC (rev 16175)
@@ -30,6 +30,8 @@
MeshIOAscii.icc \
MeshIOLagrit.hh \
MeshIOLagrit.icc \
+ MeshIOSieve.hh \
+ MeshIOSieve.icc \
OutputManager.hh \
OutputManager.cc \
OutputSolnSubset.hh \
Added: short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.cc 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "MeshIOSieve.hh" // implementation of class methods
+
+#include "petscmesh.hh"
+
+#include "MeshBuilder.hh" // USES MeshBuilder
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::meshio::MeshIOSieve::MeshIOSieve(void) :
+ _filename("")
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::meshio::MeshIOSieve::~MeshIOSieve(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+void
+pylith::meshio::MeshIOSieve::deallocate(void)
+{ // deallocate
+ MeshIO::deallocate();
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Read mesh.
+void
+pylith::meshio::MeshIOSieve::_read(void)
+{ // _read
+ MPI_Comm comm = _mesh->comm();
+ int rank = 0;
+ int meshDim = 0;
+ int spaceDim = 0;
+ int numVertices = 0;
+ int numCells = 0;
+ int numCorners = 0;
+
+
+ // :TODO: STUFF GOES HERE
+ assert(false);
+} // read
+
+// ----------------------------------------------------------------------
+// Write mesh to file.
+void
+pylith::meshio::MeshIOSieve::_write(void) const
+{ // write
+
+ ALE::MeshSerializer::writeMesh(_filename, *_mesh->sieveMesh());
+
+} // write
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.hh 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/meshio/MeshIOSieve.hh
+ *
+ * @brief C++ input/output manager for Sieve mesh files.
+ */
+
+#if !defined(pylith_meshio_meshiosieve_hh)
+#define pylith_meshio_meshiosieve_hh
+
+// Include directives ---------------------------------------------------
+#include "MeshIO.hh" // ISA MeshIO
+
+// MeshIOSieve ----------------------------------------------------------
+/// C++ input/output manager for Sieve mesh files.
+class pylith::meshio::MeshIOSieve : public MeshIO
+{ // MeshIOSieve
+ friend class TestMeshIOSieve; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ MeshIOSieve(void);
+
+ /// Destructor
+ ~MeshIOSieve(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Set filename for Sieve mesh file.
+ *
+ * @param filename Name of file
+ */
+ void filename(const char* name);
+
+ /** Get filename of Sieve mesh file.
+ *
+ * @returns Name of file
+ */
+ const char* filename(void) const;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ std::string _filename; ///< Name of file
+
+}; // MeshIOSieve
+
+#include "MeshIOSieve.icc" // inline methods
+
+#endif // pylith_meshio_meshiosieve_hh
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOSieve.icc 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_meshiosieve_hh)
+#error "MeshIOSieve.icc must be included only from MeshIOSieve.icc"
+#else
+
+// Set filename for Sieve mesh file.
+inline
+void
+pylith::meshio::MeshIOSieve::filename(const char* name) {
+ _filename = name;
+}
+
+// Get filename of Sieve mesh file.
+inline
+const char*
+pylith::meshio::MeshIOSieve::filename(void) const {
+ return _filename.c_str();
+}
+
+#endif
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh 2010-01-25 23:25:27 UTC (rev 16175)
@@ -31,6 +31,8 @@
class MeshIOAscii;
class MeshIOCubit;
class MeshIOLagrit;
+ class MeshIOSieve;
+
class GMVFile;
class GMVFileAscii;
class GMVFileBinary;
Modified: short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am 2010-01-25 23:25:27 UTC (rev 16175)
@@ -23,6 +23,7 @@
MeshIOAscii.i \
MeshIOLagrit.i \
MeshIOCubit.i \
+ MeshIOSieve.i \
VertexFilter.i \
VertexFilterVecNorm.i \
CellFilter.i \
Added: short/3D/PyLith/trunk/modulesrc/meshio/MeshIOSieve.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/MeshIOSieve.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/MeshIOSieve.i 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOSieve.i
+ *
+ * @brief Python interface to C++ MeshIOSieve object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ class MeshIOSieve : public MeshIO
+ { // MeshIOSieve
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIOSieve(void);
+
+ /// Destructor
+ ~MeshIOSieve(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Set filename for Sieve mesh file.
+ *
+ * @param filename Name of file
+ */
+ void filename(const char* name);
+
+ /** Get filename of Sieve mesh file.
+ *
+ * @returns Name of file
+ */
+ const char* filename(void) const;
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+ }; // MeshIOSieve
+
+ } // meshio
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.i 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.i 2010-01-25 23:25:27 UTC (rev 16175)
@@ -18,6 +18,7 @@
#include "pylith/meshio/MeshIO.hh"
#include "pylith/meshio/MeshIOAscii.hh"
#include "pylith/meshio/MeshIOLagrit.hh"
+#include "pylith/meshio/MeshIOSieve.hh"
#ifdef ENABLE_CUBIT
#include "pylith/meshio/MeshIOCubit.hh"
#endif
@@ -49,6 +50,7 @@
%include "MeshIOObj.i"
%include "MeshIOAscii.i"
%include "MeshIOLagrit.i"
+%include "MeshIOSieve.i"
#ifdef ENABLE_CUBIT
%include "MeshIOCubit.i"
#endif
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2010-01-25 23:23:10 UTC (rev 16174)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2010-01-25 23:25:27 UTC (rev 16175)
@@ -15,6 +15,7 @@
apps/__init__.py \
apps/PyLithApp.py \
apps/PetscApplication.py \
+ apps/PrepMeshApp.py \
bc/__init__.py \
bc/AbsorbingDampers.py \
bc/BoundaryCondition.py \
@@ -79,6 +80,7 @@
meshio/MeshIOAscii.py \
meshio/MeshIOCubit.py \
meshio/MeshIOLagrit.py \
+ meshio/MeshIOSieve.py \
meshio/OutputDirichlet.py \
meshio/OutputManager.py \
meshio/OutputManagerMesh.py \
@@ -134,6 +136,7 @@
topology/JacobianViewer.py \
topology/MeshGenerator.py \
topology/MeshImporter.py \
+ topology/MeshImporterDist.py \
topology/MeshRefiner.py \
topology/RefineUniform.py \
utils/__init__.py \
Added: short/3D/PyLith/trunk/pylith/apps/PrepMeshApp.py
===================================================================
--- short/3D/PyLith/trunk/pylith/apps/PrepMeshApp.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/apps/PrepMeshApp.py 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/apps/PrepMeshApp.py
+##
+## @brief Python pre-processing application to adjust topology of a
+## mesh and partition it before running PyLith. This alleviates the
+## need to redo these steps for every simulation when reusing the same
+## faults.
+##
+## WARNING: This preprocessing application MUST be rerun if you change
+## which faults are used in a problem.
+
+from PetscApplication import PetscApplication
+
+def faultFactory(name):
+ """
+ Factory for fault items.
+ """
+ from pyre.inventory import facility
+ from pylith.faults.FaultCohesiveKin import FaultCohesiveKin
+ return facility(name, family="fault", factory=FaultCohesiveKin)
+
+
+# PrepMeshApp class
+class PrepMeshApp(PetscApplication):
+ """
+ Python PrepMeshApp application.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li \b mesher Generates or imports the computational mesh.
+ ## @li \b writer Writer for processed mesh.
+ ## @li \b interfaces Interior surfaces with constraints or
+ ## constitutive models.
+
+ import pyre.inventory
+
+ from pylith.topology.MeshImporter import MeshImporter
+ mesher = pyre.inventory.facility("mesh_generator", family="mesh_generator",
+ factory=MeshImporter)
+ mesher.meta['tip'] = "Generates or imports the computational mesh."
+
+ from pylith.meshio.MeshIOSieve import MeshIOSieve
+ writer = pyre.inventory.facility("writer", family="mesh_io",
+ factory=MeshIOSieve)
+ writer.meta['tip'] = "Writer for processed mesh."
+
+ interfaces = pyre.inventory.facilityArray("interfaces",
+ itemFactory=faultFactory,
+ factory=EmptyBin)
+ interfaces.meta['tip'] = "Interior surfaces with constraints or " \
+ "constitutive models."
+
+ from pylith.perf.MemoryLogger import MemoryLogger
+ perfLogger = pyre.inventory.facility("perf_logger", family="perf_logger",
+ factory=MemoryLogger)
+ perfLogger.meta['tip'] = "Performance and memory logging."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="prepmeshapp"):
+ """
+ Constructor.
+ """
+ PetscApplication.__init__(self, name)
+ self._loggingPrefix = "PrepMeshApp "
+ return
+
+
+ def main(self, *args, **kwds):
+ """
+ Run the application.
+ """
+ from pylith.utils.profiling import resourceUsageString
+
+ self._debug.log(resourceUsageString())
+
+ self._setupLogging()
+
+ # Create mesh (adjust to account for interfaces (faults) if necessary)
+ self._eventLogger.stagePush("Meshing")
+ interfaces = None
+ if "interfaces" in dir(self.problem):
+ interfaces = self.problem.interfaces.components()
+ mesh = self.mesher.create(self.problem.normalizer, interfaces)
+ del interfaces
+ del self.mesher
+ self._debug.log(resourceUsageString())
+ self._eventLogger.stagePop()
+
+ self._eventLogger.stagePush("Output")
+ writer.write(mesh)
+ self._eventLogger.stagePop()
+
+
+ # Cleanup
+ self.perfLogger.logMesh('Mesh', mesh)
+ self.compilePerformanceLog()
+ if self.perfLogger.verbose:
+ self.perfLogger.show()
+
+ del mesh
+ del self.problem
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ PetscApplication._configure(self)
+ self.mesher = self.inventory.mesher
+ self.problem = self.inventory.problem
+ self.perfLogger = self.inventory.perfLogger
+
+ import journal
+ self._debug = journal.debug(self.name)
+ return
+
+ def _setupLogging(self):
+ """
+ Setup event logging.
+ """
+ from pylith.utils.EventLogger import EventLogger
+ logger = EventLogger()
+ logger.className("PyLith")
+ logger.initialize()
+
+ self._eventLogger = logger
+ return
+
+
+# End of file
Added: short/3D/PyLith/trunk/pylith/meshio/MeshIOSieve.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOSieve.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOSieve.py 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/MeshIOSieve.py
+##
+## @brief Python object for reading/writing a partitioned
+## finite-element mesh associated with the PETSc Sieve representation.
+##
+## Factory: mesh_io
+
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOSieve as ModuleMeshIOSieve
+
+# MeshIOSieve class
+class MeshIOSieve(MeshIOObj, ModuleMeshIOSieve):
+ """
+ Python object for reading/writing finite-element mesh from simple
+ ASCII file.
+
+ Factory: mesh_io
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(MeshIOObj.Inventory):
+ """
+ Python object for managing MeshIOSieve facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing MeshIOSieve facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b filename Name of mesh file
+ ##
+ ## \b Facilities
+ ## @li coordsys Coordinate system associated with mesh.
+
+ import pyre.inventory
+
+ filename = pyre.inventory.str("filename", default="")
+ filename.meta['tip'] = "Name of mesh file"
+
+ from spatialdata.geocoords.CSCart import CSCart
+ coordsys = pyre.inventory.facility("coordsys", family="coordsys",
+ factory=CSCart)
+ coordsys.meta['tip'] = "Coordinate system associated with mesh."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="meshiosieve"):
+ """
+ Constructor.
+ """
+ MeshIOObj.__init__(self, name)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ MeshIOObj._configure(self)
+ self.coordsys = self.inventory.coordsys
+ self.filename(self.inventory.filename)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create C++ MeshIOSieve object.
+ """
+ ModuleMeshIOSieve.__init__(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def mesh_io():
+ """
+ Factory associated with MeshIOSieve.
+ """
+ return MeshIOSieve()
+
+
+# End of file
Added: short/3D/PyLith/trunk/pylith/topology/MeshImporterDist.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshImporterDist.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/MeshImporterDist.py 2010-01-25 23:25:27 UTC (rev 16175)
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/MeshImporterDist.py
+##
+## @brief Python implementation of importing a mesh that is already
+## partitioned (distributed).
+##
+## Factory: mesh_generator.
+
+from MeshGenerator import MeshGenerator
+
+# MeshImporterDist class
+class MeshImporterDist(MeshGenerator):
+ """
+ Python implementation of importing a mesh.
+
+ Factory: mesh_generator.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(MeshGenerator.Inventory):
+ """
+ Python object for managing MeshImporterDist facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing MeshImporterDist facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li \b reader Mesh reader.
+ ## @li \b refiner Mesh refiner.
+
+ import pyre.inventory
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ reader = pyre.inventory.facility("reader", family="mesh_io",
+ factory=MeshIOAscii)
+ reader.meta['tip'] = "Mesh reader."
+
+ from MeshRefiner import MeshRefiner
+ refiner = pyre.inventory.facility("refiner",
+ family="mesh_refiner",
+ factory=MeshRefiner)
+ refiner.meta['tip'] = "Mesh refiner."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="meshimporter"):
+ """
+ Constructor.
+ """
+ MeshGenerator.__init__(self, name)
+ self._loggingPrefix = "MeIm "
+ return
+
+
+ def create(self, normalizer, faults=None):
+ """
+ Hook for creating mesh.
+ """
+ from pylith.utils.profiling import resourceUsageString
+
+ self._setupLogging()
+ logEvent = "%screate" % self._loggingPrefix
+ self._eventLogger.eventBegin(logEvent)
+
+ mesh = self.reader.read(self.debug, self.interpolate)
+ if self.debug:
+ mesh.view("Finite-element mesh.")
+ self._debug.log(resourceUsageString())
+
+ # refine mesh (if necessary)
+ mesh = self.refiner.refine(mesh)
+
+ # Nondimensionalize mesh (coordinates of vertices).
+ mesh.nondimensionalize(normalizer)
+
+ self._eventLogger.eventEnd(logEvent)
+ return mesh
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based on inventory.
+ """
+ MeshGenerator._configure(self)
+ self.reader = self.inventory.reader
+ self.refiner = self.inventory.refiner
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def mesh_generator():
+ """
+ Factory associated with MeshImporterDist.
+ """
+ return MeshImporterDist()
+
+
+# End of file
More information about the CIG-COMMITS
mailing list