← Back to team overview

dolfin team mailing list archive

[noreply@xxxxxxxxxxxxx: [Branch ~dolfin-core/dolfin/trunk] Rev 6460: Fix 1D mesh refinement bug and add unit test for this]

 

Nice. This looks small enough to be applied also to the 1.0.x branch.
Can you add it?

--
Anders
--- Begin Message ---
Merge authors:
  Marie Rognes (meg-simula)
------------------------------------------------------------
revno: 6460 [merge]
committer: Marie E. Rognes <meg@xxxxxxxxx>
branch nick: dolfin-trunk
timestamp: Tue 2011-11-22 03:29:46 +0100
message:
  Fix 1D mesh refinement bug and add unit test for this
modified:
  dolfin/mesh/IntervalCell.cpp
  dolfin/mesh/UnitInterval.cpp
  test/unit/refinement/python/refine.py


--
lp:dolfin
https://code.launchpad.net/~dolfin-core/dolfin/trunk

Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
To unsubscribe from this branch go to https://code.launchpad.net/~dolfin-core/dolfin/trunk/+edit-subscription
=== modified file 'dolfin/mesh/IntervalCell.cpp'
--- dolfin/mesh/IntervalCell.cpp	2011-11-18 12:14:50 +0000
+++ dolfin/mesh/IntervalCell.cpp	2011-11-22 02:03:02 +0000
@@ -17,6 +17,7 @@
 //
 // Modified by Kristian Oelgaard, 2007.
 // Modified by Kristoffer Selim, 2008.
+// Modified by Marie E. Rognes, 2011.
 //
 // First added:  2006-06-05
 // Last changed: 2011-11-14
@@ -89,11 +90,9 @@
 void IntervalCell::refine_cell(Cell& cell, MeshEditor& editor,
                               uint& current_cell) const
 {
-  // Get vertices and edges
+  // Get vertices
   const uint* v = cell.entities(0);
-  const uint* e = cell.entities(1);
   dolfin_assert(v);
-  dolfin_assert(e);
 
   // Get offset for new vertex indices
   const uint offset = cell.mesh().num_vertices();
@@ -101,7 +100,7 @@
   // Compute indices for the three new vertices
   const uint v0 = v[0];
   const uint v1 = v[1];
-  const uint e0 = offset + e[0];
+  const uint e0 = offset + cell.index();
 
   // Add the two new cells
   editor.add_cell(current_cell++, v0, e0);

=== modified file 'dolfin/mesh/UnitInterval.cpp'
--- dolfin/mesh/UnitInterval.cpp	2011-11-15 13:49:49 +0000
+++ dolfin/mesh/UnitInterval.cpp	2011-11-22 02:03:02 +0000
@@ -16,7 +16,7 @@
 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 //
 // First added:  2007-11-23
-// Last changed: 2011-11-15
+// Last changed: 2011-11-22
 
 #include <dolfin/common/MPI.h>
 #include "MeshPartitioning.h"
@@ -55,9 +55,9 @@
 
   // Create intervals
   for (uint ix = 0; ix < nx; ix++) {
-  	const uint v0 = ix;
-  	const uint v1 = v0 + 1;
-  	editor.add_cell(ix, v0, v1);
+    const uint v0 = ix;
+    const uint v1 = v0 + 1;
+    editor.add_cell(ix, v0, v1);
   }
 
   // Close mesh editor

=== modified file 'test/unit/refinement/python/refine.py'
--- test/unit/refinement/python/refine.py	2011-08-24 01:00:54 +0000
+++ test/unit/refinement/python/refine.py	2011-11-22 02:08:53 +0000
@@ -25,6 +25,13 @@
 
 class MeshRefinement(unittest.TestCase):
 
+    def test_uniform_refine1D(self):
+        if MPI.num_processes() == 1:
+            mesh = UnitInterval(2)
+            mesh2 = refine(mesh)
+            self.assertEqual(mesh.hmax(), 0.5)
+            self.assertEqual(mesh2.hmax(), 0.25)
+
     def test_uniform_refine2D(self):
         if MPI.num_processes() == 1:
             mesh = UnitSquare(4, 6)


--- End Message ---

Follow ups