KADATH
domain_bispheric_eta_first_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 "param.hpp"
23 #include "val_domain.hpp"
24 namespace Kadath {
25 void Domain_bispheric_eta_first::find_other_dom (int dom, int bound, int& other_dom, int& other_bound) const {
26 
27  switch (bound) {
28  case ETA_MINUS_BC :
29  other_dom = dom-1 ;
30  other_bound = ETA_PLUS_BC ;
31  break ;
32  case ETA_PLUS_BC :
33  other_dom = dom+1 ;
34  other_bound = ETA_PLUS_BC ;
35  break ;
36 
37  default:
38  cerr << "Unknown boundary case in Domain_bispheric_eta_first::find_other_dom" << endl ;
39  abort() ;
40  }
41 }
42 
43 double Domain_bispheric_eta_first::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 OUTER_BC :
54  for (int i=0 ; i<nbr_coefs(0) ; i++) {
55  copie_pos.set(0) = i ;
56  res += so.get_coef(copie_pos) ;
57  }
58  break ;
59  case ETA_PLUS_BC :
60  for (int j=0 ; j<nbr_coefs(1) ; j++) {
61  copie_pos.set(1) = j ;
62  res += so.get_coef(copie_pos) ;
63  }
64  break ;
65  case ETA_MINUS_BC :
66  for (int j=0 ; j<nbr_coefs(1) ; j++) {
67  copie_pos.set(1) = j ;
68  if (j%2==0)
69  res += so.get_coef(copie_pos) ;
70  else
71  res -= so.get_coef(copie_pos) ;
72  }
73  break ;
74  default :
75  cerr << "Unknown boundary type in Domain_bispheric_eta_first::val_boundary" << endl ;
76  abort() ;
77  }
78  return res ;
79  }
80 }
81 
83  int basep = (*bb.bases_1d[2]) (0) ;
84  int nbrphi = (basep==COS) ? nbr_points(2) : nbr_points(2)-2 ;
85  int res ;
86  switch (bound) {
87  case OUTER_BC :
88  res = nbrphi * nbr_points(1) ;
89  break ;
90  default :
91  cerr << "Domain_bispheric_eta_first::nbr_points_boundary not yet implemented for boundary " << bound << endl ;
92  abort() ;
93  }
94 
95  return res ;
96 }
97 
98 void Domain_bispheric_eta_first::do_which_points_boundary (int bound, const Base_spectral& bb, Index** which_coef, int start) const {
99  int pos_which = start ;
100  Index pos (nbr_points) ;
101 
102  switch (bound) {
103  case OUTER_BC :
104  pos.set(0) = nbr_points(0)-1 ;
105  break ;
106  default :
107  cerr << "Unknown boundary in Domain_bispheric_eta_first::do_which_points_inside" << endl ;
108  abort() ;
109  }
110 
111  //Look at the symetrie :
112  int basep = (*bb.bases_1d[2]) (0) ;
113  int mink = (basep==COS) ? 0 : 1 ;
114  int maxk = (basep==COS) ? nbr_points(2) : nbr_points(2)-1 ;
115 
116  for (int k=mink ; k<maxk ; k++) {
117  pos.set(2) = k ;
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 
126 }
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
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