KADATH
space_spheric_symphi.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_symphi.hpp"
22 #include "utilities.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 namespace Kadath {
26 Space_spheric_symphi::Space_spheric_symphi(int ttype, const Point& center, const Dim_array& res, double bound) {
27 
28 
29  ndim = 3 ;
30 
31  nbr_domains = 1 ;
32  type_base = ttype ;
33  domains = new Domain* [nbr_domains] ;
34  // Nucleus
35  domains[0] = new Domain_nucleus_symphi(0, ttype, bound, center, res) ;
36 }
37 
38 Space_spheric_symphi::Space_spheric_symphi(int ttype, const Point& center, const Dim_array& res, const Array<double>& bounds, bool withzec) {
39 
40 
41  ndim = 3 ;
42 
43  nbr_domains = bounds.get_size(0) ;
44  type_base = ttype ;
45  domains = (withzec) ? new Domain* [nbr_domains+1] : new Domain* [nbr_domains] ;
46  // Nucleus
47  domains[0] = new Domain_nucleus_symphi(0, ttype, bounds(0), center, res) ;
48  for (int i=1 ; i<=nbr_domains-1 ; i++)
49  domains[i] = new Domain_shell_symphi(i, ttype, bounds(i-1), bounds(i), center, res) ;
50  if (withzec) {
51  nbr_domains ++ ;
52  domains[nbr_domains-1] = new Domain_compact_symphi(nbr_domains-1, ttype, bounds(nbr_domains-2), center, res) ;
53  }
54 }
55 
56 
57 
59  fread_be (&nbr_domains, sizeof(int), 1, fd) ;
60  fread_be (&ndim, sizeof(int), 1, fd) ;
61  fread_be (&type_base, sizeof(int), 1, fd) ;
62  domains = new Domain* [nbr_domains] ;
63  //nucleus :
64  domains[0] = new Domain_nucleus_symphi(0, fd) ;
65  if (withzec) {
66  for (int i=1 ; i<nbr_domains-1 ; i++)
67  domains[i] = new Domain_shell_symphi(i, fd) ;
69  }
70  else
71  for (int i=1 ; i<=nbr_domains-1 ; i++)
72  domains[i] = new Domain_shell_symphi(i, fd) ;
73 }
74 
75 Space_spheric_symphi::~Space_spheric_symphi() {
76 }
77 
78 void Space_spheric_symphi::save (FILE* fd) const {
79  fwrite_be (&nbr_domains, sizeof(int), 1, fd) ;
80  fwrite_be (&ndim, sizeof(int), 1, fd) ;
81  fwrite_be (&type_base, sizeof(int), 1, fd) ;
82  for (int i=0 ; i<nbr_domains ; i++)
83  domains[i]->save(fd) ;
84 }
85 }
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 spherical compactified domain and a symmetry with respect to the plane and a quadrant sy...
Class for a spherical domain containing the origin a symmetry with respect to the plane and an quadr...
Class for a spherical shell and a symmetry with respect to the plane and an quadrant symmetry wrt .
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
virtual void save(FILE *) const
Saving function.
Space_spheric_symphi(int ttype, const Point &cr, const Dim_array &nbr, double bound)
Standard constructor with only one nucleus.
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