Loading...
Searching...
No Matches
FlowGenericVanguard.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_FLOW_GENERIC_VANGUARD_HPP
#define OPM_FLOW_GENERIC_VANGUARD_HPP
#include <dune/common/parallel/communication.hh>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/grid/common/GridEnums.hpp>
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <cassert>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
namespace Opm::Parameters {
struct AllowDistributedWells { static constexpr bool value = false; };
struct AllowSplittingInactiveWells { static constexpr bool value = true; };
struct EclOutputInterval { static constexpr int value = -1; };
struct EdgeWeightsMethod { static constexpr auto value = "transmissibility"; };
struct EnableDryRun { static constexpr auto value = "auto"; };
struct EnableEclOutput { static constexpr auto value = true; };
struct EnableOpmRstFile { static constexpr bool value = false; };
struct ExternalPartition { static constexpr auto* value = ""; };
template<class Scalar>
struct ImbalanceTol { static constexpr Scalar value = 1.1; };
struct IgnoreKeywords { static constexpr auto value = ""; };
struct InputSkipMode { static constexpr auto value = "100"; };
struct MetisParams { static constexpr auto value = "default"; };
#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
struct NumJacobiBlocks { static constexpr int value = 0; };
#endif // HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
struct OwnerCellsFirst { static constexpr bool value = true; };
struct ParsingStrictness { static constexpr auto value = "normal"; };
struct ActionParsingStrictness { static constexpr auto value = "normal"; };
struct PartitionMethod { static constexpr auto value = "zoltanwell"; };
struct AddCorners { static constexpr bool value = false; };
struct NumOverlap { static constexpr int value = 1; };
struct EdgeConformal { static constexpr bool value = false; };
struct SchedRestart{ static constexpr bool value = false; };
struct SerialPartitioning{ static constexpr bool value = false; };
template<class Scalar>
struct ZoltanImbalanceTol { static constexpr Scalar value = 1.1; };
struct ZoltanPhgEdgeSizeThreshold { static constexpr auto value = 0.35; };
struct ZoltanParams { static constexpr auto value = "graph"; };
} // namespace Opm::Parameters
namespace Opm {
namespace Action { class State; }
class Deck;
class EclipseState;
struct NumericalAquiferCell;
class ParseContext;
class Schedule;
class Python;
class SummaryConfig;
class SummaryState;
class UDQState;
class WellTestState;
class FlowGenericVanguard {
public:
using ParallelWellStruct = std::vector<std::pair<std::string,bool>>;
struct SimulationModelParams {
double setupTime_;
std::unique_ptr<UDQState> udqState_;
std::unique_ptr<Action::State> actionState_;
std::unique_ptr<SummaryState> summaryState_;
std::unique_ptr<WellTestState> wtestState_;
std::shared_ptr<EclipseState> eclState_;
std::shared_ptr<Schedule> eclSchedule_;
std::shared_ptr<SummaryConfig> eclSummaryConfig_;
};
static SimulationModelParams modelParams_;
FlowGenericVanguard();
explicit FlowGenericVanguard(SimulationModelParams&& params);
~FlowGenericVanguard();
static SimulationModelParams serializationTestParams();
static std::string canonicalDeckPath(const std::string& caseName);
double setupTime()
{ return setupTime_; }
static void readDeck(const std::string& filename);
void defineSimulationModel(SimulationModelParams&& params);
const EclipseState& eclState() const
{ return *eclState_; }
EclipseState& eclState()
{ return *eclState_; }
const Schedule& schedule() const
{ return *eclSchedule_; }
Schedule& schedule()
{ return *eclSchedule_; }
const SummaryConfig& summaryConfig() const
{ return *eclSummaryConfig_; }
SummaryState& summaryState()
{ return *summaryState_; }
const SummaryState& summaryState() const
{ return *summaryState_; }
Action::State& actionState()
{ return *actionState_; }
const Action::State& actionState() const
{ return *actionState_; }
UDQState& udqState()
{ return *udqState_; }
const UDQState& udqState() const
{ return *udqState_; }
std::unique_ptr<WellTestState> transferWTestState() {
return std::move(this->wtestState_);
}
const std::string& caseName() const
{ return caseName_; }
Dune::EdgeWeightMethod edgeWeightsMethod() const
{ return edgeWeightsMethod_; }
int numJacobiBlocks() const
{
#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
return numJacobiBlocks_;
#else
return 0;
#endif // HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
}
bool ownersFirst() const
{ return ownersFirst_; }
bool edgeConformal() const
{ return edgeConformal_; }
#if HAVE_MPI
bool addCorners() const
{ return addCorners_; }
int numOverlap() const
{ return numOverlap_; }
Dune::PartitionMethod partitionMethod() const
{ return partitionMethod_; }
bool serialPartitioning() const
{ return serialPartitioning_; }
double imbalanceTol() const
{
if (zoltanImbalanceTolSet_) {
OpmLog::info("The parameter --zoltan-imbalance-tol is deprecated "
"and has been renamed to --imbalance-tol, please "
"adjust your calls and scripts!");
return zoltanImbalanceTol_;
} else {
return imbalanceTol_;
}
}
const std::string& externalPartitionFile() const
{
return this->externalPartitionFile_;
}
#endif // HAVE_MPI
bool enableDistributedWells() const
{ return enableDistributedWells_; }
bool enableEclOutput() const
{ return enableEclOutput_; }
const ParallelWellStruct& parallelWells() const
{ return parallelWells_; }
static void setCommunication(std::unique_ptr<Opm::Parallel::Communication> comm)
{ comm_ = std::move(comm); }
static Parallel::Communication& comm()
{
assert(comm_ != nullptr);
return *comm_;
}
// Private to avoid pulling schedule in header.
// Static state is not serialized, only use for restart.
template<class Serializer>
void serializeOp(Serializer& serializer);
// Only compares dynamic state.
bool operator==(const FlowGenericVanguard& rhs) const;
protected:
void updateOutputDir_(std::string outputDir,
bool enableEclCompatFile);
void updateNOSIM_(std::string_view enableDryRun);
bool drsdtconEnabled() const;
std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const;
void init();
template<class Scalar>
static void registerParameters_();
double setupTime_;
// These variables may be owned by both Python and the simulator
static std::unique_ptr<Parallel::Communication> comm_;
std::string caseName_;
std::string fileName_;
Dune::EdgeWeightMethod edgeWeightsMethod_;
#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
int numJacobiBlocks_{0};
#endif // HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
bool ownersFirst_;
bool edgeConformal_;
#if HAVE_MPI
bool addCorners_;
int numOverlap_;
Dune::PartitionMethod partitionMethod_;
bool serialPartitioning_;
double imbalanceTol_;
bool zoltanImbalanceTolSet_;
double zoltanImbalanceTol_;
double zoltanPhgEdgeSizeThreshold_;
std::string zoltanParams_;
std::string metisParams_;
std::string externalPartitionFile_{};
#endif // HAVE_MPI
bool enableDistributedWells_;
bool enableEclOutput_;
bool allow_splitting_inactive_wells_;
std::string ignoredKeywords_;
std::optional<int> outputInterval_;
bool useMultisegmentWell_;
bool enableExperiments_;
std::unique_ptr<SummaryState> summaryState_;
std::unique_ptr<UDQState> udqState_;
std::unique_ptr<Action::State> actionState_;
// Observe that this instance is handled differently from the other state
// variables, it will only be initialized for a restart run. While
// initializing a restarted run this instance is transferred to the WGState
// member in the well model.
std::unique_ptr<WellTestState> wtestState_;
// these attributes point either to the internal or to the external version of the
// parser objects.
std::shared_ptr<Python> python;
// These variables may be owned by both Python and the simulator
std::shared_ptr<EclipseState> eclState_;
std::shared_ptr<Schedule> eclSchedule_;
std::shared_ptr<SummaryConfig> eclSummaryConfig_;
ParallelWellStruct parallelWells_;
};
} // namespace Opm
#endif // OPM_FLOW_GENERIC_VANGUARD_HPP
Opm::FlowGenericVanguard
Definition FlowGenericVanguard.hpp:108
Opm::FlowGenericVanguard::comm
static Parallel::Communication & comm()
Obtain global communicator.
Definition FlowGenericVanguard.hpp:336
Opm::FlowGenericVanguard::numJacobiBlocks
int numJacobiBlocks() const
Number of blocks in the Block-Jacobi preconditioner.
Definition FlowGenericVanguard.hpp:248
Opm::FlowGenericVanguard::schedule
const Schedule & schedule() const
Return a reference to the object that managages the ECL schedule.
Definition FlowGenericVanguard.hpp:177
Opm::FlowGenericVanguard::setupTime
double setupTime()
Returns the wall time required to set up the simulator before it was born.
Definition FlowGenericVanguard.hpp:151
Opm::FlowGenericVanguard::readDeck
static void readDeck(const std::string &filename)
Read a deck.
Definition FlowGenericVanguard.cpp:210
Opm::FlowGenericVanguard::summaryConfig
const SummaryConfig & summaryConfig() const
Return a reference to the object that determines which quantities ought to be put into the ECL summar...
Definition FlowGenericVanguard.hpp:187
Opm::FlowGenericVanguard::parallelWells_
ParallelWellStruct parallelWells_
Information about wells in parallel.
Definition FlowGenericVanguard.hpp:431
Opm::FlowGenericVanguard::setCommunication
static void setCommunication(std::unique_ptr< Opm::Parallel::Communication > comm)
Set global communication.
Definition FlowGenericVanguard.hpp:332
Opm::FlowGenericVanguard::enableDistributedWells
bool enableDistributedWells() const
Whether perforations of a well might be distributed.
Definition FlowGenericVanguard.hpp:311
Opm::FlowGenericVanguard::canonicalDeckPath
static std::string canonicalDeckPath(const std::string &caseName)
Returns the canonical path to a deck file.
Definition FlowGenericVanguard.cpp:227
Opm::FlowGenericVanguard::~FlowGenericVanguard
~FlowGenericVanguard()
Destructor.
Opm::FlowGenericVanguard::actionState
Action::State & actionState()
Returns the action state.
Definition FlowGenericVanguard.hpp:208
Opm::FlowGenericVanguard::eclState
const EclipseState & eclState() const
Return a reference to the internalized ECL deck.
Definition FlowGenericVanguard.hpp:168
Opm::FlowGenericVanguard::FlowGenericVanguard
FlowGenericVanguard()
Constructor.
Definition FlowGenericVanguard.cpp:108
Opm::FlowGenericVanguard::defineSimulationModel
void defineSimulationModel(SimulationModelParams &&params)
Set the simulation configuration objects.
Definition FlowGenericVanguard.cpp:198
Opm::FlowGenericVanguard::enableEclOutput
bool enableEclOutput() const
Whether or not to emit result files that are compatible with a commercial reservoir simulator.
Definition FlowGenericVanguard.hpp:318
Opm::FlowGenericVanguard::caseName
const std::string & caseName() const
Returns the name of the case.
Definition FlowGenericVanguard.hpp:236
Opm::FlowGenericVanguard::ownersFirst
bool ownersFirst() const
Parameter that decide if cells owned by rank are ordered before ghost cells.
Definition FlowGenericVanguard.hpp:260
Opm::FlowGenericVanguard::edgeWeightsMethod
Dune::EdgeWeightMethod edgeWeightsMethod() const
Parameter deciding the edge-weight strategy of the load balancer.
Definition FlowGenericVanguard.hpp:242
Opm::FlowGenericVanguard::udqState
UDQState & udqState()
Returns the udq state.
Definition FlowGenericVanguard.hpp:219
Opm::FlowGenericVanguard::parallelWells
const ParallelWellStruct & parallelWells() const
Retrieve collection (a vector of pairs) of well names and whether or not the corresponding well objec...
Definition FlowGenericVanguard.hpp:328
Opm::FlowGenericVanguard::summaryState
SummaryState & summaryState()
Returns the summary state.
Definition FlowGenericVanguard.hpp:197
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::FlowGenericVanguard::SimulationModelParams
Definition FlowGenericVanguard.hpp:112
Opm::Parameters::ActionParsingStrictness
Definition FlowGenericVanguard.hpp:73
Opm::Parameters::AddCorners
Definition FlowGenericVanguard.hpp:78
Opm::Parameters::AllowDistributedWells
Definition FlowGenericVanguard.hpp:50
Opm::Parameters::AllowSplittingInactiveWells
Definition FlowGenericVanguard.hpp:51
Opm::Parameters::EclOutputInterval
Definition FlowGenericVanguard.hpp:53
Opm::Parameters::EdgeConformal
Definition FlowGenericVanguard.hpp:80
Opm::Parameters::EdgeWeightsMethod
Definition FlowGenericVanguard.hpp:54
Opm::Parameters::EnableDryRun
Definition FlowGenericVanguard.hpp:55
Opm::Parameters::EnableEclOutput
Definition FlowGenericVanguard.hpp:56
Opm::Parameters::EnableOpmRstFile
Definition FlowGenericVanguard.hpp:57
Opm::Parameters::ExternalPartition
Definition FlowGenericVanguard.hpp:58
Opm::Parameters::IgnoreKeywords
Definition FlowGenericVanguard.hpp:63
Opm::Parameters::ImbalanceTol
Definition FlowGenericVanguard.hpp:61
Opm::Parameters::InputSkipMode
Definition FlowGenericVanguard.hpp:64
Opm::Parameters::MetisParams
Definition FlowGenericVanguard.hpp:65
Opm::Parameters::NumOverlap
Definition FlowGenericVanguard.hpp:79
Opm::Parameters::OwnerCellsFirst
Definition FlowGenericVanguard.hpp:71
Opm::Parameters::ParsingStrictness
Definition FlowGenericVanguard.hpp:72
Opm::Parameters::PartitionMethod
0: simple, 1: Zoltan, 2: METIS, 3: Zoltan with a all cells of a well represented by one vertex in the...
Definition FlowGenericVanguard.hpp:77
Opm::Parameters::SchedRestart
Definition FlowGenericVanguard.hpp:82
Opm::Parameters::SerialPartitioning
Definition FlowGenericVanguard.hpp:83
Opm::Parameters::ZoltanImbalanceTol
Definition FlowGenericVanguard.hpp:86
Opm::Parameters::ZoltanParams
Definition FlowGenericVanguard.hpp:90
Opm::Parameters::ZoltanPhgEdgeSizeThreshold
Definition FlowGenericVanguard.hpp:88