KADATH
domain_spheric_time_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 #include "spheric_time.hpp"
22 #include "array_math.hpp"
23 #include "val_domain.hpp"
24 namespace Kadath {
25 void Domain_spheric_time_shell::find_other_dom (int dom, int bound, int& other_dom, int& other_bound) const {
26 
27  switch (bound) {
28  case OUTER_BC:
29  other_dom = dom +1 ;
30  other_bound = INNER_BC ;
31  break ;
32  case INNER_BC:
33  other_dom = dom -1 ;
34  other_bound = OUTER_BC ;
35  break ;
36  default:
37  cerr << "Unknown boundary case in Domain_spheric_time_shell::find_other_dom" << endl ;
38  abort() ;
39  }
40 }
41 
42 double Domain_spheric_time_shell::val_boundary (int bound, const Val_domain& so, const Index& pos_cf) const {
43 
44  if (so.check_if_zero())
45  return 0. ;
46 
47  else {
48  so.coef() ;
49  double res = 0 ;
50  Index copie_pos (pos_cf) ;
51  switch (bound) {
52  case OUTER_BC :
53  for (int i=0 ; i<nbr_coefs(0) ; i++) {
54  copie_pos.set(0) = i ;
55  res += so.get_coef(copie_pos) ;
56  }
57  break ;
58  case INNER_BC :
59  for (int i=0 ; i<nbr_coefs(0) ; i++) {
60  copie_pos.set(0) = i ;
61  if (i%2==0)
62  res += so.get_coef(copie_pos) ;
63  else
64  res -= so.get_coef(copie_pos) ;
65  }
66  break ;
67  case TIME_INIT :
68  for (int j=0 ; j<nbr_coefs(1) ; j++) {
69  copie_pos.set(1) = j ;
70  if (j%2==0)
71  res += so.get_coef(copie_pos) ;
72  else
73  res -= so.get_coef(copie_pos) ;
74  }
75  break ;
76  default :
77  cerr << "Unknown boundary type in Domain_spheric_time_shell::val_boundary" << endl ;
78  abort() ;
79  }
80 
81  return res ;
82  }
83 }}
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.
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
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