KADATH
domain_bispheric_eta_first_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 "bispheric.hpp"
21 #include "val_domain.hpp"
22 #include "array_math.hpp"
23 namespace Kadath {
24 int mult_cos_1d (int, Array<double>&) ;
25 int mult_sin_1d (int, Array<double>&) ;
26 int div_x_1d (int, Array<double>&) ;
27 
29  so.coef() ;
30  Val_domain res(this) ;
31 
32  res.base.allocate (nbr_coefs) ;
33  *res.base.bases_1d[2] = *so.base.bases_1d[2] ;
34 
35  Index index (res.base.bases_1d[0]->get_dimensions()) ;
36 
37  // Inversion in theta :
38  do {
39  switch ((*so.base.bases_1d[0])(index)) {
40  case CHEB_EVEN :
41  res.base.bases_1d[0]->set(index) = CHEB_ODD ;
42  break ;
43  case CHEB_ODD :
44  res.base.bases_1d[0]->set(index) = CHEB_EVEN ;
45  break ;
46  case LEG_ODD :
47  res.base.bases_1d[0]->set(index) = LEG_EVEN ;
48  break ;
49  case LEG_EVEN :
50  res.base.bases_1d[0]->set(index) = LEG_ODD ;
51  break ;
52  default :
53  cout << "Unknown case in Domain_bispheric_eta_first::base_mult_sin_phi" << endl ;
54  abort() ;
55  }
56  }
57  while (index.inc()) ;
58 
59  *res.base.bases_1d[1] = *so.base.bases_1d[1] ;
60 
61  res.base.def = true ;
62 
63  res.cf = new Array<double> (so.base.ope_1d(mult_cos_1d, 2, *so.cf, res.base)) ;
64  res.in_coef = true ;
65  return res ;
66 }
67 
69  so.coef() ;
70  Val_domain res(this) ;
71 
72  res.base.allocate (nbr_coefs) ;
73  *res.base.bases_1d[2] = *so.base.bases_1d[2] ;
74 
75  Index index (res.base.bases_1d[0]->get_dimensions()) ;
76 
77  // Inversion in theta :
78  do {
79  switch ((*so.base.bases_1d[0])(index)) {
80  case CHEB_EVEN :
81  res.base.bases_1d[0]->set(index) = CHEB_ODD ;
82  break ;
83  case CHEB_ODD :
84  res.base.bases_1d[0]->set(index) = CHEB_EVEN ;
85  break ;
86  case LEG_ODD :
87  res.base.bases_1d[0]->set(index) = LEG_EVEN ;
88  break ;
89  case LEG_EVEN :
90  res.base.bases_1d[0]->set(index) = LEG_ODD ;
91  break ;
92  default :
93  cout << "Unknown case in Domain_bispheric_eta_first::base_mult_cos_phi" << endl ;
94  abort() ;
95  }
96  }
97  while (index.inc()) ;
98  *res.base.bases_1d[1] = *so.base.bases_1d[1] ;
99 
100  res.base.def = true ;
101 
102  res.cf = new Array<double> (so.base.ope_1d(mult_sin_1d, 2, *so.cf, res.base)) ;
103  res.in_coef = true ;
104  return res ;
105 }
106 
108  so.coef() ;
109  Val_domain res(this) ;
110 
111  res.base= so.base ;
112 
113  res.cf = new Array<double> (so.base.ope_1d(div_x_1d, 0, *so.cf, res.base)) ;
114  res.in_coef = true ;
115  return res ;
116 }
117 
119 
120  // First division in configuration space :
121  Val_domain res (so/sin(*p_chi)) ;
122 
123  // Points where division is singular it is done in the coefficient space
124  Val_domain copie (so.div_chi()) ;
125  copie.coef_i() ;
126 
127  Index index (nbr_points) ;
128  do {
129  if (index(0)==0)
130  res.set(index) = copie(index)/(M_PI - (*bound_chi)(index)) ;
131  }
132  while (index.inc()) ;
133 
134 
135  res.base = copie.base ;
136  return res ;
137 }
138 
140  Val_domain res (so*get_radius()) ;
141  res.set_base() = so.get_base() ;
142  return res ;
143 }
144 }
Bases_container bases_1d
Arrays containing the various basis of decomposition.
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.
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 div_sin_chi(const Val_domain &) const
Division by .
virtual Val_domain div_chi(const Val_domain &) const
Division by .
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
Val_domain * p_chi
Pointer on a Val_domain containing .
Definition: bispheric.hpp:901
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_r(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
Dim_array nbr_points
Number of colocation points.
Definition: space.hpp:65
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
bool inc(int increm, int var=0)
Increments the position of the Index.
Definition: index.hpp:99
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
Val_domain div_chi() const
Division by .
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
Definition: val_domain.hpp:77
void coef_i() const
Computes the values in the configuration space.
Definition: val_domain.cpp:637
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Definition: val_domain.cpp:171
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
Base_spectral & set_base()
Sets the basis of decomposition.
Definition: val_domain.hpp:126
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122