[cig-commits] r21303 - in short/3D/PyLith/trunk: libsrc/pylith/faults libsrc/pylith/friction libsrc/pylith/topology unittests/libtests/friction
knepley at geodynamics.org
knepley at geodynamics.org
Mon Jan 28 17:51:27 PST 2013
Author: knepley
Date: 2013-01-28 17:51:27 -0800 (Mon, 28 Jan 2013)
New Revision: 21303
Modified:
short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc
short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc
short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc
short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveLagrange.cc
short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.cc
short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.hh
short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
short/3D/PyLith/trunk/unittests/libtests/friction/TestFrictionModel.cc
Log:
Corrected bug with orientation section
Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveDyn.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -264,6 +264,7 @@
err = VecGetArray(dispTVec, &dispTArray);CHECK_PETSC_ERROR(err);
err = VecGetArray(dispTIncrVec, &dispTIncrArray);CHECK_PETSC_ERROR(err);
err = VecGetArray(residualVec, &residualArray);CHECK_PETSC_ERROR(err);
+ err = VecGetArray(valuesVec, &tractionsArray);CHECK_PETSC_ERROR(err);
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int v_lagrange = _cohesiveVertices[iVertex].lagrange;
const int v_fault = _cohesiveVertices[iVertex].fault;
@@ -397,6 +398,7 @@
err = VecRestoreArray(dispTVec, &dispTArray);CHECK_PETSC_ERROR(err);
err = VecRestoreArray(dispTIncrVec, &dispTIncrArray);CHECK_PETSC_ERROR(err);
err = VecRestoreArray(residualVec, &residualArray);CHECK_PETSC_ERROR(err);
+ err = VecRestoreArray(valuesVec, &tractionsArray);CHECK_PETSC_ERROR(err);
#if !defined(DETAILED_EVENT_LOGGING)
_logger->eventEnd(computeEvent);
@@ -1649,7 +1651,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 0, orientationVec);
+ buffer.copy(orientationSection, 0, PETSC_DETERMINE, orientationVec);
buffer.label("strike_dir");
buffer.scale(1.0);
return buffer;
@@ -1660,7 +1662,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 1, orientationVec);
+ buffer.copy(orientationSection, 1, PETSC_DETERMINE, orientationVec);
buffer.label("dip_dir");
buffer.scale(1.0);
return buffer;
@@ -1668,10 +1670,9 @@
PetscSection orientationSection = _fields->get("orientation").petscSection();
Vec orientationVec = _fields->get("orientation").localVector();
assert(orientationSection);assert(orientationVec);
- const int space = (0 == cohesiveDim) ? 0 : (1 == cohesiveDim) ? 1 : 2;
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, space, orientationVec);
+ buffer.copy(orientationSection, cohesiveDim, PETSC_DETERMINE, orientationVec);
buffer.label("normal_dir");
buffer.scale(1.0);
return buffer;
Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveImpulses.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -212,7 +212,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 0, orientationVec);
+ buffer.copy(orientationSection, 0, PETSC_DETERMINE, orientationVec);
buffer.label("strike_dir");
buffer.scale(1.0);
return buffer;
@@ -223,7 +223,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 1, orientationVec);
+ buffer.copy(orientationSection, 1, PETSC_DETERMINE, orientationVec);
buffer.label("dip_dir");
buffer.scale(1.0);
return buffer;
@@ -232,10 +232,9 @@
PetscSection orientationSection = _fields->get("orientation").petscSection();
Vec orientationVec = _fields->get("orientation").localVector();
assert(orientationSection);assert(orientationVec);
- const int space = (0 == cohesiveDim) ? 0 : (1 == cohesiveDim) ? 1 : 2;
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, space, orientationVec);
+ buffer.copy(orientationSection, cohesiveDim, PETSC_DETERMINE, orientationVec);
buffer.label("normal_dir");
buffer.scale(1.0);
return buffer;
Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveKin.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -186,7 +186,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 0, orientationVec);
+ buffer.copy(orientationSection, 0, PETSC_DETERMINE, orientationVec);
buffer.label("strike_dir");
buffer.scale(1.0);
return buffer;
@@ -196,7 +196,7 @@
assert(orientationSection);assert(orientationVec);
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, 1, orientationVec);
+ buffer.copy(orientationSection, 1, PETSC_DETERMINE, orientationVec);
buffer.label("dip_dir");
buffer.scale(1.0);
return buffer;
@@ -204,10 +204,9 @@
PetscSection orientationSection = _fields->get("orientation").petscSection();
Vec orientationVec = _fields->get("orientation").localVector();
assert(orientationSection);assert(orientationVec);
- const int space = (0 == cohesiveDim) ? 0 : (1 == cohesiveDim) ? 1 : 2;
_allocateBufferVectorField();
topology::Field<topology::SubMesh>& buffer = _fields->get("buffer (vector)");
- buffer.copy(orientationSection, 0, space, orientationVec);
+ buffer.copy(orientationSection, cohesiveDim, PETSC_DETERMINE, orientationVec);
buffer.label("normal_dir");
buffer.scale(1.0);
return buffer;
Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveLagrange.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveLagrange.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/FaultCohesiveLagrange.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -1395,11 +1395,15 @@
_fields->add("orientation", "orientation");
topology::Field<topology::SubMesh>& orientation = _fields->get("orientation");
const topology::Field<topology::SubMesh>& dispRel = _fields->get("relative disp");
- orientation.addField("orientation", cohesiveDim+1);
+ if (spaceDim > 1) orientation.addField("strike_dir", spaceDim);
+ if (spaceDim > 2) orientation.addField("dip_dir", spaceDim);
+ orientation.addField("normal_dir", spaceDim);
orientation.setupFields();
orientation.newSection(dispRel, orientationSize);
// Create components for along-strike, up-dip, and normal directions
- orientation.updateDof("orientation", pylith::topology::FieldBase::VERTICES_FIELD, spaceDim);
+ if (spaceDim > 1) orientation.updateDof("strike_dir", pylith::topology::FieldBase::VERTICES_FIELD, spaceDim);
+ if (spaceDim > 2) orientation.updateDof("dip_dir", pylith::topology::FieldBase::VERTICES_FIELD, spaceDim);
+ orientation.updateDof("normal_dir", pylith::topology::FieldBase::VERTICES_FIELD, spaceDim);
orientation.allocate();
orientation.zero();
PetscSection orientationSection = orientation.petscSection();
Modified: short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -286,6 +286,14 @@
} // hasPropStateVar
// ----------------------------------------------------------------------
+// Get metadta for physical properties or state variables.
+const pylith::materials::Metadata&
+pylith::friction::FrictionModel::getMetadata()
+{ // getMetadata
+ return _metadata;
+} // getMetadata
+
+// ----------------------------------------------------------------------
// Get physical property or state variable field.
const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::friction::FrictionModel::getField(const char* name)
Modified: short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.hh 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/friction/FrictionModel.hh 2013-01-29 01:51:27 UTC (rev 21303)
@@ -130,6 +130,12 @@
* or state variable, false otherwise.
*/
bool hasPropStateVar(const char* name);
+
+ /** Return the property and state variable metadata.
+ *
+ * @returns Metadata for properties and state variables.
+ */
+ const pylith::materials::Metadata& getMetadata();
/** Get physical property or state variable field. Data is returned
* via the argument.
Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Field.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -1067,7 +1067,7 @@
msg << "Invalid field "<<field<<" should be in [0, "<<numFields<<")";
throw std::runtime_error(msg.str());
}
- if (field >= 0) {
+ if ((field >= 0) && (component >= 0)) {
err = PetscSectionGetFieldComponents(osection, field, &numComp);CHECK_PETSC_ERROR(err);
if (component >= numComp) {
std::ostringstream msg;
@@ -1086,9 +1086,11 @@
if (field >= 0) {
err = PetscSectionGetFieldDof(osection, p, field, &odof);CHECK_PETSC_ERROR(err);
err = PetscSectionGetFieldOffset(osection, p, field, &ooff);CHECK_PETSC_ERROR(err);
- assert(!(odof%numComp));
- odof = odof/numComp;
- ooff += odof*component;
+ if (component >= 0) {
+ assert(!(odof%numComp));
+ odof = odof/numComp;
+ ooff += odof*component;
+ }
} else {
err = PetscSectionGetDof(osection, p, &odof);CHECK_PETSC_ERROR(err);
err = PetscSectionGetOffset(osection, p, &ooff);CHECK_PETSC_ERROR(err);
Modified: short/3D/PyLith/trunk/unittests/libtests/friction/TestFrictionModel.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/friction/TestFrictionModel.cc 2013-01-28 05:50:00 UTC (rev 21302)
+++ short/3D/PyLith/trunk/unittests/libtests/friction/TestFrictionModel.cc 2013-01-29 01:51:27 UTC (rev 21303)
@@ -132,74 +132,50 @@
pylith::friction::TestFrictionModel::testInitialize(void)
{ // testInitialize
const PylithScalar propertiesE[] = { 0.6, 1000000, 0.4, 1000000 };
- const int numProperties = 2;
topology::Mesh mesh;
faults::FaultCohesiveDyn fault;
StaticFriction friction;
StaticFrictionData data;
+ PetscErrorCode err;
_initialize(&mesh, &fault, &friction, &data);
+ CPPUNIT_ASSERT(0 != friction._fieldsPropsStateVars);
- const ALE::Obj<SieveSubMesh>& faultSieveMesh = fault.faultMesh().sieveMesh();
- assert(!faultSieveMesh.isNull());
- const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
- faultSieveMesh->depthStratum(0);
- assert(!vertices.isNull());
- const SieveSubMesh::label_sequence::iterator verticesBegin =
- vertices->begin();
- const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ DM faultDMMesh = fault.faultMesh().dmMesh();
+ PetscInt vStart, vEnd;
+ assert(faultDMMesh);
+ ierr = DMPlexGetDepthStratum(faultDMMesh, 0, &vStart, &vEnd);CHECK_PETSC_ERROR(err);
+
const PylithScalar tolerance = 1.0e-06;
// Test fieldsPropsStateVars with mesh
- const int fieldsFiberDim = numProperties;
+ const pylith::materials::Metadata& = friction.getMetadata();
+ const int numProperties = metadata.numProperties();
int index = 0;
- CPPUNIT_ASSERT(0 != friction._fieldsPropsStateVars);
-#if 1
- const ALE::Obj<SubRealUniformSection>& fieldsSection =
- friction._fieldsPropsStateVars->section();
- CPPUNIT_ASSERT(!fieldsSection.isNull());
- for (SieveSubMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(fieldsFiberDim,
- fieldsSection->getFiberDimension(*v_iter));
- const PylithScalar* fieldsVertex = fieldsSection->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(fieldsVertex);
- for (int i = 0; i < numProperties; ++i, ++index)
- if (0 != propertiesE[index])
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, fieldsVertex[i]/propertiesE[index],
- tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesE[index], fieldsVertex[i],
- tolerance);
- } // for
-#else
- PetscSection fieldsSection = friction._fieldsPropsStateVars->petscSection();
- Vec fieldsVec = friction._fieldsPropsStateVars->localVector();
- PetscScalar *fieldsArray;
- PetscErrorCode err;
+ for(PetscInt v = vStart; v < vEnd; ++v) {
+ for (int i = 0; i < numProperties; ++i, ++index) {
+ const materials::Metadata::ParamDescription& property = metadata.getProperty(i);
+ topology::Field<topology::SubMesh>& prop = friction._fieldsPropsStateVars->get(property.name.c_str());
+ PetscSection fieldsSection = prop.petscSection();
+ Vec fieldsVec = prop.localVector();
+ PetscScalar *fieldsArray;
- CPPUNIT_ASSERT(fieldsSection);CPPUNIT_ASSERT(fieldsVec);
- err = VecGetArray(fieldsVec, &fieldsArray);CHECK_PETSC_ERROR(err);
- for(SieveSubMesh::label_sequence::iterator v_iter = verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- PetscInt dof, off;
+ CPPUNIT_ASSERT(fieldsSection);CPPUNIT_ASSERT(fieldsVec);
+ err = VecGetArray(fieldsVec, &fieldsArray);CHECK_PETSC_ERROR(err);
+ PetscInt dof, off;
- err = PetscSectionGetDof(fieldsSection, *v_iter, &dof);CHECK_PETSC_ERROR(err);
- err = PetscSectionGetOffset(fieldsSection, *v_iter, &off);CHECK_PETSC_ERROR(err);
- CPPUNIT_ASSERT_EQUAL(fieldsFiberDim, dof);
- for (int i = 0; i < numProperties; ++i, ++index)
- if (0 != propertiesE[index])
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, fieldsArray[off+i]/propertiesE[index],
- tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesE[index], fieldsArray[off+i],
- tolerance);
+ err = PetscSectionGetDof(fieldsSection, v, &dof);CHECK_PETSC_ERROR(err);
+ err = PetscSectionGetOffset(fieldsSection, v, &off);CHECK_PETSC_ERROR(err);
+ CPPUNIT_ASSERT(dof == 1);
+ if (0 != propertiesE[index]) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, fieldsArray[off]/propertiesE[index], tolerance);
+ } else {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesE[index], fieldsArray[off], tolerance);
+ }
+ err = VecRestoreArray(fieldsVec, &fieldsArray);CHECK_PETSC_ERROR(err);
+ } // for
} // for
- err = VecRestoreArray(fieldsVec, &fieldsArray);CHECK_PETSC_ERROR(err);
-#endif
// Test vertex array sizes.
size_t size = data.numPropsVertex + data.numVarsVertex;
More information about the CIG-COMMITS
mailing list