a problem (or maybe bug) using grid_in.read_unv()

45 views
Skip to first unread message

Moraad Biagooi

unread,
Feb 7, 2018, 1:22:45 PM2/7/18
to deal.II User Group

Dear All,

I developed a simple code which just import a simple UNV file, then prints the mesh's boundary_ids and material_ids.
The problem is that the output is EMPTY.

The mesh is 3*3*3 and hexahedral, made with SALOME. There is two integer group_ids attached to some of its faces and cells.

I attached the codes with the UNV file.

Bests,
Morad Biagooi
PhD student at IASBS

// The code :

#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_in.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/vector_tools.h>

#include <iostream>
#include <fstream>

using namespace dealii;

int main ()
{
  Triangulation<3> tria;
 
  std::ifstream in;
  in.open("box.unv");

  GridIn<3,3> gi;
  gi.attach_triangulation(tria);
  gi.read_unv(in);
 
  Triangulation<3>::active_cell_iterator cell = tria.begin_active();
  Triangulation<3>::active_cell_iterator endc = tria.end();   
  for (; cell!=endc; ++cell) {   
    std::cout << "cell: " << cell->id() << "\n";
    std::cout << "  material_id: " << cell->material_id()  << "\n";
    for (unsigned int f=0; f<GeometryInfo<3>::faces_per_cell; ++f) {
      if (cell->face(f)->at_boundary())
        std::cout << "    boundary_id: " << cell->face(f)->boundary_id() << "\n";
    }   
  }  
  in.close();
  return 0;
}
read_unv_example.tar.gz

Moraad Biagooi

unread,
Feb 10, 2018, 6:49:13 AM2/10/18
to deal.II User Group
 Hi again,

Just found this.

https://groups.google.com/forum/#!topic/dealii/mN_MnegDtXE.

Problem solved.

Wolfgang Bangerth

unread,
Feb 12, 2018, 1:28:45 PM2/12/18
to dea...@googlegroups.com
On 02/10/2018 04:49 AM, Moraad Biagooi wrote:
>
> https://groups.google.com/forum/#!topic/dealii/mN_MnegDtXE.
>
> Problem solved.

Glad to see.

We really should fix this by using an *integer* data type for these
boundary_id and similar objects, rather than an unsigned char. It's just
too obscure a problem to find in many situations.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/
Reply all
Reply to author
Forward
0 new messages