[cig-commits] r21507 - short/3D/PyLith/trunk/libsrc/pylith/topology
brad at geodynamics.org
brad at geodynamics.org
Tue Mar 12 11:36:56 PDT 2013
Author: brad
Date: 2013-03-12 11:36:55 -0700 (Tue, 12 Mar 2013)
New Revision: 21507
Added:
short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.icc
short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.icc
short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.icc
short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.icc
Removed:
short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.icc
Modified:
short/3D/PyLith/trunk/libsrc/pylith/topology/Makefile.am
Log:
Improved visitors. Added Stratum helper class.
Deleted: short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.hh 2013-03-12 11:39:38 UTC (rev 21506)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.hh 2013-03-12 18:36:55 UTC (rev 21507)
@@ -1,128 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard, U.S. Geological Survey
-// Charles A. Williams, GNS Science
-// Matthew G. Knepley, University of Chicago
-//
-// This code was developed as part of the Computational Infrastructure
-// for Geodynamics (http://geodynamics.org).
-//
-// Copyright (c) 2010-2012 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-/**
- * @file libsrc/topology/MeshCoords.hh
- *
- * @brief C++ helper class for accessing coordinates in a finite-element mesh.
- */
-
-#if !defined(pylith_topology_coordinates_hh)
-#define pylith_topology_coordinates_hh
-
-// Include directives ---------------------------------------------------
-#include "topologyfwd.hh" // forward declarations
-
-#include "pylith/utils/petscfwd.h" // HASA PetscVec, PetscSection
-
-#include <petscdmmesh.hh>
-
-// Coordinates ----------------------------------------------------------
-/** @brief Helper class for accessing coordinates in a finite-element mesh.
- */
-template<typename mesh_type>
-class pylith::topology::Coordinates
-{ // MeshCoords
- friend class TestCoordinates; // unit testing
-
-// PUBLIC METHODS ///////////////////////////////////////////////////////
-public :
-
- /// Default constructor.
- Coordinates(const mesh_type& mesh);
-
- /// Default destructor
- ~Coordinates(void);
-
- /** Get the local coordinates array associated with the local PETSc Vec.
- *
- * Must call restoreLocalArray() afterwards.
- *
- * @returns Local array.
- */
- PetscScalar* getLocalArray(void) const;
-
- /** Restore local coordinates array associated with the local PETSc Vec.
- *
- * @preq Must be preceded by call to getLocalArray().
- *
- * @param a Local array.
- */
- void restoreLocalArray(PetscScalar** a) const;
-
- /** Get fiber dimension of coordinates for point.
- *
- * @preq Must call cacheSection().
- *
- * @param point Point in mesh.
- * @returns Fiber dimension.
- */
- PetscInt sectionDof(const PetscInt point) const;
-
- /** Get offset into coordinates array for point.
- *
- * @preq Must call cacheSection().
- *
- * @param point Point in mesh.
- * @returns Offset.
- */
- PetscInt sectionOffset(const PetscInt point) const;
-
- /** Get coordinates array associated with closure.
- *
- * @param coordsCell Array of coordinates for cell.
- * @param coordsSize Size of coordinates array.
- * @param cell Finite-element cell.
- */
- void getClosure(PetscScalar** coordsCell,
- PetscInt* coordsSize,
- const PetscInt cell) const;
-
- /** Restore coordinates array associated with closure.
- *
- * @param coordsCell Array of coordinates for cell.
- * @param coordsSize Size of coordinates array.
- * @param cell Finite-element cell.
- */
- void restoreClosure(PetscScalar** coordsCell,
- PetscInt* coordsSize,
- const PetscInt cell) const;
-
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
-
- const mesh_type& _mesh;
-
- PetscDM _dm; ///< Cached PETSc dm for mesh.
- PetscVec _localVec; ///< Cached local PETSc Vec.
- PetscSection _section; ///< Cached PETSc section.
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- Coordinates(const Coordinates&); ///< Not implemented
- const Coordinates& operator=(const Coordinates&); ///< Not implemented
-
-}; // Coordinates
-
-#include "Coordinates.icc"
-
-#endif // pylith_topology_coordinates_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.icc 2013-03-12 11:39:38 UTC (rev 21506)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.icc 2013-03-12 18:36:55 UTC (rev 21507)
@@ -1,137 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard, U.S. Geological Survey
-// Charles A. Williams, GNS Science
-// Matthew G. Knepley, University of Chicago
-//
-// This code was developed as part of the Computational Infrastructure
-// for Geodynamics (http://geodynamics.org).
-//
-// Copyright (c) 2010-2011 University of California, Davis
-//
-// See COPYING for license information.
-//
-// ======================================================================
-//
-
-#if !defined(pylith_topology_coordinates_hh)
-#error "Mesh.icc must be included only from Coordinates.hh"
-#else
-
-#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
-
-// ----------------------------------------------------------------------
-// Default constructor.
-template<typename mesh_type>
-inline
-pylith::topology::Coordinates<mesh_type>::Coordinates(const mesh_type& mesh) :
- _mesh(mesh)
-{ // constructor
- _dm = mesh.dmMesh();assert(_dm);
- PetscErrorCode err;
- err = DMPlexGetCoordinateSection(_dm, &_section);CHECK_PETSC_ERROR(err);
- err = DMGetCoordinatesLocal(_dm, &_localVec);CHECK_PETSC_ERROR(err);
-} // constructor
-
-// ----------------------------------------------------------------------
-// Default destructor
-template<typename mesh_type>
-inline
-pylith::topology::Coordinates<mesh_type>::~Coordinates(void)
-{ // destructor
- _localVec = NULL;
- _section = NULL;
-} // destructor
-
-// ----------------------------------------------------------------------
-// Get the local coordinates array associated with the local PETSc Vec.
-template<typename mesh_type>
-inline
-PetscScalar*
-pylith::topology::Coordinates<mesh_type>::getLocalArray(void) const
-{ // getLocalArray
- assert(_dm);
- assert(_localVec);
-
- PetscScalar* coordsArray = NULL;
- PetscErrorCode err;
- err = DMGetCoordinatesLocal(_dm, &_localVec);CHECK_PETSC_ERROR(err);
- err = VecGetArray(_localVec, &coordsArray);CHECK_PETSC_ERROR(err);
- return coordsArray;
-} // getLocalArray
-
-// ----------------------------------------------------------------------
-// Restore local coordinates array associated with the local PETSc Vec.
-template<typename mesh_type>
-inline
-void
-pylith::topology::Coordinates<mesh_type>::restoreLocalArray(PetscScalar** a) const
-{ // restoreLocalArray
- PetscErrorCode err = VecRestoreArray(_localVec, a);CHECK_PETSC_ERROR(err);
-} // restoreLocalArray
-
-// ----------------------------------------------------------------------
-// Get fiber dimension of coordinates for point.
-template<typename mesh_type>
-inline
-PetscInt
-pylith::topology::Coordinates<mesh_type>::sectionDof(const PetscInt point) const
-{ // sectionDof
- assert(_section);
- PetscInt dof;
- PetscErrorCode err = PetscSectionGetDof(_section, point, &dof);CHECK_PETSC_ERROR(err);
- return dof;
-} // sectionDof
-
-// ----------------------------------------------------------------------
-// Get offset into coordinates array for point.
-template<typename mesh_type>
-inline
-PetscInt
-pylith::topology::Coordinates<mesh_type>::sectionOffset(const PetscInt point) const
-{ // sectionOffset
- assert(_section);
- PetscInt offset;
- PetscErrorCode err = PetscSectionGetOffset(_section, point, &offset);CHECK_PETSC_ERROR(err);
- return offset;
-} // sectionOffset
-
-// ----------------------------------------------------------------------
-// Get coordinates array associated with closure.
-template<typename mesh_type>
-void
-pylith::topology::Coordinates<mesh_type>::getClosure(PetscScalar** coordsCell,
- PetscInt* coordsSize,
- const PetscInt cell) const
-{ // getClosure
- assert(_dm);
- assert(_section);
- assert(_localVec);
- PetscErrorCode err = DMPlexVecGetClosure(_dm, _section, _localVec, cell, coordsSize, coordsCell);CHECK_PETSC_ERROR(err);
-} // getClosure
-
-// ----------------------------------------------------------------------
- /** Restore coordinates array associated with closure.
- *
- * @param coordsCell Array of coordinates for cell.
- * @param coordsSize Size of coordinates array.
- * @param cell Finite-element cell.
- */
-template<typename mesh_type>
-void
-pylith::topology::Coordinates<mesh_type>::restoreClosure(PetscScalar** coordsCell,
- PetscInt* coordsSize,
- const PetscInt cell) const
-{ // restoreClosure
- assert(_dm);
- assert(_section);
- assert(_localVec);
- PetscErrorCode err = DMPlexVecRestoreClosure(_dm, _section, _localVec, cell, coordsSize, coordsCell);CHECK_PETSC_ERROR(err);
-} // restoreClosure
-
-#endif
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.hh (from rev 21503, short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.hh 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2012 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/CoordsVisitor.hh
+ *
+ * @brief C++ helper class for accessing coordinates in a finite-element mesh.
+ */
+
+#if !defined(pylith_topology_coordsvisitor_hh)
+#define pylith_topology_coordsvisitor_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/utils/petscfwd.h" // HASA PetscVec, PetscSection
+
+#include <petscdmmesh.hh>
+
+// CoordsVisitor ----------------------------------------------------------
+/** @brief Helper class for accessing coordinates in a finite-element mesh.
+ */
+template<typename mesh_type>
+class pylith::topology::CoordsVisitor
+{ // CoordsVisitor
+ friend class TestCoordsVisitor; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Default constructor (includes initialization).
+ CoordsVisitor(const mesh_type& mesh);
+
+ /// Default destructor
+ ~CoordsVisitor(void);
+
+ /// Initialize cached data.
+ void initialize(void);
+
+ /// Clear cached data.
+ void clear(void);
+
+ /** Get the local coordinates array associated with the local PETSc Vec.
+ *
+ * @returns Local array.
+ */
+ PetscScalar* localArray(void) const;
+
+ /** Get fiber dimension of coordinates for point.
+ *
+ * @param point Point in mesh.
+ * @returns Fiber dimension.
+ */
+ PetscInt sectionDof(const PetscInt point) const;
+
+ /** Get offset into coordinates array for point.
+ *
+ * @param point Point in mesh.
+ * @returns Offset.
+ */
+ PetscInt sectionOffset(const PetscInt point) const;
+
+ /** Get coordinates array associated with closure.
+ *
+ * @param coordsCell Array of coordinates for cell.
+ * @param coordsSize Size of coordinates array.
+ * @param cell Finite-element cell.
+ */
+ void getClosure(PetscScalar** coordsCell,
+ PetscInt* coordsSize,
+ const PetscInt cell) const;
+
+ /** Restore coordinates array associated with closure.
+ *
+ * @param coordsCell Array of coordinates for cell.
+ * @param coordsSize Size of coordinates array.
+ * @param cell Finite-element cell.
+ */
+ void restoreClosure(PetscScalar** coordsCell,
+ PetscInt* coordsSize,
+ const PetscInt cell) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ const mesh_type& _mesh;
+
+ PetscDM _dm; ///< Cached PETSc dm for mesh.
+ PetscVec _localVec; ///< Cached local PETSc Vec.
+ PetscSection _section; ///< Cached PETSc section.
+ PetscScalar* _localArray; ///< Cached local array.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ CoordsVisitor(const CoordsVisitor&); ///< Not implemented
+ const CoordsVisitor& operator=(const CoordsVisitor&); ///< Not implemented
+
+}; // CoordsVisitor
+
+#include "CoordsVisitor.icc"
+
+#endif // pylith_topology_coordsvisitor_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.icc (from rev 21503, short/3D/PyLith/trunk/libsrc/pylith/topology/Coordinates.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/CoordsVisitor.icc 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_coordsvisitor_hh)
+#error "CoordsVisitor.icc must be included only from CoordsVisitor.hh"
+#else
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename mesh_type>
+inline
+pylith::topology::CoordsVisitor<mesh_type>::CoordsVisitor(const mesh_type& mesh) :
+ _mesh(mesh),
+ _section(NULL),
+ _localVec(NULL),
+ _localArray(NULL)
+{ // constructor
+ _dm = mesh.dmMesh();assert(_dm);
+ PetscErrorCode err;
+ err = DMPlexGetCoordinateSection(_dm, &_section);CHECK_PETSC_ERROR(err);assert(_section);
+ err = DMGetCoordinatesLocal(_dm, &_localVec);CHECK_PETSC_ERROR(err);assert(_localVec);
+ err = VecGetArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);assert(_localArray);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename mesh_type>
+inline
+pylith::topology::CoordsVisitor<mesh_type>::~CoordsVisitor(void)
+{ // destructor
+ if (_localArray) {
+ assert(_localVec);
+ PetscErrorCode err = VecRestoreArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);
+ } // if
+
+ _localVec = NULL;
+ _section = NULL;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Get the local coordinates array associated with the local PETSc Vec.
+template<typename mesh_type>
+inline
+PetscScalar*
+pylith::topology::CoordsVisitor<mesh_type>::localArray(void) const
+{ // localArray
+ return _localArray;
+} // localArray
+
+// ----------------------------------------------------------------------
+// Get fiber dimension of coordinates for point.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::CoordsVisitor<mesh_type>::sectionDof(const PetscInt point) const
+{ // sectionDof
+ assert(_section);
+ PetscInt dof;
+ PetscErrorCode err = PetscSectionGetDof(_section, point, &dof);CHECK_PETSC_ERROR(err);
+ return dof;
+} // sectionDof
+
+// ----------------------------------------------------------------------
+// Get offset into coordinates array for point.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::CoordsVisitor<mesh_type>::sectionOffset(const PetscInt point) const
+{ // sectionOffset
+ assert(_section);
+ PetscInt offset;
+ PetscErrorCode err = PetscSectionGetOffset(_section, point, &offset);CHECK_PETSC_ERROR(err);
+ return offset;
+} // sectionOffset
+
+// ----------------------------------------------------------------------
+// Get coordinates array associated with closure.
+template<typename mesh_type>
+void
+pylith::topology::CoordsVisitor<mesh_type>::getClosure(PetscScalar** coordsCell,
+ PetscInt* coordsSize,
+ const PetscInt cell) const
+{ // getClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecGetClosure(_dm, _section, _localVec, cell, coordsSize, coordsCell);CHECK_PETSC_ERROR(err);
+} // getClosure
+
+// ----------------------------------------------------------------------
+ /** Restore coordinates array associated with closure.
+ *
+ * @param coordsCell Array of coordinates for cell.
+ * @param coordsSize Size of coordinates array.
+ * @param cell Finite-element cell.
+ */
+template<typename mesh_type>
+void
+pylith::topology::CoordsVisitor<mesh_type>::restoreClosure(PetscScalar** coordsCell,
+ PetscInt* coordsSize,
+ const PetscInt cell) const
+{ // restoreClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecRestoreClosure(_dm, _section, _localVec, cell, coordsSize, coordsCell);CHECK_PETSC_ERROR(err);
+} // restoreClosure
+
+#endif
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Makefile.am 2013-03-12 11:39:38 UTC (rev 21506)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Makefile.am 2013-03-12 18:36:55 UTC (rev 21507)
@@ -20,8 +20,8 @@
include $(top_srcdir)/subpackage.am
subpkginclude_HEADERS = \
- Coordinates.hh \
- Coordinates.icc \
+ CoordsVisitor.hh \
+ CoordsVisitor.icc \
Distributor.hh \
FieldBase.hh \
Field.hh \
@@ -36,12 +36,18 @@
Mesh.hh \
Mesh.icc \
MeshOps.hh \
+ MeshVisitor.hh \
+ MeshVisitor.icc \
RefineUniform.hh \
ReverseCuthillMcKee.hh \
SolutionFields.hh \
+ Stratum.hh \
+ Stratum.icc \
SubMesh.hh \
SubMesh.icc \
SubMesh.cc \
+ SubMeshVisitor.hh \
+ SubMeshVisitor.icc \
ISectionSpaces.hh \
ISectionSpaces.cc \
topologyfwd.hh
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.hh 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,151 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2012 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/MeshVisitor.hh
+ *
+ * @brief C++ helper class for accessing field values at points in a
+ * finite-element mesh.
+ */
+
+#if !defined(pylith_topology_meshvisitor_hh)
+#define pylith_topology_meshvisitor_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/utils/petscfwd.h" // HASA PetscVec, PetscSection
+
+#include <petscdmmesh.hh>
+
+// MeshVisitor ----------------------------------------------------------
+/** @brief Helper class for accessing field values at points in a
+ * finite-element mesh.
+ */
+template<typename field_type>
+class pylith::topology::MeshVisitor
+{ // MeshVisitor
+ friend class TestMeshVisitor; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ MeshVisitor(const field_type& field);
+
+ /// Default destructor
+ ~MeshVisitor(void);
+
+ /// Initialize cached data.
+ void initialize(void);
+
+ /// Clear cached data.
+ void clear(void);
+
+ /** Get the array of values associated with the local PETSc Vec.
+ *
+ * @returns Array of values.
+ */
+ PetscScalar* localArray(void) const;
+
+ /** Get the PETSc section.
+ *
+ * @returns PETSc section.
+ */
+ PetscSection petscSection(void) const;
+
+ /** Get the local PETSc Vec.
+ *
+ * @returns PETSc Vec.
+ */
+ PetscVec localVec(void) const;
+
+ /** Get fiber dimension of coordinates for point.
+ *
+ * @param point Point in mesh.
+ * @returns Fiber dimension.
+ */
+ PetscInt sectionDof(const PetscInt point) const;
+
+ /** Get offset into coordinates array for point.
+ *
+ * @param point Point in mesh.
+ * @returns Offset.
+ */
+ PetscInt sectionOffset(const PetscInt point) const;
+
+ /** Get array of values associated with closure.
+ *
+ * @pre Must be followed by call to getClosure().
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ */
+ void getClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const;
+
+ /** Restore array of values associated with closure.
+ *
+ * @pre Must be preceded by call to getClosure().
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ */
+ void restoreClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const;
+
+ /** Set values associated with closure.
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ * @param mode Mode for inserting values.
+ */
+ void setClosure(const PetscScalar* valuesCell,
+ const PetscInt valuesSize,
+ const PetscInt cell,
+ const InsertMode mode) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ const field_type& _field;
+
+ PetscDM _dm; ///< Cached PETSc dm for mesh.
+ PetscVec _localVec; ///< Cached local PETSc Vec.
+ PetscSection _section; ///< Cached PETSc section.
+ PetscScalar* _localArray; ///< Cached local array
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ MeshVisitor(const MeshVisitor&); ///< Not implemented
+ const MeshVisitor& operator=(const MeshVisitor&); ///< Not implemented
+
+}; // MeshVisitor
+
+#include "MeshVisitor.icc"
+
+#endif // pylith_topology_meshvisitor_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/MeshVisitor.icc 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,161 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_meshvisitor_hh)
+#error "MeshVisitor.icc must be included only from MeshVisitor.hh"
+#else
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename field_type>
+inline
+pylith::topology::MeshVisitor<field_type>::MeshVisitor(const field_type& field) :
+ _field(field)
+{ // constructor
+ initialize();
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename field_type>
+inline
+pylith::topology::MeshVisitor<field_type>::~MeshVisitor(void)
+{ // destructor
+ clear();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialized cached data members.
+template<typename field_type>
+inline
+void
+pylith::topology::MeshVisitor<field_type>::initialize(void)
+{ // initialize
+ _dm = _field.mesh().dmMesh();assert(_dm);
+ _section = _field.petscSection();assert(_section);
+ _localVec = _field.localVector();assert(_localVec);
+
+ PetscErrorCode err = VecGetArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);
+} // initialize
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename field_type>
+inline
+void
+pylith::topology::MeshVisitor<field_type>::clear(void)
+{ // clear
+ assert(_localVec);
+ PetscErrorCode err = VecRestoreArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);
+ assert(!_localArray);
+
+ _dm = NULL;
+ _section = NULL;
+ _localVec = NULL;
+} // clear
+
+// ----------------------------------------------------------------------
+// Get the local coordinates array associated with the local PETSc Vec.
+template<typename field_type>
+inline
+PetscScalar*
+pylith::topology::MeshVisitor<field_type>::localArray(void) const
+{ // localArray
+ return _localArray;
+} // localArray
+
+// ----------------------------------------------------------------------
+// Get fiber dimension of coordinates for point.
+template<typename field_type>
+inline
+PetscInt
+pylith::topology::MeshVisitor<field_type>::sectionDof(const PetscInt point) const
+{ // sectionDof
+ assert(_section);
+ PetscInt dof;
+ PetscErrorCode err = PetscSectionGetDof(_section, point, &dof);CHECK_PETSC_ERROR(err);
+ return dof;
+} // sectionDof
+
+// ----------------------------------------------------------------------
+// Get offset into coordinates array for point.
+template<typename field_type>
+inline
+PetscInt
+pylith::topology::MeshVisitor<field_type>::sectionOffset(const PetscInt point) const
+{ // sectionOffset
+ assert(_section);
+ PetscInt offset;
+ PetscErrorCode err = PetscSectionGetOffset(_section, point, &offset);CHECK_PETSC_ERROR(err);
+ return offset;
+} // sectionOffset
+
+// ----------------------------------------------------------------------
+// Get coordinates array associated with closure.
+template<typename field_type>
+void
+pylith::topology::MeshVisitor<field_type>::getClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const
+{ // getClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecGetClosure(_dm, _section, _localVec, cell, valuesSize, valuesCell);CHECK_PETSC_ERROR(err);
+} // getClosure
+
+// ----------------------------------------------------------------------
+/** Restore coordinates array associated with closure.
+ *
+ * @param coordsCell Array of coordinates for cell.
+ * @param coordsSize Size of coordinates array.
+ * @param cell Finite-element cell.
+ */
+template<typename field_type>
+void
+pylith::topology::MeshVisitor<field_type>::restoreClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const
+{ // restoreClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecRestoreClosure(_dm, _section, _localVec, cell, valuesSize, valuesCell);CHECK_PETSC_ERROR(err);
+} // restoreClosure
+
+// ----------------------------------------------------------------------
+// Set values associated with closure.
+template<typename field_type>
+void
+pylith::topology::MeshVisitor<field_type>::setClosure(const PetscScalar* valuesCell,
+ const PetscInt valuesSize,
+ const PetscInt cell,
+ const InsertMode mode) const
+{ // setClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecSetClosure(_dm, _section, _localVec, cell, valuesCell, mode);CHECK_PETSC_ERROR(err);
+} // setClosure
+
+#endif
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.hh 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,147 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2012 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Stratum.hh
+ *
+ * @brief C++ helper classes for accessing statum related information in
+ * a finite-element mesh.
+ */
+
+#if !defined(pylith_topology_stratum_hh)
+#define pylith_topology_stratum_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/utils/petscfwd.h" // HASA PetscDM, PetscIS
+
+#include <petscdmmesh.hh>
+
+// Stratum --------------------------------------------------------
+/// Height or depth stratum.
+template<typename mesh_type>
+class pylith::topology::Stratum
+{ // Stratum
+ friend class TestStratum; // unit testing
+
+// PUBLIC ENUMS /////////////////////////////////////////////////////////
+public :
+
+ /// Type of stratum (height or depth).
+ enum StratumEnum {
+ HEIGHT=0,
+ DEPTH=1,
+ }; // StratumEnum
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ * @param stype Type of stratum [HEIGHT, DEPTH].
+ * @param level Height of depth of stratum.
+ */
+ Stratum(const mesh_type& mesh,
+ const StratumEnum stype,
+ const int level);
+
+ /// Default destructor.
+ ~Stratum(void);
+
+ /** Get starting point.
+ *
+ * @return Index of starting point.
+ */
+ PetscInt begin(void) const;
+
+ /** Get ending point.
+ *
+ * @return Index of ending point.
+ */
+ PetscInt end(void) const;
+
+ /** Get number of points in stratum.
+ *
+ * @return Number of points.
+ */
+ PetscInt size(void) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ PetscInt _begin; ///< Starting point.
+ PetscInt _end; ///< End point.
+
+}; // HeightStratum
+
+
+// StratumIS ------------------------------------------------------------
+/// Index set associated with stratum (usually over label of points).
+template<typename mesh_type>
+class pylith::topology::StratumIS
+{ // StratumIS
+ friend class TestStratumIS; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ * @param label Label for stratum.
+ * @param id Value of label defining stratum.
+ */
+ StratumIS(const mesh_type& mesh,
+ const char* label,
+ const int id);
+
+ /// Default destructor.
+ ~StratumIS(void);
+
+ /// Deallocate data.
+ void deallocate(void);
+
+ /** Get array of points.
+ *
+ * @return Array of points.
+ */
+ const PetscInt* points(void) const;
+
+ /** Get number of points in index set.
+ *
+ * @return Number of points.
+ */
+ PetscInt size(void) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ PetscIS _indexSet; ///< PETSc index set.
+ PetscInt _size; ///< Size of index set.
+ const PetscInt* _points; ///< Array of points in index set.
+
+}; // StratumIS
+
+#include "Stratum.icc"
+
+#endif // pylith_topology_stratum_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Stratum.icc 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,151 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_stratum_hh)
+#error "Stratum.icc must be included only from Stratum.hh"
+#else
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename mesh_type>
+inline
+pylith::topology::Stratum<mesh_type>::Stratum(const mesh_type& mesh,
+ const StratumEnum stype,
+ const int level)
+{ // constructor
+ PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
+ PetscErrorCode err = 0;
+ switch(stype) {
+ case HEIGHT:
+ err = DMPlexGetHeightStratum(dmMesh, level, &_begin, &_end);CHECK_PETSC_ERROR(err);
+ break;
+ case DEPTH:
+ err = DMPlexGetDepthStratum(dmMesh, level, &_begin, &_end);CHECK_PETSC_ERROR(err);
+ break;
+ default:
+ assert(false);
+ throw std::logic_error("Unknown case in Stratum constructor.");
+ } // switch
+ assert(_end >= _begin);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename mesh_type>
+inline
+pylith::topology::Stratum<mesh_type>::~Stratum(void)
+{ // destructor
+ _begin = 0;
+ _end = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Get starting point.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::Stratum<mesh_type>::begin(void) const
+{ // begin
+ return _begin;
+} // begin
+
+// ----------------------------------------------------------------------
+// Get ending point.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::Stratum<mesh_type>::end(void) const
+{ // end
+ return _end;
+} // end
+
+// ----------------------------------------------------------------------
+// Get number of points in stratum.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::Stratum<mesh_type>::size(void) const
+{ // size
+ return _end-_begin;
+} // size
+
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename mesh_type>
+inline
+pylith::topology::StratumIS<mesh_type>::StratumIS(const mesh_type& mesh,
+ const char* label,
+ const int id)
+{ // constructor
+ PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
+ PetscErrorCode err;
+ err = DMPlexGetStratumIS(dmMesh, label, id, &_indexSet);CHECK_PETSC_ERROR(err);assert(_indexSet);
+ err = ISGetSize(_indexSet, &_size);CHECK_PETSC_ERROR(err);assert(size >= 0);
+ err = ISGetIndices(_indexSet, &_points);CHECK_PETSC_ERROR(err);assert(points);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor.
+template<typename mesh_type>
+inline
+pylith::topology::StratumIS<mesh_type>::~StratumIS(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc data structures.
+template<typename mesh_type>
+inline
+void
+pylith::topology::StratumIS<mesh_type>::deallocate(void)
+{ // deallocate
+ PetscErrorCode err = 0;
+ err = ISRestoreIndices(_indexSet, &_points);CHECK_PETSC_ERROR(err);assert(!_points);
+ err = ISDestroy(&_indexSet);CHECK_PETSC_ERROR(err);assert(!_indexSet);
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Get array of points.
+template<typename mesh_type>
+inline
+const PetscInt*
+pylith::topology::StratumIS<mesh_type>::points(void) const
+{ // points
+ return _points;
+} // points
+
+// ----------------------------------------------------------------------
+// Get number of points in index set.
+template<typename mesh_type>
+inline
+PetscInt
+pylith::topology::StratumIS<mesh_type>::size(void) const
+{ // size
+ return _size;
+} // size
+
+
+
+#endif
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.hh 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,206 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2012 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/SubMeshVisitor.hh
+ *
+ * @brief C++ helper class for accessing field values at points in a
+ * submesh within a finite-element mesh.
+ *
+ * This visitor is used to access values associated with a submesh
+ * when the field is defined over the entire mesh. This is why a
+ * submesh and index set are passed to the constructor.
+ *
+ * Use the PointVisitorMesh object when the field and mesh/submesh are
+ * defined over the same set of points (i.e., field over a submesh or field
+ * of a mesh).
+ */
+
+#if !defined(pylith_topology_submeshvisitor_hh)
+#define pylith_topology_submeshvisitor_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/utils/petscfwd.h" // HASA PetscVec, PetscSection
+
+#include <petscdmmesh.hh>
+
+// SubMeshVisitor -------------------------------------------------------
+/** @brief Helper class for accessing field values at points in a
+ * finite-element mesh.
+ */
+template<typename field_type>
+class pylith::topology::SubMeshVisitor
+{ // SubMeshVisitor
+ friend class TestSubMeshVisitor; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param field Field associated with visitor.
+ * @param submeshIS Submesh index set associated with visitor.
+ */
+ SubMeshVisitor(const field_type& field,
+ const SubMeshIS& submeshIS);
+
+ /// Default destructor
+ ~SubMeshVisitor(void);
+
+ /* Initialize cached data.
+ *
+ * @param submeshIS Submesh index set associated with visitor.
+ */
+ void initialize(const SubMeshIS& submeshIS);
+
+ /// Clear cached data.
+ void clear(void);
+
+ /** Get the array of values associated with the local PETSc Vec.
+ *
+ * @returns Array of values.
+ */
+ PetscScalar* localArray(void) const;
+
+ /** Get the PETSc section.
+ *
+ * @returns PETSc section.
+ */
+ PetscSection petscSection(void) const;
+
+ /** Get the local PETSc Vec.
+ *
+ * @returns PETSc Vec.
+ */
+ PetscVec localVec(void) const;
+
+ /** Get fiber dimension of coordinates for point.
+ *
+ * @param point Point in mesh.
+ * @returns Fiber dimension.
+ */
+ PetscInt sectionDof(const PetscInt point) const;
+
+ /** Get offset into coordinates array for point.
+ *
+ * @param point Point in mesh.
+ * @returns Offset.
+ */
+ PetscInt sectionOffset(const PetscInt point) const;
+
+ /** Get array of values associated with closure.
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ */
+ void getClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const;
+
+ /** Restore array of values associated with closure.
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ */
+ void restoreClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const;
+
+ /** Set values associated with closure.
+ *
+ * @param valuesCell Array of values for cell.
+ * @param valuesSize Size of values array.
+ * @param cell Finite-element cell.
+ * @param mode Mode for inserting values.
+ */
+ void setClosure(const PetscScalar* valuesCell,
+ const PetscInt valuesSize,
+ const PetscInt cell,
+ const InsertMode mode) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ const field_type& _field;
+
+ PetscDM _dm; ///< Cached PETSc dm for mesh.
+ PetscVec _localVec; ///< Cached local PETSc Vec.
+ PetscSection _section; ///< Cached PETSc subsection.
+ PetscScalar* _localArray; ///< Cached local array
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ SubMeshVisitor(const SubMeshVisitor&); ///< Not implemented
+ const SubMeshVisitor& operator=(const SubMeshVisitor&); ///< Not implemented
+
+}; // SubMeshVisitor
+
+
+// SubMeshIS ------------------------------------------------------------
+/// Index set associated with submesh.
+class pylith::topology::SubMeshIS
+{ // SubMeshIS
+ friend class TestSubMeshIS; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param submesh Submesh associated with index set.
+ */
+ SubMeshIS(const SubMesh& submesh);
+
+ /// Default destructor.
+ ~SubMeshIS(void);
+
+ /// Deallocate.
+ void deallocate(void);
+
+ /** Get the submesh.
+ *
+ * @returns Submesh.
+ */
+ const SubMesh& submesh(void) const;
+
+ /** Get PETSc index set.
+ *
+ * @returns PETSc index set.
+ */
+ PetscIS indexSet(void) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ const SubMesh& _submesh;
+ PetscIS _indexSet; ///< PETSc index set.
+
+}; // SubMeshIS
+
+
+#include "SubMeshVisitor.icc"
+
+#endif // pylith_topology_submeshvisitor_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/SubMeshVisitor.icc 2013-03-12 18:36:55 UTC (rev 21507)
@@ -0,0 +1,207 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2011 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_submeshvisitor_hh)
+#error "SubMeshVisitor.icc must be included only from SubMeshVisitor.hh"
+#else
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename field_type>
+inline
+pylith::topology::SubMeshVisitor<field_type>::SubMeshVisitor(const field_type& field,
+ const SubMeshIS& submeshIS) :
+ _field(field),
+ _dm(NULL),
+ _section(NULL),
+ _localVec(NULL),
+ _localArray(NULL)
+{ // constructor
+ initialize(submeshIS);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename field_type>
+inline
+pylith::topology::SubMeshVisitor<field_type>::~SubMeshVisitor(void)
+{ // destructor
+ clear();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Initialized cached data members.
+template<typename field_type>
+inline
+void
+pylith::topology::SubMeshVisitor<field_type>::initialize(const SubMeshIS& submeshIS)
+{ // initialize
+ _dm = submeshIS.submesh().dmMesh();assert(_dm);
+
+ _localVec = _field.localVector();assert(_localVec);
+
+ PetscErrorCode err;
+ PetscSection section = _field.petscSection();assert(section);
+ const PetscIS subpointIS = submeshIS.indexSet();assert(subpointIS);
+ err = PetscSectionCreateSubmeshSection(section, subpointIS, &_section);CHECK_PETSC_ERROR(err);assert(_section);
+ err = VecGetArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);assert(_localArray);
+} // initialize
+
+// ----------------------------------------------------------------------
+// Default destructor
+template<typename field_type>
+inline
+void
+pylith::topology::SubMeshVisitor<field_type>::clear(void)
+{ // clear
+ assert(_localVec);
+ PetscErrorCode err = VecRestoreArray(_localVec, &_localArray);CHECK_PETSC_ERROR(err);assert(!_localArray);
+
+ err = PetscSectionDestroy(&_section);assert(!_section);
+
+ _dm = NULL;
+ _localVec = NULL;
+} // clear
+
+// ----------------------------------------------------------------------
+// Get the local coordinates array associated with the local PETSc Vec.
+template<typename field_type>
+inline
+PetscScalar*
+pylith::topology::SubMeshVisitor<field_type>::localArray(void) const
+{ // localArray
+ return _localArray;
+} // localArray
+
+// ----------------------------------------------------------------------
+// Get fiber dimension of coordinates for point.
+template<typename field_type>
+inline
+PetscInt
+pylith::topology::SubMeshVisitor<field_type>::sectionDof(const PetscInt point) const
+{ // sectionDof
+ assert(_section);
+ PetscInt dof;
+ PetscErrorCode err = PetscSectionGetDof(_section, point, &dof);CHECK_PETSC_ERROR(err);
+ return dof;
+} // sectionDof
+
+// ----------------------------------------------------------------------
+// Get offset into coordinates array for point.
+template<typename field_type>
+inline
+PetscInt
+pylith::topology::SubMeshVisitor<field_type>::sectionOffset(const PetscInt point) const
+{ // sectionOffset
+ assert(_section);
+ PetscInt offset;
+ PetscErrorCode err = PetscSectionGetOffset(_section, point, &offset);CHECK_PETSC_ERROR(err);
+ return offset;
+} // sectionOffset
+
+// ----------------------------------------------------------------------
+// Get coordinates array associated with closure.
+template<typename field_type>
+void
+pylith::topology::SubMeshVisitor<field_type>::getClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const
+{ // getClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecGetClosure(_dm, _section, _localVec, cell, valuesSize, valuesCell);CHECK_PETSC_ERROR(err);
+} // getClosure
+
+// ----------------------------------------------------------------------
+// Restore coordinates array associated with closure.
+template<typename field_type>
+void
+pylith::topology::SubMeshVisitor<field_type>::restoreClosure(PetscScalar** valuesCell,
+ PetscInt* valuesSize,
+ const PetscInt cell) const
+{ // restoreClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecRestoreClosure(_dm, _section, _localVec, cell, valuesSize, valuesCell);CHECK_PETSC_ERROR(err);
+} // restoreClosure
+
+// ----------------------------------------------------------------------
+// Set values associated with closure.
+template<typename field_type>
+void
+pylith::topology::SubMeshVisitor<field_type>::setClosure(const PetscScalar* valuesCell,
+ const PetscInt valuesSize,
+ const PetscInt cell,
+ const InsertMode mode) const
+{ // setClosure
+ assert(_dm);
+ assert(_section);
+ assert(_localVec);
+ PetscErrorCode err = DMPlexVecSetClosure(_dm, _section, _localVec, cell, valuesCell, mode);CHECK_PETSC_ERROR(err);
+} // setClosure
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::topology::SubMeshIS::SubMeshIS(const SubMesh& submesh) :
+ _submesh(submesh),
+ _indexSet(NULL)
+{ // constructor
+ PetscDM dmMesh = submesh.dmMesh();assert(dmMesh);
+ PetscErrorCode err = DMPlexCreateSubpointIS(dmMesh, &_indexSet);CHECK_PETSC_ERROR(err);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor.
+pylith::topology::SubMeshIS::~SubMeshIS(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate.
+void
+pylith::topology::SubMeshIS::deallocate(void)
+{ // deallocate
+ PetscErrorCode err = ISDestroy(&_indexSet);CHECK_PETSC_ERROR(err);assert(!_indexSet);
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Get the submesh.
+const pylith::topology::SubMesh&
+pylith::topology::SubMeshIS::submesh(void) const
+{ // submesh
+ return _submesh;
+} // submesh
+
+// ----------------------------------------------------------------------
+// Get PETSc index set.
+PetscIS
+pylith::topology::SubMeshIS::indexSet(void) const
+{ // indexSet
+ return _indexSet;
+} // indexSet
+
+
+#endif
+
+
+// End of file
More information about the CIG-COMMITS
mailing list