KADATH
system_of_eqs.cpp
1 /*
2  Copyright 2017 Philippe Grandclement
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 #include "space.hpp"
21 #include "system_of_eqs.hpp"
22 #include "name_tools.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 namespace Kadath {
26 
27  template<> Profiled_object_base<std::chrono::duration<double>>::Stat_map
28  Profiled_object_base<std::chrono::duration<double>>::statistic_map{};
29 
30 
31  std::size_t System_of_eqs::default_block_size {64};
32 // Constructor
33 
34 System_of_eqs::System_of_eqs (const Space& sp) : output_stream{&std::cout},
35  espace{sp}, dom_min{0}, dom_max{espace.get_nbr_domains()-1}, ndom{dom_max-dom_min+1},
36  nvar_double{0}, var_double{VARMAX}, names_var_double{VARMAX},
37  nvar{0}, var{VARMAX}, names_var{VARMAX},
38  nterm_double{0}, term_double{VARMAX * ndom}, assoc_var_double{VARMAX*ndom},
39  nterm{0}, term{VARMAX * ndom}, assoc_var(VARMAX*ndom),
40  ncst{0}, nterm_cst{0}, cst{VARMAX*ndom}, names_cst{VARMAX * ndom},
41  ncst_hard{0}, cst_hard{VARMAX}, val_cst_hard{VARMAX},
42  ndef{0}, def {VARMAX*ndom} , names_def {VARMAX*ndom},
43  ndef_glob{0}, def_glob {VARMAX*ndom}, names_def_glob {VARMAX*ndom},
44  nopeuser{0}, opeuser{}, paruser{VARMAX}, names_opeuser{VARMAX},
45  nopeuser_bin{0}, opeuser_bin{}, paruser_bin{VARMAX}, names_opeuser_bin{VARMAX},
46  met{nullptr}, name_met{nullptr},
47  neq_int{0}, eq_int{VARMAX}, neq{0}, eq{VARMAX}, results{VARMAX},
48  nbr_unknowns{sp.nbr_unknowns_from_variable_domains()}, nbr_conditions{-1}, which_coef{nullptr}
49 {
50  // we may use the initialize tag in constructors, but it would restart a loop for each data member, better to make
51  //only one. That said, this constructor is not likely to be extensively called, so that won't matter much.
52  for (int i=0 ; i<VARMAX ; i++) {
53  var_double[i] = nullptr ;
54  var[i]=nullptr ;
55  names_var[i]=nullptr ;
56 
57  cst_hard[i] = nullptr ;
58  names_cst[i] = nullptr ;
59 
60  opeuser[i] = nullptr ;
61  paruser[i] = nullptr ;
62 
63  opeuser_bin[i] = nullptr ;
64  paruser_bin[i] = nullptr ;
65 
66  eq_int[i] = nullptr ;
67 
68  eq[i] = nullptr ;
69  results[i] = nullptr ;
70  }
71  for (int i=0 ; i<VARMAX*ndom ; i++) {
72  term[i] = nullptr ;
73  cst[i] = nullptr ;
74  term_double[i] = nullptr ;
75  }
77 }
78 
79 // same between two bounds
80 System_of_eqs::System_of_eqs (const Space& sp, int dmin, int dmax) : output_stream{&std::cout},
81 espace{sp}, dom_min{dmin}, dom_max{dmax},ndom{dom_max-dom_min+1},
82  nvar_double{0}, var_double{VARMAX}, names_var_double{VARMAX},
83  nvar{0}, var{VARMAX}, names_var{VARMAX},
84  nterm_double{0}, term_double{VARMAX * ndom}, assoc_var_double{VARMAX*ndom},
85  nterm{0}, term{VARMAX * ndom}, assoc_var(VARMAX*ndom),
86  ncst{0}, nterm_cst{0}, cst{VARMAX*ndom}, names_cst{VARMAX * ndom},
87  ncst_hard{0}, cst_hard{VARMAX}, val_cst_hard{VARMAX},
88  ndef{0}, def {VARMAX*ndom} , names_def {VARMAX*ndom},
89  ndef_glob{0}, def_glob {VARMAX*ndom}, names_def_glob {VARMAX*ndom},
90  nopeuser{0}, opeuser{}, paruser{VARMAX}, names_opeuser{VARMAX},
91  nopeuser_bin{0}, opeuser_bin{}, paruser_bin{VARMAX}, names_opeuser_bin{VARMAX},
92  met{nullptr}, name_met{nullptr},
93  neq_int{0}, eq_int{VARMAX}, neq{0}, eq{VARMAX}, results{VARMAX},
94  nbr_unknowns{sp.nbr_unknowns_from_variable_domains()}, nbr_conditions{-1}, which_coef{nullptr}
95 {
96  // we may use the initialize tag in constructors, but it would restart a loop for each data member, better to make
97  //only one. That said, this constructor is not likely to be extensively called, so that won't matter much.
98  for (int i=0 ; i<VARMAX ; i++) {
99  var_double[i] = nullptr ;
100  var[i]=nullptr ;
101  names_var[i]=nullptr ;
102 
103  cst_hard[i] = nullptr ;
104  names_cst[i] = nullptr ;
105 
106  opeuser[i] = nullptr ;
107  paruser[i] = nullptr ;
108 
109  opeuser_bin[i] = nullptr ;
110  paruser_bin[i] = nullptr ;
111 
112  eq_int[i] = nullptr ;
113 
114  eq[i] = nullptr ;
115  results[i] = nullptr ;
116  }
117  for (int i=0 ; i<VARMAX*ndom ; i++) {
118  term[i] = nullptr ;
119  cst[i] = nullptr ;
120  term_double[i] = nullptr ;
121  }
122  init_proc_data();
123 }
124 
125 
127 // delete [] var_double ;
128  for (int i=0 ; i<nvar_double ; i++) delete [] names_var_double[i] ;
129  for (int i=0 ; i<nterm_double ; i++) delete term_double[i] ;
130 // delete [] var ;
131  for (int i=0 ; i<nvar ; i++) delete [] names_var[i] ;
132  for (int i=0 ; i<nterm ; i++) delete term[i] ;
133  for (int i=0 ; i<nterm_cst ; i++) safe_delete(cst[i]);
134  for (int i=0 ; i<ncst ; i++) delete [] names_cst[i] ;
135  for (int i=0 ; i<ncst_hard ; i++) delete cst_hard[i] ;
136 // delete [] cst_hard ;
137  for (int i=0 ; i<ndef ; i++) delete def[i] ;
138 // delete [] def ;
139  for (int i=0 ; i<ndef ; i++) delete [] names_def[i] ;
140 // delete [] names_def ;
141  for (int i=0 ; i<ndef_glob ; i++) delete def_glob[i] ;
142 // delete [] def_glob ;
143  for (int i=0 ; i<ndef_glob ; i++) delete [] names_def_glob[i] ;
144 // delete [] names_def_glob ;
145  for (int i=0 ; i<nopeuser ; i++) delete names_opeuser[i] ;
146 // delete [] names_opeuser ;
147 // delete [] paruser ;
148  for (int i=0 ; i<nopeuser_bin ; i++) delete names_opeuser_bin[i] ;
149 // delete [] names_opeuser_bin ;
150 // delete [] paruser_bin ;
151  if (name_met !=nullptr) delete [] name_met ;
152  for (int i=0 ; i<neq_int ; i++) delete eq_int[i] ;
153 // delete [] eq_int ;
154  for (int i=0 ; i<neq ; i++) delete eq[i] ;
155 // delete [] eq ;
156  for (int i=0 ; i<VARMAX ; i++) if (results[i]!=nullptr)
157  delete results[i] ;
158  if(!which_coef.empty()) for (int i=0 ; i<nbr_conditions ; i++) delete which_coef[i] ;
159 }
160 
161 
163  if (met==nullptr) {
164  cerr << "Undefined metric in System_of_eqs" << endl ;
165  abort() ;
166  }
167  return met ;
168 }
169 
170 Term_eq* System_of_eqs::give_term_double (int which, int dd) const {
171 
172  assert ((which>=0) && (which<nvar_double)) ;
173  assert ((dd>=dom_min) && (dd<=dom_max)) ;
174 
175  int pos = which*ndom + (dd-dom_min) ;
176  return term_double[pos] ;
177 }
178 
179 Term_eq* System_of_eqs::give_term (int which, int dd) const {
180 
181  assert ((which>=0) && (which<nvar)) ;
182  assert ((dd>=dom_min) && (dd<=dom_max)) ;
183 
184  int pos = which*ndom + (dd-dom_min) ;
185  return term[pos] ;
186 }
187 
188 Term_eq* System_of_eqs::give_cst (int which, int dd) const {
189 
190  assert ((which>=0) && (which<ncst)) ;
191  assert ((dd>=dom_min) && (dd<=dom_max)) ;
192  int pos = which*ndom + (dd-dom_min) ;
193  return cst[pos] ;
194 }
195 
196 Term_eq* System_of_eqs::give_cst_hard (double xx, int dd) const {
197  // Check if it has already been stored :
198  for (int i=0 ; i<ncst_hard ; i++)
199  if ((fabs(val_cst_hard(i) - xx) <PRECISION) && (cst_hard[i]->get_dom()==dd))
200  return cst_hard[i] ;
201 
202  // Term not found, one needs to put it
203  cst_hard[ncst_hard] = new Term_eq (dd, xx) ;
204  cst_hard[ncst_hard]->set_der_zero() ;
205  val_cst_hard.set(ncst_hard) = xx ;
206  ncst_hard++ ;
207  return cst_hard[ncst_hard-1] ;
208 }
209 
210 Ope_def* System_of_eqs::give_def (int which) const {
211 
212  assert ((which>=0) && (which<ndef)) ;
213  return def[which] ;
214 }
215 
217 
218  assert ((which>=0) && (which<ndef_glob)) ;
219  return def_glob[which] ;
220 }
221 
223 
224  for (int d=dom_min ; d<=dom_max ; d++)
226 
228 }
229 
231 {
232  for (int vv=0 ; vv<nvar_double ; vv++)
233  for (int dd=dom_min ; dd<=dom_max ; dd++)
234  give_term_double(vv, dd)->set_val_d (*var_double[vv]) ;
235 
236  for (int vv=0 ; vv<nvar ; vv++)
237  for (int dd=dom_min ; dd<=dom_max ; dd++)
238  give_term(vv, dd)->set_val_t (*var[vv]) ;
239 }
240 
241 // Add an uknown
242 void System_of_eqs::add_var (const char*nom, double& vv) {
243 
244  if ((nbr_char(nom, '_')!=0) || (nbr_char(nom, '^')!=0)) {
245  cerr << "No indices allowed in names of variables" << endl ;
246  abort() ;
247  }
248 
249  var_double[nvar_double] = &vv ;
250  names_var_double[nvar_double] = new char[LMAX];
251  trim_spaces(names_var_double[nvar_double],nom) ;
252 
253  for (int dd=dom_min ; dd<=dom_max ; dd++) {
254  term_double[nterm_double] = new Term_eq(dd, vv) ;
256  nterm_double++ ;
257  }
258  nvar_double++ ;
259 
260  nbr_unknowns ++ ;
261 }
262 
263 // Add an uknown
264 void System_of_eqs::add_var (const char*nom, Tensor& tt) {
265 
266  if (nom!=nullptr) {
267  if ((nbr_char(nom, '_')!=0) || (nbr_char(nom, '^')!=0)) {
268  cerr << "No indices allowed in names of variables" << endl ;
269  abort() ;
270  }
271 
272 
273  names_var[nvar] = new char[LMAX];
274  trim_spaces(names_var[nvar],nom) ;
275  }
276  else {
277  names_var[nvar] = new char[LMAX] ;
278  trim_spaces (names_var[nvar], "$") ;
279  }
280 
281  assert (&tt.espace==&espace) ;
282  var[nvar] = &tt ;
283  for (int dd=dom_min ; dd<=dom_max ; dd++) {
284  term[nterm] = new Term_eq(dd, tt) ;
285  assoc_var.set(nterm) = nvar ;
286  nterm++ ;
287  }
288 
289  nvar++ ;
290 
291  for (int dd=dom_min ; dd<=dom_max ; dd++)
292  nbr_unknowns += espace.get_domain(dd)->nbr_unknowns (tt, dd) ;
293 }
294 
295 // Add a constant
296 void System_of_eqs::add_cst (const char*nom, const Tensor& so) {
297 
298  if (nom!=nullptr) {
299  if ((nbr_char(nom, '_')!=0) || (nbr_char(nom, '^')!=0)) {
300  cerr << "No indices allowed in names of constants" << endl ;
301  abort() ;
302  }
303 
304  char nomcst[LMAX];
305  trim_spaces(nomcst,nom) ;
306 
307  names_cst[ncst] = new char[LMAX] ;
308  trim_spaces (names_cst[ncst], nomcst) ;
309  }
310  else {
311  names_cst[ncst] = new char[LMAX] ;
312  trim_spaces (names_cst[ncst], "$") ;
313  }
314 
315  ncst++ ;
316 
317  for (int dd=dom_min ; dd<=dom_max ; dd++) {
318  cst[nterm_cst] = new Term_eq(dd, so) ;
319  cst[nterm_cst]->set_der_zero() ;
320  nterm_cst ++ ;
321  }
322 }
323 
324 void System_of_eqs::add_cst (const char*nom, double xx) {
325  char nomcst[LMAX];
326  trim_spaces(nomcst,nom) ;
327 
328  names_cst[ncst] = new char[LMAX] ;
329  trim_spaces (names_cst[ncst], nomcst) ;
330  ncst++ ;
331 
332  for (int dd=dom_min ; dd<=dom_max ; dd++) {
333  cst[nterm_cst] = new Term_eq(dd, xx) ;
334  cst[nterm_cst]->set_der_zero() ;
335  nterm_cst++ ;
336  }
337 }
338 
339 void System_of_eqs::add_ope (const char* nom, Term_eq (*pope) (const Term_eq&, Param*), Param* par) {
340 
341  names_opeuser[nopeuser] = new char [LMAX] ;
342  trim_spaces (names_opeuser[nopeuser], nom) ;
343  opeuser[nopeuser] = pope ;
344  paruser[nopeuser] = par ;
345  nopeuser++ ;
346 }
347 
348 void System_of_eqs::add_ope (const char* nom, Term_eq (*pope) (const Term_eq&, const Term_eq&, Param*), Param* par) {
349 
350  names_opeuser_bin[nopeuser_bin] = new char [LMAX] ;
351  trim_spaces (names_opeuser_bin[nopeuser_bin], nom) ;
352  opeuser_bin[nopeuser_bin] = pope ;
353  paruser_bin[nopeuser_bin] = par ;
354  nopeuser_bin++ ;
355 }
356 
357 // Add a definition
358 void System_of_eqs::add_def (int dom, const char* nom) {
359 
360  // Récupère le = :
361  char p1[LMAX] ;
362  char p2[LMAX] ;
363  bool indic = is_ope_bin(nom, p1, p2, '=') ;
364  if (!indic) {
365  cerr << "= needed for definitions" << endl ;
366  abort() ;
367  }
368 
369  //lhs is name of definition :
370  names_def[ndef] = new char[LMAX] ;
371  get_util (names_def[ndef], p1) ;
372 
373  int valence ;
374  char* indices = nullptr ;
375  Array<int>* ttype = nullptr ;
376  bool auxi = is_tensor (p1, names_def[ndef], valence, indices, ttype) ;
377  assert (auxi) ;
378 
379  def[ndef] = new Ope_def (this, give_ope (dom, p2), valence, indices, ttype) ;
380  if (ttype!=nullptr)
381  delete ttype ;
382  if (indices!=nullptr)
383  delete [] indices ;
384  ndef++ ;
385 }
386 
387 void System_of_eqs::add_def (const char* nom) {
388  for (int dd=dom_min ; dd<=dom_max ; dd++)
389  add_def(dd, nom) ;
390 }
391 
392 // Add a definition invloving all the domains (i.e. integral)
393 void System_of_eqs::add_def_global (int dom, const char* nom) {
394 
395  // Récupère le = :
396  char p1[LMAX] ;
397  char p2[LMAX] ;
398  bool indic = is_ope_bin(nom, p1, p2, '=') ;
399  if (!indic) {
400  cerr << "= needed for definitions" << endl ;
401  abort() ;
402  }
403 
404  //lhs is name of definition :
405  names_def_glob[ndef_glob] = new char[LMAX] ;
406  get_util (names_def_glob[ndef_glob], p1) ;
407  def_glob[ndef_glob] = new Ope_def_global (this, dom, p2) ;
408  ndef_glob++ ;
409 }
410 
411 void System_of_eqs::add_def_global (const char* nom) {
412  for (int dd=dom_min ; dd<=dom_max ; dd++)
413  add_def_global(dd, nom) ;
414 }
415 
416 
418 
419  assert (xx.get_ndim()==1) ;
420  assert (xx.get_size(0) == nbr_unknowns) ;
421 
422  int conte = 0 ;
423  int pos_term = 0 ;
424 
426 
427  for (int i=0 ; i<nvar_double ; i++) {
428  for (int dd=dom_min ; dd<dom_max ; dd++) {
429  term_double[pos_term]->set_der_d(xx(conte)) ;
430  pos_term ++ ;
431  }
432  conte ++ ;
433  }
434 
435  for (int i=0 ; i<nterm ; i++) {
436 
437  // Check for symetric tensor :
438  const Metric_tensor* pmet = dynamic_cast<const Metric_tensor*>(term[i]->val_t) ;
439  if (pmet==nullptr) {
440  Tensor auxi (term[i]->get_val_t(), false) ;
441 
442  int dom = term[i]->get_dom() ;
443  espace.get_domain(dom)->affecte_tau(auxi, dom, xx, conte) ;
444 
445  term[i]->set_der_t(auxi) ;
446  }
447  else {
448  Metric_tensor auxi (*pmet, false) ;
449 
450  int dom = term[i]->get_dom() ;
451  espace.get_domain(dom)->affecte_tau(auxi, dom, xx, conte) ;
452  term[i]->set_der_t(auxi) ;
453  }
454  }
455 }
456 
457 void System_of_eqs::xx_to_vars (const Array<double>& xx, int& conte) {
458 
459  assert (xx.get_ndim()==1) ;
460  assert (xx.get_size(0) == nbr_unknowns) ;
461 
462  for (int i=0 ; i<nvar_double ; i++) {
463  *var_double[i] = xx(conte) ;
464  conte ++ ;
465  }
466 
467  for (int i=0 ; i<nvar ; i++)
468  for (int dom=dom_min ; dom<=dom_max ; dom++) {
469  espace.get_domain(dom)->affecte_tau(*var[i], dom, xx, conte) ;
470  }
471 
472 }
473 
474 Tensor System_of_eqs::give_val_def (const char* so) const {
475 
476  char name[LMAX] ;
477  trim_spaces(name, so) ;
478 
479  bool found = false ;
480  int valence = -1;
481  Array<int>* index ;
482  Base_tensor* basis ;
483 
484  bool foundpar = false ;
485 
486  for (int i=0 ; i<ndef ; i++)
487  if (!found) {
488  if (strcmp(names_def[i], name)==0) {
489  found = true ;
490  Tensor auxi (give_def(i)->get_res()->get_val_t()) ;
491  valence = auxi.get_valence() ;
492  index = new Array<int> (auxi.get_index_type()) ;
493  basis = new Base_tensor (auxi.get_basis()) ;
494  if ((auxi.parameters) && (!foundpar)) {
495  foundpar = true ;
496  }
497  }
498  }
499 
500  if (!found) {
501  cerr << "Definition not found...." << endl ;
502  abort() ;
503  }
504 
505  Tensor res (espace, valence, *index, *basis) ;
506  res = 0 ;
507 
508  delete index ;
509  delete basis ;
510 
511  for (int i=0 ; i<ndef ; i++)
512  if (strcmp(names_def[i], name)==0) {
513  int zedom = give_def(i)->get_res()->get_dom() ;
514  Tensor auxi (give_def(i)->get_res()->get_val_t()) ;
515  for (int n=0 ; n<res.get_n_comp() ; n++) {
516  Array<int> ind (res.indices(n)) ;
517  res.set(ind).set_domain(zedom) = auxi(ind)(zedom) ;
518  }
519  res.set_basis(zedom) = auxi.get_basis().get_basis(zedom) ;
520  if (foundpar) {
521  res.set_parameters() = auxi.get_parameters() ;
522  foundpar = false ;
523  }
524  }
525 
526  return res ;
527 }
528 
529 void System_of_eqs::compute_matrix_cyclic(Array<double> &matrix, int n, int first_col, int n_col, int num_proc,
530  bool transpose)
531 {
532  assert(matrix.get_ndim()==2);
533  n_col = (n_col == ALL_COLUMNS ? n : n_col);
534  bool done = false;
535  int current = 0;
536  bool unable_to_compute{false};
537  while (!done)
538  {
539  for (int i{0},k{first_col} ; i<n_col && k < n; i++, k++) {
540  Array<double> column{n};
541  try {
542  column = do_col_J(k);
543  }
544  catch(std::exception const & e) {
545  std::cerr << "---> unable to compute column " << k << "/" << n << " (rank "
546  << mpi_proc_rank << "/" << mpi_world_size << ")" << std::endl;
547  unable_to_compute = true;
548  column = 0.;
549  }
550  if(transpose){
551  for (int j = 0; j < n; j++) matrix.set(current, j) = column(j);
552  } else {
553  for (int j = 0; j < n; j++) matrix.set(j, current) = column(j);
554  }
555  current++;
556  }
557  first_col += num_proc * n_col;
558  if (first_col>=n)
559  done = true;
560  }
561  if(unable_to_compute) throw std::runtime_error{"Unable to compute the jacobian"};
562 }
563 
564 void System_of_eqs::compute_matrix_adjacent(Array<double> &matrix, int n, int first_col, int n_col, int num_proc,
565  bool transpose, std::vector<vector<std::size_t>> *dm)
566 {
567  assert(matrix.get_ndim()==2);
568  n_col = (n_col == ALL_COLUMNS ? n : n_col);
569  for(int j{0};j<n_col;j++)
570  {
571  int const J{first_col+j};
572  Array<double> column(do_col_J(J));
573  if(transpose)
574  {
575  for(int i{0};i<n;i++) {matrix.set(J,i) = column(i); if(dm) (*dm)[i][J]++;}
576  } else {
577  for(int i{0};i<n;i++) {matrix.set(i,J) = column(i); if(dm) (*dm)[J][i]++;}
578  }
579  }
580 
581 }
582 
584 {
585  int conte = 0;
586  espace.xx_to_vars_variable_domains (this, xx, conte);
587 
588  double* old_var_double = (nvar_double==0) ? nullptr :new double[nvar_double];
589  for (int i=0 ; i<nvar_double ; i++) old_var_double[i] = *var_double[i];
590  Tensor** old_fields = new Tensor* [nvar];
591  for (int i=0 ; i<nvar ; i++) old_fields[i] = new Tensor(*var[i]);
592  xx_to_vars(xx, conte);
593  for (int i=0 ; i<nvar ; i++)
594  {
595  *var[i] = *old_fields[i] - *var[i];
596  }
597  for (int i=0 ; i<nvar_double ; i++) *var_double[i] = old_var_double[i] - *var_double[i];
598  if (old_var_double!=nullptr) delete [] old_var_double;
599  for (int i=0 ; i<nvar ; i++) delete old_fields[i];
600  delete [] old_fields;
601 }
602 
603 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
int get_ndim() const
Returns the number of dimensions.
Definition: array.hpp:323
int get_size(int i) const
Returns the size of a given dimension.
Definition: array.hpp:331
Describes the tensorial basis used by the various tensors.
Definition: base_tensor.hpp:49
int get_basis(int nd) const
Read only the basis in a given domain.
Definition: base_tensor.hpp:93
virtual void vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
Definition: space.hpp:899
virtual int nbr_unknowns(const Tensor &so, int dom) const
Computes the number of true unknowns of a Tensor, in a given domain.
Definition: domain.cpp:1498
virtual void affecte_tau(Tensor &so, int dom, const Array< double > &cf, int &pos_cf) const
Affects some coefficients to a Tensor.
Definition: domain.cpp:1569
Particular type of Tensor, dedicated to the desription of metrics.
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
Term_eq * get_res()
Returns the result.
Definition: ope_def.cpp:71
Parameter storage.
Definition: param.hpp:30
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
The Space class is an ensemble of domains describing the whole space of the computation.
Definition: space.hpp:1362
virtual void xx_to_ders_variable_domains(const Array< double > &xx, int &conte) const
Update the vairable domains from a set of values.
Definition: space.hpp:1407
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
virtual void xx_to_vars_variable_domains(System_of_eqs *syst, const Array< double > &xx, int &conte) const
Update the variables of a system, from the variation of the shape of the domains.
Definition: space.hpp:1414
MMPtr_array< Ope_def > def
Pointers on the definition (i.e. on the Ope_def that is needed to compute the result).
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.
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).
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.
void init_proc_data()
Sylvain's stuff.
Array< double > do_col_J(int i)
Computes one column of the Jacobian.
Definition: solver.cpp:127
~System_of_eqs() override
Destructor.
MMPtr_array< double > var_double
Pointer on the unknowns that are numbers (i.e. not fields)
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.
static constexpr int ALL_COLUMNS
Dummy variable for the purpose of better readability.
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.
MMPtr_array< char > names_var
Names of the unknown fields.
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.
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...
MMPtr_array< Term_eq > term_double
Pointers on the Term_eq corresponding to the unknowns that are numbers.
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...
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.
int neq_int
Number of integral equations (i.e. which are doubles)
MMPtr_array< char > names_opeuser
Names of the user defined operators (single argument).
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
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.
Array< int > assoc_var_double
Array giving the correspondance with the var_double pointers.
MMPtr_array< Term_eq > cst
Pointers on the Term_eq coming from the constants passed by the user.
void xx_to_vars(const Array< double > &val, int &conte)
Sets the values the of the fields.
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
MMPtr_array< char > names_cst
Names of the constants passed by the user.
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)
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.
int ndef
Number of definitions.
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.
virtual void add_def_global(const char *name)
Addition of a global definition.
char * name_met
Name by which the metric is recognized.
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.
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.
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.....
Array< double > val_cst_hard
Values of the constants generated on the fly (when encoutering things like "2.2" etc....
int nterm_double
Number of Term_eq corresponding to the unknowns that are numbers.
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.
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.
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.
Term_eq(* opeuser[VARMAX])(const Term_eq &, Param *)
Pointers on the functions used by the user defined operators (single argument).
Tensor handling.
Definition: tensor.hpp:149
Param_tensor parameters
Possible additional parameters relevant for the current Tensor.
Definition: tensor.hpp:181
Param_tensor & set_parameters()
Read/write of the parameters.
Definition: tensor.hpp:314
const Param_tensor & get_parameters() const
Returns a pointer on the possible additional parameter.
Definition: tensor.hpp:311
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
Definition: tensor_impl.hpp:91
int get_index_type(int i) const
Gives the type (covariant or contravariant) of a given index.
Definition: tensor.hpp:526
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tensor.hpp:504
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.hpp:514
virtual Array< int > indices(int pos) const
Gives the values of the indices corresponding to a location in the array used for storage of the comp...
Definition: tensor.hpp:484
const Space & espace
The Space.
Definition: tensor.hpp:154
int get_valence() const
Returns the valence.
Definition: tensor.hpp:509
int & set_basis(int dd)
Assigns a new tensorial basis in a given domain.
Definition: tensor.hpp:331
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
int get_dom() const
Definition: term_eq.hpp:135
void set_val_d(double)
Sets the double value.
Definition: term_eq.hpp:383
void set_val_t(Tensor)
Sets the tensorial value (only the values in the pertinent Domain are copied).
Definition: term_eq.cpp:155