20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "adapted.hpp"
24 #include "array_math.hpp"
25 #include "val_domain.hpp"
27 #include "tensor_impl.hpp"
30 void coef_1d (
int, Array<double>&) ;
31 void coef_i_1d (
int, Array<double>&) ;
32 int der_1d (
int, Array<double>&) ;
36 Domain(num, ttype, nbr), sp(sss), outer_radius(rout), center(cr) {
56 Domain(num, ttype, nbr), sp(sss), outer_radius(rout), center(cr) {
75 outer_radius (so.outer_radius), center(so.center) {
110 for (
int i=0 ; i<3 ; i++)
111 assert (
coloc[i] !=
nullptr) ;
112 assert (
radius ==
nullptr) ;
118 while (index.
inc()) ;
157 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
159 int jmin = (k>=4) ? 1 : 0 ;
160 for (
int j=jmin ; j<jmax ; j++)
189 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
191 int jmin = (k>=4) ? 1 : 0 ;
192 for (
int j=jmin ; j<jmax ; j++) {
198 auxi.
cf->
set(pos_cf) = 1 ;
199 if ((jmin==1) && (mm%2==0)) {
202 auxi.
cf->
set(pos_cf) = -1 ;
204 if ((jmin==1) && (mm%2==1)) {
207 auxi.
cf->
set(pos_cf) = -(2*j+1) ;
229 *new_inner_radius.
cf = 0 ;
237 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
239 int jmin = (k>=4) ? 1 : 0 ;
240 for (
int j=jmin ; j<jmax ; j++) {
242 new_inner_radius.
cf->
set(pos_cf) -= xx(pos) ;
243 if ((jmin==1) && (mm%2==0)) {
246 new_inner_radius.
cf->
set(pos_cf) += xx(pos) ;
248 if ((jmin==1) && (mm%2==1)) {
251 new_inner_radius.
cf->
set(pos_cf) += (2*j+1)*xx(pos) ;
264 for (
int l=0 ; l<
ndim ; l++) {
266 if (
cart[l] !=
nullptr)
delete cart[l] ;
281 for (
int l=0 ; l<
ndim ; l++) {
283 if (
cart[l] !=
nullptr)
delete cart[l] ;
329 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
331 int jmin = (k>=4) ? 1 : 0 ;
332 for (
int j=jmin ; j<jmax ; j++) {
334 auxi.
cf->
set(pos_cf) = xx(pos) ;
336 if ((jmin==1) && (mm%2==0)) {
339 auxi.
cf->
set(pos_cf) = -xx(pos) ;
341 if ((jmin==1) && (mm%2==1)) {
344 auxi.
cf->
set(pos_cf) = -(2*j+1)*xx(pos) ;
376 while (index.
inc()) ;
392 while (index.
inc()) ;
436 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
437 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
445 o <<
"Adapted shell on the inside boundary" << endl ;
446 o <<
"Center = " <<
center << endl ;
449 o <<
"Inner radius " << endl ;
458 cerr <<
"Domain_shell_inner_adapted::der_normal not implemeted" << endl ;
464 for (
int i=0 ; i<3 ; i++)
465 assert (
coloc[i] !=
nullptr) ;
466 for (
int i=0 ; i<3 ; i++)
467 assert (
absol[i] ==
nullptr) ;
468 for (
int i=0 ; i<3 ; i++) {
470 absol[i]->allocate_conf() ;
475 double rr = (
outer_radius - (*inner_radius)(index))/2. * ((*
coloc[0])(index(0))) +
477 absol[0]->set(index) = rr *
479 absol[1]->set(index) = rr *
483 while (index.
inc()) ;
484 absol[0]->std_base() ;
485 absol[1]->std_base() ;
486 absol[2]->std_anti_base() ;
491 for (
int i=0 ; i<3 ; i++)
492 assert (
coloc[i] !=
nullptr) ;
493 for (
int i=0 ; i<3 ; i++)
494 assert (
cart[i] ==
nullptr) ;
495 for (
int i=0 ; i<3 ; i++) {
497 cart[i]->allocate_conf() ;
501 double rr = (
outer_radius - (*inner_radius)(index))/2. * ((*
coloc[0])(index(0))) +
503 cart[0]->set(index) = rr *
505 cart[1]->set(index) = rr *
509 while (index.
inc()) ;
510 cart[0]->std_base() ;
511 cart[1]->std_base() ;
512 cart[2]->std_anti_base() ;
518 for (
int i=0 ; i<3 ; i++)
519 assert (
coloc[i] !=
nullptr) ;
520 for (
int i=0 ; i<3 ; i++)
522 for (
int i=0 ; i<3 ; i++) {
532 while (index.
inc()) ;
544 bool res = ((num(1)>-1-prec) && (num(1)<1+prec)) ? true : false ;
553 double x_loc = abs(1) -
center(1) ;
554 double y_loc = abs(2) -
center(2) ;
555 double z_loc = abs(3) -
center(3) ;
556 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
557 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
561 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
565 num.
set(2) = atan(rho/z_loc) ;
566 num.
set(3) = atan2 (y_loc, x_loc) ;
570 num.
set(2) = M_PI + num(2) ;
585 double x_loc = abs(1) -
center(1) ;
586 double y_loc = abs(2) -
center(2) ;
587 double z_loc = abs(3) -
center(3) ;
588 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
592 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
596 num.
set(2) = atan(rho/z_loc) ;
597 num.
set(3) = atan2 (y_loc, x_loc) ;
601 num.
set(2) = M_PI + num(2) ;
612 cerr <<
"Unknown case in Domain_shell_inner_adapted::absol_to_num_bound" << endl ;
618 double coloc_leg(
int,
int) ;
626 for (
int i=0 ; i<
ndim ; i++)
639 for (
int i=0 ; i<
ndim ; i++)
649 cerr <<
"Unknown type of basis in Domain_shell_inner_adapted::do_coloc" << endl ;
670 m = (k%2==0) ? k/2 : (k-1)/2 ;
671 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
673 index.
set(0) = j ; index.
set(1) = k ;
674 base.
bases_1d[0]->set(index) = CHEB ;
702 m = (k%2==0) ? k/2 : (k-1)/2 ;
703 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
705 index.
set(0) = j ; index.
set(1) = k ;
706 base.
bases_1d[0]->set(index) = CHEB ;
725 m = (k%2==0) ? k/2 : (k-1)/2 ;
726 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
728 index.
set(0) = j ; index.
set(1) = k ;
729 base.
bases_1d[0]->set(index) = CHEB ;
748 m = (k%2==0) ? k/2 : (k-1)/2 ;
749 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
751 index.
set(0) = j ; index.
set(1) = k ;
752 base.
bases_1d[0]->set(index) = CHEB ;
771 m = (k%2==0) ? k/2 : (k-1)/2 ;
772 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
774 index.
set(0) = j ; index.
set(1) = k ;
775 base.
bases_1d[0]->set(index) = CHEB ;
794 m = (k%2==0) ? k/2 : (k-1)/2 ;
795 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
797 index.
set(0) = j ; index.
set(1) = k ;
798 base.
bases_1d[0]->set(index) = LEG ;
817 m = (k%2==0) ? k/2 : (k-1)/2 ;
818 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
820 index.
set(0) = j ; index.
set(1) = k ;
821 base.
bases_1d[0]->set(index) = LEG ;
840 m = (k%2==0) ? k/2 : (k-1)/2 ;
841 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
843 index.
set(0) = j ; index.
set(1) = k ;
844 base.
bases_1d[0]->set(index) = LEG ;
863 m = (k%2==0) ? k/2 : (k-1)/2 ;
864 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
866 index.
set(0) = j ; index.
set(1) = k ;
867 base.
bases_1d[0]->set(index) = LEG ;
886 m = (k%2==0) ? k/2 : (k-1)/2 ;
887 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
889 index.
set(0) = j ; index.
set(1) = k ;
890 base.
bases_1d[0]->set(index) = LEG ;
924 bool res_def = true ;
956 switch ((*a.
bases_1d[1])(index_1)) {
958 switch ((*b.
bases_1d[1])(index_1)) {
960 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
963 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
966 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
969 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
977 switch ((*b.
bases_1d[1])(index_1)) {
979 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
982 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
985 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
988 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
996 switch ((*b.
bases_1d[1])(index_1)) {
998 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
1001 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
1004 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
1007 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
1015 switch ((*b.
bases_1d[1])(index_1)) {
1017 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
1020 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
1023 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
1026 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
1038 while (index_1.
inc()) ;
1045 switch ((*a.
bases_1d[0])(index_0)) {
1047 switch ((*b.
bases_1d[0])(index_0)) {
1049 res.
bases_1d[0]->set(index_0) = CHEB ;
1057 switch ((*b.
bases_1d[0])(index_0)) {
1059 res.
bases_1d[0]->set(index_0) = LEG ;
1071 while (index_0.
inc()) ;
1075 for (
int dim=0 ; dim<a.
ndim ; dim++)
1086 if (strcmp(p,
"R ")==0)
1088 if (strcmp(p,
"T ")==0)
1090 if (strcmp(p,
"P ")==0)
1102 double rr = (
outer_radius - cor_inner_radius(pos) - (*inner_radius)(pos)) * (*
coloc[0])(pos(0)) / 2.
1103 + (
outer_radius + cor_inner_radius(pos) + (*inner_radius)(pos)) / 2.;
1104 double theta = (*
coloc[1])(pos(1)) ;
1105 double phi = (*
coloc[2])(pos(2)) ;
1107 MM.
set(1) = rr*sin(theta)*cos(phi) +
center(1);
1108 MM.
set(2) = rr*sin(theta)*sin(phi) +
center(2) ;
reference set(const Index &pos)
Read/write of an element.
Class for storing the basis of decompositions of a field.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
double summation(const Point &num, const Array< double > &tab) const
Computes the spectral summation.
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-like domain, having a symmetry with respect to the plane .
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
virtual ~Domain_shell_inner_adapted()
Destructor.
virtual void affecte_coef(int &, int, bool &) const
The variation of the functions describing the shape of the Domain are affected from the unknowns of t...
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_legendre_base_t_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
virtual const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual void update_mapping(const Val_domain &)
Updates the variables parts of the Domain.
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_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
virtual void set_cheb_base_p_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
virtual void do_coloc()
Computes the colocation points.
virtual void update_variable(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
double outer_radius
The outer radius .
virtual void xx_to_vars_from_adapted(Val_domain &, const Array< double > &, int &) const
Computes the new boundary of a Domain from a set of values.
void set_mapping(const Val_domain &so) const
Affects the inner radius.
virtual void set_cheb_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for the radius.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the inner boundary, in orthonormal spherical c...
void do_normal_cart() const
Computes the normal wrt the inner boundary, in Cartesian coordinates.
virtual void xx_to_ders_from_adapted(const Array< double > &, int &) const
Affects the derivative part of variable a Domain from a set of values.
virtual void set_legendre_base_r_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector.
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
virtual void set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
Val_domain * inner_radius
Pointer on the inner boundary , as a Val_domain.
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the inner boundary, in Cartesian coordinates.
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
Term_eq * inner_radius_term_eq
Pointer on the inner boundary , as a Term_eq.
virtual void set_anti_cheb_base(Base_spectral &) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual void vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
virtual Val_domain mult_sin_phi(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.
virtual void set_legendre_base_p_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
Domain_shell_inner_adapted(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
virtual void update_constante(const Val_domain &, const Scalar &, Scalar &) const
Update the value of a scalar, after the shape of the Domain has been changed by the system.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual void do_cart() const
Computes the Cartesian coordinates.
Point center
Absolute coordinates of the center.
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 save(FILE *) const
Saving function.
virtual void do_radius() const
Computes the generalized radius.
Term_eq * dp_rad_term_eq
Pointer on the Term_eq containing the .
virtual void do_absol() const
Computes the absolute coordinates.
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.
Memory_mapped_array< Val_domain * > cart_surr
Cartesian coordinates divided by the radius.
int num_dom
Number of the current domain (used by the Space)
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.
void set_start()
Sets the position to zero in all dimensions.
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.
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
double val_point(const Point &xxx, int sens=-1) const
Computes the value of the field at a given point, by doing the spectral summation.
The Space class is an ensemble of domains describing the whole space of the computation.
This class is intended to describe the manage objects appearing in the equations.
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
void set_der_t(Tensor)
Sets the tensorial variation (only the values in the pertinent Domain are copied).
void set_der_zero()
Sets the variation of the approriate type to zero.
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
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 save(FILE *) const
Saving on a file.
void set_in_coef()
Destroys the values in the configuration space.
void set_zero()
Sets the Val_domain to zero (logical state to zero and arrays destroyed).
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration 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 .
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
void std_r_base()
Sets the basis for the radius.
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 div_sin_theta() const
Division by .
Val_domain mult_cos_theta() 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.
Base_spectral & set_base()
Sets the basis of decomposition.
Array< double > get_coef() const
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.