[cig-commits] r20652 - in short/3D/PyLith/branches/v1.7-trunk: libsrc/pylith/materials modulesrc/materials
brad at geodynamics.org
brad at geodynamics.org
Fri Aug 31 15:09:00 PDT 2012
Author: brad
Date: 2012-08-31 15:09:00 -0700 (Fri, 31 Aug 2012)
New Revision: 20652
Modified:
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.cc
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.hh
short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/Material.hh
short/3D/PyLith/branches/v1.7-trunk/modulesrc/materials/ElasticMaterial.i
Log:
Factor out stableTimeStepImplicitMax() for elastic materials.
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -325,10 +325,10 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticIsotropic3D::stableTimeStepImplicit(
- const topology::Mesh& mesh) {
- return pylith::PYLITH_MAXSCALAR;
-}
+pylith::materials::ElasticIsotropic3D::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ return ElasticMaterial::stableTimeStepImplicitMax(mesh, field);
+} // stableTimeStepImplicitMax
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticIsotropic3D.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -59,9 +59,12 @@
* Default is MAXDOUBLE (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -231,7 +231,8 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticMaterial::stableTimeStepImplicit(const topology::Mesh& mesh)
+pylith::materials::ElasticMaterial::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field)
{ // stableTimeStepImplicit
const int numQuadPts = _numQuadPts;
const int numPropsQuadPt = _numPropsQuadPt;
@@ -277,7 +278,8 @@
// Get stable time step for explicit time integration.
PylithScalar
pylith::materials::ElasticMaterial::stableTimeStepExplicit(const topology::Mesh& mesh,
- feassemble::Quadrature<topology::Mesh>* quadrature)
+ feassemble::Quadrature<topology::Mesh>* quadrature,
+ topology::Field<topology::Mesh>* field)
{ // stableTimeStepImplicit
assert(quadrature);
@@ -291,8 +293,6 @@
assert(_initialStressCell.size() == numQuadPts*_tensorSize);
assert(_initialStrainCell.size() == numQuadPts*_tensorSize);
- PylithScalar dtStable = pylith::PYLITH_MAXSCALAR;
-
// Get cells associated with material
const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
assert(!sieveMesh.isNull());
@@ -302,6 +302,37 @@
const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ // Setup field if necessary.
+ ALE::Obj<RealSection> fieldSection;
+ if (field) {
+ const int fiberDim = 1;
+ fieldSection = field->section();
+ bool useCurrentField = false;
+ if (!fieldSection.isNull()) {
+ // check fiber dimension
+ const int fiberDimCurrentLocal = (cells->size() > 0) ? fieldSection->getFiberDimension(*cells->begin()) : 0;
+ int fiberDimCurrent = 0;
+ MPI_Allreduce((void *) &fiberDimCurrentLocal,
+ (void *) &fiberDimCurrent, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(fiberDimCurrent > 0);
+ useCurrentField = fiberDim == fiberDimCurrent;
+ } // if
+ if (!useCurrentField) {
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("OutputFields");
+ field->newSection(cells, fiberDim);
+ field->allocate();
+ logger.stagePop();
+ } // if
+ assert(!fieldSection.isNull());
+ field->label("stable_dt_explicit");
+ assert(_normalizer);
+ field->scale(_normalizer->timeScale());
+ } // if
+
+ PylithScalar dtStable = pylith::PYLITH_MAXSCALAR;
+
const int spaceDim = quadrature->spaceDim();
const int numBasis = quadrature->numBasis();
scalar_array coordinatesCell(numBasis*spaceDim);
@@ -310,7 +341,6 @@
RestrictVisitor coordsVisitor(*coordinates,
coordinatesCell.size(), &coordinatesCell[0]);
-
for (SieveMesh::label_sequence::iterator c_iter=cellsBegin;
c_iter != cellsEnd;
++c_iter) {
@@ -320,6 +350,7 @@
sieveMesh->restrictClosure(*c_iter, coordsVisitor);
const double minCellWidth = quadrature->minCellWidth(coordinatesCell);
+ PylithScalar dtStableCell = pylith::PYLITH_MAXSCALAR;
for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
const PylithScalar dt =
_stableTimeStepExplicit(&_propertiesCell[iQuad*numPropsQuadPt],
@@ -327,15 +358,75 @@
&_stateVarsCell[iQuad*numVarsQuadPt],
numVarsQuadPt,
minCellWidth);
- if (dt < dtStable)
- dtStable = dt;
+ if (dt < dtStableCell)
+ dtStableCell = dt;
} // for
+ if (field) {
+ assert(!fieldSection.isNull());
+ assert(1 == fieldSection->getFiberDimension(*c_iter));
+ fieldSection->updatePoint(*c_iter, &dtStableCell);
+ } // if
+
+ if (dtStableCell < dtStable)
+ dtStable = dtStableCell;
} // for
return dtStable;
} // stableTimeStepExplicit
// ----------------------------------------------------------------------
+// Get stable time step for implicit time integration (return large value).
+PylithScalar
+pylith::materials::ElasticMaterial::stableTimeStepImplicitMax(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ const PylithScalar dtStable = pylith::PYLITH_MAXSCALAR;
+
+ if (field) {
+ const ALE::Obj<RealSection>& fieldSection = field->section();
+ // Get cells associated with material
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells = sieveMesh->getLabelStratum("material-id", id());
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+
+ const int fiberDim = 1;
+ bool useCurrentField = false;
+ if (!fieldSection.isNull()) {
+ // check fiber dimension
+ const int fiberDimCurrentLocal = (cells->size() > 0) ? fieldSection->getFiberDimension(*cells->begin()) : 0;
+ int fiberDimCurrent = 0;
+ MPI_Allreduce((void *) &fiberDimCurrentLocal,
+ (void *) &fiberDimCurrent, 1,
+ MPI_INT, MPI_MAX, field->mesh().comm());
+ assert(fiberDimCurrent > 0);
+ useCurrentField = fiberDim == fiberDimCurrent;
+ } // if
+ if (!useCurrentField) {
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush("OutputFields");
+ field->newSection(cells, fiberDim);
+ field->allocate();
+ logger.stagePop();
+ } // if
+ assert(!fieldSection.isNull());
+ field->label("stable_dt_explicit");
+ assert(_normalizer);
+ field->scale(_normalizer->timeScale());
+
+ for (SieveMesh::label_sequence::iterator c_iter=cellsBegin;
+ c_iter != cellsEnd;
+ ++c_iter) {
+ assert(1 == fieldSection->getFiberDimension(*c_iter));
+ fieldSection->updatePoint(*c_iter, &dtStable);
+ } // for
+ } // if
+
+ return dtStable;
+} // stableTimeStepImplicitMax
+
+// ----------------------------------------------------------------------
// Allocate cell arrays.
void
pylith::materials::ElasticMaterial::_allocateCellArrays(void)
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticMaterial.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -172,31 +172,42 @@
/** Get stable time step for implicit time integration.
*
- * @pre Must call retrievePropsAndVars for cell before calling
- * stableTimeStep().
- *
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
virtual
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
+ /** Get stable time step for implicit time integration for a
+ * material where the stable time step is infinite.
+ *
+ * @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
+ * @returns PYLITH::MAX_SCALAR;
+ */
+ PylithScalar stableTimeStepImplicitMax(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
+
/** Get stable time step for explicit time integration.
*
- * @pre Must call retrievePropsAndVars for cell before calling
- * stableTimeStep().
- *
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
* @param quadrature Quadrature for finite-element integration
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
virtual
PylithScalar stableTimeStepExplicit(const topology::Mesh& mesh,
- feassemble::Quadrature<topology::Mesh>* quadrature);
+ feassemble::Quadrature<topology::Mesh>* quadrature,
+ topology::Field<topology::Mesh>* field =0);
/** Get initial stress/strain fields.
*
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -311,9 +311,9 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticPlaneStrain::stableTimeStepImplicit(
- const topology::Mesh& mesh) {
- return pylith::PYLITH_MAXSCALAR;
+pylith::materials::ElasticPlaneStrain::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ return ElasticMaterial::stableTimeStepImplicitMax(mesh, field);
}
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStrain.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -59,9 +59,12 @@
* Default is MAXDOUBLE (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -314,9 +314,9 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticPlaneStress::stableTimeStepImplicit(
- const topology::Mesh& mesh) {
- return pylith::PYLITH_MAXSCALAR;
+pylith::materials::ElasticPlaneStress::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ return ElasticMaterial::stableTimeStepImplicitMax(mesh, field);
}
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticPlaneStress.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -61,9 +61,12 @@
* Default is MAXDOUBLE (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -291,9 +291,9 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticStrain1D::stableTimeStepImplicit(
- const topology::Mesh& mesh) {
- return pylith::PYLITH_MAXSCALAR;
+pylith::materials::ElasticStrain1D::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ return ElasticMaterial::stableTimeStepImplicitMax(mesh, field);
}
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStrain1D.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -60,9 +60,12 @@
* Default is MAXDOUBLE (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.cc
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.cc 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.cc 2012-08-31 22:09:00 UTC (rev 20652)
@@ -291,9 +291,9 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
PylithScalar
-pylith::materials::ElasticStress1D::stableTimeStepImplicit(
- const topology::Mesh& mesh) {
- return pylith::PYLITH_MAXSCALAR;
+pylith::materials::ElasticStress1D::stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field) {
+ return ElasticMaterial::stableTimeStepImplicitMax(mesh, field);
}
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/ElasticStress1D.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -61,9 +61,12 @@
* Default is MAXDOUBLE (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
+ * @param field Field for storing min stable time step for each cell.
+ *
* @returns Time step
*/
- PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh);
+ PylithScalar stableTimeStepImplicit(const topology::Mesh& mesh,
+ topology::Field<topology::Mesh>* field =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/Material.hh
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/Material.hh 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/libsrc/pylith/materials/Material.hh 2012-08-31 22:09:00 UTC (rev 20652)
@@ -195,7 +195,8 @@
* @param field Field over material cells.
* @param name Name of field to retrieve.
*/
- void getField(topology::Field<topology::Mesh> *field, const char* name) const;
+ void getField(topology::Field<topology::Mesh> *field,
+ const char* name) const;
/** Get the field with all properties.
*
Modified: short/3D/PyLith/branches/v1.7-trunk/modulesrc/materials/ElasticMaterial.i
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/modulesrc/materials/ElasticMaterial.i 2012-08-31 19:19:14 UTC (rev 20651)
+++ short/3D/PyLith/branches/v1.7-trunk/modulesrc/materials/ElasticMaterial.i 2012-08-31 22:09:00 UTC (rev 20652)
@@ -71,9 +71,6 @@
/** Get stable time step for implicit time integration.
*
- * @pre Must call retrievePropsAndVars for cell before calling
- * stableTimeStep().
- *
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @returns Time step
@@ -83,9 +80,6 @@
/** Get stable time step for explicit time integration.
*
- * @pre Must call retrievePropsAndVars for cell before calling
- * stableTimeStep().
- *
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
* @param mesh Finite-element mesh.
More information about the CIG-COMMITS
mailing list