[cig-commits] r14962 - in short/3D/PyLith/trunk/libsrc: materials meshio topology
brad at geodynamics.org
brad at geodynamics.org
Sun May 10 12:47:52 PDT 2009
Author: brad
Date: 2009-05-10 12:47:51 -0700 (Sun, 10 May 2009)
New Revision: 14962
Modified:
short/3D/PyLith/trunk/libsrc/materials/Material.cc
short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc
short/3D/PyLith/trunk/libsrc/topology/Field.cc
Log:
Fixed bugs associated with getting fiber dimension on multiple processors. Fixed bug in deciding whether we need to create a new section for output of material state variables.
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc 2009-05-10 18:45:07 UTC (rev 14961)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc 2009-05-10 19:47:51 UTC (rev 14962)
@@ -254,6 +254,7 @@
int stateVarIndex = -1;
_findField(&propertyIndex, &stateVarIndex, name);
+ std::cout << "AA" << std::endl;
// Get cell information
const ALE::Obj<SieveMesh>& sieveMesh = field->mesh().sieveMesh();
assert(!sieveMesh.isNull());
@@ -263,9 +264,11 @@
const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ std::cout << "BB" << std::endl;
topology::FieldBase::VectorFieldEnum fieldType = topology::FieldBase::OTHER;
if (propertyIndex >= 0) { // If field is a property
+ std::cout << "CC" << std::endl;
int propOffset = 0;
const string_vector& properties = _metadata.properties();
assert(propertyIndex < properties.size());
@@ -274,28 +277,54 @@
_metadata.fiberDim(properties[i].c_str(), Metadata::PROPERTY);
const int fiberDim = _metadata.fiberDim(name, Metadata::PROPERTY);
+ std::cout << "DD" << std::endl;
// :TODO: Get scale information
// Get properties section
+ std::cout << "EE" << std::endl;
const ALE::Obj<RealSection>& propertiesSection = _properties->section();
assert(!propertiesSection.isNull());
- const int totalPropsFiberDim =
- propertiesSection->getFiberDimension(*cells->begin());
+ const int totalPropsFiberDimLocal = (cells->size() > 0) ?
+ propertiesSection->getFiberDimension(*cells->begin()) : 0;
+ std::cout << "FF" << std::endl;
+ int totalPropsFiberDim = 0;
+ MPI_Allreduce((void *) &totalPropsFiberDimLocal,
+ (void *) &totalPropsFiberDim, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(totalPropsFiberDim > 0);
+ std::cout << "GG" << std::endl;
const int numPropsQuadPt = _numPropsQuadPt;
const int numQuadPts = totalPropsFiberDim / numPropsQuadPt;
assert(totalPropsFiberDim == numQuadPts * numPropsQuadPt);
const int totalFiberDim = numQuadPts * fiberDim;
+ std::cout << "HH" << std::endl;
- // Allocate buffer for property field.
+ // Allocate buffer for property field if necessary.
+ std::cout << "II" << std::endl;
const ALE::Obj<RealSection>& fieldSection = field->section();
- if ((fieldSection.isNull() && cells->size() > 0) ||
- totalFiberDim != fieldSection->getFiberDimension(*cells->begin())) {
+ bool useCurrentField = !fieldSection.isNull();
+ if (!fieldSection.isNull()) {
+ // check fiber dimension
+ const int totalFiberDimCurrentLocal = (cells->size() > 0) ?
+ fieldSection->getFiberDimension(*cells->begin()) : 0;
+ std::cout << "JJ" << std::endl;
+ int totalFiberDimCurrent = 0;
+ MPI_Allreduce((void *) &totalFiberDimCurrentLocal,
+ (void *) &totalFiberDimCurrent, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(totalFiberDimCurrent > 0);
+ useCurrentField = totalFiberDim == totalFiberDimCurrent;
+ } // if
+ std::cout << "KK" << std::endl;
+ if (!useCurrentField) {
field->newSection(cells, totalFiberDim);
field->allocate();
} // if
+ std::cout << "NN" << std::endl;
assert(!fieldSection.isNull());
field->label(name);
fieldType = _metadata.fieldType(name, Metadata::PROPERTY);
+ std::cout << "OO" << std::endl;
// Buffer for property at cell's quadrature points
double_array fieldCell(numQuadPts*fiberDim);
@@ -334,17 +363,34 @@
// Get state variables section
const ALE::Obj<RealSection>& stateVarsSection = _stateVars->section();
assert(!stateVarsSection.isNull());
- const int totalVarsFiberDim =
- stateVarsSection->getFiberDimension(*cells->begin());
+ const int totalVarsFiberDimLocal = (cells->size() > 0) ?
+ stateVarsSection->getFiberDimension(*cells->begin()) : 0;
+ int totalVarsFiberDim = 0;
+ MPI_Allreduce((void *) &totalVarsFiberDimLocal,
+ (void *) &totalVarsFiberDim, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(totalVarsFiberDim > 0);
const int numVarsQuadPt = _numVarsQuadPt;
const int numQuadPts = totalVarsFiberDim / numVarsQuadPt;
assert(totalVarsFiberDim == numQuadPts * numVarsQuadPt);
const int totalFiberDim = numQuadPts * fiberDim;
- // Allocate buffer for state variable field.
+ // Allocate buffer for state variable field if necessary.
const ALE::Obj<RealSection>& fieldSection = field->section();
- if (fieldSection.isNull() ||
- totalFiberDim != fieldSection->getFiberDimension(*cells->begin())) {
+ bool useCurrentField = !fieldSection.isNull();
+ if (!fieldSection.isNull()) {
+ // check fiber dimension
+ const int totalFiberDimCurrentLocal = (cells->size() > 0) ?
+ fieldSection->getFiberDimension(*cells->begin()) : 0;
+ std::cout << "JJ" << std::endl;
+ int totalFiberDimCurrent = 0;
+ MPI_Allreduce((void *) &totalFiberDimCurrentLocal,
+ (void *) &totalFiberDimCurrent, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(totalFiberDimCurrent > 0);
+ useCurrentField = totalFiberDim == totalFiberDimCurrent;
+ } // if
+ if (!useCurrentField) {
field->newSection(cells, totalFiberDim);
field->allocate();
} // if
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2009-05-10 18:45:07 UTC (rev 14961)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2009-05-10 19:47:51 UTC (rev 14962)
@@ -172,8 +172,10 @@
const ALE::Obj<RealSection>& section = field.section();
assert(!section.isNull());
assert(!sieveMesh->getLabelStratum(labelName, 0).isNull());
+
const int localFiberDim =
- section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, 0)->begin());
+ (sieveMesh->getLabelStratum(labelName, 0)->size() > 0) ?
+ section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, 0)->begin()) : 0;
int fiberDim = 0;
MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1,
MPI_INT, MPI_MAX, field.mesh().comm());
@@ -238,8 +240,10 @@
assert(!sieveMesh->getLabelStratum(labelName, depth).isNull());
const ALE::Obj<RealSection>& section = field.section();
assert(!section.isNull());
+
const int localFiberDim =
- section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, depth)->begin());
+ (sieveMesh->getLabelStratum(labelName, depth)->size() > 0) ?
+ section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, depth)->begin()) : 0;
int fiberDim = 0;
MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1,
MPI_INT, MPI_MAX, field.mesh().comm());
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2009-05-10 18:45:07 UTC (rev 14961)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2009-05-10 19:47:51 UTC (rev 14962)
@@ -120,6 +120,7 @@
*numVertices = vertices->size();
assert(*numVertices > 0);
+ assert(vertices->size() > 0);
*spaceDim = coordsField->getFiberDimension(*vertices->begin());
assert(*spaceDim > 0);
Modified: short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc 2009-05-10 18:45:07 UTC (rev 14961)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc 2009-05-10 19:47:51 UTC (rev 14962)
@@ -68,7 +68,8 @@
const ALE::Obj<RealSection>& sectionIn = fieldIn.section();
assert(!sectionIn.isNull());
- const int fiberDimIn = sectionIn->getFiberDimension(*vertices->begin());
+ const int fiberDimIn = (vertices->size() > 0) ?
+ sectionIn->getFiberDimension(*vertices->begin()) : 0;
const int fiberDimNorm = 1;
// Allocation field if necessary
Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-05-10 18:45:07 UTC (rev 14961)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-05-10 19:47:51 UTC (rev 14962)
@@ -414,7 +414,8 @@
const typename chart_type::const_iterator chartEnd = chart.end();
// Assume fiber dimension is uniform
- const int fiberDim = _section->getFiberDimension(*chartBegin);
+ const int fiberDim = (chart.size() > 0) ?
+ _section->getFiberDimension(*chartBegin) : 0;
double_array values(fiberDim);
for (typename chart_type::const_iterator c_iter = chartBegin;
@@ -448,7 +449,8 @@
const typename chart_type::const_iterator chartEnd = chart.end();
// Assume fiber dimension is uniform
- const int fiberDim = _section->getFiberDimension(*chart.begin());
+ const int fiberDim = (chart.size() > 0) ?
+ _section->getFiberDimension(*chart.begin()) : 0;
double_array values(fiberDim);
spatialdata::units::Nondimensional normalizer;
More information about the CIG-COMMITS
mailing list