Visualizing functions over a mesh

The next step is to visualize function over the mesh. The source code that generate our output is presented in the previous section, we recall it here

// tag::all[]
#include <feel/feelcore/environment.hpp>
#include <feel/feeldiscr/pch.hpp>
#include <feel/feeldiscr/operatorlagrangep1.hpp>
#include <feel/feelfilters/exporter.hpp>
#include <feel/feelfilters/unitcircle.hpp>

// tag::main[]
int main(int argc, char**argv )
{
  using namespace Feel;
  Environment env( _argc=argc, _argv=argv,
      _about=about(_name="myexporter",
        _author="Christophe Prud'homme",
        _email="christophe.prudhomme@feelpp.org"));

  // tag::meshspace[]
  // circle - geometrical order: 2
  auto mesh = unitCircle<2>();

  // circle - geometrical order: 1
  auto meshp1 = unitCircle<1>();

  auto Xh = Pch<2>( mesh );
  // end::meshspace[]

  // tag::expr[]
  auto myExpr = sin(pi*Px());
  // end::expr[]

  // tag::project[]
  auto v = project( _space=Xh, _range=elements(mesh), _expr=myExpr);
  // end::project[]

  // tag::exporter[]
  auto exhi = exporter( _mesh=mesh, _name="exhi" );
  auto exlo = exporter( _mesh=meshp1, _name="exlo" );
//  auto exhilo = exporter( _mesh=lagrangeP1(_space=Xh)->mesh(),_name="exhilo");

  int max = 10; double dt = 0.1;
  double time = 0;
  for (int i = 0; i<max; i++)
  {
    //exhilo->step( time )->add( "vhilo", v );
    exlo->step( time )->add( "vlo", idv(v) );
    exhi->step( time )->add( "vhi", v );
    time += dt;
    // tag::save[]
    exhi->save();
    exlo->save();
    //exhilo->save();
    // end::save[]
  }
  // end::exporter[]
}
// end::main[]
// end::all[]

You can visualize data via :

  • link::https://www.ceisoftware.com/[ensight]

  • link::http://www.paraview.org/[paraview]

  • link::http://geuz.org/gmsh[gmsh]

The results files are in

  • $HOME/feel/myexporter/np_1

or

  • $FEELPP_REPOSITORY/feel/myexporter/np_1.

We discriminate output directories based on the name of the simulation (the parameter _name in the environment), the number of process (mpirun -np …​) and the type of the chosen exporter

Command line option to control the output format for visualization
--exporter.format={ensight|ensightgold|gmsh|...}

or in the config file .Config file option to control the output format for visualization

[exporter]
format={ensightgold|ensight|xdmf|gmsh|...}