[cig-commits] r15535 - in short/3D/PyLith/trunk: libsrc libsrc/topology modulesrc/topology pylith/topology
brad at geodynamics.org
brad at geodynamics.org
Tue Aug 11 16:02:55 PDT 2009
Author: brad
Date: 2009-08-11 16:02:54 -0700 (Tue, 11 Aug 2009)
New Revision: 15535
Added:
short/3D/PyLith/trunk/modulesrc/topology/RefineUniform.i
Removed:
short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.cc
short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.hh
Modified:
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/libsrc/topology/Makefile.am
short/3D/PyLith/trunk/libsrc/topology/RefineUniform.cc
short/3D/PyLith/trunk/libsrc/topology/RefineUniform.hh
short/3D/PyLith/trunk/modulesrc/topology/Makefile.am
short/3D/PyLith/trunk/modulesrc/topology/topology.i
short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py
short/3D/PyLith/trunk/pylith/topology/RefineUniform.py
Log:
Improved interface for uniform global mesh refinement. Added SWIG interface; updated Python.
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2009-08-11 23:02:54 UTC (rev 15535)
@@ -107,7 +107,6 @@
topology/SubMesh.cc \
topology/SolutionFields.cc \
topology/Distributor.cc \
- topology/MeshRefiner.cc \
topology/RefineUniform.cc \
utils/EventLogger.cc \
utils/TestArray.cc
Modified: short/3D/PyLith/trunk/libsrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Makefile.am 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/topology/Makefile.am 2009-08-11 23:02:54 UTC (rev 15535)
@@ -25,7 +25,6 @@
Mesh.hh \
Mesh.icc \
MeshOps.hh \
- MeshRefiner.hh \
RefineUniform.hh \
SolutionFields.hh \
SubMesh.hh \
Deleted: short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.cc 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.cc 2009-08-11 23:02:54 UTC (rev 15535)
@@ -1,30 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "MeshRefiner.hh" // implementation of class methods
-
-// ----------------------------------------------------------------------
-// Constructor
-pylith::topology::MeshRefiner::MeshRefiner(void)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor
-pylith::topology::MeshRefiner::~MeshRefiner(void)
-{ // destructor
-} // destructor
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.hh 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/topology/MeshRefiner.hh 2009-08-11 23:02:54 UTC (rev 15535)
@@ -1,64 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/topology/MeshRefiner.hh
- *
- * @brief Object for managing mesh refinement.
- */
-
-#if !defined(pylith_topology_meshrefiner_hh)
-#define pylith_topology_meshrefiner_hh
-
-// Include directives ---------------------------------------------------
-#include "topologyfwd.hh" // forward declarations
-
-// MeshRefiner ----------------------------------------------------------
-class pylith::topology::MeshRefiner
-{ // MeshRefiner
- friend class TestMeshRefiner; // unit testing
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /// Constructor
- MeshRefiner(void);
-
- /// Destructor
- virtual
- ~MeshRefiner(void);
-
- /** Refine mesh.
- *
- * @param newMesh Refined mesh (result).
- * @param mesh Mesh to refine.
- * @param levels Number of levels to refine.
- * @param fields Solution fields.
- */
- virtual
- void refine(Mesh* const newMesh,
- const Mesh& mesh,
- const int levels =1,
- const SolutionFields* fields =0) = 0;
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- MeshRefiner(const MeshRefiner&); ///< Not implemented
- const MeshRefiner& operator=(const MeshRefiner&); ///< Not implemented
-
-}; // MeshRefiner
-
-#endif // pylith_topology_meshrefiner_hh
-
-
-// End of file
Modified: short/3D/PyLith/trunk/libsrc/topology/RefineUniform.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/RefineUniform.cc 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/topology/RefineUniform.cc 2009-08-11 23:02:54 UTC (rev 15535)
@@ -54,8 +54,7 @@
void
pylith::topology::RefineUniform::refine(Mesh* const newMesh,
const Mesh& mesh,
- const int levels,
- const SolutionFields* fields)
+ const int levels)
{ // refine
assert(0 != newMesh);
@@ -110,7 +109,7 @@
std::map<edge_type, point_type> edge2vertex;
newSieveMesh->setSieve(newSieve);
- ALE::MeshBuilder<Mesh>::refineTetrahedra(*mesh.sieveMesh(), *newSieveMesh,
+ ALE::MeshBuilder<Mesh>::refineTetrahedra(*mesh.sieveMesh(), * newSieveMesh,
edge2vertex);
// Fix material ids
Modified: short/3D/PyLith/trunk/libsrc/topology/RefineUniform.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/RefineUniform.hh 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/libsrc/topology/RefineUniform.hh 2009-08-11 23:02:54 UTC (rev 15535)
@@ -20,10 +20,10 @@
#define pylith_topology_refineuniform_hh
// Include directives ---------------------------------------------------
-#include "MeshRefiner.hh" // ISA MeshRefiner
+#include "topologyfwd.hh" // forward declarations
// RefineUniform --------------------------------------------------------
-class pylith::topology::RefineUniform : public MeshRefiner
+class pylith::topology::RefineUniform
{ // RefineUniform
friend class TestRefineUniform; // unit testing
@@ -41,12 +41,10 @@
* @param newMesh Refined mesh (result).
* @param mesh Mesh to refine.
* @param levels Number of levels to refine.
- * @param fields Solution fields.
*/
void refine(Mesh* const newMesh,
const Mesh& mesh,
- const int levels =1,
- const SolutionFields* fields =0);
+ const int levels =2);
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
@@ -59,7 +57,7 @@
*/
void _refineTet4(Mesh* const newMesh,
const Mesh& mesh,
- const int levels =1);
+ const int levels =2);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
@@ -71,5 +69,5 @@
#endif // pylith_topology_refineuniform_hh
-
+
// End of file
Modified: short/3D/PyLith/trunk/modulesrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Makefile.am 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/modulesrc/topology/Makefile.am 2009-08-11 23:02:54 UTC (rev 15535)
@@ -27,7 +27,8 @@
Fields.i \
SolutionFields.i \
Jacobian.i \
- Distributor.i
+ Distributor.i \
+ RefineUniform.i
swig_generated = \
topology_wrap.cxx \
Added: short/3D/PyLith/trunk/modulesrc/topology/RefineUniform.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/RefineUniform.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/RefineUniform.i 2009-08-11 23:02:54 UTC (rev 15535)
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/RefineUniform.hh
+ *
+ * @brief Python interface to C++ PyLith RefineUniform object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ // RefineUniform ----------------------------------------------------
+ class pylith::topology::RefineUniform
+ { // RefineUniform
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ RefineUniform(void);
+
+ /// Destructor
+ ~RefineUniform(void);
+
+ /** Refine mesh.
+ *
+ * @param newMesh Refined mesh (result).
+ * @param mesh Mesh to refine.
+ * @param levels Number of levels to refine.
+ */
+ void refine(Mesh* const newMesh,
+ const Mesh& mesh,
+ const int levels =1);
+
+ }; // RefineUniform
+
+ } // topology
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.i 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.i 2009-08-11 23:02:54 UTC (rev 15535)
@@ -24,6 +24,7 @@
#include "pylith/topology/SolutionFields.hh"
#include "pylith/topology/Jacobian.hh"
#include "pylith/topology/Distributor.hh"
+#include "pylith/topology/RefineUniform.hh"
%}
%include "exception.i"
@@ -58,6 +59,7 @@
%include "SolutionFields.i"
%include "Jacobian.i"
%include "Distributor.i"
+%include "RefineUniform.i"
// Template instatiation
%template(MeshField) pylith::topology::Field<pylith::topology::Mesh>;
Modified: short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py 2009-08-11 23:02:54 UTC (rev 15535)
@@ -26,30 +26,6 @@
Factory: mesh_refiner
"""
- class Inventory(PetscComponent.Inventory):
- """
- Python object for managing RefineUniform facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing RefineUniform facilities and properties.
- ##
- ## \b Properties
- ## @li \b debug Write partition information to file.
- ##
- ## \b Facilities
- ## @li \b writer Data writer for for partition information.
-
- import pyre.inventory
-
- debug = pyre.inventory.bool("debug", default=False)
- debug.meta['tip'] = "Write partition information to file."
-
- from pylith.meshio.DataWriterVTK import DataWriterVTK
- dataWriter = pyre.inventory.facility("data_writer", factory=DataWriterVTK,
- family="output_data_writer")
- dataWriter.meta['tip'] = "Data writer for partition information."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="refiner"):
@@ -57,7 +33,6 @@
Constructor.
"""
PetscComponent.__init__(self, name, facility="refiner")
- self.cppHandle = None
return
@@ -65,6 +40,11 @@
"""
Refine mesh.
"""
+ self._setupLogging()
+ logEvent = "%srefine" % self._loggingPrefix
+ self._eventLogger.eventBegin(logEvent)
+
+ self._eventLogger.eventEnd(logEvent)
return mesh
@@ -75,19 +55,9 @@
Set members based using inventory.
"""
PetscComponent._configure(self)
- self.debug = self.inventory.debug
- self.dataWriter = self.inventory.dataWriter
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- raise NotImplementedError("Please implement _createCppHandle().");
- return
-
-
def _setupLogging(self):
"""
Setup event logging.
@@ -105,13 +75,4 @@
return
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def mesh_refiner():
- """
- Factory associated with MeshRefiner.
- """
- return MeshRefiner()
-
-
# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/RefineUniform.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/RefineUniform.py 2009-08-11 23:02:00 UTC (rev 15534)
+++ short/3D/PyLith/trunk/pylith/topology/RefineUniform.py 2009-08-11 23:02:54 UTC (rev 15535)
@@ -18,9 +18,10 @@
## Factory: mesh_refiner.
from MeshRefiner import MeshRefiner
+from topology import RefineUniform as ModuleRefineUniform
# RefineUniform class
-class RefineUniform(MeshRefiner):
+class RefineUniform(MeshRefiner, ModuleRefineUniform):
"""
Python manager for uniform global refinement of mesh in parallel.
@@ -29,27 +30,13 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(MeshRefiner.Inventory):
- """
- Python object for managing RefineUniform facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing RefineUniform facilities and properties.
- ##
- ## \b Properties
- ## @li \b levels Number of refinement levels.
- ##
- ## \b Facilities
- ## @li None
+ levels = pyre.inventory.int("levels", default=2,
+ validator=pyre.inventory.choice([2, 4]))
+ levels.meta['tip'] = "Number of refinement levels."
- import pyre.inventory
- levels = pyre.inventory.int("levels", default=2,
- validator=pyre.inventory.choice([2, 4]))
- levels.meta['tip'] = "Number of refinement levels."
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="refineuniform"):
@@ -57,6 +44,7 @@
Constructor.
"""
MeshRefiner.__init__(self, name)
+ self._createModuleObj(self)
return
@@ -67,22 +55,16 @@
self._setupLogging()
logEvent = "%srefine" % self._loggingPrefix
self._eventLogger.eventBegin(logEvent)
- self._info.log("Refining mesh.")
- self._createCppHandle()
-
from Mesh import Mesh
- newMesh = Mesh()
- assert(None != self.cppHandle)
- newMesh.cppHandle = self.cppHandle.refine(mesh.cppHandle,
- self.levels)
- newMesh.coordsys = mesh.coordsys
+ newMesh = Mesh(mesh.comm(), mesh.debug())
+ newMesh.debug(mesh.debug())
+ newMesh.coordsys(mesh.coordsys)
+ if fields is None:
+ ModuleRefineUniform.refine(self, newMesh, mesh, self.levels)
+ else:
+ ModuleRefineUniform.refine(self, meshMesh, mesh, self.levels, fields)
- if self.debug:
- self.dataWriter.initialize()
- self.cppHandle.write(self.dataWriter.cppHandle,
- newMesh.cppHandle, newMesh.coordsys.cppHandle)
-
self._eventLogger.eventEnd(logEvent)
return newMesh
@@ -98,13 +80,11 @@
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to C++ object.
"""
- if None == self.cppHandle:
- import pylith.topology.topology as bindings
- self.cppHandle = bindings.RefineUniform()
+ ModuleRefineUniform.__init__(self)
return
More information about the CIG-COMMITS
mailing list