![]() |
![]() |
![]() |
Demo: The 2-D Laplace equation: P1 Finite Element
We present in this demo a more consistent use of the library. We aim at solving the basic Laplace equation (more precisely the Poisson problem) in 2-D using P1 finite elements.
#include "OFELI.h"
#include "Laplace.h"
using namespace OFELI;
int main(int argc, char *argv[])
{
|
if (argc < 2) {
cout << "\nUsage: " << argv[0] << " <project_file>\n";
return 0;
}
IPF data("laplace_demo1 - 1.0",argv[1]);
|
Verbosity = data.getVerbose();
|
Mesh ms(data.getMeshFile()); |
Vect<double> bc(ms), bf(ms);
Prescription p(ms,data.getPrescriptionFile());
p.get(BOUNDARY_CONDITION,bc);
p.get(SOURCE,bf);
|
Vect |
eq.setInput(BOUNDARY_CONDITION,bc);
eq.setInput(SOURCE,bf);
|
eq.run();
saveField(u,"u.pos",GMSH);
|
Vect<double> sol(ms);
p.get(SOLUTION,sol);
cout << "L2-Error: " << (u-sol).Norm(WNORM2) << endl;
return 0;
}
|
![]() |
![]() |
![]() |