20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "adapted_polar.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), inner_radius(rin), center(cr) {
55 Domain(num, ttype, nbr), sp(sss), inner_radius(rin), center(cr) {
73 inner_radius (so.inner_radius), center(so.center) {
105 for (
int i=0 ; i<2 ; i++)
106 assert (
coloc[i] !=
nullptr) ;
107 assert (
radius ==
nullptr) ;
113 while (index.
inc()) ;
118 Domain_polar_shell_outer_adapted::~Domain_polar_shell_outer_adapted() {
176 auxi.
cf->
set(pos_cf) = 1 ;
196 *new_outer_radius.
cf = 0 ;
203 new_outer_radius.
cf->
set(pos_cf) -= xx(pos) ;
213 for (
int l=0 ; l<
ndim ; l++) {
215 if (
cart[l] !=
nullptr)
delete cart[l] ;
230 for (
int l=0 ; l<
ndim ; l++) {
232 if (
cart[l] !=
nullptr)
delete cart[l] ;
277 auxi.
cf->
set(pos_cf) = xx(pos) ;
305 while (index.
inc()) ;
321 while (index.
inc()) ;
355 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
356 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
363 o <<
"Adapted polar shell on the inside boundary" << endl ;
364 o <<
"Center = " <<
center << endl ;
367 o <<
"Outer radius " << endl ;
376 cerr <<
"Domain_polar_shell_outer_adapted::der_normal not implemeted" << endl ;
382 for (
int i=0 ; i<2 ; i++)
383 assert (
coloc[i] !=
nullptr) ;
384 for (
int i=0 ; i<2 ; i++)
385 assert (
absol[i] ==
nullptr) ;
386 for (
int i=0 ; i<2 ; i++) {
388 absol[i]->allocate_conf() ;
393 double rr = ((*outer_radius)(index) -
inner_radius)/2. * ((*
coloc[0])(index(0))) +
395 absol[0]->set(index) = rr *
399 while (index.
inc()) ;
405 for (
int i=0 ; i<2 ; i++)
406 assert (
coloc[i] !=
nullptr) ;
407 for (
int i=0 ; i<2 ; i++)
408 assert (
cart[i] ==
nullptr) ;
409 for (
int i=0 ; i<2 ; i++) {
411 cart[i]->allocate_conf() ;
415 double rr = ((*outer_radius)(index) -
inner_radius)/2. * ((*
coloc[0])(index(0))) +
417 cart[0]->set(index) = rr *
421 while (index.
inc()) ;
428 for (
int i=0 ; i<2 ; i++)
429 assert (
coloc[i] !=
nullptr) ;
430 for (
int i=0 ; i<2 ; i++)
432 for (
int i=0 ; i<2 ; i++) {
441 while (index.
inc()) ;
451 bool res = ((num(1)>-1-prec) && (num(1)<1+prec)) ? true : false ;
460 double rho_loc = fabs(abs(1) -
center(1)) ;
461 double z_loc = abs(2) -
center(2) ;
462 double air = sqrt(rho_loc*rho_loc+z_loc*z_loc) ;
466 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
469 num.
set(2) = atan(rho_loc/z_loc) ;
473 num.
set(2) = M_PI + num(2) ;
485 double coloc_leg(
int,
int) ;
492 for (
int i=0 ; i<
ndim ; i++)
502 for (
int i=0 ; i<
ndim ; i++)
510 cerr <<
"Unknown type of basis in Domain_polar_shell_outer_adapted::do_coloc" << endl ;
544 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
558 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
572 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
586 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
611 der_abs[0] =
new Val_domain (sintdr+costdtsr) ;
624 bool res_def = true ;
639 res.
bases_1d[1]->set(0) = COS_EVEN ;
645 res.
bases_1d[1]->set(0) = SIN_EVEN ;
661 res.
bases_1d[1]->set(0) = COS_EVEN ;
667 res.
bases_1d[1]->set(0) = SIN_EVEN ;
677 res.
bases_1d[1]->set(0) = SIN_EVEN ;
683 res.
bases_1d[1]->set(0) = COS_EVEN ;
699 res.
bases_1d[1]->set(0) = SIN_EVEN ;
705 res.
bases_1d[1]->set(0) = COS_EVEN ;
723 switch ((*a.
bases_1d[0])(index_0)) {
725 switch ((*b.
bases_1d[0])(index_0)) {
727 res.
bases_1d[0]->set(index_0) = CHEB ;
735 switch ((*b.
bases_1d[0])(index_0)) {
737 res.
bases_1d[0]->set(index_0) = LEG ;
749 while (index_0.
inc()) ;
753 for (
int dim=0 ; dim<a.
ndim ; dim++)
771 double rr = ((*outer_radius)(pos)+ cor_outer_radius(pos) -
inner_radius) * (*
coloc[0])(pos(0)) / 2.
773 double theta = (*
coloc[1])(pos(1)) ;
789 if (strcmp(p,
"R ")==0)
791 if (strcmp(p,
"T ")==0)
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.
void save(FILE *) const
Save function.
Class for a spherical-like domain, having a symmetry with respect to the plane .
virtual void vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the outer boundary, in Cartesian coordinates.
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
Point center
Absolute coordinates of the center.
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.
void do_normal_cart() const
Computes the normal wrt the inner boundary, in Cartesian coordinates.
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
virtual void do_coloc()
Computes the colocation points.
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 set_anti_cheb_base(Base_spectral &) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
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 save(FILE *) const
Saving function.
Domain_polar_shell_outer_adapted(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
virtual void update_mapping(const Val_domain &)
Updates the variables parts of the Domain.
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
virtual void set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual void set_anti_legendre_base_with_m(Base_spectral &, int m) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the outer boundary, in orthonormal spherical c...
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_anti_cheb_base_with_m(Base_spectral &, int m) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual void set_legendre_base_with_m(Base_spectral &, int m) const
Gives the stnadard base using Legendre polynomials.
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_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
virtual void do_radius() const
Computes the generalized radius.
virtual void set_cheb_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for 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 int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
virtual void do_absol() const
Computes the absolute coordinates.
Val_domain * outer_radius
Pointer on the outer boundary , as a Val_domain.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
virtual void do_cart() const
Computes the Cartesian coordinates.
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
virtual void set_cheb_base_with_m(Base_spectral &, int m) const
Gives the standard base using Chebyshev polynomials.
void set_mapping(const Val_domain &so) const
Affects the outer radius.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
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 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...
Term_eq * outer_radius_term_eq
Pointer on the outer boundary , as a Term_eq.
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
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...
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 .
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 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.