KADATH
domain_polar_shell_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 "array.hpp"
22 #include "polar.hpp"
23 #include "val_domain.hpp"
24 #include "array_math.hpp"
25 namespace Kadath {
26 int mult_cos_1d (int, Array<double>&) ;
27 int mult_sin_1d (int, Array<double>&) ;
28 int div_sin_1d (int, Array<double>&) ;
29 int mult_x_1d (int, Array<double>&) ;
30 int div_xp1_1d (int, Array<double>&) ;
31 
33  so.coef() ;
34  Val_domain res(this) ;
35 
36  res.base = so.base ;
37 
38  res.cf = new Array<double> (so.base.ope_1d(mult_cos_1d, 1, *so.cf, res.base)) ;
39  res.in_coef = true ;
40  return res ;
41 }
42 
44  so.coef() ;
45  Val_domain res(this) ;
46 
47  res.base= so.base ;
48 
49  res.cf = new Array<double> (so.base.ope_1d(mult_sin_1d, 1, *so.cf, res.base)) ;
50  res.in_coef = true ;
51  return res ;
52 }
53 
55  so.coef() ;
56  Val_domain res(this) ;
57 
58  res.base = so.base ;
59 
60  res.cf = new Array<double> (so.base.ope_1d(div_sin_1d, 1, *so.cf, res.base)) ;
61  res.in_coef = true ;
62  return res ;
63 }
64 
66  so.coef() ;
67  Val_domain res(this) ;
68 
69  res.base= so.base ;
70 
71  res.cf = new Array<double> (so.base.ope_1d(mult_x_1d, 0, *so.cf, res.base)*alpha + (*so.cf)*beta) ;
72  res.in_coef = true ;
73  return res ;
74 }
75 
77  Val_domain res (so / get_radius()) ;
78  res.base = so.base ;
79  return (res) ;
80 }
81 
83  Val_domain derr (so.der_var(1)/alpha) ;
84  Val_domain dert (so.der_var(2)) ;
85  Val_domain res (derr.der_var(1)/alpha + div_r(2*derr + div_r(dert.der_var(2) + dert.mult_cos_theta().div_sin_theta()))) ;
86  if (m!=0)
87  res -= m * m * div_r(div_r(so.div_sin_theta().div_sin_theta())) ;
88  return res ;
89 }
90 
92  Val_domain derr (so.der_var(1)/alpha) ;
93  Val_domain dert (so.der_var(2)) ;
94  Val_domain res (derr.der_var(1)/alpha + div_r(derr + div_r(dert.der_var(2)))) ;
95  if (m!=0)
96  res -= m * m * div_r(div_r(so.div_sin_theta().div_sin_theta())) ;
97  return res ;
98 }
99 
101  return (so.der_var(1)/alpha) ;
102 }
103 
104 
106  return (so.der_var(2)) ;
107 }
108 
109 
111  so.coef() ;
112  Val_domain res(this) ;
113 
114  res.base= so.base ;
115 
116  res.cf = new Array<double> (so.base.ope_1d(div_xp1_1d, 0, *so.cf, res.base)) ;
117  res.in_coef = true ;
118  return res ;
119 }
120 
121 double Domain_polar_shell::integrale (const Val_domain& so) const {
122  double res = 0 ;
123  Val_domain integrant (mult_r(so)) ;
124  integrant.get_coef() ;
125  Array<double> cf (integrant.get_coef()) ;
126 
127  int baset = (*integrant.get_base().bases_1d[1]) (0) ;
128  switch (baset) {
129  case COS_ODD :
130  break ;
131  case SIN_EVEN :
132  break ;
133  case COS_EVEN : {
134  // Only m=0 :
135  double facttheta = M_PI ;
136  int baser = (*integrant.get_base().bases_1d[0]) (0) ;
137  switch (baser) {
138  case CHEB : {
139  for (int i=0 ; i<nbr_coefs(0) ; i+=2)
140  res += facttheta * (1./double(i+1) - 1./double(i-1)) *cf(i,0) ;
141  break ;
142  }
143  case LEG : {
144  res += facttheta*2*cf(0,0) ;
145  break ;
146  }
147  default :
148  cerr << "Case not yet implemented in Domain_polar_shell::integrale" << endl ;
149  abort() ;
150  }
151  break ;
152  }
153  case SIN_ODD : {
154  for (int j=0 ; j<nbr_coefs(1) ; j++) {
155  double facttheta = 2./double(2*j+1) ;
156  int baser = (*integrant.get_base().bases_1d[0]) (0) ;
157  switch (baser) {
158  case CHEB : {
159  for (int i=0 ; i<nbr_coefs(0) ; i+=2)
160  res += facttheta * (1./double(i+1) - 1./double(i-1)) *cf(i,j) ;
161  break ;
162  }
163  case LEG : {
164  res += facttheta*2*cf(0,j) ;
165  break ;
166  }
167  default :
168  cerr << "Case not yet implemented in Domain_polar_shell::integrale" << endl ;
169  abort() ;
170  }
171  }
172  break ;
173  }
174  default :
175  cerr << "Case not yet implemented in Domain_polar_shell::integrale" << endl ;
176  abort() ;
177  }
178  // Phi contribution :
179  // res *= 2*M_PI*alpha ;
180  res *= alpha ;
181  return res ;
182 }
183 
184 
186  return integrale(so) ;
187 }
188 }
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
virtual Val_domain mult_r(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
double beta
Relates the numerical to the physical radii.
Definition: polar.hpp:225
virtual Val_domain laplacian2(const Val_domain &, int) const
Computes the ordinary flat 2dè- Laplacian for a scalar field with an harmonic index m.
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
virtual double integ_volume(const Val_domain &) const
Volume integral.
double alpha
Relates the numerical to the physical radii.
Definition: polar.hpp:224
virtual Val_domain div_sin_theta(const Val_domain &) const
Division by .
virtual Val_domain dt(const Val_domain &) const
Compute the derivative with respect to of a scalar field.
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
virtual Val_domain div_r(const Val_domain &) const
Division by .
virtual Val_domain div_xp1(const Val_domain &) const
Division by .
virtual Val_domain laplacian(const Val_domain &, int) const
Computes the ordinary flat Laplacian for a scalar field with an harmonic index m.
virtual double integrale(const Val_domain &) const
Volume integral.
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 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
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
Definition: val_domain.hpp:77
Val_domain div_sin_theta() const
Division by .
Val_domain mult_cos_theta() const
Multiplication by .
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