30 char Grille_val_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Valencia/grille_val.C,v 1.7 2014/10/13 08:53:48 j_novak Exp $" ;
66 #include "grille_val.h"
67 #include "utilitaires.h"
80 double step = (rmax - rmin)/
double(n-1) ;
82 for (
int i=0; i<n; i++) resu->
set(i) = rmin + i*step ;
88 int n1,
const int fantome):
89 dim(n1), nfantome(fantome), type_t(SYM), type_p(SYM)
92 zrmin =
new double(izrmin) ;
93 zrmax =
new double(izrmax) ;
94 double amin = ((n1 +
nfantome - 0.5)*izrmin -
96 double amax = ((n1 +
nfantome - 0.5)*izrmax -
106 int n2,
const int n1,
const int itype_t,
108 dim(n2,n1), nfantome(fantome), type_t(itype_t), type_p(SYM)
111 zrmin =
new double(izrmin) ;
112 zrmax =
new double(izrmax) ;
113 double amin = ((n1 +
nfantome - 0.5)*izrmin -
115 double amax = ((n1 +
nfantome - 0.5)*izrmax -
126 const int n3,
const int n2,
const int n1,
127 const int itype_t,
const int itype_p,
128 const int fantome ): dim(n3,n2,n1), nfantome(fantome),
129 type_t(itype_t), type_p(itype_p)
131 zrmin =
new double(izrmin) ;
132 zrmax =
new double(izrmax) ;
133 double amin = ((n1 +
nfantome - 0.5)*izrmin -
135 double amax = ((n1 +
nfantome - 0.5)*izrmax -
146 nfantome(titi.nfantome), type_t(titi.type_t), type_p(titi.type_p)
148 assert(titi.
zr != 0x0) ;
149 assert(titi.
zri != 0x0) ;
150 assert(titi.
zrmin != 0x0) ;
151 assert(titi.
zrmax != 0x0) ;
167 fread_be(&amin,
sizeof(
double), 1, fd) ;
168 fread_be(&amax,
sizeof(
double), 1, fd) ;
169 zrmin =
new double(amin) ;
170 zrmax =
new double(amax) ;
185 assert(
zrmin != 0x0) ;
186 assert(
zrmax != 0x0) ;
206 assert(titi.
zr != 0x0) ;
207 assert(titi.
zri != 0x0) ;
208 assert(titi.
zrmin != 0x0) ;
209 assert(titi.
zrmax != 0x0) ;
212 zr->
t[i] = titi.
zr->
t[i] ;
252 o.setf(ios::showpoint);
253 o <<
"*** Grille_val " << ndim <<
"D" <<
" size: " ;
254 for (
int i = 0; i<ndim-1; i++) {
256 if (ndim-i == 3) o <<
" x " ;
257 if (ndim-i == 2) o <<
" x " ;
260 o << nfant <<
" hidden cells on each side " << endl ;
282 xmin(0x0), xmax(0x0),
283 ymin(0x0), ymax(0x0),
290 double izmin,
const double izmax,
const int nx,
291 const int nz,
const int itype_t,
const int fantome)
292 :
Grille_val(izmin, izmax, nx, nz, itype_t, fantome),
293 ymin(0x0), ymax(0x0),
296 assert ( (
type_t!=SYM) || (izmin >=
double(0)) ) ;
298 xmin =
new double(ixmin) ;
299 xmax =
new double(ixmax) ;
300 double amin = ((nx +
nfantome - 0.5)*ixmin -
302 double amax = ((nx +
nfantome - 0.5)*ixmax -
313 const double ixmin,
const double ixmax,
const
314 double izmin,
const double izmax,
const int ny,
315 const int nx,
const int nz,
const int itype_t,
316 const int itype_p,
const int fantome)
317 :
Grille_val(izmin, izmax, ny, nx, nz, itype_t, itype_p, fantome)
319 assert ( (
type_t!=SYM) || (izmin >=
double(0)) ) ;
320 assert ( (
type_p!=SYM) || (iymin >=
double(0)) ) ;
322 xmin =
new double(ixmin) ;
323 xmax =
new double(ixmax) ;
324 double amin = ((nx +
nfantome - 0.5)*ixmin -
326 double amax = ((nx +
nfantome - 0.5)*ixmax -
333 ymin =
new double(iymin) ;
334 ymax =
new double(iymax) ;
335 amin = ((ny +
nfantome - 0.5)*iymin -
337 amax = ((ny +
nfantome - 0.5)*iymax -
350 if (titi.
x != 0x0)
x =
new Tbl(*titi.
x) ;
351 if (titi.
xi != 0x0)
xi =
new Tbl(*titi.
xi) ;
354 if (titi.
y != 0x0)
y =
new Tbl(*titi.
y) ;
355 if (titi.
yi != 0x0)
yi =
new Tbl(*titi.
yi) ;
367 fread_be(&amin,
sizeof(
double), 1, fd) ;
368 fread_be(&amax,
sizeof(
double), 1, fd) ;
369 xmin =
new double(amin) ;
370 xmax =
new double(amax) ;
375 fread_be(&amin,
sizeof(
double), 1, fd) ;
376 fread_be(&amax,
sizeof(
double), 1, fd) ;
377 ymin =
new double(amin) ;
378 ymax =
new double(amax) ;
392 if (
x != 0x0)
delete x ;
393 if (
xi != 0x0)
delete xi ;
396 if (
y != 0x0)
delete y ;
397 if (
yi != 0x0)
delete yi ;
412 if (titi.
x != 0x0) *
x = *titi.
x ;
413 if (titi.
xi != 0x0) *
xi = *titi.
xi ;
416 if (titi.
y != 0x0) *
y = *titi.
y ;
417 if (titi.
yi != 0x0) *
yi = *titi.
yi ;
455 o <<
"*** Cartesian grid ***" << endl ;
460 o <<
"Z nodes: " << endl ;
461 for (
int i=0; i<
dim.
dim[0]; i++) {
470 o <<
"X nodes: " << endl ;
471 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
476 o <<
"Z nodes: " << endl ;
478 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
486 o <<
"Y nodes: " << endl ;
487 for (
int k=0 ; k<
dim.
dim[2] ; k++) {
492 o <<
"X nodes: " << endl ;
493 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
498 o <<
"Z nodes: " << endl ;
500 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
508 cout <<
"operator>> Gval_cart : unexpected dimension !" << endl ;
509 cout <<
" ndim = " << ndim << endl ;
537 assert(irmin>=
double(0)) ;
542 const int nr,
const int itype_t,
const int fantome)
543 :
Grille_val(irmin, irmax, nt, nr, itype_t, fantome),
546 assert (irmin >=
double(0)) ;
549 double tetmax = (
type_t == SYM ? M_PI_2 : M_PI) ;
550 double amin = ((nt +
nfantome - 0.5)*tetmin -
552 double amax = ((nt +
nfantome - 0.5)*tetmax -
563 const int nt,
const int nr,
const int itype_t,
564 const int itype_p,
const int fantome)
565 :
Grille_val(irmin, irmax, np, nt, nr, itype_t, itype_p, fantome)
567 assert (irmin >=
double(0)) ;
571 double tetmax = (
type_t == SYM ? M_PI_2 : M_PI) ;
572 double amin = ((nt +
nfantome - 0.5)*tetmin -
574 double amax = ((nt +
nfantome - 0.5)*tetmax -
582 double phimax = (
type_p == SYM ? M_PI : 2.*M_PI) ;
583 amin = ((np +
nfantome - 0.5)*phimin -
585 amax = ((np +
nfantome - 0.5)*phimax -
596 :
Grille_val(titi), tet(0x0), teti(0x0), phi(0x0), phii(0x0)
626 if (
tet != 0x0)
delete tet ;
628 if (
phi != 0x0)
delete phi ;
642 if (titi.
tet != 0x0) {
649 if (
tet != 0x0)
delete tet ;
652 if (titi.
teti != 0x0) {
662 if (titi.
phi != 0x0) {
669 if (
phi != 0x0)
delete phi ;
672 if (titi.
phii != 0x0) {
714 o <<
"*** Spherical grid ***" << endl ;
719 o <<
"R nodes: " << endl ;
720 for (
int i=0; i<
dim.
dim[0]; i++) {
729 o <<
"THETA nodes: " << endl ;
730 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
735 o <<
"R nodes: " << endl ;
737 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
745 o <<
"PHI nodes: " << endl ;
746 for (
int k=0 ; k<
dim.
dim[2] ; k++) {
751 o <<
"THETA nodes: " << endl ;
752 for (
int j=0 ; j<
dim.
dim[1] ; j++) {
757 o <<
"R nodes: " << endl ;
759 for (
int i=0 ; i<
dim.
dim[0] ; i++) {
767 cout <<
"operator>> Gval_spher : unexpected dimension !" << endl ;
768 cout <<
" ndim = " << ndim << endl ;
void sauve(FILE *) const
Save in a file.
int * dim
Array of dimensions (size: ndim).
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
Base class for Godunov-type grids.
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 <<).
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
Class for cartesian Godunov-type grids.
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.
Class for spherical Godunov-type grids.
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 sauve(FILE *) const
Save in a file.
double & set(int i)
Read/write of a particular element (index i) (1D case)
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
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.