[cig-commits] r22116 - in short/3D/PyLith/trunk: libsrc/pylith/faults libsrc/pylith/topology unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Mon May 20 15:05:38 PDT 2013


Author: brad
Date: 2013-05-20 15:05:37 -0700 (Mon, 20 May 2013)
New Revision: 22116

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
   short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterBCMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterFaultMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterSubMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
Log:
Added scales to more meshio tests. Fixed bugs in not setting scales in submeshes, etc.

Modified: short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/libsrc/pylith/faults/CohesiveTopology.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -613,6 +613,9 @@
   err = ISRestoreIndices(fVertexIS, &fVerticesDM);PYLITH_CHECK_ERROR(err);
   err = ISDestroy(&fVertexIS);PYLITH_CHECK_ERROR(err);
 
+  PetscReal lengthScale = 1.0;
+  err = DMPlexGetScale(complexMesh, PETSC_UNIT_LENGTH, &lengthScale);PYLITH_CHECK_ERROR(err);
+  err = DMPlexSetScale(newMesh, PETSC_UNIT_LENGTH, lengthScale);PYLITH_CHECK_ERROR(err);
   mesh->dmMesh(newMesh);
 
   PYLITH_METHOD_END;
@@ -643,6 +646,10 @@
   //   Have to do internal fault vertices before fault boundary vertices, and this is the only thing I use faultBoundary for
   err = DMPlexLabelCohesiveComplete(dm, label);PYLITH_CHECK_ERROR(err);
   err = DMPlexConstructCohesiveCells(dm, label, &sdm);PYLITH_CHECK_ERROR(err);
+
+  PetscReal lengthScale = 1.0;
+  err = DMPlexGetScale(dm, PETSC_UNIT_LENGTH, &lengthScale);PYLITH_CHECK_ERROR(err);
+  err = DMPlexSetScale(sdm, PETSC_UNIT_LENGTH, lengthScale);PYLITH_CHECK_ERROR(err);
   mesh->dmMesh(sdm);
 } // createInterpolated
 
@@ -667,6 +674,11 @@
 
   err = DMPlexCreateCohesiveSubmesh(dmMesh, constraintCell ? PETSC_TRUE : PETSC_FALSE, &dmFaultMesh);PYLITH_CHECK_ERROR(err);
   std::string meshLabel = "fault_" + std::string(label);
+
+  PetscReal lengthScale = 1.0;
+  err = DMPlexGetScale(dmMesh, PETSC_UNIT_LENGTH, &lengthScale);PYLITH_CHECK_ERROR(err);
+  err = DMPlexSetScale(dmFaultMesh, PETSC_UNIT_LENGTH, lengthScale);PYLITH_CHECK_ERROR(err);
+
   faultMesh->dmMesh(dmFaultMesh, meshLabel.c_str());
 
   PYLITH_METHOD_END;

Modified: short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/libsrc/pylith/topology/Mesh.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -125,6 +125,11 @@
   std::string meshLabel = "subdomain_" + std::string(label);
   err = PetscObjectSetName((PetscObject) _dmMesh, meshLabel.c_str());PYLITH_CHECK_ERROR(err);
 
+  // Set lengthscale
+  PylithScalar lengthScale;
+  err = DMPlexGetScale(dmMesh, PETSC_UNIT_LENGTH, &lengthScale);PYLITH_CHECK_ERROR(err);
+  err = DMPlexSetScale(_dmMesh, PETSC_UNIT_LENGTH, lengthScale);PYLITH_CHECK_ERROR(err);
+
   PYLITH_METHOD_END;
 } // SubMesh constructor
 		     

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -85,6 +85,7 @@
     (1.5*1.1 + 0.5*1.2)/2.0,
     (1.5*2.1 + 0.5*2.2)/2.0,
   };
+  const PylithScalar fieldScale = 2.0;
 
   MeshIOAscii iohandler;
   topology::Mesh mesh;
@@ -97,6 +98,7 @@
   field.allocate();
   field.vectorFieldType(fieldType);
   field.label(label.c_str());
+  field.scale(fieldScale);
 
   PetscDM dmMesh = mesh.dmMesh();CPPUNIT_ASSERT(dmMesh);
   topology::Stratum cellsStratum(dmMesh, topology::Stratum::HEIGHT, 0);
@@ -128,6 +130,7 @@
 
   CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldF.vectorFieldType());
   CPPUNIT_ASSERT_EQUAL(label, std::string(fieldF.label()));
+  CPPUNIT_ASSERT_EQUAL(fieldScale, fieldF.scale());
 
   topology::VecVisitorMesh fieldFVisitor(fieldF);
   const PetscScalar* fieldFArray = fieldFVisitor.localArray();CPPUNIT_ASSERT(fieldFArray);
@@ -188,6 +191,7 @@
     (1.5*1.1 + 0.5*1.2)/2.0,
     (1.5*2.1 + 0.5*2.2)/2.0,
   };
+  const PylithScalar fieldScale = 2.0;
 
   MeshIOAscii iohandler;
   topology::Mesh mesh;
@@ -202,6 +206,7 @@
   field.allocate();
   field.vectorFieldType(fieldType);
   field.label(label.c_str());
+  field.scale(fieldScale);
 
   PetscDM dmMesh = submesh.dmMesh();CPPUNIT_ASSERT(dmMesh);
   topology::Stratum cellsStratum(dmMesh, topology::Stratum::HEIGHT, 1);
@@ -233,6 +238,7 @@
 
   CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldF.vectorFieldType());
   CPPUNIT_ASSERT_EQUAL(label, std::string(fieldF.label()));
+  CPPUNIT_ASSERT_EQUAL(fieldScale, fieldF.scale());
 
   topology::VecVisitorMesh fieldFVisitor(fieldF);
   const PetscScalar* fieldFArray = fieldFVisitor.localArray();CPPUNIT_ASSERT(fieldFArray);

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterBCMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterBCMesh.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterBCMesh.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -25,6 +25,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/MeshOps.hh" // USES MeshOps::nondimensionalize()
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
 #include "pylith/topology/Stratum.hh" // USES Stratum
@@ -34,6 +35,7 @@
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
 // ----------------------------------------------------------------------
 // Setup testing data.
@@ -82,6 +84,10 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
+  topology::MeshOps::nondimensionalize(_mesh, normalizer);
+
   if (_data->faultLabel) {
     faults::FaultCohesiveKin fault;
     const bool useLagrangeConstraints = true;

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterFaultMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterFaultMesh.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterFaultMesh.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -25,6 +25,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/MeshOps.hh" // USES MeshOps::nondimensionalize()
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
 #include "pylith/topology/Stratum.hh" // USES Stratum
@@ -35,6 +36,7 @@
 #include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
 #include <map> // USES std::map
 
@@ -87,6 +89,10 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
+  topology::MeshOps::nondimensionalize(_mesh, normalizer);
+
   faults::FaultCohesiveKin fault;
   const bool useLagrangeConstraints = true;
   PetscInt firstFaultVertex = 0;

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterMesh.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -25,6 +25,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/MeshOps.hh" // USES MeshOps::nondimensionalize()
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
 #include "pylith/topology/Stratum.hh" // USES Stratum
@@ -34,6 +35,7 @@
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
 // ----------------------------------------------------------------------
 // Setup testing data.
@@ -80,6 +82,10 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
+  topology::MeshOps::nondimensionalize(_mesh, normalizer);
+
   if (_data->faultLabel) {
     faults::FaultCohesiveKin fault;
     const bool useLagrangeConstraints = true;
@@ -125,7 +131,7 @@
     field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
     field.allocate();
     field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
-    
+
     topology::VecVisitorMesh fieldVisitor(field);
     PetscScalar* fieldArray = fieldVisitor.localArray();CPPUNIT_ASSERT(fieldArray);
     

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterPoints.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -25,6 +25,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/MeshOps.hh" // USES MeshOps::nondimensionalize()
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
 #include "pylith/topology/Stratum.hh" // USES Stratum
@@ -34,6 +35,7 @@
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
 // ----------------------------------------------------------------------
 // Setup testing data.
@@ -80,6 +82,10 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
+  topology::MeshOps::nondimensionalize(_mesh, normalizer);
+
   if (_data->faultLabel) {
     faults::FaultCohesiveKin fault;
     const bool useLagrangeConstraints = true;

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterSubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterSubMesh.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterSubMesh.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -25,6 +25,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/MeshOps.hh" // USES MeshOps::nondimensionalize()
 #include "pylith/topology/Field.hh" // USES Field
 #include "pylith/topology/Fields.hh" // USES Fields
 #include "pylith/topology/Stratum.hh" // USES Stratum
@@ -34,6 +35,7 @@
 #include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
 
 #include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
 
 // ----------------------------------------------------------------------
 // Setup testing data.
@@ -82,6 +84,10 @@
   cs.setSpaceDim(_mesh->dimension());
   _mesh->coordsys(&cs);
 
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
+  topology::MeshOps::nondimensionalize(_mesh, normalizer);
+
   if (_data->faultLabel) {
     faults::FaultCohesiveKin fault;
     const bool useLagrangeConstraints = true;

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKPoints.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -88,6 +88,7 @@
   OutputSolnPoints output;
   DataWriterVTK writer;
   spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
 
   writer.filename(_data->timestepFilename);
   writer.timeFormat(_data->timeFormat);
@@ -127,6 +128,7 @@
   OutputSolnPoints output;
   DataWriterVTK writer;
   spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
 
   topology::Fields vertexFields(*_mesh);
   _createVertexFields(&vertexFields);

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -122,10 +122,12 @@
  
     // Set coordinate system
   spatialdata::geocoords::CSCart cs;
-  spatialdata::units::Nondimensional normalizer;
   cs.setSpaceDim(data.spaceDim);
   cs.initialize();
   _mesh->coordsys(&cs);
+
+  spatialdata::units::Nondimensional normalizer;
+  normalizer.lengthScale(10.0);
   topology::MeshOps::nondimensionalize(_mesh, normalizer);
 
   PYLITH_METHOD_END;

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc	2013-05-20 20:20:57 UTC (rev 22115)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc	2013-05-20 22:05:37 UTC (rev 22116)
@@ -72,6 +72,7 @@
     sqrt(pow(3.1, 2) + pow(3.2, 2)),
     sqrt(pow(4.1, 2) + pow(4.2, 2))
   };
+  const PylithScalar fieldScale = 4.0;
 
   MeshIOAscii iohandler;
   topology::Mesh mesh;
@@ -88,6 +89,7 @@
   field.allocate();
   field.vectorFieldType(fieldType);
   field.label(label.c_str());
+  field.scale(fieldScale);
 
   { // Setup vertex field
     topology::VecVisitorMesh fieldVisitor(field);
@@ -110,6 +112,7 @@
 
   CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldNorm.vectorFieldType());
   CPPUNIT_ASSERT_EQUAL(label, std::string(fieldNorm.label()));
+  CPPUNIT_ASSERT_EQUAL(fieldScale, fieldNorm.scale());
 
   topology::VecVisitorMesh fieldNormVisitor(fieldNorm);
   const PetscScalar* fieldNormArray = fieldNormVisitor.localArray();



More information about the CIG-COMMITS mailing list