[cig-commits] r7037 - in short/3D/PyLith/trunk: libsrc/feassemble
libsrc/materials unittests/libtests/feassemble
brad at geodynamics.org
brad at geodynamics.org
Fri Jun 1 14:54:23 PDT 2007
Author: brad
Date: 2007-06-01 14:54:23 -0700 (Fri, 01 Jun 2007)
New Revision: 7037
Modified:
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh
short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh
short/3D/PyLith/trunk/libsrc/materials/Material.cc
short/3D/PyLith/trunk/libsrc/materials/Material.hh
short/3D/PyLith/trunk/libsrc/materials/Material.icc
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh
Log:
Cleaned up usage of needNewJacobian for materials and elasticity integrators. Added corresponding C++ unit tests.
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -64,6 +64,17 @@
} // material
// ----------------------------------------------------------------------
+// Determine whether we need to recompute the Jacobian.
+bool
+pylith::feassemble::ElasticityExplicit::needNewJacobian(void)
+{ // needNewJacobian
+ assert(0 != _material);
+ if (!_needNewJacobian)
+ _needNewJacobian = _material->needNewJacobian();
+ return _needNewJacobian;
+} // needNewJacobian
+
+// ----------------------------------------------------------------------
// Integrate constributions to residual term (r) for operator.
void
pylith::feassemble::ElasticityExplicit::integrateResidual(
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -102,6 +102,12 @@
*/
void timeStep(const double dt);
+ /** Determine whether we need to recompute the Jacobian.
+ *
+ * @returns True if Jacobian needs to be recomputed, false otherwise.
+ */
+ bool needNewJacobian(void);
+
/** Integrate contributions to residual term (r) for operator.
*
* @param residual Field containing values for residual
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -68,8 +68,10 @@
bool
pylith::feassemble::ElasticityImplicit::needNewJacobian(void)
{ // needNewJacobian
+ assert(0 != _material);
+ if (!_needNewJacobian)
_needNewJacobian = _material->needNewJacobian();
- return _needNewJacobian;
+ return _needNewJacobian;
} // needNewJacobian
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -94,6 +94,12 @@
*/
void timeStep(const double dt);
+ /** Determine whether we need to recompute the Jacobian.
+ *
+ * @returns True if Jacobian needs to be recomputed, false otherwise.
+ */
+ bool needNewJacobian(void);
+
/** Integrate residual part of RHS for 3-D finite elements.
* Includes gravity and element internal force contribution.
*
@@ -130,12 +136,6 @@
void updateState(const ALE::Obj<real_section_type>& field,
const ALE::Obj<Mesh>& mesh);
- /** Determine whether we need to recompute the Jacobian.
- *
- * @returns True if Jacobian needs to be recomputed, false otherwise.
- */
- bool needNewJacobian(void);
-
// PRIVATE METHODS //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -81,6 +81,7 @@
*
* @returns True if Jacobian needs to be recomputed, false otherwise.
*/
+ virtual
bool needNewJacobian(void) const;
/** Integrate contributions to residual term (r) for operator.
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -30,7 +30,6 @@
// Default constructor.
pylith::materials::Material::Material(void) :
_dt(0.0),
- _dtm(0.0),
_parameters(0),
_dimension(0),
_needNewJacobian(false),
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -190,7 +190,6 @@
protected :
double _dt; ///< Current time step
- double _dtm; ///< Previous time step
///< Manager of parameters for physical properties of material
topology::FieldsManager* _parameters;
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.icc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.icc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -60,7 +60,6 @@
inline
void
pylith::materials::Material::timestep(const double dt) {
- _dtm = _dt;
_dt = dt;
}
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -49,14 +49,12 @@
/// Destructor
~MaxwellIsotropic3D(void);
- /** Get flag indicating whether Jacobian matrix must be reformed for
- * current state.
+ /** Set current time step.
*
- * @returns True if Jacobian matrix must be reformed, false otherwise.
+ * @param dt Current time step.
*/
+ void timestep(const double dt);
- bool needNewJacobian(void);
-
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -14,21 +14,15 @@
#error "MaxwellIsotropic3D.icc can only be included from MaxwellIsotropic3D.hh"
#endif
-/* Get flag indicating whether Jacobian matrix must be reformed for
- * current state.
- */
+// Set current time step.
inline
-bool
-pylith::materials::MaxwellIsotropic3D::needNewJacobian(void) {
- // Jacobian should be reformed for the elastic solution, for the first
- // time step, and any time the step size changes.
- if (_dt == _dtm)
- _needNewJacobian = false;
- else
+void
+pylith::materials::MaxwellIsotropic3D::timestep(const double dt) {
+ // Jacobian needs to be reformed if the time step size changes.
+ if (_dt > 0.0 && dt != _dt)
_needNewJacobian = true;
- return _needNewJacobian;
-}
-
+ _dt = dt;
+} // timestep
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -84,6 +84,20 @@
} // testMaterial
// ----------------------------------------------------------------------
+// Test needNewJacobian().
+void
+pylith::feassemble::TestElasticityExplicit::testNeedNewJacobian(void)
+{ // testNeedNewJacobian
+ ElasticityExplicit integrator;
+
+ materials::ElasticIsotropic3D material;
+ integrator.material(&material);
+ CPPUNIT_ASSERT_EQUAL(false, integrator.needNewJacobian());
+ integrator._needNewJacobian = true;
+ CPPUNIT_ASSERT_EQUAL(true, integrator.needNewJacobian());
+} // testNeedNewJacobian
+
+// ----------------------------------------------------------------------
// Test updateState().
void
pylith::feassemble::TestElasticityExplicit::testUpdateState(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -55,6 +55,7 @@
CPPUNIT_TEST( testTimeStep );
CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testMaterial );
+ CPPUNIT_TEST( testNeedNewJacobian );
CPPUNIT_TEST_SUITE_END();
@@ -73,6 +74,9 @@
/// Test material().
void testMaterial(void);
+ /// Test needNewJacobian().
+ void testNeedNewJacobian(void);
+
/// Test updateState().
void testUpdateState(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc 2007-06-01 21:54:23 UTC (rev 7037)
@@ -84,6 +84,20 @@
} // testMaterial
// ----------------------------------------------------------------------
+// Test needNewJacobian().
+void
+pylith::feassemble::TestElasticityImplicit::testNeedNewJacobian(void)
+{ // testNeedNewJacobian
+ ElasticityImplicit integrator;
+
+ materials::ElasticIsotropic3D material;
+ integrator.material(&material);
+ CPPUNIT_ASSERT_EQUAL(false, integrator.needNewJacobian());
+ integrator._needNewJacobian = true;
+ CPPUNIT_ASSERT_EQUAL(true, integrator.needNewJacobian());
+} // testNeedNewJacobian
+
+// ----------------------------------------------------------------------
// Test updateState().
void
pylith::feassemble::TestElasticityImplicit::testUpdateState(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh 2007-06-01 20:41:07 UTC (rev 7036)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh 2007-06-01 21:54:23 UTC (rev 7037)
@@ -55,6 +55,7 @@
CPPUNIT_TEST( testTimeStep );
CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testMaterial );
+ CPPUNIT_TEST( testNeedNewJacobian );
CPPUNIT_TEST_SUITE_END();
@@ -73,6 +74,9 @@
/// Test material().
void testMaterial(void);
+ /// Test needNewJacobian().
+ void testNeedNewJacobian(void);
+
/// Test updateState().
void testUpdateState(void);
More information about the cig-commits
mailing list