KADATH
domain_bispheric_rect_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 "bispheric.hpp"
22 #include "array_math.hpp"
23 #include "param.hpp"
24 #include "val_domain.hpp"
25 
26 namespace Kadath {
27 void Domain_bispheric_rect::find_other_dom (int dom, int bound, int& other_dom, int& other_bound) const {
28  switch (bound) {
29  case CHI_ONE_BC :
30  if (eta_minus<0)
31  other_dom = dom-1 ;
32  else
33  other_dom = dom+1 ;
34  other_bound = CHI_ONE_BC ;
35  break ;
36  case ETA_PLUS_BC :
37  if (eta_minus<0) {
38  other_dom = dom + 1 ;
39  other_bound = ETA_MINUS_BC ;
40  }
41  else {
42  other_dom = dom -1 ;
43  other_bound = ETA_PLUS_BC ;
44  }
45  break ;
46  default:
47  cerr << "Unknown boundary case in Domain_bispheric_rect::find_other_dom" << endl ;
48  abort() ;
49  }
50 }
51 
52 double Domain_bispheric_rect::val_boundary (int bound, const Val_domain& so, const Index& pos_cf) const {
53 
54  if (so.check_if_zero())
55  return 0. ;
56 
57  else {
58  so.coef() ;
59  double res = 0 ;
60  Index copie_pos (pos_cf) ;
61  switch (bound) {
62  case INNER_BC :
63  for (int i=0 ; i<nbr_coefs(0) ; i++) {
64  copie_pos.set(0) = i ;
65  if (i%2==0)
66  res += so.get_coef(copie_pos) ;
67  else
68  res -= so.get_coef(copie_pos) ;
69  }
70  break ;
71  case ETA_PLUS_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  case CHI_ONE_BC :
78  for (int j=0 ; j<nbr_coefs(1) ; j++) {
79  copie_pos.set(1) = j ;
80  res += so.get_coef(copie_pos) ;
81  }
82  break ;
83  case OUTER_BC :
84  for (int j=0 ; j<nbr_coefs(1) ; j++) {
85  copie_pos.set(1) = j ;
86  for (int i=0 ; i<nbr_coefs(0) ; i++) {
87  copie_pos.set(0) = i ;
88  res += so.get_coef(copie_pos) ;
89  }
90  }
91  break ;
92  default :
93  cerr << "Unknown boundary type in Domain_bispheric_rect::val_boundary" << endl ;
94  abort() ;
95  }
96  return res ;
97  }
98 }
99 
101  int basep = (*bb.bases_1d[2]) (0) ;
102  int nbrphi = (basep==COS) ? nbr_points(2) : nbr_points(2)-2 ;
103  int res ;
104  switch (bound) {
105  case INNER_BC :
106  res = nbrphi * (nbr_points(1)-1) ;
107  if (basep==COS)
108  res ++ ;
109  break ;
110  case OUTER_BC :
111  res = nbrphi ;
112  break ;
113  default :
114  cerr << "Domain_bispheric_rect::nbr_points_boundary not yet implemented for boundary " << bound << endl ;
115  abort() ;
116  }
117 
118  return res ;
119 }
120 
121 void Domain_bispheric_rect::do_which_points_boundary (int bound, const Base_spectral& bb, Index** which_coef, int start) const {
122  int pos_which = start ;
123  Index pos (nbr_points) ;
124  int basep = (*bb.bases_1d[2]) (0) ;
125  //Look at the symetrie :
126  int mink = (basep==COS) ? 0 : 1 ;
127  int maxk = (basep==COS) ? nbr_points(2) : nbr_points(2)-1 ;
128  int k,j ;
129  switch (bound) {
130  case INNER_BC :
131  pos.set(0) = 0 ;
132  if (basep==COS) {
133  pos.set(2) = 0 ;
134  pos.set(1) = 0 ;
135  which_coef[pos_which] = new Index(pos) ;
136  pos_which ++ ;
137  }
138  for (k=mink ; k<maxk ; k++) {
139  pos.set(2) = k ;
140  for (j=1 ; j<nbr_points(1) ; j++) {
141  pos.set(1) = j ;
142  which_coef[pos_which] = new Index(pos) ;
143  pos_which ++ ;
144  }
145  }
146  break ;
147  case OUTER_BC :
148  pos.set(0) = nbr_points(0)-1 ;
149  pos.set(1) = nbr_points(1)-1 ;
150  for (k=mink ; k<maxk ; k++) {
151  pos.set(2) = k ;
152  which_coef[pos_which] = new Index(pos) ;
153  pos_which ++ ;
154  }
155  break ;
156  default :
157  cerr << "Unknown boundary in Domain_bispheric_rect::do_which_points_inside" << endl ;
158  abort() ;
159  }
160 }
161 }
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
double eta_minus
associated with .
Definition: bispheric.hpp:69
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at 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 void do_which_points_boundary(int, const Base_spectral &, Index **, int) const
Lists all the indices corresponding to true 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