20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "spheric_symphi.hpp"
23 #include "array_math.hpp"
24 #include "val_domain.hpp"
41 fread_be (&
alpha,
sizeof(
double), 1, fd) ;
46 Domain_compact_symphi::~Domain_compact_symphi() {}
49 o <<
"Compactified domain sym phi" << endl ;
50 o <<
"Rmin = " << -0.5/
alpha << endl ;
51 o <<
"Center = " <<
center << endl ;
60 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
61 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
63 fwrite_be (&
alpha,
sizeof(
double), 1, fd) ;
82 cerr <<
"Unknown boundary case in Domain_compact_symphi::der_normal" << endl ;
91 if (bound!=OUTER_BC) {
92 cerr <<
"Domain_compact_symphi::integ only defined for r=infty yet..." << endl ;
97 if (baset != COS_EVEN) {
113 double fact_tet = 2./double(1-4*j*j) ;
117 res += fact_tet*(*auxi.
cf)(pos) ;
126 for (
int i=0 ; i<3 ; i++)
127 assert (
coloc[i] != 0x0) ;
128 for (
int i=0 ; i<3 ; i++)
129 assert (
absol[i] == 0x0) ;
130 for (
int i=0 ; i<3 ; i++) {
132 absol[i]->allocate_conf() ;
143 while (index.
inc()) ;
148 for (
int i=0 ; i<3 ; i++)
149 assert (
coloc[i] != 0x0) ;
156 while (index.
inc()) ;
161 for (
int i=0 ; i<3 ; i++)
162 assert (
coloc[i] != 0x0) ;
163 for (
int i=0 ; i<3 ; i++)
164 assert (
cart[i] == 0x0) ;
165 for (
int i=0 ; i<3 ; i++) {
167 cart[i]->allocate_conf() ;
178 while (index.
inc()) ;
192 cerr <<
"Unknown type of basis in Domain_compact_symphi::do_cart" << endl ;
199 for (
int i=0 ; i<3 ; i++)
200 assert (
coloc[i] != 0x0) ;
201 for (
int i=0 ; i<3 ; i++)
203 for (
int i=0 ; i<3 ; i++) {
213 while (index.
inc()) ;
227 cerr <<
"Unknown type of basis in Domain_compact_symphi::do_cart_surr" << endl ;
237 double x_loc = xx(1) -
center(1) ;
238 double y_loc = xx(2) -
center(2) ;
239 double z_loc = xx(3) -
center(3) ;
240 double air_loc = sqrt (x_loc*x_loc + y_loc*y_loc + z_loc*z_loc) ;
242 bool res = (air_loc >= -0.5/
alpha-prec) ?
true :
false ;
249 assert (
is_in(abs)) ;
252 double x_loc = abs(1) -
center(1) ;
253 double y_loc = abs(2) -
center(2) ;
254 double z_loc = abs(3) -
center(3) ;
255 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
257 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
261 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
265 num.
set(2) = atan(rho/z_loc) ;
266 num.
set(3) = atan2 (y_loc, x_loc) ;
270 num.
set(2) = M_PI + num(2) ;
279 assert (bound==INNER_BC) ;
280 assert (
is_in(abs, 1e-3)) ;
283 double x_loc = abs(1) -
center(1) ;
284 double y_loc = abs(2) -
center(2) ;
285 double z_loc = abs(3) -
center(3) ;
287 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
291 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
295 num.
set(2) = atan(rho/z_loc) ;
296 num.
set(3) = atan2 (y_loc, x_loc) ;
300 num.
set(2) = M_PI + num(2) ;
305 double coloc_leg(
int,
int) ;
312 for (
int i=0 ; i<
ndim ; i++)
324 for (
int i=0 ; i<
ndim ; i++)
334 cerr <<
"Unknown type of basis in Domain_compact_symphi::do_coloc" << endl ;
349 base.
bases_1d[2]->set(0) = COS_EVEN ;
351 base.
bases_1d[1]->set(k) = COS_EVEN ;
353 index.
set(0) = j ; index.
set(1) = k ;
354 base.
bases_1d[0]->set(index) = CHEB ;
368 base.
bases_1d[2]->set(0) = SIN_EVEN ;
370 base.
bases_1d[1]->set(k) = COS_EVEN ;
372 index.
set(0) = j ; index.
set(1) = k ;
373 base.
bases_1d[0]->set(index) = CHEB ;
386 base.
bases_1d[2]->set(0) = SIN_EVEN ;
388 base.
bases_1d[1]->set(k) = SIN_EVEN ;
390 index.
set(0) = j ; index.
set(1) = k ;
391 base.
bases_1d[0]->set(index) = CHEB ;
404 base.
bases_1d[2]->set(0) = COS_EVEN ;
406 base.
bases_1d[1]->set(k) = SIN_ODD ;
408 index.
set(0) = j ; index.
set(1) = k ;
409 base.
bases_1d[0]->set(index) = CHEB ;
422 base.
bases_1d[2]->set(0) = SIN_ODD ;
424 base.
bases_1d[1]->set(k) = SIN_ODD ;
426 index.
set(0) = j ; index.
set(1) = k ;
427 base.
bases_1d[0]->set(index) = CHEB ;
440 base.
bases_1d[2]->set(0) = COS_ODD ;
442 base.
bases_1d[1]->set(k) = SIN_ODD ;
444 index.
set(0) = j ; index.
set(1) = k ;
445 base.
bases_1d[0]->set(index) = CHEB ;
459 base.
bases_1d[2]->set(0) = SIN_EVEN ;
461 base.
bases_1d[1]->set(k) = COS_ODD ;
463 index.
set(0) = j ; index.
set(1) = k ;
464 base.
bases_1d[0]->set(index) = CHEB ;
479 base.
bases_1d[2]->set(0) = COS_ODD ;
481 base.
bases_1d[1]->set(k) = SIN_ODD ;
483 index.
set(0) = j ; index.
set(1) = k ;
484 base.
bases_1d[0]->set(index) = CHEB ;
497 base.
bases_1d[2]->set(0) = SIN_ODD ;
499 base.
bases_1d[1]->set(k) = SIN_ODD ;
501 index.
set(0) = j ; index.
set(1) = k ;
502 base.
bases_1d[0]->set(index) = CHEB ;
516 base.
bases_1d[2]->set(0) = COS_EVEN ;
518 base.
bases_1d[1]->set(k) = COS_ODD ;
520 index.
set(0) = j ; index.
set(1) = k ;
521 base.
bases_1d[0]->set(index) = CHEB ;
535 base.
bases_1d[2]->set(0) = COS_EVEN ;
537 base.
bases_1d[1]->set(k) = COS_EVEN ;
539 index.
set(0) = j ; index.
set(1) = k ;
540 base.
bases_1d[0]->set(index) = LEG ;
554 base.
bases_1d[2]->set(0) = SIN_EVEN ;
556 base.
bases_1d[1]->set(k) = COS_EVEN ;
558 index.
set(0) = j ; index.
set(1) = k ;
559 base.
bases_1d[0]->set(index) = LEG ;
572 base.
bases_1d[2]->set(0) = SIN_EVEN ;
574 base.
bases_1d[1]->set(k) = SIN_EVEN ;
576 index.
set(0) = j ; index.
set(1) = k ;
577 base.
bases_1d[0]->set(index) = LEG ;
590 base.
bases_1d[2]->set(0) = COS_EVEN ;
592 base.
bases_1d[1]->set(k) = SIN_ODD ;
594 index.
set(0) = j ; index.
set(1) = k ;
595 base.
bases_1d[0]->set(index) = LEG ;
608 base.
bases_1d[2]->set(0) = SIN_ODD ;
610 base.
bases_1d[1]->set(k) = SIN_ODD ;
612 index.
set(0) = j ; index.
set(1) = k ;
613 base.
bases_1d[0]->set(index) = LEG ;
626 base.
bases_1d[2]->set(0) = COS_ODD ;
628 base.
bases_1d[1]->set(k) = SIN_ODD ;
630 index.
set(0) = j ; index.
set(1) = k ;
631 base.
bases_1d[0]->set(index) = LEG ;
645 base.
bases_1d[2]->set(0) = SIN_EVEN ;
647 base.
bases_1d[1]->set(k) = COS_ODD ;
649 index.
set(0) = j ; index.
set(1) = k ;
650 base.
bases_1d[0]->set(index) = LEG ;
663 base.
bases_1d[2]->set(0) = COS_ODD ;
665 base.
bases_1d[1]->set(k) = SIN_ODD ;
667 index.
set(0) = j ; index.
set(1) = k ;
668 base.
bases_1d[0]->set(index) = LEG ;
681 base.
bases_1d[2]->set(0) = SIN_ODD ;
683 base.
bases_1d[1]->set(k) = SIN_ODD ;
685 index.
set(0) = j ; index.
set(1) = k ;
686 base.
bases_1d[0]->set(index) = LEG ;
700 base.
bases_1d[2]->set(0) = COS_EVEN ;
702 base.
bases_1d[1]->set(k) = COS_ODD ;
704 index.
set(0) = j ; index.
set(1) = k ;
705 base.
bases_1d[0]->set(index) = LEG ;
721 while (inf.
inc1(1)) ;
753 bool res_def = true ;
769 res.
bases_1d[2]->set(0) = COS_EVEN ;
775 res.
bases_1d[2]->set(0) = SIN_EVEN ;
794 res.
bases_1d[2]->set(0) = COS_EVEN ;
800 res.
bases_1d[2]->set(0) = SIN_EVEN ;
814 res.
bases_1d[2]->set(0) = SIN_EVEN ;
820 res.
bases_1d[2]->set(0) = COS_EVEN ;
831 res.
bases_1d[2]->set(0) = SIN_EVEN ;
837 res.
bases_1d[2]->set(0) = COS_EVEN ;
859 switch ((*a.
bases_1d[1])(index_1)) {
861 switch ((*b.
bases_1d[1])(index_1)) {
863 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
866 res.
bases_1d[1]->set(index_1) = COS_ODD ;
869 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
872 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
883 switch ((*b.
bases_1d[1])(index_1)) {
885 res.
bases_1d[1]->set(index_1) = COS_ODD ;
888 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
891 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
894 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
903 switch ((*b.
bases_1d[1])(index_1)) {
905 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
908 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
911 res.
bases_1d[1]->set(index_1) = COS_ODD ;
914 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
923 switch ((*b.
bases_1d[1])(index_1)) {
925 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
928 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
931 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
934 res.
bases_1d[1]->set(index_1) = COS_ODD ;
948 while (index_1.
inc()) ;
956 switch ((*a.
bases_1d[0])(index_0)) {
958 switch ((*b.
bases_1d[0])(index_0)) {
960 res.
bases_1d[0]->set(index_0) = CHEB ;
968 switch ((*b.
bases_1d[0])(index_0)) {
970 res.
bases_1d[0]->set(index_0) = LEG ;
982 while (index_0.
inc()) ;
986 for (
int dim=0 ; dim<a.
ndim ; dim++)
998 if (strcmp(p,
"R ")==0)
1000 if (strcmp(p,
"T ")==0)
1002 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 a spherical compactified domain and a symmetry with respect to the plane and a quadrant sy...
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
double alpha
Relates the numerical to the physical radii.
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
virtual double integ(const Val_domain &so, int bound) const
Surface integral on a given boundary.
void set_legendre_base_forx_cart(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials for a field like the component of a vecto...
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
virtual void do_radius() const
Computes the generalized radius.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual void set_legendre_base_p_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
void set_legendre_base_forz_cart(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials for a field like the component of a vecto...
virtual void set_val_inf(Val_domain &so, double xx) const
Sets the value at infinity of a Val_domain : not implemented for this type of Domain.
virtual void save(FILE *) const
Saving function.
virtual Val_domain div_sin_theta(const Val_domain &) const
Division by .
virtual void set_legendre_base_y_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void set_legendre_base_t_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void set_cheb_base_r_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the radial component of a vector.
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual void set_cheb_base_p_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void set_cheb_base_y_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void set_legendre_base_x_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void set_legendre_base_r_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector.
virtual void set_cheb_base_z_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
void set_cheb_base_forx_cart(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials for a field like the component of a vect...
virtual void set_legendre_base_z_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
Point center
Absolute coordinates of the center.
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.
void set_legendre_base_fory_cart(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials for a field like the component of a vecto...
virtual Val_domain mult_xm1(const Val_domain &) const
Multiplication by .
void set_cheb_base_forz_cart(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials for a field like the component of a vect...
virtual void do_coloc()
Computes the colocation points.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual void do_absol() const
Computes the absolute coordinates.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
void set_cheb_base_fory_cart(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials for a field like the component of a vect...
Domain_compact_symphi(int num, int ttype, double r_int, const Point &cr, const Dim_array &nbr)
Standard constructor :
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...
virtual void set_cheb_base_x_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
Abstract class that implements the fonctionnalities common to all the type of domains.
virtual void del_deriv()
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
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.
Memory_mapped_array< Val_domain * > cart_surr
Cartesian coordinates divided by the radius.
Dim_array nbr_coefs
Number of coefficients.
Dim_array nbr_points
Number of colocation points.
int type_base
Type of colocation point :
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.
bool inc1(int var)
Increment on one dimension.
The class Point is used to store the coordinates of a point.
void save(FILE *) const
Saving function.
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.
void set_in_conf()
Destroys the values in the coefficient space.
Val_domain div_xm1() const
Division by .
Val_domain mult_sin_theta() const
Multiplication by .
Val_domain mult_cos_phi() const
Multiplication by .
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
void coef_i() const
Computes the values in the configuration space.
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Val_domain mult_cos_theta() const
Multiplication by .
Val_domain mult_xm1() const
Multiplication by .
void coef() const
Computes the coefficients.
Val_domain der_var(int i) const
Computes the derivative with respect to a numerical coordinate.
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
const Domain * get_domain() const