KADATH
space_critic.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 "utilities.hpp"
23 #include "point.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 namespace Kadath {
27 Space_critic::Space_critic(int ttype, double xlim, const Dim_array& res_inner, const Dim_array& res_outer) {
28 
29  ndim = 2 ;
30  nbr_domains = 2 ;
31  type_base = ttype ;
32  // Two domains
33  domains = new Domain* [2] ;
34  // Inner one
35  domains[0] = new Domain_critic_inner(0, ttype, res_inner, xlim) ;
36  // Outer one
37  domains[1] = new Domain_critic_outer(1, ttype, res_outer, xlim) ;
38 }
39 
41  nbr_domains = 2 ;
42  fread_be (&ndim, sizeof(int), 1, fd) ;
43  fread_be (&type_base, sizeof(int), 1, fd) ;
44  domains = new Domain* [2] ;
45  // Inner
46  domains[0] = new Domain_critic_inner(0, fd) ;
47  // Outer
48  domains[1] = new Domain_critic_outer(1, fd) ;
49 }
50 
51 Space_critic::~Space_critic() {
52 }
53 
54 void Space_critic::save (FILE* fd) const {
55  fwrite_be (&ndim, sizeof(int), 1, fd) ;
56  fwrite_be (&type_base, sizeof(int), 1, fd) ;
57  domains[0]->save(fd) ;
58  domains[1]->save(fd) ;
59 }
60 
62 
63  switch (dom) {
64  case 0 : {
65  // Inner
66  Array<int> res (2,1) ;
67  switch (bound) {
68  case OUTER_BC :
69  res.set(0,0) = 1 ; // Outer domain
70  res.set(1,0) = INNER_BC ;
71  break ;
72  default :
73  cerr << "Bad bound in Space_critic::get_indices_matching_non_std" << endl ;
74  abort() ;
75  }
76  return res ;
77  }
78  case 1 :
79  {
80  // Outer domain
81  Array<int> res(2, 1) ;
82  switch (bound) {
83  case INNER_BC :
84  res.set(0,0) = 0 ; // Inner domain
85  res.set(1,0) = OUTER_BC ;
86  break ;
87  default :
88  cerr << "Bad bound in Space_critic::get_indices_matching_non_std" << endl ;
89  abort() ;
90  }
91  return res ;
92  }
93  default :
94  cerr << "Bad domain in Space_critic::get_indices_matching_non_std" << endl ;
95  abort() ;
96  }
97 }
98 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
Class for storing the dimensions of an array.
Definition: dim_array.hpp:34
Class for a 2-dimensional cylindrical type domain.
Definition: critic.hpp:45
Class for a 2-dimensional cylindrical type domain.
Definition: critic.hpp:197
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
virtual void save(FILE *) const
Saving function.
Definition: domain.cpp:68
virtual Array< int > get_indices_matching_non_std(int, int) const
Gives the number of the other domains, touching a given boundary.
virtual void save(FILE *) const
Saving function.
Space_critic(int ttype, double xl, const Dim_array &nbr_inner, const Dim_array &nbr_outer)
Standard constructor.
int type_base
Type of basis used (i.e. using either Chebyshev or Legendre polynomials).
Definition: space.hpp:1367
int ndim
Number of dimensions (should be the same for all the Domains).
Definition: space.hpp:1366
Domain ** domains
Pointers on the various Domains.
Definition: space.hpp:1368
int nbr_domains
Number od Domains.
Definition: space.hpp:1365