The next step is to construct a function space over the mesh. The source code is available in myfunctionspace.cpp
.
#include <feel/feel.hpp>
using namespace Feel;
int main( int argc, char** argv )
{
Environment env( _argc=argc, _argv=argv,
_about=about( _name="myfunctionspace",
_author="Feel++ Consortium",
_email="feelpp-devel@feelpp.org" ) );
auto mesh = loadMesh(_mesh=new Mesh<Simplex<2>>);
auto Xh = Pch<2>( mesh );
auto g = expr( soption(_name="functions.g"));
auto gradg = grad<2>(g);
auto u = Xh->element( "u" );
auto w = Xh->element( "w" );
u.on( _range=elements( mesh ), _expr=g );
w.on( _range=elements( mesh ), _expr=idv( u )-g );
double L2g = normL2( elements( mesh ), g );
double H1g = normL2( elements( mesh ), _expr=g,_grad_expr=gradg );
double L2uerror = normL2( elements( mesh ), ( idv( u )-g ) );
double H1uerror = normH1( elements( mesh ), _expr=( idv( u )-g ),
_grad_expr=( gradv( u )-gradg ) );
std::cout << "||u-g||_0 = " << L2uerror/L2g << std::endl;
std::cout << "||u-g||_1 = " << H1uerror/H1g << std::endl;
auto e = exporter( _mesh=mesh );
e->add( "g", u );
e->add( "u-g", w );
e->save();
}