stormfaciesgrid.hpp
Go to the documentation of this file.
1// $Id: stormfaciesgrid.hpp 883 2011-09-26 09:17:05Z perroe $
2
3// Copyright (c) 2011, Norwegian Computing Center
4// All rights reserved.
5// Redistribution and use in source and binary forms, with or without modification,
6// are permitted provided that the following conditions are met:
7// • Redistributions of source code must retain the above copyright notice, this
8// list of conditions and the following disclaimer.
9// • Redistributions in binary form must reproduce the above copyright notice, this list of
10// conditions and the following disclaimer in the documentation and/or other materials
11// provided with the distribution.
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
13// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
15// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
17// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
20// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21
22#ifndef NRLIB_STORMFACIESGRID_HPP
23#define NRLIB_STORMFACIESGRID_HPP
24
25#include "../volume/volume.hpp"
26#include "../grid/grid.hpp"
27#include "../iotools/fileio.hpp"
28
29namespace NRLib {
30 class StormFaciesGrid : public Grid<int>, public Volume {
31 public:
33
34 explicit StormFaciesGrid(const std::string& filename,Endianess file_format = END_BIG_ENDIAN);
35 explicit StormFaciesGrid(size_t nx = 0, size_t ny = 0, size_t nz = 0);
36 explicit StormFaciesGrid(const Volume &vol, size_t nx, size_t ny, size_t nz);
37
38 void SetMissingCode(int missing_code)
39 { missing_code_ = missing_code; }
40 int GetMissingCode() const
41 { return missing_code_; }
42 bool IsMissing(int val) const
43 { return val == missing_code_; }
44
46 { file_format_ = format; }
47
49 { return file_format_; }
50
51 void SetModelFileName(const std::string& filename)
52 { model_file_name_ = filename; }
53
55 { return model_file_name_; }
56
57 void SetZoneNumber(int zone_number)
58 { zone_number_ = zone_number; }
59
60 int GetZoneNumber() const
61 { return zone_number_; }
62
63 int GetFaciesCode(int body_index) const;
64 int GetFaciesFromCell(size_t cell_index) const;
65 int GetFaciesFromCell(size_t i, size_t j, size_t k) const
66 { return GetFaciesFromCell(GetIndex(i, j, k)); }
67 const std::string& GetFaciesName(int facies_code) const;
68 void SetBodyFacies(const std::vector<int>& body_facies);
69 void SetFaciesNames(const std::vector<std::string>& facies_names);
70
71 void WriteToFile(const std::string& filename, Endianess file_format = END_BIG_ENDIAN) const;
72 void ReadFromFile(const std::string& filename, bool commonPath = true, Endianess file_format = END_BIG_ENDIAN);
73
76 void CheckConsistency() const;
77
78 double GetDX() const {return GetLX()/GetNI();}
79 double GetDY() const {return GetLY()/GetNJ();}
80 size_t FindIndex(double x, double y, double z) const;
81 void FindIndex( double x, double y, double z, size_t& i_out, size_t& j_out, size_t& k_out) const;
82 void FindCenterOfCell(size_t i, size_t j, size_t k,
83 double& x, double& y, double& z) const;
84
85 private:
86 double RecalculateLZ();
87
88 FileFormat file_format_;
89 int missing_code_;
90 int zone_number_;
91 std::string model_file_name_;
92 std::vector<std::string> facies_names_;
93 std::vector<int> body_facies_;
94 };
95}
96
97#endif // NRLIB_STORMFACIESGRID_HPP
char const int const cJSON_bool format
Definition: cJSON.h:161
const char *const string
Definition: cJSON.h:170
Definition: grid.hpp:35
size_t GetNJ() const
Definition: grid.hpp:70
size_t GetIndex(size_t i, size_t j, size_t k) const
Definition: grid.hpp:231
size_t GetNI() const
Definition: grid.hpp:69
Definition: stormfaciesgrid.hpp:30
std::string GetModelFileName() const
Definition: stormfaciesgrid.hpp:54
StormFaciesGrid(const Volume &vol, size_t nx, size_t ny, size_t nz)
size_t FindIndex(double x, double y, double z) const
StormFaciesGrid(const std::string &filename, Endianess file_format=END_BIG_ENDIAN)
void FindCenterOfCell(size_t i, size_t j, size_t k, double &x, double &y, double &z) const
void CheckConsistency() const
Check that all the facies value for each body, and the body values inside the grid are inside the giv...
double GetDY() const
Definition: stormfaciesgrid.hpp:79
void WriteToFile(const std::string &filename, Endianess file_format=END_BIG_ENDIAN) const
int GetZoneNumber() const
Definition: stormfaciesgrid.hpp:60
FileFormat GetFormat() const
Definition: stormfaciesgrid.hpp:48
void SetFaciesNames(const std::vector< std::string > &facies_names)
bool IsMissing(int val) const
Definition: stormfaciesgrid.hpp:42
FileFormat
Definition: stormfaciesgrid.hpp:32
@ STORM_BINARY
Definition: stormfaciesgrid.hpp:32
@ STORM_ASCII
Definition: stormfaciesgrid.hpp:32
int GetFaciesCode(int body_index) const
double GetDX() const
Definition: stormfaciesgrid.hpp:78
void ReadFromFile(const std::string &filename, bool commonPath=true, Endianess file_format=END_BIG_ENDIAN)
int GetMissingCode() const
Definition: stormfaciesgrid.hpp:40
void SetModelFileName(const std::string &filename)
Definition: stormfaciesgrid.hpp:51
void SetMissingCode(int missing_code)
Definition: stormfaciesgrid.hpp:38
void SetFormat(FileFormat format)
Definition: stormfaciesgrid.hpp:45
int GetFaciesFromCell(size_t cell_index) const
void SetZoneNumber(int zone_number)
Definition: stormfaciesgrid.hpp:57
void FindIndex(double x, double y, double z, size_t &i_out, size_t &j_out, size_t &k_out) const
void SetBodyFacies(const std::vector< int > &body_facies)
int GetFaciesFromCell(size_t i, size_t j, size_t k) const
Definition: stormfaciesgrid.hpp:65
StormFaciesGrid(size_t nx=0, size_t ny=0, size_t nz=0)
const std::string & GetFaciesName(int facies_code) const
Definition: volume.hpp:31
double GetLX() const
Definition: volume.hpp:62
double GetLY() const
Definition: volume.hpp:63
Definition: exception.hpp:31
Endianess
Definition: fileio.hpp:36
@ END_BIG_ENDIAN
Definition: fileio.hpp:37
x y * z
Definition: exprtk.hpp:9663
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x(y+z)