[cig-commits] r15298 - in short/3D/PyLith/trunk: libsrc/bc libsrc/topology modulesrc/bc modulesrc/topology pylith pylith/bc unittests/libtests/bc unittests/libtests/topology
brad at geodynamics.org
brad at geodynamics.org
Tue Jun 16 09:58:26 PDT 2009
Author: brad
Date: 2009-06-16 09:58:24 -0700 (Tue, 16 Jun 2009)
New Revision: 15298
Added:
short/3D/PyLith/trunk/pylith/bc/TimeDependentPoints.py
Modified:
short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc
short/3D/PyLith/trunk/libsrc/bc/TimeDependent.cc
short/3D/PyLith/trunk/libsrc/bc/TimeDependent.hh
short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc
short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.hh
short/3D/PyLith/trunk/libsrc/topology/Field.cc
short/3D/PyLith/trunk/libsrc/topology/Field.hh
short/3D/PyLith/trunk/modulesrc/bc/TimeDependent.i
short/3D/PyLith/trunk/modulesrc/bc/TimeDependentPoints.i
short/3D/PyLith/trunk/modulesrc/topology/Field.i
short/3D/PyLith/trunk/pylith/Makefile.am
short/3D/PyLith/trunk/pylith/bc/DirichletBC.py
short/3D/PyLith/trunk/pylith/bc/TimeDependent.py
short/3D/PyLith/trunk/pylith/bc/__init__.py
short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh
Log:
Cleaned up resetting solution field to zero and setting constraints (set constraints even if zero). Added Field::zeroAll() as an option for setting entire field (including constraints) to zero. Moved bcDOF from TimeDependent to TimeDependentPoints (where it belongs).
Modified: short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -223,10 +223,6 @@
if (0 == numFixedDOF)
return;
- // no temporal change -> no increment in field
- if (0 == _dbRate && 0 == _dbChange)
- return;
-
// Calculate spatial and temporal variation of value for BC.
_calculateValueIncr(t0, t1);
Modified: short/3D/PyLith/trunk/libsrc/bc/TimeDependent.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/TimeDependent.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/bc/TimeDependent.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -50,20 +50,6 @@
} // deallocate
// ----------------------------------------------------------------------
-// Set indices of vertices with point forces.
-void
-pylith::bc::TimeDependent::bcDOF(const int* flags,
- const int size)
-{ // bcDOF
- if (size > 0)
- assert(0 != flags);
-
- _bcDOF.resize(size);
- for (int i=0; i < size; ++i)
- _bcDOF[i] = flags[i];
-} // bcDOF
-
-// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
pylith::bc::TimeDependent::verifyConfiguration(const topology::Mesh& mesh) const
Modified: short/3D/PyLith/trunk/libsrc/bc/TimeDependent.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/TimeDependent.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/bc/TimeDependent.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -44,19 +44,6 @@
virtual
void deallocate(void);
- /** Set indices of degrees of freedom associated with BC.
- *
- * Note: Forces at all points are applied to the same degrees of freedom.
- *
- * Example: [0, 1] to apply forces to x and y degrees of freedom in
- * Cartesian system.
- *
- * @param flags Array of indices for degrees of freedom for forces.
- * @param size Size of array
- */
- void bcDOF(const int* flags,
- const int size);
-
/** Set database for initial values.
*
* @param db Spatial database
@@ -120,8 +107,6 @@
/// Temporal evolution of amplitude for change in value;
spatialdata::spatialdb::TimeHistory* _dbTimeHistory;
- int_array _bcDOF; ///< Degrees of freedom associated with BC.
-
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -54,6 +54,20 @@
} // deallocate
// ----------------------------------------------------------------------
+// Set indices of vertices with point forces.
+void
+pylith::bc::TimeDependentPoints::bcDOF(const int* flags,
+ const int size)
+{ // bcDOF
+ if (size > 0)
+ assert(0 != flags);
+
+ _bcDOF.resize(size);
+ for (int i=0; i < size; ++i)
+ _bcDOF[i] = flags[i];
+} // bcDOF
+
+// ----------------------------------------------------------------------
// Query databases for parameters.
void
pylith::bc::TimeDependentPoints::_queryDatabases(const topology::Mesh& mesh,
Modified: short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -44,6 +44,19 @@
virtual
void deallocate(void);
+ /** Set indices of degrees of freedom associated with BC.
+ *
+ * Note: Forces at all points are applied to the same degrees of freedom.
+ *
+ * Example: [0, 1] to apply forces to x and y degrees of freedom in
+ * Cartesian system.
+ *
+ * @param flags Array of indices for degrees of freedom for forces.
+ * @param size Size of array
+ */
+ void bcDOF(const int* flags,
+ const int size);
+
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -91,6 +104,11 @@
void _calculateValueIncr(const double t0,
const double t1);
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ int_array _bcDOF; ///< Degrees of freedom associated with BC.
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -310,16 +310,22 @@
} // allocate
// ----------------------------------------------------------------------
-// Zero section values.
+// Zero section values (excluding constrained DOF).
template<typename mesh_type>
void
pylith::topology::Field<mesh_type>::zero(void)
{ // zero
+ if (!_section.isNull())
+ _section->zero(); // Does not zero BC.
+} // zero
+
+// ----------------------------------------------------------------------
+// Zero section values (including constrained DOF).
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::zeroAll(void)
+{ // zeroAll
if (!_section.isNull()) {
-#if 0
- _section->zero(); // Does not zero BC.
-#else
- // Add values from field
const chart_type& chart = _section->getChart();
const typename chart_type::const_iterator chartBegin = chart.begin();
const typename chart_type::const_iterator chartEnd = chart.end();
@@ -338,9 +344,8 @@
_section->updatePointAll(*c_iter, &values[0]);
} // if
} // for
-#endif
} // if
-} // zero
+} // zeroAll
// ----------------------------------------------------------------------
// Complete section by assembling across processors.
Modified: short/3D/PyLith/trunk/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -199,9 +199,12 @@
/// Allocate field.
void allocate(void);
- /// Zero section values (including constrained values).
+ /// Zero section values (does not zero constrained values).
void zero(void);
+ /// Zero section values (including constrained values).
+ void zeroAll(void);
+
/// Complete section by assembling across processors.
void complete(void);
Modified: short/3D/PyLith/trunk/modulesrc/bc/TimeDependent.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/TimeDependent.i 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/modulesrc/bc/TimeDependent.i 2009-06-16 16:58:24 UTC (rev 15298)
@@ -34,24 +34,6 @@
virtual
void deallocate(void);
- /** Set indices of degrees of freedom associated with BC.
- *
- * Note: Forces at all points are applied to the same degrees of freedom.
- *
- * Example: [0, 1] to apply forces to x and y degrees of freedom in
- * Cartesian system.
- *
- * @param flags Array of indices for degrees of freedom for forces.
- * @param size Size of array
- */
- %apply(int* INPLACE_ARRAY1, int DIM1) {
- (const int* flags,
- const int size)
- };
- void bcDOF(const int* flags,
- const int size);
- %clear(const int* flags, const int size);
-
/** Set database for initial values.
*
* @param db Spatial database
Modified: short/3D/PyLith/trunk/modulesrc/bc/TimeDependentPoints.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/TimeDependentPoints.i 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/modulesrc/bc/TimeDependentPoints.i 2009-06-16 16:58:24 UTC (rev 15298)
@@ -35,6 +35,24 @@
virtual
void deallocate(void);
+ /** Set indices of degrees of freedom associated with BC.
+ *
+ * Note: Forces at all points are applied to the same degrees of freedom.
+ *
+ * Example: [0, 1] to apply forces to x and y degrees of freedom in
+ * Cartesian system.
+ *
+ * @param flags Array of indices for degrees of freedom for forces.
+ * @param size Size of array
+ */
+ %apply(int* INPLACE_ARRAY1, int DIM1) {
+ (const int* flags,
+ const int size)
+ };
+ void bcDOF(const int* flags,
+ const int size);
+ %clear(const int* flags, const int size);
+
// PROTECTED METHODS //////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/modulesrc/topology/Field.i
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Field.i 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/modulesrc/topology/Field.i 2009-06-16 16:58:24 UTC (rev 15298)
@@ -161,9 +161,12 @@
/// Allocate field.
void allocate(void);
- /// Zero section values.
+ /// Zero section values (excluding constrained DOF).
void zero(void);
+ /// Zero section values (including constrained DOF).
+ void zeroAll(void);
+
/// Complete section by assembling across processors.
void complete(void);
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2009-06-16 16:58:24 UTC (rev 15298)
@@ -23,6 +23,7 @@
bc/Neumann.py \
bc/PointForce.py \
bc/TimeDependent.py \
+ bc/TimeDependentPoints.py \
bc/ZeroDispDB.py \
faults/__init__.py \
faults/BruneSlipFn.py \
Modified: short/3D/PyLith/trunk/pylith/bc/DirichletBC.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletBC.py 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletBC.py 2009-06-16 16:58:24 UTC (rev 15298)
@@ -18,13 +18,13 @@
## Factory: boundary_condition
from BoundaryCondition import BoundaryCondition
-from TimeDependent import TimeDependent
+from TimeDependentPoints import TimeDependentPoints
from pylith.feassemble.Constraint import Constraint
from bc import DirichletBC as ModuleDirichletBC
# DirichletBC class
class DirichletBC(BoundaryCondition,
- TimeDependent,
+ TimeDependentPoints,
Constraint,
ModuleDirichletBC):
"""
@@ -107,7 +107,7 @@
Setup members using inventory.
"""
BoundaryCondition._configure(self)
- TimeDependent._configure(self)
+ TimeDependentPoints._configure(self)
return
Modified: short/3D/PyLith/trunk/pylith/bc/TimeDependent.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/TimeDependent.py 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/pylith/bc/TimeDependent.py 2009-06-16 16:58:24 UTC (rev 15298)
@@ -32,23 +32,6 @@
from pylith.utils.NullComponent import NullComponent
-def validateDOF(value):
- """
- Validate list of fixed degrees of freedom.
- """
- try:
- size = len(value)
- num = map(int, value)
- for v in num:
- if v < 0:
- raise ValueError
- except:
- raise ValueError, \
- "'fixed_dof' must be a zero based list of indices of fixed " \
- "degrees of freedom."
- return num
-
-
# TimeDependent class
class TimeDependent(PetscComponent, ModuleTimeDependent):
"""
@@ -75,11 +58,6 @@
import pyre.inventory
- bcDOF = pyre.inventory.list("fixed_dof", default=[],
- validator=validateDOF)
- bcDOF.meta['tip'] = "Indices of boundary condition DOF " \
- "(0=1st DOF, 1=2nd DOF, etc)."
-
from spatialdata.spatialdb.SimpleDB import SimpleDB
dbInitial = pyre.inventory.facility("db_initial", factory=SimpleDB,
family="spatial_database")
@@ -117,9 +95,6 @@
PetscComponent._configure(self)
import numpy
- bcDOF = numpy.array(self.inventory.bcDOF, dtype=numpy.int32)
- ModuleTimeDependent.bcDOF(self, bcDOF)
-
if isinstance(self.inventory.dbChange, NullComponent):
if not isinstance(self.inventory.thChange, NullComponent):
raise ValueError("Cannot provide a time history temporal database "
Added: short/3D/PyLith/trunk/pylith/bc/TimeDependentPoints.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/TimeDependentPoints.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/bc/TimeDependentPoints.py 2009-06-16 16:58:24 UTC (rev 15298)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/TimeDependentPoints.py
+##
+## @brief Python abstract base class for managing a boundary condition
+## applied to a set of vertices with time dependent paramters.
+
+from TimeDependent import TimeDependent
+from bc import TimeDependentPoints as ModuleTimeDependentPoints
+
+def validateDOF(value):
+ """
+ Validate list of fixed degrees of freedom.
+ """
+ try:
+ size = len(value)
+ num = map(int, value)
+ for v in num:
+ if v < 0:
+ raise ValueError
+ except:
+ raise ValueError, \
+ "'fixed_dof' must be a zero based list of indices of fixed " \
+ "degrees of freedom."
+ return num
+
+
+# TimeDependentPoints class
+class TimeDependentPoints(TimeDependent, ModuleTimeDependentPoints):
+ """
+ Python abstract base class for managing a boundary condition applied
+ to a set of points with time dependent paramters.
+
+ Factory: boundary_condition
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ bcDOF = pyre.inventory.list("fixed_dof", default=[],
+ validator=validateDOF)
+ bcDOF.meta['tip'] = "Indices of boundary condition DOF " \
+ "(0=1st DOF, 1=2nd DOF, etc)."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="timedependentpoints"):
+ """
+ Constructor.
+ """
+ TimeDependent.__init__(self, name, facility="timedependentpoints")
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ TimeDependent._configure(self)
+
+ import numpy
+ bcDOF = numpy.array(self.inventory.bcDOF, dtype=numpy.int32)
+ ModuleTimeDependentPoints.bcDOF(self, bcDOF)
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/bc/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/__init__.py 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/pylith/bc/__init__.py 2009-06-16 16:58:24 UTC (rev 15298)
@@ -17,6 +17,7 @@
__all__ = ['AbsorbingDampers',
'BoundaryCondition',
'TimeDependent',
+ 'TimeDependentPoints',
'DirichletBC',
'DirichletBoundary',
'Neumann',
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -24,22 +24,6 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestTimeDependent );
// ----------------------------------------------------------------------
-// Test constructor.
-void
-pylith::bc::TestTimeDependent::testBCDOF(void)
-{ // testBCDOF
- PointForce bc;
-
- const size_t numDOF = 4;
- const int fixedDOF[numDOF] = { 0, 2, 3, 5 };
- bc.bcDOF(fixedDOF, numDOF);
-
- CPPUNIT_ASSERT_EQUAL(numDOF, bc._bcDOF.size());
- for (int i=0; i < numDOF; ++i)
- CPPUNIT_ASSERT_EQUAL(fixedDOF[i], bc._bcDOF[i]);
-} // testBCDOF
-
-// ----------------------------------------------------------------------
// Test dbInitial().
void
pylith::bc::TestTimeDependent::testDBInitial(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependent.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -37,7 +37,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestTimeDependent );
- CPPUNIT_TEST( testBCDOF );
CPPUNIT_TEST( testDBInitial );
CPPUNIT_TEST( testDBRate );
CPPUNIT_TEST( testDBChange );
@@ -49,9 +48,6 @@
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
- /// Test bcDOF.
- void testBCDOF(void);
-
/// Test dbInitial().
void testDBInitial(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -148,6 +148,22 @@
} // tearDown
// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::bc::TestTimeDependentPoints::testBCDOF(void)
+{ // testBCDOF
+ PointForce bc;
+
+ const size_t numDOF = 4;
+ const int fixedDOF[numDOF] = { 0, 2, 3, 5 };
+ bc.bcDOF(fixedDOF, numDOF);
+
+ CPPUNIT_ASSERT_EQUAL(numDOF, bc._bcDOF.size());
+ for (int i=0; i < numDOF; ++i)
+ CPPUNIT_ASSERT_EQUAL(fixedDOF[i], bc._bcDOF[i]);
+} // testBCDOF
+
+// ----------------------------------------------------------------------
// Test _getLabel().
void
pylith::bc::TestTimeDependentPoints::testGetLabel(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestTimeDependentPoints.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -40,6 +40,7 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestTimeDependentPoints );
+ CPPUNIT_TEST( testBCDOF );
CPPUNIT_TEST( testGetLabel );
CPPUNIT_TEST( testQueryDB );
CPPUNIT_TEST( testQueryDatabases );
@@ -65,6 +66,9 @@
/// Tear down testing data.
void tearDown(void);
+ /// Test bcDOF.
+ void testBCDOF(void);
+
/// Test _getLabel().
void testGetLabel(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc 2009-06-16 16:58:24 UTC (rev 15298)
@@ -458,6 +458,77 @@
} // testZero
// ----------------------------------------------------------------------
+// Test zero().
+void
+pylith::topology::TestFieldMesh::testZeroAll(void)
+{ // testZeroAll
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+ const int nconstraints[] = { 0, 2, 1, 3 };
+ const int constraints[] = {
+ // 0
+ 0, 2, // 1
+ 2, // 2
+ 0, 1, 2, // 3
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ // Create field and set constraint sizes
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int iV=0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ section->addConstraintDimension(*v_iter, nconstraints[iV++]);
+ field.allocate();
+ int index = 0;
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter, index += nconstraints[i++])
+ section->setConstraintDof(*v_iter, &constraints[index]);
+ field.zero();
+
+ double_array values(fiberDim);
+ i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePointAll(*v_iter, &values[0]);
+ } // for
+
+ field.zeroAll();
+
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[iDim], tolerance);
+ } // for
+ } // for
+} // testZeroAll
+
+// ----------------------------------------------------------------------
// Test complete().
void
pylith::topology::TestFieldMesh::testComplete(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh 2009-06-16 16:48:32 UTC (rev 15297)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh 2009-06-16 16:58:24 UTC (rev 15298)
@@ -56,6 +56,7 @@
CPPUNIT_TEST( testClear );
CPPUNIT_TEST( testAllocate );
CPPUNIT_TEST( testZero );
+ CPPUNIT_TEST( testZeroAll );
CPPUNIT_TEST( testComplete );
CPPUNIT_TEST( testCopy );
CPPUNIT_TEST( testOperatorAdd );
@@ -125,6 +126,9 @@
/// Test zero().
void testZero(void);
+ /// Test zeroAll().
+ void testZeroAll(void);
+
/// Test complete().
void testComplete(void);
More information about the CIG-COMMITS
mailing list