[cig-commits] r14044 - short/3D/PyLith/branches/pylith-swig/libsrc/feassemble
brad at geodynamics.org
brad at geodynamics.org
Thu Feb 12 17:02:54 PST 2009
Author: brad
Date: 2009-02-12 17:02:54 -0800 (Thu, 12 Feb 2009)
New Revision: 14044
Modified:
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/Quadrature.icc
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.cc
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.hh
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.icc
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh
Log:
A little work on quadrature.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Makefile.am 2009-02-13 01:02:54 UTC (rev 14044)
@@ -38,7 +38,7 @@
QuadratureBase.hh \
QuadratureBase.icc \
QuadratureEngine.hh \
- QuadratureEnginer.icc \
+ QuadratureEngine.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-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.cc 2009-02-13 01:02:54 UTC (rev 14044)
@@ -12,9 +12,20 @@
#include <portinfo>
-#include "Quadrature.hh" // implementation of class methods
+//#include "Quadrature.hh" // implementation of class methods
#include "CellGeometry.hh" // USES CellGeometry
+
+#if 0
+#include "Quadrature0D.hh"
+#include "Quadrature1D.hh"
+#include "Quadrature1Din2D.hh"
+#include "Quadrature1Din3D.hh"
+#include "Quadrature2D.hh"
+#include "Quadrature2Din3D.hh"
+#include "Quadrature3D.hh"
+#endif
+
#include "pylith/topology/Field.hh" // HOLDSA Field
#include <cstring> // USES memcpy()
@@ -26,6 +37,7 @@
// Constructor
template<typename mesh_type>
pylith::feassemble::Quadrature<mesh_type>::Quadrature(void) :
+ _engine(0),
_quadPtsField(0),
_jacobianField(0),
_jacobianDetField(0),
@@ -39,6 +51,7 @@
template<typename mesh_type>
pylith::feassemble::Quadrature<mesh_type>::~Quadrature(void)
{ // destructor
+ delete _engine; _engine = 0;
delete _quadPtsField; _quadPtsField = 0;
delete _jacobianField; _jacobianField = 0;
delete _jacobianDetField; _jacobianDetField = 0;
@@ -50,49 +63,28 @@
template<typename mesh_type>
pylith::feassemble::Quadrature<mesh_type>::Quadrature(const Quadrature& q) :
QuadratureBase(q),
+ _engine(0),
_quadPtsField(0),
_jacobianField(0),
_jacobianDetField(0),
_basisDerivField(0),
_checkConditioning(q._checkConditioning)
{ // copy constructor
+ if (0 != q._engine)
+ _engine = q._engine->clone();
} // copy constructor
// ----------------------------------------------------------------------
-// Deallocate temporary storage;
template<typename mesh_type>
void
-pylith::feassemble::Quadrature<mesh_type>::clear(void)
-{ // clear
- // Clear storage for fields
- delete _quadPtsField; _quadPtsField = 0;
- delete _jacobianField; _jacobianField = 0;
- delete _jacobianDetField; _jacobianDetField = 0;
- delete _basisDerivField; _basisDerivField = 0;
-} // clear
-
-// ----------------------------------------------------------------------
-// Set entries in geometry arrays to zero.
-template<typename mesh_type>
-void
-pylith::feassemble::Quadrature<mesh_type>::_resetGeometry(void)
-{ // _resetGeometry
- _quadPts = 0.0;
- _jacobian = 0.0;
- _jacobianDet = 0.0;
- _jacobianInv = 0.0;
- _basisDeriv = 0.0;
-} // _resetGeometry
-
-// ----------------------------------------------------------------------
-template<typename mesh_type>
-void
pylith::feassemble::Quadrature<mesh_type>::computeGeometry(
const mesh_type& mesh,
const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& cells)
{ // precomputeGeometry
typedef typename mesh_type::RealSection RealSection;
+ _setupEngine();
+
const char* loggingStage = "QuadratureCreation";
ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
logger.stagePush(loggingStage);
@@ -210,5 +202,74 @@
basisDerivSection->restrictPoint(cell, &_basisDeriv[0], _basisDeriv.size());
} // retrieveGeometry
+// ----------------------------------------------------------------------
+// Deallocate temporary storage;
+template<typename mesh_type>
+void
+pylith::feassemble::Quadrature<mesh_type>::clear(void)
+{ // clear
+ delete _engine; _engine = 0;
+ // Clear storage for fields
+ delete _quadPtsField; _quadPtsField = 0;
+ delete _jacobianField; _jacobianField = 0;
+ delete _jacobianDetField; _jacobianDetField = 0;
+ delete _basisDerivField; _basisDerivField = 0;
+} // clear
+
+// ----------------------------------------------------------------------
+// Setup quadrature engine.
+template<typename mesh_type>
+void
+pylith::feassemble::Quadrature<mesh_type>::_setupEngine(void)
+{ // clear
+ delete _engine; _engine = 0;
+
+ const int cellDim = _cellDim;
+ const int spaceDim = _spaceDim;
+
+#if 0
+ if (1 == spaceDim)
+ if (1 == cellDim)
+ _engine = new Quadrature1D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+ else if (2 == spaceDim) {
+ if (2 == cellDim)
+ _engine = new Quadrature2D(*this);
+ else if (1 == cellDim)
+ _engine = new Quadrature1Din2D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+ else if (3 == spaceDim) {
+ if (3 == cellDim)
+ _engine = new Quadrature3D(*this);
+ else if (2 == cellDim)
+ _engine = new Quadrature2Din3D(*this);
+ else if (1 == cellDim)
+ _engine = new Quadrature1Din3D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+#endif
+} // _setupEngine
+
+
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.hh 2009-02-13 01:02:54 UTC (rev 14044)
@@ -50,12 +50,13 @@
Quadrature(void);
/// Destructor
- virtual
~Quadrature(void);
- /// Create a copy of this object.
- virtual
- Quadrature* clone(void) const = 0;
+ /** Copy constructor.
+ *
+ * @param q Quadrature to copy
+ */
+ Quadrature(const Quadrature& q);
/** Set flag for checking ill-conditioning.
*
@@ -112,17 +113,14 @@
/// Deallocate temporary storage.
void clear(void);
-// PROTECTED METHODS ////////////////////////////////////////////////////
-protected :
+// PRIVATE METHODS //////////////////////////////////////////////////////
+private :
- /** Copy constructor.
- *
- * @param q Quadrature to copy
- */
- Quadrature(const Quadrature& q);
+ /// Setup quadrature engine.
+ void _setupEngine(void);
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
/** Fields and visitors for precomputing geometry information for
* cells associated with this quadrature.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.icc 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature.icc 2009-02-13 01:02:54 UTC (rev 14044)
@@ -14,6 +14,8 @@
#error "Quadrature.icc must be included only from Quadrature.hh"
#else
+#include <cassert> // USES assert()
+
// Set flag for checking ill-conditioning.
template<typename mesh_type>
inline
@@ -35,7 +37,8 @@
inline
const pylith::double_array&
pylith::feassemble::Quadrature<mesh_type>::quadPts(void) const {
- return _quadPts;
+ assert(0 != _engine);
+ return _engine->_quadPts;
}
// Get derivatives of basis fns evaluated at quadrature points.
@@ -43,7 +46,8 @@
inline
const pylith::double_array&
pylith::feassemble::Quadrature<mesh_type>::basisDeriv(void) const {
- return _basisDeriv;
+ assert(0 != _engine);
+ return _engine->_basisDeriv;
}
// Get Jacobians evaluated at quadrature points.
@@ -51,7 +55,8 @@
inline
const pylith::double_array&
pylith::feassemble::Quadrature<mesh_type>::jacobian(void) const {
- return _jacobian;
+ assert(0 != _engine);
+ return _engine->_jacobian;
}
// Get determinants of Jacobian evaluated at quadrature points.
@@ -59,7 +64,8 @@
inline
const pylith::double_array&
pylith::feassemble::Quadrature<mesh_type>::jacobianDet(void) const {
- return _jacobianDet;
+ assert(0 != _engine);
+ return _engine->_jacobianDet;
}
#endif
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.cc 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.cc 2009-02-13 01:02:54 UTC (rev 14044)
@@ -12,7 +12,7 @@
#include <portinfo>
-//#include "Quadrature3D.hh" // implementation of class methods
+#include "Quadrature3D.hh" // implementation of class methods
#include "CellGeometry.hh" // USES CellGeometry
@@ -24,60 +24,64 @@
// ----------------------------------------------------------------------
// Constructor
-template<typename mesh_type>
-pylith::feassemble::Quadrature3D<mesh_type>::Quadrature3D(void) : pylith::feassemble::Quadrature::Quadrature()
+pylith::feassemble::Quadrature3D::Quadrature3D(void)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-template<typename mesh_type>
-pylith::feassemble::Quadrature3D<mesh_type>::~Quadrature3D(void)
+pylith::feassemble::Quadrature3D::~Quadrature3D(void)
{ // destructor
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-template<typename mesh_type>
-pylith::feassemble::Quadrature3D<mesh_type>::Quadrature3D(const Quadrature3D& q) :
+pylith::feassemble::Quadrature3D::Quadrature3D(const Quadrature3D& q) :
Quadrature(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
-template<typename mesh_type>
void
-pylith::feassemble::Quadrature3D<mesh_type>::computeGeometry(
- const double* vertCoords,
- const int coordDim,
- const int cell)
+pylith::feassemble::Quadrature3D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(3 == _cellDim);
- assert(3 == _spaceDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPts();
+ const CellGeometry* geometry = _quadRefCell.cellGeometry();
+
+ assert(3 == cellDim);
+ assert(3 == spaceDim);
+
_resetGeometry();
assert(3 == coordDim);
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
// z = sum[i=0,n-1] (Ni * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double basis = basis[iQuadPt*_numBasis+iBasis];
for (int iDim=0; iDim < _spaceDim; ++iDim)
_quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ basis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ assert(0 != geometry);
+ geometry->coordsRefToGlobal(&quadPts[iQuadPt*spaceDim],
+ &_quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.hh 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.hh 2009-02-13 01:02:54 UTC (rev 14044)
@@ -19,10 +19,9 @@
#if !defined(pylith_feassemble_quadrature3d_hh)
#define pylith_feassemble_quadrature3d_hh
-#include "Quadrature.hh" // ISA Quadrature
+#include "QuadratureEngine.hh" // ISA QuadratureEngine
-template<typename mesh_type>
-class pylith::feassemble::Quadrature3D : public Quadrature<mesh_type>
+class pylith::feassemble::Quadrature3D : public QuadratureEngine
{ // Quadrature3D
friend class TestQuadrature3D; // unit testing
@@ -36,7 +35,7 @@
~Quadrature3D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
@@ -66,8 +65,8 @@
}; // Quadrature3D
#include "Quadrature3D.icc" // inline methods
-#include "Quadrature3D.cc" // template methods
#endif // pylith_feassemble_quadrature3d_hh
+
// End of file
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.icc 2009-02-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Quadrature3D.icc 2009-02-13 01:02:54 UTC (rev 14044)
@@ -16,11 +16,12 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature3D::clone(void) const {
return new Quadrature3D(*this);
} // clone
#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-12 09:39:30 UTC (rev 14043)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh 2009-02-13 01:02:54 UTC (rev 14044)
@@ -40,14 +40,14 @@
class QuadratureBase;
class QuadratureEngine;
+ class Quadrature0D;
+ class Quadrature1D;
+ class Quadrature1Din2D;
+ class Quadrature1Din3D;
+ class Quadrature2D;
+ class Quadrature2Din3D;
+ class Quadrature3D;
template<typename mesh_type> class Quadrature;
- template<typename mesh_type> class Quadrature0D;
- template<typename mesh_type> class Quadrature1D;
- template<typename mesh_type> class Quadrature1Din2D;
- template<typename mesh_type> class Quadrature1Din3D;
- template<typename mesh_type> class Quadrature2D;
- template<typename mesh_type> class Quadrature2Din3D;
- template<typename mesh_type> class Quadrature3D;
class Constraint;
template<typename quadrature_type> class Integrator;
More information about the CIG-COMMITS
mailing list