KADATH
multipoles_valdomain.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 
22 #include "utilities.hpp"
23 #include "spheric.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 #include "tensor.hpp"
27 #include "term_eq.hpp"
28 namespace Kadath {
29 void coef_1d (int, Array<double>&) ;
30 double integral_1d (int, const Array<double>&) ;
31 
32 
33 // Computation norm Legendre associated
34 Array<double> legendre_norme (int, int ) ;
35 Array<double> mat_leg_even (int , int ) ;
36 Array<double> mat_leg_odd (int, int) ;
37 
38 double Domain_shell::multipoles_sym (int k, int j, int bound, const Val_domain& so, const Array<double>& passage) const {
39 
40 
41  assert ((bound==INNER_BC) || (bound==OUTER_BC)) ;
42 
43  Index pos(passage.dimensions) ;
44  Index pos_bound (nbr_coefs) ;
45 
46  double alm = 0 ;
47 
48  int mm = (k%2==0) ? int(k/2) : int((k-1)/2) ;
49  pos.set(0) = mm ;
50  pos_bound.set(2) = k ;
51  if (mm%2==0) {
52  //Case m even
53  pos.set(1) = j ;
54  for (int i=0 ; i<nbr_coefs(1) ; i++) {
55  pos.set(2) = i ;
56  pos_bound.set(1) = i ;
57  alm += passage(pos)*val_boundary(bound, so, pos_bound) ;
58  }
59  }
60  else {
61  //Case m odd
62  pos.set(1) = j ;
63  for (int i=0 ; i<nbr_coefs(1)-1 ; i++) {
64  pos.set(2) = i ;
65  pos_bound.set(1) = i ;
66  alm += passage(pos)*val_boundary(bound, so, pos_bound) ;
67  }
68  }
69  return alm ;
70 }
71 
72 
73 
74 
75 
76 double Domain_shell::multipoles_asym (int k, int j, int bound, const Val_domain& so, const Array<double>& passage) const {
77 
78 
79  assert ((bound==INNER_BC) || (bound==OUTER_BC)) ;
80 
81 
82  Index pos(passage.dimensions) ;
83  Index pos_bound (nbr_coefs) ;
84 
85  double alm = 0 ;
86 
87  int mm = (k%2==0) ? int(k/2) : int((k-1)/2) ;
88  pos.set(0) = mm ;
89  pos_bound.set(2) = k ;
90  if (mm%2==0) {
91  //Case m even
92  pos.set(1) = j ;
93  for (int i=0 ; i<nbr_coefs(1)-1 ; i++) {
94  pos.set(2) = i ;
95  pos_bound.set(1) = i ;
96  alm += passage(pos)*val_boundary(bound, so, pos_bound) ;
97  }
98  }
99  else {
100  //Case m odd
101  pos.set(1) = j ;
102  for (int i=0 ; i<nbr_coefs(1)-1 ; i++) {
103  pos.set(2) = i ;
104  pos_bound.set(1) = i ;
105  alm += passage(pos)*val_boundary(bound, so, pos_bound) ;
106  }
107  }
108  return alm ;
109 }}
Dim_array dimensions
Dimensions of the Array.
Definition: array.hpp:88
virtual double multipoles_asym(int, int, int, const Val_domain &, const Array< double > &) const
Extraction of a given multipole, at some boundary, for a anti-symmetric scalar function.
virtual double multipoles_sym(int, int, int, const Val_domain &, const Array< double > &) const
Extraction of a given multipole, at some boundary, for a symmetric scalar function.
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
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