Feellgood
linear_algebra.h
Go to the documentation of this file.
1 #ifndef linear_algebra_h
2 #define linear_algebra_h
3 
9 #include <random>
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
12 #include <execution>
13 #pragma GCC diagnostic pop
14 
15 #include "config.h"
16 
17 #include "facette.h"
18 #include "feellgoodSettings.h"
19 #include "mesh.h"
20 #include "node.h"
21 #include "tetra.h"
22 
23 #include "algebra/algebra.h"
24 
34  {
35 public:
40  : NOD(my_msh.getNbNodes()), refMsh(&my_msh), iter("bicg",s.TOL,s.verbose,s.MAXITER),
42  prmTetra(s.paramTetra), prmFacette(s.paramFacette)
43  {
44  L_rhs.resize(2*NOD);
45  Xw.resize(2*NOD);
47  if (!s.recenter)
48  { idx_dir = Nodes::IDX_UNDEF; }
49  else
51 
52  if(s.getFieldType() == R4toR3)
53  { setExtSpaceField(s); }
54  }
55 
58  {
59  algebra::MatrixShape shape(2 * NOD);
60  auto insert_pair = [this, &shape](int i, int j)
61  {
62  shape[2*i].insert(2*j);
63  shape[2*i].insert(2*j+1);
64  shape[2*i+1].insert(2*j);
65  shape[2*i+1].insert(2*j+1);
66  };
67  for (int i = 0; i < NOD; ++i)
68  { insert_pair(i, i); }
69  for (auto edge: refMsh->edges)
70  {
71  insert_pair(edge.first, edge.second);
72  insert_pair(edge.second, edge.first);
73  }
74  return shape;
75  }
76 
80  void prepareElements(Eigen::Vector3d const &Hext , timing const &t_prm );
81 
85  void prepareElements(double const A_Hext , timing const &t_prm );
86 
88  void buildInitGuess(std::vector<double> &G) const;
89 
92  int solver(timing const &t_prm );
93 
95  inline void set_DW_vz(double vz ) { DW_vz = vz; }
96 
98  inline double get_v_max(void) { return v_max; }
99 
101  void setExtSpaceField(Settings &s );
102 
104  void base_projection();
105 private:
108 
110  const int NOD;
111 
114 
117 
120 
122  std::vector<double> L_rhs;
123 
125  std::vector<double> Xw;
126 
128  const int verbose;
129 
131  const std::vector<Tetra::prm> &prmTetra;
132 
134  const std::vector<Facette::prm> &prmFacette;
135 
137  double DW_vz;
138 
140  double v_max;
141 
143  std::vector< Eigen::Matrix<double,Nodes::DIM,Tetra::NPI> > extSpaceField;
144  };// end class linAlgebra
145 #endif
set of class to handle sparse matrix operations for gradient conjugate algorithms a sparse vector cla...
Definition: linear_algebra.h:34
LinAlgebra(Settings &s, Mesh::mesh &my_msh)
Definition: linear_algebra.h:39
double DW_vz
Definition: linear_algebra.h:137
const int NOD
Definition: linear_algebra.h:110
double get_v_max(void)
Definition: linear_algebra.h:98
void setExtSpaceField(Settings &s)
Definition: linear_algebra.cpp:73
Nodes::index idx_dir
Definition: linear_algebra.h:107
double v_max
Definition: linear_algebra.h:140
algebra::iteration< double > iter
Definition: linear_algebra.h:116
void prepareElements(Eigen::Vector3d const &Hext, timing const &t_prm)
Definition: linear_algebra.cpp:22
algebra::MatrixShape build_shape()
Definition: linear_algebra.h:57
void set_DW_vz(double vz)
Definition: linear_algebra.h:95
int solver(timing const &t_prm)
Definition: solver.cpp:6
const std::vector< Tetra::prm > & prmTetra
Definition: linear_algebra.h:131
Mesh::mesh * refMsh
Definition: linear_algebra.h:113
void buildInitGuess(std::vector< double > &G) const
Definition: linear_algebra.cpp:13
std::vector< double > Xw
Definition: linear_algebra.h:125
algebra::r_sparseMat K
Definition: linear_algebra.h:119
const std::vector< Facette::prm > & prmFacette
Definition: linear_algebra.h:134
void base_projection()
Definition: linear_algebra.cpp:3
std::vector< double > L_rhs
Definition: linear_algebra.h:122
std::vector< Eigen::Matrix< double, Nodes::DIM, Tetra::NPI > > extSpaceField
Definition: linear_algebra.h:143
const int verbose
Definition: linear_algebra.h:128
Definition: mesh.h:28
std::vector< std::pair< int, int > > edges
Definition: mesh.h:229
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: feellgoodSettings.h:63
Nodes::index recentering_direction
Definition: feellgoodSettings.h:137
field_exprType getFieldType(void) const
Definition: feellgoodSettings.h:278
bool recenter
Definition: feellgoodSettings.h:134
Read-mode square sparse matrix.
Definition: sparseMat.h:87
Definition: time_integration.h:6
contains namespace Facette header containing Fac class, and some constants and a less_than operator t...
many settings to give some parameters to the solver, boundary conditions for the problem,...
@ R4toR3
Definition: feellgoodSettings.h:36
class mesh, readMesh is expecting a mesh file in gmsh format either text or binary,...
index
Definition: node.h:34
std::vector< std::set< int > > MatrixShape
Definition: sparseMat.h:41
header to define struct Node
namespace Tetra header containing Tet class, some constants, and integrales