KADATH
domain_shell_inner_homothetic.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 "homothetic.hpp"
23 #include "point.hpp"
24 #include "array_math.hpp"
25 #include "val_domain.hpp"
26 #include "scalar.hpp"
27 #include "tensor_impl.hpp"
28 
29 namespace Kadath {
30 void coef_1d (int, Array<double>&) ;
31 void coef_i_1d (int, Array<double>&) ;
32 int der_1d (int, Array<double>&) ;
33 
34 // Standard constructor
35 Domain_shell_inner_homothetic::Domain_shell_inner_homothetic (const Space& sss, int num, int ttype, double rin, double rout, const Point& cr, const Dim_array& nbr) :
36  Domain_shell_inner_adapted(sss, num, ttype, rin, rout, cr, nbr) {
37 }
38 
39 // Constructor by copy
41 }
42 
44 }
45 
46 
47 // Destructor
48 Domain_shell_inner_homothetic::~Domain_shell_inner_homothetic() {
49 }
50 
52 
53  int res = 1 ;
54  return res ;
55 }
56 
57 
58 void Domain_shell_inner_homothetic::affecte_coef(int& conte, int cc, bool& found) const {
59  Val_domain auxi (this) ;
60  auxi.std_base() ;
61  auxi.set_in_coef() ;
62  auxi.allocate_coef() ;
63  *auxi.cf = 0 ;
64 
65  found = false ;
66 
67  if (conte==cc) {
68  Index pos_cf (nbr_coefs) ;
69  auxi.cf->set(pos_cf) = 1 ;
70  found = true ;
71  }
72 
73  conte ++ ;
74 
75  if (found) {
76  Scalar auxi_scal (sp) ;
77  auxi_scal.set_domain(num_dom) = auxi ;
78  inner_radius_term_eq->set_der_t(auxi_scal) ;
79  }
80  else {
82  }
83  update() ;
84 }
85 
86 
87 void Domain_shell_inner_homothetic::xx_to_vars_from_adapted(Val_domain& new_inner_radius, const Array<double>& xx, int& pos) const {
88 
89  new_inner_radius.allocate_coef() ;
90  *new_inner_radius.cf = 0 ;
91 
92  Index pos_cf (nbr_coefs) ;
93  pos_cf.set(0) = 0 ;
94 
95  new_inner_radius.cf->set(pos_cf) -= xx(pos) ;
96  pos ++ ;
97  new_inner_radius.set_base() = inner_radius->get_base() ;
98 }
99 
100 
101 
103 
104  Val_domain auxi (this) ;
105  auxi.std_base() ;
106  auxi.set_in_coef() ;
107  auxi.allocate_coef() ;
108  *auxi.cf = 0 ;
109 
110  Index pos_cf (nbr_coefs) ;
111  pos_cf.set(0) = 0 ;
112 
113  auxi.cf->set(pos_cf) = xx(pos) ;
114  pos ++ ;
115 
116  Scalar auxi_scal (sp) ;
117  auxi_scal.set_domain(num_dom) = auxi ;
118  inner_radius_term_eq->set_der_t(auxi_scal) ;
119  update() ;
120 }
121 
122 
123 ostream& Domain_shell_inner_homothetic::print (ostream& o) const {
124  o << "Adapted homothetic shell on the inside boundary" << endl ;
125  o << "Center = " << center << endl ;
126  o << "Nbr pts = " << nbr_points << endl ;
127  o << "Outer radius " << outer_radius << endl ;
128  Index pos (nbr_points) ;
129  o << "Inner radius " << (*inner_radius)(pos) << endl ;
130  o << endl ;
131  return o ;
132 }
133 
134 
135 
136 void Domain_shell_inner_homothetic::update_constante (const Val_domain& cor_inner_radius, const Scalar& old, Scalar& res) const {
137  update_variable (cor_inner_radius, old, res) ;
138 }
139 
140 double Domain_shell_inner_homothetic::integ (const Val_domain& so, int bound) const {
142 
143  double res = 0 ;
144  if (!so.check_if_zero())
145  {
146 
147  int baset = (*rrso.get_base().bases_1d[1]) (0) ;
148  Index pcf (nbr_coefs) ;
149  switch (baset) {
150  case COS_ODD :
151  break ;
152  case SIN_EVEN :
153  break ;
154  case COS_EVEN : {
155  res += M_PI*val_boundary(bound, rrso, pcf) ;
156  break ;
157  }
158  case SIN_ODD : {
159  for (int j=0 ; j<nbr_coefs(1) ; j++) {
160  pcf.set(1) = j ;
161  res += 2./(2*double(j)+1) * val_boundary(bound, rrso, pcf) ;
162  }
163  break ;
164  }
165 
166  default :
167  cerr << "Case not yet implemented in Domain_shell_inner_homothetic::integ" << endl ;
168  abort() ;
169  }
170  res *= 2*M_PI ;
171  }
172  return res ;
173 }
174 
175 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
Bases_container bases_1d
Arrays containing the various basis of decomposition.
Class for storing the dimensions of an array.
Definition: dim_array.hpp:34
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: adapted.hpp:51
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
virtual void update_variable(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
double outer_radius
The outer radius .
Definition: adapted.hpp:60
Val_domain * inner_radius
Pointer on the inner boundary , as a Val_domain.
Definition: adapted.hpp:58
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Definition: adapted.hpp:57
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
Term_eq * inner_radius_term_eq
Pointer on the inner boundary , as a Term_eq.
Definition: adapted.hpp:59
Point center
Absolute coordinates of the center.
Definition: adapted.hpp:86
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: homothetic.hpp:45
virtual void update_constante(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
Domain_shell_inner_homothetic(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
virtual void xx_to_vars_from_adapted(Val_domain &, const Array< double > &, int &) const
Computes the new boundary of a Domain from a set of values.
virtual void xx_to_ders_from_adapted(const Array< double > &, int &) const
Affects the derivative part of variable a Domain from a set of values.
virtual int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
virtual double integ(const Val_domain &, int) const
Surface integral on a given boundary.
virtual void affecte_coef(int &, int, bool &) const
The variation of the functions describing the shape of the Domain are affected from the unknowns of t...
int num_dom
Number of the current domain (used by the Space)
Definition: space.hpp:63
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
int & set(int i)
Read/write of the position in a given dimension.
Definition: index.hpp:72
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
The Space class is an ensemble of domains describing the whole space of the computation.
Definition: space.hpp:1362
void set_der_t(Tensor)
Sets the tensorial variation (only the values in the pertinent Domain are copied).
Definition: term_eq.cpp:171
void set_der_zero()
Sets the variation of the approriate type to zero.
Definition: term_eq.cpp:187
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
void set_in_coef()
Destroys the values in the configuration space.
Definition: val_domain.cpp:203
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration space.
Definition: val_domain.cpp:216
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
Definition: val_domain.hpp:77
void std_base()
Sets the standard basis of decomposition.
Definition: val_domain.cpp:246
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