KADATH
domain_polar_nucleus_nbr_unknowns.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_unknowns_val_domain (const Val_domain& so, int mquant, int llim) const {
30 
31  int res = 0 ;
32  Index pos (nbr_coefs) ;
33  do {
34  bool indic = true ;
35 
36  // Get base in theta :
37  int baset = (*so.get_base().bases_1d[1]) (0) ;
38  int lquant ;
39  switch (baset) {
40  case COS_EVEN:
41  if ((pos(1)==0) && (mquant!=0))
42  indic = false ;
43  lquant = 2*pos(1) ;
44  break ;
45  case COS_ODD:
46  if ((pos(1)==nbr_coefs(1)-1) || ((pos(1)==0) && (mquant!=0)))
47  indic = false ;
48  lquant = 2*pos(1)+1 ;
49  break ;
50  case SIN_EVEN:
51  if (((pos(1)==1) && (mquant>1)) || (pos(1)==0) || (pos(1)==nbr_coefs(1)-1))
52  indic = false ;
53  lquant = 2*pos(1) ;
54  break ;
55  case SIN_ODD:
56  if (((pos(1)==0) && (mquant>1)) || (pos(1)==nbr_coefs(1)-1))
57  indic = false ;
58  lquant = 2*pos(1)+1 ;
59  break ;
60  default:
61  cerr << "Unknow theta basis in Domain_polar_nucleus::nbr_unknowns_val_domain" << endl ;
62  abort() ;
63  }
64 
65  if (indic) {
66 
67  // Base in r :
68  int baser = (*so.get_base().bases_1d[0]) (pos(1)) ;
69  switch (baser) {
70  case CHEB_EVEN :
71  switch (baset) {
72  case COS_EVEN :
73  if ((pos(0)==0) && ((lquant>llim) || (mquant!=0)))
74  indic = false ;
75  break ;
76  case SIN_EVEN :
77  if (pos(0)==0)
78  indic = false ;
79  break ;
80  default :
81  cerr << "Strange base in Domain_polar_nucleus::br_unknowns_val_domain" << endl ;
82  abort() ;
83  }
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::br_unknowns_val_domain" << endl ;
97  abort() ;
98  }
99  break ;
100  case CHEB_ODD :
101  switch (baset) {
102  case SIN_ODD :
103  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
104  indic = false ;
105  break ;
106  case COS_ODD :
107  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
108  indic = false ;
109  break ;
110  default :
111  cerr << "Strange base in Domain_polar_nucleus::br_unknowns_val_domain" << endl ;
112  abort() ;
113  }
114  break ;
115  case LEG_ODD :
116  switch (baset) {
117  case SIN_ODD :
118  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
119  indic = false ;
120  break ;
121  case COS_ODD :
122  if ((pos(0)==nbr_coefs(0)-1) || ((pos(0)==0) && (lquant>llim+1)))
123  indic = false ;
124  break ;
125  default :
126  cerr << "Strange base in Domain_polar_nucleus::br_unknowns_val_domain" << endl ;
127  abort() ;
128  }
129  break ;
130  default :
131  cerr << "Unknown base in Domain_polar_nucleus::br_unknowns_val_domain" << endl ;
132  abort() ;
133  }
134  }
135 
136  if (indic)
137  res ++ ;
138  }
139  while (pos.inc()) ;
140 
141  return res ;
142 }
143 
144 int Domain_polar_nucleus::nbr_unknowns (const Tensor& tt, int dom) const {
145 
146  // Check right domain
147  assert (tt.get_space().get_domain(dom)==this) ;
148 
149  int res = 0 ;
150  int val = tt.get_valence() ;
151  switch (val) {
152  case 0 :
153  if (!tt.is_m_quant_affected())
154  res += nbr_unknowns_val_domain (tt()(dom), 0 , 0) ;
155  else
156  res += nbr_unknowns_val_domain (tt()(dom), tt.get_parameters().get_m_quant(), 0) ;
157  break ;
158  default :
159  cerr << "Valence " << val << " not implemented in Domain_polar_nucleus::nbr_unknowns" << endl ;
160  break ;
161  }
162  return res ;
163 }}
Bases_container bases_1d
Arrays containing the various basis of decomposition.
int nbr_unknowns_val_domain(const Val_domain &so, int mquant, int llim) const
Computes the number of true unknowns of a Val_domain.
virtual int nbr_unknowns(const Tensor &, int) const
Computes the number of true unknowns of a Tensor, in a given domain.
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
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
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_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
const Space & get_space() const
Returns the Space.
Definition: tensor.hpp:499
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