KADATH
domain_shell_export_tau_boundary_exception.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 
22 #include "spheric.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_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_shell::export_tau_val_domain_boundary_exception" << endl ;
281  abort() ;
282  }
283  }
284  }
285 }
286 
287 void Domain_shell::export_tau_val_domain_boundary_exception (const Val_domain& so, int mlim, int bound, Array<double>& sec, int& pos_sec, int ncond,
288  const Param& par, int type_exception, const Val_domain& exception) const {
289 
290 
291  // Place for the exceptionnal part
292  int ktarget = par.get_int(0) ;
293  int jtarget = par.get_int(1) ;
294  double value = par.get_double(0) ;
295 
296  assert ((type_exception>=1) && (type_exception <=4)) ;
297 
298 
299  if (so.check_if_zero())
300  pos_sec += ncond ;
301 
302 
303  else {
304  so.coef() ;
305  int kmin = 2*mlim + 2 ;
306  Index pos_cf (nbr_coefs) ;
307  Index pos_galerkin (nbr_coefs) ;
308 
309  // Loop on phi :
310  for (int k=0 ; k<nbr_coefs(2)-1 ; k++)
311  if (k!=1) {
312  pos_cf.set(2) = k ;
313  // Loop on theta
314  int baset = (*so.get_base().bases_1d[1]) (k) ;
315  for (int j=0 ; j<nbr_coefs(1) ; j++) {
316  pos_cf.set(1) = j ;
317  switch (baset) {
318  case COS_EVEN:
319  if (k<kmin) {
320  if ((k==ktarget) && (j==jtarget)) {
321  switch (type_exception) {
322  case 1 :
323  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
324  break ;
325  case 2 :
326  sec.set(pos_sec) = 0 ;
327  break ;
328  case 3 :
329  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
330  break ;
331  case 4 :
332  sec.set(pos_sec) = 0 ;
333  break ;
334  default :
335  cerr << "bad value for type_exception" << endl ;
336  abort() ;
337  }
338  }
339  else
340  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
341  pos_sec ++ ;
342  }
343  else if (j!=0) {
344  // Galerkin base
345  pos_galerkin = pos_cf ;
346  pos_galerkin.set(1) = 0 ;
347  if ((k==ktarget) && (j==jtarget)) {
348  switch (type_exception) {
349  case 1 :
350  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
351  break ;
352  case 2 :
353  sec.set(pos_sec) = 0 ;
354  break ;
355  case 3 :
356  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
357  break ;
358  case 4 :
359  sec.set(pos_sec) = 0 ;
360  break ;
361  default :
362  cerr << "bad value for type_exception" << endl ;
363  abort() ;
364  }
365  }
366  else
367  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
368  -2.*val_boundary(bound, so, pos_galerkin) ;
369  pos_sec ++ ;
370  }
371  break ;
372  case COS_ODD:
373  if (j!=nbr_coefs(1)-1) {
374  if (k<kmin) {
375 
376  if ((k==ktarget) && (j==jtarget)) {
377  switch (type_exception) {
378  case 1 :
379  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
380  break ;
381  case 2 :
382  sec.set(pos_sec) = 0 ;
383  break ;
384  case 3 :
385  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
386  break ;
387  case 4 :
388  sec.set(pos_sec) = 0 ;
389  break ;
390  default :
391  cerr << "bad value for type_exception" << endl ;
392  abort() ;
393  }
394  }
395  else
396  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
397  pos_sec ++ ;
398  }
399  else if (j!=0) {
400  // Galerkin base
401  pos_galerkin = pos_cf ;
402  pos_galerkin.set(1) = 0 ;
403  if ((k==ktarget) && (j==jtarget)) {
404  switch (type_exception) {
405  case 1 :
406  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
407  break ;
408  case 2 :
409  sec.set(pos_sec) = 0 ;
410  break ;
411  case 3 :
412  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
413  break ;
414  case 4 :
415  sec.set(pos_sec) = 0 ;
416  break ;
417  default :
418  cerr << "bad value for type_exception" << endl ;
419  abort() ;
420  }
421  }
422  else
423  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
424  -val_boundary(bound, so, pos_galerkin) ;
425  pos_sec ++ ;
426  }}
427  break ;
428  case SIN_EVEN:
429  if ((j!=0) && (j!=nbr_coefs(1)-1)) {
430  if (k<kmin+2){
431  if ((k==ktarget) && (j==jtarget)) {
432  switch (type_exception) {
433  case 1 :
434  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
435  break ;
436  case 2 :
437  sec.set(pos_sec) = 0 ;
438  break ;
439  case 3 :
440  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
441  break ;
442  case 4 :
443  sec.set(pos_sec) = 0 ;
444  break ;
445  default :
446  cerr << "bad value for type_exception" << endl ;
447  abort() ;
448  }
449  }
450  else
451  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
452  pos_sec ++ ;
453  }
454  else if (j!=1) {
455  // Galerkin base
456  pos_galerkin = pos_cf ;
457  pos_galerkin.set(1) = 1 ;
458  if ((k==ktarget) && (j==jtarget)) {
459  switch (type_exception) {
460  case 1 :
461  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
462  break ;
463  case 2 :
464  sec.set(pos_sec) = 0 ;
465  break ;
466  case 3 :
467  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
468  break ;
469  case 4 :
470  sec.set(pos_sec) = 0 ;
471  break ;
472  default :
473  cerr << "bad value for type_exception" << endl ;
474  abort() ;
475  }
476  }
477  else
478  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
479  -j*val_boundary(bound, so, pos_galerkin) ;
480  pos_sec ++ ;
481  }
482  }
483  break ;
484  case SIN_ODD:
485  if (j!=nbr_coefs(1)-1) {
486  if (k<kmin+2) {
487  if ((k==ktarget) && (j==jtarget)) {
488  switch (type_exception) {
489  case 1 :
490  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
491  break ;
492  case 2 :
493  sec.set(pos_sec) = 0 ;
494  break ;
495  case 3 :
496  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
497  break ;
498  case 4 :
499  sec.set(pos_sec) = 0 ;
500  break ;
501  default :
502  cerr << "bad value for type_exception" << endl ;
503  abort() ;
504  }
505  }
506  else
507  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
508  pos_sec ++ ;
509  }
510  else if (j!=0) {
511  // Galerkin base
512  pos_galerkin = pos_cf ;
513  pos_galerkin.set(1) = 0 ;
514  if ((k==ktarget) && (j==jtarget)) {
515  switch (type_exception) {
516  case 1 :
517  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) - value ;
518  break ;
519  case 2 :
520  sec.set(pos_sec) = 0 ;
521  break ;
522  case 3 :
523  sec.set(pos_sec) = val_boundary(bound, exception, pos_cf) ;
524  break ;
525  case 4 :
526  sec.set(pos_sec) = 0 ;
527  break ;
528  default :
529  cerr << "bad value for type_exception" << endl ;
530  abort() ;
531  }
532  }
533  else
534  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
535  -(2*j+1)*val_boundary(bound, so, pos_galerkin) ;
536  pos_sec ++ ;
537 
538  }
539  }
540  break ;
541  default:
542  cerr << "Unknow theta basis in Domain_shell::export_tau_val_domain_boundary_exception" << endl ;
543  abort() ;
544  }
545  }
546  }
547  }
548 }
549 
550 void Domain_shell::export_tau_boundary_exception (const Tensor& tt, int dom, int bound, Array<double>& res, int& pos_res, const Array<int>& ncond,
551  const Param& par, int type_exception, const Tensor& exception,
552  int n_cmp, Array<int>** p_cmp) const {
553  // Check boundary_exception
554  if ((bound!=INNER_BC) && (bound!=OUTER_BC)) {
555  cerr << "Unknown boundary_exception in Domain_shell::export_tau_boundary_exception" << endl ;
556  abort() ;
557  }
558 
559  int val = tt.get_valence() ;
560  switch (val) {
561  case 0 : if (tt.is_m_quant_affected()) {
562  // Special case for bosonic field
563  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)) ;
564  }
565  else {
566  export_tau_val_domain_boundary_exception (tt()(dom), 0, bound, res, pos_res, ncond(0), par, type_exception, exception()(dom)) ;
567  }
568  break ;
569  default :
570  cerr << "Valence " << val << " not implemented in Domain_shell::export_tau_boundary_exception" << endl ;
571  break ;
572  }
573 }}
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.
void export_tau_val_domain_boundary_exception(const Val_domain &eq, int mlim, 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 one tensorial one on a given boundary,...
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,...
void export_tau_val_domain_boundary_exception_mquant(const Val_domain &eq, 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 one tensorial one on a given boundary,...
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a 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