KADATH
domain_shell_outer_adapted_export_tau_boundary.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 "adapted.hpp"
22 #include "point.hpp"
23 #include "array_math.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 #include "tensor.hpp"
27 
28 namespace Kadath {
29 void Domain_shell_outer_adapted::export_tau_val_domain_boundary (const Val_domain& so, int mlim, int bound, Array<double>& sec, int& pos_sec, int ncond) const {
30 
31  if (so.check_if_zero())
32  pos_sec += ncond ;
33  else {
34  so.coef() ;
35  int kmin = 2*mlim + 2 ;
36  Index pos_cf (nbr_coefs) ;
37  Index pos_galerkin (nbr_coefs) ;
38 
39  // Loop on phi :
40  for (int k=0 ; k<nbr_coefs(2)-1 ; k++)
41  if (k!=1) {
42  pos_cf.set(2) = k ;
43  // Loop on theta
44  int baset = (*so.get_base().bases_1d[1]) (k) ;
45  for (int j=0 ; j<nbr_coefs(1) ; j++) {
46  pos_cf.set(1) = j ;
47  switch (baset) {
48  case COS_EVEN:
49  if (k<kmin) {
50  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
51  pos_sec ++ ;
52  }
53  else if (j!=0) {
54  // Galerkin base
55  pos_galerkin = pos_cf ;
56  pos_galerkin.set(1) = 0 ;
57  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
58  -2.*val_boundary(bound, so, pos_galerkin) ;
59  pos_sec ++ ;
60  }
61  break ;
62  case COS_ODD:
63  if (j!=nbr_coefs(1)-1) {
64  if (k<kmin) {
65  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
66  pos_sec ++ ;
67  }
68  else if (j!=0) {
69  // Galerkin base
70  pos_galerkin = pos_cf ;
71  pos_galerkin.set(1) = 0 ;
72  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
73  -val_boundary(bound, so, pos_galerkin) ;
74  pos_sec ++ ;
75  }}
76  break ;
77  case SIN_EVEN:
78  if ((j!=0) && (j!=nbr_coefs(1)-1)) {
79  if (k<kmin+2) {
80  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
81  pos_sec ++ ;
82  }
83  else if (j!=1) {
84  // Galerkin
85  pos_galerkin = pos_cf ;
86  pos_galerkin.set(1) = 1 ;
87  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
88  -j*val_boundary(bound, so, pos_galerkin) ;
89  pos_sec ++ ;
90 
91  }
92  }
93  break ;
94  case SIN_ODD:
95  if (j!=nbr_coefs(1)-1) {
96  if (k<kmin+2) {
97  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
98  pos_sec ++ ;
99  }
100  else if (j!=0) {
101  // Galerkin
102  pos_galerkin = pos_cf ;
103  pos_galerkin.set(1) = 0 ;
104  sec.set(pos_sec) = val_boundary(bound, so, pos_cf)
105  -(2*j+1)*val_boundary(bound, so, pos_galerkin) ;
106  pos_sec ++ ;
107 
108  }
109  }
110  break ;
111  default:
112  cerr << "Unknow theta basis in Domain_shell_outer_adapted::export_tau_val_domain_boundary" << endl ;
113  abort() ;
114  }
115  }
116  }
117  }
118 }
119 
120 void Domain_shell_outer_adapted::export_tau_boundary (const Tensor& tt, int dom, int bound, Array<double>& res, int& pos_res, const Array<int>& ncond,
121  int n_cmp, Array<int>** p_cmp) const {
122 
123  // Check boundary
124  if ((bound!=INNER_BC) && (bound!=OUTER_BC)) {
125  cerr << "Unknown boundary in Domain_shell_outer_adapted::export_tau_boundary" << endl ;
126  abort() ;
127  }
128 
129  int val = tt.get_valence() ;
130  switch (val) {
131  case 0 :
132  if (!tt.is_m_order_affected())
133  export_tau_val_domain_boundary (tt()(dom), 0, bound, res, pos_res, ncond(0)) ;
134  else
135  export_tau_val_domain_boundary (tt()(dom), tt.get_parameters().get_m_order(), bound, res, pos_res, ncond(0)) ;
136  break ;
137  case 1 : {
138  bool found = false ;
139  // Cartesian basis
140  if (tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) {
141  if (n_cmp==-1) {
142  export_tau_val_domain_boundary (tt(1)(dom), 0, bound, res, pos_res, ncond(0)) ;
143  export_tau_val_domain_boundary (tt(2)(dom), 0, bound, res, pos_res, ncond(1)) ;
144  export_tau_val_domain_boundary (tt(3)(dom), 0, bound, res, pos_res, ncond(2)) ;
145  }
146  else for (int i=0 ; i<n_cmp ; i++) {
147  if ((*p_cmp[i])(0)==1)
148  export_tau_val_domain_boundary (tt(1)(dom), 0, bound, res, pos_res, ncond(i)) ;
149  if ((*p_cmp[i])(0)==2)
150  export_tau_val_domain_boundary (tt(2)(dom), 0, bound, res, pos_res, ncond(i)) ;
151  if ((*p_cmp[i])(0)==3)
152  export_tau_val_domain_boundary (tt(3)(dom), 0, bound, res, pos_res, ncond(i)) ;
153  }
154  found = true ;
155  }
156  // Spherical coordinates
157  if (tt.get_basis().get_basis(dom)==SPHERICAL_BASIS) {
158  if (n_cmp==-1) {
159  export_tau_val_domain_boundary (tt(1)(dom), 0, bound, res, pos_res, ncond(0)) ;
160  export_tau_val_domain_boundary (tt(2)(dom), 1, bound, res, pos_res, ncond(1)) ;
161  export_tau_val_domain_boundary (tt(3)(dom), 1, bound, res, pos_res, ncond(2)) ;
162  }
163  else for (int i=0 ; i<n_cmp ; i++) {
164  if ((*p_cmp[i])(0)==1)
165  export_tau_val_domain_boundary (tt(1)(dom), 0, bound, res, pos_res, ncond(i)) ;
166  if ((*p_cmp[i])(0)==2)
167  export_tau_val_domain_boundary (tt(2)(dom), 1, bound, res, pos_res, ncond(i)) ;
168  if ((*p_cmp[i])(0)==3)
169  export_tau_val_domain_boundary (tt(3)(dom), 1, bound, res, pos_res, ncond(i)) ;
170  }
171  found = true ;
172  }
173  if (!found) {
174  cerr << "Unknown type of vector Domain_shell_outer_adapted::export_tau_boundary" << endl ;
175  abort() ;
176  }
177  }
178  break ;
179  case 2 : {
180  bool found = false ;
181  // Cartesian basis and symetric
182  if ((tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) && (tt.get_n_comp()==6)) {
183  if (n_cmp==-1) {
184  export_tau_val_domain_boundary (tt(1,1)(dom), 0, bound, res, pos_res, ncond(0)) ;
185  export_tau_val_domain_boundary (tt(1,2)(dom), 0, bound, res, pos_res, ncond(1)) ;
186  export_tau_val_domain_boundary (tt(1,3)(dom), 0, bound, res, pos_res, ncond(2)) ;
187  export_tau_val_domain_boundary (tt(2,2)(dom), 0, bound, res, pos_res, ncond(3)) ;
188  export_tau_val_domain_boundary (tt(2,3)(dom), 0, bound, res, pos_res, ncond(4)) ;
189  export_tau_val_domain_boundary (tt(3,3)(dom), 0, bound, res, pos_res, ncond(5)) ;
190  }
191  else for (int i=0 ; i<n_cmp ; i++) {
192  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
193  export_tau_val_domain_boundary (tt(1, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
194  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
195  export_tau_val_domain_boundary (tt(1, 2)(dom), 0, bound, res, pos_res, ncond(i)) ;
196  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
197  export_tau_val_domain_boundary (tt(1, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
198  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
199  export_tau_val_domain_boundary (tt(2, 2)(dom), 0, bound, res, pos_res, ncond(i)) ;
200  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
201  export_tau_val_domain_boundary (tt(2, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
202  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
203  export_tau_val_domain_boundary (tt(3, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
204  }
205  found = true ;
206  }
207  // Cartesian basis and not symetric
208  if ((tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) && (tt.get_n_comp()==9)) {
209  if (n_cmp==-1) {
210  export_tau_val_domain_boundary (tt(1,1)(dom), 0, bound, res, pos_res, ncond(0)) ;
211  export_tau_val_domain_boundary (tt(1,2)(dom), 0, bound, res, pos_res, ncond(1)) ;
212  export_tau_val_domain_boundary (tt(1,3)(dom), 0, bound, res, pos_res, ncond(2)) ;
213  export_tau_val_domain_boundary (tt(2,1)(dom), 0, bound, res, pos_res, ncond(3)) ;
214  export_tau_val_domain_boundary (tt(2,2)(dom), 0, bound, res, pos_res, ncond(4)) ;
215  export_tau_val_domain_boundary (tt(2,3)(dom), 0, bound, res, pos_res, ncond(5)) ;
216  export_tau_val_domain_boundary (tt(3,1)(dom), 0, bound, res, pos_res, ncond(6)) ;
217  export_tau_val_domain_boundary (tt(3,2)(dom), 0, bound, res, pos_res, ncond(7)) ;
218  export_tau_val_domain_boundary (tt(3,3)(dom), 0, bound, res, pos_res, ncond(8)) ;
219 
220  }
221  else for (int i=0 ; i<n_cmp ; i++) {
222  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
223  export_tau_val_domain_boundary (tt(1, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
224  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
225  export_tau_val_domain_boundary (tt(1, 2)(dom), 0, bound, res, pos_res, ncond(i)) ;
226  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
227  export_tau_val_domain_boundary (tt(1, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
228  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==1))
229  export_tau_val_domain_boundary (tt(2, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
230  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
231  export_tau_val_domain_boundary (tt(2, 2)(dom), 0, bound, res, pos_res, ncond(i)) ;
232  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
233  export_tau_val_domain_boundary (tt(2, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
234  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
235  export_tau_val_domain_boundary (tt(3, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
236  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
237  export_tau_val_domain_boundary (tt(3, 2)(dom), 0, bound, res, pos_res, ncond(i)) ;
238  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
239  export_tau_val_domain_boundary (tt(3, 3)(dom), 0, bound, res, pos_res, ncond(i)) ;
240  }
241  found = true ;
242  }
243  // Spherical coordinates and symetric
244  if ((tt.get_basis().get_basis(dom)==SPHERICAL_BASIS) && (tt.get_n_comp()==6)) {
245  if (n_cmp==-1) {
246  export_tau_val_domain_boundary (tt(1,1)(dom), 0, bound, res, pos_res, ncond(0)) ;
247  export_tau_val_domain_boundary (tt(1,2)(dom), 1, bound, res, pos_res, ncond(1)) ;
248  export_tau_val_domain_boundary (tt(1,3)(dom), 1, bound, res, pos_res, ncond(2)) ;
249  export_tau_val_domain_boundary (tt(2,2)(dom), 2, bound, res, pos_res, ncond(3)) ;
250  export_tau_val_domain_boundary (tt(2,3)(dom), 2, bound, res, pos_res, ncond(4)) ;
251  export_tau_val_domain_boundary (tt(3,3)(dom), 2, bound, res, pos_res, ncond(5)) ;
252  }
253  else for (int i=0 ; i<n_cmp ; i++) {
254  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
255  export_tau_val_domain_boundary (tt(1, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
256  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
257  export_tau_val_domain_boundary (tt(1, 2)(dom), 1, bound, res, pos_res, ncond(i)) ;
258  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
259  export_tau_val_domain_boundary (tt(1, 3)(dom), 1, bound, res, pos_res, ncond(i)) ;
260  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
261  export_tau_val_domain_boundary (tt(2, 2)(dom), 2, bound, res, pos_res, ncond(i)) ;
262  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
263  export_tau_val_domain_boundary (tt(2, 3)(dom), 2, bound, res, pos_res, ncond(i)) ;
264  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
265  export_tau_val_domain_boundary (tt(3, 3)(dom), 2, bound, res, pos_res, ncond(i)) ;
266  }
267  found = true ;
268  }
269  // Spherical coordinates and not symetric
270  if ((tt.get_basis().get_basis(dom)==SPHERICAL_BASIS) && (tt.get_n_comp()==9)) {
271  if (n_cmp==-1) {
272  export_tau_val_domain_boundary (tt(1,1)(dom), 0, bound, res, pos_res, ncond(0)) ;
273  export_tau_val_domain_boundary (tt(1,2)(dom), 1, bound, res, pos_res, ncond(1)) ;
274  export_tau_val_domain_boundary (tt(1,3)(dom), 1, bound, res, pos_res, ncond(2)) ;
275  export_tau_val_domain_boundary (tt(2,1)(dom), 1, bound, res, pos_res, ncond(3)) ;
276  export_tau_val_domain_boundary (tt(2,2)(dom), 2, bound, res, pos_res, ncond(4)) ;
277  export_tau_val_domain_boundary (tt(2,3)(dom), 2, bound, res, pos_res, ncond(5)) ;
278  export_tau_val_domain_boundary (tt(3,1)(dom), 1, bound, res, pos_res, ncond(6)) ;
279  export_tau_val_domain_boundary (tt(3,2)(dom), 2, bound, res, pos_res, ncond(7)) ;
280  export_tau_val_domain_boundary (tt(3,3)(dom), 2, bound, res, pos_res, ncond(8)) ;
281  }
282  else for (int i=0 ; i<n_cmp ; i++) {
283  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
284  export_tau_val_domain_boundary (tt(1, 1)(dom), 0, bound, res, pos_res, ncond(i)) ;
285  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
286  export_tau_val_domain_boundary (tt(1, 2)(dom), 1, bound, res, pos_res, ncond(i)) ;
287  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
288  export_tau_val_domain_boundary (tt(1, 3)(dom), 1, bound, res, pos_res, ncond(i)) ;
289  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==1))
290  export_tau_val_domain_boundary (tt(2, 1)(dom), 1, bound, res, pos_res, ncond(i)) ;
291  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
292  export_tau_val_domain_boundary (tt(2, 2)(dom), 2, bound, res, pos_res, ncond(i)) ;
293  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
294  export_tau_val_domain_boundary (tt(2, 3)(dom), 2, bound, res, pos_res, ncond(i)) ;
295  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
296  export_tau_val_domain_boundary (tt(3, 1)(dom), 1, bound, res, pos_res, ncond(i)) ;
297  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
298  export_tau_val_domain_boundary (tt(3, 2)(dom), 2, bound, res, pos_res, ncond(i)) ;
299  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
300  export_tau_val_domain_boundary (tt(3, 3)(dom), 2, bound, res, pos_res, ncond(i)) ;
301  }
302  found = true ;
303  }
304  if (!found) {
305  cerr << "Unknown type of 2-tensor Domain_shell_outer_adapted::export_tau_boundary" << endl ;
306  abort() ;
307  }
308  }
309  break ;
310  default :
311  cerr << "Valence " << val << " not implemented in Domain_shell_outer_adapted::export_tau_boundary" << endl ;
312  break ;
313  }
314 }
315 }
316 
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.
int get_basis(int nd) const
Read only the basis in a given domain.
Definition: base_tensor.hpp:93
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
virtual void export_tau_boundary(const Tensor &, int, int, Array< double > &, int &, const Array< int > &, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Exports all the residual equations corresponding to a tensorial one on a given boundary It makes use ...
void export_tau_val_domain_boundary(const Val_domain &eq, int mlim, int bound, Array< double > &res, int &pos_res, int ncond) const
Exports all the residual equations corresponding to a tensorial one on a given boundary It makes use ...
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_order() const
Returns .
Definition: tensor.hpp:737
Tensor handling.
Definition: tensor.hpp:149
bool is_m_order_affected() const
Checks whether the additional parameter order is affected (not very used).
Definition: tensor.hpp:323
const Param_tensor & get_parameters() const
Returns a pointer on the possible additional parameter.
Definition: tensor.hpp:311
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tensor.hpp:504
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.hpp:514
int get_valence() const
Returns the valence.
Definition: tensor.hpp:509
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