KADATH
domain_oned_inf_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 "utilities.hpp"
22 #include "oned.hpp"
23 #include "array_math.hpp"
24 #include "val_domain.hpp"
25 namespace Kadath {
26 int mult_xm1_1d (int, Array<double>&) ;
27 int div_xm1_1d (int, Array<double>&) ;
28 
30  so.coef() ;
31  Val_domain res(this) ;
32 
33  res.base= so.base ;
34 
35  res.cf = new Array<double> (so.base.ope_1d(mult_xm1_1d, 0, *so.cf, res.base)) ;
36  res.in_coef = true ;
37  return res ;
38 }
39 
40 Val_domain Domain_oned_inf::der_partial_var (const Val_domain& so, int which_var) const {
41 
42  switch (which_var) {
43  case 0 :
44  return -alpha*so.der_var(1).mult_xm1().mult_xm1() ;
45  break ;
46  default:
47  cerr << "Unknown variable in Domain_oned_inf::der_partial_var" << endl ;
48  abort() ;
49  }
50 }
51 
53  so.coef() ;
54  Val_domain res(this) ;
55 
56  res.base = so.base ;
57 
58  res.cf = new Array<double> (so.base.ope_1d(div_xm1_1d, 0, *so.cf, res.base)) ;
59  res.in_coef = true ;
60  return res ;
61 }
62 
64  so.coef() ;
65  Val_domain res(div_xm1(so)) ;
66  res /= alpha ;
67  return res ;
68 }
69 
70 
71 double Domain_oned_inf::integrale (const Val_domain& so) const {
72  double res = 0 ;
73  Val_domain integrant (div_xm1(div_xm1(so))) ;
74  integrant.coef() ;
75  int baser = (*integrant.get_base().bases_1d[0]) (0) ;
76 
77  switch (baser) {
78  case CHEB :
79  for (int i=0 ; i<nbr_coefs(0) ; i+=2)
80  res += integrant.get_coef()(i)*(1./double(i+1) - 1./double(i-1)) ;
81  break ;
82  default :
83  cerr << "Case not implemented in Domain_oned_inf::integrale" << endl ;
84  }
85  return -res/alpha ;
86 }}
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_xm1(const Val_domain &) const
Multiplication by .
virtual Val_domain div_xm1(const Val_domain &) const
Division by .
double alpha
Relates the numerical radius to the physical one.
Definition: oned.hpp:322
virtual Val_domain der_partial_var(const Val_domain &, int) const
Partial derivative with respect to a coordinate.
virtual Val_domain mult_x(const Val_domain &) const
Multiplication by .
virtual double integrale(const Val_domain &) const
Volume integral.
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
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 mult_xm1() 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