KADATH
domain_polar_periodic_nucleus_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_nucleus::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_nucleus::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_nucleus::nbr_conditions_boundary (const Tensor& tt, int dom, int bound, int n_cmp, Array<int>** p_cmp) const {
81 
82 #ifndef REMOVE_ALL_CHECKS
83  // Check boundary
84  if (bound!=OUTER_BC) {
85  cerr << "Unknown boundary in Domain_polar_periodic_nucleus::nbr_conditions_boundary" << endl ;
86  abort() ;
87  }
88 #endif
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)) ;
96  break ;
97  case 1 :
98  if (n_cmp==-1) {
99  res.set(0) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
100  res.set(1) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
101  res.set(2) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
102  }
103  else for (int i=0 ; i<n_cmp ; i++) {
104  if ((*p_cmp[i])(0)==1)
105  res.set(i) = nbr_conditions_val_domain_boundary (tt(1)(dom)) ;
106  if ((*p_cmp[i])(0)==2)
107  res.set(i) = nbr_conditions_val_domain_boundary (tt(2)(dom)) ;
108  if ((*p_cmp[i])(0)==3)
109  res.set(i) = nbr_conditions_val_domain_boundary (tt(3)(dom)) ;
110  }
111  break ;
112  case 2 :
113  if (tt.get_n_comp()==6) {
114  if (n_cmp==-1) {
115  res.set(0) = nbr_conditions_val_domain_boundary (tt(1,1)(dom)) ;
116  res.set(1) = nbr_conditions_val_domain_boundary (tt(1,2)(dom)) ;
117  res.set(2) = nbr_conditions_val_domain_boundary (tt(1,3)(dom)) ;
118  res.set(3) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
119  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
120  res.set(5) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
121  }
122  else for (int i=0 ; i<n_cmp ; i++) {
123  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
124  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
125  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
126  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
127  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
128  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
129  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
130  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
131  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
132  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
133  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
134  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
135  }
136  }
137  // not symetric
138  if (tt.get_n_comp()==9) {
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,1)(dom)) ;
144  res.set(4) = nbr_conditions_val_domain_boundary (tt(2,2)(dom)) ;
145  res.set(5) = nbr_conditions_val_domain_boundary (tt(2,3)(dom)) ;
146  res.set(6) = nbr_conditions_val_domain_boundary (tt(3,1)(dom)) ;
147  res.set(7) = nbr_conditions_val_domain_boundary (tt(3,2)(dom)) ;
148  res.set(8) = nbr_conditions_val_domain_boundary (tt(3,3)(dom)) ;
149  }
150  else for (int i=0 ; i<n_cmp ; i++) {
151  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
152  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 1)(dom)) ;
153  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==2))
154  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 2)(dom)) ;
155  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==3))
156  res.set(i) = nbr_conditions_val_domain_boundary (tt(1, 3)(dom)) ;
157  if (((*p_cmp[i])(0)==1) && ((*p_cmp[i])(1)==1))
158  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 1)(dom)) ;
159  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==2))
160  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 2)(dom)) ;
161  if (((*p_cmp[i])(0)==2) && ((*p_cmp[i])(1)==3))
162  res.set(i) = nbr_conditions_val_domain_boundary (tt(2, 3)(dom)) ;
163  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==1))
164  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 1)(dom)) ;
165  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==2))
166  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 2)(dom)) ;
167  if (((*p_cmp[i])(0)==3) && ((*p_cmp[i])(1)==3))
168  res.set(i) = nbr_conditions_val_domain_boundary (tt(3, 3)(dom)) ;
169  }
170  }
171  break ;
172  default :
173  cerr << "Valence " << val << " not implemented in Domain_polar_periodic_nucleus::nbr_conditions_boundary" << endl ;
174  break ;
175  }
176  return res ;
177 }}
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 nbr_conditions_val_domain_boundary(const Val_domain &eq) 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
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