KADATH
domain_polar_periodic_nucleus_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_nucleus::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_nucleus_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_nucleus_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_nucleus::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  // Check boundary
97  if (bound!=OUTER_BC) {
98  cerr << "Unknown boundary in Domain_polar_periodic_nucleus::export_tau_boundary" << endl ;
99  abort() ;
100  }
101 
102  int val = tt.get_valence() ;
103  switch (val) {
104  case 0 :
105  export_tau_val_domain_boundary (tt()(dom), bound, res, pos_res, ncond(0)) ;
106  break ;
107  case 1 :
108  if (n_cmp==-1) {
109  export_tau_val_domain_boundary (tt(1)(dom), bound, res, pos_res, ncond(0)) ;
110  export_tau_val_domain_boundary (tt(2)(dom), bound, res, pos_res, ncond(1)) ;
111  export_tau_val_domain_boundary (tt(3)(dom), bound, res, pos_res, ncond(2)) ;
112  }
113  else for (int i=0 ; i<n_cmp ; i++) {
114  if ((*p_cmp[i])(0)==1)
115  export_tau_val_domain_boundary (tt(1)(dom), bound, res, pos_res, ncond(i)) ;
116  if ((*p_cmp[i])(0)==2)
117  export_tau_val_domain_boundary (tt(2)(dom), bound, res, pos_res, ncond(i)) ;
118  if ((*p_cmp[i])(0)==3)
119  export_tau_val_domain_boundary (tt(3)(dom), bound, res, pos_res, ncond(i)) ;
120  }
121  break ;
122  case 2 :
123  if (tt.get_n_comp()==6) {
124  if (n_cmp==-1) {
125  export_tau_val_domain_boundary (tt(1,1)(dom), bound, res, pos_res, ncond(0)) ;
126  export_tau_val_domain_boundary (tt(1,2)(dom), bound, res, pos_res, ncond(1)) ;
127  export_tau_val_domain_boundary (tt(1,3)(dom), bound, res, pos_res, ncond(2)) ;
128  export_tau_val_domain_boundary (tt(2,2)(dom), bound, res, pos_res, ncond(3)) ;
129  export_tau_val_domain_boundary (tt(2,3)(dom), bound, res, pos_res, ncond(4)) ;
130  export_tau_val_domain_boundary (tt(3,3)(dom), bound, res, pos_res, ncond(5)) ;
131  }
132  else for (int i=0 ; i<n_cmp ; i++) {
133  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
134  export_tau_val_domain_boundary (tt(1, 1)(dom), bound, res, pos_res, ncond(i)) ;
135  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
136  export_tau_val_domain_boundary (tt(1, 2)(dom), bound, res, pos_res, ncond(i)) ;
137  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
138  export_tau_val_domain_boundary (tt(1, 3)(dom), bound, res, pos_res, ncond(i)) ;
139  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
140  export_tau_val_domain_boundary (tt(2, 2)(dom), bound, res, pos_res, ncond(i)) ;
141  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
142  export_tau_val_domain_boundary (tt(2, 3)(dom), bound, res, pos_res, ncond(i)) ;
143  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
144  export_tau_val_domain_boundary (tt(3, 3)(dom), bound, res, pos_res, ncond(i)) ;
145  }
146  }
147  // not symetric
148  if (tt.get_n_comp()==9) {
149  if (n_cmp==-1) {
150  export_tau_val_domain_boundary (tt(1,1)(dom), bound, res, pos_res, ncond(0)) ;
151  export_tau_val_domain_boundary (tt(1,2)(dom), bound, res, pos_res, ncond(1)) ;
152  export_tau_val_domain_boundary (tt(1,3)(dom), bound, res, pos_res, ncond(2)) ;
153  export_tau_val_domain_boundary (tt(2,1)(dom), bound, res, pos_res, ncond(3)) ;
154  export_tau_val_domain_boundary (tt(2,2)(dom), bound, res, pos_res, ncond(4)) ;
155  export_tau_val_domain_boundary (tt(2,3)(dom), bound, res, pos_res, ncond(5)) ;
156  export_tau_val_domain_boundary (tt(3,1)(dom), bound, res, pos_res, ncond(6)) ;
157  export_tau_val_domain_boundary (tt(3,2)(dom), bound, res, pos_res, ncond(7)) ;
158  export_tau_val_domain_boundary (tt(3,3)(dom), bound, res, pos_res, ncond(8)) ;
159 
160  }
161  else for (int i=0 ; i<n_cmp ; i++) {
162  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
163  export_tau_val_domain_boundary (tt(1, 1)(dom), bound, res, pos_res, ncond(i)) ;
164  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
165  export_tau_val_domain_boundary (tt(1, 2)(dom), bound, res, pos_res, ncond(i)) ;
166  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
167  export_tau_val_domain_boundary (tt(1, 3)(dom), bound, res, pos_res, ncond(i)) ;
168  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==1))
169  export_tau_val_domain_boundary (tt(2, 1)(dom), bound, res, pos_res, ncond(i)) ;
170  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
171  export_tau_val_domain_boundary (tt(2, 2)(dom), bound, res, pos_res, ncond(i)) ;
172  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
173  export_tau_val_domain_boundary (tt(2, 3)(dom), bound, res, pos_res, ncond(i)) ;
174  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
175  export_tau_val_domain_boundary (tt(3, 1)(dom), bound, res, pos_res, ncond(i)) ;
176  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
177  export_tau_val_domain_boundary (tt(3, 2)(dom), bound, res, pos_res, ncond(i)) ;
178  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
179  export_tau_val_domain_boundary (tt(3, 3)(dom), bound, res, pos_res, ncond(i)) ;
180  }
181  }
182  break ;
183  default :
184  cerr << "Valence " << val << " not implemented in Domain_polar_periodic_nucleus::export_tau_boundary" << endl ;
185  abort() ;
186  break ;
187  }
188 }}
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(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 ...
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 ...
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