KADATH
domain_critic_inner_systems.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 "critic.hpp"
22 #include "point.hpp"
23 #include "array_math.hpp"
24 #include "val_domain.hpp"
25 namespace Kadath {
26 void Domain_critic_inner::find_other_dom (int dom, int bound, int& other_dom, int& other_bound) const {
27 
28  switch (bound) {
29  case OUTER_BC:
30  other_dom = dom +1 ;
31  other_bound = INNER_BC ;
32  break ;
33  default:
34  cerr << "Unknown boundary case in Domain_critic_inner::find_other_dom" << endl ;
35  abort() ;
36  }
37 }
38 
39 double Domain_critic_inner::val_boundary (int bound, const Val_domain& so, const Index& pos_cf) const {
40 
41  if (so.check_if_zero())
42  return 0. ;
43 
44  else {
45  so.coef() ;
46  double res = 0 ;
47  Index copie_pos (pos_cf) ;
48  double fact = 1 ;
49 
50  int base_r = so.get_base().bases_1d[0]->set(0) ;
51  switch (bound) {
52  case INNER_BC :
53  if ((base_r==CHEB_EVEN) || (base_r==LEG_EVEN)) {
54  for (int i=0 ; i<nbr_coefs(0) ; i++) {
55  copie_pos.set(0) = i ;
56  res += fact*so.get_coef(copie_pos) ;
57  switch (base_r) {
58  case CHEB_EVEN :
59  fact *= -1 ;
60  break ;
61  case LEG_EVEN :
62  fact *= - double(i-1)/double(i) ;
63  break ;
64  default :
65  cerr << "Unknown basis type in Domain_critic_inner::val_boundary" << endl ;
66  abort() ;
67  }
68 
69  }}
70  break ;
71  case OUTER_BC :
72  for (int i=0 ; i<nbr_coefs(0) ; i++) {
73  copie_pos.set(0) = i ;
74  res += so.get_coef(copie_pos) ;
75  }
76  break ;
77  default :
78  cerr << "Unknown boundary type in Domain_critic_inner::val_boundary" << endl ;
79  abort() ;
80  }
81  return res ;
82  }
83 }
84 
85 
86 int Domain_critic_inner::nbr_points_boundary (int bound, const Base_spectral& bb) const {
87 
88  if ((bound!=INNER_BC) && (bound!=OUTER_BC)) {
89  cerr << "Unknown boundary in Domain_critic_inner::nbr_points_boundary" << endl ;
90  abort() ;
91  }
92 
93  int base_t = (*bb.bases_1d[1])(0) ;
94  if ((base_t!=COSSIN_EVEN) && (base_t!=COSSIN_ODD)) {
95  cerr << "Unknown base in Domain_critic_inner::nbr_conditions_val_domain_boundary" << endl ;
96  abort() ;
97  }
98  return nbr_coefs(1)-2 ;
99 }
100 
101 void Domain_critic_inner::do_which_points_boundary (int bound, const Base_spectral&, Index** which_coef, int start) const {
102 
103  int pos_which = start ;
104  Index pos (nbr_points) ;
105 
106  switch (bound) {
107  case INNER_BC :
108  pos.set(0) = 0 ;
109  break ;
110  case OUTER_BC :
111  pos.set(0) = nbr_points(0)-1 ;
112  break ;
113  default :
114  cerr << "Unknown boundary in Domain_critic_inner::do_which_points_boundary" << endl ;
115  abort() ;
116  }
117 
118  for (int j=0 ; j<nbr_points(1) ; j++) {
119  pos.set(1) = j ;
120  which_coef[pos_which] = new Index(pos) ;
121  pos_which ++ ;
122  }
123 }
124 
125 }
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
virtual void do_which_points_boundary(int, const Base_spectral &, Index **, int) const
Lists all the indices corresponding to true collocation points on a boundary.
virtual void find_other_dom(int, int, int &, int &) const
Gives the informations corresponding the a touching neighboring domain.
virtual int nbr_points_boundary(int, const Base_spectral &) const
Computes the number of relevant collocation points on a boundary.
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
Dim_array nbr_coefs
Number of coefficients.
Definition: space.hpp:66
Dim_array nbr_points
Number of colocation points.
Definition: space.hpp:65
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
int & set(int i)
Read/write of the position in a given dimension.
Definition: index.hpp:72
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
void coef() const
Computes the coefficients.
Definition: val_domain.cpp:622
Array< double > get_coef() const
Definition: val_domain.hpp:136
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122