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