KADATH
domain_bispheric_chi_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_chi_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_mu ;
47  switch (bound) {
48  case INNER_BC :
49  index_mu = 0 ;
50  break ;
51  case OUTER_BC :
52  index_mu = nbr_points(0)-1 ;
53  break ;
54  default :
55  cerr << "Unknown boundary in Domain_bispheric_chi_first::import" << endl ;
56  }
57 
58  Index pos (get_nbr_points()) ;
59  Index pos_bound (get_nbr_points()) ;
60 
61  for (int k=0 ; k<nbr_points(2) ; k++)
62  for (int j=0 ; j<nbr_points(1) ; j++) {
63 
64  // Indices in the shell
65  pos_bound.set(0) = index_mu ;
66  pos_bound.set(1) = j ;
67  pos_bound.set(2) = k ;
68 
69  // Absolute coordinates
70  Point MM (3) ;
71  MM.set(1) = xx(pos_bound) ;
72  MM.set(2) = yy(pos_bound) ;
73  MM.set(3) = zz(pos_bound) ;
74 
75  // In which other domain is it ?
76  bool found = false ;
77  int current = 0 ;
78  while ((current<n_ope) && (!found)) {
79  if (parts[0]->get_space().get_domain(zedoms(current))->is_in(MM, 1e-3))
80  found = true ;
81  else
82  current ++ ;
83  }
84  if (!found) {
85  cerr << "Point " << MM << " not found in other domains, for Domain_bispheric_chi_first::import" << endl ;
86  abort() ;
87  }
88 
89  // Convert to numerical coordinates of the other domain
90  Point num (parts[0]->get_space().get_domain(zedoms(current))->absol_to_num(MM)) ;
91 
92  // Now loop on the components :
93  for (int nc=0 ; nc<res.get_n_comp() ; nc++) {
94  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) ;
95  // Loop on radius :
96  for (int i=0 ; i<nbr_points(0) ; i++) {
97  pos.set(0) = i ;
98  pos.set(1) = j ;
99  pos.set(2) = k ;
100 
101  res.cmp[nc]->set_domain(numdom).set(pos) = val ;
102  }
103  }
104  }
105 
106  // Assert a std_base :
107  res.std_base() ;
108 
109 
110  return res ;
111 }
112 }
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