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):
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,
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),
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 -
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] ;
237 zr->sauve(fd) ;
zri->sauve(fd) ;
252 int ndim =
dim.ndim ;
255 o.setf(ios::showpoint);
256 o <<
"*** Grille_val " << ndim <<
"D" <<
" size: " ;
257 for (
int i = 0; i<ndim-1; i++) {
258 o <<
dim.dim[ndim-1-i] ;
259 if (ndim-i == 3) o <<
" x " ;
260 if (ndim-i == 2) o <<
" x " ;
262 o <<
dim.dim[0] << endl ;
263 o << nfant <<
" hidden cells on each side " << endl ;
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),
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 ;
437 x->sauve(fd) ;
xi->sauve(fd) ;
442 y->sauve(fd) ;
yi->sauve(fd) ;
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 -
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 ;
int type_p
Type of symmetry in :
int nfantome
The number of hidden cells (same on each side).
double * zrmin
Lower boundary for z (or r ) direction.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
friend ostream & operator<<(ostream &, const Grille_val &)
Display.
virtual void sauve(FILE *) const
Save in a file.
Dim_tbl dim
The dimensions of the grid.
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes.
virtual ~Grille_val()
Destructor.
Tbl * fait_grille1D(const double rmin, const double rmax, const int n)
Auxilliary function used to allocate memory and construct 1D grid.
int type_t
Type of symmetry in :
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).
void operator=(const Grille_val &)
Assignment to another Grille_val.
Tbl * zri
Arrays containing the values of coordinate z (or r) on the interfaces.
double * zrmax
Higher boundary for z (or r ) direction.
double * xmax
Higher boundary for x dimension.
double * xmin
Lower boundary for x dimension.
double * ymin
Lower boundary for y dimension.
virtual void sauve(FILE *) const
Save in a file.
double * ymax
Higher boundary for y dimension.
Tbl * y
Arrays containing the values of coordinate y on the nodes.
void operator=(const Gval_cart &)
Assignment to another Gval_cart.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Tbl * xi
Arrays containing the values of coordinate x on the interfaces.
Gval_cart(const double izmin, const double izmax, const int n1, const int fantome=2)
Standard 1D constructor.
virtual ~Gval_cart()
Destructor.
Tbl * x
Arrays containing the values of coordinate x on the nodes.
Tbl * yi
Arrays containing the values of coordinate y on the interfaces.
void operator=(const Gval_spher &)
Assignment to another Gval_spher.
Tbl * phi
Arrays containing the values of coordinate on the nodes.
Tbl * teti
Arrays containing the values of coordinate on the interfaces.
virtual void sauve(FILE *) const
Save in a file.
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Tbl * phii
Arrays containing the values of coordinate on the interfaces.
Gval_spher(const double irmin, const double irmax, const int nr, const int fantome=2)
Standard 1D constructor.
virtual ~Gval_spher()
Destructor.
Tbl * tet
Arrays containing the values of coordinate on the nodes.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double & set(int i)
Read/write of a particular element (index i) (1D case).
double * t
The array of double.
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 fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.