Feel++ 0.91.0
|
In this section, we present some of the mesh definition and manipulation tools provided by Feel.
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.
createGMSHMesh
allows to generate a mesh .msh
file automatically from a description (e.g. .geo
file) using the _desc
parameter and store the generated mesh into the _mesh
parameter allocated when calling the funcitondomain
allows to generate
.geo string description of simple domains : simplex and hypercubeHere 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
![]() Line | ![]() Triangle | ![]() Tetrahedron |
![]() Line | ![]() Unit Square | ![]() Unit Cube |
Here is the output of the execution
Simplex
| Hypercube
|
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
Ensight
(case and sos) which is supported by the software Ensight{{http://www.ensight.com}} and Paraview{{http://www.paraview.org}}Gmsh
which is post-processing format of GmshFirst 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 #
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, ...