Feellgood
feellgoodSettings.h
Go to the documentation of this file.
1 #ifndef feellgoodSettings_h
2 #define feellgoodSettings_h
3 
9 #include <cmath>
10 #include <iostream>
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 #include <yaml-cpp/yaml.h>
16 
17 #include "expression_parser.h"
18 #include "facette.h"
19 #include "spinTransferTorque.h"
20 #include "tetra.h"
21 #include "time_integration.h"
22 
33  {
34  UNDEF = -1,
35  RtoR3 = 1,
36  R4toR3 = 2
38  };
39 
62 class Settings
63  {
64 public:
71  Settings();
72 
74  static void dumpDefaults();
75 
77  void toYaml(void);
78 
80  std::string evolMetadata(std::string realWorldTime) const;
81 
83  std::string solMetadata(double t, std::string columnsTitle) const;
84 
86  void read(YAML::Node);
87 
89  bool read(std::string filename);
90 
92  inline int getPrecision(void) const { return precision; }
93 
95  inline std::string getFileDisplayName(void) const { return fileDisplayName; }
96 
98  inline void setFileDisplayName(std::string _s) { fileDisplayName = _s; }
99 
101  inline void setPbName(std::string str) { pbName = str; }
102 
104  inline std::string getPbName(void) const { return pbName; }
105 
107  inline void setSimName(std::string str) { simName = str; }
108 
110  inline std::string getSimName(void) const { return simName; }
111 
113  inline void setScale(const double s) { _scale = s; }
114 
116  inline double getScale(void) const { return _scale; }
117 
119  inline void set_MAXITER(int i) { MAXITER = i; }
120 
122  bool withTsv;
123 
125  int verbose;
126 
128  double time_step;
129 
132 
134  bool recenter;
135 
138 
140  double threshold;
141 
144 
147 
150 
152  bool stt_flag;
153 
155  std::string sMx;
156 
158  std::string sMy;
159 
161  std::string sMz;
162 
164  std::string sM;
165 
167  std::string sBx;
168 
170  std::string sBy;
171 
173  std::string sBz;
174 
176  std::string sB;
177 
179  std::string sB_space;
180 
182  std::string sB_time;
183 
185  std::string restoreFileName;
186 
188  double initial_time = NAN;
189 
191  double DUMAX; // 0.1 for magnetostatic simulations; 0.02 for the dynamics
192 
194  double TOL;
195 
197  int MAXITER;
198 
202  double ILU_tol;
203 
208 
210  std::vector<Tetra::prm> paramTetra;
211 
213  inline int findTetraRegionIdx(const std::string name ) const
214  {
215  std::vector<Tetra::prm>::const_iterator result =
216  std::find_if(paramTetra.begin(), paramTetra.end(),
217  [name](Tetra::prm const &p) { return (p.regName == name); });
218 
219  int idx(-2);
220  if (result == paramTetra.end())
221  {
222  idx = -1;
223  }
224  else
225  {
226  idx = std::distance(paramTetra.begin(), result);
227  }
228  return idx;
229  };
230 
232  std::vector<Facette::prm> paramFacette;
233 
235  std::string r_path_output_dir;
236 
238  std::vector<std::string> evol_columns;
239 
241  double tf;
242 
244  double dt_min;
245 
247  double dt_max;
248 
250  inline int findFacetteRegionIdx(const std::string name ) const
251  {
252  std::vector<Facette::prm>::const_iterator result =
253  std::find_if(paramFacette.begin(), paramFacette.end(),
254  [name](Facette::prm const &p) { return (p.regName == name); });
255  int idx(-2);
256 
257  if (result == paramFacette.end())
258  {
259  idx = -1;
260  }
261  else
262  {
263  idx = std::distance(paramFacette.begin(), result);
264  }
265  return idx;
266  };
267 
272  inline Eigen::Vector3d getMagnetization(const Eigen::Ref<Eigen::Vector3d> p) const
273  {
274  Eigen::Vector3d tmp = mag_parser.get_vector(p);
275  tmp.normalize();
276  return tmp;
277  }
278 
283  inline Eigen::Vector3d getField(const double t_val) const
284  {
285  return (field_parser.get_vector(t_val))/mu0;
286  }
287 
291  inline field_exprType getFieldType(void) const
292  { return field_type; }
293 
298  inline Eigen::Vector3d getFieldSpace(const Eigen::Ref<Eigen::Vector3d> p) const
299  { return field_space_parser.get_vector(p); }
300 
305  inline double getFieldTime(const double t_val) const
306  { return (field_time_parser.get_scalar(t_val))/mu0; }
307 
308 private:
309  int precision;
310  std::string fileDisplayName;
311  double _scale;
312  std::string simName;
313  std::string pbName;
321 
324 
325  // field(x,y,z,t) = field_time(t) * field_space(x,y,z) with field_time R -> R and field_space R³->R³
328 
331  };
332 
333 #endif /* feellgoodSettings_h */
Definition: expression_parser.h:20
double get_scalar(double arg) const
Definition: expression_parser.cpp:67
Eigen::Vector3d get_vector(double arg) const
Definition: expression_parser.cpp:103
Container for all the settings provided by the user, with conversions to/from YAML.
Definition: feellgoodSettings.h:63
int ILU_fill_factor
Definition: feellgoodSettings.h:207
std::string getFileDisplayName(void) const
Definition: feellgoodSettings.h:95
std::string pbName
Definition: feellgoodSettings.h:313
void setFileDisplayName(std::string _s)
Definition: feellgoodSettings.h:98
std::string sB_space
Definition: feellgoodSettings.h:179
int solverNbTh
Definition: feellgoodSettings.h:143
void toYaml(void)
Definition: feellgoodSettings.cpp:128
std::string r_path_output_dir
Definition: feellgoodSettings.h:235
double DUMAX
Definition: feellgoodSettings.h:191
void read(YAML::Node)
Definition: feellgoodSettings.cpp:274
int verbose
Definition: feellgoodSettings.h:125
int getPrecision(void) const
Definition: feellgoodSettings.h:92
std::string sB_time
Definition: feellgoodSettings.h:182
void setScale(const double s)
Definition: feellgoodSettings.h:113
void setSimName(std::string str)
Definition: feellgoodSettings.h:107
bool stt_flag
Definition: feellgoodSettings.h:152
Nodes::index recentering_direction
Definition: feellgoodSettings.h:137
std::string evolMetadata(std::string realWorldTime) const
Definition: feellgoodSettings.cpp:246
int MAXITER
Definition: feellgoodSettings.h:197
std::string sMz
Definition: feellgoodSettings.h:161
std::string solMetadata(double t, std::string columnsTitle) const
Definition: feellgoodSettings.cpp:266
field_exprType getFieldType(void) const
Definition: feellgoodSettings.h:291
ExpressionParser field_time_parser
Definition: feellgoodSettings.h:327
ExpressionParser field_parser
Definition: feellgoodSettings.h:323
std::vector< Facette::prm > paramFacette
Definition: feellgoodSettings.h:229
ExpressionParser field_space_parser
Definition: feellgoodSettings.h:330
double dt_max
Definition: feellgoodSettings.h:247
double initial_time
Definition: feellgoodSettings.h:188
ExpressionParser mag_parser
Definition: feellgoodSettings.h:314
std::string sM
Definition: feellgoodSettings.h:164
std::string sBz
Definition: feellgoodSettings.h:173
double getScale(void) const
Definition: feellgoodSettings.h:116
std::string simName
Definition: feellgoodSettings.h:312
double getFieldTime(const double t_val) const
Definition: feellgoodSettings.h:305
void setPbName(std::string str)
Definition: feellgoodSettings.h:101
std::string getPbName(void) const
Definition: feellgoodSettings.h:104
std::string sMy
Definition: feellgoodSettings.h:158
std::string sBx
Definition: feellgoodSettings.h:167
bool withTsv
Definition: feellgoodSettings.h:122
int precision
Definition: feellgoodSettings.h:309
Settings()
Definition: feellgoodSettings.cpp:116
std::string restoreFileName
Definition: feellgoodSettings.h:185
bool recenter
Definition: feellgoodSettings.h:134
Eigen::Vector3d getMagnetization(const Eigen::Ref< Eigen::Vector3d > p) const
Definition: feellgoodSettings.h:272
std::string getSimName(void) const
Definition: feellgoodSettings.h:110
double TOL
Definition: feellgoodSettings.h:194
STT p_stt
Definition: feellgoodSettings.h:149
Eigen::Vector3d getFieldSpace(const Eigen::Ref< Eigen::Vector3d > p) const
Definition: feellgoodSettings.h:298
double tf
Definition: feellgoodSettings.h:241
double threshold
Definition: feellgoodSettings.h:140
int findTetraRegionIdx(const std::string name) const
Definition: feellgoodSettings.h:213
void set_MAXITER(int i)
Definition: feellgoodSettings.h:119
std::vector< std::string > evol_columns
Definition: feellgoodSettings.h:238
static void dumpDefaults()
Definition: feellgoodSettings.cpp:126
Eigen::Vector3d getField(const double t_val) const
Definition: feellgoodSettings.h:283
double _scale
Definition: feellgoodSettings.h:311
std::string fileDisplayName
Definition: feellgoodSettings.h:310
std::string sB
Definition: feellgoodSettings.h:176
double dt_min
Definition: feellgoodSettings.h:244
int findFacetteRegionIdx(const std::string name) const
Definition: feellgoodSettings.h:250
std::string sMx
Definition: feellgoodSettings.h:155
std::vector< Tetra::prm > paramTetra
Definition: feellgoodSettings.h:210
double ILU_tol
Definition: feellgoodSettings.h:202
field_exprType field_type
Definition: feellgoodSettings.h:320
std::string sBy
Definition: feellgoodSettings.h:170
int save_period
Definition: feellgoodSettings.h:131
double time_step
Definition: feellgoodSettings.h:128
int scalfmmNbTh
Definition: feellgoodSettings.h:146
contains namespace Facette header containing Fac class, and some constants and a less_than operator t...
field_exprType
Definition: feellgoodSettings.h:33
@ RtoR3
B(t)
Definition: feellgoodSettings.h:35
@ UNDEF
undefined
Definition: feellgoodSettings.h:34
@ R4toR3
Definition: feellgoodSettings.h:36
index
Definition: node.h:34
Definition: facette.h:43
Definition: spinTransferTorque.h:13
Definition: tetra.h:64
namespace Tetra header containing Tet class, some constants, and integrales