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