Feel++ provides some tools to manipulate meshes.
Here is a basic example that shows how to generate a mesh for a square geometry (source "doc/manual/tutorial/mymesh.cpp"
).
As always, we initialize the Feel++ environment (see section FirstApp ).
The unitSquare()
will generate a mesh for a square geometry. Feel++ provides several functions to automate the GMSH mesh generation for different topologies. These functions will create a geometry file .geo and a mesh file
.msh. We can visualize them in GMSH.
gmsh <entity_name>.msh
Finally we use the exporter()
(see Post-Processing and Visualization) function to export the mesh for post processing. It will create by default a Paraview format file .sos and an Ensight format file
.case.
paraview <app_name>.sos
In this section, we present some of the mesh definition and manipulation tools provided by Feel++. For more information you can also see Gmsh.
There is a list of basic geometries you can automatically generate with Feel++ library.
Feel++ function | Dim | Description</th |
---|---|---|
unitSegment() ; | 1 | Build a mesh of the unit segment \([0,1]\) |
unitSquare() ; | 2 | Build a mesh of the unit square \([0,1]^2\) using triangles |
unitCircle() ; | 2 | Build a mesh of the unit circle using triangles |
unitHypercube() ; | 3 | Build a mesh of the unit hypercube \([0,1]^3\) using tetrahedrons |
unitSphere() ; | 3 | Build a mesh of the unit sphere using tetrahedrons |
Examples:
From "doc/manual/tutorial/myfunctionspace.cpp"
:
You can use this function to:
.msh file and use the mesh data structure
.geo file and automatically generate a mesh data structure on this geometrical structureInterface:
Required Parameters:
_mesh:
a mesh data structure.Optional Parameters:
_hsize
(double): characteristic size of the mesh. This option will edit the
.geo file and change the variable h
if defined0.1
gmsh.hsize
_geo_variables_list
(string): Set a list of variable that may be defined in a
.geo file""
gmsh.geo-variables-list
_filename
(string): filename with extension."feel.geo"
gmsh.filename
_depends
(string): list of files (separated by , or ;) on which gmsh.filename
depends""
gmsh.depends
_refine
(boolean): optionally refine with refine
levels the mesh.0
.gmsh.refine
_update
(integer): update the mesh data structure (build internal faces and edges).true
_physical_are_elementary_regions
(boolean): to load specific meshes formats.false
._straighten
(boolean): in case of curvilinear elements, straighten the elements which are not touching with a face the boundary of the domaintrue
gmsh.straighten
_partitioner
(integer): define the mesh partitioner to use:1
(if Metis is available) 0
if not (CHACO)
The file you want to load has to be in an appropriate repository.
Feel++ looks for .geo and
.msh files in the following directories (in this order):
"$HOME/feel/geo"
(cf: Environment ) "$FEELPP_DIR/share/feel/geo"
(cf: Environment)Examples:
Load a mesh data structure from the file "$HOME/feel/mymesh.msh"
.
Load a geometric structure from the file "./mygeo.geo"
and automatically create a mesh data structure.
Create a mesh data structure from the file "./feel.geo"
.
In order to load only .msh file, you can also use the loadGMSHMesh.
Interface:
Required Parameters:
_mesh:
a mesh data structure. _filename:
filename with extension.Optional Parameters:
_refine:
optionally refine with refine
levels the mesh. Default =0
. _update:
update the mesh data structure (build internal faces and edges). Default =true
. _physical_are_elementary_regions:
to load specific meshes formats. Default = false
.The file you want to load has to be in an appropriate repository. See loadMesh.
Examples:
From "doc/manual/heatns.cpp"
:
From "applications/check/check.cpp"
:
Interface:
Required Parameters:
_mesh:
mesh data structure. _desc:
descprition. See further.Optional Parameters:
_h:
characteristic size. Default = 0.1
. _order:
order. Default = 1
. _parametricnodes:
Default = 0
. _refine:
optionally refine with refine
levels the mesh. Default =0
. _update:
update the mesh data structure (build internal faces and edges). Default =true
. _force_rebuild:
rebuild mesh if already exists. Default = false
. _physical_are_elementary_regions:
to load specific meshes formats. Default = false
.To generate your mesh you need a description parameter. This one can be create by one the two following function.
Use this function to create a description from a .geo file.
Interface :
Required Parameters:
filename:
file to load.Optional Parameters:
_h:
characteristic size of the mesh. Default = 0.1
. _dim:
dimension. Default = 3
. _order:
order. Default = 1
. _files_path:
path to the file. Default = localGeoRepository()
.The file you want to load has to be in an appropriate repository. See loadMesh.
Examples :
From "doc/manual/heat/ground.cpp"
:
From "doc/manual/fd/penalisation.cpp"
:
Use this function to generate a simple geometrical domain from parameters.
Interface :
Required Parameters:
_name:
name of the file that will ge generated without extension. _shape:
shape of the domain to be generated (simplex or hypercube).Optional Parameters:
_h:
characteristic size of the mesh. Default = 0.1
. _dim:
dimension of the domain. Default = 2
. _order:
order of the geometry. Default = 1
. _convex:
type of convex used to mesh the domain. Default = simplex
._addmidpoint:
add middle point. Default = true
. _xmin:
minimum x coordinate. Default = 0
. _xmax:
maximum x coordinate. Default = 1
. _ymin:
minimum y coordinate. Default = 0
. _ymax:
maximum y coordinate. Default = 1
. _zmin:
minimum z coordinate. Default = 0
. _zmax:
maximum z coordinate. Default = 1
.Examples :
From "doc/manual/laplacian/laplacian.ccp"
:
From "doc/manual/stokes/stokes.cpp"
:
From "doc/manual/solid/beam.cpp"
: