KADATH
space_polar.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 "polar.hpp"
22 #include "utilities.hpp"
23 #include "point.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 namespace Kadath {
27 Space_polar::Space_polar(int ttype, const Point& center, const Dim_array& res, const Array<double>& bounds) {
28 
29  // Verif :
30  assert (bounds.get_ndim()== 1) ;
31 
32  ndim = 2 ;
33 
34  nbr_domains = bounds.get_size(0)+1 ;
35  type_base = ttype ;
36  domains = new Domain* [nbr_domains] ;
37  // Nucleus
38  domains[0] = new Domain_polar_nucleus(0, ttype, bounds(0), center, res) ;
39  for (int i=1 ; i<nbr_domains-1 ; i++)
40  domains[i] = new Domain_polar_shell(i, ttype, bounds(i-1), bounds(i), center, res) ;
41 
42  domains[nbr_domains-1] = new Domain_polar_compact (nbr_domains-1, ttype, bounds(nbr_domains-2), center, res) ;
43 }
44 
46  fread_be (&nbr_domains, sizeof(int), 1, fd) ;
47  fread_be (&ndim, sizeof(int), 1, fd) ;
48  fread_be (&type_base, sizeof(int), 1, fd) ;
49  domains = new Domain* [nbr_domains] ;
50  //nucleus :
51  domains[0] = new Domain_polar_nucleus(0, fd) ;
52  //Shells :
53  for (int i=1 ; i<nbr_domains-1 ; i++)
54  domains[i] = new Domain_polar_shell(i, fd) ;
55  // Compactified
57 }
58 
59 Space_polar::~Space_polar() {
60 }
61 
62 void Space_polar::save (FILE* fd) const {
63  fwrite_be (&nbr_domains, sizeof(int), 1, fd) ;
64  fwrite_be (&ndim, sizeof(int), 1, fd) ;
65  fwrite_be (&type_base, sizeof(int), 1, fd) ;
66  for (int i=0 ; i<nbr_domains ; i++)
67  domains[i]->save(fd) ;
68 }
69 
70 
71 double Space_polar::int_inf (const Scalar& so) const {
72 
73  const Domain_polar_compact* p_cmp = dynamic_cast <const Domain_polar_compact*> (domains[nbr_domains-1]) ;
74 #ifndef REMOVE_ALL_CHECKS
75  if (p_cmp==nullptr) {
76  cerr << "No compactified domain in Space_polar::int_inf" << endl ;
77  abort() ;
78  }
79 #endif
80  return p_cmp->integ (so(nbr_domains-1), OUTER_BC) ;
81 }}
int get_ndim() const
Returns the number of dimensions.
Definition: array.hpp:323
int get_size(int i) const
Returns the size of a given dimension.
Definition: array.hpp:331
Class for storing the dimensions of an array.
Definition: dim_array.hpp:34
Class for a 2-dimensional spherical shell and a symmetry with respect to the plane .
Definition: polar.hpp:408
virtual double integ(const Val_domain &, int) const
Surface integral on a given boundary.
Class for a 2-dimensional spherical domain containing the origin and a symetry with respect to the pl...
Definition: polar.hpp:45
Class for a 2-dimensional spherical shell and a symmetry with respect to the plane .
Definition: polar.hpp:221
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
double int_inf(const Scalar &so) const
Computes the surface integral at infinity.
Definition: space_polar.cpp:71
virtual void save(FILE *) const
Saving function.
Definition: space_polar.cpp:62
Space_polar(int ttype, const Point &cr, const Dim_array &nbr, const Array< double > &bounds)
Standard constructor.
Definition: space_polar.cpp:27
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