KADATH
domain_shell_symphi_nbr_conditions_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 "spheric_symphi.hpp"
22 #include "array_math.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 #include "tensor.hpp"
26 namespace Kadath {
28 
29  int res = 0 ;
30 
31  for (int k=0 ; k<nbr_coefs(2) ; k++)
32  for (int j=0 ; j<nbr_coefs(1) ; j++) {
33  bool indic = true ;
34 
35  int mquant ;
36  // Base in phi
37  int basep = (*so.get_base().bases_1d[2]) (0) ;
38  switch (basep) {
39  case COS_EVEN:
40  mquant = 2*k ;
41  break ;
42  case COS_ODD:
43  if (k==nbr_coefs(2)-1)
44  indic = false ;
45  mquant = 2*k+1 ;
46  break ;
47  case SIN_EVEN:
48  if ((k==0) || (k==nbr_coefs(2)-1))
49  indic = false ;
50  mquant = 2*k ;
51  break ;
52  case SIN_ODD:
53  if (k==nbr_coefs(2)-1)
54  indic = false ;
55  mquant = 2*k+1 ;
56  break ;
57  default:
58  cerr << "Unknow phi basis in Domain_shell_symphi::nbr_unknowns_val_domain" << endl ;
59  abort() ;
60  }
61 
62  // Get base in theta :
63  int baset = (*so.get_base().bases_1d[1]) (k) ;
64  if (indic) {
65  switch (baset) {
66  case COS_EVEN:
67  if ((j==0) && (mquant>0))
68  indic = false ;
69  break ;
70  case COS_ODD:
71  if ((j==nbr_coefs(1)-1) || ((j==0) && (mquant>0)))
72  indic = false ;
73  break ;
74  case SIN_EVEN:
75  if (((j==1) && (mquant>1)) || (j==0) || (j==nbr_coefs(1)-1))
76  indic = false ;
77  break ;
78  case SIN_ODD:
79  if (((j==0) && (mquant>1)) || (j==nbr_coefs(1)-1))
80  indic = false ;
81  break ;
82  default:
83  cerr << "Unknow theta basis in Domain_shell_symphi::nbr_unknowns_val_domain" << endl ;
84  abort() ;
85  }
86  }
87 
88  if (indic)
89  res ++ ;
90  }
91  return res ;
92 }
93 
94 Array<int> Domain_shell_symphi::nbr_conditions_boundary (const Tensor& tt, int dom, int bound, int n_cmp, Array<int>** p_cmp) const {
95 
96  // Check boundary
97  if ((bound!=OUTER_BC) && (bound !=INNER_BC)) {
98  cerr << "Unknown boundary in Domain_shell_symphi::nbr_conditions_boundary" << endl ;
99  abort() ;
100  }
101 
102  int size = (n_cmp==-1) ? tt.get_n_comp() : n_cmp ;
103  Array<int> res (size) ;
104  int val = tt.get_valence() ;
105  switch (val) {
106  case 0 :
107  res.set(0) = nbr_conditions_val_domain_boundary (tt()(dom)) ;
108  break ;
109  case 1 : {
110  bool found = false ;
111  // Cartesian basis
112  if (tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) {
113  if (n_cmp==-1) {
114  res.set(0) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
115  res.set(1) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
116  res.set(2) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
117  }
118  else for (int i=0 ; i<n_cmp ; i++) {
119  if ((*p_cmp[i])(0)==1)
120  res.set(i) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
121  if ((*p_cmp[i])(0)==2)
122  res.set(i) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
123  if ((*p_cmp[i])(0)==3)
124  res.set(i) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
125  }
126  found = true ;
127  }
128 
129  if (!found) {
130  cerr << "Unknown type of vector Domain_shell_symphi::nbr_conditions_boundary" << endl ;
131  abort() ;
132  }
133  }
134  break ;
135  case 2 : {
136  bool found = false ;
137  // Cartesian basis and symetric
138  if ((tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) && (tt.get_n_comp()==6)) {
139  if (n_cmp==-1) {
140  res.set(0) = nbr_conditions_val_domain_boundary (tt(1,1)(dom)) ;
141  res.set(1) = nbr_conditions_val_domain_boundary (tt(1,2)(dom)) ;
142  res.set(2) = nbr_conditions_val_domain_boundary (tt(1,3)(dom)) ;
143  res.set(3) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
144  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
145  res.set(5) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
146  }
147  else for (int i=0 ; i<n_cmp ; i++) {
148  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
149  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
150  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
151  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
152  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
153  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
154  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
155  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
156  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
157  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
158  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
159  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
160  }
161  found = true ;
162  }
163  // Cartesian basis and not symetric
164  if ((tt.get_basis().get_basis(dom)==CARTESIAN_BASIS) && (tt.get_n_comp()==9)) {
165  if (n_cmp==-1) {
166  res.set(0) = nbr_conditions_val_domain_boundary (tt(1,1)(dom)) ;
167  res.set(1) = nbr_conditions_val_domain_boundary (tt(1,2)(dom)) ;
168  res.set(2) = nbr_conditions_val_domain_boundary (tt(1,3)(dom)) ;
169  res.set(3) = nbr_conditions_val_domain_boundary (tt(2,1)(dom)) ;
170  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
171  res.set(5) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
172  res.set(6) = nbr_conditions_val_domain_boundary (tt(3,1)(dom)) ;
173  res.set(7) = nbr_conditions_val_domain_boundary (tt(3,2)(dom)) ;
174  res.set(8) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
175  }
176  else for (int i=0 ; i<n_cmp ; i++) {
177  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
178  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
179  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
180  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
181  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
182  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
183  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
184  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 1)(dom)) ;
185  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
186  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
187  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
188  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
189  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
190  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 1)(dom)) ;
191  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
192  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 2)(dom)) ;
193  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
194  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
195  }
196  found = true ;
197  }
198  if (!found) {
199  cerr << "Unknown type of 2-tensor Domain_shell_symphi::nbr_conditions_boundary" << endl ;
200  abort() ;
201  }
202  }
203  break ;
204  default :
205  cerr << "Valence " << val << " not implemented in Domain_shell_symphi::nbr_conditions_boundary" << endl ;
206  break ;
207  }
208  return res ;
209 }}
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 Array< int > nbr_conditions_boundary(const Tensor &, int, int, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Computes number of discretized equations associated with a given tensorial equation on a boundary.
int nbr_conditions_val_domain_boundary(const Val_domain &eq) const
Computes number of discretized equations associated with a given equation on a boundary.
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
Tensor handling.
Definition: tensor.hpp:149
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
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122