Dear developers,
     I am trying out the VTK Input-Output feature of libmesh and run in 
a bug that causes incorrect output of refined meshes.

In the following test code I create a mesh of a single QUAD4 element and 
call vtkio.write to output the mesh into a file. The output is correct, 
since the mesh has 4 nodes and the element (0123).

Next, I repeatedly uniformly refine the mesh and call vtkio.write again. 
Already after 1 refinement, the output is wrong: the output file 
correctly contains 4 elements, but the inactive (0123) is included, 
while the active top-right subelement (5728) is not included. (At this 
point, viewing the file with paraview, it has a reasonable look, but 
after another refinement, the problem becomes evident even at visual 
inspection)

I had a quick look at the code and maybe the bug is in 
libMesh::VTKIO::cells_to_vtk (at line 140 of file vtk_io.C).
In fact, I think that the loop

for(unsigned int el_nr =0; el_nr< mesh.n_active_elem(); ++el_nr){
    Elem *elem  = mesh.elem(el_nr);

loops over the first n_active_elem(), regardless of their state, while 
it should loop only over active elements.

By the way, also vtkio.write_equation_systems has some funny behaviour, 
but hopefully it's the same bug...

I hope this helps. The code to reproduce the bug follows the signature.

(For the records, I have libmesh-0.7.0.4, compiled with VTK support and 
using vtk5.4 libraries on a Debian squeeze system)


Best regards,
     Matteo Semplice


=================== vtk_output_error.C =================
  // C++ include files that we need
#include <iostream>
// Functions to initialize the library.
#include "libmesh.h"
// Basic include files needed for the mesh functionality.
#include "mesh.h"
// Include file that defines various mesh generation utilities
#include "mesh_generation.h"
#include "mesh_refinement.h"
//Include VTK Input-Output
#include "vtk_io.h"

// Bring in everything from the libMesh namespace
using namespace libMesh;

int main (int argc, char** argv)
{
   LibMeshInit init (argc, argv);

   // Skip this 2D example if libMesh was compiled as 1D-only.
   libmesh_example_assert(2 <= LIBMESH_DIM, "2D support");

   // Create a mesh
   Mesh mesh;
   // A mesh with just 1 QUAD4 element
   MeshTools::Generation::build_square (mesh, 1, 1, 0.,1.,0.,1.,QUAD4);

   VTKIO vtkio(mesh);

   MeshRefinement mesh_ref(mesh);

   for (int ref=0;ref<5;ref++)
     {
       if (ref>0){
     mesh_ref.uniformly_refine(1);
       }
       std::ostringstream filename;
       filename << "mesh"<<ref<<".vtu";
       vtkio.write(filename.str());
     }

   return 0;
}
====================================================

-- 
Matteo Semplice                         Dip. di Fisica e Matematica
Phone: 031-2386132                      Università dell'Insubria
Fax:   031-2386209                      Via Valleggio, 11
                                        22100 Como


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to