20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "adapted.hpp"
24 #include "array_math.hpp"
26 #include "tensor_impl.hpp"
29 void coef_1d (
int, Array<double>&) ;
30 void coef_i_1d (
int, Array<double>&) ;
31 int der_1d (
int, Array<double>&) ;
35 Domain(num, ttype, nbr), sp(sss), inner_radius(rin), center(cr) {
55 Domain(num, ttype, nbr), sp(sss), inner_radius(rin), center(cr) {
74 inner_radius (so.inner_radius), center(so.center) {
109 for (
int i=0 ; i<3 ; i++)
110 assert (
coloc[i] !=
nullptr) ;
111 assert (
radius ==
nullptr) ;
117 while (index.
inc()) ;
122 Domain_shell_outer_adapted::~Domain_shell_outer_adapted() {
155 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
157 int jmin = (k>=4) ? 1 : 0 ;
158 for (
int j=jmin ; j<jmax ; j++)
187 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
189 int jmin = (k>=4) ? 1 : 0 ;
190 for (
int j=jmin ; j<jmax ; j++) {
196 auxi.
cf->
set(pos_cf) = 1 ;
197 if ((jmin==1) && (mm%2==0)) {
200 auxi.
cf->
set(pos_cf) = -1 ;
202 if ((jmin==1) && (mm%2==1)) {
205 auxi.
cf->
set(pos_cf) = -(2*j+1) ;
227 *new_outer_radius.
cf = 0 ;
235 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
237 int jmin = (k>=4) ? 1 : 0 ;
238 for (
int j=jmin ; j<jmax ; j++) {
240 new_outer_radius.
cf->
set(pos_cf) -= xx(pos) ;
241 if ((jmin==1) && (mm%2==0)) {
244 new_outer_radius.
cf->
set(pos_cf) += xx(pos) ;
246 if ((jmin==1) && (mm%2==1)) {
249 new_outer_radius.
cf->
set(pos_cf) += (2*j+1)*xx(pos) ;
262 for (
int l=0 ; l<
ndim ; l++) {
264 if (
cart[l] !=
nullptr)
delete cart[l] ;
279 for (
int l=0 ; l<
ndim ; l++) {
281 if (
cart[l] !=
nullptr)
delete cart[l] ;
314 cout <<
"enter xx_to_ders_from_adapted" << endl ;
328 int mm = (k%2==0) ?
int(k/2) : int ((k-1)/2) ;
330 int jmin = (k>=4) ? 1 : 0 ;
331 for (
int j=jmin ; j<jmax ; j++) {
333 auxi.
cf->
set(pos_cf) = xx(pos) ;
335 if ((jmin==1) && (mm%2==0)) {
338 auxi.
cf->
set(pos_cf) = -xx(pos) ;
340 if ((jmin==1) && (mm%2==1)) {
343 auxi.
cf->
set(pos_cf) = -(2*j+1)*xx(pos) ;
374 while (index.
inc()) ;
390 while (index.
inc()) ;
434 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
435 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
443 o <<
"Adapted shell on the outside boundary" << endl ;
444 o <<
"Center = " <<
center << endl ;
447 o <<
"Outer radius " << endl ;
454 cerr <<
"Domain_shell_outer_adapted::der_normal not implemeted" << endl ;
460 for (
int i=0 ; i<3 ; i++)
461 assert (
coloc[i] !=
nullptr) ;
462 for (
int i=0 ; i<3 ; i++)
463 assert (
absol[i] ==
nullptr) ;
464 for (
int i=0 ; i<3 ; i++) {
466 absol[i]->allocate_conf() ;
473 absol[0]->set(index) = rr *
475 absol[1]->set(index) = rr *
479 while (index.
inc()) ;
485 for (
int i=0 ; i<3 ; i++)
486 assert (
coloc[i] !=
nullptr) ;
487 for (
int i=0 ; i<3 ; i++)
488 assert (
cart[i] ==
nullptr) ;
489 for (
int i=0 ; i<3 ; i++) {
491 cart[i]->allocate_conf() ;
497 cart[0]->set(index) = rr *
499 cart[1]->set(index) = rr *
503 while (index.
inc()) ;
510 for (
int i=0 ; i<3 ; i++)
511 assert (
coloc[i] !=
nullptr) ;
512 for (
int i=0 ; i<3 ; i++)
514 for (
int i=0 ; i<3 ; i++) {
524 while (index.
inc()) ;
534 bool res = ((num(1)>-1-prec) && (num(1)<1+prec)) ? true : false ;
544 double x_loc = abs(1) -
center(1) ;
545 double y_loc = abs(2) -
center(2) ;
546 double z_loc = abs(3) -
center(3) ;
547 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
548 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
552 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
556 num.
set(2) = atan(rho/z_loc) ;
557 num.
set(3) = atan2 (y_loc, x_loc) ;
561 num.
set(2) = M_PI + num(2) ;
573 double coloc_leg(
int,
int) ;
581 for (
int i=0 ; i<
ndim ; i++)
594 for (
int i=0 ; i<
ndim ; i++)
604 cerr <<
"Unknown type of basis in Domain_shell_outer_adapted::do_coloc" << endl ;
625 m = (k%2==0) ? k/2 : (k-1)/2 ;
626 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
628 index.
set(0) = j ; index.
set(1) = k ;
629 base.
bases_1d[0]->set(index) = CHEB ;
657 m = (k%2==0) ? k/2 : (k-1)/2 ;
658 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
660 index.
set(0) = j ; index.
set(1) = k ;
661 base.
bases_1d[0]->set(index) = CHEB ;
680 m = (k%2==0) ? k/2 : (k-1)/2 ;
681 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
683 index.
set(0) = j ; index.
set(1) = k ;
684 base.
bases_1d[0]->set(index) = CHEB ;
703 m = (k%2==0) ? k/2 : (k-1)/2 ;
704 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
706 index.
set(0) = j ; index.
set(1) = k ;
707 base.
bases_1d[0]->set(index) = CHEB ;
726 m = (k%2==0) ? k/2 : (k-1)/2 ;
727 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
729 index.
set(0) = j ; index.
set(1) = k ;
730 base.
bases_1d[0]->set(index) = CHEB ;
749 m = (k%2==0) ? k/2 : (k-1)/2 ;
750 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
752 index.
set(0) = j ; index.
set(1) = k ;
753 base.
bases_1d[0]->set(index) = LEG ;
772 m = (k%2==0) ? k/2 : (k-1)/2 ;
773 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_ODD : SIN_EVEN ;
775 index.
set(0) = j ; index.
set(1) = k ;
776 base.
bases_1d[0]->set(index) = LEG ;
795 m = (k%2==0) ? k/2 : (k-1)/2 ;
796 base.
bases_1d[1]->set(k) = (m%2==0) ? COS_EVEN : SIN_ODD ;
798 index.
set(0) = j ; index.
set(1) = k ;
799 base.
bases_1d[0]->set(index) = LEG ;
818 m = (k%2==0) ? k/2 : (k-1)/2 ;
819 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_EVEN : COS_ODD ;
821 index.
set(0) = j ; index.
set(1) = k ;
822 base.
bases_1d[0]->set(index) = LEG ;
841 m = (k%2==0) ? k/2 : (k-1)/2 ;
842 base.
bases_1d[1]->set(k) = (m%2==0) ? SIN_ODD : COS_EVEN ;
844 index.
set(0) = j ; index.
set(1) = k ;
845 base.
bases_1d[0]->set(index) = LEG ;
880 bool res_def = true ;
912 switch ((*a.
bases_1d[1])(index_1)) {
914 switch ((*b.
bases_1d[1])(index_1)) {
916 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
919 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
922 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
925 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
933 switch ((*b.
bases_1d[1])(index_1)) {
935 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_ODD : SIN_EVEN ;
938 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? COS_EVEN : SIN_ODD ;
941 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
944 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
952 switch ((*b.
bases_1d[1])(index_1)) {
954 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
957 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
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 ;
971 switch ((*b.
bases_1d[1])(index_1)) {
973 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_ODD : COS_EVEN ;
976 res.
bases_1d[1]->set(index_1) = (index_1(0)%4<2) ? SIN_EVEN : COS_ODD ;
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 ;
994 while (index_1.
inc()) ;
1001 switch ((*a.
bases_1d[0])(index_0)) {
1003 switch ((*b.
bases_1d[0])(index_0)) {
1005 res.
bases_1d[0]->set(index_0) = CHEB ;
1013 switch ((*b.
bases_1d[0])(index_0)) {
1015 res.
bases_1d[0]->set(index_0) = LEG ;
1027 while (index_0.
inc()) ;
1031 for (
int dim=0 ; dim<a.
ndim ; dim++)
1042 if (strcmp(p,
"R ")==0)
1044 if (strcmp(p,
"T ")==0)
1046 if (strcmp(p,
"P ")==0)
1059 double rr = ((*outer_radius)(pos) + cor_outer_radius(pos) -
inner_radius) * (*
coloc[0])(pos(0)) / 2.
1061 double theta = (*
coloc[1])(pos(1)) ;
1062 double phi = (*
coloc[2])(pos(2)) ;
1064 MM.
set(1) = rr*sin(theta)*cos(phi) +
center(1);
1065 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 .
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 mult_sin_phi(const Val_domain &) const
Multiplication by .
void set_mapping(const Val_domain &so) const
Affects the outer radius.
Domain_shell_outer_adapted(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
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 void do_absol() const
Computes the absolute coordinates.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
Term_eq * outer_radius_term_eq
Pointer on the outer boundary , as a Term_eq.
virtual void do_coloc()
Computes the colocation points.
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_legendre_base_r_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the radial component of a vector.
Term_eq * dp_rad_term_eq
Pointer on the Term_eq containing the .
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
Point center
Absolute coordinates of the center.
virtual void do_radius() const
Computes the generalized radius.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual void save(FILE *) const
Saving function.
void do_normal_cart() const
Computes the normal wrt the inner boundary, in 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_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for the radius.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
virtual void set_legendre_base_t_spher(Base_spectral &) const
Gives the base using Legendre polynomials, for the component of a vector.
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the outer boundary, in orthonormal spherical c...
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the outer boundary, in Cartesian coordinates.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
virtual void set_cheb_base_t_spher(Base_spectral &) const
Gives the base using Chebyshev polynomials, for the component of a vector.
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
Val_domain * outer_radius
Pointer on the outer boundary , as a Val_domain.
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.
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 Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
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 const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
double inner_radius
The inner radius .
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 ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
virtual void update_mapping(const Val_domain &)
Updates the variables parts of the Domain.
virtual void set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
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 vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
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.
virtual void set_anti_cheb_base(Base_spectral &) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
virtual void do_cart() const
Computes the Cartesian 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.