[cig-commits] r14320 - in short/3D/PyLith/branches/pylith-swig: libsrc/feassemble unittests/libtests/feassemble
brad at geodynamics.org
brad at geodynamics.org
Sat Mar 14 16:00:35 PDT 2009
Author: brad
Date: 2009-03-14 16:00:35 -0700 (Sat, 14 Mar 2009)
New Revision: 14320
Modified:
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh
short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.icc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/Makefile.am
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.hh
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.cc
short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.hh
Log:
Work on updating C++ elasticity integrator tests.
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.hh 2009-03-14 23:00:35 UTC (rev 14320)
@@ -163,8 +163,8 @@
* @param mesh Finite-element mesh
*/
virtual
- void updateState(const double t,
- topology::SolutionFields* const fields);
+ void updateStateVars(const double t,
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
Modified: short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.icc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.icc 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/Integrator.icc 2009-03-14 23:00:35 UTC (rev 14320)
@@ -95,7 +95,7 @@
template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator<quadrature_type>::updateState(
+pylith::feassemble::Integrator<quadrature_type>::updateStateVars(
const double t,
topology::SolutionFields* const fields) {
} // updateState
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/Makefile.am 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/Makefile.am 2009-03-14 23:00:35 UTC (rev 14320)
@@ -44,10 +44,10 @@
TestQuadrature2Din3D.cc \
TestQuadrature3D.cc \
TestQuadrature.cc \
+ TestIntegrator.cc \
+ TestIntegratorElasticity.cc \
test_feassemble.cc
-# TestIntegrator.cc \
-# TestIntegratorElasticity.cc \
# TestElasticityExplicit.cc \
# TestElasticityExplicit1DLinear.cc \
# TestElasticityExplicit1DQuadratic.cc \
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-03-14 23:00:35 UTC (rev 14320)
@@ -19,7 +19,8 @@
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -156,7 +157,7 @@
ALE::Obj<Mesh> mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
const ALE::Obj<real_section_type>& dispT = fields.getReal("dispT");
@@ -174,7 +175,7 @@
ALE::Obj<Mesh> mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
spatialdata::geocoords::CSCart cs;
@@ -210,7 +211,7 @@
ALE::Obj<Mesh> mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
integrator._needNewJacobian = true;
@@ -273,7 +274,7 @@
pylith::feassemble::TestElasticityExplicit::_initialize(
ALE::Obj<Mesh>* mesh,
ElasticityExplicit* const integrator,
- topology::FieldsManager* fields)
+ topology::SolutionFields* fields)
{ // _initialize
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != integrator);
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.hh 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestElasticityExplicit.hh 2009-03-14 23:00:35 UTC (rev 14320)
@@ -23,35 +23,19 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SolutionFields
+#include "pylith/materials/materialsfwd.hh" // USES ElasticMaterial
-#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES GravityField
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
class TestElasticityExplicit;
-
- class ElasticityExplicit; // USES ElasticityExplicit
- class IntegratorData; // HOLDSA IntegratorData
- class Quadrature; // HOLDSA Quadrature
} // feassemble
-
- namespace materials {
- class ElasticMaterial; // HOLDSA ElasticMaterial
- } // materials
-
- namespace topology {
- class FieldsManager; // USES FieldsManager
- } // topology
} // pylith
-namespace spatialdata {
- namespace spatialdb {
- class GravityField; // HOLDSA GravityField
- } // spatialdb
-} // spatialdata
-
/// C++ unit testing for ElasticityExplicit
class pylith::feassemble::TestElasticityExplicit : public CppUnit::TestFixture
{ // class TestElasticityExplicit
@@ -117,13 +101,13 @@
/** Initialize elasticity integrator.
*
- * @param mesh PETSc mesh to initialize.
+ * @param mesh Finite-element mesh to initialize.
* @param integrator ElasticityIntegrator to initialize.
* @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
ElasticityExplicit* const integrator,
- topology::FieldsManager* const fields);
+ topology::SolutionFields* const fields);
}; // class TestElasticityExplicit
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.cc
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.cc 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.cc 2009-03-14 23:00:35 UTC (rev 14320)
@@ -16,14 +16,12 @@
#include "pylith/feassemble/ElasticityExplicit.hh" // USES ElasticityExplicit
#include "pylith/feassemble/ElasticityImplicit.hh" // USES ElasticityImplicit
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include <petscmat.h>
-
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestIntegrator );
@@ -57,7 +55,7 @@
// Since quadrature is cloned, test setting quadrature by testing
// value of minJacobian
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
const double minJacobian = 4.0;
quadrature.minJacobian(minJacobian);
@@ -68,32 +66,33 @@
} // testQuadrature
// ----------------------------------------------------------------------
+// Test normalizer().
+void
+pylith::feassemble::TestIntegrator::testNormalizer(void)
+{ // testNormalizer
+ const double lengthScale = 2.0;
+
+ spatialdata::units::Nondimensional normalizer;
+ normalizer.lengthScale(lengthScale);
+
+ ElasticityExplicit integrator;
+ integrator.normalizer(normalizer);
+
+ CPPUNIT_ASSERT_EQUAL(lengthScale, integrator._normalizer->lengthScale());
+} // testNormalizer
+
+// ----------------------------------------------------------------------
// Test gravityField().
void
pylith::feassemble::TestIntegrator::testGravityField(void)
{ // testGravityField
- // Test gravity field by testing value of gravity vector.
- const int spaceDim = 3;
- const double gravityE[] = { 0.0, 0.0, -9.80665 };
-
ElasticityImplicit integrator;
spatialdata::spatialdb::GravityField gravityField;
- integrator.gravityField(&gravityField);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ CPPUNIT_ASSERT(0 == integrator._gravityField);
- integrator._gravityField->open();
- double gravity[spaceDim];
- const double coords[] = { 1.0, 2.0, 3.0 };
- const int err = integrator._gravityField->query(gravity, spaceDim,
- coords, spaceDim, &cs);
- CPPUNIT_ASSERT_EQUAL(0, err);
- integrator._gravityField->close();
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < spaceDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(gravityE[i], gravity[i], tolerance);
+ integrator.gravityField(&gravityField);
+ CPPUNIT_ASSERT(0 != integrator._gravityField);
} // testGravityField
// ----------------------------------------------------------------------
@@ -101,7 +100,7 @@
void
pylith::feassemble::TestIntegrator::testInitCellVector(void)
{ // testInitCellVector
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -109,10 +108,10 @@
integrator._initCellVector();
- CPPUNIT_ASSERT(0 != integrator._cellVector);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellVector.size());
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellVector[i]);
} // testInitCellVector
@@ -121,7 +120,7 @@
void
pylith::feassemble::TestIntegrator::testResetCellVector(void)
{ // testResetCellVector
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -129,13 +128,13 @@
integrator._initCellVector();
- CPPUNIT_ASSERT(0 != integrator._cellVector);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellVector.size());
+ for (size_t i=0; i < size; ++i)
integrator._cellVector[i] = 1.4+2*i;
integrator._resetCellVector();
- for (int i=0; i < size; ++i)
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellVector[i]);
} // testResetCellVector
@@ -144,7 +143,7 @@
void
pylith::feassemble::TestIntegrator::testInitCellMatrix(void)
{ // testInitCellMatrix
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -152,11 +151,11 @@
integrator._initCellMatrix();
- CPPUNIT_ASSERT(0 != integrator._cellMatrix);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis() *
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellMatrix.size());
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellMatrix[i]);
} // testInitCellMatrix
@@ -165,7 +164,7 @@
void
pylith::feassemble::TestIntegrator::testResetCellMatrix(void)
{ // testResetCellMatrix
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -173,21 +172,22 @@
integrator._initCellMatrix();
- CPPUNIT_ASSERT(0 != integrator._cellMatrix);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis() *
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellMatrix.size());
+ for (size_t i=0; i < size; ++i)
integrator._cellMatrix[i] = 1.23 + 1.2*i;
integrator._resetCellMatrix();
- for (int i=0; i < size; ++i)
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellMatrix[i]);
} // testResetCellMatrix
// ----------------------------------------------------------------------
// Set quadrature information.
void
-pylith::feassemble::TestIntegrator::_initQuadrature(Quadrature1D* quadrature)
+pylith::feassemble::TestIntegrator::_initQuadrature(
+ Quadrature<topology::Mesh>* quadrature)
{ // _initQuadrature
CPPUNIT_ASSERT(0 != quadrature);
@@ -201,8 +201,11 @@
const double quadWts[] = { 2.0 };
const double minJacobian = 1.0;
- quadrature->initialize(basis, basisDeriv, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
+ quadrature->initialize(basis, numQuadPts, numBasis,
+ basisDeriv, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
} // _initQuadrature
Modified: short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.hh
===================================================================
--- short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.hh 2009-03-14 22:14:43 UTC (rev 14319)
+++ short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestIntegrator.hh 2009-03-14 23:00:35 UTC (rev 14320)
@@ -23,6 +23,9 @@
#include <cppunit/extensions/HelperMacros.h>
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
+#include "pylith/feassemble/feassemblefwd.hh" // USES Quadrature
+
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
@@ -41,6 +44,7 @@
CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testQuadrature );
+ CPPUNIT_TEST( testNormalizer );
CPPUNIT_TEST( testGravityField );
CPPUNIT_TEST( testInitCellVector );
CPPUNIT_TEST( testResetCellVector );
@@ -58,24 +62,36 @@
/// Test stableTimeStep().
void testStableTimeStep(void);
- /// Test quadrature()
+ /// Test quadrature().
void testQuadrature(void);
- /// Test gravityField()
+ /// Test normalizer().
+ void testNormalizer(void);
+
+ /// Test gravityField().
void testGravityField(void);
- /// Test _initCellVector()
+ /// Test _initCellVector().
void testInitCellVector(void);
- /// Test _resetCellVector()
+ /// Test _resetCellVector().
void testResetCellVector(void);
- /// Test _initCellMatrix()
+ /// Test _initCellMatrix().
void testInitCellMatrix(void);
- /// Test _resetCellMatrix()
+ /// Test _resetCellMatrix().
void testResetCellMatrix(void);
+ // PRIVATE METHODS /////////////////////////////////////////////////////
+private :
+
+ /** Initialize quadrature.
+ *
+ * @param quadrature Quadrature to initiqlize.
+ */
+ void _initQuadrature(Quadrature<topology::Mesh>* quadrature);
+
}; // class TestIntegrator
#endif // pylith_feassemble_testintegrator_hh
More information about the CIG-COMMITS
mailing list