[cig-commits] r7746 - in
short/3D/PyLith/trunk/unittests/libtests/bc: . data
willic3 at geodynamics.org
willic3 at geodynamics.org
Wed Jul 25 14:27:06 PDT 2007
Author: willic3
Date: 2007-07-25 14:27:06 -0700 (Wed, 25 Jul 2007)
New Revision: 7746
Added:
short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.cc
short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.hh
short/3D/PyLith/trunk/unittests/libtests/bc/data/hex8b.mesh
Modified:
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
Log:
More work on unit tests for Neumann BC.
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc 2007-07-25 21:26:35 UTC (rev 7745)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc 2007-07-25 21:27:06 UTC (rev 7746)
@@ -82,22 +82,28 @@
} // for
// Check traction values
- const ALE::Obj<ALE::Mesh::label_sequence>& vertices =
- _boundaryMesh->heightStratum(0);
- const int numVertices = vertices->size();
- CPPUNIT_ASSERT_EQUAL(_data.numVertices, numVertices);
- int i = 0;
- const int spaceDim = _data.spaceDim;
- for(Mesh::label_sequance::iterator v_iter =
- vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const Mesh::real_section_type::value_type *tractionVals =
- _tractionGlobal->restrictPoint(*v_iter);
- const double tolerance = 1.0e-06;
- for(int iDim=0; iDim < spaceDim; ++iDim)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->tractionVals[i], tractionVals[iDim],
- tolerance);
+ numQuadPts = _data->numQuadPts;
+ spaceDim = _data->spaceDim;
+ fiberDim = numQuadPts * spaceDim;
+ double_array tractionCell(fiberDim);
+ int index = 0;
+ const double tolerance = 1.0e-06;
+
+ for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ c_iter != cells->end();
+ ++c_iter) {
+
+ _boundaryMesh->restrict(_tractionGlobal, *c_iter,
+ &tractionCell[0], tractionCell.size());
+
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
+ for (int iDim =0; iDim < spaceDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->tractionCell[index],
+ tractionCell[iQuad*spaceDim+iDim],
+ tolerance);
+ ++index;
+ } // for
+ } // for
} // for
} // testInitialize
@@ -107,44 +113,45 @@
void
pylith::bc::TestNeumann::testIntegrateResidual(void)
{ // testIntegrateResidual
+ CPPUNIT_ASSERT(0 != _data);
+
ALE::Obj<Mesh> mesh;
Neumann bc;
+ Neumann integrator;
+ topology::FieldsManager fields(mesh);
+ _initialize(&mesh, &bc, &fields);
- _initialize(&mesh, &bc);
const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fields->addReal("dispTBctpdt");
- fields->copyLayout("residual");
+ CPPUNIT_ASSERT(!residual.isNull());
const double t = 0.0;
+ integrator.integrateResidual(residual, t, &fields, mesh);
- CPPUNIT_ASSERT(0 != _data);
+ const double* valsE = _data->valsResidual;
+ const int sizeE = _data->spaceDim * _data->numVertices;
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, field->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
- field->getConstraintDimension(*v_iter));
- ++iConstraint;
- } // if/else
- } // for
+ const double* vals = residual->restrict();
+ const int size = residual->sizeWithBC();
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < size; ++i)
+ if (fabs(valsE[i]) > 1.0)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vals[i]/valsE[i], tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valsE[i], vals[i], tolerance);
+
} // testIntegrateResidual
// ----------------------------------------------------------------------
void
pylith::bc::TestNeumann::_initialize(ALE::Obj<Mesh>* mesh,
- Neumann* const bc) const
+ Neumann* const bc,
+ topology::FieldsManager* fields) const
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != bc);
+ CPPUNIT_ASSERT(0 != fields);
CPPUNIT_ASSERT(0 != _quadrature);
// Set up mesh
@@ -159,6 +166,18 @@
cs.setSpaceDim((*mesh)->getDimension());
cs.initialize();
+ // Set up fields
+ fields->addReal("residual");
+ fields->addReal("solution");
+ const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
+ CPPUNIT_ASSERT(!residual.isNull());
+ residual->setFiberDimension((*mesh)->depthStratum(0), _data->spaceDim);
+ (*mesh)->allocate(residual);
+ residual->zero();
+ fields->copyLayout("residual");
+ const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
+ CPPUNIT_ASSERT(!solution.isNull());
+
// Set up quadrature
_quadrature->initialize(_data->basis, _data->basisDeriv, _data->quadPts,
_data->quadWts, _data->cellDim, _data->numBasis,
Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.cc 2007-07-25 21:26:35 UTC (rev 7745)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.cc 2007-07-25 21:27:06 UTC (rev 7746)
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DirichletData.hh"
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::bc::DirichletData::DirichletData(void) :
+ numDOF(0),
+ numFixedDOF(0),
+ numConstrainedPts(0),
+ id(0),
+ label(0),
+ fixedDOF(0),
+ constrainedPoints(0),
+ values(0),
+ meshFilename(0),
+ dbFilename(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::bc::DirichletData::~DirichletData(void)
+{ // destructor
+} // destructor
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.hh 2007-07-25 21:26:35 UTC (rev 7745)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/NeumannData.hh 2007-07-25 21:27:06 UTC (rev 7746)
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_bc_neumanndata_hh)
+#define pylith_bc_neumanndata_hh
+
+namespace pylith {
+ namespace bc {
+ class NeumannData;
+ } // pylith
+} // bc
+
+class pylith::bc::NeumannData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ NeumannData(void);
+
+ /// Destructor
+ ~NeumannData(void);
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public:
+
+ int numDOF; ///< Number of degrees of freedom at each point.
+ int boundaryCellDim; ///< Dimension of surface cells.
+ int numBoundaryCells; ///< Number of cells on Neumann boundary.
+ int numBoundaryVertices; ///< Number of vertices on Neumann boundary.
+ int numVertices; ///< Number of vertices in the mesh.
+ int spaceDim; ///< Spatial dimension for the problem.
+
+ int id; ///< Boundary condition identifier
+ char* label; ///< Label for boundary condition group
+
+ int* numCorners; ///< Array defining the number of vertices for each
+ /// boundary cell.
+ int* cells; ///< Array of vertices defining each boundary cell.
+ double* tractionVals; ///< Traction values at specified points.
+
+ char* meshFilename; ///< Filename for input mesh.
+ char* dbFilename; ///< Filename of simple spatial database.
+};
+
+#endif // pylith_bc_neumanndata_hh
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/bc/data/hex8b.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/data/hex8b.mesh 2007-07-25 21:26:35 UTC (rev 7745)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/data/hex8b.mesh 2007-07-25 21:27:06 UTC (rev 7746)
@@ -0,0 +1,47 @@
+mesh = {
+ dimension = 3
+ use-index-zero = true
+ vertices = {
+ dimension = 3
+ count = 12
+ coordinates = {
+ 0 -2.0 -1.0 -1.0
+ 1 -2.0 1.0 -1.0
+ 2 -2.0 -1.0 1.0
+ 3 -2.0 1.0 1.0
+ 4 0.0 -1.0 -1.0
+ 5 0.0 1.0 -1.0
+ 6 0.0 -1.0 1.0
+ 7 0.0 1.0 1.0
+ 8 2.0 -1.0 -1.0
+ 9 2.0 1.0 -1.0
+ 10 2.0 -1.0 1.0
+ 11 2.0 1.0 1.0
+ }
+ }
+ cells = {
+ count = 2
+ num-corners = 8
+ simplices = {
+ 0 0 1 3 2 4 5 7 6
+ 1 4 5 7 6 8 9 11 10
+ }
+ material-ids = {
+ 0 0
+ 1 0
+ }
+ }
+ group = {
+ name = tractionVerts
+ type = vertices
+ count = 6
+ indices = {
+ 0
+ 2
+ 4
+ 6
+ 8
+ 10
+ }
+ }
+}
More information about the cig-commits
mailing list