KADATH
domain_polar_periodic_shell_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 "polar_periodic.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_polar_periodic_shell::export_tau_val_domain_boundary (const Val_domain& so, 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  Index pos_cf (nbr_coefs) ;
36 
37  int basetime = (*so.get_base().bases_1d[2]) (0) ;
38  int mink, maxk ;
39  switch (basetime) {
40  case COS :
41  mink=0 ;
42  maxk=nbr_coefs(2) ;
43  break ;
44  case SIN :
45  mink=1 ;
46  maxk=nbr_coefs(2)-1 ;
47  break ;
48  default :
49  cerr << "Unknown time basis in Domain_polar_periodic_shell_export_tau_val_domain_boundary" << endl ;
50  abort() ;
51  }
52 
53 
54  for (int k=mink ; k<maxk ; k++) {
55  pos_cf.set(2) = k ;
56 
57  // Loop on theta
58  int baset = (*so.get_base().bases_1d[1]) (k) ;
59  int minj, maxj ;
60  switch (baset) {
61  case COS_EVEN :
62  minj=0 ;
63  maxj=nbr_coefs(1) ;
64  break ;
65  case COS_ODD :
66  minj=0 ;
67  maxj=nbr_coefs(1)-1 ;
68  break ;
69  case SIN_EVEN :
70  minj=1 ;
71  maxj=nbr_coefs(1)-1 ;
72  break ;
73  case SIN_ODD :
74  minj=0 ;
75  maxj=nbr_coefs(1)-1 ;
76  break ;
77 
78  default :
79  cerr << "Unknown theta basis in Domain_polar_periodic_shell_export_tau_val_domain" << endl ;
80  abort() ;
81  }
82 
83 
84  for (int j=minj ; j<maxj ; j++) {
85  pos_cf.set(1) = j ;
86  sec.set(pos_sec) = val_boundary(bound, so, pos_cf) ;
87  pos_sec ++ ;
88  } // end loop j
89  } // end loop k
90  } // end null case
91 }
92 
93 void Domain_polar_periodic_shell::export_tau_boundary (const Tensor& tt, int dom, int bound, Array<double>& res, int& pos_res, const Array<int>& ncond,
94  int n_cmp, Array<int>** p_cmp) const {
95 
96 #ifndef REMOVE_ALL_CHECKS
97  // Check boundary
98  if ((bound!=OUTER_BC) && (bound!=INNER_BC)) {
99  cerr << "Unknown boundary in Domain_polar_periodic_shell::export_tau_boundary" << endl ;
100  abort() ;
101  }
102 #endif
103 
104  int val = tt.get_valence() ;
105  switch (val) {
106  case 0 :
107  export_tau_val_domain_boundary (tt()(dom), bound, res, pos_res, ncond(0)) ;
108  break ;
109  case 1 :
110  if (n_cmp==-1) {
111  export_tau_val_domain_boundary (tt(1)(dom), bound, res, pos_res, ncond(0)) ;
112  export_tau_val_domain_boundary (tt(2)(dom), bound, res, pos_res, ncond(1)) ;
113  export_tau_val_domain_boundary (tt(3)(dom), bound, res, pos_res, ncond(2)) ;
114  }
115  else for (int i=0 ; i<n_cmp ; i++) {
116  if ((*p_cmp[i])(0)==1)
117  export_tau_val_domain_boundary (tt(1)(dom), bound, res, pos_res, ncond(i)) ;
118  if ((*p_cmp[i])(0)==2)
119  export_tau_val_domain_boundary (tt(2)(dom), bound, res, pos_res, ncond(i)) ;
120  if ((*p_cmp[i])(0)==3)
121  export_tau_val_domain_boundary (tt(3)(dom), bound, res, pos_res, ncond(i)) ;
122  }
123  break ;
124  case 2 :
125  if (tt.get_n_comp()==6) {
126  if (n_cmp==-1) {
127  export_tau_val_domain_boundary (tt(1,1)(dom), bound, res, pos_res, ncond(0)) ;
128  export_tau_val_domain_boundary (tt(1,2)(dom), bound, res, pos_res, ncond(1)) ;
129  export_tau_val_domain_boundary (tt(1,3)(dom), bound, res, pos_res, ncond(2)) ;
130  export_tau_val_domain_boundary (tt(2,2)(dom), bound, res, pos_res, ncond(3)) ;
131  export_tau_val_domain_boundary (tt(2,3)(dom), bound, res, pos_res, ncond(4)) ;
132  export_tau_val_domain_boundary (tt(3,3)(dom), bound, res, pos_res, ncond(5)) ;
133  }
134  else for (int i=0 ; i<n_cmp ; i++) {
135  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
136  export_tau_val_domain_boundary (tt(1, 1)(dom), bound, res, pos_res, ncond(i)) ;
137  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
138  export_tau_val_domain_boundary (tt(1, 2)(dom), bound, res, pos_res, ncond(i)) ;
139  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
140  export_tau_val_domain_boundary (tt(1, 3)(dom), bound, res, pos_res, ncond(i)) ;
141  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
142  export_tau_val_domain_boundary (tt(2, 2)(dom), bound, res, pos_res, ncond(i)) ;
143  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
144  export_tau_val_domain_boundary (tt(2, 3)(dom), bound, res, pos_res, ncond(i)) ;
145  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
146  export_tau_val_domain_boundary (tt(3, 3)(dom), bound, res, pos_res, ncond(i)) ;
147  }
148  }
149  // not symetric
150  if (tt.get_n_comp()==9) {
151  if (n_cmp==-1) {
152  export_tau_val_domain_boundary (tt(1,1)(dom), bound, res, pos_res, ncond(0)) ;
153  export_tau_val_domain_boundary (tt(1,2)(dom), bound, res, pos_res, ncond(1)) ;
154  export_tau_val_domain_boundary (tt(1,3)(dom), bound, res, pos_res, ncond(2)) ;
155  export_tau_val_domain_boundary (tt(2,1)(dom), bound, res, pos_res, ncond(3)) ;
156  export_tau_val_domain_boundary (tt(2,2)(dom), bound, res, pos_res, ncond(4)) ;
157  export_tau_val_domain_boundary (tt(2,3)(dom), bound, res, pos_res, ncond(5)) ;
158  export_tau_val_domain_boundary (tt(3,1)(dom), bound, res, pos_res, ncond(6)) ;
159  export_tau_val_domain_boundary (tt(3,2)(dom), bound, res, pos_res, ncond(7)) ;
160  export_tau_val_domain_boundary (tt(3,3)(dom), bound, res, pos_res, ncond(8)) ;
161 
162  }
163  else for (int i=0 ; i<n_cmp ; i++) {
164  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
165  export_tau_val_domain_boundary (tt(1, 1)(dom), bound, res, pos_res, ncond(i)) ;
166  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
167  export_tau_val_domain_boundary (tt(1, 2)(dom), bound, res, pos_res, ncond(i)) ;
168  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
169  export_tau_val_domain_boundary (tt(1, 3)(dom), bound, res, pos_res, ncond(i)) ;
170  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==1))
171  export_tau_val_domain_boundary (tt(2, 1)(dom), bound, res, pos_res, ncond(i)) ;
172  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
173  export_tau_val_domain_boundary (tt(2, 2)(dom), bound, res, pos_res, ncond(i)) ;
174  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
175  export_tau_val_domain_boundary (tt(2, 3)(dom), bound, res, pos_res, ncond(i)) ;
176  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
177  export_tau_val_domain_boundary (tt(3, 1)(dom), bound, res, pos_res, ncond(i)) ;
178  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
179  export_tau_val_domain_boundary (tt(3, 2)(dom), bound, res, pos_res, ncond(i)) ;
180  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
181  export_tau_val_domain_boundary (tt(3, 3)(dom), bound, res, pos_res, ncond(i)) ;
182  }
183  }
184  break ;
185  default :
186  cerr << "Valence " << val << " not implemented in Domain_polar_periodic_shell::export_tau_boundary" << endl ;
187  abort() ;
188  break ;
189  }
190 }}
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.
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 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
Tensor handling.
Definition: tensor.hpp:149
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