Dear Marek, 

> On 29 Sep 2018, at 22:58, Marek Čapek <fregew...@gmail.com> wrote:
> 
> Hi,
> I have a geometry in step file format. I would like to import it and generate
> from it a mesh digestible by dealii GridIn functions.
> I followed step-54, modifying thefunction read_domain
> 
> https://www.dealii.org/8.4.1/doxygen/deal.II/step_54.html#TriangulationOnCADread_domain
> 
> in the following way:
> 
>   void TriangulationOnCAD::read_domain()
>   {
>     TopoDS_Shape sh = OpenCASCADE::read_STEP(cad_file_name, 1e-3);
> 
>     std::vector<TopoDS_Face>   faces;
>      std::vector<TopoDS_Edge>   edges;
>      std::vector<TopoDS_Vertex> vertices;
> 
>      OpenCASCADE::extract_geometrical_shapes(sh, faces, edges, vertices);
> 
>      OpenCASCADE::create_triangulation(faces[0], tria);
> 
>      
>        const double tolerance = OpenCASCADE::get_shape_tolerance(sh) * 5;
> 
>     
>        std::vector<TopoDS_Compound>  compounds;
>        std::vector<TopoDS_CompSolid> compsolids;
>        std::vector<TopoDS_Solid>     solids;
>        std::vector<TopoDS_Shell>     shells;
>        std::vector<TopoDS_Wire>      wires;
> 
>        OpenCASCADE::extract_compound_shapes(sh,
>                                             compounds,
>                                             compsolids,
>                                             solids,
>                                             shells,
>                                             wires);

You have to make sure you know how the surfaces/wires/solids,etc are 
distributed in your CAD file. This will depend on how you generated your cad 
file, how many faces it is made of, etc.


>  std::ifstream in;
> 
>        in.open(initial_mesh_filename.c_str());
> 
>        GridIn<2,3> gi;
>        gi.attach_triangulation(tria);
>        gi.read_vtk(in);

How did you generate the initial grid? Are you sure the scaling is correct? 
IGES and STEP files often have different units of measure (typically IGES files 
units are millimiters). If your grid does not use the same units, you may get 
into trouble.

>        output_results(0);
> 
>       
>        Triangulation<2,3>::active_cell_iterator cell = tria.begin_active();
>        cell->set_manifold_id(1);

This only sets the first cell id to 1. I don’t think your initial mesh only 
contains one face, does it? If it does, from what I can see from the file, 
there is no chance it can produce anything sensible. You will have to produce 
an initial mesh that is at least topologically equivalent to the CAD file your 
are trying to import. 

> 
>        for (unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
>          cell->face(f)->set_manifold_id(2);

Same here. You are setting the id of the faces of the first cell to 2.

>        OpenCASCADE::ArclengthProjectionLineManifold<2,3>
>        line_projector (wires[0], tolerance);
> 
>        tria.set_manifold(2, line_projector);

There are at least 5 wires in the file you attached. You should identify where 
they are, set the corresponding manifold ids to something useful, and then 
attach the correct wire. The above lines were working on the case of the 
example, but won’t work in your case.

> Maybe my approach is wrong. Is that possible to import an IGES or STEP file 
> into dealii and
> let dealii process it automatically?

It depends by what you mean with “automatically”. If you have an input grid (in 
ucd format) where you already specified all the manifold ids, then you could use

read_ucd (in, true /* apply_all_indicators_to_manifolds */)

to get a mesh with all manifold ids set to the correct value. Then you should 
loop over all wires, and attach the correct one to the corresponding manifold 
id, and do the same with all faces. This cannot be done automatically, unless 
you manage to number your manifold ids with the same numbering of the step file 
(which I strongly suggest you do).

Unfortunately, we don’t have a file format (yet) that would do this 
automatically. You’ll have to do a lot of manual tuning.

L.

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to