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  absorb(s.absorb)
48  {
49  Xw.resize(2 * NOD);
51  if (!s.recenter)
52  { idx_dir = Nodes::IDX_UNDEF; }
53  else
54  { idx_dir = s.recentering_direction; }
55 
56  for (int i = 0; i < NOD; i++)
57  {
58  if(!my_msh.magNode[i])
59  {
60  lvd.push_back(2 * i );
61  lvd.push_back(2 * i + 1);
62  }
63  }
64  lvd.shrink_to_fit();
65  }
66 
68  void checkBoundaryConditions(void) const override {}
69 
76  void prepareElements(const Eigen::Vector3d &Hext ,
77  const timing &t_prm ) const;
78 
85  void prepareElements(const double A_Hext ,
87  const timing &t_prm ) const;
88 
90  void buildInitGuess(std::vector<double> &G) const;
91 
95  bool solve(const timing &t_prm );
96 
98  inline void set_DW_vz(const double vz )
99  { DW_vz = vz; }
100 
102  inline double get_v_max(void) const
103  { return v_max; }
104 
106  void base_projection() const;
107 
108 private:
111 
113  std::vector<double> Xw;
114 
116  const int verbose;
117 
119  double DW_vz;
120 
122  double v_max;
123 
125  const std::vector< Eigen::Matrix<double,Nodes::DIM,Tetra::NPI> >& extSpaceField;
126 
128  std::vector<int> lvd;
129 
132  };// end class linAlgebra
133 #endif
Definition: linear_algebra.h:35
LinAlgebra(Settings &s, Mesh::mesh &my_msh)
Definition: linear_algebra.h:40
const AbsorbingEnds & absorb
Definition: linear_algebra.h:131
double DW_vz
Definition: linear_algebra.h:119
Nodes::index idx_dir
Definition: linear_algebra.h:110
void base_projection() const
Definition: linear_algebra.cpp:3
double v_max
Definition: linear_algebra.h:122
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:98
void buildInitGuess(std::vector< double > &G) const
Definition: linear_algebra.cpp:13
std::vector< int > lvd
Definition: linear_algebra.h:128
std::vector< double > Xw
Definition: linear_algebra.h:113
const std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > & extSpaceField
Definition: linear_algebra.h:125
bool solve(const timing &t_prm)
Definition: solver.cpp:6
void checkBoundaryConditions(void) const override
Definition: linear_algebra.h:68
double get_v_max(void) const
Definition: linear_algebra.h:102
const int verbose
Definition: linear_algebra.h:116
Definition: mesh.h:34
std::vector< bool > magNode
Definition: mesh.h:365
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: settings.h:72
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:13
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...
Definition: absorbing_ends.h:26
namespace Tetra header containing Tet class, some constants, and integrales