20 #include "headcpp.hpp"
23 #include "array_math.hpp"
24 #include "val_domain.hpp"
27 void coef_1d (
int, Array<double>&) ;
28 void coef_i_1d (
int, Array<double>&) ;
29 int der_1d (
int, Array<double>&) ;
33 Domain(num, ttype, nbr), alpha(r),center(cr) {
44 fread_be (&
alpha,
sizeof(
double), 1, fd) ;
49 Domain_polar_nucleus::~Domain_polar_nucleus() {}
54 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
55 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
57 fwrite_be (&
alpha,
sizeof(
double), 1, fd) ;
61 o <<
"Polar nucleus" << endl ;
62 o <<
"Rmax = " <<
alpha << endl ;
63 o <<
"Center = " <<
center << endl ;
78 cerr <<
"Unknown boundary case in Domain_polar_nucleus::der_normal" << endl ;
86 for (
int i=0 ; i<2 ; i++)
87 assert (
coloc[i] != 0x0) ;
88 for (
int i=0 ; i<2 ; i++)
89 assert (
absol[i] == 0x0) ;
90 for (
int i=0 ; i<2 ; i++) {
92 absol[i]->allocate_conf() ;
100 while (index.
inc()) ;
107 for (
int i=0 ; i<2 ; i++)
108 assert (
coloc[i] != 0x0) ;
115 while (index.
inc()) ;
120 for (
int i=0 ; i<2 ; i++)
121 assert (
coloc[i] != 0x0) ;
122 for (
int i=0 ; i<2 ; i++)
123 assert (
cart[i] == 0x0) ;
124 for (
int i=0 ; i<2 ; i++) {
126 cart[i]->allocate_conf() ;
134 while (index.
inc()) ;
140 for (
int i=0 ; i<2 ; i++)
141 assert (
coloc[i] != 0x0) ;
142 for (
int i=0 ; i<2 ; i++)
144 for (
int i=0 ; i<2 ; i++) {
153 while (index.
inc()) ;
162 double rho_loc = xx(1) -
center(1) ;
163 double z_loc = xx(2) -
center(2) ;
164 double air_loc = sqrt (rho_loc*rho_loc + z_loc*z_loc) ;
166 bool res = (air_loc <=
alpha+prec) ?
true :
false ;
173 assert (
is_in(abs)) ;
176 double rho_loc = fabs(abs(1) -
center(1)) ;
177 double z_loc = abs(2) -
center(2) ;
178 double air = sqrt(rho_loc*rho_loc+z_loc*z_loc) ;
183 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
186 num.
set(2) = atan(rho_loc/z_loc) ;
190 num.
set(2) = M_PI + num(2) ;
195 double coloc_leg_parity(
int,
int) ;
202 for (
int i=0 ; i<
ndim ; i++)
212 for (
int i=0 ; i<
ndim ; i++)
220 cerr <<
"Unknown type of basis in Domain_polar_nucleus::do_coloc" << endl ;
256 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
258 l = (m%2==0) ? 2*j : 2*j+1 ;
259 base.
bases_1d[0]->set(j) = (l%2==0) ? CHEB_EVEN : CHEB_ODD ;
274 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
276 l = (m%2==0) ? 2*j+1 : 2*j ;
277 base.
bases_1d[0]->set(j) = (l%2==1) ? CHEB_ODD : CHEB_EVEN ;
292 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_EVEN : SIN_ODD ;
294 l = (m%2==0) ? 2*j : 2*j+1 ;
295 base.
bases_1d[0]->set(j) = (l%2==0) ? LEG_EVEN : LEG_ODD ;
310 base.
bases_1d[1]->set(0) = (m%2==0) ? COS_ODD : SIN_EVEN ;
312 l = (m%2==0) ? 2*j+1 : 2*j ;
313 base.
bases_1d[0]->set(j) = (l%2==1) ? LEG_ODD : LEG_EVEN ;
335 bool res_def = true ;
351 res.
bases_1d[1]->set(0) = COS_EVEN ;
357 res.
bases_1d[1]->set(0) = SIN_EVEN ;
373 res.
bases_1d[1]->set(0) = COS_EVEN ;
379 res.
bases_1d[1]->set(0) = SIN_EVEN ;
389 res.
bases_1d[1]->set(0) = SIN_EVEN ;
395 res.
bases_1d[1]->set(0) = COS_EVEN ;
411 res.
bases_1d[1]->set(0) = SIN_EVEN ;
417 res.
bases_1d[1]->set(0) = COS_EVEN ;
433 switch ((*a.
bases_1d[0])(index_0)) {
435 switch ((*b.
bases_1d[0])(index_0)) {
437 res.
bases_1d[0]->set(index_0) = CHEB_EVEN ;
440 res.
bases_1d[0]->set(index_0) = CHEB_ODD ;
448 switch ((*b.
bases_1d[0])(index_0)) {
450 res.
bases_1d[0]->set(index_0) = CHEB_ODD ;
453 res.
bases_1d[0]->set(index_0) = CHEB_EVEN ;
461 switch ((*b.
bases_1d[0])(index_0)) {
463 res.
bases_1d[0]->set(index_0) = LEG_EVEN ;
466 res.
bases_1d[0]->set(index_0) = LEG_ODD ;
474 switch ((*b.
bases_1d[0])(index_0)) {
476 res.
bases_1d[0]->set(index_0) = LEG_ODD ;
479 res.
bases_1d[0]->set(index_0) = LEG_EVEN ;
491 while (index_0.
inc()) ;
494 for (
int dim=0 ; dim<a.
ndim ; dim++)
505 if (strcmp(p,
"R ")==0)
507 if (strcmp(p,
"T ")==0)
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 2-dimensional spherical domain containing the origin and a symetry with respect to the pl...
virtual Val_domain der_normal(const Val_domain &, int) const
Normal derivative with respect to a given surface.
Domain_polar_nucleus(int num, int ttype, double radius, const Point &cr, const Dim_array &nbr)
Standard constructor :
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 set_cheb_base(Base_spectral &) const
Gives the standard base for Chebyshev polynomials.
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_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_legendre_base_with_m(Base_spectral &, int m) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
virtual int give_place_var(char *) const
Translates a name of a coordinate into its corresponding numerical name.
virtual Val_domain div_x(const Val_domain &) const
Division by .
Point center
Absolute coordinates of the center.
virtual void do_coloc()
Computes the colocation points.
virtual void set_cheb_base_with_m(Base_spectral &, int m) const
Gives the standard base using Chebyshev polynomials.
virtual void set_anti_legendre_base(Base_spectral &) const
Gives the base using Legendre polynomials, for functions antisymetric with respect to .
virtual void set_legendre_base(Base_spectral &) const
Gives the standard base for Legendre polynomials.
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual void set_anti_cheb_base(Base_spectral &) const
Gives the base using Chebyshev polynomials, for functions antisymetric with respect to .
virtual const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void save(FILE *) const
Saving function.
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.
double alpha
Relates the numerical to the physical radii.
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.
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.
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_theta() const
Multiplication by .
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Val_domain mult_cos_theta() const
Multiplication by .
Val_domain der_var(int i) const
Computes the derivative with respect to a numerical coordinate.
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.