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

brad at geodynamics.org brad at geodynamics.org
Mon Feb 8 13:27:11 PST 2010


Author: brad
Date: 2010-02-08 13:27:10 -0800 (Mon, 08 Feb 2010)
New Revision: 16239

Modified:
   short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDynL.cc
   short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
   short/3D/PyLith/trunk/libsrc/topology/Field.cc
   short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc
   short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
   short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
Log:
Switched to splitting displacement field into components rather than a single fibration.

Modified: short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -78,8 +78,6 @@
   const ALE::Obj<RealSection>& section = field.section();
   assert(!section.isNull());
 
-  const int fibration = (section->getNumSpaces() > 0) ? 0 : -1;
-
   // Set constraints in field
   const int numPoints = _points.size();
   _offsetLocal.resize(numPoints);
@@ -99,13 +97,17 @@
     } // if
     _offsetLocal[iPoint] = curNumConstraints;
     section->addConstraintDimension(_points[iPoint], numFixedDOF);
-    if (fibration >= 0) {
-      assert(fiberDim == section->getFiberDimension(_points[iPoint],
-						    fibration));
-      section->addConstraintDimension(_points[iPoint], numFixedDOF, 
-				      fibration);
-    } // if
   } // for
+
+  // We only worry about the conventional DOF in a split field associated with
+  // fibrations.
+  const int numFibrations = section->getNumSpaces(); // > 1 for split field
+  if (numFibrations > 0)
+    for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
+      const int fibration = _bcDOF[iDOF];
+      for (int iPoint=0; iPoint < numPoints; ++iPoint)
+        section->addConstraintDimension(_points[iPoint], 1, fibration);
+    } // for
 } // setConstraintSizes
 
 // ----------------------------------------------------------------------
@@ -120,8 +122,6 @@
   const ALE::Obj<RealSection>& section = field.section();
   assert(!section.isNull());
 
-  const int fibration = (section->getNumSpaces() > 0) ? 0 : -1;
-
   const int numPoints = _points.size();
   for (int iPoint=0; iPoint < numPoints; ++iPoint) {
     const SieveMesh::point_type point = _points[iPoint];
@@ -168,10 +168,19 @@
 
     // Update list of constrained DOF
     section->setConstraintDof(point, &allFixedDOF[0]);
+  } // for
 
-    if (fibration >= 0)
-      section->setConstraintDof(point, &allFixedDOF[0], fibration);
-  } // for
+  // We only worry about the conventional DOF in a split field associated with
+  // fibrations.
+  const int numFibrations = section->getNumSpaces(); // > 1 for split field
+  if (numFibrations > 0) {
+    int zero = 0;
+    for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
+      const int fibration = _bcDOF[iDOF];
+      for (int iPoint=0; iPoint < numPoints; ++iPoint)
+        section->setConstraintDof(_points[iPoint], &zero, fibration);
+    } // for
+  } // if
 } // setConstraints
 
 // ----------------------------------------------------------------------

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDynL.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDynL.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDynL.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -158,7 +158,8 @@
 
 // ----------------------------------------------------------------------
 void pylith::faults::FaultCohesiveDynL::splitField(topology::Field<
-    topology::Mesh>* field) { // splitFields
+    topology::Mesh>* field)
+{ // splitField
   assert(0 != field);
 
   const ALE::Obj<RealSection>& section = field->section();
@@ -199,7 +200,7 @@
       // Set Langrange fibration fiber dimension.
       section->setFiberDimension(vertexMesh, fiberDim, fibrationLagrange);
     } // if
-} // splitFields
+} // splitField
 
 // ----------------------------------------------------------------------
 // Integrate contribution of cohesive cells to residual term that

Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -146,7 +146,8 @@
 
 // ----------------------------------------------------------------------
 void pylith::faults::FaultCohesiveKin::splitField(topology::Field<
-    topology::Mesh>* field) { // splitFields
+    topology::Mesh>* field)
+{ // splitField
   assert(0 != field);
 
   const ALE::Obj<RealSection>& section = field->section();
@@ -154,20 +155,20 @@
   if (0 == section->getNumSpaces())
     return; // Return if there are no fibrations
 
-  const int fibrationDisp = 0;
-  const int fibrationLagrange = 1;
+  const int spaceDim = field->mesh().dimension();
+  const int fibrationLagrange = spaceDim;
 
   const int numVertices = _cohesiveVertices.size();
   for (int iVertex=0; iVertex < numVertices; ++iVertex) {
     const int v_lagrange = _cohesiveVertices[iVertex].lagrange;
-    const int fiberDim = section->getFiberDimension(v_lagrange);
-    assert(fiberDim > 0);
+    assert(spaceDim == section->getFiberDimension(v_lagrange));
     // Reset displacement fibration fiber dimension to zero.
-    section->setFiberDimension(v_lagrange, 0, fibrationDisp);
+    for (int fibration=0; fibration < spaceDim; ++fibration)
+      section->setFiberDimension(v_lagrange, 0, fibration);
     // Set Lagrange fibration fiber dimension.
-    section->setFiberDimension(v_lagrange, fiberDim, fibrationLagrange);
+    section->setFiberDimension(v_lagrange, spaceDim, fibrationLagrange);
   } // for
-} // splitFields
+} // splitField
 
 // ----------------------------------------------------------------------
 // Integrate contribution of cohesive cells to residual term that do

Modified: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -752,20 +752,22 @@
 pylith::topology::Field<mesh_type>::splitDefault(void)
 { // splitDefault
   assert(!_section.isNull());
-  _section->addSpace(); // displacements
+  const int spaceDim = _mesh.dimension();
+  for (int iDim=0; iDim < spaceDim; ++iDim)
+    _section->addSpace(); // displacements
   _section->addSpace(); // Lagrange multipliers
 
   const chart_type& chart = _section->getChart();
 
-  const int fibration = 0;
   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 = chart.begin();
-       c_iter != chartEnd;
-       ++c_iter) {
-    const int fiberDim = _section->getFiberDimension(*c_iter);
-    _section->setFiberDimension(*c_iter, fiberDim, fibration);
-  } // for
+  for (int fibration=0; fibration < spaceDim; ++fibration)
+    for (typename chart_type::const_iterator c_iter = chart.begin();
+        c_iter != chartEnd;
+        ++c_iter) {
+      assert(spaceDim == _section->getFiberDimension(*c_iter));
+      _section->setFiberDimension(*c_iter, 1, fibration);
+    } // for
 } // splitDefault
 
 // End of file 

Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -136,6 +136,7 @@
   CPPUNIT_ASSERT(!vertices.isNull());
   
   const int fiberDim = _data->numDOF;
+  const int spaceDim = mesh.dimension();
   topology::Field<topology::Mesh> field(mesh);
   field.newSection(vertices, fiberDim);
   field.splitDefault();
@@ -146,7 +147,6 @@
 
   const int numCells = sieveMesh->heightStratum(0)->size();
   const int offset = numCells;
-  const int fibration = 0;
   int iConstraint = 0;
   for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
        v_iter != vertices->end();
@@ -156,23 +156,32 @@
 			   fieldSection->getFiberDimension(*v_iter));
       CPPUNIT_ASSERT_EQUAL(0,
 			   fieldSection->getConstraintDimension(*v_iter));
-      CPPUNIT_ASSERT_EQUAL(_data->numDOF,
-			   fieldSection->getFiberDimension(*v_iter,
-							   fibration));
-      CPPUNIT_ASSERT_EQUAL(0,
-			   fieldSection->getConstraintDimension(*v_iter,
-								fibration));
+      for (int fibration=0; fibration < spaceDim; ++fibration) {
+        CPPUNIT_ASSERT_EQUAL(1,
+            fieldSection->getFiberDimension(*v_iter,
+                fibration));
+        CPPUNIT_ASSERT_EQUAL(0,
+            fieldSection->getConstraintDimension(*v_iter,
+                fibration));
+      } // for
     } else {
       CPPUNIT_ASSERT_EQUAL(_data->numDOF,
 			   fieldSection->getFiberDimension(*v_iter));
       CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF, 
 			   fieldSection->getConstraintDimension(*v_iter));
-      CPPUNIT_ASSERT_EQUAL(_data->numDOF,
-			   fieldSection->getFiberDimension(*v_iter,
-							   fibration));
-      CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF, 
-			   fieldSection->getConstraintDimension(*v_iter,
-								fibration));
+      for (int fibration=0; fibration < spaceDim; ++fibration) {
+        CPPUNIT_ASSERT_EQUAL(1,
+            fieldSection->getFiberDimension(*v_iter,
+                fibration));
+        bool isConstrained = false;
+        for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
+          if (fibration == _data->fixedDOF[iDOF])
+            isConstrained = true;
+        const int constraintDimE = (!isConstrained) ? 0 : 1;
+        CPPUNIT_ASSERT_EQUAL(constraintDimE,
+            fieldSection->getConstraintDimension(*v_iter,
+                fibration));
+      } // for
       ++iConstraint;
     } // if/else
   } // for
@@ -194,6 +203,7 @@
 		 sieveMesh->depthStratum(0);
   CPPUNIT_ASSERT(!vertices.isNull());
   
+  const int spaceDim = mesh.dimension();
   const int fiberDim = _data->numDOF;
   topology::Field<topology::Mesh> field(mesh);
   field.newSection(vertices, fiberDim);
@@ -214,7 +224,6 @@
     const int* fixedDOF = fieldSection->getConstraintDof(*v_iter);
     if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
       CPPUNIT_ASSERT_EQUAL(0, fieldSection->getConstraintDimension(*v_iter));
-      //CPPUNIT_ASSERT(0 == fixedDOF);
     } else {
       CPPUNIT_ASSERT(0 != fixedDOF);
       CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF, 
@@ -225,25 +234,35 @@
     } // if/else
   } // for
 
-  // Check fibration 0
-  const int fibration = 0;
+  // Check fibrations for split fields.
   iConstraint = 0;
   for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
        v_iter != vertices->end();
        ++v_iter) {
-    const int* fixedDOF = fieldSection->getConstraintDof(*v_iter, fibration);
     if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
-      CPPUNIT_ASSERT_EQUAL(0,
-			   fieldSection->getConstraintDimension(*v_iter,
-								fibration));
-      //CPPUNIT_ASSERT(0 == fixedDOF);
+      for (int fibration=0; fibration < spaceDim; ++fibration)
+        CPPUNIT_ASSERT_EQUAL(0,
+            fieldSection->getConstraintDimension(*v_iter,
+                fibration));
     } else {
-      CPPUNIT_ASSERT(0 != fixedDOF);
-      CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF, 
-			   fieldSection->getConstraintDimension(*v_iter,
-								fibration));
-      for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
-	CPPUNIT_ASSERT_EQUAL(_data->fixedDOF[iDOF], fixedDOF[iDOF]);
+      for (int fibration=0; fibration < spaceDim; ++fibration) {
+        bool isConstrained = false;
+        for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
+          if (fibration == _data->fixedDOF[iDOF])
+          isConstrained = true;
+        if (isConstrained) {
+          CPPUNIT_ASSERT_EQUAL(1,
+              fieldSection->getConstraintDimension(*v_iter,
+                  fibration));
+          const int* fixedDOF = fieldSection->getConstraintDof(*v_iter,
+            fibration);
+          CPPUNIT_ASSERT(0 != fixedDOF);
+          CPPUNIT_ASSERT_EQUAL(0, fixedDOF[0]);
+        } else
+          CPPUNIT_ASSERT_EQUAL(0,
+              fieldSection->getConstraintDimension(*v_iter,
+                  fibration));
+      } // for
       ++iConstraint;
     } // if/else
   } // for

Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -924,9 +924,6 @@
 void
 pylith::faults::TestFaultCohesiveKin::testSplitField(void)
 { // testSplitField
-  const int fibrationDisp = 0;
-  const int fibrationFault = 1;
-
   topology::Mesh mesh;
   FaultCohesiveKin fault;
   topology::SolutionFields fields(mesh);
@@ -946,7 +943,7 @@
 
   const ALE::Obj<RealSection>& section = splitField.section();
   CPPUNIT_ASSERT(!section.isNull());
-  CPPUNIT_ASSERT_EQUAL(2, section->getNumSpaces());
+  CPPUNIT_ASSERT_EQUAL(spaceDim+1, section->getNumSpaces());
 
   const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
   CPPUNIT_ASSERT(!sieveMesh.isNull());
@@ -959,25 +956,19 @@
   for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
        v_iter != verticesEnd;
        ++v_iter) {
+    const int fiberDim = section->getFiberDimension(*v_iter);
+    CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
     if (*v_iter == _data->constraintVertices[iVertex]) {
-      const int fiberDim = section->getFiberDimension(*v_iter);
-      const int fiberDimD = section->getFiberDimension(*v_iter, 
-						       fibrationDisp); 
-      const int fiberDimF = section->getFiberDimension(*v_iter, 
-						       fibrationFault); 
-      CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
-      CPPUNIT_ASSERT_EQUAL(0, fiberDimD);
-      CPPUNIT_ASSERT_EQUAL(fiberDim, fiberDimF);
+      for (int fibration=0; fibration < spaceDim; ++fibration)
+        CPPUNIT_ASSERT_EQUAL(0, section->getFiberDimension(*v_iter, fibration));
+      const int fibrationF = spaceDim;
+      CPPUNIT_ASSERT_EQUAL(spaceDim, section->getFiberDimension(*v_iter, fibrationF));
       ++iVertex;
     } else {
-      const int fiberDim = section->getFiberDimension(*v_iter);
-      const int fiberDimD = section->getFiberDimension(*v_iter, 
-						       fibrationDisp); 
-      const int fiberDimF = section->getFiberDimension(*v_iter, 
-						       fibrationFault); 
-      CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
-      CPPUNIT_ASSERT_EQUAL(fiberDim, fiberDimD);
-      CPPUNIT_ASSERT_EQUAL(0, fiberDimF);
+      for (int fibration=0; fibration < spaceDim; ++fibration)
+        CPPUNIT_ASSERT_EQUAL(1, section->getFiberDimension(*v_iter, fibration));
+      const int fibrationF = spaceDim;
+      CPPUNIT_ASSERT_EQUAL(0, section->getFiberDimension(*v_iter, fibrationF));
     } // if/else
   } // for
 } // testSplitField

Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc	2010-02-08 02:08:04 UTC (rev 16238)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc	2010-02-08 21:27:10 UTC (rev 16239)
@@ -1023,15 +1023,14 @@
 void
 pylith::topology::TestFieldMesh::testSplitDefault(void)
 { // testSplitDefault
-  const int fiberDim = 2;
-  const int numFibrations = 2;
-  const int fibration = 0; // Default fibration
-  const int nconstraints[] = { 0, 2, 1, 3 };
-  const int constraints[] = {
-              // 0
-    0, 2,     // 1
-    2,        // 2
-    0, 1, 2,  // 3
+  const int spaceDim = _TestFieldMesh::cellDim;
+  const int numFibrations = spaceDim + 1;
+  const int nconstraints[4] = { 1, 2, 0, 1 };
+  const int constraints[4] = {
+    1,     // 0
+    0, 1,  // 1
+           // 2
+    0,     // 3
   };
     
   Mesh mesh;
@@ -1046,43 +1045,63 @@
   // Create field with atlas to use to create new field
   Field<Mesh> fieldSrc(mesh);
   { // Setup source field
-    fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+    fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, spaceDim);
     fieldSrc.splitDefault();
     const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
     CPPUNIT_ASSERT(!section.isNull());
     int iV=0;
+    int iC=0;
     for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-	 v_iter != vertices->end();
-	 ++v_iter, ++iV) {
-      section->addConstraintDimension(*v_iter, nconstraints[iV]);
-      section->addConstraintDimension(*v_iter, nconstraints[iV], fibration);
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      const int nconstraintsVertex = nconstraints[iV];
+      section->addConstraintDimension(*v_iter, nconstraintsVertex);
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint) {
+        const int fibration = constraints[iC++];
+        section->addConstraintDimension(*v_iter, 1, fibration);
+      } // for
     } // for
     fieldSrc.allocate();
 
-    int index = 0;
-    int i = 0;
+    iC = 0;
+    iV = 0;
+    int zero = 0;
     for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-	 v_iter != vertices->end();
-	 ++v_iter, index += nconstraints[i++]) {
-      section->setConstraintDof(*v_iter, &constraints[index]);
-      section->setConstraintDof(*v_iter, &constraints[index], fibration);
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      const int nconstraintsVertex = nconstraints[iV];
+      if (nconstraintsVertex > 0)
+        section->setConstraintDof(*v_iter, &constraints[iC]);
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint) {
+        const int fibration = constraints[iC++];
+        section->setConstraintDof(*v_iter, &zero, fibration);
+      } // for
     } // for
   } // Setup source field
 
   const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
   CPPUNIT_ASSERT(!section.isNull());
   CPPUNIT_ASSERT_EQUAL(numFibrations, section->getNumSpaces());
-  const ALE::Obj<Mesh::RealSection>& sectionSplit = section->getFibration(0);
-  CPPUNIT_ASSERT(!sectionSplit.isNull());
 
-  CPPUNIT_ASSERT(!vertices.isNull());
-  int iV = 0;
-  for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-       v_iter != vertices->end();
-       ++v_iter) {
-    CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter, fibration));
-    CPPUNIT_ASSERT_EQUAL(nconstraints[iV++], 
-			 section->getConstraintDimension(*v_iter, fibration));
+  for (int fibration=0; fibration < spaceDim; ++fibration) {
+    const ALE::Obj<Mesh::RealSection>& sectionSplit = section->getFibration(fibration);
+    CPPUNIT_ASSERT(!sectionSplit.isNull());
+    CPPUNIT_ASSERT(!vertices.isNull());
+    int iV = 0;
+    int iC = 0;
+    for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      CPPUNIT_ASSERT_EQUAL(1, section->getFiberDimension(*v_iter, fibration));
+      bool isConstrained = false;
+      const int nconstraintsVertex = nconstraints[iV];
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint)
+        if (constraints[iC++] == fibration)
+          isConstrained = true;
+      const int constraintDimE = (!isConstrained) ? 0 : 1;
+      CPPUNIT_ASSERT_EQUAL(constraintDimE,
+                           section->getConstraintDimension(*v_iter, fibration));
+    } // for
   } // for
 } // testSplitDefault
 
@@ -1091,16 +1110,15 @@
 void
 pylith::topology::TestFieldMesh::testCloneSectionSplit(void)
 { // testCloneSectionSplit
-  const int fiberDim = 3;
-  const int nconstraints[] = { 0, 2, 1, 3 };
-  const int constraints[] = {
-              // 0
-    0, 2,     // 1
-    2,        // 2
-    0, 1, 2,  // 3
+  const int spaceDim = _TestFieldMesh::cellDim;
+  const int numFibrations = spaceDim + 1;
+  const int nconstraints[4] = { 1, 2, 0, 1 };
+  const int constraints[4] = {
+    1,     // 0
+    0, 1,  // 1
+           // 2
+    0,     // 3
   };
-  const int numFibrations = 2;
-  const int fibration = 0; // Default fibration
     
   Mesh mesh;
   _buildMesh(&mesh);
@@ -1114,45 +1132,66 @@
   // Create field with atlas to use to create new field
   Field<Mesh> fieldSrc(mesh);
   { // Setup source field
-    fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+    fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, spaceDim);
     fieldSrc.splitDefault();
     const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
     CPPUNIT_ASSERT(!section.isNull());
     int iV=0;
+    int iC=0;
     for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-	 v_iter != vertices->end();
-	 ++v_iter, ++iV) {
-      section->addConstraintDimension(*v_iter, nconstraints[iV]);
-      section->addConstraintDimension(*v_iter, nconstraints[iV], fibration);
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      const int nconstraintsVertex = nconstraints[iV];
+      section->addConstraintDimension(*v_iter, nconstraintsVertex);
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint) {
+        const int fibration = constraints[iC++];
+        section->addConstraintDimension(*v_iter, 1, fibration);
+      } // for
     } // for
     fieldSrc.allocate();
 
-    int index = 0;
-    int i = 0;
+    iC = 0;
+    iV = 0;
+    int zero = 0;
     for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-	 v_iter != vertices->end();
-	 ++v_iter, index += nconstraints[i++]) {
-      section->setConstraintDof(*v_iter, &constraints[index]);
-      section->setConstraintDof(*v_iter, &constraints[index], fibration);
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      const int nconstraintsVertex = nconstraints[iV];
+      if (nconstraintsVertex > 0)
+        section->setConstraintDof(*v_iter, &constraints[iC]);
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint) {
+        const int fibration = constraints[iC++];
+        section->setConstraintDof(*v_iter, &zero, fibration);
+      } // for
     } // for
   } // Setup source field
 
   Field<Mesh> field(mesh);
   field.cloneSection(fieldSrc);
-  const ALE::Obj<Mesh::RealSection>& section = field.section();
+
+  const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
   CPPUNIT_ASSERT(!section.isNull());
   CPPUNIT_ASSERT_EQUAL(numFibrations, section->getNumSpaces());
-  const ALE::Obj<Mesh::RealSection>& sectionSplit = section->getFibration(0);
-  CPPUNIT_ASSERT(!sectionSplit.isNull());
 
-  int iV = 0;
-  for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
-       v_iter != vertices->end();
-       ++v_iter) {
-    CPPUNIT_ASSERT_EQUAL(fiberDim, 
-			 section->getFiberDimension(*v_iter, fibration));
-    CPPUNIT_ASSERT_EQUAL(nconstraints[iV++], 
-			 section->getConstraintDimension(*v_iter, fibration));
+  for (int fibration=0; fibration < spaceDim; ++fibration) {
+    const ALE::Obj<Mesh::RealSection>& sectionSplit = section->getFibration(fibration);
+    CPPUNIT_ASSERT(!sectionSplit.isNull());
+    CPPUNIT_ASSERT(!vertices.isNull());
+    int iV = 0;
+    int iC = 0;
+    for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+        v_iter != vertices->end();
+        ++v_iter, ++iV) {
+      CPPUNIT_ASSERT_EQUAL(1, section->getFiberDimension(*v_iter, fibration));
+      bool isConstrained = false;
+      const int nconstraintsVertex = nconstraints[iV];
+      for (int iConstraint=0; iConstraint < nconstraintsVertex; ++iConstraint)
+        if (constraints[iC++] == fibration)
+          isConstrained = true;
+      const int constraintDimE = (!isConstrained) ? 0 : 1;
+      CPPUNIT_ASSERT_EQUAL(constraintDimE,
+                           section->getConstraintDimension(*v_iter, fibration));
+    } // for
   } // for
 } // testCloneSectionSplit
 



More information about the CIG-COMMITS mailing list