[cig-commits] r14040 - in short/3D/PyLith/branches/pylith-swig/libsrc: . feassemble

brad at geodynamics.org brad at geodynamics.org
Tue Feb 10 21:24:47 PST 2009


Author: brad
Date: 2009-02-10 21:24:47 -0800 (Tue, 10 Feb 2009)
New Revision: 14040

Added:
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.icc
Modified:
   short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.cc
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.hh
   short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh
Log:
More work on Quadrature. Added QuadratureEngine.

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/Makefile.am	2009-02-11 05:24:47 UTC (rev 14040)
@@ -40,6 +40,7 @@
 	feassemble/GeometryQuad3D.cc \
 	feassemble/GeometryHex3D.cc \
 	feassemble/QuadratureBase.cc \
+	feassemble/QuadratureEngine.cc \
 	meshio/BinaryIO.cc \
 	meshio/GMVFile.cc \
 	meshio/GMVFileAscii.cc \

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am	2009-02-11 05:24:47 UTC (rev 14040)
@@ -37,6 +37,8 @@
 	GeometryHex3D.hh \
 	QuadratureBase.hh \
 	QuadratureBase.icc \
+	QuadratureEngine.hh \
+	QuadratureEnginer.icc \
 	Quadrature.hh \
 	Quadrature.icc \
 	Quadrature.cc \

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.cc	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.cc	2009-02-11 05:24:47 UTC (rev 14040)
@@ -101,7 +101,6 @@
 
   // Allocate field and cell buffer for quadrature points
   int fiberDim = _numQuadPts * _spaceDim;
-  _quadPts.resize(fiberDim);
   _quadPtsField = new topology::Field<mesh_type>(mesh);
   assert(0 != _quadPtsField);
   _quadPtsField->newSection(cells, fiberDim);
@@ -114,8 +113,6 @@
 
   // Allocate field and cell buffer for Jacobian at quadrature points
   fiberDim = _numQuadPts * _cellDim * _spaceDim;
-  _jacobian.resize(fiberDim);
-  _jacobianInv.resize(fiberDim);
   _jacobianField = new topology::Field<mesh_type>(mesh);
   assert(0 != _jacobianField);
   _jacobianField->newSection(chart, fiberDim);
@@ -123,7 +120,6 @@
   
   // Allocate field and cell buffer for determinant of Jacobian at quad pts
   fiberDim = _numQuadPts;
-  _jacobianDet.resize(fiberDim);
   _jacobianDetField = new topology::Field<mesh_type>(mesh);
   assert(0 != _jacobianDetField);
   _jacobianDetField->newSection(chart, fiberDim);
@@ -131,7 +127,6 @@
   
   // Allocate field for derivatives of basis functions at quad pts
   fiberDim = _numQuadPts * _numBasis * _spaceDim;
-  _basisDeriv.resize(fiberDim);
   _basisDerivField = new topology::Field<mesh_type>(mesh);
   assert(0 != _basisDerivField);
   _basisDerivField->newSection(chart, fiberDim);
@@ -177,6 +172,7 @@
     sieveMesh->restrictClosure(*c_iter, coordsVisitor);
     const double* cellVertexCoords = coordsVisitor.getValues();
     assert(0 != cellVertexCoords);
+    _resetGeometry();
     computeGeometry(cellVertexCoords, _spaceDim, *c_iter);
 
     // Update fields with cell data

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh	2009-02-11 05:24:47 UTC (rev 14040)
@@ -121,30 +121,9 @@
    */
   Quadrature(const Quadrature& q);
 
-  /// Set entries in geometry arrays to zero.
-  void _resetGeometry(void);
-
-  /** Compute geometric quantities for a cell at quadrature points.
-   *
-   * @param coordsVertices Coordinates of vertices of cell.
-   * @param spaceDim Number of coordinates per vertex.
-   * @param cell Finite-element cell
-   */
-  virtual 
-  void _computeGeometry(const double* coordsVertices,
-			const int spaceDim,
-			const int cell) = 0;
-
 // PROTECTED MEMBERS ////////////////////////////////////////////////////
 protected :
 
-  /** Buffers for cell data */
-  double_array _quadPts; ///< Coordinates of quad pts.
-  double_array _jacobian; ///< Jacobian at quad pts;
-  double_array _jacobianDet; ///< |J| at quad pts.
-  double_array _jacobianInv; /// Inverse of Jacobian at quad pts.
-  double_array _basisDeriv; ///< Deriv. of basis fns at quad pts.
-
   /** Fields and visitors for precomputing geometry information for
    * cells associated with this quadrature.
    */

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.cc	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.cc	2009-02-11 05:24:47 UTC (rev 14040)
@@ -44,20 +44,21 @@
 { // copy constructor
 } // copy constructor
 
-#if 0
+#if 1
 // ----------------------------------------------------------------------
 // Compute geometric quantities for a cell at quadrature points.
 template<typename mesh_type>
 void
-pylith::feassemble::Quadrature1D<mesh_type>::computeGeometry(
+pylith::feassemble::Quadrature1D<mesh_type>::_computeGeometry(
 					      const double* vertCoords,
 					      const int coordDim,
 					      const int cell)
 { // computeGeometry
-  assert(1 == _cellDim);
-  assert(1 == _spaceDim);
+  const int cellDim = this->_cellDim;
+  const int spaceDim = this->_spaceDim;
 
-  _resetGeometry();
+  assert(1 == this->_cellDim);
+  assert(1 == this->_spaceDim);
   assert(1 == coordDim);
   
   // Loop over quadrature points

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.hh	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature1D.hh	2009-02-11 05:24:47 UTC (rev 14040)
@@ -38,16 +38,6 @@
   /// Create a copy of this object.
   Quadrature<mesh_type>* clone(void) const;
 
-  /** Compute geometric quantities for a cell at quadrature points.
-   *
-   * @param mesh Finite-element mesh
-   * @param coordinates Section containing vertex coordinates
-   * @param cell Finite-element cell
-   */
-  void computeGeometry(const double* vertCoords,
-                       const int coordDim,
-                       const int cell);
-
 // PROTECTED METHODS ////////////////////////////////////////////////////
 protected :
 
@@ -57,6 +47,16 @@
    */
   Quadrature1D(const Quadrature1D& q);
 
+  /** Compute geometric quantities for a cell at quadrature points.
+   *
+   * @param mesh Finite-element mesh
+   * @param coordinates Section containing vertex coordinates
+   * @param cell Finite-element cell
+   */
+  void _computeGeometry(const double* vertCoords,
+			const int coordDim,
+			const int cell);
+
 // PRIVATE METHODS //////////////////////////////////////////////////////
 private :
 

Added: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.cc	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.cc	2009-02-11 05:24:47 UTC (rev 14040)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "QuadratureEngine.hh" // implementation of class methods
+
+#include "CellGeometry.hh" // USES CellGeometry
+#include "QuadratureBase.hh" // QuadratureBase
+
+// ----------------------------------------------------------------------
+// Constructor.
+pylith::feassemble::QuadratureEngine::QuadratureEngine(const QuadratureBase& q) :
+  _quadRefCell(q)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::feassemble::QuadratureEngine::~QuadratureEngine(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Allocate cell buffers.
+void
+pylith::feassemble::QuadratureEngine::initialize(void)
+{ // initialize
+  const int numQuadPts = _quadRefCell.numQuadPts();
+  const int numBasis = _quadRefCell.numBasis();
+  const int cellDim = _quadRefCell.cellDim();
+  const int spaceDim = _quadRefCell.spaceDim();
+
+  _quadPts.resize(numQuadPts*spaceDim);
+  _jacobian.resize(numQuadPts*cellDim*spaceDim);
+  _jacobianInv.resize(numQuadPts*cellDim*spaceDim);
+  _jacobianDet.resize(numQuadPts);
+  _basisDeriv.resize(numQuadPts*numBasis*spaceDim);
+} // initialize
+
+// ----------------------------------------------------------------------
+// Fill cell buffers with zeros.
+void
+pylith::feassemble::QuadratureEngine::zero(void)
+{ // zero
+  _quadPts = 0.0;
+  _jacobian = 0.0;
+  _jacobianDet = 0.0;
+  _jacobianInv = 0.0;
+  _basisDeriv = 0.0;
+} // zero
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::feassemble::QuadratureEngine::QuadratureEngine(const QuadratureEngine& q) :
+  _quadPts(q._quadPts),
+  _jacobian(q._jacobian),
+  _jacobianDet(q._jacobianDet),
+  _jacobianInv(q._jacobianInv),
+  _basisDeriv(q._basisDeriv),
+  _quadRefCell(q._quadRefCell)
+{ // copy constructor
+} // copy constructor
+
+
+// End of file 

Added: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.hh	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.hh	2009-02-11 05:24:47 UTC (rev 14040)
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/feassemble/QuadratureEngine.hh
+ *
+ * @brief Abstract base class for quadrature computation engine.
+ */
+
+#if !defined(pylith_feassemble_quadratureengine_hh)
+#define pylith_feassemble_quadratureengine_hh
+
+#include "feassemblefwd.hh" // forward declaration
+#include "pylith/utils/array.hh" // USES double_array
+
+class pylith::feassemble::QuadratureEngine
+{ // QuadratureEngine
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+  /** Constructor.
+   *
+   * @param q Quadrature information for reference cell.
+   */
+  QuadratureEngine(const QuadratureBase& q);
+
+  /// Destructor
+  ~QuadratureEngine(void);
+
+  /** Create a copy of this object.
+   *
+   * @returns Copy of this.
+   */
+  virtual
+  QuadratureEngine* clone(void) const = 0;
+
+  /** Get coordinates of quadrature points in cell (NOT reference cell).
+   *
+   * @returns Array of coordinates of quadrature points in cell
+   */
+  const double_array& quadPts(void) const;
+
+  /** Get derivatives of basis fns evaluated at quadrature points.
+   *
+   * @returns Array of derivatives of basis fns evaluated at
+   * quadrature points
+   */
+  const double_array& basisDeriv(void) const;
+
+  /** Get Jacobians evaluated at quadrature points.
+   *
+   * @returns Array of Jacobian inverses evaluated at quadrature points.
+   */
+  const double_array& jacobian(void) const;
+
+  /** Get determinants of Jacobian evaluated at quadrature points.
+   *
+   * @returns Array of determinants of Jacobian evaluated at quadrature pts
+   */
+  const double_array& jacobianDet(void) const;
+
+  /// Allocate cell buffers.
+  void initialize(void);
+
+  /// Fill cell buffers with zeros.
+  void zero(void);
+
+  /** Compute geometric quantities for a cell at quadrature points.
+   *
+   * @param mesh Finite-element mesh
+   * @param coordinates Section containing vertex coordinates
+   * @param cell Finite-element cell
+   */
+  virtual
+  void computeGeometry(const double* vertCoords,
+		       const int coordDim,
+		       const int cell) = 0;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+  /** Copy constructor.
+   *
+   * @param q QuadratureEngine to copy
+   */
+  QuadratureEngine(const QuadratureEngine& q);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+  /** Buffers for cell data */
+  double_array _quadPts; ///< Coordinates of quad pts.
+  double_array _jacobian; ///< Jacobian at quad pts;
+  double_array _jacobianDet; ///< |J| at quad pts.
+  double_array _jacobianInv; /// Inverse of Jacobian at quad pts.
+  double_array _basisDeriv; ///< Deriv. of basis fns at quad pts.
+
+  const QuadratureBase& _quadRefCell;
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+  /// Not implemented.
+  const QuadratureEngine& operator=(const QuadratureEngine&);
+
+}; // QuadratureEngine
+
+#include "QuadratureEngine.icc" // inline methods
+
+#endif // pylith_feassemble_quadratureengine_hh
+
+// End of file 

Added: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.icc	                        (rev 0)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.icc	2009-02-11 05:24:47 UTC (rev 14040)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+//                           Brad T. Aagaard
+//                        U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_feassemble_quadratureengine_hh)
+#error "QuadratureEngine.icc must be included only from QuadratureEngine.hh"
+#else
+
+// Get coordinates of quadrature points in cell (NOT reference cell).
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::quadPts(void) const {
+  return _quadPts;
+}
+
+// Get derivatives of basis fns evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::basisDeriv(void) const {
+  return _basisDeriv;
+}
+
+// Get Jacobians evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::jacobian(void) const {
+  return _jacobian;
+}
+
+// Get determinants of Jacobian evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::jacobianDet(void) const {
+  return _jacobianDet;
+}
+
+#endif
+
+
+// End of file

Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh	2009-02-11 02:00:58 UTC (rev 14039)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh	2009-02-11 05:24:47 UTC (rev 14040)
@@ -39,6 +39,7 @@
     class GeometryHex3D;
 
     class QuadratureBase;
+    class QuadratureEngine;
     template<typename mesh_type> class Quadrature;
     template<typename mesh_type> class Quadrature0D;
     template<typename mesh_type> class Quadrature1D;



More information about the CIG-COMMITS mailing list