20 #include "headcpp.hpp"
21 #include "utilities.hpp"
23 #include "bispheric.hpp"
24 #include "array_math.hpp"
26 #include "val_domain.hpp"
29 Domain_bispheric_rect::Domain_bispheric_rect (
int num,
int ttype,
double a,
double rr,
double etamin,
double etapl,
double chimin,
const Dim_array& nbr) :
Domain(num, ttype, nbr), aa(a), r_ext(rr), eta_minus(etamin), eta_plus(etapl), chi_min(chimin), p_eta(nullptr), p_chi(nullptr), p_phi(nullptr),
30 p_detadx(nullptr), p_detady(nullptr), p_detadz(nullptr), p_dchidx(nullptr), p_dchidy(nullptr), p_dchidz(nullptr), p_dphidy(nullptr), p_dphidz(nullptr), p_dsint(nullptr) {
38 eta_minus(so.eta_minus), eta_plus(so.eta_plus), chi_min(so.chi_min) {
54 fread_be (&
aa,
sizeof(
double), 1, fd) ;
55 fread_be (&
eta_minus,
sizeof(
double), 1, fd) ;
56 fread_be (&
eta_plus,
sizeof(
double), 1, fd) ;
57 fread_be (&
chi_min,
sizeof(
double), 1, fd) ;
75 Domain_bispheric_rect::~Domain_bispheric_rect() {
82 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
83 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
84 fwrite_be (&
aa,
sizeof(
double), 1, fd) ;
85 fwrite_be (&
eta_minus,
sizeof(
double), 1, fd) ;
86 fwrite_be (&
eta_plus,
sizeof(
double), 1, fd) ;
87 fwrite_be (&
chi_min,
sizeof(
double), 1, fd) ;
92 for (
int l=0 ; l<
ndim ; l++) {
93 safe_delete(
coloc[l]);
114 o <<
"Bispherical domain, rectangular part" << endl ;
115 o <<
"aa = " <<
aa << endl ;
117 o <<
chi_min <<
" < chi < pi " << endl ;
125 for (
int i=0 ; i<3 ; i++)
126 assert (
coloc[i] !=
nullptr) ;
127 assert (
p_eta==
nullptr) ;
133 while (index.
inc()) ;
138 for (
int i=0 ; i<3 ; i++)
139 assert (
coloc[i] !=
nullptr) ;
140 assert (
p_chi==
nullptr) ;
146 while (index.
inc()) ;
151 for (
int i=0 ; i<3 ; i++)
152 assert (
coloc[i] !=
nullptr) ;
153 assert (
p_phi==
nullptr) ;
159 while (index.
inc()) ;
175 for (
int i=0 ; i<3 ; i++)
176 assert (
coloc[i] !=
nullptr) ;
177 for (
int i=0 ; i<3 ; i++)
178 assert (
absol[i] ==
nullptr) ;
179 for (
int i=0 ; i<3 ; i++) {
181 absol[i]->allocate_conf() ;
195 absol[1]->set(index) =
197 absol[2]->set(index) =
200 while (index.
inc()) ;
203 absol[0]->std_base() ;
204 absol[1]->std_base() ;
205 absol[2]->std_anti_base() ;
212 for (
int i=0 ; i<3 ; i++)
213 assert (
coloc[i] !=
nullptr) ;
214 assert (
radius ==
nullptr) ;
220 for (
int i=0 ; i<3 ; i++)
221 assert (
coloc[i] !=
nullptr) ;
222 for (
int i=0 ; i<3 ; i++)
223 assert (
cart[i] ==
nullptr) ;
224 for (
int i=0 ; i<3 ; i++) {
226 cart[i]->allocate_conf() ;
240 cart[1]->set(index) =
242 cart[2]->set(index) =
245 while (index.
inc()) ;
248 cart[0]->std_base() ;
249 cart[1]->std_base() ;
250 cart[2]->std_anti_base() ;
274 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
277 double rho = sqrt(yy*yy+zz*zz) ;
282 chi = (fabs(xx)>fabs(x_out)) ? 0 : M_PI ;
284 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
289 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
309 assert (
is_in(abs, 1e-12)) ;
315 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
317 num.
set(3) = atan2 (zz, yy) ;
320 num.
set(3) += 2*M_PI ;
323 double rho = sqrt(yy*yy+zz*zz) ;
329 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
334 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
344 assert (
is_in(abs, 1e-3)) ;
350 double air = sqrt (xx*xx+yy*yy+zz*zz) ;
352 num.
set(3) = atan2 (zz, yy) ;
355 num.
set(3) += 2*M_PI ;
358 double rho = sqrt(yy*yy+zz*zz) ;
364 chi = atan (2*
aa*rho/(air*air-
aa*
aa)) ;
369 double eta = 0.5*log((1+(2*
aa*xx)/(
aa*
aa+air*air))/(1-(2*
aa*xx)/(
aa*
aa+air*air))) ;
389 cerr <<
"Unknown case in Domain_bispheric_rect::absol_to_num_bound" << endl ;
395 double coloc_leg(
int,
int) ;
396 double coloc_leg_parity(
int,
int) ;
403 for (
int i=0 ; i<
ndim ; i++)
418 for (
int i=0 ; i<
ndim ; i++)
431 cerr <<
"Unknown type of basis in Domain_bispheric_rect::do_coloc" << endl ;
447 base.
bases_1d[1]->set(k) = (k%2==0) ? CHEB_EVEN : CHEB_ODD ;
449 index.
set(0) = j ; index.
set(1) = k ;
450 base.
bases_1d[0]->set(index) = CHEB ;
466 base.
bases_1d[1]->set(k) = (k%2==0) ? CHEB_EVEN : CHEB_ODD ;
468 index.
set(0) = j ; index.
set(1) = k ;
469 base.
bases_1d[0]->set(index) = CHEB ;
474 double coloc_leg(
int,
int) ;
475 double coloc_leg_parity(
int,
int) ;
487 base.
bases_1d[1]->set(k) = (k%2==0) ? LEG_EVEN : LEG_ODD ;
489 index.
set(0) = j ; index.
set(1) = k ;
490 base.
bases_1d[0]->set(index) = LEG ;
506 base.
bases_1d[1]->set(k) = (k%2==0) ? LEG_EVEN : LEG_ODD ;
508 index.
set(0) = j ; index.
set(1) = k ;
509 base.
bases_1d[0]->set(index) = LEG ;
517 if (
cart[0]==
nullptr)
580 bool res_def = true ;
627 switch ((*a.
bases_1d[1])(index_1)) {
629 switch ((*b.
bases_1d[1])(index_1)) {
631 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? CHEB_EVEN : CHEB_ODD ;
634 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? CHEB_ODD : CHEB_EVEN ;
642 switch ((*b.
bases_1d[1])(index_1)) {
644 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? CHEB_ODD : CHEB_EVEN ;
647 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? CHEB_EVEN : CHEB_ODD ;
655 switch ((*b.
bases_1d[1])(index_1)) {
657 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? LEG_EVEN : LEG_ODD ;
660 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? LEG_ODD : LEG_EVEN ;
668 switch ((*b.
bases_1d[1])(index_1)) {
670 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? LEG_ODD : LEG_EVEN ;
673 res.
bases_1d[1]->set(index_1) = (index_1(0)%2==0) ? LEG_EVEN : LEG_ODD ;
685 while (index_1.
inc()) ;
691 switch ((*a.
bases_1d[0])(index_0)) {
693 switch ((*b.
bases_1d[0])(index_0)) {
695 res.
bases_1d[0]->set(index_0) = CHEB ;
703 switch ((*b.
bases_1d[0])(index_0)) {
705 res.
bases_1d[0]->set(index_0) = LEG ;
717 while (index_0.
inc()) ;
721 for (
int dim=0 ; dim<a.
ndim ; dim++)
749 cerr <<
"Unknown boundary case in Domain_bispheric_rect::der_normal" << endl ;
756 if (bound !=INNER_BC) {
757 cerr <<
"Domain_bispheric_rect::integ only defined for inner boundary yet" << endl ;
790 val_cheb = double(2*j)/double(4*j*j-1) -1./double(2*j-1) ;
797 val_cheb = 2*double(2*j+1)/double((2*j+1)*(2*j+1)-1) - 1./double(2*j) ;
799 val_cheb = -1./double(2*j) ;
802 cerr <<
"Unknown basis in Domain_bispheric_rect::integ" << endl ;
808 res += val_cheb * (*auxi.
cf)(pos) ;
810 res -= val_cheb * (*auxi.
cf)(pos) ;
818 double val_leg = 1. ;
820 double val_m = -0.5 ;
830 val_leg = (val_m1 - val_m)/
double(4*j+3) ;
831 val_m *= -double(2*j+3)/double(2*j+4) ;
832 val_m1 *= -double(2*j+1)/double(2*j+2) ;
835 cerr <<
"Unknown basis in Domain_bispheric_rect::integ" << endl ;
842 res += val_leg*(*auxi.
cf)(pos) ;
844 res -= val_leg*(*auxi.
cf)(pos) ;
854 if (strcmp(p,
"ETA ")==0)
856 if (strcmp(p,
"CHI ")==0)
858 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 set_anti_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials and an astisymetric function with respect...
Val_domain * p_dsint
Pointer on a Val_domain containing the surface element on the inner boundary of the domain (being sph...
Val_domain * p_dchidy
Pointer on a Val_domain containing The explicit expression are : .
Val_domain * p_eta
Pointer on a Val_domain containing .
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
double eta_plus
associated with .
Val_domain * p_detadz
Pointer on a Val_domain containing The explicit expression are : .
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
Val_domain * p_detady
Pointer on a Val_domain containing The explicit expression are : .
virtual void do_absol() const
Computes the absolute coordinates.
virtual const Val_domain & get_eta() const
Returns the variable .
double eta_minus
associated with .
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual void do_radius() const
Computes the generalized radius.
void do_for_der() const
Computes the partial derivatives of the numerical coordinates with respect to the Cartesian ones like...
double aa
Distance scale .
void do_chi() const
Computes in *p_chi.
Val_domain * p_dphidz
Pointer on a Val_domain containing The explicit expression is : .
Val_domain * p_chi
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.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
Val_domain * p_dphidy
Pointer on a Val_domain containing The explicit expression is : .
virtual const Val_domain & get_chi() const
Returns the variable .
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 The explicit expression are : .
void do_dsint() const
Computes the surface element and stores it in *p_dsint.
virtual void set_legendre_base(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials.
Val_domain * p_dchidz
Pointer on a Val_domain containing The explicit expression are : .
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_detadx
Pointer on a Val_domain containing The explicit expression are : .
double chi_min
Lower bound for .
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 r_ext
Radius of the outer boundary.
virtual void set_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials.
virtual double integ(const Val_domain &, int) const
Surface integral on a given boundary.
virtual void save(FILE *fd) const
Saving function.
void do_phi() const
Computes in *p_phi
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 ...
virtual void do_coloc()
Computes the colocation points.
Domain_bispheric_rect(int nd, int ttype, double aa, double rext, double eta_minus, double eta_plus, double chi_min, const Dim_array &nbr)
Standard constructor :
void do_eta() const
Computes in *p_eta.
Val_domain * p_phi
Pointer on a Val_domain containing .
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 const & get_nbr_coefs() const
Returns the number of coefficients.
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 .
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
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.
void coef() const
Computes the coefficients.
Val_domain der_var(int i) const
Computes the derivative with respect to a numerical coordinate.
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.