KADATH
domain_shell_inner_adapted.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 "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "adapted.hpp"
23 #include "point.hpp"
24 #include "array_math.hpp"
25 #include "val_domain.hpp"
26 #include "scalar.hpp"
27 #include "tensor_impl.hpp"
28 
29 namespace Kadath {
30 void coef_1d (int, Array<double>&) ;
31 void coef_i_1d (int, Array<double>&) ;
32 int der_1d (int, Array<double>&) ;
33 
34 // Standard constructor
35 Domain_shell_inner_adapted::Domain_shell_inner_adapted (const Space& sss, int num, int ttype, double rin, double rout, const Point& cr, const Dim_array& nbr) :
36  Domain(num, ttype, nbr), sp(sss), outer_radius(rout), center(cr) {
37  assert (nbr.get_ndim()==3) ;
38  assert (cr.get_ndim()==3) ;
39 
40 
41  inner_radius_term_eq = nullptr ;
42  rad_term_eq = nullptr ;
43  der_rad_term_eq = nullptr ;
44  dt_rad_term_eq = nullptr ;
45  dp_rad_term_eq = nullptr ;
46  normal_spher = nullptr ;
47  normal_cart = nullptr ;
48 
49  do_coloc() ;
50  inner_radius = new Val_domain (this) ;
51  *inner_radius = rin ;
53 }
54 
55 Domain_shell_inner_adapted::Domain_shell_inner_adapted (const Space& sss, int num, int ttype, const Val_domain& rin, double rout, const Point& cr, const Dim_array& nbr) :
56  Domain(num, ttype, nbr), sp(sss), outer_radius(rout), center(cr) {
57  assert (nbr.get_ndim()==3) ;
58  assert (cr.get_ndim()==3) ;
59 
60 
61  inner_radius_term_eq = nullptr ;
62  rad_term_eq = nullptr ;
63  der_rad_term_eq = nullptr ;
64  dt_rad_term_eq = nullptr ;
65  dp_rad_term_eq = nullptr ;
66  normal_spher = nullptr ;
67  normal_cart = nullptr ;
68 
69  do_coloc() ;
70  inner_radius = new Val_domain(rin) ;
71 }
72 
73 // Constructor by copy
75  outer_radius (so.outer_radius), center(so.center) {
76 
78  if (so.inner_radius_term_eq != nullptr)
80  if (so.rad_term_eq !=nullptr)
81  rad_term_eq = new Term_eq (*so.rad_term_eq) ;
82  if (so.der_rad_term_eq !=nullptr)
84  if (so.dt_rad_term_eq !=nullptr)
86  if (so.dp_rad_term_eq !=nullptr)
88  if (so.normal_spher !=nullptr)
89  normal_spher = new Term_eq (*so.normal_spher) ;
90  if (so.normal_cart !=nullptr)
91  normal_cart = new Term_eq (*so.normal_cart) ;
92 }
93 
94 Domain_shell_inner_adapted::Domain_shell_inner_adapted (const Space& sss, int num, FILE* fd) : Domain(num, fd), sp(sss), center(fd) {
95  fread_be (&outer_radius, sizeof(double), 1, fd) ;
96  inner_radius = new Val_domain(this, fd) ;
97 
98  inner_radius_term_eq = nullptr ;
99  rad_term_eq = nullptr ;
100  der_rad_term_eq = nullptr ;
101  dt_rad_term_eq = nullptr ;
102  dp_rad_term_eq = nullptr ;
103  normal_spher = nullptr ;
104  normal_cart = nullptr ;
105 
106  do_coloc() ;
107 }
108 
110  for (int i=0 ; i<3 ; i++)
111  assert (coloc[i] != nullptr) ;
112  assert (radius == nullptr) ;
113  radius = new Val_domain(this) ;
114  radius->allocate_conf() ;
115  Index index (nbr_points) ;
116  do
117  radius->set(index) = (outer_radius - (*inner_radius)(index))/2.* ((*coloc[0])(index(0))) + (outer_radius + (*inner_radius)(index))/2. ;
118  while (index.inc()) ;
119  radius->std_r_base() ;
120 }
121 
122 // Destructor
124 
125  delete inner_radius ;
126  if (inner_radius_term_eq != nullptr)
127  delete inner_radius_term_eq ;
128  if (rad_term_eq != nullptr)
129  delete rad_term_eq ;
130  if (der_rad_term_eq != nullptr)
131  delete der_rad_term_eq ;
132  if (normal_spher != nullptr)
133  delete normal_spher ;
134  if (normal_cart != nullptr)
135  delete normal_cart ;
136  if (dt_rad_term_eq != nullptr)
137  delete dt_rad_term_eq ;
138  if (dp_rad_term_eq != nullptr)
139  delete dp_rad_term_eq ;
140 }
141 
143  safe_delete(inner_radius_term_eq);
144  safe_delete(rad_term_eq);
145  safe_delete(der_rad_term_eq);
146  safe_delete(normal_spher);
147  safe_delete(normal_cart);
148  safe_delete(dt_rad_term_eq);
149  safe_delete(dp_rad_term_eq);
150 }
151 
153 
154  int res = 0 ;
155  for (int k=0 ; k<nbr_coefs(2) ; k++)
156  if ((k!=1) && (k!=nbr_coefs(2)-1)) {
157  int mm = (k%2==0) ? int(k/2) : int ((k-1)/2) ;
158  int jmax = (mm%2==0) ? nbr_coefs(1) : nbr_coefs(1)-1 ;
159  int jmin = (k>=4) ? 1 : 0 ;
160  for (int j=jmin ; j<jmax ; j++)
161  res ++ ;
162  }
163  return res ;
164 }
165 
167 
168  if (inner_radius_term_eq != nullptr)
169  delete inner_radius_term_eq ;
170  Scalar val (sp) ;
172 
173  inner_radius_term_eq = new Term_eq (num_dom, val) ;
174  update() ;
175 }
176 
177 void Domain_shell_inner_adapted::affecte_coef(int& conte, int cc, bool& found) const {
178 
179  Val_domain auxi (this) ;
180  auxi.std_base() ;
181  auxi.set_in_coef() ;
182  auxi.allocate_coef() ;
183  *auxi.cf = 0 ;
184 
185  found = false ;
186 
187  for (int k=0 ; k<nbr_coefs(2) ; k++)
188  if ((k!=1) && (k!=nbr_coefs(2)-1)) {
189  int mm = (k%2==0) ? int(k/2) : int ((k-1)/2) ;
190  int jmax = (mm%2==0) ? nbr_coefs(1) : nbr_coefs(1)-1 ;
191  int jmin = (k>=4) ? 1 : 0 ;
192  for (int j=jmin ; j<jmax ; j++) {
193  if (conte==cc) {
194  Index pos_cf (nbr_coefs) ;
195  pos_cf.set(0) = 0 ;
196  pos_cf.set(1) = j ;
197  pos_cf.set(2) = k ;
198  auxi.cf->set(pos_cf) = 1 ;
199  if ((jmin==1) && (mm%2==0)) {
200  // Galerkin base COS EVEN
201  pos_cf.set(1) = 0 ;
202  auxi.cf->set(pos_cf) = -1 ;
203  }
204  if ((jmin==1) && (mm%2==1)) {
205  // Galerkin base SIN ODD
206  pos_cf.set(1) = 0 ;
207  auxi.cf->set(pos_cf) = -(2*j+1) ;
208  }
209  found = true ;
210  }
211  conte ++ ;
212  }
213  }
214 
215  if (found) {
216  Scalar auxi_scal (sp) ;
217  auxi_scal.set_domain(num_dom) = auxi ;
218  inner_radius_term_eq->set_der_t(auxi_scal) ;
219  }
220  else {
222  }
223  update() ;
224 }
225 
226 void Domain_shell_inner_adapted::xx_to_vars_from_adapted(Val_domain& new_inner_radius, const Array<double>& xx, int& pos) const {
227 
228  new_inner_radius.allocate_coef() ;
229  *new_inner_radius.cf = 0 ;
230 
231  Index pos_cf (nbr_coefs) ;
232  pos_cf.set(0) = 0 ;
233 
234  for (int k=0 ; k<nbr_coefs(2) ; k++)
235  if ((k!=1) && (k!=nbr_coefs(2)-1)) {
236  pos_cf.set(2) = k ;
237  int mm = (k%2==0) ? int(k/2) : int ((k-1)/2) ;
238  int jmax = (mm%2==0) ? nbr_coefs(1) : nbr_coefs(1)-1 ;
239  int jmin = (k>=4) ? 1 : 0 ;
240  for (int j=jmin ; j<jmax ; j++) {
241  pos_cf.set(1)= j ;
242  new_inner_radius.cf->set(pos_cf) -= xx(pos) ;
243  if ((jmin==1) && (mm%2==0)) {
244  // Galerkin basis COS EVEN
245  pos_cf.set(1) = 0 ;
246  new_inner_radius.cf->set(pos_cf) += xx(pos) ;
247  }
248  if ((jmin==1) && (mm%2==1)) {
249  // Galerkin basis SIN ODD
250  pos_cf.set(1) = 0 ;
251  new_inner_radius.cf->set(pos_cf) += (2*j+1)*xx(pos) ;
252  }
253 
254  pos ++ ;
255  }
256  }
257 
258  new_inner_radius.set_base() = inner_radius->get_base() ;
259 }
260 
262 
263  *inner_radius += cor ;
264  for (int l=0 ; l<ndim ; l++) {
265  if (absol[l] !=nullptr) delete absol[l] ;
266  if (cart[l] !=nullptr) delete cart[l] ;
267  if (cart_surr[l] !=nullptr) delete cart_surr[l] ;
268  absol[l] = nullptr ;
269  cart_surr[l] = nullptr ;
270  cart[l]= nullptr ;
271  }
272  if (radius !=nullptr)
273  delete radius ;
274  radius = nullptr ;
275  update() ;
276 }
277 
279 
280  *inner_radius = cor ;
281  for (int l=0 ; l<ndim ; l++) {
282  if (absol[l] !=nullptr) delete absol[l] ;
283  if (cart[l] !=nullptr) delete cart[l] ;
284  if (cart_surr[l] !=nullptr) delete cart_surr[l] ;
285  absol[l] = nullptr ;
286  cart_surr[l] = nullptr ;
287  cart[l]= nullptr ;
288  }
289  if (radius !=nullptr)
290  delete radius ;
291  radius = nullptr ;
292  vars_to_terms() ;
293 }
294 
295 void Domain_shell_inner_adapted::update_variable (const Val_domain& cor_inner_radius, const Scalar& old, Scalar& res) const {
296 
297  Val_domain dr (old(num_dom).der_r()) ;
298  if (dr.check_if_zero())
299  res.set_domain(num_dom) = 0 ;
300  else {
301 
302  Index pos(nbr_points) ;
304  do {
305  res.set_domain(num_dom).set(pos) = dr(pos) * (1-(*coloc[0])(pos(0))) / 2. ;
306  }
307  while (pos.inc()) ;
308 
309  res.set_domain(num_dom) = cor_inner_radius * res(num_dom) + old(num_dom) ;
310  res.set_domain(num_dom).set_base() = old(num_dom).get_base() ;
311  }
312 }
313 
314 
316 
317  Val_domain auxi (this) ;
318  auxi.std_base() ;
319  auxi.set_in_coef() ;
320  auxi.allocate_coef() ;
321  *auxi.cf = 0 ;
322 
323  Index pos_cf (nbr_coefs) ;
324  pos_cf.set(0) = 0 ;
325 
326  for (int k=0 ; k<nbr_coefs(2) ; k++)
327  if ((k!=1) && (k!=nbr_coefs(2)-1)) {
328  pos_cf.set(2) = k ;
329  int mm = (k%2==0) ? int(k/2) : int ((k-1)/2) ;
330  int jmax = (mm%2==0) ? nbr_coefs(1) : nbr_coefs(1)-1 ;
331  int jmin = (k>=4) ? 1 : 0 ;
332  for (int j=jmin ; j<jmax ; j++) {
333  pos_cf.set(1)= j ;
334  auxi.cf->set(pos_cf) = xx(pos) ;
335 
336  if ((jmin==1) && (mm%2==0)) {
337  // Galerkin basis COS EVEN
338  pos_cf.set(1) = 0 ;
339  auxi.cf->set(pos_cf) = -xx(pos) ;
340  }
341  if ((jmin==1) && (mm%2==1)) {
342  // Galerkin basis SIN ODD
343  pos_cf.set(1) = 0 ;
344  auxi.cf->set(pos_cf) = -(2*j+1)*xx(pos) ;
345  }
346  pos ++ ;
347  }
348  }
349 
350  Scalar auxi_scal (sp) ;
351  auxi_scal.set_domain(num_dom) = auxi ;
352  inner_radius_term_eq->set_der_t(auxi_scal) ;
353  update() ;
354 }
355 
356 
358 
359  if (rad_term_eq != nullptr)
360  delete rad_term_eq ;
361  if (der_rad_term_eq != nullptr)
362  delete der_rad_term_eq ;
363  if (dt_rad_term_eq != nullptr)
364  delete dt_rad_term_eq ;
365  if (dp_rad_term_eq != nullptr)
366  delete dp_rad_term_eq ;
367 
368  // Computation of rad_term_eq
369  Scalar val_res (sp) ;
370  val_res.set_domain(num_dom).allocate_conf() ;
371  Index index (nbr_points) ;
372  do {
373  val_res.set_domain(num_dom).set(index) = (outer_radius - ((*inner_radius_term_eq->val_t)()(num_dom))(index))/2. * ((*coloc[0])(index(0))) +
374  (outer_radius + ((*inner_radius_term_eq->val_t)()(num_dom))(index))/2. ;
375  }
376  while (index.inc()) ;
377  val_res.set_domain(num_dom).std_r_base() ;
378 
379  bool doder = (inner_radius_term_eq->der_t ==nullptr) ? false : true ;
380  if (doder) {
381  Scalar der_res (sp) ;
382  if ((*inner_radius_term_eq->der_t)()(num_dom).check_if_zero()) {
383  der_res.set_domain(num_dom).set_zero() ;
384  }
385  else {
386  der_res.set_domain(num_dom).allocate_conf() ;
387  index.set_start() ;
388  do {
389  der_res.set_domain(num_dom).set(index) = -((*inner_radius_term_eq->der_t)()(num_dom))(index)/2. * ((*coloc[0])(index(0))) +
390  ((*inner_radius_term_eq->der_t)()(num_dom))(index)/2. ;
391  }
392  while (index.inc()) ;
393  der_res.set_domain(num_dom).std_r_base() ;
394  }
395  rad_term_eq = new Term_eq (num_dom, val_res, der_res) ;
396  }
397  else
398  rad_term_eq = new Term_eq (num_dom, val_res) ;
399 
400  // Computation of der_rad_term_eq which is dr / dxi
401  val_res.set_domain(num_dom) = (outer_radius - (*inner_radius_term_eq->val_t)()(num_dom)) / 2. ;
402  if (doder) {
403  Scalar der_res (sp) ;
404  der_res.set_domain(num_dom) = - (*inner_radius_term_eq->der_t)()(num_dom) / 2. ;
405  der_rad_term_eq = new Term_eq (num_dom, val_res, der_res) ;
406  }
407  else
408  der_rad_term_eq = new Term_eq (num_dom, val_res) ;
409 
410  // Computation of dt_rad_term_eq which is dr / d theta
411  val_res.set_domain(num_dom) = (*rad_term_eq->val_t)()(num_dom).der_var(2) ;
412  if (doder) {
413  Scalar der_res (sp) ;
414  der_res.set_domain(num_dom) = (*rad_term_eq->der_t)()(num_dom).der_var(2) ;
415  dt_rad_term_eq = new Term_eq (num_dom, val_res, der_res) ;
416  }
417  else
418  dt_rad_term_eq = new Term_eq (num_dom, val_res) ;
419 
420  // Computation of dt_rad_term_eq which is dr / d phi
421  val_res.set_domain(num_dom) = (*rad_term_eq->val_t)()(num_dom).der_var(3) ;
422  if (doder) {
423  Scalar der_res (sp) ;
424  der_res.set_domain(num_dom) = (*rad_term_eq->der_t)()(num_dom).der_var(3) ;
425  dp_rad_term_eq = new Term_eq (num_dom, val_res, der_res) ;
426  }
427  else
428  dp_rad_term_eq = new Term_eq (num_dom, val_res) ;
429 
430  do_normal_cart() ;
431 }
432 
433 void Domain_shell_inner_adapted::save (FILE* fd) const {
434  nbr_points.save(fd) ;
435  nbr_coefs.save(fd) ;
436  fwrite_be (&ndim, sizeof(int), 1, fd) ;
437  fwrite_be (&type_base, sizeof(int), 1, fd) ;
438  center.save(fd) ;
439  fwrite_be (&outer_radius, sizeof(double), 1, fd) ;
440  inner_radius->save(fd) ;
441 }
442 
443 //ostream& operator<< (ostream& o, const Domain_shell_inner_adapted& so) {
444 ostream& Domain_shell_inner_adapted::print (ostream& o) const {
445  o << "Adapted shell on the inside boundary" << endl ;
446  o << "Center = " << center << endl ;
447  o << "Nbr pts = " << nbr_points << endl ;
448  o << "Outer radius " << outer_radius << endl ;
449  o << "Inner radius " << endl ;
450  o << *inner_radius << endl ;
451  o << endl ;
452  return o ;
453 }
454 
455 
456 
458  cerr << "Domain_shell_inner_adapted::der_normal not implemeted" << endl ;
459  abort() ;
460 }
461 
462 // Computes the cartesian coordinates
464  for (int i=0 ; i<3 ; i++)
465  assert (coloc[i] != nullptr) ;
466  for (int i=0 ; i<3 ; i++)
467  assert (absol[i] == nullptr) ;
468  for (int i=0 ; i<3 ; i++) {
469  absol[i] = new Val_domain(this) ;
470  absol[i]->allocate_conf() ;
471  }
472  Index index (nbr_points) ;
473  do {
474 
475  double rr = (outer_radius - (*inner_radius)(index))/2. * ((*coloc[0])(index(0))) +
476  (outer_radius + (*inner_radius)(index))/2. ;
477  absol[0]->set(index) = rr *
478  sin((*coloc[1])(index(1)))*cos((*coloc[2])(index(2))) + center(1);
479  absol[1]->set(index) = rr *
480  sin((*coloc[1])(index(1)))*sin((*coloc[2])(index(2))) + center(2) ;
481  absol[2]->set(index) = rr * cos((*coloc[1])(index(1))) + center(3) ;
482  }
483  while (index.inc()) ;
484  absol[0]->std_base() ;
485  absol[1]->std_base() ;
486  absol[2]->std_anti_base() ;
487 }
488 
489 // Computes the cartesian coordinates
491  for (int i=0 ; i<3 ; i++)
492  assert (coloc[i] != nullptr) ;
493  for (int i=0 ; i<3 ; i++)
494  assert (cart[i] == nullptr) ;
495  for (int i=0 ; i<3 ; i++) {
496  cart[i] = new Val_domain(this) ;
497  cart[i]->allocate_conf() ;
498  }
499  Index index (nbr_points) ;
500  do {
501  double rr = (outer_radius - (*inner_radius)(index))/2. * ((*coloc[0])(index(0))) +
502  (outer_radius + (*inner_radius)(index))/2. ;
503  cart[0]->set(index) = rr *
504  sin((*coloc[1])(index(1)))*cos((*coloc[2])(index(2))) + center(1);
505  cart[1]->set(index) = rr *
506  sin((*coloc[1])(index(1)))*sin((*coloc[2])(index(2))) + center(2) ;
507  cart[2]->set(index) = rr * cos((*coloc[1])(index(1))) + center(3) ;
508  }
509  while (index.inc()) ;
510  cart[0]->std_base() ;
511  cart[1]->std_base() ;
512  cart[2]->std_anti_base() ;
513 }
514 
515 
516 // Computes the cartesian coordinates over the radius
518  for (int i=0 ; i<3 ; i++)
519  assert (coloc[i] != nullptr) ;
520  for (int i=0 ; i<3 ; i++)
521  assert (cart_surr[i] == nullptr) ;
522  for (int i=0 ; i<3 ; i++) {
523  cart_surr[i] = new Val_domain(this) ;
524  cart_surr[i]->allocate_conf() ;
525  }
526  Index index (nbr_points) ;
527  do {
528  cart_surr[0]->set(index) = sin((*coloc[1])(index(1)))*cos((*coloc[2])(index(2))) ;
529  cart_surr[1]->set(index) = sin((*coloc[1])(index(1)))*sin((*coloc[2])(index(2))) ;
530  cart_surr[2]->set(index) = cos((*coloc[1])(index(1))) ;
531  }
532  while (index.inc()) ;
533  cart_surr[0]->std_base() ;
534  cart_surr[1]->std_base() ;
535  cart_surr[2]->std_anti_base() ;
536 }
537 
538 
539 // Is a point inside this domain ?
540 bool Domain_shell_inner_adapted::is_in (const Point& xx, double prec) const {
541 
542  assert (xx.get_ndim()==3) ;
543  Point num (absol_to_num(xx)) ;
544  bool res = ((num(1)>-1-prec) && (num(1)<1+prec)) ? true : false ;
545  return res ;
546 }
547 
548 // Convert absolute coordinates to numerical ones
550 
551  Point num(3) ;
552 
553  double x_loc = abs(1) - center(1) ;
554  double y_loc = abs(2) - center(2) ;
555  double z_loc = abs(3) - center(3) ;
556  double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
557  double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
558 
559  if (rho==0) {
560  // Sur l'axe
561  num.set(2) = (z_loc>=0) ? 0 : M_PI ;
562  num.set(3) = 0 ;
563  }
564  else {
565  num.set(2) = atan(rho/z_loc) ;
566  num.set(3) = atan2 (y_loc, x_loc) ;
567  }
568 
569  if (num(2) <0)
570  num.set(2) = M_PI + num(2) ;
571 
572  // Get the boundary for those angles
573  num.set(1) = 1 ;
574  inner_radius->coef() ;
575  double inner = inner_radius->get_base().summation(num, inner_radius->get_coef()) ;
576  num.set(1) = (2./(outer_radius-inner)) * (air - (outer_radius + inner)/2.) ;
577 
578  return num ;
579 }
580 
581 const Point Domain_shell_inner_adapted::absol_to_num_bound(const Point& abs, int bound) const {
582 
583  Point num(3) ;
584 
585  double x_loc = abs(1) - center(1) ;
586  double y_loc = abs(2) - center(2) ;
587  double z_loc = abs(3) - center(3) ;
588  double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
589 
590  if (rho==0) {
591  // Sur l'axe
592  num.set(2) = (z_loc>=0) ? 0 : M_PI ;
593  num.set(3) = 0 ;
594  }
595  else {
596  num.set(2) = atan(rho/z_loc) ;
597  num.set(3) = atan2 (y_loc, x_loc) ;
598  }
599 
600  if (num(2) <0)
601  num.set(2) = M_PI + num(2) ;
602 
603  // Get the boundary for those angles
604  switch (bound) {
605  case INNER_BC :
606  num.set(1) = -1 ;
607  break ;
608  case OUTER_BC :
609  num.set(1) = 1 ;
610  break ;
611  default:
612  cerr << "Unknown case in Domain_shell_inner_adapted::absol_to_num_bound" << endl ;
613  abort() ;
614  }
615  return num ;
616 }
617 
618 double coloc_leg(int, int) ;
620 
621  switch (type_base) {
622  case CHEB_TYPE:
624  nbr_coefs.set(2) += 2 ;
625  del_deriv() ;
626  for (int i=0 ; i<ndim ; i++)
627  coloc[i] = new Array<double> (nbr_points(i)) ;
628  for (int i=0 ; i<nbr_points(0) ; i++)
629  coloc[0]->set(i) = -cos(M_PI*i/(nbr_points(0)-1)) ;
630  for (int j=0 ; j<nbr_points(1) ; j++)
631  coloc[1]->set(j) = M_PI/2.*j/(nbr_points(1)-1) ;
632  for (int k=0 ; k<nbr_points(2) ; k++)
633  coloc[2]->set(k) = M_PI*2.*k/nbr_points(2) ;
634  break ;
635  case LEG_TYPE:
637  nbr_coefs.set(2) += 2 ;
638  del_deriv() ;
639  for (int i=0 ; i<ndim ; i++)
640  coloc[i] = new Array<double> (nbr_points(i)) ;
641  for (int i=0 ; i<nbr_points(0) ; i++)
642  coloc[0]->set(i) = coloc_leg(i, nbr_points(0)) ;
643  for (int j=0 ; j<nbr_points(1) ; j++)
644  coloc[1]->set(j) = M_PI/2.*j/(nbr_points(1)-1) ;
645  for (int k=0 ; k<nbr_points(2) ; k++)
646  coloc[2]->set(k) = M_PI*2.*k/nbr_points(2) ;
647  break ;
648  default :
649  cerr << "Unknown type of basis in Domain_shell_inner_adapted::do_coloc" << endl ;
650  abort() ;
651  }
652 }
653 
654 
655 // standard base for a symetric function in z, using Chebyshev
657 
658  int m ;
659 
660  assert (type_base == CHEB_TYPE) ;
661 
662  base.allocate(nbr_coefs) ;
663 
664  base.def =true ;
665  base.bases_1d[2]->set(0) = COSSIN ;
666 
667  Index index (base.bases_1d[0]->get_dimensions()) ;
668 
669  for (int k=0 ; k<nbr_coefs(2) ; k++) {
670  m = (k%2==0) ? k/2 : (k-1)/2 ;
671  base.bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
672  for (int j=0 ; j<nbr_coefs(1) ; j++) {
673  index.set(0) = j ; index.set(1) = k ;
674  base.bases_1d[0]->set(index) = CHEB ;
675  }
676  }
677 }
678 
680  set_cheb_base(base) ;
681 }
682 
684  set_legendre_base(base) ;
685 }
686 
687 // standard base for a anti-symetric function in z, using Chebyshev
689 
690  int m ;
691 
692  assert (type_base == CHEB_TYPE) ;
693 
694  base.allocate(nbr_coefs) ;
695 
696  base.def =true ;
697  base.bases_1d[2]->set(0) = COSSIN ;
698 
699  Index index (base.bases_1d[0]->get_dimensions()) ;
700 
701  for (int k=0 ; k<nbr_coefs(2) ; k++) {
702  m = (k%2==0) ? k/2 : (k-1)/2 ;
703  base.bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
704  for (int j=0 ; j<nbr_coefs(1) ; j++) {
705  index.set(0) = j ; index.set(1) = k ;
706  base.bases_1d[0]->set(index) = CHEB ;
707  }
708  }
709 }
710 
712 
713  int m ;
714 
715  assert (type_base == CHEB_TYPE) ;
716 
717  base.allocate(nbr_coefs) ;
718 
719  base.def =true ;
720  base.bases_1d[2]->set(0) = COSSIN ;
721 
722  Index index (base.bases_1d[0]->get_dimensions()) ;
723 
724  for (int k=0 ; k<nbr_coefs(2) ; k++) {
725  m = (k%2==0) ? k/2 : (k-1)/2 ;
726  base.bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
727  for (int j=0 ; j<nbr_coefs(1) ; j++) {
728  index.set(0) = j ; index.set(1) = k ;
729  base.bases_1d[0]->set(index) = CHEB ;
730  }
731  }
732 }
733 
735 
736  int m ;
737 
738  assert (type_base == CHEB_TYPE) ;
739 
740  base.allocate(nbr_coefs) ;
741 
742  base.def =true ;
743  base.bases_1d[2]->set(0) = COSSIN ;
744 
745  Index index (base.bases_1d[0]->get_dimensions()) ;
746 
747  for (int k=0 ; k<nbr_coefs(2) ; k++) {
748  m = (k%2==0) ? k/2 : (k-1)/2 ;
749  base.bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
750  for (int j=0 ; j<nbr_coefs(1) ; j++) {
751  index.set(0) = j ; index.set(1) = k ;
752  base.bases_1d[0]->set(index) = CHEB ;
753  }
754  }
755 }
756 
758 
759  int m ;
760 
761  assert (type_base == CHEB_TYPE) ;
762 
763  base.allocate(nbr_coefs) ;
764 
765  base.def =true ;
766  base.bases_1d[2]->set(0) = COSSIN ;
767 
768  Index index (base.bases_1d[0]->get_dimensions()) ;
769 
770  for (int k=0 ; k<nbr_coefs(2) ; k++) {
771  m = (k%2==0) ? k/2 : (k-1)/2 ;
772  base.bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
773  for (int j=0 ; j<nbr_coefs(1) ; j++) {
774  index.set(0) = j ; index.set(1) = k ;
775  base.bases_1d[0]->set(index) = CHEB ;
776  }
777  }
778 }
779 
780 // standard base for a symetric function in z, using Legendre
782 
783  int m ;
784 
785  assert (type_base == LEG_TYPE) ;
786  base.allocate(nbr_coefs) ;
787 
788  base.def = true ;
789  base.bases_1d[2]->set(0) = COSSIN ;
790 
791  Index index (base.bases_1d[0]->get_dimensions()) ;
792 
793  for (int k=0 ; k<nbr_coefs(2) ; k++) {
794  m = (k%2==0) ? k/2 : (k-1)/2 ;
795  base.bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
796  for (int j=0 ; j<nbr_coefs(1) ; j++) {
797  index.set(0) = j ; index.set(1) = k ;
798  base.bases_1d[0]->set(index) = LEG ;
799  }
800  }
801 }
802 
803 // standard base for a anti-symetric function in z, using Legendre
805 
806  int m ;
807  assert (type_base == LEG_TYPE) ;
808 
809  base.allocate(nbr_coefs) ;
810 
811  base.def = true ;
812  base.bases_1d[2]->set(0) = COSSIN ;
813 
814  Index index (base.bases_1d[0]->get_dimensions()) ;
815 
816  for (int k=0 ; k<nbr_coefs(2) ; k++) {
817  m = (k%2==0) ? k/2 : (k-1)/2 ;
818  base.bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
819  for (int j=0 ; j<nbr_coefs(1) ; j++) {
820  index.set(0) = j ; index.set(1) = k ;
821  base.bases_1d[0]->set(index) = LEG ;
822  }
823  }
824 }
825 
827 
828  int m ;
829 
830  assert (type_base == LEG_TYPE) ;
831 
832  base.allocate(nbr_coefs) ;
833 
834  base.def =true ;
835  base.bases_1d[2]->set(0) = COSSIN ;
836 
837  Index index (base.bases_1d[0]->get_dimensions()) ;
838 
839  for (int k=0 ; k<nbr_coefs(2) ; k++) {
840  m = (k%2==0) ? k/2 : (k-1)/2 ;
841  base.bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
842  for (int j=0 ; j<nbr_coefs(1) ; j++) {
843  index.set(0) = j ; index.set(1) = k ;
844  base.bases_1d[0]->set(index) = LEG ;
845  }
846  }
847 }
848 
850 
851  int m ;
852 
853  assert (type_base == LEG_TYPE) ;
854 
855  base.allocate(nbr_coefs) ;
856 
857  base.def =true ;
858  base.bases_1d[2]->set(0) = COSSIN ;
859 
860  Index index (base.bases_1d[0]->get_dimensions()) ;
861 
862  for (int k=0 ; k<nbr_coefs(2) ; k++) {
863  m = (k%2==0) ? k/2 : (k-1)/2 ;
864  base.bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
865  for (int j=0 ; j<nbr_coefs(1) ; j++) {
866  index.set(0) = j ; index.set(1) = k ;
867  base.bases_1d[0]->set(index) = LEG ;
868  }
869  }
870 }
871 
873 
874  int m ;
875 
876  assert (type_base == LEG_TYPE) ;
877 
878  base.allocate(nbr_coefs) ;
879 
880  base.def =true ;
881  base.bases_1d[2]->set(0) = COSSIN ;
882 
883  Index index (base.bases_1d[0]->get_dimensions()) ;
884 
885  for (int k=0 ; k<nbr_coefs(2) ; k++) {
886  m = (k%2==0) ? k/2 : (k-1)/2 ;
887  base.bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
888  for (int j=0 ; j<nbr_coefs(1) ; j++) {
889  index.set(0) = j ; index.set(1) = k ;
890  base.bases_1d[0]->set(index) = LEG ;
891  }
892  }
893 }
894 
895 // Computes the derivatives with respect to XYZ as a function of the numerical ones.
896 void Domain_shell_inner_adapted::do_der_abs_from_der_var(const Val_domain *const *const der_var , Val_domain **const der_abs) const {
897  Val_domain rr (get_radius()) ;
898  Val_domain dr (*der_var[0] / (*der_rad_term_eq->val_t)()(num_dom)) ;
899  Val_domain dtsr ((*der_var[1] - rr.der_var(2) * dr) / rr);
900  dtsr.set_base() = der_var[1]->get_base() ;
901  Val_domain dpsr ((*der_var[2] - rr.der_var(3) * dr) / rr);
902  dpsr.set_base() = der_var[2]->get_base() ;
903 
904  // d/dx :
905  Val_domain sintdr (dr.mult_sin_theta()) ;
906  Val_domain costdtsr (dtsr.mult_cos_theta()) ;
907 
908  Val_domain dpsrssint (dpsr.div_sin_theta()) ;
909  der_abs[0] = new Val_domain ((sintdr+costdtsr).mult_cos_phi() - dpsrssint.mult_sin_phi()) ;
910 
911  // d/dy :
912  der_abs[1] = new Val_domain ((sintdr+costdtsr).mult_sin_phi() + dpsrssint.mult_cos_phi()) ;
913  // d/dz :
914  der_abs[2] = new Val_domain (dr.mult_cos_theta() - dtsr.mult_sin_theta()) ;
915 }
916 
917 // Rules for the multiplication of two basis.
919 
920  assert (a.ndim==3) ;
921  assert (b.ndim==3) ;
922 
923  Base_spectral res(3) ;
924  bool res_def = true ;
925 
926  if (!a.def)
927  res_def=false ;
928  if (!b.def)
929  res_def=false ;
930 
931  if (res_def) {
932 
933  // Base in phi :
934  res.bases_1d[2] = new Array<int> (a.bases_1d[2]->get_dimensions()) ;
935  switch ((*a.bases_1d[2])(0)) {
936  case COSSIN:
937  switch ((*b.bases_1d[2])(0)) {
938  case COSSIN:
939  res.bases_1d[2]->set(0) = COSSIN ;
940  break ;
941  default:
942  res_def = false ;
943  break ;
944  }
945  break ;
946  default:
947  res_def = false ;
948  break ;
949  }
950 
951  // Bases in theta :
952  // On check l'alternance :
953  Index index_1 (a.bases_1d[1]->get_dimensions()) ;
954  res.bases_1d[1] = new Array<int> (a.bases_1d[1]->get_dimensions()) ;
955  do {
956  switch ((*a.bases_1d[1])(index_1)) {
957  case COS_EVEN:
958  switch ((*b.bases_1d[1])(index_1)) {
959  case COS_EVEN:
960  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
961  break ;
962  case COS_ODD:
963  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
964  break ;
965  case SIN_EVEN:
966  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
967  break ;
968  case SIN_ODD:
969  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
970  break ;
971  default:
972  res_def = false ;
973  break ;
974  }
975  break ;
976  case COS_ODD:
977  switch ((*b.bases_1d[1])(index_1)) {
978  case COS_EVEN:
979  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
980  break ;
981  case COS_ODD:
982  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
983  break ;
984  case SIN_EVEN:
985  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
986  break ;
987  case SIN_ODD:
988  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
989  break ;
990  default:
991  res_def = false ;
992  break ;
993  }
994  break ;
995  case SIN_EVEN:
996  switch ((*b.bases_1d[1])(index_1)) {
997  case COS_EVEN:
998  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
999  break ;
1000  case COS_ODD:
1001  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
1002  break ;
1003  case SIN_EVEN:
1004  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
1005  break ;
1006  case SIN_ODD:
1007  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
1008  break ;
1009  default:
1010  res_def = false ;
1011  break ;
1012  }
1013  break ;
1014  case SIN_ODD:
1015  switch ((*b.bases_1d[1])(index_1)) {
1016  case COS_EVEN:
1017  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
1018  break ;
1019  case COS_ODD:
1020  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
1021  break ;
1022  case SIN_EVEN:
1023  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
1024  break ;
1025  case SIN_ODD:
1026  res.bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
1027  break ;
1028  default:
1029  res_def = false ;
1030  break ;
1031  }
1032  break ;
1033  default:
1034  res_def = false ;
1035  break ;
1036  }
1037  }
1038  while (index_1.inc()) ;
1039 
1040 
1041  // Base in r :
1042  Index index_0 (a.bases_1d[0]->get_dimensions()) ;
1043  res.bases_1d[0] = new Array<int> (a.bases_1d[0]->get_dimensions()) ;
1044  do {
1045  switch ((*a.bases_1d[0])(index_0)) {
1046  case CHEB:
1047  switch ((*b.bases_1d[0])(index_0)) {
1048  case CHEB:
1049  res.bases_1d[0]->set(index_0) = CHEB ;
1050  break ;
1051  default:
1052  res_def = false ;
1053  break ;
1054  }
1055  break ;
1056  case LEG:
1057  switch ((*b.bases_1d[0])(index_0)) {
1058  case LEG:
1059  res.bases_1d[0]->set(index_0) = LEG ;
1060  break ;
1061  default:
1062  res_def = false ;
1063  break ;
1064  }
1065  break ;
1066  default:
1067  res_def = false ;
1068  break ;
1069  }
1070  }
1071  while (index_0.inc()) ;
1072  }
1073 
1074  if (!res_def)
1075  for (int dim=0 ; dim<a.ndim ; dim++)
1076  if (res.bases_1d[dim]!= nullptr) {
1077  delete res.bases_1d[dim] ;
1078  res.bases_1d[dim] = nullptr ;
1079  }
1080  res.def = res_def ;
1081  return res ;
1082 }
1083 
1085  int res = -1 ;
1086  if (strcmp(p,"R ")==0)
1087  res = 0 ;
1088  if (strcmp(p,"T ")==0)
1089  res = 1 ;
1090  if (strcmp(p,"P ")==0)
1091  res = 2 ;
1092  return res ;
1093 }
1094 
1095 void Domain_shell_inner_adapted::update_constante (const Val_domain& cor_inner_radius, const Scalar& old, Scalar& res) const {
1096 
1097  Point MM(3) ;
1098  Index pos(nbr_points) ;
1100  do {
1101 
1102  double rr = (outer_radius - cor_inner_radius(pos) - (*inner_radius)(pos)) * (*coloc[0])(pos(0)) / 2.
1103  + (outer_radius + cor_inner_radius(pos) + (*inner_radius)(pos)) / 2.;
1104  double theta = (*coloc[1])(pos(1)) ;
1105  double phi = (*coloc[2])(pos(2)) ;
1106 
1107  MM.set(1) = rr*sin(theta)*cos(phi) + center(1);
1108  MM.set(2) = rr*sin(theta)*sin(phi) + center(2) ;
1109  MM.set(3) = rr*cos(theta) + center(3) ;
1110 
1111  res.set_domain(num_dom).set(pos) = old.val_point(MM, +1) ;
1112 
1113  }
1114  while (pos.inc()) ;
1115 
1116  res.set_domain(num_dom).set_base() = old(num_dom).get_base() ;
1117 }
1118 }
1119 
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
double summation(const Point &num, const Array< double > &tab) const
Computes the spectral summation.
void allocate(const Dim_array &nbr_coefs)
Allocates the various arrays, for a given number of coefficients.
bool def
true if the Base_spectral is defined and false otherwise.
int ndim
Number of dimensions.
Class for storing the dimensions of an array.
Definition: dim_array.hpp:34
int get_ndim() const
Returns the number of dimensions.
Definition: dim_array.hpp:63
int & set(int i)
Read/write of the size of a given dimension.
Definition: dim_array.hpp:54
void save(FILE *) const
Save function.
Definition: dim_array.cpp:32
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: adapted.hpp:51
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
Definition: adapted.hpp:76
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
virtual void affecte_coef(int &, int, bool &) const
The variation of the functions describing the shape of the Domain are affected from the unknowns of t...
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_legendre_base_t_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
virtual const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual void update_mapping(const Val_domain &)
Updates the variables parts of the Domain.
virtual void set_cheb_base_r_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the radial component of a vector.
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
virtual void set_cheb_base_p_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
Definition: adapted.hpp:72
virtual void do_coloc()
Computes the colocation points.
virtual void update_variable(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
double outer_radius
The outer radius .
Definition: adapted.hpp:60
virtual void xx_to_vars_from_adapted(Val_domain &, const Array< double > &, int &) const
Computes the new boundary of a Domain from a set of values.
void set_mapping(const Val_domain &so) const
Affects the inner radius.
virtual void set_cheb_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for the radius.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the inner boundary, in orthonormal spherical c...
Definition: adapted.hpp:64
void do_normal_cart() const
Computes the normal wrt the inner boundary, in Cartesian coordinates.
virtual void xx_to_ders_from_adapted(const Array< double > &, int &) const
Affects the derivative part of variable a Domain from a set of values.
virtual void set_legendre_base_r_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector.
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
virtual void set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
Val_domain * inner_radius
Pointer on the inner boundary , as a Val_domain.
Definition: adapted.hpp:58
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Definition: adapted.hpp:57
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
Definition: adapted.hpp:80
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the inner boundary, in Cartesian coordinates.
Definition: adapted.hpp:68
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
Term_eq * inner_radius_term_eq
Pointer on the inner boundary , as a Term_eq.
Definition: adapted.hpp:59
virtual void set_anti_cheb_base(Base_spectral &) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual void vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual const Point absol_to_num_bound(const Point &, int) const
Computes the numerical coordinates from the physical ones for a point lying on a boundary.
virtual void set_legendre_base_p_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
Domain_shell_inner_adapted(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
virtual void update_constante(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual void do_cart() const
Computes the Cartesian coordinates.
Point center
Absolute coordinates of the center.
Definition: adapted.hpp:86
virtual void do_der_abs_from_der_var(const Val_domain *const *const der_var, Val_domain **const der_abs) const
Computes the derivative with respect to the absolute Cartesian coordinates from the derivative with r...
virtual void save(FILE *) const
Saving function.
virtual void do_radius() const
Computes the generalized radius.
Term_eq * dp_rad_term_eq
Pointer on the Term_eq containing the .
Definition: adapted.hpp:84
virtual void do_absol() const
Computes the absolute coordinates.
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
Val_domain * radius
The generalized radius.
Definition: space.hpp:78
Memory_mapped_array< Val_domain * > cart
Cartesian coordinates.
Definition: space.hpp:77
Memory_mapped_array< Val_domain * > absol
Asbolute coordinates (if defined ; usually Cartesian-like)
Definition: space.hpp:76
int ndim
Number of dimensions.
Definition: space.hpp:64
Memory_mapped_array< Val_domain * > cart_surr
Cartesian coordinates divided by the radius.
Definition: space.hpp:79
int num_dom
Number of the current domain (used by the Space)
Definition: space.hpp:63
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
Val_domain const & get_radius() const
Returns the generalized radius.
Definition: space.hpp:1465
Dim_array nbr_points
Number of colocation points.
Definition: space.hpp:65
int type_base
Type of colocation point :
Definition: space.hpp:73
Memory_mapped_array< Array< double > * > coloc
Colocation points in each dimension (stored in ndim 1d- arrays)
Definition: space.hpp:75
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
int & set(int i)
Read/write of the position in a given dimension.
Definition: index.hpp:72
void set_start()
Sets the position to zero in all dimensions.
Definition: index.hpp:88
bool inc(int increm, int var=0)
Increments the position of the Index.
Definition: index.hpp:99
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
void save(FILE *) const
Saving function.
Definition: point.cpp:33
const int & get_ndim() const
Returns the number of dimensions.
Definition: point.hpp:51
double & set(int i)
Read/write of a coordinate.
Definition: point.hpp:47
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
double val_point(const Point &xxx, int sens=-1) const
Computes the value of the field at a given point, by doing the spectral summation.
Definition: scalar.cpp:62
The Space class is an ensemble of domains describing the whole space of the computation.
Definition: space.hpp:1362
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
Definition: term_eq.hpp:69
void set_der_t(Tensor)
Sets the tensorial variation (only the values in the pertinent Domain are copied).
Definition: term_eq.cpp:171
void set_der_zero()
Sets the variation of the approriate type to zero.
Definition: term_eq.cpp:187
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Definition: term_eq.hpp:68
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
Val_domain mult_sin_phi() const
Multiplication by .
void save(FILE *) const
Saving on a file.
Definition: val_domain.cpp:110
void set_in_coef()
Destroys the values in the configuration space.
Definition: val_domain.cpp:203
void set_zero()
Sets the Val_domain to zero (logical state to zero and arrays destroyed).
Definition: val_domain.cpp:223
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration space.
Definition: val_domain.cpp:216
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
Val_domain mult_sin_theta() const
Multiplication by .
Val_domain mult_cos_phi() const
Multiplication by .
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
Definition: val_domain.hpp:77
void std_r_base()
Sets the basis for the radius.
Definition: val_domain.cpp:262
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Definition: val_domain.cpp:171
void std_base()
Sets the standard basis of decomposition.
Definition: val_domain.cpp:246
Val_domain div_sin_theta() const
Division by .
Val_domain mult_cos_theta() const
Multiplication by .
void coef() const
Computes the coefficients.
Definition: val_domain.cpp:622
Val_domain der_var(int i) const
Computes the derivative with respect to a numerical coordinate.
Definition: val_domain.cpp:670
Base_spectral & set_base()
Sets the basis of decomposition.
Definition: val_domain.hpp:126
Array< double > get_coef() const
Definition: val_domain.hpp:136
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
Definition: val_domain.cpp:209
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122