KADATH
domain_polar_shell_export_tau_boundary_exception.cpp
1 /*
2  Copyright 2021 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 
22 #include "polar.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 #include "tensor.hpp"
26 #include "param.hpp"
27 
28 namespace Kadath {
29 
30 void Domain_polar_shell::export_tau_val_domain_boundary_exception_mquant (const Val_domain& so, int mquant, int bound, Array<double>& sec, int& pos_sec, int ncond,
31  const Param& par, int type_exception, const Val_domain& exception) const {
32 
33 
34  // Place for the exceptionnal part
35  int jtarget = par.get_int(0) ;
36  double value = par.get_double(0) ;
37 
38  assert ((type_exception>=1) && (type_exception <=4)) ;
39 
40 
41  if (so.check_if_zero())
42  pos_sec += ncond ;
43 
44 
45  else {
46  so.coef() ;
47 
48  Index pos_cf (nbr_coefs) ;
49  Index pos_galerkin (nbr_coefs) ;
50 
51  // Loop on theta
52  int baset = (*so.get_base().bases_1d[1]) (0) ;
53  for (int j=0 ; j<nbr_coefs(1) ; j++) {
54  pos_cf.set(1) = j ;
55  switch (baset) {
56  case COS_EVEN:
57  if (mquant==0) {
58  if (j==jtarget) {
59  switch (type_exception) {
60  case 1 :
61  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
62  break ;
63  case 2 :
64  sec.set(pos_sec) = 0 ;
65  break ;
66  case 3 :
67  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
68  break ;
69  case 4 :
70  sec.set(pos_sec) = 0 ;
71  break ;
72  default :
73  cerr << "bad value for type_exception" << endl ;
74  abort() ;
75  }
76  }
77  else
78  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
79  pos_sec ++ ;
80  }
81  else if (j!=0) {
82  // Galerkin base
83  pos_galerkin = pos_cf ;
84  pos_galerkin.set(1) = 0 ;
85  if (j==jtarget) {
86  switch (type_exception) {
87  case 1 :
88  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
89  break ;
90  case 2 :
91  sec.set(pos_sec) = 0 ;
92  break ;
93  case 3 :
94  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
95  break ;
96  case 4 :
97  sec.set(pos_sec) = 0 ;
98  break ;
99  default :
100  cerr << "bad value for type_exception" << endl ;
101  abort() ;
102  }
103  }
104  else
105  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
106  -2.*val_boundary(bound, so, pos_galerkin) ;
107  pos_sec ++ ;
108  }
109  break ;
110  case COS_ODD:
111  if (j!=nbr_coefs(1)-1) {
112  if (mquant==0) {
113 
114  if (j==jtarget) {
115  switch (type_exception) {
116  case 1 :
117  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
118  break ;
119  case 2 :
120  sec.set(pos_sec) = 0 ;
121  break ;
122  case 3 :
123  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
124  break ;
125  case 4 :
126  sec.set(pos_sec) = 0 ;
127  break ;
128  default :
129  cerr << "bad value for type_exception" << endl ;
130  abort() ;
131  }
132  }
133  else
134  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
135  pos_sec ++ ;
136  }
137  else if (j!=0) {
138  // Galerkin base
139  pos_galerkin = pos_cf ;
140  pos_galerkin.set(1) = 0 ;
141  if (j==jtarget) {
142  switch (type_exception) {
143  case 1 :
144  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
145  break ;
146  case 2 :
147  sec.set(pos_sec) = 0 ;
148  break ;
149  case 3 :
150  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
151  break ;
152  case 4 :
153  sec.set(pos_sec) = 0 ;
154  break ;
155  default :
156  cerr << "bad value for type_exception" << endl ;
157  abort() ;
158  }
159  }
160  else
161  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
162  -val_boundary(bound, so, pos_galerkin) ;
163  pos_sec ++ ;
164  }}
165  break ;
166  case SIN_EVEN:
167  if ((j!=0) && (j!=nbr_coefs(1)-1)) {
168  if (mquant<=1){
169  if (j==jtarget) {
170  switch (type_exception) {
171  case 1 :
172  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
173  break ;
174  case 2 :
175  sec.set(pos_sec) = 0 ;
176  break ;
177  case 3 :
178  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
179  break ;
180  case 4 :
181  sec.set(pos_sec) = 0 ;
182  break ;
183  default :
184  cerr << "bad value for type_exception" << endl ;
185  abort() ;
186  }
187  }
188  else
189  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
190  pos_sec ++ ;
191  }
192  else if (j!=1) {
193  // Galerkin base
194  pos_galerkin = pos_cf ;
195  pos_galerkin.set(1) = 1 ;
196  if (j==jtarget) {
197  switch (type_exception) {
198  case 1 :
199  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
200  break ;
201  case 2 :
202  sec.set(pos_sec) = 0 ;
203  break ;
204  case 3 :
205  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
206  break ;
207  case 4 :
208  sec.set(pos_sec) = 0 ;
209  break ;
210  default :
211  cerr << "bad value for type_exception" << endl ;
212  abort() ;
213  }
214  }
215  else
216  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
217  -j*val_boundary(bound, so, pos_galerkin) ;
218  pos_sec ++ ;
219  }
220  }
221  break ;
222  case SIN_ODD:
223  if (j!=nbr_coefs(1)-1) {
224  if (mquant<=1) {
225  if (j==jtarget) {
226  switch (type_exception) {
227  case 1 :
228  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
229  break ;
230  case 2 :
231  sec.set(pos_sec) = 0 ;
232  break ;
233  case 3 :
234  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
235  break ;
236  case 4 :
237  sec.set(pos_sec) = 0 ;
238  break ;
239  default :
240  cerr << "bad value for type_exception" << endl ;
241  abort() ;
242  }
243  }
244  else
245  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
246  pos_sec ++ ;
247  }
248  else if (j!=0) {
249  // Galerkin base
250  pos_galerkin = pos_cf ;
251  pos_galerkin.set(1) = 0 ;
252  if (j==jtarget) {
253  switch (type_exception) {
254  case 1 :
255  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
256  break ;
257  case 2 :
258  sec.set(pos_sec) = 0 ;
259  break ;
260  case 3 :
261  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
262  break ;
263  case 4 :
264  sec.set(pos_sec) = 0 ;
265  break ;
266  default :
267  cerr << "bad value for type_exception" << endl ;
268  abort() ;
269  }
270  }
271  else
272  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
273  -(2*j+1)*val_boundary(bound, so, pos_galerkin) ;
274  pos_sec ++ ;
275 
276  }
277  }
278  break ;
279  default:
280  cerr << "Unknow theta basis in Domain_polar_shell::export_tau_val_domain_boundary_exception" << endl ;
281  abort() ;
282  }
283  }
284  }
285 }
286 
287 
288 void Domain_polar_shell::export_tau_boundary_exception (const Tensor& tt, int dom, int bound, Array<double>& res, int& pos_res, const Array<int>& ncond,
289  const Param& par, int type_exception, const Tensor& exception,
290  int n_cmp, Array<int>** p_cmp) const {
291  // Check boundary_exception
292  if ((bound!=INNER_BC) && (bound!=OUTER_BC)) {
293  cerr << "Unknown boundary_exception in Domain_polar_shell::export_tau_boundary_exception" << endl ;
294  abort() ;
295  }
296 
297  int val = tt.get_valence() ;
298  switch (val) {
299  case 0 : if (tt.is_m_quant_affected()) {
300  // Special case for bosonic field
301  export_tau_val_domain_boundary_exception_mquant(tt()(dom), tt.get_parameters().get_m_quant(), bound, res, pos_res, ncond(0), par, type_exception, exception()(dom)) ;
302  }
303  else {
304  export_tau_val_domain_boundary_exception_mquant (tt()(dom), 0, bound, res, pos_res, ncond(0), par, type_exception, exception()(dom)) ;
305  }
306  break ;
307  default :
308  cerr << "Valence " << val << " not implemented in Domain_shell::export_tau_boundary_exception" << endl ;
309  break ;
310  }
311 }}
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.
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
void export_tau_val_domain_boundary_exception_mquant(const Val_domain &so, int mquant, int bound, Array< double > &res, int &pos_res, int ncond, const Param &param, int type_exception, const Val_domain &exception) const
Exports all the residual equations corresponding to a tensorial one on a given boundary but for one c...
virtual void export_tau_boundary_exception(const Tensor &, int, int, Array< double > &, int &, const Array< int > &, const Param &, int, const Tensor &, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Exports all the residual equations corresponding to one tensorial one on a given boundary,...
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
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
int get_m_quant() const
Returns .
Definition: tensor.hpp:747
Parameter storage.
Definition: param.hpp:30
const double & get_double(int position=0) const
Returns the reference of a double stored in the list.
Definition: param.cpp:148
const int & get_int(int position=0) const
Returns the reference of a int stored in the list.
Definition: param.cpp:92
Tensor handling.
Definition: tensor.hpp:149
const Param_tensor & get_parameters() const
Returns a pointer on the possible additional parameter.
Definition: tensor.hpp:311
int get_valence() const
Returns the valence.
Definition: tensor.hpp:509
bool is_m_quant_affected() const
Checks whether the additional parameter is affected (used for boson stars for instance).
Definition: tensor.hpp:326
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
void coef() const
Computes the coefficients.
Definition: val_domain.cpp:622
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122