[cig-commits] [commit] next: Fixed bug in setting up fields for output of stable time step. (e5caf46)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu Mar 27 21:42:35 PDT 2014
Repository : ssh://shell.geodynamics.org/pylith
On branch : next
Link : https://github.com/geodynamics/pylith/compare/0a91ee7931f78ff7ea096a03053ca3bed552d844...bb528b0b0888f781da725b6e26f53de2394391f8
>---------------------------------------------------------------
commit e5caf46cc8abc00af300b37262268ee7510dd8c0
Author: Brad Aagaard <baagaard at usgs.gov>
Date: Thu Mar 27 21:40:59 2014 -0700
Fixed bug in setting up fields for output of stable time step.
Visitor requires that the section be setup. Reorganize to prevent segfault or assertion.
>---------------------------------------------------------------
e5caf46cc8abc00af300b37262268ee7510dd8c0
examples/bar_shearwave/tri3/pylithapp.cfg | 2 +-
libsrc/pylith/materials/ElasticMaterial.cc | 25 ++++++++++++++-----------
tests_auto/2d/tri3/axialdisp.cfg | 1 +
tests_auto/2d/tri3/sheardisp.cfg | 1 +
4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/examples/bar_shearwave/tri3/pylithapp.cfg b/examples/bar_shearwave/tri3/pylithapp.cfg
index 38e3c61..1287128 100644
--- a/examples/bar_shearwave/tri3/pylithapp.cfg
+++ b/examples/bar_shearwave/tri3/pylithapp.cfg
@@ -224,7 +224,7 @@ writer.time_format = %05.2f
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.elastic.output]
-cell_info_fields = [mu,lambda,density,stable_dt_explicit]
+cell_info_fields = [stable_dt_explicit,mu,lambda,density]
skip = 29
writer.filename = output/shearwave-statevars.vtk
writer.time_format = %05.2f
diff --git a/libsrc/pylith/materials/ElasticMaterial.cc b/libsrc/pylith/materials/ElasticMaterial.cc
index cfe08f1..b25f7af 100644
--- a/libsrc/pylith/materials/ElasticMaterial.cc
+++ b/libsrc/pylith/materials/ElasticMaterial.cc
@@ -292,18 +292,18 @@ pylith::materials::ElasticMaterial::stableTimeStepImplicit(const topology::Mesh&
const PetscInt numCells = _materialIS->size();
// Setup field if necessary.
- topology::VecVisitorMesh* fieldVisitor = (field) ? new topology::VecVisitorMesh(*field) : 0;
+ topology::VecVisitorMesh* fieldVisitor = NULL;
PetscScalar* fieldArray = NULL;
if (field) {
- assert(fieldVisitor);
const int fiberDim = 1*numQuadPts;
bool useCurrentField = false;
- if (fieldVisitor->petscSection()) {
+ if (field->hasSection()) {
// check fiber dimension
int fiberDimCurrentLocal = 0;
int fiberDimCurrent = 0;
if (numCells > 0) {
- fiberDimCurrentLocal = fieldVisitor->sectionDof(cells[0]);
+ topology::VecVisitorMesh fieldVisitor(*field);
+ fiberDimCurrentLocal = fieldVisitor.sectionDof(cells[0]);
} // if
MPI_Allreduce((void *) &fiberDimCurrentLocal,
(void *) &fiberDimCurrent, 1,
@@ -320,6 +320,7 @@ pylith::materials::ElasticMaterial::stableTimeStepImplicit(const topology::Mesh&
assert(_normalizer);
field->scale(_normalizer->timeScale());
field->vectorFieldType(topology::FieldBase::MULTI_SCALAR);
+ fieldVisitor = new topology::VecVisitorMesh(*field);assert(fieldVisitor);
fieldArray = fieldVisitor->localArray();
} // if
@@ -383,17 +384,17 @@ pylith::materials::ElasticMaterial::stableTimeStepExplicit(const topology::Mesh&
const PetscInt numCells = _materialIS->size();
// Setup field if necessary.
- topology::VecVisitorMesh* fieldVisitor = (field) ? new topology::VecVisitorMesh(*field) : 0;
+ topology::VecVisitorMesh* fieldVisitor = NULL;
PetscScalar *fieldArray = NULL;
if (field) {
- assert(fieldVisitor);
const int fiberDim = 1*numQuadPts;
bool useCurrentField = false;
- if (fieldVisitor->petscSection()) {
+ if (field->hasSection()) {
// check fiber dimension
PetscInt fiberDimCurrentLocal = 0;
if (numCells > 0) {
- fiberDimCurrentLocal = fieldVisitor->sectionDof(cells[0]);
+ topology::VecVisitorMesh fieldVisitor(*field);
+ fiberDimCurrentLocal = fieldVisitor.sectionDof(cells[0]);
} // if
PetscInt fiberDimCurrent = 0;
MPI_Allreduce(&fiberDimCurrentLocal, &fiberDimCurrent, 1, MPIU_INT, MPI_MAX, field->mesh().comm());
@@ -408,6 +409,7 @@ pylith::materials::ElasticMaterial::stableTimeStepExplicit(const topology::Mesh&
assert(_normalizer);
field->scale(_normalizer->timeScale());
field->vectorFieldType(topology::FieldBase::MULTI_SCALAR);
+ fieldVisitor = new topology::VecVisitorMesh(*field);assert(fieldVisitor);
fieldArray = fieldVisitor->localArray();
} // if
@@ -474,17 +476,17 @@ pylith::materials::ElasticMaterial::_stableTimeStepImplicitMax(const topology::M
PetscDM dmMesh = mesh.dmMesh();assert(dmMesh);
assert(_materialIS);
- const PetscInt *cells = _materialIS->points();
+ const PetscInt* cells = _materialIS->points();
const PetscInt numCells = _materialIS->size();
// Setup field if necessary.
- topology::VecVisitorMesh fieldVisitor(*field);
const int fiberDim = 1*numQuadPts;
bool useCurrentField = false;
- if (fieldVisitor.petscSection()) {
+ if (field->hasSection()) {
// check fiber dimension
PetscInt fiberDimCurrentLocal = 0;
if (numCells > 0) {
+ topology::VecVisitorMesh fieldVisitor(*field);
fiberDimCurrentLocal = fieldVisitor.sectionDof(cells[0]);
} // if
PetscInt fiberDimCurrent = 0;
@@ -500,6 +502,7 @@ pylith::materials::ElasticMaterial::_stableTimeStepImplicitMax(const topology::M
assert(_normalizer);
field->scale(_normalizer->timeScale());
field->vectorFieldType(topology::FieldBase::MULTI_SCALAR);
+ topology::VecVisitorMesh fieldVisitor(*field);
PetscScalar* fieldArray = fieldVisitor.localArray();
scalar_array dtStableCell(numQuadPts);
diff --git a/tests_auto/2d/tri3/axialdisp.cfg b/tests_auto/2d/tri3/axialdisp.cfg
index c9fcb93..9e57435 100644
--- a/tests_auto/2d/tri3/axialdisp.cfg
+++ b/tests_auto/2d/tri3/axialdisp.cfg
@@ -106,6 +106,7 @@ writer = pylith.meshio.DataWriterHDF5
writer.filename = axialdisp.h5
[axialdisp.timedependent.materials.elastic.output]
+cell_info_fields = [stable_dt_implicit,mu,lambda,density]
cell_filter = pylith.meshio.CellFilterAvg
writer = pylith.meshio.DataWriterHDF5
writer.filename = axialdisp-elastic.h5
diff --git a/tests_auto/2d/tri3/sheardisp.cfg b/tests_auto/2d/tri3/sheardisp.cfg
index 68310ea..b3bf3b7 100644
--- a/tests_auto/2d/tri3/sheardisp.cfg
+++ b/tests_auto/2d/tri3/sheardisp.cfg
@@ -116,6 +116,7 @@ writer = pylith.meshio.DataWriterHDF5
writer.filename = sheardisp.h5
[sheardisp.timedependent.materials.elastic.output]
+cell_info_fields = [stable_dt_explicit,mu,lambda,density]
cell_filter = pylith.meshio.CellFilterAvg
writer = pylith.meshio.DataWriterHDF5
writer.filename = sheardisp-elastic.h5
More information about the CIG-COMMITS
mailing list