Feellgood
linear_algebra.h
Go to the documentation of this file.
1 #ifndef linear_algebra_h
2 #define linear_algebra_h
3 
10 #include <random>
11 #pragma GCC diagnostic push
12 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
13 #include <execution>
14 #pragma GCC diagnostic pop
15 
16 #include "config.h"
17 
18 #include "settings.h"
19 #include "solver.h"
20 #include "node.h"
21 #include "tetra.h"
22 
24 const int DIM_PB_MAG = 2;
25 
34 class LinAlgebra : public solver<DIM_PB_MAG>
35  {
36 public:
41  : solver<DIM_PB_MAG>(
42  my_msh, s.paramTetra, s.paramTriangle, "bicg_dir", s.TOL, s.verbose, s.MAXITER,
43  [this](const Mesh::Edge edge){ return msh->magNode[edge.first] && msh->magNode[edge.second]; }
44  ),
45  verbose(s.verbose),
46  extSpaceField(my_msh.extSpaceField)
47  {
48  Xw.resize(2 * NOD);
50  if (!s.recenter)
51  { idx_dir = Nodes::IDX_UNDEF; }
52  else
53  { idx_dir = s.recentering_direction; }
54 
55  for (int i = 0; i < NOD; i++)
56  {
57  if(!my_msh.magNode[i])
58  {
59  lvd.push_back(2 * i );
60  lvd.push_back(2 * i + 1);
61  }
62  }
63  lvd.shrink_to_fit();
64  }
65 
67  void checkBoundaryConditions(void) const override {}
68 
75  void prepareElements(const Eigen::Vector3d &Hext ,
76  const timing &t_prm ) const;
77 
84  void prepareElements(const double A_Hext ,
86  const timing &t_prm ) const;
87 
89  void buildInitGuess(std::vector<double> &G) const;
90 
94  bool solve(const timing &t_prm );
95 
97  inline void set_DW_vz(const double vz )
98  { DW_vz = vz; }
99 
101  inline double get_v_max(void) const
102  { return v_max; }
103 
107 
109  void base_projection() const;
110 
111 private:
114 
116  std::vector<double> Xw;
117 
119  const int verbose;
120 
122  double DW_vz;
123 
125  double v_max;
126 
128  const std::vector< Eigen::Matrix<double,Nodes::DIM,Tetra::NPI> >& extSpaceField;
129 
131  std::vector<int> lvd;
132  };// end class linAlgebra
133 #endif
Definition: linear_algebra.h:35
LinAlgebra(Settings &s, Mesh::mesh &my_msh)
Definition: linear_algebra.h:40
double DW_vz
Definition: linear_algebra.h:122
void setExtSpaceField(Settings &s)
Nodes::index idx_dir
Definition: linear_algebra.h:113
void base_projection() const
Definition: linear_algebra.cpp:3
double v_max
Definition: linear_algebra.h:125
void prepareElements(const Eigen::Vector3d &Hext, const timing &t_prm) const
Definition: linear_algebra.cpp:26
void set_DW_vz(const double vz)
Definition: linear_algebra.h:97
void buildInitGuess(std::vector< double > &G) const
Definition: linear_algebra.cpp:13
std::vector< int > lvd
Definition: linear_algebra.h:131
std::vector< double > Xw
Definition: linear_algebra.h:116
const std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > & extSpaceField
Definition: linear_algebra.h:128
bool solve(const timing &t_prm)
Definition: solver.cpp:6
void checkBoundaryConditions(void) const override
Definition: linear_algebra.h:67
double get_v_max(void) const
Definition: linear_algebra.h:101
const int verbose
Definition: linear_algebra.h:119
Definition: mesh.h:34
std::vector< bool > magNode
Definition: mesh.h:363
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: settings.h:70
template class for the different solvers template parameter DIM_PROBLEM: dimensionnality of the probl...
Definition: solver.h:22
Mesh::mesh * msh
Definition: solver.h:49
const int NOD
Definition: solver.h:52
Definition: time_integration.h:7
const int DIM_PB_MAG
Definition: linear_algebra.h:24
index
Definition: node.h:33
header to define struct Node
many settings to give some parameters to the solver, boundary conditions for the problem,...
two templates to fill matrix and vectors in various dimensionnality situations. DIM_PROBLEM = 1 is us...
namespace Tetra header containing Tet class, some constants, and integrales