KADATH
domain_polar_periodic_shell_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 "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 {
30 
31  int res = 0 ;
32 
33  for (int k=0 ; k<nbr_coefs(2) ; k++)
34  for (int j=0 ; j<nbr_coefs(1) ; j++) {
35  bool indic = true ;
36 
37  // Base in time
38  int basetime = (*so.get_base().bases_1d[2]) (0) ;
39  switch (basetime) {
40  case COS:
41  break ;
42  case SIN:
43  if ((k==0) || (k==nbr_coefs(2)-1))
44  indic = false ;
45  break ;
46  default:
47  cerr << "Unknow time basis in Domain_polar_polar_shell::nbr_conditions_val_domain_boundary" << endl ;
48  abort() ;
49  }
50 
51 
52  // Get base in theta :
53  int baset = (*so.get_base().bases_1d[1])(k) ;
54  switch (baset) {
55  case COS_EVEN:
56  break ;
57  case COS_ODD:
58  if (j==nbr_coefs(1)-1)
59  indic = false ;
60  break ;
61  case SIN_EVEN:
62  if ((j==0) || (j==nbr_coefs(1)-1))
63  indic = false ;
64  break ;
65  case SIN_ODD:
66  if (j==nbr_coefs(1)-1)
67  indic = false ;
68  break ;
69  default:
70  cerr << "Unknow theta basis in Domain_polar_periodic_shell::nbr_conditions_val_boundary" << endl ;
71  abort() ;
72  }
73 
74  if (indic)
75  res ++ ;
76  }
77  return res ;
78 }
79 
80 Array<int> Domain_polar_periodic_shell::nbr_conditions_boundary (const Tensor& tt, int dom, int bound, int n_cmp, Array<int>** p_cmp) const {
81 
82  // Check boundary
83  if ((bound!=OUTER_BC) && (bound!=INNER_BC)) {
84  cerr << "Unknown boundary in Domain_polar_periodic_shell::nbr_conditions_boundary" << endl ;
85  abort() ;
86  }
87 
88  int size = (n_cmp==-1) ? tt.get_n_comp() : n_cmp ;
89  Array<int> res (size) ;
90  int val = tt.get_valence() ;
91  switch (val) {
92  case 0 :
93  res.set(0) = nbr_conditions_val_domain_boundary (tt()(dom)) ;
94  break ;
95  case 1 :
96  if (n_cmp==-1) {
97  res.set(0) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
98  res.set(1) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
99  res.set(2) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
100  }
101  else for (int i=0 ; i<n_cmp ; i++) {
102  if ((*p_cmp[i])(0)==1)
103  res.set(i) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
104  if ((*p_cmp[i])(0)==2)
105  res.set(i) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
106  if ((*p_cmp[i])(0)==3)
107  res.set(i) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
108  }
109  break ;
110  case 2 :
111  if (tt.get_n_comp()==6) {
112  if (n_cmp==-1) {
113  res.set(0) = nbr_conditions_val_domain_boundary (tt(1,1)(dom)) ;
114  res.set(1) = nbr_conditions_val_domain_boundary (tt(1,2)(dom)) ;
115  res.set(2) = nbr_conditions_val_domain_boundary (tt(1,3)(dom)) ;
116  res.set(3) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
117  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
118  res.set(5) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
119  }
120  else for (int i=0 ; i<n_cmp ; i++) {
121  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
122  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
123  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
124  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
125  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
126  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
127  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
128  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
129  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
130  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
131  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
132  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
133  }
134  }
135  // not symetric
136  if (tt.get_n_comp()==9) {
137  if (n_cmp==-1) {
138  res.set(0) = nbr_conditions_val_domain_boundary (tt(1,1)(dom)) ;
139  res.set(1) = nbr_conditions_val_domain_boundary (tt(1,2)(dom)) ;
140  res.set(2) = nbr_conditions_val_domain_boundary (tt(1,3)(dom)) ;
141  res.set(3) = nbr_conditions_val_domain_boundary (tt(2,1)(dom)) ;
142  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
143  res.set(5) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
144  res.set(6) = nbr_conditions_val_domain_boundary (tt(3,1)(dom)) ;
145  res.set(7) = nbr_conditions_val_domain_boundary (tt(3,2)(dom)) ;
146  res.set(8) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
147  }
148  else for (int i=0 ; i<n_cmp ; i++) {
149  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
150  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
151  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
152  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
153  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
154  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
155  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
156  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 1)(dom)) ;
157  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
158  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
159  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
160  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
161  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
162  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 1)(dom)) ;
163  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
164  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 2)(dom)) ;
165  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
166  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
167  }
168  }
169  break ;
170  default :
171  cerr << "Valence " << val << " not implemented in Domain_polar_periodic_shell::nbr_conditions_boundary" << endl ;
172  break ;
173  }
174  return res ;
175 }}
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 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
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