KADATH
system_of_eqs.hpp
1 /*
2  Copyright 2017 Philippe Grandclement & Gregoire Martinon
3 
4  This file is part of Kadath.
5 
6  Kadath is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef __SYSTEM_OF_EQS_HPP_
21 #define __SYSTEM_OF_EQS_HPP_
22 
23 #include "headcpp.hpp"
24 #ifdef PAR_VERSION
25 #include "mpi.h"
26 #endif
27 #include <sstream>
28 #include "profiled_object.hpp"
29 #include "tensor.hpp"
30 #include "ope_eq.hpp"
31 #include "term_eq.hpp"
32 #include "metric.hpp"
33 #include "param.hpp"
34 #include "matrice.hpp"
35 #include "list_comp.hpp"
36 
37 #include <vector>
38 using std::vector;
39 
40 constexpr int VARMAX{1000};
41 
42 #define GMRES_SPARSE 0
43 #define BICGSTAB_SPARSE 1
44 
45 #define SAVED_DER 1
46 
47 namespace Kadath {
48 
49  class Equation ;
50  class Eq_int ;
51 
60  class System_of_eqs : public Profiled_object<System_of_eqs> {
61  public:
66  static std::size_t default_block_size;
68  static constexpr std::size_t nb_core_per_node{24};
70  static constexpr int ALL_COLUMNS {-1};
72  enum : bool { DO_NOT_TRANSPOSE = false, TRANSPOSE = true};
73  //enum Matrix_computation_parallel_paradigm: unsigned short {sequential, multi_thread, mpi, hybrid};
75  struct Output_data{
77  unsigned n_iter{};
79  int problem_size{};
81  double current_error{};
83  Duration t_load_matrix{};
85  Duration t_trans_matrix{};
87  Duration t_inv_matrix{};
89  Duration t_newton_update{};
90  };
92 
93  protected:
94  std::ostream * output_stream;
95  const Space& espace ;
96  int dom_min ;
97  int dom_max ;
98  int ndom ;
99 
100  int nvar_double ;
101  MMPtr_array<double> var_double ;
102  MMPtr_array<char> names_var_double ;
103 
104  int nvar ;
105  MMPtr_array<Tensor> var ;
106  MMPtr_array<char> names_var ;
107 
109  MMPtr_array<Term_eq> term_double ;
111 
112  int nterm ;
113  MMPtr_array<Term_eq> term ;
115 
116  int ncst ;
117  int nterm_cst ;
118  MMPtr_array<Term_eq> cst ;
119  MMPtr_array<char> names_cst ;
120 
121  mutable int ncst_hard ;
122  mutable MMPtr_array<Term_eq> cst_hard ;
124 
125  // Definitions (liste of operators I guess)
126  int ndef ;
127  MMPtr_array<Ope_def> def ;
128  MMPtr_array<char> names_def ;
129 
130  // Definitions globale (liste of operators I guess)
131  int ndef_glob ;
132  MMPtr_array<Ope_def_global> def_glob ;
133  MMPtr_array<char> names_def_glob ;
134 
135  // ser defined operators
136  int nopeuser ;
137  Term_eq (*opeuser[VARMAX]) (const Term_eq&, Param*) ;
138  MMPtr_array<Param> paruser ;
139  MMPtr_array<char> names_opeuser ;
140 
142  Term_eq (*opeuser_bin[VARMAX]) (const Term_eq&, const Term_eq&, Param*) ;
143  MMPtr_array<Param> paruser_bin ;
144  MMPtr_array<char> names_opeuser_bin ;
145 
146  // The metric (only one for now)
148  char* name_met ;
149 
150  int neq_int ;
151  MMPtr_array<Eq_int> eq_int ;
152 
153  int neq ;
154  MMPtr_array<Equation> eq ;
155 
156  MMPtr_array<Term_eq> results ;
157 
160 
161  MMPtr_array<Index> which_coef ;
162 
163  unsigned niter{0u};
167  int mpi_proc_rank{0};
169  void init_proc_data() {
170 #ifdef PAR_VERSION
171  MPI_Comm_rank(MPI_COMM_WORLD,&mpi_proc_rank);
172  MPI_Comm_size(MPI_COMM_WORLD,&mpi_world_size);
173 #endif
174  }
175 
176  public:
181  explicit System_of_eqs (const Space& so) ;
188  System_of_eqs (const Space& so, int i, int j) ;
194  System_of_eqs (const Space& so, int i) : System_of_eqs{so,i,i} {}
195  System_of_eqs (const System_of_eqs&) = delete ;
196  ~System_of_eqs() override ;
197 
198  const Metric* get_met() const ;
199 
200  // Accessors
204  std::ostream & get_output_stream() const {return *output_stream;}
208  void set_output_stream(std::ostream & new_output_stream) {output_stream = &new_output_stream;}
212  const Space& get_space() const {return espace ;} ;
216  int get_dom_min() const {return dom_min ;} ;
220  int get_dom_max() const {return dom_max ;} ;
224  int get_nbr_conditions() const {return nbr_conditions ;} ;
228  int get_nbr_unknowns() const {return nbr_unknowns ;} ;
232  unsigned get_niter() const {return niter;}
233 
234  int get_mpi_proc_rank() const {return mpi_proc_rank;}
235  int get_mpi_world_size() const {return mpi_world_size;}
236 
242  Term_eq* give_term_double (int which, int dd) const ;
248  Term_eq* give_term (int which, int dd) const ;
254  Term_eq* give_cst (int which, int dd) const ;
260  Term_eq* give_cst_hard (double xx, int dd) const ;
265  Ope_def* give_def (int i) const ;
270  Ope_def_global* give_def_glob (int i) const ;
271 
276  Tensor give_val_def (const char* name) const ;
277 
278 
284  virtual void add_var (const char* name, double& var) ;
290  virtual void add_var (const char* name, Tensor& var) ;
296  virtual void add_cst (const char* name, double cst) ;
302  virtual void add_cst (const char* name, const Tensor& cst) ;
303 
308  virtual void add_def (const char* name) ;
314  virtual void add_def (int dd, const char* name) ;
319  virtual void add_def_global (const char* name) ;
325  virtual void add_def_global (int dd, const char* name) ;
332  virtual void add_ope (const char* name, Term_eq (*pope) (const Term_eq&, Param*), Param* par) ;
339  virtual void add_ope (const char* name, Term_eq (*pope) (const Term_eq&, const Term_eq&, Param*), Param* par) ;
340 
346  bool isvar_double (const char* target, int& which) const ;
355  bool isvar (const char* target, int& which, int& valence, char*& name_ind, Array<int>*& type_ind) const ;
364  bool iscst (const char* target, int& which, int& valence, char*& name_ind, Array<int>*& type_ind) const ;
374  bool isdef (int dd, const char* target, int& which, int& valence, char*& name_ind, Array<int>*& type_ind) const ;
381  bool isdef_glob (int dd, const char* target, int& which) const ;
382 
383 
389  bool is_ope_minus (const char* input, char* output) const ;
395  bool isdouble (const char* input, double& output) const ;
402  bool ismet (const char* input, char*& name_ind, int& type_ind) const ;
407  bool ismet (const char* input) const ;
415  bool ischristo (const char* input, char*& name_ind, Array<int>*& type_ind) const ;
423  bool isriemann (const char* input, char*& name_ind, Array<int>*&type_ind) const ;
431  bool isricci_tensor (const char* input, char*& name_ind, Array<int>*& type_ind) const ;
439  bool isricci_scalar (const char* input, char*& name_ind, Array<int>*& type_ind) const ;
447  bool is_ope_bin (const char* input, char* p1, char* p2, char symb) const ;
454  bool is_ope_uni (const char* input, char* p1, const char* nameope) const ;
462  bool is_ope_uni (const char* input, char* p1, char* p2, const char* nameope) const ;
470  bool is_ope_deriv (const char* input, char* p1, int& typeder, char& nameind) const ;
478  bool is_ope_deriv_flat (const char* input, char* p1, int& typeder, char& nameind) const ;
486  bool is_ope_deriv_background (const char* input, char* p1, int& typeder, char& nameind) const ;
493  bool is_ope_pow (const char* input, char* p1, int& expo) const ;
500  bool is_ope_partial (const char* input, char* p1, char& nameind) const ;
508  bool is_ope_der_var (int dd, const char* input, char* p1, int& which) const ;
509 
517  Ope_eq* give_ope (int dom, const char* name, int bb=0) const ;
518 
526  virtual void add_eq_inside (int dom, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
527 
535  virtual void add_eq_inside (int dom, const char* eq, const List_comp& list) ;
536 
545  virtual void add_eq_order (int dom, int order, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
546 
554  virtual void add_eq_order (int dom, int order, const char* eq, const List_comp& list) ;
555 
564  virtual void add_eq_bc (int dom, int bb, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
565 
573  virtual void add_eq_bc (int dom, int bb, const char* eq, const List_comp& list) ;
574 
583  virtual void add_eq_matching (int dom, int bb, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
584 
592  virtual void add_eq_matching (int dom, int bb, const char* eq, const List_comp& list) ;
593 
602  virtual void add_eq_matching_one_side (int dom, int bb, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
603 
611  virtual void add_eq_matching_one_side (int dom, int bb, const char* eq, const List_comp& list) ;
612 
624  virtual void add_eq_matching_non_std (int dom, int bb, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
625 
636  virtual void add_eq_matching_non_std (int dom, int bb, const char* eq, const List_comp& list) ;
637 
649  virtual void add_eq_matching_import (int dom, int bb, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
650 
661  virtual void add_eq_matching_import (int dom, int bb, const char* eq, const List_comp& list) ;
662 
670  virtual void add_eq_full (int dom, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
671 
678  virtual void add_eq_full (int dom, const char* eq, const List_comp& list) ;
679 
687  virtual void add_eq_one_side (int dom, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
688 
695  virtual void add_eq_one_side (int dom, const char* eq, const List_comp& list) ;
696 
707  virtual void add_eq_matching_exception (int dom, int bb, const char* eq, const Param& par, const char* eq_exception, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
708 
718  virtual void add_eq_matching_exception (int dom, int bb, const char* eq, const Param& par, const char* eq_exception, const List_comp& list) ;
719 
729  virtual void add_eq_order (int dom, const Array<int>& orders, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
730 
739  virtual void add_eq_order (int dom, const Array<int>& orders, const char* eq, const List_comp& list) ;
740 
748  virtual void add_eq_vel_pot (int dom, int order, const char* eq, const char* const_part) ;
749 
757  void add_eq_bc_exception (int dom, int bound, const char* eq, const char* const_part) ;
758 
769  virtual void add_eq_bc (int dom, int bb, const Array<int>& orders, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
770 
780  virtual void add_eq_bc (int dom, int bb, const Array<int>& orders, const char* eq, const List_comp& list) ;
781 
782 
793  virtual void add_eq_matching (int dom, int bb, const Array<int>& orders, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
794 
804  virtual void add_eq_matching (int dom, int bb, const Array<int>& orders, const char* eq, const List_comp& list) ;
805 
806  // virtual void add_eq_first_integral (int dom, const char* eq, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
807 
815  virtual void add_eq_first_integral (int dom_min, int dom_max, const char* integ_part, const char* const_part) ;
816 
825  virtual void add_eq_mode (int dom, int bb, const char* eq, const Index& pos_cf, double val) ;
833  virtual void add_eq_val_mode (int dom, const char* eq, const Index& pos_cf, double val) ;
840  virtual void add_eq_val (int dom, const char* eq, const Index& pos) ;
847  virtual void add_eq_point (int dom, const char* eq, const Point& MM) ;
848 
849  // Various computational stuff :
859  void vars_to_terms() ;
860 
862  virtual void vars_to_terms_impl();
864  virtual void compute_nbr_of_conditions();
874  void xx_to_ders(const Array<double>& vder) ;
880  void xx_to_vars(const Array<double>& val, int& conte) ;
886  Array<double> do_JX (const Array<double>& xx) ;
892  Array<double> do_col_J (int i) ;
893 
904  virtual void compute_matrix_cyclic(Array<double> &matrix, int n, int first_col= 0, int n_col= ALL_COLUMNS, int num_proc = 1,
905  bool transpose = DO_NOT_TRANSPOSE);
906 
907 
909  virtual void compute_matrix_adjacent(Array<double> &matrix, int n, int first_col= 0, int n_col= ALL_COLUMNS, int num_proc = 1,
910  bool transpose = DO_NOT_TRANSPOSE, std::vector<std::vector<std::size_t>> *dm = nullptr);
911 
919  template<Computational_model computational_model = default_computational_model>
920  bool do_newton(double prec, double &error);
921 
927  void newton_update_vars(Array<double> const & xx);
928 
933  void update_terms_from_variable_domains(const Array<int>& zedoms) ;
934 
944  template<Computational_model computational_model = default_computational_model>
945  bool do_newton_with_linesearch (double precision, double& error, int ntrymax = 10, double stepmax = 1.0);
946 
947 
948  // Parts for implementing gmres
950  void do_arnoldi (int n, Array<double>& qi, Matrice& Hmat) ;
952  void update_gmres (const Array<double>&) ;
953 
954  private:
959  template<Computational_model computational_model = default_computational_model>
965  template<Computational_model computational_model = default_computational_model>
966  void check_bsize(int bsize);
971  template<Computational_model computational_model = default_computational_model>
972  void compute_matloc(Array<double>& matloc_in, int nn, int bsize);
977  template<Computational_model computational_model = default_computational_model>
978  void translate_second_member(Array<double>& secloc, Array<double> const& second, int nn, int bsize, int nprow, int myrow, int mycol);
983  template<Computational_model computational_model = default_computational_model>
984  void get_global_solution(Array<double>& auxi, Array<double> const& secloc, int nn, int bsize, int nprow, int myrow, int mycol);
989  template<Computational_model computational_model = default_computational_model>
990  void update_fields(double lambda, vector<double> const& old_var_double, vector<Tensor> const& old_var_fields, vector<double> const& p_var_double, vector<Tensor> const& p_var_fields);
995  template<Computational_model computational_model = default_computational_model>
996  void compute_old_and_var(Array<double> const& xx, vector<double>& old_var_double, vector<Tensor>& old_var_fields, vector<double>& p_var_double, vector<Tensor>& p_var_fields);
1001  template<Computational_model computational_model = default_computational_model>
1002  double compute_f(Array<double> const& second);
1007  template<Computational_model computational_model = default_computational_model>
1008  void compute_p(Array<double>& xx, Array<double> const& second, int nn);
1013  template<Computational_model computational_model = default_computational_model>
1014  void check_positive(double delta);
1019  template<Computational_model computational_model = default_computational_model>
1020  void check_negative(double delta);
1021 
1022  friend class Space_spheric ;
1023  friend class Space_bispheric ;
1024  friend class Space_critic ;
1025  friend class Space_polar ;
1026  friend class Space_spheric_adapted ;
1027  friend class Space_polar_adapted ;
1028  friend class Space_bin_ns ;
1029  friend class Space_bin_bh ;
1030  friend class Space_bin_fake ;
1031  friend class Space_polar_periodic ;
1032  friend class Space_adapted_bh ;
1033  friend class Space_bbh ;
1034  friend class Metric ;
1035  friend class Metric_general ;
1036  friend class Metric_flat ;
1037  friend class Metric_dirac ;
1038  friend class Metric_dirac_const ;
1039  friend class Metric_conf ;
1040  friend class Metric_relax ;
1041  friend class Metric_ADS ;
1042  friend class Metric_AADS ;
1043  friend class Metric_const ;
1044  friend class Metric_flat_nophi ;
1045  friend class Metric_nophi ;
1046  friend class Metric_nophi_AADS ;
1047  friend class Metric_nophi_const ;
1048  friend class Metric_nophi_AADS_const ;
1049  friend class Metric_conf_factor ;
1050  friend class Metric_conf_factor_const ;
1051  friend class Metric_cfc ;
1052 
1053  };
1054 
1059  class Equation : public Memory_mapped {
1060  protected:
1061  const Domain* dom ;
1062  int ndom ;
1063  int n_ope ;
1064  MMPtr_array<Ope_eq> parts ;
1065 
1070  bool called ;
1071  int n_comp ;
1072  int n_cond_tot ;
1074 
1075  int n_cmp_used ;
1077 
1086  Equation (const Domain *dom, int nd, int nope, int n_cmp=-1, Array<int>** p_cmp=nullptr) ;
1087 
1088 
1089  public:
1090  virtual ~Equation() ;
1091 
1095  int get_n_cond_tot() const {return n_cond_tot;} ;
1096 
1102  virtual void apply(int& conte, Term_eq** res) ;
1111  virtual void export_val(int& conte, Term_eq** residuals, Array<double>& sec, int& pos_sec) const = 0 ;
1120  virtual void export_der(int& conte, Term_eq** residuals, Array<double>& sec, int& pos_sec) const = 0 ;
1125  virtual Array<int> do_nbr_conditions (const Tensor& tt) const = 0 ;
1130  virtual bool take_into_account (int target) const = 0 ;
1131 
1132  friend class System_of_eqs ;
1133  } ;
1134 
1141  class Eq_inside : public Equation {
1142 
1143  public:
1152  Eq_inside(const Domain* dom, int nd, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1153  virtual ~Eq_inside() ;
1154 
1155  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1156  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1157  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1158  bool take_into_account (int) const override;
1159  } ;
1160 
1167  class Eq_vel_pot : public Equation {
1168 
1169  public:
1170  int order ;
1171 
1180  Eq_vel_pot(const Domain* dom, int nd, int ord, Ope_eq* ope, Ope_eq* ope_constant) ;
1181  virtual ~Eq_vel_pot() ;
1182 
1183  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1184  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1185  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1186  bool take_into_account (int) const override;
1187  } ;
1188 
1194  class Eq_bc_exception : public Equation {
1195 
1196  public:
1197  int bound ;
1198 
1207  Eq_bc_exception (const Domain* dom, int nd, int bound, Ope_eq* ope, Ope_eq* ope_constant) ;
1208  virtual ~Eq_bc_exception() ;
1209 
1210  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1211  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1212  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1213  bool take_into_account (int) const override;
1214  } ;
1215 
1220  class Eq_order : public Equation {
1221 
1222  public:
1223  int order ;
1224 
1235  Eq_order(const Domain* dom, int nd, int ord, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1236  virtual ~Eq_order() ;
1237 
1238  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1239  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1240  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1241  bool take_into_account (int) const override;
1242  } ;
1243 
1248  class Eq_bc : public Equation {
1249 
1250  public:
1251  int bound ;
1261  Eq_bc(const Domain* dom, int nd, int bb, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1262  virtual ~Eq_bc() ;
1263 
1264  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1265  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1266  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1267  bool take_into_account (int) const override;
1268  } ;
1269 
1274  class Eq_matching : public Equation {
1275 
1276  public:
1277  int bound ;
1278  int other_dom ;
1280 
1294  Eq_matching(const Domain* dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq* ope, Ope_eq* oz_ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1295  virtual ~Eq_matching() ;
1296 
1297  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1298  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1299  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1300  bool take_into_account (int) const override;
1301  } ;
1302 
1309 
1310  public:
1311  int bound ;
1312  int other_dom ;
1314 
1327  Eq_matching_one_side(const Domain* dom, int nd , int bb, int oz_nd, int oz_bb, Ope_eq* ope, Ope_eq* oz_ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1328  virtual ~Eq_matching_one_side() ;
1329 
1330  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1331  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1332  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1333  bool take_into_account (int) const override;
1334  } ;
1335 
1344 
1345  public :
1346  int bound ;
1349 
1351 
1361  Eq_matching_non_std (const Domain* dom, int nd, int bb, const Array<int>& ozers, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1362  virtual ~Eq_matching_non_std() ;
1363 
1364  void apply(int&, Term_eq**) override;
1365  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1366  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1367 
1373  void do_which_points (const Base_spectral& base, int start) ;
1374  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1375  bool take_into_account (int) const override;
1376 
1377  friend class System_of_eqs ;
1378  } ;
1379 
1387  class Eq_matching_import : public Equation {
1388 
1389  public:
1390  int bound ;
1393 
1394 
1405  Eq_matching_import (const Domain* dom, int nd, int bb, Ope_eq* eq, const Array<int>& ozers, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1406  virtual ~Eq_matching_import() ;
1407 
1408  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1409  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1410  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1411  bool take_into_account (int) const override;
1412  } ;
1413 
1418  class Eq_int {
1419 
1420  protected:
1421  int n_ope ;
1423 
1424  public:
1429  Eq_int (int nop) ;
1430 
1431  public:
1432  ~Eq_int() ;
1433 
1434  double get_val() const ;
1435  double get_der() const ;
1441  void set_part (int i, Ope_eq* ope) ;
1442 
1443  friend class System_of_eqs ;
1444  } ;
1445 
1451  class Eq_full : public Equation {
1452 
1453  public:
1462  Eq_full(const Domain* dom, int nd, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1463  virtual ~Eq_full() ;
1464 
1465  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1466  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1467  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1468  bool take_into_account (int) const override;
1469  } ;
1470 
1475  class Eq_one_side : public Equation {
1476 
1477  public:
1486  Eq_one_side(const Domain* dom, int nd, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1487  virtual ~Eq_one_side() ;
1488 
1489  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1490  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1491  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1492  bool take_into_account (int) const override;
1493  } ;
1494 
1499  class Eq_order_array : public Equation {
1500 
1501  public:
1502  const Array<int>& order ;
1503 
1513  Eq_order_array(const Domain* dom, int nd, const Array<int>& ord, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1514  virtual ~Eq_order_array() ;
1515 
1516  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1517  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1518  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1519  bool take_into_account (int) const override;
1520  } ;
1521 
1527  class Eq_bc_order_array : public Equation {
1528 
1529  public:
1530  int bound ;
1532 
1543  Eq_bc_order_array(const Domain* dom, int nd, int bb, const Array<int>& ord, Ope_eq* ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1544  virtual ~Eq_bc_order_array() ;
1545 
1546  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1547  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1548  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1549  bool take_into_account (int) const override;
1550  } ;
1551 
1558 
1559  public:
1560  int bound ;
1561  int other_dom ;
1563  const Array<int>& order ;
1564 
1578  Eq_matching_order_array(const Domain* dom, int nd, int bb, int oz_nd, int oz_bb, const Array<int>& ord, Ope_eq* ope, Ope_eq* oz_ope, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1579  virtual ~Eq_matching_order_array() ;
1580 
1581  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1582  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1583  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1584  bool take_into_account (int) const override;
1585  } ;
1586 
1592 
1593  public:
1594  int bound ;
1597  const Param& parameters ;
1598 
1613  Eq_matching_exception(const Domain* dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq* ope, Ope_eq* oz_ope, const Param& par, Ope_eq* ope_exc, int n_cmp = -1, Array<int>** p_cmp=nullptr) ;
1614  virtual ~Eq_matching_exception() ;
1615 
1616  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1617  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1618  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1619  bool take_into_account (int) const override;
1620  } ;
1621 
1626  class Eq_first_integral : public Equation {
1627 
1628  public:
1629 
1630  int dom_min ;
1631  int dom_max ;
1632 
1642  Eq_first_integral(const System_of_eqs* syst, const Domain* dom, int dommin, int dommax, const char* integ_part, const char* const_part) ;
1643  virtual ~Eq_first_integral() ;
1644 
1645  void export_val(int&, Term_eq**, Array<double>&, int&) const override;
1646  void export_der(int&, Term_eq**, Array<double>&, int&) const override;
1647  Array<int> do_nbr_conditions (const Tensor& tt) const override;
1648  bool take_into_account (int) const override;
1649  } ;
1650 
1651 #ifdef PAR_VERSION
1652  extern "C" {
1653  void sl_init_ (int*, int*, int*);
1654  void blacs_gridexit_ (int*);
1655  void blacs_gridinfo_ (int*, int*, int*, int*, int*);
1656  int numroc_ (int*, int*, int*, int*, int*);
1657  void descinit_ (int*, int*, int*, int*, int* , int*, int*, int*, int*, int*);
1658  void pdgesv_ (int*, int*, double*, int*, int*, int*, int*, double*, int*, int*, int*, int*);
1659  int blacs_pnum_ (int*, int*, int*);
1660  void Cpdgemr2d (int, int, double*, int, int, int*, double*, int, int, int*, int);
1661  }
1662 #endif
1663 
1664  inline void split_two_d (int target, int& low, int& up) {
1665  int start = int(sqrt(target));
1666  low = start;
1667  up = start;
1668 
1669  bool endloop = (low*up==target) ? true : false;
1670 
1671  bool first = true;
1672  while (!endloop) {
1673  if (!first)
1674  low--;
1675  else
1676  first= false;
1677 
1678  up = int(target/low);
1679 
1680  if (low*up==target)
1681  endloop = true;
1682  }
1683 
1684  }
1685 
1686  template<>
1687  bool System_of_eqs::do_newton<Computational_model::sequential>(double prec, double &error);
1688  template<>
1689  bool System_of_eqs::do_newton<Computational_model::mpi_parallel>(double, double &);
1690  template<>
1691  bool System_of_eqs::do_newton<Computational_model::gpu_sequential>(double, double &);
1692  template<>
1693  bool System_of_eqs::do_newton<Computational_model::gpu_mpi_parallel>(double, double &);
1694  template<> bool System_of_eqs::do_newton_with_linesearch<Computational_model::mpi_parallel>(double , double &, int , double );
1695 
1696 // default : not implemented - the implemention is made through the specializations (see the seq_do_newton.cpp,
1697 // mpi_do_newton.cpp... files).
1698  template<Computational_model computational_model>
1699  bool System_of_eqs::do_newton(double, double &)
1700  {
1701  cerr << "Error: System_of_eq::do_newton is not implemented for the "
1702  << computational_model_name(computational_model)
1703  << " computational model." << endl;
1704  return true;
1705  }
1706 
1707  template<Computational_model computational_model>
1708  bool System_of_eqs::do_newton_with_linesearch(double precision, double &error, int ntrymax, double stepmax)
1709  {
1710  cerr << "Error: System_of_eq::do_newton is not implemented for the "
1711  << computational_model_name(computational_model)
1712  << " computational model." << endl;
1713  return true;
1714  }
1715 
1716  template<Computational_model computational_model>
1717  void check_size_VS_unknowns(int n)
1718  {
1719  cerr << "Error: System_of_eq::check_size_VS_unknowns is not implemented for the "
1720  << computational_model_name(computational_model)
1721  << " computational model." << endl;
1722  }
1723 
1724  template<Computational_model computational_model>
1725  void check_bsize(int bsize)
1726  {
1727  cerr << "Error: System_of_eq::check_bsize is not implemented for the "
1728  << computational_model_name(computational_model)
1729  << " computational model." << endl;
1730  }
1731 
1732  template<Computational_model computational_model>
1733  void compute_matloc(Array<double>& matloc_in, int nn, int bsize)
1734  {
1735  cerr << "Error: System_of_eq::compute_matloc is not implemented for the "
1736  << computational_model_name(computational_model)
1737  << " computational model." << endl;
1738  }
1739 
1740  template<Computational_model computational_model>
1741  void translate_second_member(Array<double>& secloc, Array<double> const& second, int nn, int bsize, int nprow, int myrow, int mycol)
1742  {
1743  cerr << "Error: System_of_eq::translate_second_member is not implemented for the "
1744  << computational_model_name(computational_model)
1745  << " computational model." << endl;
1746  }
1747 
1748  template<Computational_model computational_model>
1749  void get_global_solution(Array<double>& auxi, Array<double> const& secloc, int nn, int bsize, int nprow, int myrow, int mycol)
1750  {
1751  cerr << "Error: System_of_eq::get_global_solution is not implemented for the "
1752  << computational_model_name(computational_model)
1753  << " computational model." << endl;
1754  }
1755 
1756  template<Computational_model computational_model>
1757  void update_fields(double lambda, vector<double> const& old_var_double, vector<Tensor> const& old_var_fields, vector<double> const& p_var_double, vector<Tensor> const& p_var_fields)
1758  {
1759  cerr << "Error: System_of_eq::update_fields is not implemented for the "
1760  << computational_model_name(computational_model)
1761  << " computational model." << endl;
1762  }
1763 
1764  template<Computational_model computational_model>
1765  void compute_old_and_var(Array<double> const& xx, vector<double>& old_var_double, vector<Tensor>& old_var_fields, vector<double>& p_var_double, vector<Tensor>& p_var_fields)
1766  {
1767  cerr << "Error: System_of_eq::compute_old_and_var is not implemented for the "
1768  << computational_model_name(computational_model)
1769  << " computational model." << endl;
1770  }
1771 
1772  template<Computational_model computational_model>
1773  double compute_f(Array<double> const& second)
1774  {
1775  cerr << "Error: System_of_eq::compute_f is not implemented for the "
1776  << computational_model_name(computational_model)
1777  << " computational model." << endl;
1778  return double{};
1779  }
1780 
1781  template<Computational_model computational_model>
1782  void compute_p(Array<double>& xx, Array<double> const& second, int nn)
1783  {
1784  cerr << "Error: System_of_eq::compute_p is not implemented for the "
1785  << computational_model_name(computational_model)
1786  << " computational model." << endl;
1787  }
1788 
1789  template<Computational_model computational_model>
1790  void check_positive(double delta)
1791  {
1792  cerr << "Error: System_of_eq::check_positive is not implemented for the "
1793  << computational_model_name(computational_model)
1794  << " computational model." << endl;
1795  }
1796 
1797  template<Computational_model computational_model>
1798  void check_negative(double delta)
1799  {
1800  cerr << "Error: System_of_eq::check_negative is not implemented for the "
1801  << computational_model_name(computational_model)
1802  << " computational model." << endl;
1803  }
1804 }
1805 #endif
Class for storing the basis of decompositions of a field.
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
Class for enforcing boundary condition.
virtual ~Eq_bc_exception()
Destructor.
Eq_bc_exception(const Domain *dom, int nd, int bound, Ope_eq *ope, Ope_eq *ope_constant)
Constructor.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
int bound
Order of the equation.
Class for a boundary condition.
Eq_bc_order_array(const Domain *dom, int nd, int bb, const Array< int > &ord, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
virtual ~Eq_bc_order_array()
Destructor.
const Array< int > & order
Orders of the equation wrt each variable.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Class for an equation representing a boundary condition on some surface.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_bc.cpp:50
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_bc.cpp:46
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_bc.cpp:32
Eq_bc(const Domain *dom, int nd, int bb, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_bc.cpp:25
int bound
The boundary.
virtual ~Eq_bc()
Destructor.
Definition: eq_bc.cpp:29
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_bc.cpp:39
Equation for describing a first integral equation (i.e.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Eq_first_integral(const System_of_eqs *syst, const Domain *dom, int dommin, int dommax, const char *integ_part, const char *const_part)
Constructor.
int dom_min
Index of the first Domain.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
int dom_max
Index of the last Domain.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
virtual ~Eq_first_integral()
Destructor.
Class for a zeroth order equation in a Domain.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_full.cpp:51
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_full.cpp:47
virtual ~Eq_full()
Destructor.
Definition: eq_full.cpp:30
Eq_full(const Domain *dom, int nd, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_full.cpp:26
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_full.cpp:33
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_full.cpp:40
Class for bulk equations that are solved stricly inside a given domain.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_inside.cpp:40
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_inside.cpp:47
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_inside.cpp:51
virtual ~Eq_inside()
Destructor.
Definition: eq_inside.cpp:30
Eq_inside(const Domain *dom, int nd, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_inside.cpp:26
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_inside.cpp:33
Class implementing an integral equation.
Ope_eq ** parts
Array of pointers on the various terms.
double get_der() const
Return the variation of the equation.
Definition: eq_int.cpp:47
~Eq_int()
Destructor.
Definition: eq_int.cpp:32
int n_ope
Number of terms.
Eq_int(int nop)
Constructor just sets n_ope.
Definition: eq_int.cpp:26
void set_part(int i, Ope_eq *ope)
Sets one of the Ope_eq needed by the equation.
Definition: eq_int.cpp:54
double get_val() const
Return the value of the equation.
Definition: eq_int.cpp:39
Equation for a matching condition, except for one coefficient where an alternative condition is enfor...
virtual ~Eq_matching_exception()
Destructor.
Eq_matching_exception(const Domain *dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq *ope, Ope_eq *oz_ope, const Param &par, Ope_eq *ope_exc, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
const Param & parameters
Parameters needed for describing the exception.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
int other_dom
Number of the Domain on the other side of the boundary.
int other_bound
Name of the boundary as seen from the other domain.
Class for an equation representing the matching of quantities accross a boundary using the "import" r...
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Array< int > other_doms
Array containing the number of the domains being on the other side of the surface.
Array< int > other_bounds
Names of the boundary, as seen in the other domains.
Eq_matching_import(const Domain *dom, int nd, int bb, Ope_eq *eq, const Array< int > &ozers, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
int bound
Name of the boundary in the domain of the equation.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
virtual ~Eq_matching_import()
Destructor.
Class for an equation representing the matching of quantities accross a boundary.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
virtual ~Eq_matching_non_std()
Destructor.
Array< int > other_bounds
Names of the boundary, as seen in the other domains.
void do_which_points(const Base_spectral &base, int start)
Computes the collocation points used.
Array< int > other_doms
Array containing the number of the domains being on the other side of the surface.
int bound
Name of the boundary in the domain of the equation.
Eq_matching_non_std(const Domain *dom, int nd, int bb, const Array< int > &ozers, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
void apply(int &, Term_eq **) override
Computes the terms involved in computing the residual of the equations.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Index ** which_points
Lists the collocation points on the boundary (probably...)
Class for an equation representing the matching of quantities accross a boundary.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Eq_matching_one_side(const Domain *dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq *ope, Ope_eq *oz_ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
virtual ~Eq_matching_one_side()
Destructor.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
int other_dom
Number of the other domain.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
int other_bound
Name of the boundary in the other domain.
int bound
Name of the boundary in the domain of the equation.
Class for a matching condition.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
const Array< int > & order
Orders of the equation wrt each variable.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
int other_dom
Number of the Domain on the other side of the boundary.
int other_bound
Name of the boundary as seen from the other domain.
Eq_matching_order_array(const Domain *dom, int nd, int bb, int oz_nd, int oz_bb, const Array< int > &ord, Ope_eq *ope, Ope_eq *oz_ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Class for an equation representing the matching of quantities accross a boundary.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_matching.cpp:73
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_matching.cpp:35
int other_dom
Number of the other domain.
virtual ~Eq_matching()
Destructor.
Definition: eq_matching.cpp:32
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_matching.cpp:68
Eq_matching(const Domain *dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq *ope, Ope_eq *oz_ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_matching.cpp:25
int bound
Name of the boundary in the domain of the equation.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_matching.cpp:52
int other_bound
Name of the boundary in the other domain.
Class for a first order equation in a Domain.
virtual ~Eq_one_side()
Destructor.
Definition: eq_one_side.cpp:30
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_one_side.cpp:51
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_one_side.cpp:33
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_one_side.cpp:40
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_one_side.cpp:47
Eq_one_side(const Domain *dom, int nd, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_one_side.cpp:26
Class for an equation in a Domain which order is passed, for each variable.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Eq_order_array(const Domain *dom, int nd, const Array< int > &ord, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
virtual ~Eq_order_array()
Destructor.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
const Array< int > & order
Orders of the equation wrt each variable.
Class for bulk equation which order is passed as a parameter.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_order.cpp:52
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_order.cpp:41
int order
Order of the equation.
virtual ~Eq_order()
Destructor.
Definition: eq_order.cpp:31
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_order.cpp:34
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_order.cpp:48
Eq_order(const Domain *dom, int nd, int ord, Ope_eq *ope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: eq_order.cpp:26
Class for the velocity potential in irrotational binray neutron stars.
int order
Order of the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
Definition: eq_vel_pot.cpp:87
virtual ~Eq_vel_pot()
Destructor.
Definition: eq_vel_pot.cpp:31
Eq_vel_pot(const Domain *dom, int nd, int ord, Ope_eq *ope, Ope_eq *ope_constant)
Constructor.
Definition: eq_vel_pot.cpp:26
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_vel_pot.cpp:58
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_vel_pot.cpp:34
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_vel_pot.cpp:83
Class implementing an equation.
bool called
Indicator checking whther the result has been computed already once.
const Domain * dom
Pointer on the Domain where the equation is defined.
virtual Array< int > do_nbr_conditions(const Tensor &tt) const =0
Computes the number of conditions associated with the equation.
Array< int > ** p_cmp_used
Array of pointer on the indices of the used components.
virtual void apply(int &conte, Term_eq **res)
Computes the terms involved in computing the residual of the equations.
Definition: equation.cpp:49
virtual ~Equation()
Destructor.
Definition: equation.cpp:44
int ndom
Number of the domain.
int n_cmp_used
Number of components used (by default the same thing as n_comp).
int n_ope
Number of terms involved in the equation (one for bulk, two or more fot matching.....
virtual void export_val(int &conte, Term_eq **residuals, Array< double > &sec, int &pos_sec) const =0
Generates the discretized errors, from the various Term_eq computed by the equation.
int n_comp
Number of components of the residual (1 for a scalar, 6 for a symmetric rank-2 tensor etc).
Array< int > * n_cond
Number of discretized equations, component by component.
int get_n_cond_tot() const
virtual void export_der(int &conte, Term_eq **residuals, Array< double > &sec, int &pos_sec) const =0
Generates the discretized variations, from the various Term_eq computed by the equation.
virtual bool take_into_account(int target) const =0
Check whether the variation of the residual has to be taken into account when computing a given colum...
MMPtr_array< Ope_eq > parts
Array of pointers on the various terms.
Equation(const Domain *dom, int nd, int nope, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Definition: equation.cpp:38
int n_cond_tot
Total number of discretized equations (essentially the number of all coefficients of the residual).
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
Class for storing a list of tensorial components.
Definition: list_comp.hpp:33
Matrix handling.
Definition: matrice.hpp:38
Class to manage asymptotically anti de Sitter metrics.
Class to manage anti de Sitter metrics.
Definition: metric_AADS.hpp:45
Class to deal with a metric with a conformaly flat metric.
Definition: metric.hpp:632
Class to deal with a metric with a conformal decomposition (mainly used for AADS spacetimes) The true...
Definition: metric.hpp:562
Class to deal with a metric which determinant is 1.
Definition: metric.hpp:443
Class to deal with arbitrary type of metric but that is constant.
Definition: metric.hpp:416
Class to deal with a conformal metric in the Dirac gauge.
Definition: metric.hpp:510
Class to deal with a conformal metric in the Dirac gauge.
Definition: metric.hpp:485
Class that deals with flat metric assuming a axisymmetric setting (nothing depends on ).
Class that deals with flat metric.
Definition: metric.hpp:222
Class to deal with arbitrary type of metric.
Definition: metric.hpp:379
Class to deal with a metric independant of with a conformal decomposition and constant.
Class to deal with a metric independant of with a conformal decomposition (mainly used for AADS spac...
Class to deal with a metric independant of and constant.
Class to deal with a metric independant of .
Purely abstract class for metric handling.
Definition: metric.hpp:39
Operator for a global definition (i.e.
Definition: ope_eq.hpp:1340
The operator definition.
Definition: ope_eq.hpp:480
Abstract class that describes the various operators that can appear in the equations.
Definition: ope_eq.hpp:32
Parameter storage.
Definition: param.hpp:30
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
The Space_spheric_adapted class fills the space with one shell adapted on the inside,...
Definition: adapted_bh.hpp:36
Spacetime intended for binary black hole configurations in full general relativity (see constructor f...
Definition: bbh.hpp:33
Spacetime intended for binary black hole configurations (see constructor for details about the domain...
Definition: bin_bh.hpp:35
Spacetime intended for fake binary neutron star configurations (see constructor for details about the...
Definition: bin_fake.hpp:35
Spacetime intended for binary neutron stars configurations (see constructor for details about the dom...
Definition: bin_ns.hpp:35
The Space_bispheric class fills the space with bispherical coordinates (see the constructor for more ...
Definition: bispheric.hpp:1241
The Space_critic ; set the space with two critic domains, separated at .
Definition: critic.hpp:329
The Space_polar_adapted class fills the space with one polar nucleus, one polar shell adapted on the ...
The Space_polar_periodic class fills the space with one polar nucleus and several polar shells,...
The Space_polar class fills the space with one polar nucleus, several polar shells and a compactified...
Definition: polar.hpp:575
The Space_spheric_adapted class fills the space with one nucleus, one shell adapted on the outside,...
Definition: adapted.hpp:661
The Space_spheric class fills the space with one nucleus, several shells and a compactified domain,...
Definition: spheric.hpp:1350
The Space class is an ensemble of domains describing the whole space of the computation.
Definition: space.hpp:1362
Class used to describe and solve a system of equations.
MMPtr_array< Ope_def > def
Pointers on the definition (i.e. on the Ope_def that is needed to compute the result).
bool isvar(const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is an unknown field.
Definition: give_ope.cpp:39
bool do_newton_with_linesearch(double precision, double &error, int ntrymax=10, double stepmax=1.0)
Does one step of the Newton-Raphson iteration with a linesearch algorithm.
virtual void vars_to_terms_impl()
Sylvain's stuff.
MMPtr_array< Param > paruser
Parameters used by the user defined operators (single argument).
virtual void compute_matrix_adjacent(Array< double > &matrix, int n, int first_col=0, int n_col=ALL_COLUMNS, int num_proc=1, bool transpose=DO_NOT_TRANSPOSE, std::vector< std::vector< std::size_t >> *dm=nullptr)
Sylvain's stuff.
Array< double > sec_member()
Computes the second member of the Newton-Raphson equations.
Definition: solver.cpp:75
virtual void add_eq_inside(int dom, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation to be solved inside a domain (assumed to be second order).
Definition: add_eq.cpp:26
int nvar_double
Number of unknowns that are numbers (i.e. not fields)
MMPtr_array< Term_eq > results
Pointers on the residual of the various equations.
int nopeuser_bin
Number of operators defined by the user (with two arguments).
bool isvar_double(const char *target, int &which) const
Check if a string is an unknown (number).
Definition: give_ope.cpp:25
virtual void add_var(const char *name, double &var)
Addition of a variable (number case)
const Metric * get_met() const
Returns a pointer on the Metric.
int nterm
Number of Term_eq corresponding to the unknown fields.
Term_eq * give_term_double(int which, int dd) const
Returns a pointer on a Term_eq corresponding to an unknown number.
int get_mpi_world_size() const
Returns the total number of MPI processes.
virtual void add_eq_full(int dom, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation to be solved inside a domain (assumed to be zeroth order i....
Definition: add_eq.cpp:374
void init_proc_data()
Sylvain's stuff.
const Space & get_space() const
Returns the space.
Array< double > do_col_J(int i)
Computes one column of the Jacobian.
Definition: solver.cpp:127
virtual void add_eq_order(int dom, int order, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation to be solved inside a domain (of arbitrary order).
Definition: add_eq.cpp:56
bool is_ope_der_var(int dd, const char *input, char *p1, int &which) const
Checks if a string represents the derivative wrt a numerical coordinate of a given Domain (like "a,...
Definition: give_ope.cpp:539
~System_of_eqs() override
Destructor.
MMPtr_array< double > var_double
Pointer on the unknowns that are numbers (i.e. not fields)
bool isricci_tensor(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Ricci tensor.
Definition: give_ope.cpp:233
MMPtr_array< Ope_def_global > def_glob
Pointers on the global definitions.
Array< int > assoc_var
Array giving the correspondance with the var pointers.
virtual void add_def(const char *name)
Addition of a definition.
void check_positive(double delta)
Tests the positivity of &#160; Used by do_newton_with_linesearch ; only implemented in parallel version.
static constexpr int ALL_COLUMNS
Dummy variable for the purpose of better readability.
std::ostream * output_stream
Default output stream for log messages.
virtual void add_cst(const char *name, double cst)
Addition of a constant (number case)
MMPtr_array< char > names_def_glob
Names of the global definitions.
bool is_ope_minus(const char *input, char *output) const
Checks if a string contains the operator minus.
Definition: give_ope.cpp:293
void add_eq_bc_exception(int dom, int bound, const char *eq, const char *const_part)
Addition of an boundary equation with an exception for .
Definition: add_eq.cpp:123
MMPtr_array< char > names_var
Names of the unknown fields.
bool is_ope_uni(const char *input, char *p1, const char *nameope) const
Checks if a string represents an operator of the type "ope(a)".
Definition: give_ope.cpp:314
int mpi_proc_rank
Sylvain's stuff.
Term_eq * give_cst_hard(double xx, int dd) const
Returns a pointer on a Term_eq corresponding to a constant generated on the fly.
bool is_ope_deriv_background(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the covariant derivative wrt a background metric.
Definition: give_ope.cpp:455
virtual void add_eq_matching_import(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between domains using the ("import" setting) ...
Definition: add_eq.cpp:344
virtual void add_eq_mode(int dom, int bb, const char *eq, const Index &pos_cf, double val)
Addition of an equation prescribing the value of one coefficient of a scalar field,...
Definition: add_eq.cpp:438
virtual void add_eq_matching(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between two domains (standard setting)
Definition: add_eq.cpp:198
void compute_matloc(Array< double > &matloc_in, int nn, int bsize)
Computes the local part of the Jacobian Used by do_newton_with_linesearch ; only implemented in paral...
MMPtr_array< Term_eq > cst_hard
Pointers on the Term_eq coming from the constants generated on the fly (when encoutering things like ...
Term_eq * give_term(int which, int dd) const
Returns a pointer on a Term_eq corresponding to an unknown field.
Ope_def * give_def(int i) const
Returns a pointer on a definition (better to use give_val_def if one wants to access the result of so...
bool isdouble(const char *input, double &output) const
Checks if a string is a double.
Definition: give_ope.cpp:140
MMPtr_array< Term_eq > term_double
Pointers on the Term_eq corresponding to the unknowns that are numbers.
bool ischristo(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Christoffel symbols.
Definition: give_ope.cpp:185
int nbr_unknowns
Number of unknowns (basically the number of coefficients of all the unknown fields,...
MMPtr_array< char > names_opeuser_bin
Names of the user defined operators (with two arguments).
int ndom
Number of domains used.
int ndef_glob
Number of global definitions (the one that require the knowledge of the whole space to give the resul...
bool isriemann(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Riemann tensor.
Definition: give_ope.cpp:205
Tensor give_val_def(const char *name) const
Gives the result of a definition.
Ope_def_global * give_def_glob(int i) const
Returns a pointer on a global definition.
bool is_ope_pow(const char *input, char *p1, int &expo) const
Checks if a string represents the power of something (like "a^2").
Definition: give_ope.cpp:519
int neq_int
Number of integral equations (i.e. which are doubles)
int get_mpi_proc_rank() const
Returns the MPI rank.
void update_terms_from_variable_domains(const Array< int > &zedoms)
Updates the variations of the Term_eq that comes from the fact that some Domains are variable (i....
Definition: solver.cpp:236
bool iscst(const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is a constant (can required indices manipulation and/or inner contraction).
Definition: give_ope.cpp:63
MMPtr_array< char > names_opeuser
Names of the user defined operators (single argument).
virtual void add_eq_bc(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a boundary condition.
Definition: add_eq.cpp:168
bool is_ope_partial(const char *input, char *p1, char &nameind) const
Checks if a string represents the partial derivative (like "partial_i a")
Definition: give_ope.cpp:491
MMPtr_array< Equation > eq
Pointers onto the field equations.
bool is_ope_bin(const char *input, char *p1, char *p2, char symb) const
Checks if a string represents an operator of the type "a + b".
Definition: give_ope.cpp:276
virtual void add_eq_point(int dom, const char *eq, const Point &MM)
Addition of an equation saying that the value of a field must be zero at one point (arbitrary).
Definition: add_eq.cpp:473
bool ismet(const char *input, char *&name_ind, int &type_ind) const
Checks if a string is a metric.
Definition: give_ope.cpp:147
MMPtr_array< Index > which_coef
Stores the "true" coefficients on some boundaries (probably deprecated).
int nopeuser
Number of operators defined by the user (single argument).
MMPtr_array< Param > paruser_bin
Parameters used by the user defined operators (with two arguments).
MMPtr_array< Tensor > var
Pointer on the unknown fields.
virtual void compute_nbr_of_conditions()
Sylvain's stuff.
Definition: solver.cpp:51
bool do_newton(double prec, double &error)
Does one step of the Newton-Raphson iteration.
virtual void add_eq_matching_one_side(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between two domains (specialized function for...
Definition: add_eq.cpp:270
std::ostream & get_output_stream() const
Returns the default output stream reference.
Array< int > assoc_var_double
Array giving the correspondance with the var_double pointers.
bool isdef_glob(int dd, const char *target, int &which) const
Check if a string is a global definition.
Definition: give_ope.cpp:127
unsigned get_niter() const
Returns the current iteration number.
MMPtr_array< Term_eq > cst
Pointers on the Term_eq coming from the constants passed by the user.
void compute_p(Array< double > &xx, Array< double > const &second, int nn)
Inner routine for the linesearch algorithm Used by do_newton_with_linesearch ; only implemented in pa...
void xx_to_vars(const Array< double > &val, int &conte)
Sets the values the of the fields.
Array< double > check_equations()
Computes the residual of all the equations.
Definition: solver.cpp:26
void check_negative(double delta)
Tests the positivity of &#160; Used by do_newton_with_linesearch ; only implemented in parallel version.
Ope_eq * give_ope(int dom, const char *name, int bb=0) const
Function that reads a string and returns a pointer on the generated Ope_eq.
Definition: give_ope.cpp:559
void check_size_VS_unknowns(int n)
Tests the value of the number of unknowns.
void get_global_solution(Array< double > &auxi, Array< double > const &secloc, int nn, int bsize, int nprow, int myrow, int mycol)
Solves the linear problem in Newton-Raphson.
MMPtr_array< char > names_cst
Names of the constants passed by the user.
int get_nbr_unknowns() const
Returns the number of unknowns.
void compute_old_and_var(Array< double > const &xx, vector< double > &old_var_double, vector< Tensor > &old_var_fields, vector< double > &p_var_double, vector< Tensor > &p_var_fields)
Update the fields when some domains have been modified.
virtual void add_ope(const char *name, Term_eq(*pope)(const Term_eq &, Param *), Param *par)
Addition of a user defined operator (one argument version)
virtual void add_eq_val(int dom, const char *eq, const Index &pos)
Addition of an equation saying that the value of a field must be zero at one collocation point.
Definition: add_eq.cpp:462
bool isricci_scalar(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Ricci scalar.
Definition: give_ope.cpp:254
static std::size_t default_block_size
Defines the sub-matrix size in the scalapack 2D cyclic block decomposition.
void vars_to_terms()
Copies the various unknowns (doubles and Tensors) into their Term_eq counterparts.
unsigned niter
Counter toward the number of times the do_newton method has been called.
int ndef
Number of definitions.
virtual void add_eq_vel_pot(int dom, int order, const char *eq, const char *const_part)
Addition of an equation for the velocity potential of irrotational binaries.
Definition: add_eq.cpp:82
double compute_f(Array< double > const &second)
Inner routine for the linesearch algorithm Used by do_newton_with_linesearch ; only implemented in pa...
MMPtr_array< char > names_var_double
Names of the unknowns that are numbers (i.e. not fields)
int nterm_cst
Number of Term_eq coming from the constants passed by the user.
void do_arnoldi(int n, Array< double > &qi, Matrice &Hmat)
Performs the Arnoldi algorithm (under developpement)
virtual void add_def_global(const char *name)
Addition of a global definition.
virtual void add_eq_matching_exception(int dom, int bb, const char *eq, const Param &par, const char *eq_exception, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of a matching condition, except for one coefficient where an alternative condition is enforc...
Definition: add_eq.cpp:231
char * name_met
Name by which the metric is recognized.
int get_dom_max() const
Returns the highest index of the domains.
bool is_ope_deriv(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the covariant derivative.
Definition: give_ope.cpp:385
int nbr_conditions
Total number of conditions (the number of coefficients of all the equations, once regularities are ta...
MMPtr_array< Term_eq > term
Pointers on the Term_eq corresponding to the unknown fields.
System_of_eqs(const Space &so, int i)
Constructor, nothing is done.
bool isdef(int dd, const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is a definition (can required indices manipulation and/or inner contraction).
Definition: give_ope.cpp:106
int neq
Number of field equations.
int dom_max
Highest domain number.
void newton_update_vars(Array< double > const &xx)
Update the values of var and var_double from the solution of the linear system of the last Newton ite...
const Space & espace
Associated Space.
void check_bsize(int bsize)
Tests the not too many processors are used.
MMPtr_array< char > names_def
Names of the definitions.
int ncst
Number of constants passed by the user.
int ncst_hard
Number of constants generated on the fly (when encoutering things like "2.2" etc.....
virtual void add_eq_one_side(int dom, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation to be solved inside a domain (assumed to be first order).
Definition: add_eq.cpp:407
Array< double > val_cst_hard
Values of the constants generated on the fly (when encoutering things like "2.2" etc....
int get_dom_min() const
Returns the smallest index of the domains.
int nterm_double
Number of Term_eq corresponding to the unknowns that are numbers.
Array< double > do_JX(const Array< double > &xx)
Computes the product where is the Jacobian of the system.
Definition: solver.cpp:94
MMPtr_array< Eq_int > eq_int
Pointers onto the integral equations.
Term_eq * give_cst(int which, int dd) const
Returns a pointer on a Term_eq corresponding to a constant.
int mpi_world_size
Sylvain's stuff.
void xx_to_ders(const Array< double > &vder)
Sets the values the variation of the fields.
int dom_min
Smallest domain number.
bool is_ope_deriv_flat(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the flat covariant derivative.
Definition: give_ope.cpp:419
virtual void add_eq_val_mode(int dom, const char *eq, const Index &pos_cf, double val)
Addition of an equation prescribing the value of one coefficient of a scalar field.
Definition: add_eq.cpp:450
Metric * met
Pointer on the associated Metric, if defined.
virtual void compute_matrix_cyclic(Array< double > &matrix, int n, int first_col=0, int n_col=ALL_COLUMNS, int num_proc=1, bool transpose=DO_NOT_TRANSPOSE)
Compute some columns of the jacobian of the system of equations.
virtual void add_eq_matching_non_std(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between domains.
Definition: add_eq.cpp:303
void update_gmres(const Array< double > &)
Perfoems one step of the GMRES method (under developpement)
void update_fields(double lambda, vector< double > const &old_var_double, vector< Tensor > const &old_var_fields, vector< double > const &p_var_double, vector< Tensor > const &p_var_fields)
Update the fields after a Newton-Raphson iteration.
System_of_eqs(const System_of_eqs &)=delete
Constructor by copy.
int nvar
Number of unknown fields.
Term_eq(* opeuser_bin[VARMAX])(const Term_eq &, const Term_eq &, Param *)
Pointers on the functions used by the user defined operators (with two arguments).
System_of_eqs(const Space &so)
Standard constructor nothing is done.
void set_output_stream(std::ostream &new_output_stream)
Sets a new output stream reference.
Term_eq(* opeuser[VARMAX])(const Term_eq &, Param *)
Pointers on the functions used by the user defined operators (single argument).
Output_data current_output_data
Data related to the last newton iterations.
static constexpr std::size_t nb_core_per_node
Sylvain's stuff.
virtual void add_eq_first_integral(int dom_min, int dom_max, const char *integ_part, const char *const_part)
Addition of an equation representing a first integral.
Definition: add_eq.cpp:578
void translate_second_member(Array< double > &secloc, Array< double > const &second, int nn, int bsize, int nprow, int myrow, int mycol)
Distributes the second member of Newton-Raphson accross the various processors.
int get_nbr_conditions() const
Returns the number of conditions.
Tensor handling.
Definition: tensor.hpp:149
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Duration t_newton_update
Sylvain's stuff.
unsigned n_iter
Sylvain's stuff.
Duration t_load_matrix
Sylvain's stuff.
Duration t_inv_matrix
Sylvain's stuff.
double current_error
Sylvain's stuff.
Duration t_trans_matrix
Sylvain's stuff.