KADATH
domain_shell_outer_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_outer_homothetic::Domain_shell_outer_homothetic (const Space& sss, int num, int ttype, double rin, double rout, const Point& cr, const Dim_array& nbr) :
36  Domain_shell_outer_adapted(sss, num, ttype, rin, rout, cr, nbr) {
37 }
38 
39 // Constructor by copy
41 }
42 
44 }
45 
46 
47 // Destructor
49 }
50 
52 
53  int res = 1 ;
54  return res ;
55 }
56 
57 
58 void Domain_shell_outer_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  outer_radius_term_eq->set_der_t(auxi_scal) ;
79  }
80  else {
82  }
83  update() ;
84 }
85 
86 
87 void Domain_shell_outer_homothetic::xx_to_vars_from_adapted(Val_domain& new_outer_radius, const Array<double>& xx, int& pos) const {
88 
89  new_outer_radius.allocate_coef() ;
90  *new_outer_radius.cf = 0 ;
91 
92  Index pos_cf (nbr_coefs) ;
93  pos_cf.set(0) = 0 ;
94 
95  new_outer_radius.cf->set(pos_cf) -= xx(pos) ;
96  pos ++ ;
97  new_outer_radius.set_base() = outer_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  outer_radius_term_eq->set_der_t(auxi_scal) ;
119  update() ;
120 }
121 
122 
123 ostream& Domain_shell_outer_homothetic::print (ostream& o) const {
124  o << "Adapted homothetic shell on the outside boundary" << endl ;
125  o << "Center = " << center << endl ;
126  o << "Nbr pts = " << nbr_points << endl ;
127  Index pos (nbr_points) ;
128  o << "Outer radius " << (*outer_radius)(pos) << endl ;
129  o << "Inner radius " << inner_radius << endl ;
130  o << endl ;
131  return o ;
132 }
133 
134 
135 
136 void Domain_shell_outer_homothetic::update_constante (const Val_domain& cor_outer_radius, const Scalar& old, Scalar& res) const {
137  update_variable (cor_outer_radius, old, res) ;
138 }
139 
140 
141 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
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:367
Term_eq * outer_radius_term_eq
Pointer on the outer boundary , as a Term_eq.
Definition: adapted.hpp:375
Point center
Absolute coordinates of the center.
Definition: adapted.hpp:402
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
Val_domain * outer_radius
Pointer on the outer boundary , as a Val_domain.
Definition: adapted.hpp:374
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 inner_radius
The inner radius .
Definition: adapted.hpp:376
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Definition: adapted.hpp:373
Class for a spherical-like domain, having a symmetry with respect to the plane .
Definition: homothetic.hpp:105
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 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 int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
Domain_shell_outer_homothetic(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
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...
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
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.
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
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
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