[cig-commits] r7963 - in
short/3D/PyLith/trunk/unittests/libtests/faults: . data
brad at geodynamics.org
brad at geodynamics.org
Thu Sep 13 10:35:05 PDT 2007
Author: brad
Date: 2007-09-13 10:35:02 -0700 (Thu, 13 Sep 2007)
New Revision: 7963
Added:
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4h.mesh
Modified:
short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
Log:
Added unit test for two faults in mesh with quad cells.
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2007-09-13 17:35:02 UTC (rev 7963)
@@ -74,6 +74,7 @@
data/CohesiveDataQuad4e.cc \
data/CohesiveDataQuad4f.cc \
data/CohesiveDataQuad4g.cc \
+ data/CohesiveDataQuad4h.cc \
data/CohesiveDataQuad4Lagrange.cc \
data/CohesiveDataTet4.cc \
data/CohesiveDataTet4b.cc \
@@ -129,6 +130,7 @@
data/CohesiveDataQuad4e.hh \
data/CohesiveDataQuad4f.hh \
data/CohesiveDataQuad4g.hh \
+ data/CohesiveDataQuad4h.hh \
data/CohesiveDataQuad4Lagrange.hh \
data/CohesiveDataTet4.hh \
data/CohesiveDataTet4b.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2007-09-13 17:35:02 UTC (rev 7963)
@@ -36,6 +36,7 @@
#include "data/CohesiveDataQuad4e.hh" // USES CohesiveDataQuad4e
#include "data/CohesiveDataQuad4f.hh" // USES CohesiveDataQuad4f
#include "data/CohesiveDataQuad4g.hh" // USES CohesiveDataQuad4g
+#include "data/CohesiveDataQuad4h.hh" // USES CohesiveDataQuad4h
#include "data/CohesiveDataTet4.hh" // USES CohesiveDataTet4
#include "data/CohesiveDataTet4b.hh" // USES CohesiveDataTet4b
#include "data/CohesiveDataTet4c.hh" // USES CohesiveDataTet4c
@@ -188,7 +189,7 @@
// Test adjustTopology() with 2-D quadrilateral element.
void
pylith::faults::TestFaultCohesive::testAdjustTopologyQuad4f(void)
-{ // testAdjustTopologyQuad4fs
+{ // testAdjustTopologyQuad4f
CohesiveDataQuad4f data;
FaultCohesiveDyn fault;
_testAdjustTopology(&fault, data);
@@ -198,13 +199,24 @@
// Test adjustTopology() with 2-D quadrilateral element.
void
pylith::faults::TestFaultCohesive::testAdjustTopologyQuad4g(void)
-{ // testAdjustTopologyQuad4gs
+{ // testAdjustTopologyQuad4g
CohesiveDataQuad4g data;
FaultCohesiveDyn fault;
_testAdjustTopology(&fault, data);
} // testAdjustTopologyQuad4g
// ----------------------------------------------------------------------
+// Test adjustTopology() with 2-D quadrilateral element.
+void
+pylith::faults::TestFaultCohesive::testAdjustTopologyQuad4h(void)
+{ // testAdjustTopologyQuad4h
+ CohesiveDataQuad4h data;
+ FaultCohesiveDyn faultA;
+ FaultCohesiveDyn faultB;
+ _testAdjustTopology(&faultA, &faultB, data);
+} // testAdjustTopologyQuad4h
+
+// ----------------------------------------------------------------------
// Test adjustTopology() with 3-D tetrahedral element.
void
pylith::faults::TestFaultCohesive::testAdjustTopologyTet4(void)
@@ -553,4 +565,125 @@
} // for
} // _testAdjustTopology
+// ----------------------------------------------------------------------
+// Test adjustTopology().
+void
+pylith::faults::TestFaultCohesive::_testAdjustTopology(Fault* faultA,
+ Fault* faultB,
+ const CohesiveData& data)
+{ // _testAdjustTopology
+ ALE::Obj<ALE::Mesh> mesh;
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(data.filename);
+ iohandler.debug(true);
+ iohandler.interpolate(false);
+ iohandler.read(&mesh);
+
+ CPPUNIT_ASSERT(0 != faultA);
+ faultA->id(1);
+ faultA->label("faultA");
+ faultA->adjustTopology(mesh);
+
+ CPPUNIT_ASSERT(0 != faultB);
+ faultB->id(1);
+ faultB->label("faultB");
+ faultB->adjustTopology(mesh);
+
+ CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh->getDimension());
+
+ // Check vertices
+ const ALE::Obj<Mesh::label_sequence>& vertices = mesh->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 = mesh->getSieve();
+ const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+
+ 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
+
+ // 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
+} // _testAdjustTopology
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2007-09-13 17:35:02 UTC (rev 7963)
@@ -55,6 +55,7 @@
CPPUNIT_TEST( testAdjustTopologyQuad4e );
CPPUNIT_TEST( testAdjustTopologyQuad4f );
CPPUNIT_TEST( testAdjustTopologyQuad4g );
+ CPPUNIT_TEST( testAdjustTopologyQuad4h );
CPPUNIT_TEST( testAdjustTopologyTet4 );
CPPUNIT_TEST( testAdjustTopologyTet4b );
CPPUNIT_TEST( testAdjustTopologyTet4c );
@@ -127,6 +128,9 @@
/// Test adjustTopology() with 2-D quadrilateral element (vertex on fault).
void testAdjustTopologyQuad4g(void);
+ /// Test adjustTopology() with 2-D quadrilateral element (2 faults).
+ void testAdjustTopologyQuad4h(void);
+
/// Test adjustTopology() with 3-D tetrahedral element.
void testAdjustTopologyTet4(void);
@@ -212,6 +216,16 @@
void _testAdjustTopology(Fault* fault,
const CohesiveData& data);
+ /** Test adjustTopology().
+ *
+ * @param faultA First fault for cohesive elements.
+ * @param faultB Second fault for cohesive elements.
+ * @param data Cohesive element data.
+ */
+ void _testAdjustTopology(Fault* faultA,
+ Fault* faultB,
+ const CohesiveData& data);
+
}; // class TestFaultCohesive
#endif // pylith_faults_testfaultcohesive_hh
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.cc 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.cc 2007-09-13 17:35:02 UTC (rev 7963)
@@ -0,0 +1,171 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/* Original mesh
+ *
+ * Cells are 0-8, vertices are 9-24.
+ *
+ * 9 ----10 ----11 ----12
+ * | | | |
+ * | | | |
+ * | | | |
+ * | | | |
+ *13 ----14 ----15 ----16
+ * | | | |
+ * | | | |
+ * | | | |
+ * | | | |
+ *17 ----18 ----19 ----20
+ * | | | |
+ * | | | |
+ * | | | |
+ * | | | |
+ *21 ----22 ----23 ----24
+ *
+ * After adding cohesive elements
+ *
+ * Cells are 0-8,16-17 vertices are 9-24.
+ *
+ * 9 ----10 ----25-11 ----12
+ * | | | | |
+ * | | | | |
+ * | | | | |
+ * | | | | |
+ *13 ----14 ----26-15 ----16
+ * | | | | |
+ * | | | | |
+ * | | | | |
+ * | | | | |
+ *17 ----18 ----27-19 ----20
+ * | | | |
+ *28 ----29 | |
+ * | | | |
+ * | | | |
+ * | | | |
+ * | | | |
+ *21 ----22 ----23 -------24
+ *
+ */
+
+#include "CohesiveDataQuad4h.hh"
+
+const int pylith::faults::CohesiveDataQuad4h::_numVertices = 21;
+
+const int pylith::faults::CohesiveDataQuad4h::_spaceDim = 2;
+
+const int pylith::faults::CohesiveDataQuad4h::_numCells = 12;
+
+const int pylith::faults::CohesiveDataQuad4h::_cellDim = 2;
+
+const double pylith::faults::CohesiveDataQuad4h::_vertices[] = {
+ -3.0, 3.0,
+ -1.0, 3.0,
+ 1.0, 3.0,
+ 3.0, 3.0,
+ -3.0, 1.0,
+ -1.0, 1.0,
+ 1.0, 1.0,
+ 3.0, 1.0,
+ -3.0, -1.0,
+ -1.0, -1.0,
+ 1.0, -1.0,
+ 3.0, -1.0,
+ -3.0, -3.0,
+ -1.0, -3.0,
+ 1.0, -3.0,
+ 3.0, -3.0,
+ 1.0, 3.0,
+ 1.0, 1.0,
+ 1.0, -1.0,
+ -3.0, -1.0,
+ -1.0, -1.0,
+};
+
+const int pylith::faults::CohesiveDataQuad4h::_numCorners[] = {
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+ 4,
+};
+
+const int pylith::faults::CohesiveDataQuad4h::_cells[] = {
+ 9, 13, 14, 10,
+ 10, 14, 26, 25,
+ 11, 15, 16, 12,
+ 13, 30, 31, 14,
+ 14, 31, 27, 26,
+ 15, 19, 20, 16,
+ 17, 21, 22, 18,
+ 31, 22, 23, 27,
+ 27, 23, 24, 20,
+ 11, 15, 25, 26,
+ 15, 19, 26, 27,
+ 18, 17, 31, 30,
+};
+
+const int pylith::faults::CohesiveDataQuad4h::_materialIds[] = {
+ 10, 10, 11, 10, 10, 11, 12, 12, 11,
+ 1, 1, 1, 2, 2,
+};
+
+const int pylith::faults::CohesiveDataQuad4h::_numGroups = 2;
+
+const int pylith::faults::CohesiveDataQuad4h::_groupSizes[] =
+ { 6, 4 };
+
+const int pylith::faults::CohesiveDataQuad4h::_groups[] = {
+ 11, 15, 19, 25, 26, 27,
+ 17, 18, 30, 31,
+};
+
+const char* pylith::faults::CohesiveDataQuad4h::_groupNames[] = {
+ "faultA", "faultB"
+};
+
+const char* pylith::faults::CohesiveDataQuad4h::_groupTypes[] = {
+ "vertex", "vertex"
+};
+
+const char* pylith::faults::CohesiveDataQuad4h::_filename =
+ "data/quad4h.mesh";
+
+pylith::faults::CohesiveDataQuad4h::CohesiveDataQuad4h(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);
+ materialIds = const_cast<int*>(_materialIds);
+ groups = const_cast<int*>(_groups);
+ groupSizes = const_cast<int*>(_groupSizes);
+ groupNames = const_cast<char**>(_groupNames);
+ groupTypes = const_cast<char**>(_groupTypes);
+ numGroups = _numGroups;
+ filename = const_cast<char*>(_filename);
+} // constructor
+
+pylith::faults::CohesiveDataQuad4h::~CohesiveDataQuad4h(void)
+{}
+
+
+// End of file
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.hh 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveDataQuad4h.hh 2007-09-13 17:35:02 UTC (rev 7963)
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_faults_cohesivedataquad4h_hh)
+#define pylith_faults_cohesivedataquad4h_hh
+
+#include "CohesiveData.hh"
+
+namespace pylith {
+ namespace faults {
+ class CohesiveDataQuad4h;
+ } // pylith
+} // faults
+
+class pylith::faults::CohesiveDataQuad4h : public CohesiveData
+{
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public:
+
+ /// Constructor
+ CohesiveDataQuad4h(void);
+
+ /// Destructor
+ ~CohesiveDataQuad4h(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 int _materialIds[]; ///< Pointer to cell material identifiers
+
+ static const int _groups[]; ///< Groups of points
+ static const int _groupSizes[]; ///< Sizes of groups
+ static const char* _groupNames[]; ///< Array of group names
+ static const char* _groupTypes[]; ///< Array of group types
+ static const int _numGroups; ///< Number of groups
+
+ static const char* _filename; ///< Filename of input mesh
+};
+
+#endif // pylith_faults_cohesivedataquad4h_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am 2007-09-13 17:35:02 UTC (rev 7963)
@@ -38,6 +38,7 @@
quad4e.mesh \
quad4f.mesh \
quad4g.mesh \
+ quad4h.mesh \
quad4_finalslip.spatialdb \
quad4_sliptime.spatialdb \
quad4_peakrate.spatialdb \
Added: short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4h.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4h.mesh 2007-09-13 16:01:06 UTC (rev 7962)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4h.mesh 2007-09-13 17:35:02 UTC (rev 7963)
@@ -0,0 +1,71 @@
+mesh = {
+ dimension = 2
+ use-index-zero = true
+ vertices = {
+ dimension = 2
+ count = 16
+ coordinates = {
+ 0 -3.0 3.0
+ 1 -1.0 3.0
+ 2 1.0 3.0
+ 3 3.0 3.0
+ 4 -3.0 1.0
+ 5 -1.0 1.0
+ 6 1.0 1.0
+ 7 3.0 1.0
+ 8 -3.0 -1.0
+ 9 -1.0 -1.0
+ 10 1.0 -1.0
+ 11 3.0 -1.0
+ 12 -3.0 -3.0
+ 13 -1.0 -3.0
+ 14 1.0 -3.0
+ 15 3.0 -3.0
+ }
+ }
+ cells = {
+ count = 9
+ num-corners = 4
+ simplices = {
+ 0 0 4 5 1
+ 1 1 5 6 2
+ 2 2 6 7 3
+ 3 4 8 9 5
+ 4 5 9 10 6
+ 5 6 10 11 7
+ 6 8 12 13 9
+ 7 9 13 14 10
+ 8 10 14 15 11
+ }
+ material-ids = {
+ 0 10
+ 1 10
+ 2 11
+ 3 10
+ 4 10
+ 5 11
+ 6 12
+ 7 12
+ 8 11
+ }
+ }
+ group = {
+ name = faultA
+ type = vertices
+ count = 3
+ indices = {
+ 2
+ 6
+ 10
+ }
+ }
+ group = {
+ name = faultB
+ type = vertices
+ count = 2
+ indices = {
+ 8
+ 9
+ }
+ }
+}
More information about the cig-commits
mailing list