20 #include "headcpp.hpp"
22 #include "utilities.hpp"
23 #include "spheric.hpp"
25 #include "val_domain.hpp"
42 fread_be (&
alpha,
sizeof(
double), 1, fd) ;
47 Domain_compact::~Domain_compact() {}
50 o <<
"Compactified domain" << endl ;
51 o <<
"Rmin = " << -0.5/
alpha << endl ;
52 o <<
"Center = " <<
center << endl ;
61 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
62 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
64 fwrite_be (&
alpha,
sizeof(
double), 1, fd) ;
83 cerr <<
"Unknown boundary case in Domain_compact::der_normal" << endl ;
111 res += 2./(2*double(j)+1) *
val_boundary(bound, rrso, pcf) ;
117 cerr <<
"Case not yet implemented in Domain_shell::integ" << endl ;
127 for (
int i=0 ; i<3 ; i++)
128 assert (
coloc[i] != 0x0) ;
129 for (
int i=0 ; i<3 ; i++)
130 assert (
absol[i] == 0x0) ;
131 for (
int i=0 ; i<3 ; i++) {
133 absol[i]->allocate_conf() ;
144 while (index.
inc()) ;
149 for (
int i=0 ; i<3 ; i++)
150 assert (
coloc[i] != 0x0) ;
157 while (index.
inc()) ;
162 for (
int i=0 ; i<3 ; i++)
163 assert (
coloc[i] != 0x0) ;
164 for (
int i=0 ; i<3 ; i++)
165 assert (
cart[i] == 0x0) ;
166 for (
int i=0 ; i<3 ; i++) {
168 cart[i]->allocate_conf() ;
179 while (index.
inc()) ;
184 for (
int i=0 ; i<3 ; i++)
185 assert (
coloc[i] != 0x0) ;
186 for (
int i=0 ; i<3 ; i++)
188 for (
int i=0 ; i<3 ; i++) {
198 while (index.
inc()) ;
206 double x_loc = xx(1) -
center(1) ;
207 double y_loc = xx(2) -
center(2) ;
208 double z_loc = xx(3) -
center(3) ;
209 double air_loc = sqrt (x_loc*x_loc + y_loc*y_loc + z_loc*z_loc) ;
211 bool res = (1. + 1./(2*
alpha*air_loc) >= -prec) ? true : false ;
218 assert (
is_in(abs)) ;
221 double x_loc = abs(1) -
center(1) ;
222 double y_loc = abs(2) -
center(2) ;
223 double z_loc = abs(3) -
center(3) ;
224 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
226 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
230 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
234 num.
set(2) = atan(rho/z_loc) ;
235 num.
set(3) = atan2 (y_loc, x_loc) ;
239 num.
set(2) = M_PI + num(2) ;
248 assert (bound==INNER_BC) ;
249 assert (
is_in(abs, 1e-3)) ;
252 double x_loc = abs(1) -
center(1) ;
253 double y_loc = abs(2) -
center(2) ;
254 double z_loc = abs(3) -
center(3) ;
256 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
260 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
264 num.
set(2) = atan(rho/z_loc) ;
265 num.
set(3) = atan2 (y_loc, x_loc) ;
269 num.
set(2) = M_PI + num(2) ;
274 double coloc_leg(
int,
int) ;
282 for (
int i=0 ; i<
ndim ; i++)
295 for (
int i=0 ; i<
ndim ; i++)
305 cerr <<
"Unknown type of basis in Domain_compact::do_coloc" << endl ;
323 m = (k%2==0) ? k/2 : (k-1)/2 ;
324 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
326 index.
set(0) = j ; index.
set(1) = k ;
327 base.
bases_1d[0]->set(index) = CHEB ;
345 m = (k%2==0) ? k/2 : (k-1)/2 ;
346 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
348 index.
set(0) = j ; index.
set(1) = k ;
349 base.
bases_1d[0]->set(index) = CHEB ;
357 m = (k%2==0) ? k/2 : (k-1)/2 ;
358 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
360 index.
set(0) = j ; index.
set(1) = k ;
361 base.
bases_1d[0]->set(index) = CHEB ;
389 m = (k%2==0) ? k/2 : (k-1)/2 ;
390 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
392 index.
set(0) = j ; index.
set(1) = k ;
393 base.
bases_1d[0]->set(index) = CHEB ;
410 m = (k%2==0) ? k/2 : (k-1)/2 ;
411 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
413 index.
set(0) = j ; index.
set(1) = k ;
414 base.
bases_1d[0]->set(index) = CHEB ;
431 m = (k%2==0) ? k/2 : (k-1)/2 ;
432 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
434 index.
set(0) = j ; index.
set(1) = k ;
435 base.
bases_1d[0]->set(index) = CHEB ;
452 m = (k%2==0) ? k/2 : (k-1)/2 ;
453 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
455 index.
set(0) = j ; index.
set(1) = k ;
456 base.
bases_1d[0]->set(index) = CHEB ;
472 m = (k%2==0) ? k/2 : (k-1)/2 ;
473 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
475 index.
set(0) = j ; index.
set(1) = k ;
476 base.
bases_1d[0]->set(index) = CHEB ;
493 m = (k%2==0) ? k/2 : (k-1)/2 ;
494 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
496 index.
set(0) = j ; index.
set(1) = k ;
497 base.
bases_1d[0]->set(index) = CHEB ;
514 m = (k%2==0) ? k/2 : (k-1)/2 ;
515 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
517 index.
set(0) = j ; index.
set(1) = k ;
518 base.
bases_1d[0]->set(index) = CHEB ;
537 m = (k%2==0) ? k/2 : (k-1)/2 ;
538 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
540 index.
set(0) = j ; index.
set(1) = k ;
541 base.
bases_1d[0]->set(index) = LEG ;
560 m = (k%2==0) ? k/2 : (k-1)/2 ;
561 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
563 index.
set(0) = j ; index.
set(1) = k ;
564 base.
bases_1d[0]->set(index) = LEG ;
582 m = (k%2==0) ? k/2 : (k-1)/2 ;
583 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
585 index.
set(0) = j ; index.
set(1) = k ;
586 base.
bases_1d[0]->set(index) = LEG ;
603 m = (k%2==0) ? k/2 : (k-1)/2 ;
604 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
606 index.
set(0) = j ; index.
set(1) = k ;
607 base.
bases_1d[0]->set(index) = LEG ;
624 m = (k%2==0) ? k/2 : (k-1)/2 ;
625 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
627 index.
set(0) = j ; index.
set(1) = k ;
628 base.
bases_1d[0]->set(index) = LEG ;
644 m = (k%2==0) ? k/2 : (k-1)/2 ;
645 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
647 index.
set(0) = j ; index.
set(1) = k ;
648 base.
bases_1d[0]->set(index) = LEG ;
665 m = (k%2==0) ? k/2 : (k-1)/2 ;
666 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
668 index.
set(0) = j ; index.
set(1) = k ;
669 base.
bases_1d[0]->set(index) = LEG ;
686 m = (k%2==0) ? k/2 : (k-1)/2 ;
687 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
689 index.
set(0) = j ; index.
set(1) = k ;
690 base.
bases_1d[0]->set(index) = LEG ;
706 while (inf.
inc1(1)) ;
738 bool res_def = true ;
770 switch ((*a.
bases_1d[1])(index_1)) {
772 switch ((*b.
bases_1d[1])(index_1)) {
774 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
777 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
780 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
783 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
791 switch ((*b.
bases_1d[1])(index_1)) {
793 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
796 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
799 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
802 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
810 switch ((*b.
bases_1d[1])(index_1)) {
812 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
815 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
818 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
821 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
829 switch ((*b.
bases_1d[1])(index_1)) {
831 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
834 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
837 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
840 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
852 while (index_1.
inc()) ;
859 switch ((*a.
bases_1d[0])(index_0)) {
861 switch ((*b.
bases_1d[0])(index_0)) {
863 res.
bases_1d[0]->set(index_0) = CHEB ;
871 switch ((*b.
bases_1d[0])(index_0)) {
873 res.
bases_1d[0]->set(index_0) = LEG ;
885 while (index_0.
inc()) ;
889 for (
int dim=0 ; dim<a.
ndim ; dim++)
900 if (strcmp(p,
"R ")==0)
902 if (strcmp(p,
"T ")==0)
904 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.
int & set(int i)
Read/write of the size of a given dimension.
void save(FILE *) const
Save function.
Class for a spherical compactified domain and a symmetry with respect to the plane .
virtual double val_boundary(int, const Val_domain &, const Index &) const
Computes the value of a field at a boundary.
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void set_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials.
virtual void do_coloc()
Computes the colocation points.
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual void set_val_inf(Val_domain &, double) const
Sets the value at infinity of a Val_domain : not implemented for this type of Domain.
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.
virtual void save(FILE *) const
Saving function.
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual void set_cheb_base_r_mtz(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the radial component of a vector in the MTZ setting.
virtual void set_legendre_base_t_mtz(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector in the MTZ context.
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
double alpha
Relates the numerical to the physical radii.
virtual Val_domain div_sin_theta(const Val_domain &) const
Division by .
virtual Val_domain mult_r(const Val_domain &) const
Multiplication by .
Point center
Absolute coordinates of the center.
Domain_compact(int num, int ttype, double r_int, const Point &cr, const Dim_array &nbr)
Standard constructor :
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
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_legendre_base_r_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector.
virtual void set_legendre_base_r_mtz(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector in the MTZ context.
virtual void do_absol() const
Computes the absolute coordinates.
virtual void set_legendre_base_p_mtz(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector in the MTZ context.
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual void set_cheb_base_p_mtz(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector in the MTZ setting.
virtual void set_cheb_base_t_mtz(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector in the MTZ setting.
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 set_anti_legendre_base(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials for functions antisymetric in The bases a...
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev 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.
virtual void set_anti_cheb_base(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials for functions antisymetric in The bases ...
virtual void set_legendre_base(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials.
virtual Val_domain mult_xm1(const Val_domain &) const
Multiplication by .
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
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_legendre_base_t_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void set_cheb_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for the radius.
virtual double integ(const Val_domain &, int) const
Surface integral on a given boundary.
virtual void do_radius() const
Computes the generalized radius.
virtual void set_cheb_base_with_m(Base_spectral &so, int m) const
Gives the standard base using Chebyshev polynomials.
virtual void set_legendre_base_p_spher(Base_spectral &) const
Gives the base using Legendre 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.
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 .
void set_in_conf()
Destroys the values in the coefficient space.
bool check_if_zero() const
Check whether the logical state is zero or not.
Val_domain mult_sin_theta() const
Multiplication by .
Val_domain mult_cos_phi() const
Multiplication by .
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 .
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
const Base_spectral & get_base() const
Returns the basis of decomposition.