Loading a Mesh

The next step is to load a mesh.

The loadMesh function has a _name option set by default as the default value of the --gmsh.filename option that point either to a .geo, either to a .msh, or a .h5 file.

Meshes in general are more detailed in this section.

auto mesh=loadMesh( _mesh=new Mesh<Simplex<2>> );

1. Exporting the Mesh for visualisation

See this section for more details about exporting and visualizing meshes.

2. Implementation

An implementation reads as follows:

#include <feel/feelcore/environment.hpp>
#include <feel/feelfilters/loadmesh.hpp>
#include <feel/feelvf/integrate.hpp>
#include <feel/feelvf/cst.hpp>

#include "ut.hpp"

int main( int argc, char** argv )
{
    using namespace Feel;

    // initialize Feel++ Environment
    Environment env( _argc=argc, _argv=argv,
                     _about=about( _name="mymesh" ,
                                   _author="Feel++ Consortium",
                                   _email="feelpp-devel@feelpp.org" ) );


    // tag::mesh[]
    // create a mesh with GMSH using Feel++ geometry tool
    auto mesh = loadMesh(_mesh=new  Mesh<Simplex<2>>);
    // end::mesh[]

    LOG(INFO) << "mesh " << soption(_name="gmsh.filename") << " loaded";
    using namespace Feel::vf;
    auto I1 = integrate( _range=elements( mesh ), _expr=cst( 1. ) ).evaluate();
    LOG(INFO) << "volume =" << I1;
    auto I2 = integrate( _range=boundaryfaces( mesh ), _expr=cst( 1. ) ).evaluate();
    LOG(INFO) << "surface = " << I2;

    using namespace boost::ut;
    "Mesh"_test  = [&] {
        expect( I1(0,0) == 4.00000000_d );
        expect( I2(0,0) == 8.00000000_d );
    };
}

and the associated config file

[gmsh]
hsize=1e-1
filename=$cfgdir/03-mymesh.geo