[cig-commits] r7601 - in short/3D/PyLith/trunk: libsrc/faults
unittests/libtests/faults unittests/libtests/faults/data
knepley at geodynamics.org
knepley at geodynamics.org
Wed Jul 4 08:49:00 PDT 2007
Author: knepley
Date: 2007-07-04 08:48:59 -0700 (Wed, 04 Jul 2007)
New Revision: 7601
Added:
short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3traction.mesh
Modified:
short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc
short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
Log:
Moved some topology operations to PETSc, added a test for boundary extraction
Modified: short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc 2007-07-04 15:48:59 UTC (rev 7601)
@@ -13,6 +13,7 @@
#include <portinfo>
#include "CohesiveTopology.hh" // implementation of object methods
+#include <Selection.hh> // Algorithms for submeshes
#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
@@ -29,6 +30,7 @@
assert(0 != fault);
typedef ALE::SieveAlg<Mesh> sieveAlg;
+ typedef ALE::Selection<Mesh> selection;
typedef std::set<Mesh::point_type> PointSet;
const int_section_type::chart_type& chart = groupField->getChart();
@@ -48,7 +50,7 @@
if (!(*fault)->commRank()) {
numCorners = sieve->nCone(*mesh->heightStratum(0)->begin(), mesh->depth())->size();
- faceSize = _numFaceVertices(*mesh->heightStratum(0)->begin(), mesh);
+ faceSize = selection::numFaceVertices(*mesh->heightStratum(0)->begin(), mesh);
indices = new int[faceSize];
}
@@ -112,7 +114,7 @@
faultSieve->addArrow(*preFace->begin(), *c_iter);
} else if (preFace->size() == 0) {
if (debug) std::cout << " Orienting face " << f << std::endl;
- _getOrientedFace(mesh, *c_iter, face, numCorners, indices, &origVertices, &faceVertices);
+ selection::getOrientedFace(mesh, *c_iter, face, numCorners, indices, &origVertices, &faceVertices);
if (debug) std::cout << " Adding face " << f << std::endl;
int color = 0;
for(PointArray::const_iterator f_iter = faceVertices.begin();
@@ -142,7 +144,7 @@
numFaultCorners = faultSieve->nCone(*fFaces->begin(), faultDepth)->size();
if (debug) std::cout << " Fault corners " << numFaultCorners << std::endl;
assert(numFaultCorners == faceSize);
- faultFaceSize = _numFaceVertices(*fFaces->begin(), (*fault), faultDepth);
+ faultFaceSize = selection::numFaceVertices(*fFaces->begin(), (*fault), faultDepth);
}
if (debug) std::cout << " Fault face size " << faultFaceSize << std::endl;
// Do BFS on the fault mesh
@@ -236,8 +238,8 @@
}
if ((int) meet->size() == faultFaceSize) {
if (debug) std::cout << " Found neighboring fault face " << *n_iter << std::endl;
- bool eOrient = _getOrientedFace(*fault, *e_iter, meet, numFaultCorners, indices, &origVertices, &faceVertices);
- bool nOrient = _getOrientedFace(*fault, *n_iter, meet, numFaultCorners, indices, &origVertices, &neighborVertices);
+ bool eOrient = selection::getOrientedFace(*fault, *e_iter, meet, numFaultCorners, indices, &origVertices, &faceVertices);
+ bool nOrient = selection::getOrientedFace(*fault, *n_iter, meet, numFaultCorners, indices, &origVertices, &neighborVertices);
if (faultFaceSize > 1) {
if (debug) {
@@ -319,7 +321,7 @@
Mesh::point_type otherCell;
if (debug) std::cout << " Checking orientation against cell " << cell << std::endl;
- _getOrientedFace(mesh, cell, &vertexRenumber, numCorners, indices, &origVertices, &faceVertices);
+ selection::getOrientedFace(mesh, cell, &vertexRenumber, numCorners, indices, &origVertices, &faceVertices);
const ALE::Obj<sieve_type::traits::coneSequence>& faceCone = faultSieve->cone(*f_iter);
bool found = true;
@@ -458,308 +460,6 @@
if (debug) coordinates->view("Coordinates with shadow vertices");
} // createCohesiveCells
-// ----------------------------------------------------------------------
-unsigned int
-pylith::faults::CohesiveTopology::_numFaceVertices(const Mesh::point_type& cell,
- const ALE::Obj<Mesh>& mesh,
- const int depth)
-{ // _numFaceVertices
-
- /** :QUESTION:
- *
- * If mesh is interpolated is there a simple way to get the number
- * of vertices on the face (3-D), edge (2-D), end (1-D) of a cell?
- */
- const int cellDim = mesh->getDimension();
-
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- int meshDepth = (depth < 0) ? mesh->depth() : depth;
- unsigned int numCorners = sieve->nCone(cell, meshDepth)->size();
-
- unsigned int numFaceVertices = 0;
- switch (cellDim)
- { // switch
- case 0 :
- numFaceVertices = 0;
- break;
- case 1 :
- numFaceVertices = 1;
- break;
- case 2:
- switch (numCorners)
- { // switch
- case 3 : // tri3
- numFaceVertices = 2; // Edge has 2 vertices
- break;
- case 4 : // quad4
- numFaceVertices = 2; // Edge has 2 vertices
- break;
- default :
- std::cerr << "numCorners: " << numCorners << std::endl;
- assert(0);
- } // switch
- break;
- case 3:
- switch (numCorners)
- { // switch
- case 4 : // tet4
- numFaceVertices = 3; // Face has 3 vertices
- break;
- case 8 : // hex8
- numFaceVertices = 4; // Face has 4 vertices
- break;
- default :
- std::cerr << "numCorners: " << numCorners << std::endl;
- assert(0);
- } // switch
- break;
- default:
- assert(0);
- } // swtich
- return numFaceVertices;
-} // _numFaceVertices
-
-// ----------------------------------------------------------------------
-// We need this method because we do not use interpolates sieves
-// - Without interpolation, we cannot say what vertex collections are
-// faces, and how they are oriented
-// - Now we read off the list of face vertices IN THE ORDER IN WHICH
-// THEY APPEAR IN THE CELL
-// - This leads to simple algorithms for simplices and quads to check
-// orientation since these sets are always valid faces
-// - This is not true with hexes, so we just sort and check explicit cases
-// - This means for hexes that we have to alter the vertex container as well
-bool
-pylith::faults::CohesiveTopology::_faceOrientation(const Mesh::point_type& cell,
- const ALE::Obj<Mesh>& mesh,
- const int numCorners,
- const int indices[],
- const int oppositeVertex,
- PointArray *origVertices,
- PointArray *faceVertices)
-{ // _faceOrientation
- const int cellDim = mesh->getDimension();
- bool posOrient = false;
- int debug = mesh->debug();
-
- // Simplices
- if (cellDim == numCorners-1) {
- posOrient = !(oppositeVertex%2);
- } else if (cellDim == 2) {
- // Quads
- if ((indices[1] > indices[0]) && (indices[1] - indices[0] == 1)) {
- posOrient = true;
- } else if ((indices[0] == 3) && (indices[1] == 0)) {
- posOrient = true;
- } else {
- posOrient = false;
- }
- } else if (cellDim == 3) {
- // Hexes
- // A hex is two oriented quads with the normal of the first
- // pointing up at the second.
- //
- // 7---6
- // /| /|
- // 4---5 |
- // | 3-|-2
- // |/ |/
- // 0---1
- int sortedIndices[4];
-
- for(int i = 0; i < 4; ++i) sortedIndices[i] = indices[i];
- std::sort(sortedIndices, sortedIndices+4);
- // Case 1: Bottom quad
- if ((sortedIndices[0] == 0) && (sortedIndices[1] == 1) && (sortedIndices[2] == 2) && (sortedIndices[3] == 3)) {
- if (debug) std::cout << "Bottom quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 3) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 2) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 1) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 0) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- // Case 2: Top quad
- if ((sortedIndices[0] == 4) && (sortedIndices[1] == 5) && (sortedIndices[2] == 6) && (sortedIndices[3] == 7)) {
- if (debug) std::cout << "Top quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 5) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 6) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 7) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 4) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- // Case 3: Front quad
- if ((sortedIndices[0] == 0) && (sortedIndices[1] == 1) && (sortedIndices[2] == 4) && (sortedIndices[3] == 5)) {
- if (debug) std::cout << "Front quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 1) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 5) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 4) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 0) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- // Case 4: Back quad
- if ((sortedIndices[0] == 2) && (sortedIndices[1] == 3) && (sortedIndices[2] == 6) && (sortedIndices[3] == 7)) {
- if (debug) std::cout << "Back quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 7) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 6) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 2) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 3) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- // Case 5: Right quad
- if ((sortedIndices[0] == 1) && (sortedIndices[1] == 2) && (sortedIndices[2] == 5) && (sortedIndices[3] == 6)) {
- if (debug) std::cout << "Right quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 2) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 6) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 5) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 1) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- // Case 6: Left quad
- if ((sortedIndices[0] == 0) && (sortedIndices[1] == 3) && (sortedIndices[2] == 4) && (sortedIndices[3] == 7)) {
- if (debug) std::cout << "Left quad" << std::endl;
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 4) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 7) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 3) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- for(int i = 0; i < 4; ++i) {
- if (indices[i] == 0) {
- faceVertices->push_back((*origVertices)[i]); break;
- }
- }
- }
- return true;
- }
- if (!posOrient) {
- if (debug) std::cout << " Reversing initial face orientation" << std::endl;
- faceVertices->insert(faceVertices->end(), (*origVertices).rbegin(), (*origVertices).rend());
- } else {
- if (debug) std::cout << " Keeping initial face orientation" << std::endl;
- faceVertices->insert(faceVertices->end(), (*origVertices).begin(), (*origVertices).end());
- }
- return posOrient;
-} // _faceOrientation
-
-// ----------------------------------------------------------------------
-// Given a cell and a face, as a set of vertices,
-// return the oriented face, as a set of vertices, in faceVertices
-// The orientation is such that the face normal points out of the cell
-template<typename FaceType>
-bool
-pylith::faults::CohesiveTopology::_getOrientedFace(const ALE::Obj<Mesh>& mesh,
- const Mesh::point_type& cell,
- FaceType face,
- const int numCorners,
- int indices[],
- PointArray *origVertices,
- PointArray *faceVertices)
-{
- const ALE::Obj<sieve_type::traits::coneSequence>& cone = mesh->getSieve()->cone(cell);
- const int debug = mesh->debug();
- int v = 0;
- int oppositeVertex;
-
- origVertices->clear();
- faceVertices->clear();
- for(sieve_type::traits::coneSequence::iterator v_iter = cone->begin();
- v_iter != cone->end(); ++v_iter, ++v) {
- if (face->find(*v_iter) != face->end()) {
- if (debug) std::cout << " vertex " << *v_iter << std::endl;
- indices[origVertices->size()] = v;
- origVertices->insert(origVertices->end(), *v_iter);
- } else {
- if (debug) std::cout << " vertex " << *v_iter << std::endl;
- oppositeVertex = v;
- }
- }
- return _faceOrientation(cell, mesh, numCorners, indices, oppositeVertex, origVertices, faceVertices);
-}
-
template<class InputPoints>
bool
pylith::faults::CohesiveTopology::_compatibleOrientation(const ALE::Obj<Mesh>& mesh,
@@ -774,11 +474,12 @@
PointArray *faceVertices,
PointArray *neighborVertices)
{
+ typedef ALE::Selection<Mesh> selection;
const int debug = mesh->debug();
bool compatible;
- bool eOrient = _getOrientedFace(mesh, p, points, numFaultCorners, indices, origVertices, faceVertices);
- bool nOrient = _getOrientedFace(mesh, q, points, numFaultCorners, indices, origVertices, neighborVertices);
+ bool eOrient = selection::getOrientedFace(mesh, p, points, numFaultCorners, indices, origVertices, faceVertices);
+ bool nOrient = selection::getOrientedFace(mesh, q, points, numFaultCorners, indices, origVertices, neighborVertices);
if (faultFaceSize > 1) {
if (debug) {
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2007-07-04 15:48:59 UTC (rev 7601)
@@ -35,6 +35,7 @@
TestFaultCohesiveKinTet4e.cc \
TestFaultCohesiveKinTet4f.cc \
TestFaultCohesiveKinHex8.cc \
+ TestBoundary.cc \
test_faults.cc
noinst_HEADERS = \
@@ -51,7 +52,8 @@
TestFaultCohesiveKinTet4.hh \
TestFaultCohesiveKinTet4e.hh \
TestFaultCohesiveKinTet4f.hh \
- TestFaultCohesiveKinHex8.hh
+ TestFaultCohesiveKinHex8.hh \
+ TestBoundary.hh
# Source files associated with testing data
testfaults_SOURCES += \
@@ -98,7 +100,9 @@
data/CohesiveKinDataTet4.cc \
data/CohesiveKinDataTet4e.cc \
data/CohesiveKinDataTet4f.cc \
- data/CohesiveKinDataHex8.cc
+ data/CohesiveKinDataHex8.cc \
+ data/BoundaryData.cc \
+ data/BoundaryDataTri3.cc
noinst_HEADERS += \
data/CohesiveData.hh \
@@ -144,7 +148,9 @@
data/CohesiveKinDataTet4.hh \
data/CohesiveKinDataTet4e.hh \
data/CohesiveKinDataTet4f.hh \
- data/CohesiveKinDataHex8.hh
+ data/CohesiveKinDataHex8.hh \
+ data/BoundaryData.hh \
+ data/BoundaryDataTri3.hh
AM_CPPFLAGS = $(PETSC_SIEVE_FLAGS) $(PETSC_INCLUDE)
Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.cc 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.cc 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,149 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestBoundary.hh" // Implementation of class methods
+
+#include <Selection.hh> // USES submesh algorithms
+
+#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/utils/array.hh" // USES int_array, double_array
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+#include "data/BoundaryDataTri3.hh" // USES BoundaryDataTri3
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestBoundary );
+
+// ----------------------------------------------------------------------
+// Test createBoundary() with 2-D triangular element.
+void
+pylith::faults::TestBoundary::testCreateBoundaryTri3(void)
+{ // testCreateBoundaryTri3
+ BoundaryDataTri3 data;
+ _testCreateBoundary(data);
+} // testCreateBoundaryTri3
+
+// ----------------------------------------------------------------------
+// Test createBoundary().
+void
+pylith::faults::TestBoundary::_testCreateBoundary(const BoundaryData& data)
+{ // _testAdjustTopology
+ ALE::Obj<ALE::Mesh> mesh;
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(data.filename);
+ iohandler.debug(false);
+ iohandler.interpolate(false);
+ iohandler.read(&mesh);
+
+ // Extract submesh for "traction"
+ const ALE::Obj<ALE::Mesh> submesh = ALE::Selection<ALE::Mesh>::submesh(mesh, mesh->getIntSection("traction"));
+
+ CPPUNIT_ASSERT_EQUAL(data.cellDim, submesh->getDimension());
+
+ // Check vertices
+ const ALE::Obj<Mesh::label_sequence>& vertices = submesh->depthStratum(0);
+ const ALE::Obj<Mesh::real_section_type>& coordsField =
+ mesh->getRealSection("coordinates");
+ const int numVertices = vertices->size();
+ CPPUNIT_ASSERT_EQUAL(data.numVertices, numVertices);
+ CPPUNIT_ASSERT_EQUAL(data.spaceDim,
+ coordsField->getFiberDimension(*vertices->begin()));
+ int i = 0;
+ const int spaceDim = data.spaceDim;
+ for(Mesh::label_sequence::iterator v_iter =
+ vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const Mesh::real_section_type::value_type *vertexCoords =
+ coordsField->restrictPoint(*v_iter);
+ const double tolerance = 1.0e-06;
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ if (data.vertices[i] < 1.0)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.vertices[i++], vertexCoords[iDim],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vertexCoords[iDim]/data.vertices[i++],
+ tolerance);
+ } // for
+
+ // check cells
+ const ALE::Obj<sieve_type>& sieve = submesh->getSieve();
+ const ALE::Obj<Mesh::label_sequence>& cells = submesh->heightStratum(1);
+
+ const int numCells = cells->size();
+ CPPUNIT_ASSERT_EQUAL(data.numCells, numCells);
+
+ int iCell = 0;
+ i = 0;
+ //mesh->view(data.filename);
+ for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ c_iter != cells->end();
+ ++c_iter) {
+ const int numCorners = sieve->nCone(*c_iter, mesh->depth())->size();
+ CPPUNIT_ASSERT_EQUAL(data.numCorners[iCell++], numCorners);
+ const ALE::Obj<sieve_type::traits::coneSequence>& cone =
+ sieve->cone(*c_iter);
+ for(sieve_type::traits::coneSequence::iterator v_iter = cone->begin();
+ v_iter != cone->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(data.cells[i++], *v_iter);
+ } // for
+#if 0
+ // check materials
+ const ALE::Obj<Mesh::label_type>& labelMaterials =
+ mesh->getLabel("material-id");
+ const int idDefault = -999;
+ const int size = numCells;
+ int_array materialIds(size);
+ i = 0;
+ for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ c_iter != cells->end();
+ ++c_iter)
+ materialIds[i++] = mesh->getValue(labelMaterials, *c_iter, idDefault);
+
+ for (int iCell=0; iCell < numCells; ++iCell)
+ CPPUNIT_ASSERT_EQUAL(data.materialIds[iCell], materialIds[iCell]);
+
+ // Check groups
+ const ALE::Obj<std::set<std::string> >& groupNames =
+ mesh->getIntSections();
+ int iGroup = 0;
+ int index = 0;
+ for (std::set<std::string>::const_iterator name=groupNames->begin();
+ name != groupNames->end();
+ ++name, ++iGroup) {
+ const ALE::Obj<int_section_type>& groupField = mesh->getIntSection(*name);
+ CPPUNIT_ASSERT(!groupField.isNull());
+ const int_section_type::chart_type& chart = groupField->getChart();
+ const Mesh::point_type firstPoint = *chart.begin();
+ std::string groupType =
+ (mesh->height(firstPoint) == 0) ? "cell" : "vertex";
+ const int numPoints = chart.size();
+ int_array points(numPoints);
+ int i = 0;
+ for(int_section_type::chart_type::iterator c_iter = chart.begin();
+ c_iter != chart.end();
+ ++c_iter)
+ points[i++] = *c_iter;
+
+ CPPUNIT_ASSERT_EQUAL(std::string(data.groupNames[iGroup]), *name);
+ CPPUNIT_ASSERT_EQUAL(std::string(data.groupTypes[iGroup]), groupType);
+ CPPUNIT_ASSERT_EQUAL(data.groupSizes[iGroup], numPoints);
+ for (int i=0; i < numPoints; ++i)
+ CPPUNIT_ASSERT_EQUAL(data.groups[index++], points[i]);
+ } // for
+#endif
+} // _testCreateBoundary
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.hh 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBoundary.hh 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/faults/TestBoundary.hh
+ *
+ * @brief C++ TestBoundary object
+ *
+ * C++ unit testing for Fault.
+ */
+
+#if !defined(pylith_faults_testboundary_hh)
+#define pylith_faults_testboundary_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/utils/sievefwd.hh" // USES PETSc Mesh
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace faults {
+ class TestBoundary;
+ class BoundaryData;
+ } // faults
+} // pylith
+
+/// C++ unit testing for Fault
+class pylith::faults::TestBoundary : public CppUnit::TestFixture
+{ // class TestBoundary
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestBoundary );
+
+ CPPUNIT_TEST( testCreateBoundaryTri3 );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test createBoundary() with 2-D triangular element.
+ void testCreateBoundaryTri3(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+public :
+
+ /** Test createBoundary().
+ *
+ * @param fault Fault for cohesive elements.
+ * @param data Cohesive element data.
+ */
+ void _testCreateBoundary(const BoundaryData& data);
+
+}; // class TestBoundary
+
+#endif // pylith_faults_testboundary_hh
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.cc 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.cc 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "BoundaryData.hh"
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::faults::BoundaryData::BoundaryData(void) :
+ numVertices(0),
+ spaceDim(0),
+ numCells(0),
+ cellDim(0),
+ vertices(0),
+ numCorners(0),
+ cells(0),
+ filename(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::faults::BoundaryData::~BoundaryData(void)
+{ // destructor
+} // destructor
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.hh 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryData.hh 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_faults_boundarydata_hh)
+#define pylith_faults_boundarydata_hh
+
+namespace pylith {
+ namespace faults {
+ class BoundaryData;
+ } // pylith
+} // faults
+
+class pylith::faults::BoundaryData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ BoundaryData(void);
+
+ /// Destructor
+ ~BoundaryData(void);
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public:
+
+ int numVertices; ///< Number of vertices
+ int spaceDim; ///< Number of dimensions in vertex coordinates
+ int numCells; ///< Number of cells
+ int cellDim; ///< Number of dimensions associated with cell
+
+ double* vertices; ///< Pointer to coordinates of vertices
+ int* numCorners; ///< Number of vertices in cell
+ int* cells; ///< Pointer to indices of vertices in cells
+
+ char* filename; ///< Filename for input mesh
+};
+
+#endif // pylith_faults_boundarydata_hh
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.cc 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.cc 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/* Original mesh
+ *
+ * Cells are 0-1, vertices are 2-5.
+ *
+ * 3
+ * /|\
+ * / | \
+ * / | \
+ * / | \
+ * 2 | 5
+ * \ | /
+ * \ | /
+ * \ | /
+ * \|/
+ * 4
+ *
+ * The boundary is
+ *
+ * 3
+ * / \
+ * / \
+ * / \
+ * / \
+ * 2 5
+ * \ /
+ * \ /
+ * \ /
+ * \ /
+ * 4
+ */
+
+#include "BoundaryDataTri3.hh"
+
+const int pylith::faults::BoundaryDataTri3::_numVertices = 4;
+
+const int pylith::faults::BoundaryDataTri3::_spaceDim = 2;
+
+const int pylith::faults::BoundaryDataTri3::_numCells = 4;
+
+const int pylith::faults::BoundaryDataTri3::_cellDim = 1;
+
+const double pylith::faults::BoundaryDataTri3::_vertices[] = {
+ -1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, -1.0,
+ 1.0, 0.0,
+};
+
+const int pylith::faults::BoundaryDataTri3::_numCorners[] = {
+ 2,
+ 2,
+ 2,
+ 2
+};
+
+const int pylith::faults::BoundaryDataTri3::_cells[] = {
+ 3, 2,
+ 2, 4,
+ 5, 3,
+ 4, 5,
+};
+
+const char* pylith::faults::BoundaryDataTri3::_filename = "data/tri3traction.mesh";
+
+pylith::faults::BoundaryDataTri3::BoundaryDataTri3(void)
+{ // constructor
+ numVertices = _numVertices;
+ spaceDim = _spaceDim;
+ numCells = _numCells;
+ cellDim = _cellDim;
+ vertices = const_cast<double*>(_vertices);
+ numCorners = const_cast<int*>(_numCorners);
+ cells = const_cast<int*>(_cells);
+ filename = const_cast<char*>(_filename);
+} // constructor
+
+pylith::faults::BoundaryDataTri3::~BoundaryDataTri3(void)
+{}
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.hh 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/BoundaryDataTri3.hh 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_faults_boundarydatatri3_hh)
+#define pylith_faults_boundarydatatri3_hh
+
+#include "BoundaryData.hh"
+
+namespace pylith {
+ namespace faults {
+ class BoundaryDataTri3;
+ } // pylith
+} // faults
+
+class pylith::faults::BoundaryDataTri3 : public BoundaryData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public:
+
+ /// Constructor
+ BoundaryDataTri3(void);
+
+ /// Destructor
+ ~BoundaryDataTri3(void);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private:
+
+ static const int _numVertices; ///< Number of vertices
+ static const int _spaceDim; ///< Number of dimensions in vertex coordinates
+ static const int _numCells; ///< Number of cells
+ static const int _cellDim; ///< Number of dimensions associated with cell
+
+ static const double _vertices[]; ///< Pointer to coordinates of vertices
+ static const int _numCorners[]; ///< Number of vertices in cell
+ static const int _cells[]; ///< Pointer to indices of vertices in cells
+
+ static const char* _filename; ///< Filename of input mesh
+};
+
+#endif // pylith_faults_boundarydatatri3_hh
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3traction.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3traction.mesh 2007-07-04 00:02:42 UTC (rev 7600)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3traction.mesh 2007-07-04 15:48:59 UTC (rev 7601)
@@ -0,0 +1,56 @@
+mesh = {
+ dimension = 2
+ use-index-zero = true
+ vertices = {
+ dimension = 2
+ count = 4
+ coordinates = {
+ 0 -1.0 0.0
+ 1 0.0 1.0
+ 2 0.0 -1.0
+ 3 1.0 0.0
+ }
+ }
+ cells = {
+ count = 2
+ num-corners = 3
+ simplices = {
+ 0 0 2 1
+ 1 1 2 3
+ }
+ material-ids = {
+ 0 0
+ 1 0
+ }
+ }
+ group = {
+ name = fault
+ type = vertices
+ count = 2
+ indices = {
+ 1
+ 2
+ }
+ }
+ group = {
+ name = output
+ type = vertices
+ count = 3
+ indices = {
+ 1
+ 2
+ 3
+ }
+ }
+ group = {
+ name = traction
+ type = vertices
+ count = 4
+ indices = {
+ 0
+ 1
+ 3
+ 2
+ }
+ }
+}
More information about the cig-commits
mailing list