69 #include "grille_val.h" 70 #include "utilitaires.h" 83 double step = (rmax - rmin)/
double(n-1) ;
85 for (
int i=0; i<n; i++) resu->
set(i) = rmin + i*step ;
91 int n1,
const int fantome):
92 dim(n1), nfantome(fantome), type_t(SYM), type_p(SYM)
95 zrmin =
new double(izrmin) ;
96 zrmax =
new double(izrmax) ;
97 double amin = ((n1 +
nfantome - 0.5)*izrmin -
99 double amax = ((n1 +
nfantome - 0.5)*izrmax -
109 int n2,
const int n1,
const int itype_t,
111 dim(n2,n1), nfantome(fantome), type_t(itype_t), type_p(SYM)
114 zrmin =
new double(izrmin) ;
115 zrmax =
new double(izrmax) ;
116 double amin = ((n1 +
nfantome - 0.5)*izrmin -
118 double amax = ((n1 +
nfantome - 0.5)*izrmax -
129 const int n3,
const int n2,
const int n1,
130 const int itype_t,
const int itype_p,
131 const int fantome ): dim(n3,n2,n1), nfantome(fantome),
132 type_t(itype_t), type_p(itype_p)
134 zrmin =
new double(izrmin) ;
135 zrmax =
new double(izrmax) ;
136 double amin = ((n1 +
nfantome - 0.5)*izrmin -
138 double amax = ((n1 +
nfantome - 0.5)*izrmax -
149 nfantome(titi.nfantome), type_t(titi.type_t), type_p(titi.type_p)
151 assert(titi.
zr != 0x0) ;
152 assert(titi.
zri != 0x0) ;
153 assert(titi.
zrmin != 0x0) ;
154 assert(titi.
zrmax != 0x0) ;
170 fread_be(&amin,
sizeof(
double), 1, fd) ;
171 fread_be(&amax,
sizeof(
double), 1, fd) ;
172 zrmin =
new double(amin) ;
173 zrmax =
new double(amax) ;
188 assert(
zrmin != 0x0) ;
189 assert(
zrmax != 0x0) ;
209 assert(titi.
zr != 0x0) ;
210 assert(titi.
zri != 0x0) ;
211 assert(titi.
zrmin != 0x0) ;
212 assert(titi.
zrmax != 0x0) ;
215 zr->
t[i] = titi.
zr->
t[i] ;
255 o.setf(ios::showpoint);
256 o <<
"*** Grille_val " << ndim <<
"D" <<
" size: " ;
257 for (
int i = 0; i<ndim-1; i++) {
259 if (ndim-i == 3) o <<
" x " ;
260 if (ndim-i == 2) o <<
" x " ;
263 o << nfant <<
" hidden cells on each side " << endl ;
285 xmin(0x0), xmax(0x0),
286 ymin(0x0), ymax(0x0),
293 double izmin,
const double izmax,
const int nx,
294 const int nz,
const int itype_t,
const int fantome)
295 :
Grille_val(izmin, izmax, nx, nz, itype_t, fantome),
296 ymin(0x0), ymax(0x0),
299 assert ( (
type_t!=SYM) || (izmin >=
double(0)) ) ;
301 xmin =
new double(ixmin) ;
302 xmax =
new double(ixmax) ;
303 double amin = ((nx +
nfantome - 0.5)*ixmin -
305 double amax = ((nx +
nfantome - 0.5)*ixmax -
316 const double ixmin,
const double ixmax,
const 317 double izmin,
const double izmax,
const int ny,
318 const int nx,
const int nz,
const int itype_t,
319 const int itype_p,
const int fantome)
320 :
Grille_val(izmin, izmax, ny, nx, nz, itype_t, itype_p, fantome)
322 assert ( (
type_t!=SYM) || (izmin >=
double(0)) ) ;
323 assert ( (
type_p!=SYM) || (iymin >=
double(0)) ) ;
325 xmin =
new double(ixmin) ;
326 xmax =
new double(ixmax) ;
327 double amin = ((nx +
nfantome - 0.5)*ixmin -
329 double amax = ((nx +
nfantome - 0.5)*ixmax -
336 ymin =
new double(iymin) ;
337 ymax =
new double(iymax) ;
338 amin = ((ny +
nfantome - 0.5)*iymin -
340 amax = ((ny +
nfantome - 0.5)*iymax -
353 if (titi.
x != 0x0)
x =
new Tbl(*titi.
x) ;
354 if (titi.
xi != 0x0)
xi =
new Tbl(*titi.
xi) ;
357 if (titi.
y != 0x0)
y =
new Tbl(*titi.
y) ;
358 if (titi.
yi != 0x0)
yi =
new Tbl(*titi.
yi) ;
370 fread_be(&amin,
sizeof(
double), 1, fd) ;
371 fread_be(&amax,
sizeof(
double), 1, fd) ;
372 xmin =
new double(amin) ;
373 xmax =
new double(amax) ;
378 fread_be(&amin,
sizeof(
double), 1, fd) ;
379 fread_be(&amax,
sizeof(
double), 1, fd) ;
380 ymin =
new double(amin) ;
381 ymax =
new double(amax) ;
395 if (
x != 0x0)
delete x ;
396 if (
xi != 0x0)
delete xi ;
399 if (
y != 0x0)
delete y ;
400 if (
yi != 0x0)
delete yi ;
415 if (titi.
x != 0x0) *
x = *titi.
x ;
416 if (titi.
xi != 0x0) *
xi = *titi.
xi ;
419 if (titi.
y != 0x0) *
y = *titi.
y ;
420 if (titi.
yi != 0x0) *
yi = *titi.
yi ;
458 o <<
"*** Cartesian grid ***" << endl ;
463 o <<
"Z nodes: " << endl ;
464 for (
int i=0; i<
dim.
dim[0]; i++) {
473 o <<
"X nodes: " << endl ;
474 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
479 o <<
"Z nodes: " << endl ;
481 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
489 o <<
"Y nodes: " << endl ;
490 for (
int k=0 ; k<
dim.
dim[2] ; k++) {
495 o <<
"X nodes: " << endl ;
496 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
501 o <<
"Z nodes: " << endl ;
503 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
511 cout <<
"operator>> Gval_cart : unexpected dimension !" << endl ;
512 cout <<
" ndim = " << ndim << endl ;
540 assert(irmin>=
double(0)) ;
545 const int nr,
const int itype_t,
const int fantome)
546 :
Grille_val(irmin, irmax, nt, nr, itype_t, fantome),
549 assert (irmin >=
double(0)) ;
552 double tetmax = (
type_t == SYM ? M_PI_2 : M_PI) ;
553 double amin = ((nt +
nfantome - 0.5)*tetmin -
555 double amax = ((nt +
nfantome - 0.5)*tetmax -
566 const int nt,
const int nr,
const int itype_t,
567 const int itype_p,
const int fantome)
568 :
Grille_val(irmin, irmax, np, nt, nr, itype_t, itype_p, fantome)
570 assert (irmin >=
double(0)) ;
574 double tetmax = (
type_t == SYM ? M_PI_2 : M_PI) ;
575 double amin = ((nt +
nfantome - 0.5)*tetmin -
577 double amax = ((nt +
nfantome - 0.5)*tetmax -
585 double phimax = (
type_p == SYM ? M_PI : 2.*M_PI) ;
586 amin = ((np +
nfantome - 0.5)*phimin -
588 amax = ((np +
nfantome - 0.5)*phimax -
599 :
Grille_val(titi), tet(0x0), teti(0x0), phi(0x0), phii(0x0)
629 if (
tet != 0x0)
delete tet ;
631 if (
phi != 0x0)
delete phi ;
645 if (titi.
tet != 0x0) {
652 if (
tet != 0x0)
delete tet ;
655 if (titi.
teti != 0x0) {
665 if (titi.
phi != 0x0) {
672 if (
phi != 0x0)
delete phi ;
675 if (titi.
phii != 0x0) {
717 o <<
"*** Spherical grid ***" << endl ;
722 o <<
"R nodes: " << endl ;
723 for (
int i=0; i<
dim.
dim[0]; i++) {
732 o <<
"THETA nodes: " << endl ;
733 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
738 o <<
"R nodes: " << endl ;
740 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
748 o <<
"PHI nodes: " << endl ;
749 for (
int k=0 ; k<
dim.
dim[2] ; k++) {
754 o <<
"THETA nodes: " << endl ;
755 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
760 o <<
"R nodes: " << endl ;
762 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
770 cout <<
"operator>> Gval_spher : unexpected dimension !" << endl ;
771 cout <<
" ndim = " << ndim << endl ;
virtual void sauve(FILE *) const
Save in a file.
Tbl * xi
Arrays containing the values of coordinate x on the interfaces.
double * xmax
Higher boundary for x dimension.
Tbl * zri
Arrays containing the values of coordinate z (or r) on the interfaces.
void sauve(FILE *) const
Save in a file.
Tbl * y
Arrays containing the values of coordinate y on the nodes.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Tbl * tet
Arrays containing the values of coordinate on the nodes.
double * zrmax
Higher boundary for z (or r ) direction.
Tbl * phii
Arrays containing the values of coordinate on the interfaces.
double * zrmin
Lower boundary for z (or r ) direction.
void operator=(const Gval_spher &)
Assignment to another Gval_spher.
double * ymax
Higher boundary for y dimension.
int type_t
Type of symmetry in :
Base class for Godunov-type grids.
double * xmin
Lower boundary for x dimension.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
virtual void sauve(FILE *) const
Save in a file.
Tbl * yi
Arrays containing the values of coordinate y on the interfaces.
double * ymin
Lower boundary for y dimension.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Tbl * x
Arrays containing the values of coordinate x on the nodes.
Tbl * fait_grille1D(const double rmin, const double rmax, const int n)
Auxilliary function used to allocate memory and construct 1D grid.
Grille_val(const double, const double, const int n1, const int fantome=2)
Standard 1D constructor (the size is to be given without hidden cells)
Tbl * teti
Arrays containing the values of coordinate on the interfaces.
double * t
The array of double.
virtual void sauve(FILE *) const
Save in a file.
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes.
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
virtual ~Gval_spher()
Destructor.
void operator=(const Grille_val &)
Assignment to another Grille_val.
Tbl * phi
Arrays containing the values of coordinate on the nodes.
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
int nfantome
The number of hidden cells (same on each side)
Class for spherical Godunov-type grids.
Class for cartesian Godunov-type grids.
Dim_tbl dim
The dimensions of the grid.
Gval_spher(const double irmin, const double irmax, const int nr, const int fantome=2)
Standard 1D constructor.
Gval_cart(const double izmin, const double izmax, const int n1, const int fantome=2)
Standard 1D constructor.
virtual ~Grille_val()
Destructor.
void sauve(FILE *) const
Save in a file.
void operator=(const Gval_cart &)
Assignment to another Gval_cart.
virtual ~Gval_cart()
Destructor.
int type_p
Type of symmetry in :
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
int * dim
Array of dimensions (size: ndim).