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), outer_radius(rout), center(cr) {
55 Domain(num, ttype, nbr), sp(sss), outer_radius(rout), center(cr) {
73 outer_radius (so.outer_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_inner_adapted::~Domain_polar_shell_inner_adapted() {
175 auxi.
cf->
set(pos_cf) = 1 ;
195 *new_inner_radius.
cf = 0 ;
202 new_inner_radius.
cf->
set(pos_cf) -= xx(pos) ;
212 for (
int l=0 ; l<
ndim ; l++) {
214 if (
cart[l] !=
nullptr)
delete cart[l] ;
229 for (
int l=0 ; l<
ndim ; l++) {
231 if (
cart[l] !=
nullptr)
delete cart[l] ;
276 auxi.
cf->
set(pos_cf) = xx(pos) ;
304 while (index.
inc()) ;
320 while (index.
inc()) ;
354 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
355 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
362 o <<
"Adapted polar shell on the inside boundary" << endl ;
363 o <<
"Center = " <<
center << endl ;
366 o <<
"Inner radius " << endl ;
375 cerr <<
"Domain_polar_shell_inner_adapted::der_normal not implemeted" << endl ;
381 for (
int i=0 ; i<2 ; i++)
382 assert (
coloc[i] !=
nullptr) ;
383 for (
int i=0 ; i<2 ; i++)
384 assert (
absol[i] ==
nullptr) ;
385 for (
int i=0 ; i<2 ; i++) {
387 absol[i]->allocate_conf() ;
392 double rr = (
outer_radius - (*inner_radius)(index))/2. * ((*
coloc[0])(index(0))) +
394 absol[0]->set(index) = rr *
398 while (index.
inc()) ;
404 for (
int i=0 ; i<2 ; i++)
405 assert (
coloc[i] !=
nullptr) ;
406 for (
int i=0 ; i<2 ; i++)
407 assert (
cart[i] ==
nullptr) ;
408 for (
int i=0 ; i<2 ; i++) {
410 cart[i]->allocate_conf() ;
414 double rr = (
outer_radius - (*inner_radius)(index))/2. * ((*
coloc[0])(index(0))) +
416 cart[0]->set(index) = rr *
420 while (index.
inc()) ;
427 for (
int i=0 ; i<2 ; i++)
428 assert (
coloc[i] !=
nullptr) ;
429 for (
int i=0 ; i<2 ; i++)
431 for (
int i=0 ; i<2 ; i++) {
440 while (index.
inc()) ;
450 bool res = ((num(1)>-1-prec) && (num(1)<1+prec)) ? true : false ;
459 double rho_loc = fabs(abs(1) -
center(1)) ;
460 double z_loc = abs(2) -
center(2) ;
461 double air = sqrt(rho_loc*rho_loc+z_loc*z_loc) ;
465 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
468 num.
set(2) = atan(rho_loc/z_loc) ;
472 num.
set(2) = M_PI + num(2) ;
484 double coloc_leg(
int,
int) ;
491 for (
int i=0 ; i<
ndim ; i++)
501 for (
int i=0 ; i<
ndim ; i++)
509 cerr <<
"Unknown type of basis in Domain_polar_shell_inner_adapted::do_coloc" << endl ;
543 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
557 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
571 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
585 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
609 der_abs[0] =
new Val_domain (sintdr+costdtsr) ;
622 bool res_def = true ;
637 res.
bases_1d[1]->set(0) = COS_EVEN ;
643 res.
bases_1d[1]->set(0) = SIN_EVEN ;
659 res.
bases_1d[1]->set(0) = COS_EVEN ;
665 res.
bases_1d[1]->set(0) = SIN_EVEN ;
675 res.
bases_1d[1]->set(0) = SIN_EVEN ;
681 res.
bases_1d[1]->set(0) = COS_EVEN ;
697 res.
bases_1d[1]->set(0) = SIN_EVEN ;
703 res.
bases_1d[1]->set(0) = COS_EVEN ;
721 switch ((*a.
bases_1d[0])(index_0)) {
723 switch ((*b.
bases_1d[0])(index_0)) {
725 res.
bases_1d[0]->set(index_0) = CHEB ;
733 switch ((*b.
bases_1d[0])(index_0)) {
735 res.
bases_1d[0]->set(index_0) = LEG ;
747 while (index_0.
inc()) ;
751 for (
int dim=0 ; dim<a.
ndim ; dim++)
769 double rr = (
outer_radius - cor_inner_radius(pos) - (*inner_radius)(pos)) * (*
coloc[0])(pos(0)) / 2.
770 + (
outer_radius + cor_inner_radius(pos) + (*inner_radius)(pos)) / 2.;
771 double theta = (*
coloc[1])(pos(1)) ;
787 if (strcmp(p,
"R ")==0)
789 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 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.
void set_mapping(const Val_domain &so) const
Affects the inner radius.
virtual void do_cart_surr() const
Computes the Cartesian coordinates over the radius.
virtual const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
Term_eq * der_rad_term_eq
Pointer on the Term_eq containing the .
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 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 set_cheb_base_with_m(Base_spectral &, int m) const
Gives the standard base using Chebyshev polynomials.
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.
Point center
Absolute coordinates of the center.
virtual void update_mapping(const Val_domain &)
Updates the variables parts of the Domain.
double outer_radius
The outer radius .
void del_deriv() override
Destroys the derivated members (like coloc, cart and radius), when changing the type of colocation po...
void do_normal_cart() const
Computes the normal wrt the inner boundary, in Cartesian coordinates.
Val_domain * inner_radius
Pointer on the inner boundary , as a Val_domain.
Term_eq * dt_rad_term_eq
Pointer on the Term_eq containing the .
Term_eq * rad_term_eq
Pointer on the Term_eq containing the radius.
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
Term_eq * inner_radius_term_eq
Pointer on the inner boundary , as a Term_eq.
virtual void vars_to_terms() const
The Term_eq describing the variable shape of the Domain are updated.
virtual void set_legendre_r_base(Base_spectral &) const
Gives the base using odd Legendre polynomials$ for the radius.
virtual void set_legendre_base_with_m(Base_spectral &, int m) const
Gives the stnadard base using Legendre polynomials.
virtual Val_domain der_r(const Val_domain &) const
Compute the radial derivative of a scalar field.
void update() const
Updates all the quantities that depend on the inner radius (like the normal vectors).
const Space & sp
The corresponding Space ; required for updating fields whene the mapping changes.
Term_eq * normal_cart
Pointer on the Term_eq containing the normal vector to the inner boundary, in Cartesian coordinates.
virtual void save(FILE *) const
Saving function.
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 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_anti_cheb_base_with_m(Base_spectral &, int m) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void do_radius() const
Computes the generalized radius.
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual void set_cheb_r_base(Base_spectral &) const
Gives the base using odd Chebyshev polynomials$ for the radius.
virtual void do_absol() const
Computes the absolute coordinates.
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 .
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
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 set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
virtual int nbr_unknowns_from_adapted() const
Gives the number of unknowns coming from the variable shape of the domain.
Domain_polar_shell_inner_adapted(const Space &sp, int num, int ttype, double rin, double rout, const Point &cr, const Dim_array &nbr)
Constructor :
virtual void do_coloc()
Computes the colocation points.
Term_eq * normal_spher
Pointer on the Term_eq containing the normal vector to the inner boundary, in orthonormal spherical c...
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual void set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
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...
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.