KADATH
import.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 "scalar.hpp"
22 #include "tensor_impl.hpp"
23 #include "point.hpp"
24 
25 namespace Kadath {
26 void Scalar::import(const Scalar& so) {
27 
28  set_in_conf() ;
29  allocate_conf() ;
30 
31  // Loop on the domains :
32  for (int dd=0 ; dd<get_nbr_domains() ; dd++) {
33  Index pos (get_space().get_domain(dd)->get_nbr_points()) ;
34  Point xx (ndim) ;
35  do {
36  for (int i=1 ; i<=ndim ;i++)
37  xx.set(i) = (get_space().get_domain(dd)->get_cart(i))(pos) ;
38 
39  // Provisory :
40 
41  if ((dd!=get_nbr_domains()-1) ||
42  (pos(0) != get_space().get_domain(dd)->get_nbr_points()(0)-1))
43  val_zones[dd]->set(pos) = so.val_point(xx) ;
44  }
45  while (pos.inc()) ;
46  }
47 }}
Dim_array const & get_nbr_points() const
Returns the number of points.
Definition: space.hpp:92
Val_domain const & get_cart(int i) const
Returns a Cartesian coordinates.
Definition: space.hpp:1471
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
bool inc(int increm, int var=0)
Increments the position of the Index.
Definition: index.hpp:99
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
double & set(int i)
Read/write of a coordinate.
Definition: point.hpp:47
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
const Domain * get_domain(int i) const
Definition: scalar.hpp:122
const Space & get_space() const
Definition: scalar.hpp:126
void set_in_conf()
Destroys the values in the coefficient space.
Definition: scalar.hpp:389
void import(const Scalar &so)
Affects all the values to the one of another scalar.
Definition: import.cpp:26
Memory_mapped_array< Val_domain * > val_zones
Pointers on the various Val_domain describing the field in each Domain.
Definition: scalar.hpp:70
int get_nbr_domains() const
Definition: scalar.hpp:117
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
Definition: scalar.hpp:535
double val_point(const Point &xxx, int sens=-1) const
Computes the value of the field at a given point, by doing the spectral summation.
Definition: scalar.cpp:62
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
int ndim
The dimension/.
Definition: tensor.hpp:156
Scalar & set()
Read/write for a Scalar.
Definition: tensor.hpp:364