KADATH
domain_shell_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 
22 #include "spheric.hpp"
23 #include "point.hpp"
24 #include "val_domain.hpp"
25 namespace Kadath {
26 void Domain_shell::find_other_dom (int dom, int bound, int& other_dom, int& other_bound) const {
27 
28  switch (bound) {
29  case INNER_BC:
30  other_dom = dom -1 ;
31  other_bound = OUTER_BC ;
32  break ;
33  case OUTER_BC:
34  other_dom = dom +1 ;
35  other_bound = INNER_BC ;
36  break ;
37  default:
38  cerr << "Unknown boundary case in Domain_shell::find_other_dom" << endl ;
39  abort() ;
40  }
41 }
42 
43 double Domain_shell::val_boundary (int bound, const Val_domain& so, const Index& pos_cf) const {
44 
45  if (so.check_if_zero())
46  return 0. ;
47 
48  else {
49  so.coef();
50  double res = 0 ;
51  Index copie_pos (pos_cf) ;
52  switch (bound) {
53  case INNER_BC :
54  for (int i=0 ; i<nbr_coefs(0) ; i++) {
55  copie_pos.set(0) = i ;
56  if (i%2==0)
57  res += so.get_coef(copie_pos) ;
58  else
59  res -= so.get_coef(copie_pos) ;
60  }
61  break ;
62  case OUTER_BC :
63  for (int i=0 ; i<nbr_coefs(0) ; i++) {
64  copie_pos.set(0) = i ;
65  res += so.get_coef(copie_pos) ;
66  }
67  break ;
68  default :
69  cerr << "Unknown boundary type in Domain_shell::val_boundary" << endl ;
70  abort() ;
71  }
72  return res ;
73  }
74 }
75 
76 int Domain_shell::nbr_points_boundary (int bound, const Base_spectral& bb) const {
77 
78  if ((bound!=INNER_BC) && (bound!=OUTER_BC)) {
79  cerr << "Unknown boundary in Domain_shell::nbr_points_boundary" << endl ;
80  abort() ;
81  }
82 
83  //Look at the symetrie :
84  int first_base_theta = (*bb.bases_1d[1]) (0) ;
85  int nbrj = ((first_base_theta==COS_EVEN) || (first_base_theta==SIN_ODD)) ? nbr_points(1)-1 : nbr_points(1)-2 ;
86 
87  return (nbrj*nbr_points(2)+1) ;
88 }
89 
90 void Domain_shell::do_which_points_boundary (int bound, const Base_spectral& bb, Index** which_coef, int start) const {
91 
92  int pos_which = start ;
93  Index pos (nbr_points) ;
94 
95  switch (bound) {
96  case INNER_BC :
97  pos.set(0) = 0 ;
98  break ;
99  case OUTER_BC :
100  pos.set(0) = nbr_points(0)-1 ;
101  break ;
102  default :
103  cerr << "Unknown boundary in Domain_shell::do_which_points_inside" << endl ;
104  abort() ;
105  }
106 
107 
108  //Look at the symetrie :
109  int first_base_theta = (*bb.bases_1d[1]) (0) ;
110  int maxj = ((first_base_theta==COS_EVEN) || (first_base_theta==SIN_ODD)) ? nbr_points(1) : nbr_points(1)-1 ;
111 
112  for (int k=0 ; k<nbr_points(2) ; k++) {
113  pos.set(2) = k ;
114  for (int j=0 ; j<maxj ; j++) {
115  pos.set(1) = j ;
116  if ((k==0) || (j!=0)) {
117  which_coef[pos_which] = new Index(pos) ;
118  pos_which ++ ;
119  }
120  }
121  }
122 }
123 }
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 double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
virtual int nbr_points_boundary(int, const Base_spectral &) const
Computes the number of relevant collocation points on 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