KADATH
domain_polar_periodic_shell_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_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  Index pos (nbr_coefs) ;
33  do {
34  bool indic = true ;
35 
36  // Base in time
37  int basetime = (*so.get_base().bases_1d[2]) (0) ;
38  switch (basetime) {
39  case COS:
40  break ;
41  case SIN:
42  if ((pos(2)==0) || (pos(2)==nbr_coefs(2)-1))
43  indic = false ;
44  break ;
45  default:
46  cerr << "Unknow time basis in Domain_polar_polar_shell::nbr_unknowns_val_domain" << endl ;
47  abort() ;
48  }
49 
50  // Get base in theta :
51  int baset = (*so.get_base().bases_1d[1]) (pos(2)) ;
52  switch (baset) {
53  case COS_EVEN:
54  break ;
55  case COS_ODD:
56  if (pos(1)==nbr_coefs(1)-1)
57  indic = false ;
58  break ;
59  case SIN_EVEN:
60  if ((pos(1)==0) || (pos(1)==nbr_coefs(1)-1))
61  indic = false ;
62  break ;
63  case SIN_ODD:
64  if (pos(1)==nbr_coefs(1)-1)
65  indic = false ;
66  break ;
67  default:
68  cerr << "Unknow theta basis in Domain_polar_periodic_shell::nbr_unknowns_val_domain" << endl ;
69  abort() ;
70  }
71 
72 
73  if (indic)
74  res ++ ;
75  }
76  while (pos.inc()) ;
77 
78  return res ;
79 }
80 
81 int Domain_polar_periodic_shell::nbr_unknowns (const Tensor& tt, int dom) const {
82 
83  // Check right domain
84  assert (tt.get_space().get_domain(dom)==this) ;
85 
86  int res = 0 ;
87  int val = tt.get_valence() ;
88  switch (val) {
89  case 0 :
90  res += nbr_unknowns_val_domain (tt()(dom)) ;
91  break ;
92  case 1 :
93  res += nbr_unknowns_val_domain (tt(1)(dom)) ;
94  res += nbr_unknowns_val_domain (tt(2)(dom)) ;
95  res += nbr_unknowns_val_domain (tt(3)(dom)) ;
96  break ;
97  case 2 :
98  if (tt.get_n_comp()==6) {
99  res += nbr_unknowns_val_domain (tt(1,1)(dom)) ;
100  res += nbr_unknowns_val_domain (tt(1,2)(dom)) ;
101  res += nbr_unknowns_val_domain (tt(1,3)(dom)) ;
102  res += nbr_unknowns_val_domain (tt(2,2)(dom)) ;
103  res += nbr_unknowns_val_domain (tt(2,3)(dom)) ;
104  res += nbr_unknowns_val_domain (tt(3,3)(dom)) ;
105  }
106  else {
107  res += nbr_unknowns_val_domain (tt(1,1)(dom)) ;
108  res += nbr_unknowns_val_domain (tt(1,2)(dom)) ;
109  res += nbr_unknowns_val_domain (tt(1,3)(dom)) ;
110  res += nbr_unknowns_val_domain (tt(2,1)(dom)) ;
111  res += nbr_unknowns_val_domain (tt(2,2)(dom)) ;
112  res += nbr_unknowns_val_domain (tt(2,3)(dom)) ;
113  res += nbr_unknowns_val_domain (tt(3,1)(dom)) ;
114  res += nbr_unknowns_val_domain (tt(3,2)(dom)) ;
115  res += nbr_unknowns_val_domain (tt(3,3)(dom)) ;
116  }
117  break ;
118  default :
119  cerr << "Valence " << val << " not implemented in Domain_polar_periodic_shell::nbr_unknowns" << endl ;
120  break ;
121  }
122  return res ;
123 }}
Bases_container bases_1d
Arrays containing the various basis of decomposition.
int nbr_unknowns_val_domain(const Val_domain &so) 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
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
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
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