![]() |
![]() |
![]() |
We consider the same example as in Lesson 2 with the following modifications:
The Finite Element Code
#include "OFELI.h" #include "Therm.h" using namespace OFELI; int main(int argc, char *argv[]) { |
if (argc <= 1) { cout << " Usage: lesson3 <mesh_file>" << endl; exit(1); } |
Mesh ms(argv[1],true); |
SpMatrix<double> A(ms); |
Vect<double> b(ms.getNbEq()), x(ms.getNbEq()), bc(ms), u(ms); |
bc.setNodeBC(1,"y"); |
MeshElements(ms) { DC2DT3 eq(theElement); eq.Diffusion(); eq.updateBC(bc); eq.ElementAssembly(A); eq.ElementAssembly(b); } |
LinearSolver<double> ls(1000,1.e-8,1); int nb_it = ls.solve(A,b,x,CG_SOLVER,DILU_PREC); |
Note that the member function solve returns the number of performed iterations.
cout << "Nb. of iterations: " << nb_it << endl; |
u.insertBC(ms,x,bc); |
cout << "\nSolution:\n" << u; return 0; } |
Material 1 AluminiumThis line must be given after all elements lines. Note that the file Aluminium.md must be present in the material's directory. We are now ready to test the package.
A test
We use here a finer mesh than in Lesson 2 except the line defining the material. We obtain the same solution as Lesson 2 after 15 iterations.
![]() |
![]() |
![]() |