Feel++ 0.91.0

Manipulating Meshes

In this section, we present some of the mesh definition and manipulation tools provided by Feel.

Mesh definition

We look at the definition of a mesh data structure. First, we define the type of geometric entities that we shall use to form our mesh. Feel supports

We choose between Simplex<Dim,Order,RealDim> and SimplexProduct<Dim,Order,RealDim>. They have the same template arguments: {itemize} Dim: the topological dimension of the entity Order: the order of the entity(usually 1, higher order in development) RealDim: the dimension of the real space {itemize}

    //# marker1 #
    typedef Simplex<Dim> convex_type;
    //typedef Hypercube<Dim, 1,Dim> convex_type;
    //# endmarker1 #

Then we define the mesh type, Mesh<Entity> by passing as argument the type of entity it is formed with. At the moment hybrid meshes are not supported.

    //# marker2 #
    typedef Mesh<convex_type > mesh_type;
    typedef boost::shared_ptr<mesh_type> mesh_ptrtype;
    //# endmarker2 #

The next step is to read some mesh files. Feel supports only the Gmsh mesh file format. It provides also some classes to manipulate Gmsh .geo files and generate .msh files. To begin, we use some helper functions to generate a .geo file.

Here is an example

    //# marker4 #
    auto mesh = createGMSHMesh( _mesh=new mesh_type,
                                _desc=domain( _name=(boost::format( "%1%-%2%" ) % shape % Dim).str() ,
                                              _shape=shape,
                                              _dim=Dim,
                                              _h=X[0] ) );
    //#endmarker4#

The parameter _h allows to change the mesh characteristic size to M_meshSize which was given for example on the command line using the Application framework, see this section for more details.

We get a simplex (line in 1D, triangle in 2D and tetrahedron) geometry and mesh when executing

feel_doc_mymesh --shape="simplex" --nochdir
feel_doc_mymesh --shape="hypercube" --nochdir

generates the following graphics after post-processing with

gmsh mymesh-simplex.pos
gmsh mymesh-hypercube.pos
mymesh-simplex-1.png

Line

mymesh-simplex-2.png

Triangle

mymesh-simplex-3.png

Tetrahedron

mymesh-hypercube-1.png

Line

mymesh-hypercube-2.png

Unit Square

mymesh-hypercube-3.png

Unit Cube

Here is the output of the execution

Simplex

Hypercube

Exporting Meshes for post-processing

At this stage we are ready to use the mesh instance: we can for example export the mesh to a postprocessing format. Two formats are supported at the moment

First we define the Exporter data structure type

    //# marker61 #
    /* export */
    typedef Exporter<mesh_type> export_type;
    typedef boost::shared_ptr<export_type> export_ptrtype;
    //# endmarker61 #

We then call in the code Exporter::setMesh() and Exporter::save() to save the mesh to the format given to the command line --exporter= <format> (by default it is ensight)

    //# marker62 #
    exporter->step(0)->setMesh( mesh );
    exporter->save();
    //# endmarker62 #

Iterating over the entities of a mesh Iterating over the entities of a mesh

Feel mesh data structures provides powerful iterators that allows to walk though the mesh in various ways: iterate over element, faces , points, marked (associated to an integer flag denoting a region, material, processor) elements, marked faces, ...