30char TBL_VAL_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Valencia/tbl_val.C,v 1.7 2014/10/13 08:53:48 j_novak Exp $" ;
73#include "utilitaires.h"
84 dim(g->get_dim_tbl()), gval(g), t(0x0), tzri(0x0), txti(0x0), typi(0x0) {}
91 if (tc.
etat == ETATQCQ) {
92 t = new double[get_taille()] ;
93 for (int i=0 ; i<get_taille() ; i++) {
122Tbl_val::Tbl_val(
const Grille_val* g, FILE* fd) : dim(g->get_dim_tbl()),
128 if (
etat == ETATQCQ) {
167 assert(tx.
get_etat() != ETATNONDEF) ;
178 for (
int i=0 ; i<n ; i++) {
189 cout <<
"Erreur bizarre !" << endl ;
198 if ( a ==
double(0) ) {
204 for (
int i=0 ; i<n ; i++) {
227 for (
int i=0 ; i<n ; i++) {
252 if (
etat == ETATQCQ) {
268 if (
t != 0x0)
delete []
t ;
281 if (
etat == ETATZERO) return ;
288 if (
etat == ETATNONDEF) return ;
295 if (
etat == ETATQCQ) return ;
298 assert( (
etat == ETATZERO) || (
etat == ETATNONDEF) ) ;
337 assert (t_in != 0x0) ;
351ostream& operator<<(ostream& o,
const Tbl_val& t) {
355 o.setf(ios::showpoint);
356 o <<
"*** Tbl_val " << ndim <<
"D" <<
" size: " ;
357 for (
int i = 0; i<ndim-1; i++) {
359 if (ndim-i == 3) o <<
"(Y)" <<
" x " ;
360 if (ndim-i == 2) o <<
"(X)" <<
" x " ;
363 " hidden cells on each side = " << t.
get_taille() << endl ;
366 o <<
"Identically ZERO" << endl ;
371 o <<
"UNDEFINED STATE" << endl ;
375 assert(t.
etat == ETATQCQ) ;
379 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
388 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
389 o <<
" J_x " << j <<
" : " << endl ;
390 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
391 o <<
" " << t(j, i) ;
400 for (
int k=0 ; k<t.
get_dim(2) ; k++) {
401 o <<
" K_y = " << k <<
" : " << endl ;
402 for (
int j=0 ; j<t.
get_dim(1) ; j++) {
403 o <<
" J_x = " << j <<
" : " ;
404 for (
int i=0 ; i<t.
get_dim(0) ; i++) {
405 o <<
" " << t(k, j, i) ;
416 cout <<
"operator<< Tbl_val : unexpected dimension !" << endl ;
417 cout <<
" ndim = " << ndim << endl ;
432 ost <<
"*** Tbl_val " << ndim <<
"D" <<
" size: " ;
433 for (
int i = 0; i<ndim-1; i++) {
437 " hidden cells on each side = " <<
get_taille() << endl ;
442 if (
etat == ETATNONDEF) {
443 ost <<
" state: UNDEFINED" << endl ;
447 if (
etat == ETATZERO) {
448 ost <<
" state: ZERO" << endl ;
455 ost <<
" threshold for display : " << seuil << endl ;
456 ost.precision(precis);
457 ost.setf(ios::showpoint);
459 ost <<
" Values on the nodes, without hidden cells:" << endl ;
463 for (
int i=0; i<
get_dim(0); i++) {
464 ost <<
" " << setw(precis) << (*this)(i) ;
472 for (
int j=0; j<
get_dim(1); j++) {
473 ost <<
" #j=" << j <<
" : " ;
474 for (
int i=0; i<
get_dim(0); i++){
475 ost <<
" " << setw(precis) << (*this)(j, i) ;
484 for (
int k=0; k<
get_dim(2); k++) {
485 for (
int j=0; j<
get_dim(1); j++){
487 for (
int i=0; i<
get_dim(0); i++){
488 if ( fabs( (*
this)(k, j, i) ) >= seuil )
491 if (test_imp == 1 ) {
492 ost <<
" #k=" << k <<
",j=" << j <<
" : " ;
493 for (
int i=0; i<
get_dim(0); i++){
494 ost <<
" " << setw(precis) << (*this)(k, j, i) ;
505 cout <<
"Tbl_val:affiche_seuil : unexpected dimension !" << endl ;
506 cout <<
" get_ndim() = " <<
get_ndim() << endl ;
515 ost.unsetf(ios::showpoint);
Base class for Godunov-type grids.
int get_fantome() const
Returns the number of hidden cells.
Finite-difference array intended to store field values.
void del_t()
Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATN...
const Grille_val * gval
The Grille_val (cartesian or spherical) on which the array is defined.
void operator=(const Tbl_val &)
Assignment to another Tbl_val.
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
int get_ndim() const
Gives the number of dimensions (ie dim->ndim )
int get_dim(int i) const
Gives the i th dimension (ie dim->dim[i] , without hidden cells)
int get_taille_i(int i) const
Gives the size of the interface arrays (including the hidden cells)
double * txti
The array at x (or ) interfaces.
double * tzri
The array at z (or r) interfaces.
void annule_hard()
Sets the Tbl_val to zero in a hard way.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double * t
The array of double at the nodes.
int get_etat() const
Gives the logical state.
Tbl_val(const Grille_val *)
Constructor from a 3D grid.
void sauve(FILE *) const
Save in a file.
double * typi
The array at y (or ) interfaces.
int get_taille() const
Gives the size of the node array (including the hidden cells)
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
void affiche_seuil(ostream &ostr, int precision=4, double threshold=1.e-7) const
Prints only the values greater than a given threshold.
int etat
logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
void append_array(double *t_in)
Appends an array of doubles as the main array t of this (DO NOT use it, unless you REALLY know how it...
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.