KADATH
domain_bispheric_chi_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 
24 namespace Kadath{
25 int mult_cos_1d (int, Array<double>&) ;
26 int mult_sin_1d (int, Array<double>&) ;
27 int div_x_1d (int, Array<double>&) ;
28 
30  so.coef() ;
31  Val_domain res(this) ;
32 
33  res.base.allocate (nbr_coefs) ;
34  *res.base.bases_1d[2] = *so.base.bases_1d[2] ;
35 
36  Index index (res.base.bases_1d[1]->get_dimensions()) ;
37 
38  // Inversion in theta :
39  do {
40  switch ((*so.base.bases_1d[1])(index)) {
41  case CHEB_EVEN :
42  res.base.bases_1d[1]->set(index) = CHEB_ODD ;
43  break ;
44  case CHEB_ODD :
45  res.base.bases_1d[1]->set(index) = CHEB_EVEN ;
46  break ;
47  case LEG_ODD :
48  res.base.bases_1d[1]->set(index) = LEG_EVEN ;
49  break ;
50  case LEG_EVEN :
51  res.base.bases_1d[1]->set(index) = LEG_ODD ;
52  break ;
53  default :
54  cout << "Unknown case in Domain_bispheric_chi_first::base_mult_sin_phi" << endl ;
55  abort() ;
56  }
57  }
58  while (index.inc()) ;
59 
60  *res.base.bases_1d[0] = *so.base.bases_1d[0] ;
61 
62  res.base.def = true ;
63 
64  res.cf = new Array<double> (so.base.ope_1d(mult_cos_1d, 2, *so.cf, res.base)) ;
65  res.in_coef = true ;
66  return res ;
67 }
68 
70  so.coef() ;
71  Val_domain res(this) ;
72 
73  res.base.allocate (nbr_coefs) ;
74  *res.base.bases_1d[2] = *so.base.bases_1d[2] ;
75 
76  Index index (res.base.bases_1d[1]->get_dimensions()) ;
77 
78  // Inversion in theta :
79  do {
80  switch ((*so.base.bases_1d[1])(index)) {
81  case CHEB_EVEN :
82  res.base.bases_1d[1]->set(index) = CHEB_ODD ;
83  break ;
84  case CHEB_ODD :
85  res.base.bases_1d[1]->set(index) = CHEB_EVEN ;
86  break ;
87  case LEG_ODD :
88  res.base.bases_1d[1]->set(index) = LEG_EVEN ;
89  break ;
90  case LEG_EVEN :
91  res.base.bases_1d[1]->set(index) = LEG_ODD ;
92  break ;
93  default :
94  cout << "Unknown case in Domain_bispheric_chi_first::base_mult_cos_phi" << endl ;
95  abort() ;
96  }
97  }
98  while (index.inc()) ;
99  *res.base.bases_1d[0] = *so.base.bases_1d[0] ;
100 
101  res.base.def = true ;
102 
103  res.cf = new Array<double> (so.base.ope_1d(mult_sin_1d, 2, *so.cf, res.base)) ;
104  res.in_coef = true ;
105  return res ;
106 }
107 
109  so.coef() ;
110  Val_domain res(this) ;
111 
112  res.base= so.base ;
113 
114  res.cf = new Array<double> (so.base.ope_1d(div_x_1d, 1, *so.cf, res.base)) ;
115  res.in_coef = true ;
116  return res ;
117 }
118 
120 
121  // First division in configuration space :
122  Val_domain res (so/sin(*p_chi)) ;
123 
124  // Points where division is singular it is done in the coefficient space
125  Val_domain copie (so.div_chi()) ;
126  copie.coef_i() ;
127 
128  Index index (nbr_points) ;
129  do {
130  if (index(1)==0)
131  res.set(index) = copie(index)/chi_max ;
132  }
133  while (index.inc()) ;
134 
135 
136  res.base = copie.base ;
137  return res ;
138 }
139 
141  Val_domain res (so*get_radius()) ;
142  res.set_base() = so.get_base() ;
143  return res ;
144 }
145 }
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
Val_domain * p_chi
Pointer on a Val_domain containing .
Definition: bispheric.hpp:483
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual Val_domain div_chi(const Val_domain &) const
Division by .
virtual Val_domain div_sin_chi(const Val_domain &) const
Division by .
double chi_max
Upper bound for .
Definition: bispheric.hpp:466
virtual Val_domain mult_r(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_sin_phi(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