[cig-commits] r16418 - in short/3D/PyLith/trunk: . playpen/closure

brad at geodynamics.org brad at geodynamics.org
Sun Mar 14 19:33:22 PDT 2010


Author: brad
Date: 2010-03-14 19:33:21 -0700 (Sun, 14 Mar 2010)
New Revision: 16418

Modified:
   short/3D/PyLith/trunk/configure.ac
   short/3D/PyLith/trunk/playpen/closure/TestClosure.cc
Log:
Setup closure test with separated fields.

Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac	2010-03-15 02:13:41 UTC (rev 16417)
+++ short/3D/PyLith/trunk/configure.ac	2010-03-15 02:33:21 UTC (rev 16418)
@@ -292,6 +292,7 @@
 		tests/2d/quad4/Makefile
 		tests/3dnew/hex8/Makefile
 		tests/petsc/Makefile
+		playpen/closure/Makefile
                 doc/Makefile
 		doc/developer/Makefile
 		doc/install/Makefile

Modified: short/3D/PyLith/trunk/playpen/closure/TestClosure.cc
===================================================================
--- short/3D/PyLith/trunk/playpen/closure/TestClosure.cc	2010-03-15 02:13:41 UTC (rev 16417)
+++ short/3D/PyLith/trunk/playpen/closure/TestClosure.cc	2010-03-15 02:33:21 UTC (rev 16418)
@@ -24,7 +24,7 @@
 #include <cassert> // USES assert()
 #include <stdexcept> // USES std::runtime_error
 
-#define SEPARATE_FIELDS
+//#define SEPARATE_FIELDS
 
 // ----------------------------------------------------------------------
 typedef pylith::topology::Mesh::SieveMesh SieveMesh;
@@ -61,16 +61,6 @@
 
   const int spaceDim = _spaceDim;
 
-  // Create fields
-  pylith::topology::SolutionFields fields(mesh);
-  fields.add("field A", "field_A");
-  fields.add("field B", "field_B");
-  topology::Field<topology::Mesh>& fieldA = fields.get("field A");
-  fieldA.newSection(topology::FieldBase::VERTICES_FIELD, spaceDim);
-  fieldA.allocate();
-  fieldA.zero();
-  fields.copyLayout("field A");
-
   // Setup timing
   utils::EventLogger logger;
   logger.className("TestClosure");
@@ -97,7 +87,7 @@
 							       *cellsBegin, ncV);
   const int coneSize = ncV.getSize();
 
-  // Setup visitors
+  // Setup coordinates visitor
   double_array coordsCell(coneSize*spaceDim);
   const ALE::Obj<RealSection>& coordsSection = 
     sieveMesh->getRealSection("coordinates");
@@ -105,6 +95,18 @@
   topology::Mesh::RestrictVisitor coordsVisitor(*coordsSection,
 						coordsCell.size(),
 						&coordsCell[0]);
+#if defined(SEPARATE_FIELDS)
+  // Create fields
+  pylith::topology::SolutionFields fields(mesh);
+  fields.add("field A", "field_A");
+  fields.add("field B", "field_B");
+  topology::Field<topology::Mesh>& fieldA = fields.get("field A");
+  fieldA.newSection(topology::FieldBase::VERTICES_FIELD, spaceDim);
+  fieldA.allocate();
+  fieldA.zero();
+  fields.copyLayout("field A");
+
+  // Setup field visitors
   double_array fieldACell(coneSize*spaceDim);
   const ALE::Obj<RealSection>& fieldASection = fields.get("field A").section();
   assert(!fieldASection.isNull());
@@ -120,6 +122,28 @@
   
   double_array tmpCell(coneSize*spaceDim);
 
+#else
+  // Create fields
+  pylith::topology::SolutionFields fields(mesh);
+  fields.add("field AB", "field_AB");
+  topology::Field<topology::Mesh>& fieldAB = fields.get("field AB");
+  fieldAB.newSection(topology::FieldBase::VERTICES_FIELD, 2*spaceDim);
+  fieldAB.allocate();
+  fieldAB.zero();
+  fields.copyLayout("field AB");
+
+  // Create field visitors
+  double_array fieldABCell(coneSize*2*spaceDim);
+  const ALE::Obj<RealSection>& fieldABSection = fields.get("field AB").section();
+  assert(!fieldABSection.isNull());
+  topology::Mesh::RestrictVisitor fieldABVisitor(*fieldABSection,
+						 fieldABCell.size(),
+						&fieldABCell[0]);
+  
+  double_array tmpCell(coneSize*2*spaceDim);
+#endif
+  const int dataSize = coneSize * spaceDim;
+
   ALE::LogStagePush(stage);
   logger.eventBegin(closureEvent);
 
@@ -129,22 +153,28 @@
     for (SieveMesh::label_sequence::iterator c_iter=cellsBegin;
 	 c_iter != cellsEnd;
 	 ++c_iter) {
-#if defined(SEPARATE_FIELDS)
       coordsVisitor.clear();
       sieveMesh->restrictClosure(*c_iter, coordsVisitor);
       
+#if defined(SEPARATE_FIELDS)
       fieldAVisitor.clear();
       sieveMesh->restrictClosure(*c_iter, fieldAVisitor);
       
       fieldBVisitor.clear();
       sieveMesh->restrictClosure(*c_iter, fieldBVisitor);
       
-      ++i;
+      // Perform trivial operation on fields
+      tmpCell = fieldACell + fieldBCell + coordsCell;
 #else
+      fieldABVisitor.clear();
+      sieveMesh->restrictClosure(*c_iter, fieldABVisitor);
+      
+      // Perform trivial operation on fields
+      for (int i=0; i < dataSize; ++i) 
+	tmpCell[i] = fieldABCell[i] + fieldABCell[dataSize+i] + coordsCell[i];
 #endif
+      ++i;
       
-      // Perform trivial operation on fields
-      tmpCell = fieldACell + fieldBCell + coordsCell;
     } // for
 
   logger.eventEnd(closureEvent);



More information about the CIG-COMMITS mailing list