KADATH
domain_bispheric_eta_first_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 
22 #include "bispheric.hpp"
23 #include "term_eq.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 
27 namespace Kadath {
28 // Tensorial parts :
29 Tensor Domain_bispheric_eta_first::import (int numdom, int bound, int n_ope, const Array<int>& zedoms, Tensor** parts) const {
30 
31  Tensor res (*parts[0], false);
32 
33  for (int nc=0 ; nc<res.get_n_comp() ; nc++)
34  res.cmp[nc]->set_domain(numdom).allocate_conf() ;
35 
36  // Need coefficients of parts :
37  for (int i=0 ; i<n_ope ; i++)
38  for (int nc=0 ; nc<parts[i]->get_n_comp() ; nc++)
39  parts[i]->cmp[nc]->set_domain(zedoms(i)).coef() ;
40 
41  // Loop on the points of the boundary :
42  Val_domain xx (get_cart(1)) ;
43  Val_domain yy (get_cart(2)) ;
44  Val_domain zz (get_cart(3)) ;
45 
46  int index_chi ;
47  switch (bound) {
48  case OUTER_BC :
49  index_chi = nbr_points(0)-1 ;
50  break ;
51  default :
52  cerr << "Unknown boundary in Domain_bispheric_eta_first::import" << endl ;
53  }
54 
55  Index pos (get_nbr_points()) ;
56  Index pos_bound (get_nbr_points()) ;
57 
58  for (int k=0 ; k<nbr_points(2) ; k++)
59  for (int j=0 ; j<nbr_points(1) ; j++) {
60 
61  // Indices in the shell
62  pos_bound.set(0) = index_chi ;
63  pos_bound.set(1) = j ;
64  pos_bound.set(2) = k ;
65 
66  // Absolute coordinates
67  Point MM (3) ;
68  MM.set(1) = xx(pos_bound) ;
69  MM.set(2) = yy(pos_bound) ;
70  MM.set(3) = zz(pos_bound) ;
71 
72  // In which other domain is it ?
73  bool found = false ;
74  int current = 0 ;
75  while ((current<n_ope) && (!found)) {
76  if (parts[0]->get_space().get_domain(zedoms(current))->is_in(MM, 1e-3))
77  found = true ;
78  else
79  current ++ ;
80  }
81  if (!found) {
82  cerr << "Point " << MM << " not found in other domains, for Domain_bispheric_eta_first::import" << endl ;
83  abort() ;
84  }
85 
86  // Convert to numerical coordinates of the other domain
87  Point num (parts[0]->get_space().get_domain(zedoms(current))->absol_to_num(MM)) ;
88 
89  // Now loop on the components :
90  for (int nc=0 ; nc<res.get_n_comp() ; nc++) {
91  double val = ((*parts[current]->cmp[nc])(zedoms(current)).check_if_zero()) ? 0 : (*parts[current]->cmp[nc])(zedoms(current)).get_base().summation (num, *(*parts[current]->cmp[nc])(zedoms(current)).cf) ;
92  // Loop on radius :
93  for (int i=0 ; i<nbr_points(0) ; i++) {
94  pos.set(0) = i ;
95  pos.set(1) = j ;
96  pos.set(2) = k ;
97 
98  res.cmp[nc]->set_domain(numdom).set(pos) = val ;
99  }
100  }
101  }
102 
103  // Assert a std_base :
104  res.std_base() ;
105 
106 
107  return res ;
108 }
109 }
virtual Tensor import(int, int, int, const Array< int > &, Tensor **) const
Gets the value of a Tensor by importing data from neighboring domains, on a boundary.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
Dim_array const & get_nbr_points() const
Returns the number of points.
Definition: space.hpp:92
Dim_array nbr_points
Number of colocation points.
Definition: space.hpp:65
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
int & set(int i)
Read/write of the position in a given dimension.
Definition: index.hpp:72
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
Tensor handling.
Definition: tensor.hpp:149
void coef() const
Computes the coefficients.
virtual void std_base()
Sets the standard spectal bases of decomposition for each component.
Definition: tensor.cpp:385
Memory_mapped_array< Scalar * > cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.hpp:179
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.hpp:514
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69