20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "spheric_symphi.hpp"
23 #include "array_math.hpp"
24 #include "val_domain.hpp"
28 alpha((rext-rint)/2.), beta((rext+rint)/2.), center(cr) {
39 beta(so.beta), center(so.center){}
44 fread_be (&
alpha,
sizeof(
double), 1, fd) ;
45 fread_be (&
beta,
sizeof(
double), 1, fd) ;
55 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
56 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
58 fwrite_be (&
alpha,
sizeof(
double), 1, fd) ;
59 fwrite_be (&
beta,
sizeof(
double), 1, fd) ;
63 o <<
"Shell symphi" << endl ;
65 o <<
"Center = " <<
center << endl ;
85 cerr <<
"Unknown boundary case in Domain_shell_symphi::der_normal" << endl ;
93 for (
int i=0 ; i<3 ; i++)
94 assert (
coloc[i] != 0x0) ;
95 for (
int i=0 ; i<3 ; i++)
96 assert (
absol[i] == 0x0) ;
97 for (
int i=0 ; i<3 ; i++) {
99 absol[i]->allocate_conf() ;
110 while (index.
inc()) ;
115 for (
int i=0 ; i<3 ; i++)
116 assert (
coloc[i] != 0x0) ;
123 while (index.
inc()) ;
133 cerr <<
"Unknown type of basis in Domain_nucleus_symphi::do_radius" << endl ;
140 for (
int i=0 ; i<3 ; i++)
141 assert (
coloc[i] != 0x0) ;
142 for (
int i=0 ; i<3 ; i++)
143 assert (
cart[i] == 0x0) ;
144 for (
int i=0 ; i<3 ; i++) {
146 cart[i]->allocate_conf() ;
157 while (index.
inc()) ;
172 cerr <<
"Unknown type of basis in Domain_shell_symphi::do_cart" << endl ;
179 for (
int i=0 ; i<3 ; i++)
180 assert (
coloc[i] != 0x0) ;
181 for (
int i=0 ; i<3 ; i++)
183 for (
int i=0 ; i<3 ; i++) {
194 while (index.
inc()) ;
209 cerr <<
"Unknown type of basis in Domain_shell_symphi::do_cart_surr" << endl ;
220 double x_loc = xx(1) -
center(1) ;
221 double y_loc = xx(2) -
center(2) ;
222 double z_loc = xx(3) -
center(3) ;
223 double air_loc = sqrt (x_loc*x_loc + y_loc*y_loc + z_loc*z_loc) ;
225 bool res = ((air_loc <=
alpha+
beta+prec) && (air_loc >=
beta-
alpha-prec)) ?
true :
false ;
232 assert (
is_in(abs)) ;
235 double x_loc = abs(1) -
center(1) ;
236 double y_loc = abs(2) -
center(2) ;
237 double z_loc = abs(3) -
center(3) ;
238 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
240 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
244 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
248 num.
set(2) = atan(rho/z_loc) ;
249 num.
set(3) = atan2 (y_loc, x_loc) ;
253 num.
set(2) = M_PI + num(2) ;
261 assert ((bound==OUTER_BC) || (bound==INNER_BC)) ;
262 assert (
is_in(abs, 1e-3)) ;
265 double x_loc = abs(1) -
center(1) ;
266 double y_loc = abs(2) -
center(2) ;
267 double z_loc = abs(3) -
center(3) ;
277 cerr <<
"unknown boundary in Domain_shell_symphi::absol_to_num" << endl ;
281 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
285 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
289 num.
set(2) = atan(rho/z_loc) ;
290 num.
set(3) = atan2 (y_loc, x_loc) ;
294 num.
set(2) = M_PI + num(2) ;
298 double coloc_leg (
int,
int) ;
305 for (
int i=0 ; i<
ndim ; i++)
317 for (
int i=0 ; i<
ndim ; i++)
327 cerr <<
"Unknown type of basis in Domain_shell_symphi::do_coloc" << endl ;
342 base.
bases_1d[2]->set(0) = COS_EVEN ;
344 base.
bases_1d[1]->set(k) = COS_EVEN ;
346 index.
set(0) = j ; index.
set(1) = k ;
347 base.
bases_1d[0]->set(index) = CHEB ;
361 base.
bases_1d[2]->set(0) = SIN_EVEN ;
363 base.
bases_1d[1]->set(k) = COS_EVEN ;
365 index.
set(0) = j ; index.
set(1) = k ;
366 base.
bases_1d[0]->set(index) = CHEB ;
379 base.
bases_1d[2]->set(0) = SIN_EVEN ;
381 base.
bases_1d[1]->set(k) = SIN_EVEN ;
383 index.
set(0) = j ; index.
set(1) = k ;
384 base.
bases_1d[0]->set(index) = CHEB ;
397 base.
bases_1d[2]->set(0) = COS_EVEN ;
399 base.
bases_1d[1]->set(k) = SIN_ODD ;
401 index.
set(0) = j ; index.
set(1) = k ;
402 base.
bases_1d[0]->set(index) = CHEB ;
413 base.
bases_1d[2]->set(0) = COS_EVEN ;
415 base.
bases_1d[1]->set(k) = SIN_EVEN ;
417 index.
set(0) = j ; index.
set(1) = k ;
418 base.
bases_1d[0]->set(index) = CHEB ;
429 base.
bases_1d[2]->set(0) = SIN_EVEN ;
431 base.
bases_1d[1]->set(k) = SIN_ODD ;
433 index.
set(0) = j ; index.
set(1) = k ;
434 base.
bases_1d[0]->set(index) = CHEB ;
445 base.
bases_1d[2]->set(0) = SIN_EVEN ;
447 base.
bases_1d[1]->set(k) = COS_ODD ;
449 index.
set(0) = j ; index.
set(1) = k ;
450 base.
bases_1d[0]->set(index) = CHEB ;
463 base.
bases_1d[2]->set(0) = SIN_ODD ;
465 base.
bases_1d[1]->set(k) = SIN_ODD ;
467 index.
set(0) = j ; index.
set(1) = k ;
468 base.
bases_1d[0]->set(index) = CHEB ;
481 base.
bases_1d[2]->set(0) = COS_ODD ;
483 base.
bases_1d[1]->set(k) = SIN_ODD ;
485 index.
set(0) = j ; index.
set(1) = k ;
486 base.
bases_1d[0]->set(index) = CHEB ;
500 base.
bases_1d[2]->set(0) = SIN_EVEN ;
502 base.
bases_1d[1]->set(k) = COS_ODD ;
504 index.
set(0) = j ; index.
set(1) = k ;
505 base.
bases_1d[0]->set(index) = CHEB ;
516 base.
bases_1d[2]->set(0) = SIN_EVEN ;
518 base.
bases_1d[1]->set(k) = COS_EVEN ;
520 index.
set(0) = j ; index.
set(1) = k ;
521 base.
bases_1d[0]->set(index) = CHEB ;
532 base.
bases_1d[2]->set(0) = COS_ODD ;
534 base.
bases_1d[1]->set(k) = SIN_EVEN ;
536 index.
set(0) = j ; index.
set(1) = k ;
537 base.
bases_1d[0]->set(index) = CHEB ;
548 base.
bases_1d[2]->set(0) = SIN_ODD ;
550 base.
bases_1d[1]->set(k) = SIN_EVEN ;
552 index.
set(0) = j ; index.
set(1) = k ;
553 base.
bases_1d[0]->set(index) = CHEB ;
564 base.
bases_1d[2]->set(0) = COS_EVEN ;
566 base.
bases_1d[1]->set(k) = COS_EVEN ;
568 index.
set(0) = j ; index.
set(1) = k ;
569 base.
bases_1d[0]->set(index) = CHEB ;
582 base.
bases_1d[2]->set(0) = COS_ODD ;
584 base.
bases_1d[1]->set(k) = SIN_ODD ;
586 index.
set(0) = j ; index.
set(1) = k ;
587 base.
bases_1d[0]->set(index) = CHEB ;
600 base.
bases_1d[2]->set(0) = SIN_ODD ;
602 base.
bases_1d[1]->set(k) = SIN_ODD ;
604 index.
set(0) = j ; index.
set(1) = k ;
605 base.
bases_1d[0]->set(index) = CHEB ;
619 base.
bases_1d[2]->set(0) = COS_EVEN ;
621 base.
bases_1d[1]->set(k) = COS_ODD ;
623 index.
set(0) = j ; index.
set(1) = k ;
624 base.
bases_1d[0]->set(index) = CHEB ;
638 base.
bases_1d[2]->set(0) = COS_EVEN ;
640 base.
bases_1d[1]->set(k) = COS_EVEN ;
642 index.
set(0) = j ; index.
set(1) = k ;
643 base.
bases_1d[0]->set(index) = LEG ;
657 base.
bases_1d[2]->set(0) = SIN_EVEN ;
659 base.
bases_1d[1]->set(k) = COS_EVEN ;
661 index.
set(0) = j ; index.
set(1) = k ;
662 base.
bases_1d[0]->set(index) = LEG ;
675 base.
bases_1d[2]->set(0) = SIN_EVEN ;
677 base.
bases_1d[1]->set(k) = SIN_EVEN ;
679 index.
set(0) = j ; index.
set(1) = k ;
680 base.
bases_1d[0]->set(index) = LEG ;
693 base.
bases_1d[2]->set(0) = COS_EVEN ;
695 base.
bases_1d[1]->set(k) = SIN_ODD ;
697 index.
set(0) = j ; index.
set(1) = k ;
698 base.
bases_1d[0]->set(index) = LEG ;
711 base.
bases_1d[2]->set(0) = SIN_ODD ;
713 base.
bases_1d[1]->set(k) = SIN_ODD ;
715 index.
set(0) = j ; index.
set(1) = k ;
716 base.
bases_1d[0]->set(index) = LEG ;
729 base.
bases_1d[2]->set(0) = COS_ODD ;
731 base.
bases_1d[1]->set(k) = SIN_ODD ;
733 index.
set(0) = j ; index.
set(1) = k ;
734 base.
bases_1d[0]->set(index) = LEG ;
748 base.
bases_1d[2]->set(0) = SIN_EVEN ;
750 base.
bases_1d[1]->set(k) = COS_ODD ;
752 index.
set(0) = j ; index.
set(1) = k ;
753 base.
bases_1d[0]->set(index) = LEG ;
766 base.
bases_1d[2]->set(0) = COS_EVEN ;
768 base.
bases_1d[1]->set(k) = COS_EVEN ;
770 index.
set(0) = j ; index.
set(1) = k ;
771 base.
bases_1d[0]->set(index) = LEG ;
784 base.
bases_1d[2]->set(0) = COS_ODD ;
786 base.
bases_1d[1]->set(k) = SIN_ODD ;
788 index.
set(0) = j ; index.
set(1) = k ;
789 base.
bases_1d[0]->set(index) = LEG ;
802 base.
bases_1d[2]->set(0) = SIN_ODD ;
804 base.
bases_1d[1]->set(k) = SIN_ODD ;
806 index.
set(0) = j ; index.
set(1) = k ;
807 base.
bases_1d[0]->set(index) = LEG ;
821 base.
bases_1d[2]->set(0) = COS_EVEN ;
823 base.
bases_1d[1]->set(k) = COS_ODD ;
825 index.
set(0) = j ; index.
set(1) = k ;
826 base.
bases_1d[0]->set(index) = LEG ;
859 if (!a.
def) res_def =
false;
860 if (!b.
def) res_def =
false;
869 int basea((*a.
bases_1d[2])(index_2));
870 int baseb((*b.
bases_1d[2])(index_2));
872 }
while(index_2.
inc());
880 int basea((*a.
bases_1d[1])(index_1));
881 int baseb((*b.
bases_1d[1])(index_1));
883 }
while(index_1.
inc());
889 switch ((*a.
bases_1d[0])(index_0)) {
891 switch ((*b.
bases_1d[0])(index_0)) {
893 res.
bases_1d[0]->set(index_0) = CHEB ;
901 switch ((*b.
bases_1d[0])(index_0)) {
903 res.
bases_1d[0]->set(index_0) = LEG ;
915 while (index_0.
inc()) ;
919 for (
int dim=0 ; dim<a.
ndim ; dim++)
931 if ( basea == COS_EVEN and baseb == COS_EVEN) res = COS_EVEN;
932 if ((basea == COS_EVEN and baseb == COS_ODD) or (basea == COS_ODD and baseb == COS_EVEN)) res = COS_ODD;
933 if ((basea == COS_EVEN and baseb == SIN_EVEN) or (basea == SIN_EVEN and baseb == COS_EVEN)) res = SIN_EVEN;
934 if ((basea == COS_EVEN and baseb == SIN_ODD) or (basea == SIN_ODD and baseb == COS_EVEN)) res = SIN_ODD;
935 if ( basea == COS_ODD and baseb == COS_ODD) res = COS_EVEN;
936 if ((basea == COS_ODD and baseb == SIN_EVEN) or (basea == SIN_EVEN and baseb == COS_ODD)) res = SIN_ODD;
937 if ((basea == COS_ODD and baseb == SIN_ODD) or (basea == SIN_ODD and baseb == COS_ODD)) res = SIN_EVEN;
938 if ( basea == SIN_EVEN and baseb == SIN_EVEN) res = COS_EVEN;
939 if ((basea == SIN_EVEN and baseb == SIN_ODD) or (basea == SIN_ODD and baseb == SIN_EVEN)) res = COS_ODD;
940 if ( basea == SIN_ODD and baseb == SIN_ODD) res = COS_EVEN;
947 if (strcmp(p,
"R ")==0)
949 if (strcmp(p,
"T ")==0)
951 if (strcmp(p,
"P ")==0)
958 if (bound != OUTER_BC)
960 cerr <<
"Domain_shell_symphi::integ only defined for r=rmax yet..." << endl ;
964 int baset((*so.base.bases_1d[1])(0));
965 if (baset != COS_EVEN)
971 Index pos(get_nbr_coefs());
973 for (
int j(0) ; j < nbr_coefs(1) ; ++j)
976 double fact_tet(2.0/(1.0 - 4.0*j*j));
978 for (
int i(0) ; i < nbr_coefs(0) ; ++i)
981 res += fact_tet*(*so.cf)(pos);
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 shell and a symmetry with respect to the plane and an quadrant symmetry wrt .
double alpha
Relates the numerical to the physical radii.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
double beta
Relates the numerical to the physical radii.
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_z_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the 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.
virtual ~Domain_shell_symphi()
Destructor.
int mult_base_angle_int(int basea, int baseb) const
Multiply two angular basis.
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual void set_cheb_base_p_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
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...
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...
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 double integ(const Val_domain &so, int bound) const
Surface integral on a given boundary.
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
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 void set_cheb_base_tp_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a 2-tensor.
virtual void set_legendre_base_y_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
void set_legendre_base_forr(Base_spectral &so) const
Sets the base to the standard one for Legendre polynomials for a field like the radius .
virtual void set_cheb_base_xz_cart(Base_spectral &) const
Gives the base using Chebyshev 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.
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...
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual void do_coloc()
Computes the colocation points.
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
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_legendre_base_x_cart(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
Point center
Absolute coordinates of the center.
virtual void set_cheb_base_yz_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void set_cheb_base_rp_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a 2-tensor.
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void set_cheb_base_x_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
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 void set_cheb_base_xy_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
Domain_shell_symphi(int num, int ttype, double r_int, double r_ext, const Point &cr, const Dim_array &nbr)
Standard constructor :
virtual void set_cheb_base_y_cart(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void save(FILE *) const
Saving function.
virtual void set_legendre_base_p_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void set_cheb_base_rt_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a 2-tensor.
void set_cheb_base_forr(Base_spectral &so) const
Sets the base to the standard one for Chebyshev polynomials for a field like the radius .
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual void do_absol() const
Computes the absolute coordinates.
virtual void do_radius() const
Computes the generalized radius.
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 Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
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.
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.
Val_domain const & get_radius() const
Returns the generalized radius.
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.
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 .
Val_domain mult_sin_theta() const
Multiplication by .
Val_domain mult_cos_phi() const
Multiplication by .
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Val_domain div_sin_theta() const
Division by .
Val_domain mult_cos_theta() const
Multiplication by .
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 allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
const Base_spectral & get_base() const
Returns the basis of decomposition.