Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
First Feel++ Application
Author
Christophe Prud'homme

See section Building Feel++ for more information about Feel++ installation.

Minimal Example

Let's begin with our first program using the Feel++ framework (source : "doc/manual/tutorial/myapp.cpp"). Before all, you have to include the Feel++ headers.

#include <feel/feel.hpp>
using namespace Feel;

We use the C++ namespace to avoid Feel:: prefix before Feel++ objects.

int main( int argc, char* argv[] )
{
// create custom command option
po::options_description app_options( "MyApp options" );
app_options.add( feel_options() );
app_options.add_options()
( "value",
po::value<double>() -> default_value(4.2),
"a ’double’ with default value" )
;
// initialize feel++ environment
Environment env( _argc=argc, _argv=argv,
_desc=app_options,
_about=about( _name="myapp",
_author="Feel++ Consortium",
_email="feelpp-devel@feelpp.org") );
// create a log and write inside
LOG(INFO) << "value = " << option(_name="value").as<double>()
<< std::endl;
LOG(INFO) << "proc " << Environment::worldComm().globalRank()
<<" of "<< Environment::numberOfProcessors()
<< std::endl;
}
  • We pass command line options using the Boost Program Options, library using the prefix po:: which is a Feel++ alias for the Boost::program_options namespace. To add a new Feel++ option, we must create a new Feel++ options_description. You must add the default Feel++ options and the new one that we choose here as a double value. Note that the default value will be assigned if not specified by the user.
  • Then we initialize the environment variables through the Feel++ Environment class.
  • We instantiate a new application. We specify the directory where to execute the program. That could be usefull for archiving your results.
  • Finally, we save the results in a log file using the google-glog library. As you can see, we save in this example our custom option value and the current processor number.

top


Compilation, execution, logs

To compile a tutorial, just use the GNU make command.

  make feelpp_doc_<appname>

where <appname> is the name of the application you wish to compile (here, myapp). Go to the execution directory as specified in the program, and execute it. You can change your option value.

  ./feelpp_doc_myapp [--value 6.6]

You can list the log files created.

  ls /tmp/<your login>/feelpp_doc_myapp/

If you open one of these log, you should be able to see your value and the processor number used to compute. You can run your application on several processors using MPI.

  mpirun -np 2 feelpp_doc_myapp

Note that there will be one log for each processor in that case.

top


Config files

A config file can be parsed to the program to profile your options. The default config paths are,

  • current dir
  • $HOME/feel/config/
  • $INSTALL_PREFIX/share/feel/config/

then you have to write inside one of these folders a file called <app_name>.cfg or feelpp_<app_name>.cfg. For example, our myapp.cfg would looks like,

value=0.53

Note that you can specify the config file through the option –config-file=<path>

top


Initializing PETSc and Trilinos

PETSc is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for parallelism.

Feel++ supports the PETSc framework, the Environment takes care of initializing the associated PETSc environment.

top



Generated on Fri Oct 25 2013 14:24:27 for Feel++ by doxygen 1.8.4