KADATH
val_domain.hpp
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 #ifndef __VAL_DOMAIN_HPP_
21 #define __VAL_DOMAIN_HPP_
22 
23 #include "space.hpp"
24 #include "dim_array.hpp"
25 #include "base_spectral.hpp"
26 namespace Kadath {
27 
28  Val_domain sin(const Val_domain& ) ;
29  Val_domain cos(const Val_domain& ) ;
30  Val_domain operator+ (const Val_domain&) ;
31  Val_domain operator- (const Val_domain&) ;
32  Val_domain operator+ (const Val_domain&, const Val_domain&) ;
33  Val_domain operator+ (const Val_domain&, double) ;
34  Val_domain operator+ (double, const Val_domain&) ;
35  Val_domain operator- (const Val_domain&, const Val_domain&) ;
36  Val_domain operator- (const Val_domain&, double) ;
37  Val_domain operator- (double, const Val_domain&) ;
38  Val_domain operator* (const Val_domain&, const Val_domain&) ;
39  Val_domain operator* (const Val_domain&, double) ;
40  Val_domain operator* (double, const Val_domain&) ;
41  Val_domain operator* (const Val_domain&, int) ;
42  Val_domain operator* (int, const Val_domain&) ;
43  Val_domain operator* (const Val_domain&, long int) ;
44  Val_domain operator* (long int, const Val_domain&) ;
45  Val_domain operator/ (const Val_domain&, const Val_domain&) ;
46  Val_domain operator/ (const Val_domain&, double) ;
47  Val_domain operator/ (double, const Val_domain&) ;
48  Val_domain pow (const Val_domain&, int) ;
49  Val_domain pow (const Val_domain&, double) ;
50  Val_domain sqrt (const Val_domain&) ;
51  Val_domain exp (const Val_domain&) ;
52  Val_domain log (const Val_domain&) ;
53  Val_domain atanh(const Val_domain&);
54  double diffmax (const Val_domain&, const Val_domain&) ;
55  Val_domain bessel_jl (const Val_domain&, int) ;
56  Val_domain bessel_yl (const Val_domain&, int) ;
57  Val_domain bessel_djl (const Val_domain&, int) ;
58  Val_domain bessel_dyl (const Val_domain&, int) ;
59  Val_domain atan (const Val_domain&) ;
60  double maxval (const Val_domain&) ;
61 
69  class Val_domain : public Memory_mapped {
70  protected:
71  const Domain* zone ;
73 
74  bool is_zero ;
75 
76  mutable Array<double>* c ;
77  mutable Array<double>* cf ;
78  mutable bool in_conf ;
79  mutable bool in_coef ;
80 
81  mutable Memory_mapped_array<Val_domain*> p_der_var ;
82  mutable Memory_mapped_array<Val_domain*> p_der_abs ;
83 
84  private:
85  void del_deriv() const ;
86  void compute_der_var() const ;
87  void compute_der_abs() const ;
88 
89  public:
95  Val_domain (const Domain* so) ;
101  Val_domain (const Val_domain& so, bool const copy=true) ;
102  Val_domain(Val_domain &&) noexcept;
103  Val_domain (const Domain* so, FILE*) ;
104  ~Val_domain() ;
105 
106  void save (FILE*) const ;
107 
111  const Domain* get_domain() const {return zone ;}
112  void swap(Val_domain & so) noexcept;
113  void operator= (const Val_domain&) ;
114  Val_domain & operator=(Val_domain &&) noexcept;
115  void operator= (double) ;
116  void annule_hard() ;
117  void annule_hard_coef() ;
118 
122  const Base_spectral& get_base() const {return base ;} ;
126  Base_spectral& set_base() {return base ;} ;
127 
131  Array<double> get_conf() const {return *c ;} ;
132 
136  Array<double> get_coef() const {return *cf ;} ;
137 
138  void set_zero() ;
142  bool check_if_zero() const {return is_zero ;} ;
143 
144  public:
148  void set_in_conf() ;
152  void set_in_coef() ;
156  void allocate_conf() ;
160  void allocate_coef() ;
161  void std_base() ;
162  void std_anti_base() ;
163  void std_base(int m) ;
164  void std_anti_base(int m) ;
165  void std_base_r_spher() ;
166  void std_base_t_spher() ;
167  void std_base_p_spher() ;
168  void std_base_x_cart() ;
169  void std_base_y_cart() ;
170  void std_base_z_cart() ;
171  void std_r_base() ;
172 
173  void std_base_rt_spher() ;
174  void std_base_rp_spher() ;
175  void std_base_tp_spher() ;
176  void std_base_xy_cart() ;
177  void std_base_xz_cart() ;
178  void std_base_yz_cart() ;
179 
180  void std_xodd_base() ;
181  void std_todd_base() ;
182  void std_xodd_todd_base() ;
183 
184  void std_base_odd() ;
185 
186  void std_base_r_mtz() ;
187  void std_base_t_mtz() ;
188  void std_base_p_mtz() ;
189 
194  double& set(const Index& pos) ;
199  double& set_coef(const Index& pos) ;
204  double get_coef (const Index& pos) const ;
205 
210  double operator()(const Index& pos) const ;
211  void coef() const ;
212  void coef_i() const ;
213 
219  Val_domain der_var (int i) const ;
225  Val_domain der_abs (int i) const ;
231  Val_domain der_spher (int i) const ;
232  Val_domain der_r () const ;
233  Val_domain der_t () const ;
234  Val_domain der_p () const ;
235  Val_domain mult_sin_theta () const ;
236  Val_domain mult_cos_theta () const ;
237  Val_domain mult_sin_phi () const ;
238  Val_domain mult_cos_phi () const ;
239  Val_domain div_sin_theta () const ;
240  Val_domain div_cos_theta () const ;
241  Val_domain div_x () const ;
242  Val_domain div_xm1 () const ;
243  Val_domain div_xp1 () const ;
244  Val_domain mult_xm1 () const ;
245  Val_domain div_1mx2 () const ;
246  Val_domain div_1mrsL () const ;
247  Val_domain div_sin_chi () const ;
248  Val_domain div_chi () const ;
249  Val_domain div_r () const ;
250  Val_domain mult_r () const ;
251  Val_domain der_r_rtwo () const ;
252  Val_domain mult_cos_time() const ;
253  Val_domain mult_sin_time() const ;
254 
255  double integrale() const ;
256  double integ_volume() const ;
257 
258  void operator+= (const Val_domain&) ;
259  void operator-= (const Val_domain&) ;
260  void operator*= (const Val_domain&) ;
261  void operator/= (const Val_domain&) ;
262  void operator+= (double) ;
263  void operator-= (double) ;
264  void operator*= (double) ;
265  void operator/= (double) ;
266 
267  friend class Space ;
268  friend class Space_spheric ;
269  friend class Scalar ;
270  friend class Domain_nucleus ;
271  friend class Domain_shell ;
272  friend class Domain_shell_log ;
273  friend class Domain_shell_surr ;
274  friend class Domain_compact ;
275  friend class Domain_bispheric_rect ;
276  friend class Domain_bispheric_chi_first ;
277  friend class Domain_bispheric_eta_first ;
278  friend class Domain_critic_inner ;
279  friend class Domain_critic_outer ;
280  friend class Domain_polar_nucleus ;
281  friend class Domain_polar_shell ;
282  friend class Domain_polar_shell_inner_adapted ;
283  friend class Domain_polar_shell_outer_adapted ;
284  friend class Domain_polar_compact ;
285  friend class Domain_oned_ori ;
286  friend class Domain_oned_qcq ;
287  friend class Domain_oned_inf ;
288  friend class Domain_spheric_periodic_nucleus ;
289  friend class Domain_spheric_periodic_shell ;
290  friend class Domain_spheric_periodic_compact ;
291  friend class Domain_spheric_time_nucleus ;
292  friend class Domain_spheric_time_shell ;
293  friend class Domain_spheric_time_compact ;
294  friend class Domain_shell_outer_adapted ;
295  friend class Domain_shell_inner_adapted ;
296  friend class Domain_shell_inner_homothetic ;
297  friend class Domain_shell_outer_homothetic ;
298  friend class Domain_nucleus_symphi ;
299  friend class Domain_shell_symphi ;
300  friend class Domain_compact_symphi ;
301  friend class Domain_polar_periodic_nucleus ;
302  friend class Domain_polar_periodic_shell ;
303  friend class Domain_fourD_periodic_nucleus ;
304  friend class Domain_fourD_periodic_shell ;
305 
306 
307  friend class Eq_matching_non_std ;
308  friend ostream& operator<< (ostream&, const Val_domain&) ;
309  friend Val_domain sin(const Val_domain& ) ;
310  friend Val_domain cos(const Val_domain& ) ;
311  friend Val_domain sinh(const Val_domain& ) ;
312  friend Val_domain cosh(const Val_domain& ) ;
313  friend Val_domain operator+ (const Val_domain&) ;
314  friend Val_domain operator- (const Val_domain&) ;
315  friend Val_domain operator+ (const Val_domain&, const Val_domain&) ;
316  friend Val_domain operator+ (const Val_domain&, double) ;
317  friend Val_domain operator+ (double, const Val_domain&) ;
318  friend Val_domain operator- (const Val_domain&, const Val_domain&) ;
319  friend Val_domain operator- (const Val_domain&, double) ;
320  friend Val_domain operator- (double, const Val_domain&) ;
321  friend Val_domain operator* (const Val_domain&, const Val_domain&) ;
322  friend Val_domain operator* (const Val_domain&, double) ;
323  friend Val_domain operator* (double, const Val_domain&) ;
324  friend Val_domain operator* (const Val_domain&, int) ;
325  friend Val_domain operator* (int, const Val_domain&) ;
326  friend Val_domain operator* (const Val_domain&, long int) ;
327  friend Val_domain operator* (long int, const Val_domain&) ;
328  friend Val_domain operator/ (const Val_domain&, const Val_domain&) ;
329  friend Val_domain operator/ (const Val_domain&, double) ;
330  friend Val_domain operator/ (double, const Val_domain&) ;
331  friend Val_domain pow (const Val_domain&, int) ;
332  friend Val_domain pow (const Val_domain&, double) ;
333  friend Val_domain sqrt (const Val_domain&) ;
334  friend Val_domain exp (const Val_domain&) ;
335  friend Val_domain log (const Val_domain&) ;
336  friend Val_domain atanh(const Val_domain&);
337  friend Val_domain bessel_jl (const Val_domain&, int) ;
338  friend Val_domain bessel_yl (const Val_domain&, int) ;
339  friend Val_domain atan (const Val_domain&) ;
340  friend double diffmax (const Val_domain&, const Val_domain&) ;
341  friend double maxval (const Val_domain&) ;
342  } ;
343 }
344 #endif
Class for storing the basis of decompositions of a field.
Class for bispherical coordinates with a symmetry with respect to the plane .
Definition: bispheric.hpp:460
Class for bispherical coordinates with a symmetry with respect to the plane .
Definition: bispheric.hpp:878
Class for bispherical coordinates with a symmetry with respect to the plane .
Definition: bispheric.hpp:64
Class for a spherical compactified domain and a symmetry with respect to the plane and a quadrant sy...
Class for a spherical compactified domain and a symmetry with respect to the plane .
Definition: spheric.hpp:1007
Class for a 2-dimensional cylindrical type domain.
Definition: critic.hpp:45
Class for a 2-dimensional cylindrical type domain.
Definition: critic.hpp:197
Class for a spherical nucleus.
Class for a spherical shell.
Class for a spherical domain containing the origin a symmetry with respect to the plane and an quadr...
Class for a spherical domain containing the origin and a symmetry with respect to the plane .
Definition: spheric.hpp:66
Class for a 1-dimensional compactified spherical domain.
Definition: oned.hpp:319
Class for a 1-dimensional spherical domain containing the origin.
Definition: oned.hpp:40
Class for a 1-dimensional spherical domain bounded between two raii.
Definition: oned.hpp:179
Class for a 2-dimensional spherical shell and a symmetry with respect to the plane .
Definition: polar.hpp:408
Class for a 2-dimensional spherical domain containing the origin and a symetry with respect to the pl...
Definition: polar.hpp:45
Class for a spherical nucleus with a symmetry in .
Class for a spherical shell with a symmetry in .
Class for a spherical-like domain, having a symmetry with respect to the plane .
Class for a spherical-like domain, having a symmetry with respect to the plane .
Class for a 2-dimensional spherical shell and a symmetry with respect to the plane .
Definition: polar.hpp:221
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: adapted.hpp:51
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: homothetic.hpp:45
Class for a spherical shell and a symmetry with respect to the plane .
Definition: spheric.hpp:1507
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: adapted.hpp:367
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: homothetic.hpp:105
Class for a spherical shell and a symmetry with respect to the plane .
Definition: spheric.hpp:1597
Class for a spherical shell and a symmetry with respect to the plane and an quadrant symmetry wrt .
Class for a spherical shell and a symmetry with respect to the plane .
Definition: spheric.hpp:555
Class for a 2-dimensional compactified spherical domain and a symetry with respect to the plane .
Class for a 2-dimensional spherical domain containing the origin and a symetry with respect to the pl...
Class for a 2-dimensional spherical domain bounded between two fixed radii and a symetry with respect...
Class for a 2-dimensional compactified spherical domain and a symetry with respect to the plane .
Class for a 2-dimensional spherical domain containing the origin and a symetry with respect to the pl...
Class for a 2-dimensional spherical domain bounded between two finite radii and a symetry with respec...
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
Class for an equation representing the matching of quantities accross a boundary.
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
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 for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
double operator()(const Index &pos) const
Read only value of the field in the configuration space.
Definition: val_domain.cpp:192
friend Val_domain bessel_yl(const Val_domain &, int)
Operator Bessel function.
Val_domain mult_sin_phi() const
Multiplication by .
void std_base_r_spher()
Sets the basis for the radial component of a vector in orthonormal spherical coordinates.
Definition: val_domain.cpp:412
void operator/=(const Val_domain &)
Operator /=.
friend Val_domain log(const Val_domain &)
Operator logarithm.
void std_base_p_mtz()
Sets the basis for the component of a vector in orthonormal coordinates in the MTZ context.
Definition: val_domain.cpp:540
Base_spectral base
Spectral basis of the field.
Definition: val_domain.hpp:72
friend double diffmax(const Val_domain &, const Val_domain &)
Maximal difference.
Val_domain div_cos_theta() const
Division by .
void set_in_conf()
Destroys the values in the coefficient space.
Definition: val_domain.cpp:197
void std_todd_base()
Sets the basis for an odd function in (Critic case).
Definition: val_domain.cpp:573
void std_base_t_mtz()
Sets the basis for the component of a vector in orthonormal coordinates in the MTZ context.
Definition: val_domain.cpp:524
void operator=(const Val_domain &)
Assignement to another Val_domain.
Definition: val_domain.cpp:130
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
double & set_coef(const Index &pos)
Read/write the value of the field in the coefficient space.
Definition: val_domain.cpp:177
friend Val_domain atanh(const Val_domain &)
Operator atanh.
void swap(Val_domain &so) noexcept
Swaps the content with the source.
Definition: val_domain.cpp:47
void set_zero()
Sets the Val_domain to zero (logical state to zero and arrays destroyed).
Definition: val_domain.cpp:223
double integrale() const
Definition: val_domain.cpp:756
void std_base_y_cart()
Sets the basis for the Y-component of a vector in Cartesian coordinates.
Definition: val_domain.cpp:476
Val_domain div_r() const
Division by the radius.
Definition: val_domain.cpp:743
Val_domain div_xm1() const
Division by .
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration space.
Definition: val_domain.cpp:216
void std_base_tp_spher()
Sets the basis for the component of a 2-tensor in orthonormal spherical coordinates.
Definition: val_domain.cpp:356
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
friend Val_domain sinh(const Val_domain &)
Hyperbolic sine operator.
friend Val_domain pow(const Val_domain &, int)
Operator power (integer version)
Val_domain der_r() const
Definition: val_domain.cpp:726
Array< double > get_conf() const
Definition: val_domain.hpp:131
Val_domain mult_sin_theta() const
Multiplication by .
bool in_conf
Is the field known in the configuration space ?
Definition: val_domain.hpp:78
Val_domain div_chi() const
Division by .
Val_domain div_xp1() const
Division by .
void compute_der_abs() const
Computes the derivatives with respect to the absolute Cartesian coordinates.
Definition: val_domain.cpp:783
void std_base_xy_cart()
Sets the basis for the XY component of a 2-tensor in Cartesian coordinates.
Definition: val_domain.cpp:370
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 del_deriv() const
Delete the derived quantities.
Definition: val_domain.cpp:124
void std_r_base()
Sets the basis for the radius.
Definition: val_domain.cpp:262
Val_domain div_x() const
Division by .
void coef_i() const
Computes the values in the configuration space.
Definition: val_domain.cpp:637
friend Val_domain exp(const Val_domain &)
Operator exponential.
friend Val_domain cos(const Val_domain &)
Cosine operator.
friend Val_domain sqrt(const Val_domain &)
Operator square root.
friend Val_domain sin(const Val_domain &)
Sine operator.
void std_base_x_cart()
Sets the basis for the X-component of a vector in Cartesian coordinates.
Definition: val_domain.cpp:460
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Definition: val_domain.cpp:171
void std_base_xz_cart()
Sets the basis for the XZ component of a 2-tensor in Cartesian coordinates.
Definition: val_domain.cpp:384
void std_xodd_base()
Sets the basis for an odd function in (Critic case).
Definition: val_domain.cpp:557
friend Val_domain atan(const Val_domain &)
Operator arctangent.
bool is_zero
Indicator used for null fields (for speed issues).
Definition: val_domain.hpp:74
Val_domain div_1mrsL() const
Division by .
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 std_base_yz_cart()
Sets the basis for the YZ component of a 2-tensor in Cartesian coordinates.
Definition: val_domain.cpp:398
Val_domain der_t() const
Definition: val_domain.cpp:730
friend Val_domain operator*(const Val_domain &, const Val_domain &)
Operator *.
friend Val_domain operator+(const Val_domain &)
Operator + (unitary version)
void operator*=(const Val_domain &)
Operator *=.
Val_domain der_r_rtwo() const
Definition: val_domain.cpp:739
friend Val_domain operator-(const Val_domain &)
Operator - (unitary version)
Val_domain mult_xm1() const
Multiplication by .
friend ostream & operator<<(ostream &, const Val_domain &)
Output operator.
Definition: val_domain.cpp:653
bool in_coef
Is the field known in the coefficient space ?
Definition: val_domain.hpp:79
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
Memory_mapped_array< Val_domain * > p_der_var
Pointers on the derivatives of the field with respect to the numerical coordinates.
Definition: val_domain.hpp:81
double integ_volume() const
Definition: val_domain.cpp:763
void std_base_z_cart()
Sets the basis for the Z-component of a vector in Cartesian coordinates.
Definition: val_domain.cpp:492
void operator-=(const Val_domain &)
Operator -=.
void annule_hard_coef()
Sets all the arrays to zero in the coefficient space (the logical state is NOT set to zero).
Definition: val_domain.cpp:165
Base_spectral & set_base()
Sets the basis of decomposition.
Definition: val_domain.hpp:126
Val_domain mult_r() const
Multiplication by the radius.
Definition: val_domain.cpp:750
void std_base_t_spher()
Sets the basis for the component of a vector in orthonormal spherical coordinates.
Definition: val_domain.cpp:428
Val_domain mult_sin_time() const
void std_anti_base()
Sets the standard, anti-symetric, basis of decomposition.
Definition: val_domain.cpp:279
Array< double > get_coef() const
Definition: val_domain.hpp:136
void std_base_r_mtz()
Sets the basis for the radial component of a vector in orthonormal coordinates in the MTZ context.
Definition: val_domain.cpp:508
void std_base_p_spher()
Sets the basis for the component of a vector in orthonormal spherical coordinates.
Definition: val_domain.cpp:444
void std_xodd_todd_base()
Sets the basis for an odd function in and (Critic case).
Definition: val_domain.cpp:589
Val_domain div_1mx2() const
Division by .
Array< double > * c
Pointer on the Array of the values in the configuration space.
Definition: val_domain.hpp:76
Val_domain der_spher(int i) const
Computes the derivative with respect to the spherical coordinates (if defined).
Definition: val_domain.cpp:699
friend Val_domain operator/(const Val_domain &, const Val_domain &)
Operator /.
Memory_mapped_array< Val_domain * > p_der_abs
Pointers on the derivatives of the field with respect to the absolute Cartesian coordinates.
Definition: val_domain.hpp:82
void std_base_odd()
Sets the basis in odd polynomials.
Definition: val_domain.cpp:605
void std_base_rp_spher()
Sets the basis for the component of a 2-tensor in orthonormal spherical coordinates.
Definition: val_domain.cpp:342
Val_domain(const Domain *so)
Constructor from a Domain.
Definition: val_domain.cpp:23
friend double maxval(const Val_domain &)
Maximal value.
Val_domain mult_cos_time() const
Val_domain der_abs(int i) const
Computes the derivative with respect to an absolute coordinate (typically Cartesian).
Definition: val_domain.cpp:681
void annule_hard()
Sets all the arrays to zero (the logical state is NOT set to zero).
Definition: val_domain.cpp:159
friend Val_domain cosh(const Val_domain &)
Hyperbolic cosine operator.
void compute_der_var() const
Computes the derivatives with respect to the numerical coordinates.
Definition: val_domain.cpp:771
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
Definition: val_domain.cpp:209
Val_domain div_sin_chi() const
Division by .
void operator+=(const Val_domain &)
Operator +=.
const Domain * get_domain() const
Definition: val_domain.hpp:111
friend Val_domain bessel_jl(const Val_domain &, int)
Operator Bessel function.
Val_domain der_p() const
Definition: val_domain.cpp:734
void std_base_rt_spher()
Sets the basis for the component of a 2-tensor in orthonormal spherical coordinates.
Definition: val_domain.cpp:328
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122
const Domain * zone
Pointer to the associated Domain.
Definition: val_domain.hpp:71