![]() |
![]() |
![]() |
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.getNbDOF()); |
bc.setNodeBC(ms,1,"y"); |
MeshElements(ms) { DC2DT3 eq(theElement); eq.Diffusion(); eq.updateBC(bc); eq.ElementAssembly(A); eq.ElementAssembly(b); } |
double toler = 1.e-8; int nb_it = CG(a,Prec<double>(A,ILU_PREC),b,x,100,toler,2); |
Note that CG returns the number of performed iterations.
cout << "Nb. of iterations: " << nb_it << endl; |
Vect<double> u(ms.getNbDOF()); 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.
![]() |
![]() |
![]() |