20 #include "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "fourD_periodic.hpp"
24 #include "array_math.hpp"
25 #include "term_eq.hpp"
26 #include "val_domain.hpp"
27 #include "term_eq.hpp"
29 #include "tensor_impl.hpp"
32 void coef_1d (
int, Array<double>&) ;
33 void coef_i_1d (
int, Array<double>&) ;
34 int der_1d (
int, Array<double>&) ;
38 Domain(num, ttype, nbr), alpha((rout-rin)/2.), beta ((rout+rin)/2.), ome(oome), type_time(TO_PI) {
45 cerr <<
"Unknown case for type_time" << endl ;
53 type_time(so.type_time), maxt(so.maxt) {
57 fread_be (&
alpha,
sizeof(
double), 1, fd) ;
58 fread_be (&
beta,
sizeof(
double), 1, fd) ;
59 fread_be (&
ome,
sizeof(
double), 1, fd) ;
60 fread_be (&
type_time,
sizeof(
int), 1, fd) ;
66 cerr <<
"Unknown case for type_time" << endl ;
73 Domain_fourD_periodic_shell::~Domain_fourD_periodic_shell() {
79 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
80 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
81 fwrite_be (&
alpha,
sizeof(
double), 1, fd) ;
82 fwrite_be (&
beta,
sizeof(
double), 1, fd) ;
83 fwrite_be (&
ome,
sizeof(
double), 1, fd) ;
84 fwrite_be (&
type_time,
sizeof(
int), 1, fd) ;
88 o <<
"fourD_periodic shell" << endl ;
89 o <<
"time goes to " <<
maxt << endl ;
91 o <<
"Omega = " <<
ome << endl ;
99 for (
int i=0 ; i<4 ; i++)
100 assert (
coloc[i] != 0x0) ;
101 for (
int i=0 ; i<4 ; i++)
102 assert (
absol[i] == 0x0) ;
103 for (
int i=0 ; i<4 ; i++) {
105 absol[i]->allocate_conf() ;
111 sin((*
coloc[1])(index(1)))*cos((*
coloc[2])(index(2))) ;
113 sin((*
coloc[1])(index(1)))*sin((*
coloc[2])(index(2))) ;
117 while (index.
inc()) ;
122 for (
int i=0 ; i<4 ; i++)
123 assert (
coloc[i] != 0x0) ;
124 for (
int i=0 ; i<4 ; i++)
125 assert (
cart[i] == 0x0) ;
126 for (
int i=0 ; i<4 ; i++) {
128 cart[i]->allocate_conf() ;
134 sin((*
coloc[1])(index(1)))*cos((*
coloc[2])(index(2))) ;
136 sin((*
coloc[1])(index(1)))*sin((*
coloc[2])(index(2))) ;
140 while (index.
inc()) ;
153 cerr <<
"Unknown type of basis in Domain_fourD_periodic_shell::do_cart" << endl ;
162 for (
int i=0 ; i<4 ; i++)
163 assert (
coloc[i] != 0x0) ;
170 while (index.
inc()) ;
179 double x_loc = xx(1) ;
180 double y_loc = xx(2) ;
181 double z_loc = xx(3) ;
182 double air_loc = sqrt (x_loc*x_loc + y_loc*y_loc + z_loc*z_loc) ;
184 bool res = ((air_loc <=
alpha+
beta+prec) && (air_loc >=
beta-
alpha-prec)) ?
true :
false ;
186 if ((xx(4)<0-prec) || (xx(4)>
maxt/
ome + prec))
195 assert (
is_in(abs)) ;
198 double x_loc = abs(1) ;
199 double y_loc = abs(2) ;
200 double z_loc = abs(3) ;
201 double air = sqrt(x_loc*x_loc+y_loc*y_loc+z_loc*z_loc) ;
203 double rho = sqrt(x_loc*x_loc+y_loc*y_loc) ;
207 num.
set(2) = (z_loc>=0) ? 0 : M_PI ;
211 num.
set(2) = atan(rho/z_loc) ;
212 num.
set(3) = atan2 (y_loc, x_loc) ;
216 num.
set(2) = M_PI + num(2) ;
223 double coloc_leg(
int,
int) ;
231 for (
int i=0 ; i<
ndim ; i++)
246 for (
int i=0 ; i<
ndim ; i++)
248 for (
int i=0 ; i<
ndim ; i++)
260 cerr <<
"Unknown type of basis in Domain_fourD_periodic_shell::do_coloc" << endl ;
280 base.
bases_1d[1]->set(k, l) = SIN_ODD ;
283 base.
bases_1d[0]->set(j, k, l) = CHEB ;
303 base.
bases_1d[1]->set(k, l) = SIN_ODD ;
306 base.
bases_1d[0]->set(j, k, l) = CHEB ;
325 base.
bases_1d[1]->set(k, l) = SIN_ODD ;
328 base.
bases_1d[0]->set(j, k, l) = LEG ;
348 base.
bases_1d[1]->set(k, l) = SIN_ODD ;
351 base.
bases_1d[0]->set(j, k, l) = LEG ;
388 bool res_def = true ;
433 switch ((*a.
bases_1d[2])(index_2)) {
435 switch ((*b.
bases_1d[2])(index_2)) {
437 res.
bases_1d[2]->set(index_2) = COSSIN ;
448 }
while (index_2.
inc()) ;
454 switch ((*a.
bases_1d[1])(index_1)) {
456 switch ((*b.
bases_1d[1])(index_1)) {
458 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
461 res.
bases_1d[1]->set(index_1) = COS_ODD ;
464 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
467 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
475 switch ((*b.
bases_1d[1])(index_1)) {
477 res.
bases_1d[1]->set(index_1) = COS_ODD ;
480 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
483 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
486 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
494 switch ((*b.
bases_1d[1])(index_1)) {
496 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
499 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
502 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
505 res.
bases_1d[1]->set(index_1) = COS_ODD ;
513 switch ((*b.
bases_1d[1])(index_1)) {
515 res.
bases_1d[1]->set(index_1) = SIN_ODD ;
518 res.
bases_1d[1]->set(index_1) = SIN_EVEN ;
521 res.
bases_1d[1]->set(index_1) = COS_ODD ;
524 res.
bases_1d[1]->set(index_1) = COS_EVEN ;
536 while (index_1.
inc()) ;
543 switch ((*a.
bases_1d[0])(index_0)) {
545 switch ((*b.
bases_1d[0])(index_0)) {
547 res.
bases_1d[0]->set(index_0) = CHEB ;
555 switch ((*b.
bases_1d[0])(index_0)) {
557 res.
bases_1d[0]->set(index_0) = LEG ;
569 while (index_0.
inc()) ;
574 for (
int dim=0 ; dim<a.
ndim ; dim++)
626 pcf.
set(3) = pso(2) ;
628 pcf.
set(1) = pso(1) ;
629 pcf.
set(0) = pso(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.
int & set(int i)
Read/write of the size of a given dimension.
void save(FILE *) const
Save function.
Class for a spherical shell.
virtual Base_spectral mult(const Base_spectral &, const Base_spectral &) const
Method for the multiplication of two Base_spectral.
double beta
Relates the numerical radius to the physical one.
Domain_fourD_periodic_shell(int num, int ttype, double rin, double rout, double ome, const Dim_array &nbr)
Standard constructor :
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
virtual const Point absol_to_num(const Point &) const
Computes the numerical coordinates from the physical ones.
virtual void do_cart() const
Computes the Cartesian coordinates.
virtual ostream & print(ostream &o) const
Delegate function to virtualize the << operator.
virtual void do_absol() const
Computes the absolute coordinates.
virtual void save(FILE *) const
Saving function.
virtual void set_legendre_base_y_cart(Base_spectral &so) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual void do_coloc()
Computes the colocation points.
virtual void do_radius() const
Computes the generalized radius.
virtual void set_cheb_base_y_cart(Base_spectral &so) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual Val_domain mult_cos_phi(const Val_domain &) const
Multiplication by .
virtual Val_domain mult_cos_theta(const Val_domain &) const
Multiplication by .
double maxt
Upper bound of which is or .
int type_time
Gives the type of time periodicity.
double alpha
Relates the numerical radius to the physical one.
virtual Val_domain mult_sin_phi(const Val_domain &) const
Multiplication by .
virtual void set_cheb_base_x_cart(Base_spectral &so) const
Gives the base using Chebyshev polynomials, for the component of a vector.
virtual void set_legendre_base_x_cart(Base_spectral &so) const
Gives the base using Legendre polynomials, for the component of a vector.
virtual Val_domain mult_sin_theta(const Val_domain &) const
Multiplication by .
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...
Val_domain translate(const Val_domain &so) const
Generates a Val_domain, from another one assumed to be on a Polar_periodic_nucleus.
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.
Dim_array const & get_nbr_coefs() const
Returns the number of coefficients.
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.
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.
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_phi() const
Multiplication by .
double & set_coef(const Index &pos)
Read/write the value of the field in the coefficient space.
Val_domain mult_sin_theta() const
Multiplication by .
Val_domain mult_cos_phi() const
Multiplication by .
double & set(const Index &pos)
Read/write the value of the field in the configuration space.
Val_domain div_sin_theta() const
Division by .
Val_domain mult_cos_theta() const
Multiplication by .
void coef() const
Computes the coefficients.
Base_spectral & set_base()
Sets the basis of decomposition.
Array< double > get_coef() const
void annule_hard()
Sets all the arrays to zero (the logical state is NOT set to zero).
void allocate_conf()
Allocates the values in the configuration space and destroys the values in the coefficients space.
const Domain * get_domain() const
const Base_spectral & get_base() const
Returns the basis of decomposition.