20 #ifndef OPM_PARSER_ECLIPSE_GRID_HPP 21 #define OPM_PARSER_ECLIPSE_GRID_HPP 23 #include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp> 24 #include <opm/input/eclipse/EclipseState/Grid/MapAxes.hpp> 25 #include <opm/input/eclipse/EclipseState/Grid/MinpvMode.hpp> 26 #include <opm/input/eclipse/EclipseState/Grid/NNC.hpp> 27 #include <opm/input/eclipse/EclipseState/Grid/PinchMode.hpp> 37 #include <unordered_set> 75 EclipseGrid(std::size_t nx, std::size_t ny, std::size_t nz,
76 double dx = 1.0,
double dy = 1.0,
double dz = 1.0,
81 const std::vector<double>& coord ,
82 const std::vector<double>& zcorn ,
83 const int * actnum =
nullptr);
91 static bool hasGDFILE(
const Deck& deck);
92 static bool hasRadialKeywords(
const Deck& deck);
93 static bool hasSpiderKeywords(
const Deck& deck);
94 static bool hasCylindricalKeywords(
const Deck& deck);
95 static bool hasCornerPointKeywords(
const Deck&);
96 static bool hasCartesianKeywords(
const Deck&);
97 std::size_t getNumActive( )
const;
98 bool allActive()
const;
100 std::size_t activeIndex(std::size_t i, std::size_t j, std::size_t k)
const;
101 std::size_t activeIndex(std::size_t globalIndex)
const;
103 std::size_t getTotalActiveLGR()
const;
104 std::size_t getActiveIndexLGR(
const std::string& label, std::size_t i, std::size_t j, std::size_t k)
const;
105 std::size_t getActiveIndexLGR(
const std::string& label, std::size_t localIndex)
const;
107 std::size_t activeIndexLGR(
const std::string& label, std::size_t i, std::size_t j, std::size_t k)
const;
108 std::size_t activeIndexLGR(
const std::string& label, std::size_t localIndex)
const;
110 std::size_t getActiveIndex(std::size_t i, std::size_t j, std::size_t k)
const {
111 return activeIndex(i, j, k);
113 const std::vector<std::size_t>& get_print_order_lgr ()
const {
114 return m_print_order_lgr_cells;
117 std::size_t get_lgr_cell_index(
const std::string& lgr_tag)
const 119 const auto& labels = get_all_lgr_labels();
121 if (labels.empty()) {
122 throw std::runtime_error(
"No LGR labels available.");
125 const auto it = std::ranges::find(labels, lgr_tag);
126 if (it == labels.end()) {
127 throw std::runtime_error(
"LGR tag not found: " + lgr_tag);
130 return static_cast<std::size_t
>(std::distance(labels.begin(), it));
133 std::size_t getActiveIndex(std::size_t globalIndex)
const {
134 return activeIndex(globalIndex);
137 std::vector<std::string> get_all_lgr_labels()
const 139 if (this->all_lgr_labels.empty()) {
142 return {this->all_lgr_labels.begin() + 1, this->all_lgr_labels.end()};
146 const std::string& get_lgr_labels_by_number(std::size_t num)
const 148 return all_lgr_labels[num];
151 const std::vector<std::string>& get_all_labels()
const 153 return this->all_lgr_labels;
156 const std::string& get_lgr_tag()
const {
157 return this->lgr_label;
160 std::vector<GridDims> get_lgr_children_gridim()
const;
163 void assertIndexLGR(std::size_t localIndex)
const;
165 void assertLabelLGR(
const std::string& label)
const;
167 void save(
const std::string& filename,
bool formatted,
const std::vector<Opm::NNCdata>& nnc,
const Opm::UnitSystem& units)
const;
176 void init_children_host_cells(
bool logical =
true);
177 void init_children_host_cells_logical(
void);
178 void init_children_host_cells_geometrical(
void);
179 std::array<int,3> getCellSubdivisionRatioLGR(
const std::string& lgr_tag,
180 std::array<int,3> acum = {1,1,1})
const;
182 void perform_refinement();
184 using GridDims::getGlobalIndex;
194 bool isPinchActive()
const;
195 double getPinchThresholdThickness()
const;
196 PinchMode getPinchOption()
const;
197 PinchMode getMultzOption()
const;
198 PinchMode getPinchGapMode()
const;
199 double getPinchMaxEmptyGap()
const;
200 MinpvMode getMinpvMode()
const;
201 const std::vector<double>& getMinpvVector( )
const;
217 std::vector<T> compressedVector(
const std::vector<T>& input_vector)
const {
218 if( input_vector.size() == this->getNumActive() ) {
222 if (input_vector.size() != getCartesianSize())
223 throw std::invalid_argument(
"Input vector must have full size");
226 std::vector<T> compressed_vector( this->getNumActive() );
229 for (std::size_t i = 0; i < this->getNumActive(); ++i)
230 compressed_vector[i] = input_vector[ active_map[i] ];
232 return compressed_vector;
244 std::tuple<std::array<double, 3>,std::array<double, 3>,std::array<double, 3>>
246 std::array<double, 3> getCellCenter(std::size_t i,std::size_t j, std::size_t k)
const;
247 std::array<double, 3> getCellCenter(std::size_t globalIndex)
const;
248 std::array<double, 3> getCornerPos(std::size_t i,std::size_t j, std::size_t k, std::size_t corner_index)
const;
249 const std::vector<double>& activeVolume()
const;
250 double getCellVolume(std::size_t globalIndex)
const;
251 double getCellVolume(std::size_t i , std::size_t j , std::size_t k)
const;
252 double getCellThickness(std::size_t globalIndex)
const;
253 double getCellThickness(std::size_t i , std::size_t j , std::size_t k)
const;
254 std::array<double, 3> getCellDims(std::size_t i,std::size_t j, std::size_t k)
const;
255 std::array<double, 3> getCellDims(std::size_t globalIndex)
const;
256 bool cellActive( std::size_t globalIndex )
const;
257 bool cellActive( std::size_t i , std::size_t j, std::size_t k )
const;
258 bool cellActiveAfterMINPV( std::size_t i , std::size_t j , std::size_t k,
double cell_porv )
const;
259 bool is_lgr()
const {
return lgr_grid;};
260 std::array<double, 3> getCellDimensions(std::size_t i, std::size_t j, std::size_t k)
const {
261 return getCellDims(i, j, k);
265 bool isCellActive(std::size_t i, std::size_t j, std::size_t k)
const {
266 return cellActive(i, j, k);
277 double getCellDepth(std::size_t i,std::size_t j, std::size_t k)
const;
278 double getCellDepth(std::size_t globalIndex)
const;
281 const std::vector<double>& getCOORD()
const;
282 const std::vector<double>& getZCORN()
const;
283 const std::vector<int>& getACTNUM( )
const;
285 const std::optional<MapAxes>& getMapAxes()
const;
287 const std::map<std::size_t, std::array<int,2>>& getAquiferCellTabnums()
const;
296 std::size_t fixupZCORN();
297 std::size_t getZcornFixed() {
return zcorn_fixed; };
302 void resetACTNUM(
const std::vector<int>& actnum);
305 void setMINPVV(
const std::vector<double>& minpvv);
307 void setDEPTH(
const std::vector<double>& depth);
310 static bool hasDVDEPTHZKeywords(
const Deck&);
319 static bool hasEqualDVDEPTHZ(
const Deck&);
320 static bool allEqual(
const std::vector<double> &v);
323 const EclipseGridLGR& getLGRCell(
const std::string& lgr_tag)
const;
324 int getLGR_global_father(std::size_t global_index,
const std::string& lgr_tag)
const;
325 int getLGR_father(std::size_t i, std::size_t j, std::size_t k,
const std::string& lgr_tag)
const;
326 int getLGR_father(std::size_t global_index,
const std::string& lgr_tag)
const;
327 std::array<int,3> getLGR_fatherIJK(std::size_t i, std::size_t j, std::size_t k,
const std::string& lgr_tag)
const;
328 std::vector<EclipseGridLGR> lgr_children_cells;
336 virtual void set_lgr_refinement(
const std::string& lgr_tag,
const std::vector<double>& coords,
const std::vector<double>& zcorn);
339 std::size_t lgr_global_counter = 0;
340 std::string lgr_label =
"GLOBAL";
342 int lgr_level_father = 0;
343 std::vector<std::string> lgr_children_labels;
344 std::vector<std::size_t> lgr_active_index;
345 std::vector<std::size_t> lgr_level_active_map;
346 std::vector<std::string> all_lgr_labels;
347 std::map<std::vector<std::size_t>, std::size_t> num_lgr_children_cells;
348 std::vector<double> m_zcorn;
349 std::vector<double> m_coord;
350 std::vector<int> m_actnum;
351 std::vector<std::size_t> m_print_order_lgr_cells;
353 mutable std::optional<std::vector<double>> m_input_zcorn;
354 mutable std::optional<std::vector<double>> m_input_coord;
359 std::vector<double> m_minpvVector;
360 MinpvMode m_minpvMode;
361 std::optional<double> m_pinch;
364 PinchMode m_pinchoutMode;
366 PinchMode m_multzMode;
368 PinchMode m_pinchGapMode;
369 double m_pinchMaxEmptyGap;
370 bool lgr_grid =
false;
371 mutable std::optional<std::vector<double>> active_volume;
373 bool m_circle =
false;
374 std::size_t zcorn_fixed = 0;
375 bool m_useActnumFromGdfile =
false;
377 std::optional<MapAxes> m_mapaxes;
381 std::vector<int> m_active_to_global;
382 std::vector<int> m_global_to_active;
384 std::unordered_set<std::size_t> m_aquifer_cells;
386 std::map<std::size_t, double> m_aquifer_cell_depths;
387 std::map<std::size_t, std::array<int,2>> m_aquifer_cell_tabnums;
388 std::optional<std::vector<double>> m_depth;
391 std::optional<std::vector<double>> m_thetav;
392 std::optional<std::vector<double>> m_rv;
393 void parseGlobalReferenceToChildren(
void);
394 int initializeLGRObjectIndices(
int);
395 void initializeLGRTreeIndices(
void);
396 void propagateParentIndicesToLGRChildren(
int);
397 void updateNumericalAquiferCells(
const Deck&);
398 double computeCellGeometricDepth(std::size_t globalIndex)
const;
401 const std::string& fileName);
402 void resetACTNUM(
const int* actnum);
404 void initBinaryGrid(
const Deck& deck);
406 void initCornerPointGrid(
const std::vector<double>& coord ,
407 const std::vector<double>& zcorn ,
410 bool keywInputBeforeGdfile(
const Deck& deck,
const std::string& keyword)
const;
412 void initCylindricalGrid(
const Deck&);
413 void initSpiderwebGrid(
const Deck&);
414 void initSpiderwebOrCylindricalGrid(
const Deck&,
const bool);
415 void initCartesianGrid(
const Deck&);
416 void initDTOPSGrid(
const Deck&);
417 void initDVDEPTHZGrid(
const Deck&);
418 void initGrid(
const Deck&,
const int* actnum);
419 void initCornerPointGrid(
const Deck&);
420 void assertCornerPointKeywords(
const Deck&);
422 static bool hasDTOPSKeywords(
const Deck&);
423 static void assertVectorSize(
const std::vector<double>& vector, std::size_t expectedSize,
const std::string& msg);
425 static std::vector<double> createTOPSVector(
const std::array<int, 3>& dims,
const std::vector<double>& DZ,
const Deck&);
426 static std::vector<double> createDVector(
const std::array<int, 3>& dims, std::size_t dim,
const std::string& DKey,
const std::string& DVKey,
const Deck&);
427 static void scatterDim(
const std::array<int, 3>& dims , std::size_t dim ,
const std::vector<double>& DV , std::vector<double>& D);
430 std::vector<double> makeCoordDxDyDzTops(
const std::vector<double>& dx,
const std::vector<double>& dy,
const std::vector<double>& dz,
const std::vector<double>& tops)
const;
431 std::vector<double> makeZcornDzTops(
const std::vector<double>& dz,
const std::vector<double>& tops)
const ;
432 std::vector<double> makeZcornDzvDepthz(
const std::vector<double>& dzv,
const std::vector<double>& depthz)
const;
433 std::vector<double> makeCoordDxvDyvDzvDepthz(
const std::vector<double>& dxv,
const std::vector<double>& dyv,
const std::vector<double>& dzv,
const std::vector<double>& depthz)
const;
435 void getCellCorners(
const std::array<int, 3>& ijk,
const std::array<int, 3>& dims, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z)
const;
436 void getCellCorners(
const std::size_t globalIndex,
437 std::array<double,8>& X,
438 std::array<double,8>& Y,
439 std::array<double,8>& Z)
const;
444 void save_nnc_same_grid(
Opm::EclIO::EclOutput& egridfile,
const std::vector<Opm::NNCdata>& nnc, std::size_t grid_num = 0)
const;
445 void save_nnc_local_global(
Opm::EclIO::EclOutput& egridfile,
const std::vector<Opm::NNCdata>& nnc, std::size_t grid_num, std::size_t num_nnc)
const;
446 void save_nna(
Opm::EclIO::EclOutput& egridfile,
const std::vector<Opm::NNCdata>& nnc, std::size_t grid1, std::size_t grid2)
const;
449 void addZCORN(
const Deck& deck);
456 using vec_size_t = std::vector<std::size_t>;
459 const std::string& father_label_,
463 const vec_size_t& father_lgr_index,
464 const std::array<int, 3>& low_fatherIJK_,
465 const std::array<int, 3>& up_fatherIJK_);
466 const vec_size_t& getFatherGlobalID()
const;
470 void set_lgr_global_counter(std::size_t counter)
472 lgr_global_counter = counter;
474 const vec_size_t& get_father_global()
const 476 return father_global;
478 std::optional<std::reference_wrapper<EclipseGridLGR>>
479 get_child_LGR_cell(
const std::string& lgr_tag)
const;
480 std::vector<int> save_hostnum(
void)
const;
481 int get_hostnum(std::size_t global_index)
const {
return(m_hostnum[global_index]);};
484 std::vector<int> getLGRCell_global_father(
const EclipseGrid& father_grid)
const;
485 std::vector<double> getLGRCell_all_depth (
const EclipseGrid& father_grid)
const;
487 void get_label_child_to_top_father(std::vector<std::reference_wrapper<const std::string>>& list)
const;
488 void get_global_index_child_to_top_father(std::vector<std::size_t> & list,
489 std::size_t i, std::size_t j, std::size_t k)
const;
490 void get_global_index_child_to_top_father(std::vector<std::size_t> & list, std::size_t global_ind)
const;
492 void set_hostnum(
const std::vector<int>&);
493 const std::array<int,3>& get_low_fatherIJK()
const{
494 return low_fatherIJK;
496 const std::string& get_father_label()
const{
500 const std::array<int,3>& get_up_fatherIJK()
const{
513 const std::vector<double>& coord,
514 const std::vector<double>& zcorn)
override;
517 void perform_refinement(
const std::vector<double>& coord,
518 const std::vector<double>& zcorn,
519 const std::array<int,3>& parent_nxyz);
523 void init_father_global();
526 std::string father_label;
528 vec_size_t father_global;
529 std::array<int, 3> low_fatherIJK {};
530 std::array<int, 3> up_fatherIJK {};
531 std::vector<int> m_hostnum;
533 std::vector<double> generate_refined_coord(
const std::vector<double>& ,
534 const std::array<int,3>&);
536 std::vector<double> generate_refined_zcorn(
const std::vector<double>& zcorn_h,
537 const std::array<int,3>& parent_nxyz);
544 std::size_t size()
const;
552 std::size_t index(std::size_t i, std::size_t j, std::size_t dim, std::size_t layer)
const;
566 ZcornMapper(std::size_t nx, std::size_t ny, std::size_t nz);
567 std::size_t index(std::size_t i, std::size_t j, std::size_t k,
int c)
const;
568 std::size_t index(std::size_t g,
int c)
const;
569 std::size_t size()
const;
586 std::size_t fixupZCORN( std::vector<double>& zcorn);
587 bool validZCORN(
const std::vector<double>& zcorn)
const;
588 void addZCORN( std::vector<double>& zcorn,
const std::vector<AddZCornInput>& addzcorns)
const;
591 std::array<std::size_t,3> dims;
592 std::array<std::size_t,3> stride;
593 std::array<std::size_t,8> cell_shift;
596 #endif // OPM_PARSER_ECLIPSE_GRID_HPP Definition: EclipseGrid.hpp:560
void setDEPTH(const std::vector< double > &depth)
Sets DEPTH values for active cells if present in EDIT.
Definition: EclipseGrid.cpp:2701
void set_lgr_refinement(const std::string &lgr_tag, const std::vector< double > &coord, const std::vector< double > &zcorn) override
Sets Local Grid Refinement for the EclipseGridLGR.
Definition: EclipseGrid.cpp:2993
const std::vector< int > & getActiveMap() const
Will return a vector a length num_active; where the value of each element is the corresponding global...
Definition: EclipseGrid.cpp:2423
Specialized Class to describe LGR refined cells.
Definition: EclipseGrid.hpp:453
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:63
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
std::size_t getGlobalIndex(std::size_t active_index) const
Observe: the input argument is assumed to be in the space [0,num_active).
Definition: EclipseGrid.cpp:591
Definition: EclOutput.hpp:39
std::tuple< std::array< double, 3 >, std::array< double, 3 >, std::array< double, 3 > > getCellAndBottomCenterNormal(std::size_t globalIndex) const
get cell center, and center and normal of bottom face
Definition: EclipseGrid.cpp:1676
void setMINPVV(const std::vector< double > &minpvv)
Sets MINPVV if MINPV and MINPORV are not used.
Definition: EclipseGrid.cpp:2691
Definition: EclFile.hpp:34
virtual void set_lgr_refinement(const std::string &lgr_tag, const std::vector< double > &coords, const std::vector< double > &zcorn)
Sets Local Grid Refinement for the EclipseGrid.
Definition: EclipseGrid.cpp:2346
Definition: EclipseGrid.hpp:541
Definition: UnitSystem.hpp:34
Definition: LgrCollection.hpp:34
bool isValidCellGeomtry(const std::size_t globalIndex, const UnitSystem &usys) const
Whether or not given cell has a valid cell geometry.
Definition: EclipseGrid.cpp:1784
Definition: GridDims.hpp:30