27#ifndef OPM_CPGRID_VANGUARD_HPP
28#define OPM_CPGRID_VANGUARD_HPP
30#include <opm/common/TimingMacros.hpp>
48template <
class TypeTag>
52namespace Opm::Properties {
56 using InheritsFrom = std::tuple<FlowBaseVanguard>;
61template<
class TypeTag>
65template<
class TypeTag>
67 using type = Dune::CpGrid;
69template<
class TypeTag>
85template <
class TypeTag>
87 ,
public GenericCpGridVanguard<GetPropType<TypeTag, Properties::ElementMapper>,
88 GetPropType<TypeTag, Properties::GridView>,
89 GetPropType<TypeTag, Properties::Scalar>>
104 static constexpr int dimensionworld = Grid::dimensionworld;
106 static constexpr bool waterEnabled = Indices::waterEnabled;
107 static constexpr bool gasEnabled = Indices::gasEnabled;
108 static constexpr bool oilEnabled = Indices::oilEnabled;
110 using Element =
typename GridView::template Codim<0>::Entity;
113 explicit CpGridVanguard(Simulator& simulator)
117 this->callImplementationInit();
120 int compressedIndexForInteriorLGR(
const std::string& lgr_tag,
const Connection& conn)
const override
122 const std::array<int,3> lgr_ijk = {conn.getI(), conn.getJ(), conn.getK()};
123 const auto& lgr_level = this->
grid().getLgrNameToLevel().at(lgr_tag);
127 const auto& lgr_dim = this->
grid().currentData()[lgr_level]->logicalCartesianSize();
128 const auto lgr_cartesian_index = (lgr_ijk[2]*lgr_dim[0]*lgr_dim[1]) + (lgr_ijk[1]*lgr_dim[0]) + (lgr_ijk[0]);
136 const auto& runspec = this->
eclState().runspec();
137 const auto& config = this->
eclState().getSimulationConfig();
138 const auto& phases = runspec.phases();
141 if (config.isThermal()) {
143 throw std::runtime_error(
"Input specifies energy while simulator has disabled it, try xxx_energy");
147 throw std::runtime_error(
"Input specifies no energy while simulator has energy, try run without _energy");
151 if (config.isDiffusive()) {
153 throw std::runtime_error(
"Input specifies diffusion while simulator has disabled it, try xxx_diffusion");
157 if (runspec.micp()) {
159 throw std::runtime_error(
"Input specifies MICP while simulator has it disabled");
163 if (runspec.biof()) {
165 throw std::runtime_error(
"Input specifies Biofilm while simulator has it disabled");
169 if (phases.active(Phase::BRINE)) {
171 throw std::runtime_error(
"Input specifies Brine while simulator has it disabled");
175 if (phases.active(Phase::POLYMER)) {
177 throw std::runtime_error(
"Input specifies Polymer while simulator has it disabled");
182 if (phases.active(Phase::ZFRACTION)) {
184 throw std::runtime_error(
"Input specifies ExBo while simulator has it disabled");
187 if (phases.active(Phase::FOAM)) {
189 throw std::runtime_error(
"Input specifies Foam while simulator has it disabled");
193 if (phases.active(Phase::SOLVENT)) {
195 throw std::runtime_error(
"Input specifies Solvent while simulator has it disabled");
198 if(phases.active(Phase::WATER)){
199 if(waterEnabled ==
false){
200 throw std::runtime_error(
"Input specifies water while simulator has it disabled");
203 if(phases.active(Phase::GAS)){
204 if(gasEnabled ==
false){
205 throw std::runtime_error(
"Input specifies gas while simulator has it disabled");
208 if(phases.active(Phase::OIL)){
209 if(oilEnabled ==
false){
210 throw std::runtime_error(
"Input specifies oil while simulator has it disabled");
223 globalTrans_.reset();
226 const TransmissibilityType& globalTransmissibility()
const
228 assert( globalTrans_ !=
nullptr );
229 return *globalTrans_;
240 if (
const auto& extPFile = this->externalPartitionFile();
241 !extPFile.empty() && (extPFile !=
"none"))
247 this->addCorners(), this->numOverlap(),
248 this->partitionMethod(), this->serialPartitioning(),
250 this->allow_splitting_inactive_wells_,
251 this->imbalanceTol(),
257 this->updateGridView_();
258 this->updateCartesianToCompressedMapping_();
259 this->updateCellDepths_();
260 this->updateCellThickness_();
263 this->distributeFieldProps_(this->
eclState());
274 if (
const auto& lgrs = this->
eclState().getLgrs(); lgrs.size() > 0) {
275 OpmLog::info(
"\nAdding LGRs to the grid and updating its leaf grid view");
276 this->addLgrsUpdateLeafView(lgrs, lgrs.size(), *this->grid_);
278 this->updateGridView_();
279 this->updateCellDepths_();
280 this->updateCellThickness_();
282 if (this->grid_->comm().size()>1) {
286 OpmLog::info(
"\nAdding LGRs to the global view and updating its leaf grid view");
287 this->grid_->switchToGlobalView();
288 this->addLgrsUpdateLeafView(lgrs, lgrs.size(), *this->grid_);
289 this->grid_->switchToDistributedView();
290 this->grid_->syncDistributedGlobalCellIds();
295 unsigned int gridEquilIdxToGridIdx(
unsigned int elemIndex)
const {
299 unsigned int gridIdxToEquilGridIdx(
unsigned int elemIndex)
const {
309 std::function<std::array<double,dimensionworld>(
int)>
315 const std::vector<int>& globalCell()
317 return this->
grid().globalCell();
323 this->doCreateGrids_(this->edgeConformal(), this->
eclState());
326 void allocTrans()
override
328 OPM_TIMEBLOCK(allocateTrans);
329 globalTrans_.reset(
new TransmissibilityType(this->
eclState(),
337 globalTrans_->update(
false, TransmissibilityType::TransUpdateQuantities::Trans);
340 double getTransmissibility(
unsigned I,
unsigned J)
const override
342 return globalTrans_->transmissibility(I,J);
346 const std::string& zoltanParams()
const override
348 return this->zoltanParams_;
351 double zoltanPhgEdgeSizeThreshold()
const override
353 return this->zoltanPhgEdgeSizeThreshold_;
356 const std::string& metisParams()
const override
358 return this->metisParams_;
363 void filterConnections_()
365 this->doFilterConnections_(this->
schedule());
372 std::unique_ptr<TransmissibilityType> globalTrans_;
This file ensures that flow can be compiled in the presence of dune-fem.
Helper class for grid instantiation of ECL file-format using problems.
Helper class for grid instantiation of ECL file-format using problems.
Declares the properties required by the black oil model.
Definition CollectDataOnIORank.hpp:49
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition basevanguard.hh:70
Helper class for grid instantiation of ECL file-format using problems.
Definition CpGridVanguard.hpp:90
void releaseGlobalTransmissibilities()
Free the memory occupied by the global transmissibility object.
Definition CpGridVanguard.hpp:221
void addLgrs()
Add LGRs and update Leaf Grid View in the simulation grid.
Definition CpGridVanguard.hpp:270
void checkConsistency()
Checking consistency of simulator.
Definition CpGridVanguard.hpp:134
std::function< std::array< double, dimensionworld >(int)> cellCentroids() const
Get function to query cell centroids for a distributed grid.
Definition CpGridVanguard.hpp:310
void loadBalance()
Distribute the simulation grid over multiple processes.
Definition CpGridVanguard.hpp:237
FlowBaseVanguard(Simulator &simulator)
Create the grid for problem data files which use the ECL file format.
Definition FlowBaseVanguard.hpp:118
std::optional< std::vector< std::unordered_map< std::size_t, std::size_t > > > lgrMappers_
Mapping between LGR cartesian and compressed cells.
Definition FlowBaseVanguard.hpp:448
std::function< std::array< double, dimensionworld >(int)> cellCentroids_(const CartMapper &cartMapper, const bool &isCpGrid) const
Get function to query cell centroids for a distributed grid.
Definition FlowBaseVanguard.hpp:302
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition FlowGenericVanguard.hpp:248
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition FlowGenericVanguard.hpp:177
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition FlowGenericVanguard.hpp:431
bool enableDistributedWells() const
Whether perforations of a well might be distributed.
Definition FlowGenericVanguard.hpp:311
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition FlowGenericVanguard.hpp:168
bool enableEclOutput() const
Whether or not to emit result files that are compatible with a commercial reservoir simulator.
Definition FlowGenericVanguard.hpp:318
bool ownersFirst() const
Parameter that decide if cells owned by rank are ordered before ghost cells.
Definition FlowGenericVanguard.hpp:260
Dune::EdgeWeightMethod edgeWeightsMethod() const
Parameter deciding the edge-weight strategy of the load balancer.
Definition FlowGenericVanguard.hpp:242
const CartesianIndexMapper & cartesianIndexMapper() const
Definition GenericCpGridVanguard.cpp:644
static void setExternalLoadBalancer(const std::function< std::vector< int >(const Dune::CpGrid &)> &loadBalancer)
Definition GenericCpGridVanguard.hpp:125
Dune::CpGrid & grid()
Definition GenericCpGridVanguard.hpp:93
Definition Transmissibility.hpp:54
Defines the common properties required by the porous medium multi-phase models.
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Definition FlowBaseVanguard.hpp:70
The type of the DUNE grid.
Definition basicproperties.hh:100
Definition CpGridVanguard.hpp:55
Property which provides a Vanguard (manages grids).
Definition basicproperties.hh:96