[cig-commits] r21472 - short/3D/PyLith/trunk/libsrc/pylith/topology
brad at geodynamics.org
brad at geodynamics.org
Fri Mar 8 09:27:05 PST 2013
Author: brad
Date: 2013-03-08 09:27:05 -0800 (Fri, 08 Mar 2013)
New Revision: 21472
Modified:
short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.hh
Log:
Moved nondimensionalize routine to more logical place in file.
Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc 2013-03-08 17:25:46 UTC (rev 21471)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc 2013-03-08 17:27:05 UTC (rev 21472)
@@ -24,6 +24,7 @@
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
#include "pylith/utils/array.hh" // USES scalar_array
+#include "pylith/utils/petscfwd.h" // USES PetscVec
#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
#include <stdexcept> // USES std::runtime_error
@@ -112,66 +113,6 @@
} // coordsys
// ----------------------------------------------------------------------
-// Nondimensionalizer the finite-element mesh.
-void
-pylith::topology::Mesh::nondimensionalize(const spatialdata::units::Nondimensional& normalizer)
-{ // initialize
- Vec coordVec, coordDimVec;
- const PylithScalar lengthScale = normalizer.lengthScale();
- PetscErrorCode err;
-
- // Get coordinates (currently dimensioned).
- if (!_mesh.isNull()) {
- const ALE::Obj<RealSection>& coordsSection = _mesh->getRealSection("coordinates");
- assert(!coordsSection.isNull());
-
- // Get field for dimensioned coordinates.
- const ALE::Obj<RealSection>& coordsDimSection =
- _mesh->getRealSection("coordinates_dimensioned");
- assert(!coordsDimSection.isNull());
- coordsDimSection->setAtlas(coordsSection->getAtlas());
- coordsDimSection->allocateStorage();
- coordsDimSection->setBC(coordsSection->getBC());
-
- const ALE::Obj<SieveMesh::label_sequence>& vertices = _mesh->depthStratum(0);
- assert(!vertices.isNull());
- const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
- const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
-
- PylithScalar coordsVertex[3];
- for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
- v_iter != verticesEnd;
- ++v_iter) {
- const int spaceDim = coordsSection->getFiberDimension(*v_iter);
- assert(spaceDim <= 3);
- const PylithScalar* coordsDimVertex = coordsSection->restrictPoint(*v_iter);
-
- // Update section with dimensioned coordinates
- assert(spaceDim == coordsDimSection->getFiberDimension(*v_iter));
- coordsDimSection->updatePoint(*v_iter, coordsDimVertex);
-
- // Copy coordinates to array for nondimensionalization.
- for (int i=0; i < spaceDim; ++i)
- coordsVertex[i] = coordsDimVertex[i];
-
- // Nondimensionalize original coordinates.
- normalizer.nondimensionalize(&coordsVertex[0], spaceDim, lengthScale);
-
- // Update section with nondimensional coordinates
- assert(spaceDim == coordsSection->getFiberDimension(*v_iter));
- coordsSection->updatePoint(*v_iter, coordsVertex);
- } // for
- }
-
- assert(_newMesh);
- err = DMGetCoordinatesLocal(_newMesh, &coordVec);CHECK_PETSC_ERROR(err);
- assert(coordVec);
- // There does not seem to be an advantage to calling nondimensionalize()
- err = VecScale(coordVec, 1.0/lengthScale);CHECK_PETSC_ERROR(err);
- err = DMPlexSetScale(_newMesh, PETSC_UNIT_LENGTH, lengthScale);CHECK_PETSC_ERROR(err);
-} // nondimensionalize
-
-// ----------------------------------------------------------------------
// Return the names of all vertex groups.
void
pylith::topology::Mesh::groups(int* numNames,
@@ -238,4 +179,65 @@
} // groupSize
+// ----------------------------------------------------------------------
+// Nondimensionalize the finite-element mesh.
+void
+pylith::topology::Mesh::nondimensionalize(const spatialdata::units::Nondimensional& normalizer)
+{ // initialize
+ PetscVec coordVec, coordDimVec;
+ const PylithScalar lengthScale = normalizer.lengthScale();
+ PetscErrorCode err;
+
+ // Get coordinates (currently dimensioned).
+ if (!_mesh.isNull()) {
+ const ALE::Obj<RealSection>& coordsSection = _mesh->getRealSection("coordinates");
+ assert(!coordsSection.isNull());
+
+ // Get field for dimensioned coordinates.
+ const ALE::Obj<RealSection>& coordsDimSection =
+ _mesh->getRealSection("coordinates_dimensioned");
+ assert(!coordsDimSection.isNull());
+ coordsDimSection->setAtlas(coordsSection->getAtlas());
+ coordsDimSection->allocateStorage();
+ coordsDimSection->setBC(coordsSection->getBC());
+
+ const ALE::Obj<SieveMesh::label_sequence>& vertices = _mesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ PylithScalar coordsVertex[3];
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter) {
+ const int spaceDim = coordsSection->getFiberDimension(*v_iter);
+ assert(spaceDim <= 3);
+ const PylithScalar* coordsDimVertex = coordsSection->restrictPoint(*v_iter);
+
+ // Update section with dimensioned coordinates
+ assert(spaceDim == coordsDimSection->getFiberDimension(*v_iter));
+ coordsDimSection->updatePoint(*v_iter, coordsDimVertex);
+
+ // Copy coordinates to array for nondimensionalization.
+ for (int i=0; i < spaceDim; ++i)
+ coordsVertex[i] = coordsDimVertex[i];
+
+ // Nondimensionalize original coordinates.
+ normalizer.nondimensionalize(&coordsVertex[0], spaceDim, lengthScale);
+
+ // Update section with nondimensional coordinates
+ assert(spaceDim == coordsSection->getFiberDimension(*v_iter));
+ coordsSection->updatePoint(*v_iter, coordsVertex);
+ } // for
+ }
+
+ assert(_newMesh);
+ err = DMGetCoordinatesLocal(_newMesh, &coordVec);CHECK_PETSC_ERROR(err);
+ assert(coordVec);
+ // There does not seem to be an advantage to calling nondimensionalize()
+ err = VecScale(coordVec, 1.0/lengthScale);CHECK_PETSC_ERROR(err);
+ err = DMPlexSetScale(_newMesh, PETSC_UNIT_LENGTH, lengthScale);CHECK_PETSC_ERROR(err);
+} // nondimensionalize
+
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.hh 2013-03-08 17:25:46 UTC (rev 21471)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.hh 2013-03-08 17:27:05 UTC (rev 21472)
@@ -211,12 +211,6 @@
*/
int commRank(void) const;
- /** Initialize the finite-element mesh.
- *
- * @param normalizer Nondimensionalizer.
- */
- void nondimensionalize(const spatialdata::units::Nondimensional& normalizer);
-
/** Print mesh to stdout.
*
* @param label Label for mesh.
@@ -237,6 +231,12 @@
*/
int groupSize(const char *name);
+ /** Nondimensionalize the finite-element mesh.
+ *
+ * @param normalizer Nondimensionalizer.
+ */
+ void nondimensionalize(const spatialdata::units::Nondimensional& normalizer);
+
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
More information about the CIG-COMMITS
mailing list