Feellgood
solver.h
Go to the documentation of this file.
1 #ifndef solver_h
2 #define solver_h
3 
10 #include <eigen3/Eigen/Dense>
11 #include "mesh.h"
12 
18 template <int DIM_PROBLEM>
19 class solver
20  {
21  public:
23  explicit solver(Mesh::mesh & _msh ,
24  std::vector<Tetra::prm> & _pTetra ,
25  std::vector<Facette::prm> & _pFac ,
26  const std::string name ,
27  const double _tol ,
28  const bool v ,
29  const int max_iter ):
30  msh(&_msh), NOD(_msh.getNbNodes()), paramTet(_pTetra),
31  paramFac(_pFac), verbose(v), iter(name,_tol,v,max_iter) {}
32 
34  virtual void checkBoundaryConditions(void) const = 0;
35 
36  protected:
38  static const int DIM_PB = DIM_PROBLEM;
39 
42 
44  const int NOD;
45 
47  const std::vector<Tetra::prm> &paramTet;
48 
50  const std::vector<Facette::prm> &paramFac;
51 
53  const bool verbose;
54 
57 
61  template <int N>
62  void buildMat(std::vector<int> &ind, Eigen::Matrix<double,DIM_PROBLEM*N,DIM_PROBLEM*N> &Ke, algebra::w_sparseMat &K)
63  {
64  for (int ie=0; ie<N; ie++)
65  {
66  int i_ = ind[ie];
67  for (int je=0; je<N; je++)
68  {
69  int j_ = ind[je];
70  for (int di=0; di<DIM_PROBLEM; di++)
71  for (int dj=0; dj<DIM_PROBLEM; dj++)
72  K.insert(DIM_PROBLEM*i_ + di, DIM_PROBLEM*j_ + dj, Ke(di*N+ie,dj*N+je));
73  }
74  }
75  }
76 
80  template <int N>
81  void buildVect(std::vector<int> &ind, std::vector<double> &Le, std::vector<double> &L)
82  {
83  for (int ie=0; ie<N; ie++)
84  {
85  int i_ = ind[ie];
86  for (int di=0; di<DIM_PROBLEM; di++)
87  { L[DIM_PROBLEM*i_ + di] += Le[di*N+ie]; }
88  }
89  }
90  }; // end template class solver
91 
92 #endif
Definition: mesh.h:27
Write-mode sparse matrix.
Definition: sparseMat.h:52
void insert(const int i, const int j, const double val)
Definition: sparseMat.h:70
template class for the different solvers template parameter DIM_PROBLEM: dimensionnality of the probl...
Definition: solver.h:20
Mesh::mesh * msh
Definition: solver.h:41
virtual void checkBoundaryConditions(void) const =0
void buildMat(std::vector< int > &ind, Eigen::Matrix< double, DIM_PROBLEM *N, DIM_PROBLEM *N > &Ke, algebra::w_sparseMat &K)
Definition: solver.h:62
const int NOD
Definition: solver.h:44
const bool verbose
Definition: solver.h:53
void buildVect(std::vector< int > &ind, std::vector< double > &Le, std::vector< double > &L)
Definition: solver.h:81
algebra::iteration< double > iter
Definition: solver.h:56
const std::vector< Tetra::prm > & paramTet
Definition: solver.h:47
solver(Mesh::mesh &_msh, std::vector< Tetra::prm > &_pTetra, std::vector< Facette::prm > &_pFac, const std::string name, const double _tol, const bool v, const int max_iter)
Definition: solver.h:23
static const int DIM_PB
Definition: solver.h:38
const std::vector< Facette::prm > & paramFac
Definition: solver.h:50
class mesh, readMesh is expecting a mesh file in gmsh format either text or binary,...
const int N
Definition: facette.h:17
constexpr double v[NPI]
Definition: facette.h:22