[cig-commits] r15139 - in short/3D/PyLith/trunk: libsrc/bc libsrc/faults libsrc/materials libsrc/topology unittests/libtests/topology

brad at geodynamics.org brad at geodynamics.org
Mon Jun 8 09:01:23 PDT 2009


Author: brad
Date: 2009-06-08 09:01:22 -0700 (Mon, 08 Jun 2009)
New Revision: 15139

Modified:
   short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc
   short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
   short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
   short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc
   short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
   short/3D/PyLith/trunk/libsrc/materials/Material.cc
   short/3D/PyLith/trunk/libsrc/topology/Field.cc
   short/3D/PyLith/trunk/libsrc/topology/Field.hh
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh
   short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc
Log:
Switched newSection(chart, fiberDim) to newSection(field, fiberDim) in order to match fiber dimension structure (same nonzero pattern).

Modified: short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/bc/TimeDependentPoints.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -87,13 +87,20 @@
   delete _parameters;
   _parameters = new topology::Fields<topology::Field<topology::Mesh> >(mesh);
 
+  // Create section to hold time dependent values
+  _parameters->add("value", fieldName);
+  topology::Field<topology::Mesh>& value = _parameters->get("value");
+  value.scale(valueScale);
+  value.vectorFieldType(topology::FieldBase::OTHER);
+  value.newSection(_points, numBCDOF);
+  value.allocate();
+
   if (0 != _dbInitial) { // Setup initial values, if provided.
     std::string fieldLabel = std::string("initial_") + std::string(fieldName);
     _parameters->add("initial", fieldLabel.c_str());
     topology::Field<topology::Mesh>& initial = 
       _parameters->get("initial");
-    initial.newSection(_points, numBCDOF);
-    initial.allocate();
+    initial.cloneSection(value);
     initial.scale(valueScale);
     initial.vectorFieldType(topology::FieldBase::OTHER);
 
@@ -108,8 +115,7 @@
     _parameters->add("rate", fieldLabel.c_str());
     topology::Field<topology::Mesh>& rate = 
       _parameters->get("rate");
-    rate.newSection(_points, numBCDOF);
-    rate.allocate();
+    rate.cloneSection(value);
     rate.scale(rateScale);
     rate.vectorFieldType(topology::FieldBase::OTHER);
     const ALE::Obj<RealSection>& rateSection = rate.section();
@@ -124,7 +130,7 @@
     _parameters->add("rate time", timeLabel.c_str());
     topology::Field<topology::Mesh>& rateTime = 
       _parameters->get("rate time");
-    rateTime.newSection(_points, 1);
+    rateTime.newSection(rate, 1);
     rateTime.allocate();
     rateTime.scale(timeScale);
     rateTime.vectorFieldType(topology::FieldBase::SCALAR);
@@ -140,8 +146,7 @@
     _parameters->add("change", fieldLabel.c_str());
     topology::Field<topology::Mesh>& change = 
       _parameters->get("change");
-    change.newSection(_points, numBCDOF);
-    change.allocate();
+    change.cloneSection(value);
     change.scale(valueScale);
     change.vectorFieldType(topology::FieldBase::OTHER);
     const ALE::Obj<RealSection>& changeSection = change.section();
@@ -156,7 +161,7 @@
     _parameters->add("change time", timeLabel.c_str());
     topology::Field<topology::Mesh>& changeTime = 
       _parameters->get("change time");
-    changeTime.newSection(_points, 1);
+    changeTime.newSection(change, 1);
     changeTime.allocate();
     changeTime.scale(timeScale);
     changeTime.vectorFieldType(topology::FieldBase::SCALAR);
@@ -170,12 +175,6 @@
       _dbTimeHistory->open();
   } // if
 
-  _parameters->add("value", fieldName);
-  topology::Field<topology::Mesh>& value = _parameters->get("value");
-  value.scale(valueScale);
-  value.vectorFieldType(topology::FieldBase::OTHER);
-  value.newSection(_points, numBCDOF);
-  value.allocate();
 } // _queryDatabases
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -92,7 +92,7 @@
 
   _parameters->add("slip time", "slip_time");
   topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
-  slipTime.newSection(finalSlipSection->getChart(), 1);
+  slipTime.newSection(finalSlip, 1);
   slipTime.allocate();
   slipTime.scale(timeScale);
   slipTime.vectorFieldType(topology::FieldBase::SCALAR);

Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -89,7 +89,7 @@
 
   _parameters->add("slip time", "slip_time");
   topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
-  slipTime.newSection(slipRateSection->getChart(), 1);
+  slipTime.newSection(slipRate, 1);
   slipTime.allocate();
   slipTime.scale(timeScale);
   slipTime.vectorFieldType(topology::FieldBase::SCALAR);

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -851,9 +851,8 @@
   // Allocate orientation field.
   _fields->add("orientation", "orientation");
   topology::Field<topology::SubMesh>& orientation = _fields->get("orientation");
-  const ALE::Obj<RealSection>& slipSection = _fields->get("slip").section();
-  assert(!slipSection.isNull());
-  orientation.newSection(slipSection->getChart(), orientationSize);
+  const topology::Field<topology::SubMesh>& slip = _fields->get("slip");
+  orientation.newSection(slip, orientationSize);
   const ALE::Obj<RealSection>& orientationSection = orientation.section();
   assert(!orientationSection.isNull());
   // Create subspaces for along-strike, up-dip, and normal directions
@@ -1018,9 +1017,8 @@
   _fields->add("area", "area");
 
   topology::Field<topology::SubMesh>& area = _fields->get("area");
-  const ALE::Obj<RealSection>& slipSection = _fields->get("slip").section();
-  assert(!slipSection.isNull());
-  area.newSection(slipSection->getChart(), 1);
+  const topology::Field<topology::SubMesh>& slip = _fields->get("slip");
+  area.newSection(slip, 1);
   area.allocate();
   area.zero();
   const ALE::Obj<RealSection>& areaSection = area.section();
@@ -1160,10 +1158,8 @@
   // Allocate buffer for tractions field (if nec.).
   const ALE::Obj<RealSection>& tractionsSection = tractions->section();
   if (tractionsSection.isNull()) {
-    const ALE::Obj<RealSection>& slipSection =
-      _fields->get("slip").section();
-    assert(!slipSection.isNull());
-    tractions->newSection(slipSection->getChart(), fiberDim);
+    const topology::Field<topology::SubMesh>& slip =_fields->get("slip");
+    tractions->newSection(slip, fiberDim);
     tractions->allocate();
   } // if
   assert(!tractionsSection.isNull());

Modified: short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -92,7 +92,7 @@
 
   _parameters->add("slip time", "slip_time");
   topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
-  slipTime.newSection(finalSlipSection->getChart(), 1);
+  slipTime.newSection(finalSlip, 1);
   slipTime.allocate();
   slipTime.scale(timeScale);
   slipTime.vectorFieldType(topology::FieldBase::SCALAR);

Modified: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -87,7 +87,7 @@
 
   _parameters->add("slip time", "slip_time");
   topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
-  slipTime.newSection(finalSlipSection->getChart(), 1);
+  slipTime.newSection(finalSlip, 1);
   slipTime.allocate();
   slipTime.scale(timeScale);
   slipTime.vectorFieldType(topology::FieldBase::SCALAR);

Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -163,10 +163,8 @@
   fiberDim = numQuadPts * _numVarsQuadPt;
   if (fiberDim > 0) {
     assert(0 != _stateVars);
-    const ALE::Obj<RealSection::chart_type>& chart = 
-      propertiesSection->getChart();
-    assert(!chart.isNull());
-    _stateVars->newSection(*chart, fiberDim);
+    assert(0 != _properties);
+    _stateVars->newSection(*_properties, fiberDim);
     _stateVars->allocate();
     _stateVars->zero();
   } // if

Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -204,7 +204,7 @@
 // Create section given chart.
 template<typename mesh_type>
 void
-pylith::topology::Field<mesh_type>::newSection(const chart_type& chart,
+pylith::topology::Field<mesh_type>::newSection(const Field& src,
 					       const int fiberDim)
 { // newSection
   ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
@@ -215,15 +215,21 @@
     newSection();
     logger.stagePush("Field");
   } // if
-  _section->setChart(chart);
 
-  const typename chart_type::const_iterator chartEnd = chart.end();
-  for (typename chart_type::const_iterator c_iter = chart.begin();
-       c_iter != chartEnd;
-       ++c_iter) {
-    _section->setFiberDimension(*c_iter, fiberDim);
-  } // for
+  const ALE::Obj<RealSection>& srcSection = src.section();
+  if (!srcSection.isNull()) {
+    _section->setChart(srcSection->getChart());
+    const chart_type& chart = _section->getChart();
+    const typename chart_type::const_iterator chartBegin = chart.begin();
+    const typename chart_type::const_iterator chartEnd = chart.end();
 
+    for (typename chart_type::const_iterator c_iter = chartBegin;
+	 c_iter != chartEnd;
+	 ++c_iter) 
+      if (srcSection->getFiberDimension(*c_iter) > 0)
+	_section->setFiberDimension(*c_iter, fiberDim);
+  } // if
+
   std::cout << "Done making Field " << _label << " section type 2" << std::endl;
   logger.stagePop();
 } // newSection

Modified: short/3D/PyLith/trunk/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.hh	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.hh	2009-06-08 16:01:22 UTC (rev 15139)
@@ -176,13 +176,12 @@
 		  const int fiberDim,
 		  const int stratum =0);
 
-  /** Create section given chart. This allows a chart to be reused
-   * across multiple fields, reducing memory usage.
+  /** Create section using src field as template with given fiber dimension.
    *
-   * @param chart Chart defining points over which section is defined.
+   * @param sec Field defining layout.
    * @param fiberDim Fiber dimension.
    */
-  void newSection(const chart_type& chart,
+  void newSection(const Field& src,
 		  const int fiberDim);
 
   /** Create section with same layout (fiber dimension and
@@ -190,7 +189,7 @@
    * structures to be reused across multiple fields, reducing memory
    * usage.
    *
-   * @param sec Section defining layout.
+   * @param sec Field defining layout.
    */
   void cloneSection(const Field& src);
 

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -244,10 +244,10 @@
 } // testNewSectionDomain
 
 // ----------------------------------------------------------------------
-// Test newSection(chart).
+// Test newSection(field).
 void
-pylith::topology::TestFieldMesh::testNewSectionChart(void)
-{ // testNewSectionChart
+pylith::topology::TestFieldMesh::testNewSectionField(void)
+{ // testNewSectionField
   const int fiberDim = 3;
     
   Mesh mesh;
@@ -262,8 +262,9 @@
   CPPUNIT_ASSERT(!sectionSrc.isNull());
   const Mesh::RealSection::chart_type& chart = sectionSrc->getChart();
 
+  const int fiberDim2 = 5;
   Field<Mesh> field(mesh);
-  field.newSection(chart, fiberDim);
+  field.newSection(fieldSrc, fiberDim2);
   const ALE::Obj<Mesh::RealSection>& section = field.section();
   CPPUNIT_ASSERT(!section.isNull());
   const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices = 
@@ -272,8 +273,8 @@
   for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
        v_iter != vertices->end();
        ++v_iter)
-    CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
-} // testNewSectionChart
+    CPPUNIT_ASSERT_EQUAL(fiberDim2, section->getFiberDimension(*v_iter));
+} // testNewSectionField
 
 // ----------------------------------------------------------------------
 // Test cloneSection().

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh	2009-06-08 16:01:22 UTC (rev 15139)
@@ -51,7 +51,7 @@
   CPPUNIT_TEST( testNewSectionPoints );
   CPPUNIT_TEST( testNewSectionPointsArray );
   CPPUNIT_TEST( testNewSectionDomain );
-  CPPUNIT_TEST( testNewSectionChart );
+  CPPUNIT_TEST( testNewSectionField );
   CPPUNIT_TEST( testCloneSection );
   CPPUNIT_TEST( testClear );
   CPPUNIT_TEST( testAllocate );
@@ -110,8 +110,8 @@
   /// Test newSection(domain).
   void testNewSectionDomain(void);
 
-  /// Test newSection(chart).
-  void testNewSectionChart(void);
+  /// Test newSection(field).
+  void testNewSectionField(void);
 
   /// Test cloneSection().
   void testCloneSection(void);

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -179,10 +179,10 @@
 } // testNewSectionDomain
 
 // ----------------------------------------------------------------------
-// Test newSection(chart).
+// Test newSection(field).
 void
-pylith::topology::TestFieldSubMesh::testNewSectionChart(void)
-{ // testNewSectionChart
+pylith::topology::TestFieldSubMesh::testNewSectionField(void)
+{ // testNewSectionField
   const int fiberDim = 3;
     
   Mesh mesh;
@@ -196,10 +196,10 @@
   fieldSrc.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
   const ALE::Obj<SubMesh::RealSection>& sectionSrc = fieldSrc.section();
   CPPUNIT_ASSERT(!sectionSrc.isNull());
-  const SubMesh::RealSection::chart_type& chart = sectionSrc->getChart();
 
+  const int fiberDim2 = 4;
   Field<SubMesh> field(submesh);
-  field.newSection(chart, fiberDim);
+  field.newSection(fieldSrc, fiberDim2);
   const ALE::Obj<SubMesh::RealSection>& section = field.section();
   CPPUNIT_ASSERT(!section.isNull());
   const ALE::Obj<SieveMesh::label_sequence>& vertices = 
@@ -208,7 +208,7 @@
   for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
        v_iter != vertices->end();
        ++v_iter)
-    CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+    CPPUNIT_ASSERT_EQUAL(fiberDim2, section->getFiberDimension(*v_iter));
 } // testNewSectionChart
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh	2009-06-08 16:01:22 UTC (rev 15139)
@@ -47,7 +47,7 @@
   CPPUNIT_TEST( testNewSection );
   CPPUNIT_TEST( testNewSectionPoints );
   CPPUNIT_TEST( testNewSectionDomain );
-  CPPUNIT_TEST( testNewSectionChart );
+  CPPUNIT_TEST( testNewSectionField );
   CPPUNIT_TEST( testCloneSection );
   CPPUNIT_TEST( testClear );
   CPPUNIT_TEST( testAllocate );
@@ -89,8 +89,8 @@
   /// Test newSection(domain).
   void testNewSectionDomain(void);
 
-  /// Test newSection(chart).
-  void testNewSectionChart(void);
+  /// Test newSection(field).
+  void testNewSectionField(void);
 
   /// Test cloneSection().
   void testCloneSection(void);

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc	2009-06-08 04:44:14 UTC (rev 15138)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc	2009-06-08 16:01:22 UTC (rev 15139)
@@ -72,10 +72,8 @@
   Field<Mesh>& fieldC = manager.get(labels[2]);
   fieldA.newSection(vertices, fiberDimA);
 
-  const ALE::Obj<Mesh::RealSection>& section = fieldA.section();
-  const Mesh::RealSection::chart_type& chart = section->getChart();
-  fieldB.newSection(chart, fiberDimB);
-  fieldC.newSection(chart, fiberDimC);
+  fieldB.newSection(fieldA, fiberDimB);
+  fieldC.newSection(fieldB, fiberDimC);
 
   manager.solutionName(labels[1]);
   const Field<Mesh>& solution = manager.solution();



More information about the CIG-COMMITS mailing list