20 #include "headcpp.hpp"
22 #include "bispheric.hpp"
24 #include "val_domain.hpp"
27 double chi_lim_eta(
double,
double,
double,
double) ;
30 Domain_bispheric_eta_first::Domain_bispheric_eta_first (
int num,
int ttype,
double a,
double air,
double etamin,
double etamax,
const Dim_array& nbr) :
Domain(num, ttype, nbr), aa(a), r_ext(air), eta_min(etamin), eta_max(etamax), bound_chi(nullptr),
31 bound_chi_der(nullptr), p_eta(nullptr), p_chi(nullptr), p_phi(nullptr),
32 p_detadx(nullptr), p_detady(nullptr), p_detadz(nullptr), p_dchidx(nullptr), p_dchidy(nullptr), p_dchidz(nullptr), p_dphidy(nullptr), p_dphidz(nullptr) {
41 r_ext(so.r_ext), eta_min (so.eta_min), eta_max(so.eta_max) {
59 fread_be (&
aa,
sizeof(
double), 1, fd) ;
60 fread_be (&
r_ext,
sizeof(
double), 1, fd) ;
61 fread_be (&
eta_min,
sizeof(
double), 1, fd) ;
62 fread_be (&
eta_max,
sizeof(
double), 1, fd) ;
63 fread_be (&
chi_c,
sizeof(
double), 1, fd) ;
82 Domain_bispheric_eta_first::~Domain_bispheric_eta_first() {
89 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
90 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
91 fwrite_be (&
aa,
sizeof(
double), 1, fd) ;
92 fwrite_be (&
r_ext,
sizeof(
double), 1, fd) ;
93 fwrite_be (&
eta_min,
sizeof(
double), 1, fd) ;
94 fwrite_be (&
eta_max,
sizeof(
double), 1, fd) ;
95 fwrite_be (&
chi_c,
sizeof(
double), 1, fd) ;
100 for (
int l=0 ; l<
ndim ; l++) {
101 safe_delete(
coloc[l]);
102 safe_delete(
cart[l]);
123 o <<
"Bispherical domain, chi fonction of eta" << endl ;
124 o <<
"aa = " <<
aa << endl ;
125 o <<
"Radius = " <<
r_ext << endl ;
135 assert (
p_eta!=
nullptr) ;
144 while (index.
inc()) ;
152 for (
int i=0 ; i<3 ; i++)
153 assert (
coloc[i] !=
nullptr) ;
154 assert (
p_chi==
nullptr) ;
160 p_chi->
set(index) = ((*bound_chi)(index)-M_PI)*((*
coloc[0])(index(0))) + M_PI ;
161 while (index.
inc()) ;
166 for (
int i=0 ; i<3 ; i++)
167 assert (
coloc[i] !=
nullptr) ;
168 assert (
p_eta==
nullptr) ;
174 while (index.
inc()) ;
179 for (
int i=0 ; i<3 ; i++)
180 assert (
coloc[i] !=
nullptr) ;
181 assert (
p_phi==
nullptr) ;
187 while (index.
inc()) ;
204 for (
int i=0 ; i<3 ; i++)
205 assert (
coloc[i] !=
nullptr) ;
206 for (
int i=0 ; i<3 ; i++)
207 assert (
absol[i] ==
nullptr) ;
208 for (
int i=0 ; i<3 ; i++) {
210 absol[i]->allocate_conf() ;
225 absol[1]->set(index) =
227 absol[2]->set(index) =
230 while (index.
inc()) ;
233 absol[0]->std_base() ;
234 absol[1]->std_base() ;
235 absol[2]->std_anti_base() ;
242 for (
int i=0 ; i<3 ; i++)
243 assert (
coloc[i] !=
nullptr) ;
244 assert (
radius ==
nullptr) ;
250 for (
int i=0 ; i<3 ; i++)
251 assert (
coloc[i] !=
nullptr) ;
252 for (
int i=0 ; i<3 ; i++)
253 assert (
cart[i] ==
nullptr) ;
254 for (
int i=0 ; i<3 ; i++) {
256 cart[i]->allocate_conf() ;
271 cart[1]->set(index) =
273 cart[2]->set(index) =
276 while (index.
inc()) ;
279 cart[0]->std_base() ;
280 cart[1]->std_base() ;
281 cart[2]->std_anti_base() ;
291 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
294 double rho = sqrt(yy*yy+zz*zz) ;
299 chi = (fabs(abs(1)) < fabs(x_out)) ? M_PI : 0;
301 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
306 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
315 double chi_bound = chi_lim_eta (fabs(eta),
r_ext,
aa,
chi_c) ;
316 if (chi<chi_bound-prec)
326 assert (
is_in(abs, 1e-12)) ;
332 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
334 num.
set(3) = atan2 (zz, yy) ;
337 num.
set(3) += 2*M_PI ;
340 double rho = sqrt(yy*yy+zz*zz) ;
344 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
349 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
352 double chi_bound = chi_lim_eta (fabs(eta),
r_ext,
aa,
chi_c) ;
353 num.
set(1) = (chi-M_PI)/(chi_bound-M_PI);
360 assert (
is_in(abs, 1e-3)) ;
366 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
368 num.
set(3) = atan2 (zz, yy) ;
371 num.
set(3) += 2*M_PI ;
374 double rho = sqrt(yy*yy+zz*zz) ;
378 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
383 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
386 double chi_bound = chi_lim_eta (fabs(eta),
r_ext,
aa,
chi_c) ;
387 num.
set(1) = (chi-M_PI)/(chi_bound-M_PI);
400 cerr <<
"Unknown case in Domain_bispheric_eta_first::absol_to_num_bound" << endl ;
407 double coloc_leg(
int,
int) ;
408 double coloc_leg_parity(
int,
int) ;
415 for (
int i=0 ; i<
ndim ; i++)
431 for (
int i=0 ; i<
ndim ; i++)
445 cerr <<
"Unknown type of basis in Domain_bispheric_eta_first::do_coloc" << endl ;
462 index.
set(0) = j ; index.
set(1) = k ;
463 base.
bases_1d[0]->set(index) = (k%2==0) ? CHEB_EVEN : CHEB_ODD ;
482 index.
set(0) = j ; index.
set(1) = k ;
483 base.
bases_1d[0]->set(index) = (k%2==0) ? LEG_EVEN : LEG_ODD ;
501 index.
set(0) = j ; index.
set(1) = k ;
502 base.
bases_1d[0]->set(index) = (k%2==0) ? CHEB_EVEN : CHEB_ODD ;
519 index.
set(0) = j ; index.
set(1) = k ;
520 base.
bases_1d[0]->set(index) = (k%2==0) ? LEG_EVEN : LEG_ODD ;
528 if (
cart[0]==
nullptr)
605 bool res_def = true ;
651 switch ((*a.
bases_1d[1])(index_1)) {
653 switch ((*b.
bases_1d[1])(index_1)) {
655 res.
bases_1d[1]->set(index_1) = CHEB ;
663 switch ((*b.
bases_1d[1])(index_1)) {
665 res.
bases_1d[1]->set(index_1) = LEG ;
677 while (index_1.
inc()) ;
683 switch ((*a.
bases_1d[0])(index_0)) {
685 switch ((*b.
bases_1d[0])(index_0)) {
687 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? CHEB_EVEN : CHEB_ODD ;
690 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? CHEB_ODD : CHEB_EVEN ;
698 switch ((*b.
bases_1d[0])(index_0)) {
700 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? CHEB_ODD : CHEB_EVEN ;
703 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? CHEB_EVEN : CHEB_ODD ;
711 switch ((*b.
bases_1d[0])(index_0)) {
713 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? LEG_EVEN : LEG_ODD ;
716 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? LEG_ODD : LEG_EVEN ;
724 switch ((*b.
bases_1d[0])(index_0)) {
726 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? LEG_ODD : LEG_EVEN ;
729 res.
bases_1d[0]->set(index_0) = (index_0(1)%2==0) ? LEG_EVEN : LEG_ODD ;
741 while (index_0.
inc()) ;
745 for (
int dim=0 ; dim<a.
ndim ; dim++)
761 case ETA_MINUS_BC : {
776 cerr <<
"Unknown boundary case in Domain_bispheric_eta_first::der_normal" << endl ;
783 if (strcmp(p,
"CHI ")==0)
785 if (strcmp(p,
"ETA ")==0)
787 if (strcmp(p,
"P ")==0)
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
void allocate(const Dim_array &nbr_coefs)
Allocates the various arrays, for a given number of coefficients.
bool def
true if the Base_spectral is defined and false otherwise.
int ndim
Number of dimensions.
Class for storing the dimensions of an array.
int get_ndim() const
Returns the number of dimensions.
void save(FILE *) const
Save function.
Class for bispherical coordinates with a symmetry with respect to the plane .
virtual void do_radius() const
Computes the generalized radius.
Val_domain * p_dchidz
Pointer on a Val_domain containing .
Domain_bispheric_eta_first(int num, int ttype, double aa, double rr, double eta_min, double eta_max, const Dim_array &nbr)
Standard constructor :
virtual void do_cart() const
Computes the Cartesian coordinates.
void do_phi() const
Computes in *p_phi.
virtual void do_coloc()
Computes the colocation points.
void do_for_der() const
Computes the partial derivatives of the numerical coordinates with respect to the Cartesian ones like...
virtual void set_anti_legendre_base(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials and an astisymetric function with respect ...
void do_bound_chi() const
Computes and its first derivative stored respectively in and .
virtual void save(FILE *) const
Saving function.
void do_eta() const
Computes in *p_eta.
Val_domain * p_chi
Pointer on a Val_domain containing .
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
Val_domain * p_detadz
Pointer on a Val_domain containing The explicit expression are : .
virtual const Val_domain & get_eta() const
Returns the variable .
Val_domain * p_detady
Pointer on a Val_domain containing The explicit expression are : .
Val_domain * p_eta
Pointer on a Val_domain containing .
virtual void set_legendre_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials.
void do_chi() const
Computes in *p_chi.
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
virtual const Val_domain & get_chi() const
Returns the variable .
virtual void set_anti_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials and an astisymetric function with respect...
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
double r_ext
Radius of the outer boundary.
Val_domain * p_dphidy
Pointer on a Val_domain containing The explicit expression is : .
virtual void set_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials.
virtual const Point absol_to_num_bound(const Point &, int) const
Computes the numerical coordinates from the physical ones for a point lying on a boundary.
Val_domain * p_dphidz
Pointer on a Val_domain containing The explicit expression is : .
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
Val_domain * p_dchidx
Pointer on a Val_domain containing .
double aa
Distance scale .
Val_domain * p_detadx
Pointer on a Val_domain containing The explicit expression are : .
virtual void do_absol() const
Computes the absolute coordinates.
Val_domain * p_dchidy
Pointer on a Val_domain containing .
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
Val_domain * bound_chi
Pointer on a Val_domain containing the values of .
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
double eta_max
Upper bound for .
Val_domain * bound_chi_der
Pointer on a Val_domain containing the values of the derivative with respect to .
Val_domain * p_phi
Pointer on a Val_domain containing .
virtual void do_der_abs_from_der_var(const Val_domain *const *const der_var, Val_domain **const der_abs) const
Computes the derivative with respect to the absolute Cartesian coordinates from the derivative with r...
double eta_min
Lower bound for .
Abstract class that implements the fonctionnalities common to all the type of domains.
Val_domain * radius
The generalized radius.
Memory_mapped_array< Val_domain * > cart
Cartesian coordinates.
Memory_mapped_array< Val_domain * > absol
Asbolute coordinates (if defined ; usually Cartesian-like)
int ndim
Number of dimensions.
Dim_array nbr_coefs
Number of coefficients.
Dim_array nbr_points
Number of colocation points.
int type_base
Type of colocation point :
Val_domain const & get_cart(int i) const
Returns a Cartesian coordinates.
Memory_mapped_array< Array< double > * > coloc
Colocation points in each dimension (stored in ndim 1d- arrays)
Class that gives the position inside a multi-dimensional Array.
int & set(int i)
Read/write of the position in a given dimension.
bool inc(int increm, int var=0)
Increments the position of the Index.
The class Point is used to store the coordinates of a point.
const int & get_ndim() const
Returns the number of dimensions.
double & set(int i)
Read/write of a coordinate.
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Val_domain mult_sin_phi() const
Multiplication by .
Base_spectral base
Spectral basis of the field.
Val_domain mult_cos_phi() const
Multiplication by .
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
void std_base()
Sets the standard basis of decomposition.
Val_domain der_var(int i) const
Computes the derivative with respect to a numerical coordinate.
Base_spectral & set_base()
Sets the basis of decomposition.
void std_anti_base()
Sets the standard, anti-symetric, basis of decomposition.
Val_domain der_abs(int i) const
Computes the derivative with respect to an absolute coordinate (typically Cartesian).
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
Val_domain div_sin_chi() const
Division by .
const Base_spectral & get_base() const
Returns the basis of decomposition.