KADATH
domain_shell_symphi_ope.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 "spheric_symphi.hpp"
22 #include "val_domain.hpp"
23 #include "array_math.hpp"
24 namespace Kadath {
25 int mult_cos_1d (int, Array<double>&) ;
26 int mult_sin_1d (int, Array<double>&) ;
27 int div_sin_1d (int, Array<double>&) ;
28 int div_cos_1d (int, Array<double>&) ;
29 int mult_x_1d (int, Array<double>&) ;
30 int div_xp1_1d (int, Array<double>&) ;
31 int div_xm1_1d (int, Array<double>&) ;
32 int mult_xm1_1d (int, Array<double>&) ;
33 int div_1mx2_1d (int, Array<double>&) ;
34 
35 
37  so.coef() ;
38  Val_domain res(this) ;
39 
40  res.base= so.base ;
41 
42  res.cf = new Array<double> (so.base.ope_1d(mult_cos_1d, 2, *so.cf, res.base)) ;
43  res.in_coef = true ;
44  return res ;
45 }
46 
48  so.coef() ;
49  Val_domain res(this) ;
50 
51  res.base= so.base ;
52 
53  res.cf = new Array<double> (so.base.ope_1d(mult_sin_1d, 2, *so.cf, res.base)) ;
54  res.in_coef = true ;
55  return res ;
56 }
57 
59  so.coef() ;
60  Val_domain res(this) ;
61  res.base = so.base ;
62  res.cf = new Array<double> (so.base.ope_1d(mult_cos_1d, 1, *so.cf, res.base)) ;
63  res.in_coef = true ;
64  return res ;
65 }
66 
68 
69  so.coef() ;
70  Val_domain res(this) ;
71 
72  res.base= so.base ;
73  res.cf = new Array<double> (so.base.ope_1d(mult_sin_1d, 1, *so.cf, res.base)) ;
74  res.in_coef = true ;
75  return res ;
76 }
77 
79  so.coef() ;
80  Val_domain res(this) ;
81 
82  res.base = so.base ;
83 
84  res.cf = new Array<double> (so.base.ope_1d(div_sin_1d, 1, *so.cf, res.base)) ;
85  res.in_coef = true ;
86  return res ;
87 }
88 
90  so.coef() ;
91  Val_domain res(this) ;
92 
93  res.base = so.base ;
94 
95  res.cf = new Array<double> (so.base.ope_1d(div_cos_1d, 1, *so.cf, res.base)) ;
96  res.in_coef = true ;
97  return res ;
98 }
99 
100 
102  so.coef() ;
103  Val_domain res(this) ;
104 
105  res.base= so.base ;
106 
107  res.cf = new Array<double> (so.base.ope_1d(mult_x_1d, 0, *so.cf, res.base)*alpha + (*so.cf)*beta) ;
108  res.in_coef = true ;
109  return res ;
110 }
111 
113  if (so.check_if_zero())
114  return so;
115  Val_domain res(so*(1.-get_radius()/(alpha+beta))) ;
116 
117  res.base= so.base ;
118  return res ;
119 }
120 
122  if (so.check_if_zero())
123  return so;
124  so.coef() ;
125  Val_domain res(this) ;
126 
127  res.base= so.base ;
128 
129  res.cf = new Array<double> (-(alpha+beta)/alpha*so.base.ope_1d(div_xm1_1d, 0, *so.cf, res.base)) ;
130  res.in_coef = true ;
131  return res ;
132 }
133 
134 
135 
137  Val_domain res (so / get_radius()) ;
138  res.base = so.base ;
139  return (res) ;
140 }
141 
142 
144  return (so.der_var(1)/alpha) ;
145 }
146 
148 
149  switch (which_var) {
150  case 0 :
151  return so.der_r() ;
152  break ;
153  case 1 :
154  return so.der_var(2) ;
155  break ;
156  case 2 :
157  return so.der_var(3) ;
158  default:
159  cerr << "Unknown variable in Domain_shell_symphi::der_partial_var" << endl ;
160  abort() ;
161  }
162 }
163 
165  return (so.der_var(3).der_var(3)) ;
166 }
167 
169  so.coef() ;
170  Val_domain res(this) ;
171 
172  res.base = so.base ;
173 
174  res.cf = new Array<double> (so.base.ope_1d(div_xm1_1d, 0, *so.cf, res.base)) ;
175  res.in_coef = true ;
176  return res ;
177 }
178 
180  so.coef() ;
181  Val_domain res(this) ;
182 
183  res.base= so.base ;
184 
185  res.cf = new Array<double> (so.base.ope_1d(mult_xm1_1d, 0, *so.cf, res.base)) ;
186  res.in_coef = true ;
187  return res ;
188 }
189 
191  so.coef() ;
192  Val_domain res(this) ;
193 
194  res.base= so.base ;
195 
196  res.cf = new Array<double> (so.base.ope_1d(div_1mx2_1d, 0, *so.cf, res.base)) ;
197  res.in_coef = true ;
198  return res ;
199 }
200 
201 
202 
203 double integral_1d (int, const Array<double>&) ;
205 
206  if (so.check_if_zero())
207  return 0 ;
208  else {
209 
210  Val_domain integrant (mult_r(mult_r(mult_sin_theta(so)))*alpha) ;
211  integrant.coef() ;
212 
213  double val = 0 ;
214  // Only k = 0
215  int baset = (*integrant.get_base().bases_1d[1]) (0) ;
216  assert(baset==SIN_ODD) ;
217  Index pos (nbr_coefs) ;
218  for (int j=0 ; j<nbr_coefs(1) ; j++) {
219  pos.set(1) = j ;
220  int baser = (*integrant.get_base().bases_1d[0]) (j, 0) ;
221  assert (baser==CHEB) ;
222 
223  Array<double> cf (nbr_coefs(0)) ;
224  for (int i=0 ; i<nbr_coefs(0) ; i++) {
225  pos.set(0) = i ;
226  cf.set(i) = integrant.get_coef(pos) ;
227  }
228  val += 2./(2.*j+1) * integral_1d(CHEB, cf) ;
229  }
230 
231  return val * 2*M_PI ;
232 }
233 }
234 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
Bases_container bases_1d
Arrays containing the various basis of decomposition.
Array< double > ope_1d(int(*function)(int, Array< double > &), int var, const Array< double > &so, Base_spectral &base) const
One-dimensional operator acting in the coefficient space.
Definition: ope_1d.cpp:26
double alpha
Relates the numerical to the physical radii.
virtual Val_domain ddp(const Val_domain &) const
Compute the second derivative with respect to of a scalar field.
double beta
Relates the numerical to the physical radii.
virtual Val_domain mult_xm1(const Val_domain &) const
Multiplication by .
virtual Val_domain div_r(const Val_domain &) const
Division by .
virtual Val_domain mult_r(const Val_domain &) const
Multiplication by .
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual Val_domain div_sin_theta(const Val_domain &) const
Division by .
virtual Val_domain div_cos_theta(const Val_domain &) const
Division by .
virtual Val_domain mult_1mrsL(const Val_domain &) const
Multiplication by .
virtual Val_domain der_partial_var(const Val_domain &, int) const
Partial derivative with respect to a coordinate.
virtual Val_domain div_xm1(const Val_domain &) const
Division by .
virtual Val_domain div_1mx2(const Val_domain &) const
Division by .
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual Val_domain div_1mrsL(const Val_domain &) const
Division by .
virtual double integ_volume(const Val_domain &so) const
Volume integral.
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
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
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
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
Base_spectral base
Spectral basis of the field.
Definition: val_domain.hpp:72
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
Val_domain der_r() const
Definition: val_domain.cpp:726
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
Definition: val_domain.hpp:77
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
Array< double > get_coef() const
Definition: val_domain.hpp:136
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122