KADATH
domain_polar_nucleus_nbr_conditions.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.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 int Domain_polar_nucleus::nbr_conditions_val_domain (const Val_domain& so, int mquant, int llim, int order) const {
30  int res = 0 ;
31 
32  Index pos (nbr_coefs) ;
33  do {
34  bool indic = true ;
35  // Get base in theta :
36  int baset = (*so.get_base().bases_1d[1]) (0) ;
37  int lquant ;
38  switch (baset) {
39  case COS_EVEN:
40  if ((pos(1)==0) && (mquant!=0))
41  indic = false ;
42  lquant = 2*pos(1) ;
43  break ;
44  case COS_ODD:
45  if ((pos(1)==nbr_coefs(1)-1) || ((pos(1)==0) && (mquant!=0)))
46  indic = false ;
47  lquant = 2*pos(1)+1 ;
48  break ;
49  case SIN_EVEN:
50  if (((pos(1)==1) && (mquant>1)) || (pos(1)==0) || (pos(1)==nbr_coefs(1)-1))
51  indic = false ;
52  lquant = 2*pos(1) ;
53  break ;
54  case SIN_ODD:
55  if (((pos(1)==0) && (mquant>1)) || (pos(1)==nbr_coefs(1)-1))
56  indic = false ;
57  lquant = 2*pos(1)+1 ;
58  break ;
59  default:
60  cerr << "Unknow theta basis in Domain_polar_nucleus::nbr_unknowns_val_domain" << endl ;
61  abort() ;
62  }
63 
64  int max = 0;
65  if (indic) {
66  // Base in r :
67  int baser = (*so.get_base().bases_1d[0]) (pos(1)) ;
68  switch (baser) {
69  case CHEB_EVEN :
70  switch (baset) {
71  case COS_EVEN :
72  if ((pos(0)==0) && ((lquant>llim) || (mquant!=0)))
73  indic = false ;
74  break ;
75  case SIN_EVEN :
76  if (pos(0)==0)
77  indic = false ;
78  break ;
79  default :
80  cerr << "Strange base in Domain_polar_nucleus::nbr_conditions_val_domain" << endl ;
81  abort() ;
82  }
83  max = nbr_coefs(0) ;
84  break ;
85  case LEG_EVEN :
86  switch (baset) {
87  case COS_EVEN :
88  if ((pos(0)==0) && ((lquant>llim) || (mquant!=0)))
89  indic = false ;
90  break ;
91  case SIN_EVEN :
92  if (pos(0)==0)
93  indic = false ;
94  break ;
95  default :
96  cerr << "Strange base in Domain_polar_nucleus::nbr_conditions_val_domain" << endl ;
97  abort() ;
98  }
99  max = nbr_coefs(0) ;
100  break ;
101  case CHEB_ODD :
102  switch (baset) {
103  case SIN_ODD :
104  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
105  indic = false ;
106  break ;
107  case COS_ODD :
108  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
109  indic = false ;
110  break ;
111  default :
112  cerr << "Strange base in Domain_polar_nucleus::nbr_conditions_val_domain" << endl ;
113  abort() ;
114  }
115  max = nbr_coefs(0)-1 ;
116  break ;
117  case LEG_ODD :
118  switch (baset) {
119  case SIN_ODD :
120  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
121  indic = false ;
122  break ;
123  case COS_ODD :
124  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
125  indic = false ;
126  break ;
127  default :
128  cerr << "Strange base in Domain_polar_nucleus::nbr_conditions_val_domain" << endl ;
129  abort() ;
130  }
131  max = nbr_coefs(0)-1 ;
132  break ;
133  default :
134  cerr << "Unknown base in Domain_polar_nucleus::nbr_conditions_val_domain" << endl ;
135  abort() ;
136  }
137  }
138 
139  // Order with respect to r :
140  int lim = 0 ;
141  switch (order) {
142  case 2 :
143  lim = max-2 ;
144  break ;
145  case 1 :
146  {
147  if (pos(1)==0)
148  lim = max-2 ;
149  else
150  lim = max -1 ;}
151  break ;
152  case 0 :
153  lim = max-1 ;
154  break ;
155  default :
156  cerr << "Unknown case in Domain_polar_nucleus_nbr_conditions" << endl ;
157  abort() ;
158  }
159 
160  if (pos(0)>lim)
161  indic = false ;
162 
163  if (indic)
164  res ++ ;
165  }
166  while (pos.inc()) ;
167 
168  return res ;
169 }
170 
171 Array<int> Domain_polar_nucleus::nbr_conditions (const Tensor& tt, int dom, int order, int n_cmp, Array<int>**) const {
172 
173  int size = (n_cmp==-1) ? tt.get_n_comp() : n_cmp ;
174  Array<int> res (size) ;
175  int val = tt.get_valence() ;
176  switch (val) {
177  case 0 :
178  if (!tt.is_m_quant_affected())
179  res.set(0) = nbr_conditions_val_domain (tt()(dom), 0, 0, order) ;
180  else
181  res.set(0) = nbr_conditions_val_domain (tt()(dom), tt.get_parameters().get_m_quant(), 0, order) ;
182  break ;
183  default :
184  cerr << "Valence " << val << " not implemented in Domain_polar_nucleus::nbr_conditions" << endl ;
185  break ;
186  }
187  return res ;
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.
int nbr_conditions_val_domain(const Val_domain &so, int mquant, int llim, int order) const
Computes number of discretized equations associated with a given tensorial equation in the bulk.
virtual Array< int > nbr_conditions(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 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
bool inc(int increm, int var=0)
Increments the position of the Index.
Definition: index.hpp:99
int get_m_quant() const
Returns .
Definition: tensor.hpp:747
Tensor handling.
Definition: tensor.hpp:149
const Param_tensor & get_parameters() const
Returns a pointer on the possible additional parameter.
Definition: tensor.hpp:311
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
bool is_m_quant_affected() const
Checks whether the additional parameter is affected (used for boson stars for instance).
Definition: tensor.hpp:326
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