KADATH
domain_bispheric_rect_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 "utilities.hpp"
23 #include "bispheric.hpp"
24 #include "term_eq.hpp"
25 #include "scalar.hpp"
26 #include "tensor_impl.hpp"
27 
28 namespace Kadath {
29 // Tensorial parts :
30 Tensor Domain_bispheric_rect::import (int numdom, int bound, int n_ope, const Array<int>& zedoms, Tensor** parts) const {
31 
32  Tensor res (*parts[0], false);
33 
34  for (int nc=0 ; nc<res.get_n_comp() ; nc++)
35  res.cmp[nc]->set_domain(numdom).allocate_conf() ;
36 
37  // Need coefficients of parts :
38  for (int i=0 ; i<n_ope ; i++)
39  for (int nc=0 ; nc<parts[i]->get_n_comp() ; nc++)
40  parts[i]->cmp[nc]->set_domain(zedoms(i)).coef() ;
41 
42  // Loop on the points of the boundary :
43  Val_domain xx (get_cart(1)) ;
44  Val_domain yy (get_cart(2)) ;
45  Val_domain zz (get_cart(3)) ;
46 
47  if (bound==INNER_BC) {
48  int index_mu = 0 ;
49  Index pos (get_nbr_points()) ;
50  Index pos_bound (get_nbr_points()) ;
51 
52  for (int k=0 ; k<nbr_points(2) ; k++)
53  for (int j=0 ; j<nbr_points(1) ; j++) {
54 
55  // Indices in the shell
56  pos_bound.set(0) = index_mu ;
57  pos_bound.set(1) = j ;
58  pos_bound.set(2) = k ;
59 
60  // Absolute coordinates
61  Point MM (3) ;
62  MM.set(1) = xx(pos_bound) ;
63  MM.set(2) = yy(pos_bound) ;
64  MM.set(3) = zz(pos_bound) ;
65 
66  // In which other domain is it ?
67  bool found = false ;
68  int current = 0 ;
69  while ((current<n_ope) && (!found)) {
70  if (parts[0]->get_space().get_domain(zedoms(current))->is_in(MM))
71  found = true ;
72  else
73  current ++ ;
74  }
75  if (!found) {
76  cerr << "Point " << MM << " not found in other domains, for Domain_bispheric_rect::import" << endl ;
77  abort() ;
78  }
79 
80  // Convert to numerical coordinates of the other domain
81  Point num (parts[0]->get_space().get_domain(zedoms(current))->absol_to_num(MM)) ;
82 
83  // Now loop on the components :
84  for (int nc=0 ; nc<res.get_n_comp() ; nc++) {
85  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) ;
86  // Loop on radius :
87  for (int i=0 ; i<nbr_points(0) ; i++) {
88  pos.set(0) = i ;
89  pos.set(1) = j ;
90  pos.set(2) = k ;
91 
92  res.cmp[nc]->set_domain(numdom).set(pos) = val ;
93  }
94  }
95  }
96 
97  // Assert a std_base :
98  res.std_base() ;
99  return res ;
100  }
101 
102 
103  if (bound==OUTER_BC) {
104  int index_mu = nbr_points(0)-1 ;
105  int index_chi = nbr_points(1)-1 ;
106 
107  Index pos (get_nbr_points()) ;
108  Index pos_bound (get_nbr_points()) ;
109 
110  for (int k=0 ; k<nbr_points(2) ; k++) {
111 
112  // Indices in the shell
113  pos_bound.set(0) = index_mu ;
114  pos_bound.set(1) = index_chi ;
115  pos_bound.set(2) = k ;
116 
117  // Absolute coordinates
118  Point MM (3) ;
119  MM.set(1) = xx(pos_bound) ;
120  MM.set(2) = yy(pos_bound) ;
121  MM.set(3) = zz(pos_bound) ;
122 
123  // In which other domain is it ?
124  bool found = false ;
125  int current = 0 ;
126  while ((current<n_ope) && (!found)) {
127  if (parts[0]->get_space().get_domain(zedoms(current))->is_in(MM))
128  found = true ;
129  else
130  current ++ ;
131  }
132  if (!found) {
133  cerr << "Point " << MM << " not found in other domains, for Domain_bispheric_rect::import" << endl ;
134  abort() ;
135  }
136 
137  // Convert to numerical coordinates of the other domain
138  Point num (parts[0]->get_space().get_domain(zedoms(current))->absol_to_num(MM)) ;
139 
140  // Now loop on the components :
141  for (int nc=0 ; nc<res.get_n_comp() ; nc++) {
142  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) ;
143  // Loop on radius :
144  for (int i=0 ; i<nbr_points(0) ; i++)
145  for (int j=0 ; j<nbr_points(1) ; j++) {
146  pos.set(0) = i ;
147  pos.set(1) = j ;
148  pos.set(2) = k ;
149 
150  res.cmp[nc]->set_domain(numdom).set(pos) = val ;
151  }
152  }
153  }
154 
155  // Assert a std_base :
156  res.std_base() ;
157  return res ;
158  }
159 
160  cerr << "unknown bound in Domain_bispheric_rect::import" << endl ;
161  abort() ;
162 }}
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
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.
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