4 #include "MCRCProgramming.hpp"
5 #include "flumy_export.hpp"
7 #include "GridParams.hpp"
34 const MP_real & ox = 0.,
35 const MP_real & oy = 0.,
36 const MP_real & val = MP_UNKNOWN_REAL_VALUE);
44 const MP_real & ox = 0.,
45 const MP_real & oy = 0.,
46 const MP_real & oz = 0.,
47 const MP_real & val = MP_UNKNOWN_REAL_VALUE);
49 GridReal(
const std::vector<std::vector<MP_real> >& values);
65 virtual void reset(
const MP_real & dx,
69 const MP_real & ox = 0.,
70 const MP_real & oy = 0.,
71 const MP_real & val = MP_UNKNOWN_REAL_VALUE);
73 virtual void reset(
const MP_real & dx,
79 const MP_real & ox = 0.,
80 const MP_real & oy = 0.,
81 const MP_real & oz = 0.,
82 const MP_real & val = MP_UNKNOWN_REAL_VALUE);
84 virtual bool check(MP_real & val,
bool correct =
true)
const;
86 virtual void fill(
const MP_real & val);
88 virtual void fill_2D(
const std::vector<std::vector<MP_real> >& values);
91 virtual void fill_yxz(
const MP_int size,
const MP_real values[]);
94 virtual void fill_zyx(
const MP_int size,
const MP_real values[]);
97 virtual bool get_at(MP_int& size, MP_real values[])
const;
99 virtual bool set_at(
const MP_int & ix,
const MP_int & iy,
const MP_real & val);
101 virtual bool set_at(
const MP_int & ix,
const MP_int & iy,
const MP_int & iz,
const MP_real & val);
103 virtual bool get_at(
const MP_int & ix,
const MP_int & iy, MP_real & val)
const;
105 virtual bool get_at(
const MP_int & ix,
const MP_int & iy, RealList & val)
const;
107 virtual bool get_at(
const MP_int & ix,
const MP_int & iy,
const MP_int & iz, MP_real & val)
const;
109 virtual bool write(
const MP_string& filename,
110 const iTracer* tracer,
111 const GridFileFormat& format = GFF_F2G,
112 const MP_string& order = MP_DEFAULT_CELLS_ORDER)
const;
114 virtual bool read(
const MP_string& filename);
126 MP_real
get_min(MP_int& ix, MP_int& iy)
const;
128 MP_real
get_max(MP_int& ix, MP_int& iy)
const;
136 void set_name(
const MP_string& name) { _name = name; }
138 const MP_string&
get_name()
const {
return _name; }
156 const MP_string& order2,
157 const MP_string& order3);
189 const iTracer* tracer)
const;
192 const iTracer* tracer)
const;
195 const iTracer* tracer,
196 const MP_string& order = MP_DEFAULT_CELLS_ORDER)
const;
199 const iTracer* tracer,
200 const MP_string& order = MP_DEFAULT_CELLS_ORDER)
const;
Base class for 3D grid description.
Definition: GridParams.hpp:28
GridParams & operator=(const GridParams &)
Operator =.
Base class for 2D grid containing real values.
Definition: GridReal.hpp:23
virtual bool read(const MP_string &filename)
Read all grid node values from a file (see User Manual Appendices for the file format)
static bool is_order_valid(const MP_string &order, MP_string &order1, MP_string &order2, MP_string &order3)
Test if an "order string" is valid.
MP_real get_max() const
Retrieve the grid max value (keep get_ prefix to avoid conflict under windows)
Definition: GridReal.hpp:124
MP_real _min
Minimum and maximum of values.
Definition: GridReal.hpp:169
MP_int _iymin
Definition: GridReal.hpp:173
MP_real get_mean() const
Retrieve the grid mean value.
bool write_f2g(const MP_string &filename, const iTracer *tracer, const MP_string &order=MP_DEFAULT_CELLS_ORDER) const
Write all grid node values into an F2F formated file (see User Manual Appendices for the file format)
virtual bool get_at(const MP_int &ix, const MP_int &iy, RealList &val) const
Retrieve the vertical values list at node [ix,iy].
GridReal(const GridReal &grid)
Copy constructor.
const MP_real & get_undef_value() const
Return the undefined value of the variable.
Definition: GridReal.hpp:146
MP_real get_min() const
Retrieve the grid min value (keep get_ prefix to avoid conflict under windows)
Definition: GridReal.hpp:122
MP_string _last_error
Last error message.
Definition: GridReal.hpp:185
GridReal(const GridParams &grid, const MP_real &val)
Constructor build from another grid (use it to copy another grid parameters). This is not a copy con...
std::vector< GridReal * > _aux
Auxiliary grids (at any time, these grids must contain the same number of elements)
Definition: GridReal.hpp:177
virtual bool get_at(const MP_int &ix, const MP_int &iy, const MP_int &iz, MP_real &val) const
Retrieve the node[ix,iy,iz] value of the grid.
MP_string _undef_string
Undefined string.
Definition: GridReal.hpp:181
virtual void fill_2D(const std::vector< std::vector< MP_real > > &values)
Fill the grid with a 2D array of real values.
bool read_cps3(const MP_string &filename)
Read all grid node values from a CPS-3 formated file (see User Manual Appendices for the file format)
static GridFileFormat get_format(const MP_string &filename)
Return the Ascii format of the given grid file.
const MP_string & get_undef_string() const
Return the undefined string of the variable.
Definition: GridReal.hpp:142
MP_int _ixmax
Definition: GridReal.hpp:174
const MP_string & last_error() const
Return last error message.
Definition: GridReal.hpp:163
virtual void fill(const MP_real &val)
Fill the grid with a new real value.
GridReal(const MP_real &dx, const MP_real &dy, const MP_real &dz, const MP_int &nx, const MP_int &ny, const MP_int &nz, const MP_real &ox=0., const MP_real &oy=0., const MP_real &oz=0., const MP_real &val=MP_UNKNOWN_REAL_VALUE)
Constructor from 3D grid parameters which fills the grid with the given real value.
GridReal(const std::vector< std::vector< MP_real > > &values)
Constructor from a 2D array of real values.
MP_real get_max(MP_int &ix, MP_int &iy) const
Retrieve the grid max value and location (keep get_ prefix to avoid conflict under windows)
virtual void fill_zyx(const MP_int size, const MP_real values[])
Fill the grid with an array of real values (sorted by y then x then z, e.g. iz increasing first) Size...
GridReal(const MP_real &dx, const MP_real &dy, const MP_int &nx, const MP_int &ny, const MP_real &ox=0., const MP_real &oy=0., const MP_real &val=MP_UNKNOWN_REAL_VALUE)
Constructor from 2D grid parameters which fills the grid with the given real value.
void set_name(const MP_string &name)
Set the variable name.
Definition: GridReal.hpp:136
MP_real _max
Definition: GridReal.hpp:170
bool read_f2g(const MP_string &filename)
Read all grid node values from an F2G formatted file (see User Manual Appendices for the file format)
MP_int _iymax
Definition: GridReal.hpp:175
bool write_ascii(const MP_string &filename, const iTracer *tracer) const
Write all grid node values into an ASCII formated file (see User Manual Appendices for the file forma...
void set_undef_string(const MP_string &undef)
Set the undefined string.
Definition: GridReal.hpp:140
bool write_gslib(const MP_string &filename, const iTracer *tracer) const
Write all grid node values into an GSLIB formated file (see User Manual Appendices for the file forma...
virtual bool write(const MP_string &filename, const iTracer *tracer, const GridFileFormat &format=GFF_F2G, const MP_string &order=MP_DEFAULT_CELLS_ORDER) const
Write all grid node values into a file (see User Manual Appendices for the file format)
RealList _values
Grid values (at any time, vector size should be _nx*_ny*_nz)
Definition: GridReal.hpp:167
virtual bool set_at(const MP_int &ix, const MP_int &iy, const MP_int &iz, const MP_real &val)
Set the node[ix,iy,iz] value of the grid.
RealList get_values_zyx() const
Retrieve all grid values in a vector (order is +Z +Y +X, e.g. iz increasing first) (same as getRegula...
const MP_string & get_name() const
Return the name of the variable.
Definition: GridReal.hpp:138
void set_undef_value(const MP_real undef)
Set the undefined value.
Definition: GridReal.hpp:144
MP_string _name
Variable name.
Definition: GridReal.hpp:179
static bool is_order_valid(const MP_string &order)
Test if an "order string" is valid.
bool add_variable(GridReal *aux)
Add an auxiliary variable to the current grid (grids must be compatible)
virtual bool get_at(MP_int &size, MP_real values[]) const
Retrieve the grid values in an array of real values (sorted by z then x then y) Size of the array mus...
virtual void reset(const GridParams &grid) override
Reset 2D grid parameters to new values.
MP_real _undef_value
Undefined value.
Definition: GridReal.hpp:183
virtual void reset(const MP_real &dx, const MP_real &dy, const MP_real &dz, const MP_int &nx, const MP_int &ny, const MP_int &nz, const MP_real &ox=0., const MP_real &oy=0., const MP_real &oz=0., const MP_real &val=MP_UNKNOWN_REAL_VALUE)
Reset 3D grid parameters to new values and fill the grid with a new real value.
bool write_values(std::ofstream &os, const iTracer *tracer, const MP_string &order=MP_DEFAULT_CELLS_ORDER) const
Write values in the given output stream and in the given order.
virtual bool set_at(const MP_int &ix, const MP_int &iy, const MP_real &val)
Set the node[ix,iy] value of the grid (if grid is 3D, fill all pillar nodes)
bool read_ascii(const MP_string &filename)
Read all grid node values from an ASCII formated file (see User Manual Appendices for the file format...
virtual void reset(const MP_real &dx, const MP_real &dy, const MP_int &nx, const MP_int &ny, const MP_real &ox=0., const MP_real &oy=0., const MP_real &val=MP_UNKNOWN_REAL_VALUE)
Reset 2D grid parameters to new values and fill the grid with a new real value.
GridReal(const GridParams &grid)
Constructor build from another grid (use it to copy another grid parameters). This is not a copy con...
static bool is_order_valid(const MP_string &order1, const MP_string &order2, const MP_string &order3)
Test if an "order string" is valid.
virtual bool check(MP_real &val, bool correct=true) const
Check the input value (and correct it if needed)
GridReal()
Default constructor.
bool read_gslib(const MP_string &filename)
Read all grid node values from a GSLIB formated file (see User Manual Appendices for the file format)
virtual bool get_at(const MP_int &ix, const MP_int &iy, MP_real &val) const
Retrieve the node[ix,iy] value of the grid (if grid is 3D, retrieve first pillar node)
virtual ~GridReal()
Destructor.
Definition: GridReal.hpp:59
MP_real get_min(MP_int &ix, MP_int &iy) const
Retrieve the grid min value and location (keep get_ prefix to avoid conflict under windows)
static MP_string get_format_label(const GridFileFormat &format)
Return the Ascii format label for the given format id.
MP_int _ixmin
Minimum and maximum location.
Definition: GridReal.hpp:172
MP_int get_nb_negative() const
Retrieve the number of negative cells.
virtual void fill_yxz(const MP_int size, const MP_real values[])
Fill the grid with an array of real values (sorted by z then x then y, e.g. iy increasing first) Size...
const RealList & get_values() const
Retrieve all grid values in a vector (order is +X +Y +Z, e.g. ix increasing first)
Definition: GridReal.hpp:116
MP_int get_nb_positive() const
Retrieve the number of positive cells.