Merge pull request #1287 from andlaus/improve_polymorphic_flow

Improve polymorphic flow
This commit is contained in:
Atgeirr Flø Rasmussen
2017-10-11 15:44:54 +02:00
committed by GitHub
20 changed files with 595 additions and 197 deletions

View File

@@ -91,6 +91,10 @@ SET_BOOL_PROP(EclFlowProblem, UseVolumetricResidual, false);
// SWATINIT is done by the flow part of flow_ebos. this can be removed once the legacy
// code for fluid and satfunc handling gets fully retired.
SET_BOOL_PROP(EclFlowProblem, EnableSwatinit, false);
// Silence the deprecation warnings about the SimulatorParameter mechanism. This needs to
// be removed once the SimulatorParameter mechanism bites the dust!
SET_TYPE_PROP(EclFlowProblem, SimulatorParameter, Ewoms::EmptySimulationParameters);
}}
namespace Opm {

View File

@@ -45,7 +45,6 @@
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/ResetLocale.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@@ -55,7 +54,11 @@
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
#include <ewoms/version.hh>
#if HAVE_DUNE_FEM
#include <dune/fem/misc/mpimanager.hh>
#else
#include <dune/common/parallel/mpihelper.hh>
#endif
namespace Opm
{
@@ -75,9 +78,8 @@ namespace Opm
public:
typedef typename GET_PROP(TypeTag, MaterialLaw)::EclMaterialLawManager MaterialLawManager;
typedef typename GET_PROP_TYPE(TypeTag, Simulator) EbosSimulator;
typedef typename GET_PROP_TYPE(TypeTag, SimulatorParameter) EbosSimulatorParameter;
typedef typename GET_PROP_TYPE(TypeTag, ElementMapper) ElementMapper;
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
@@ -91,23 +93,17 @@ namespace Opm
/// simulator classes, based on user command-line input. The
/// content of this function used to be in the main() function of
/// flow.cpp.
int execute(int argc, char** argv,
std::shared_ptr<Opm::Deck> deck = std::shared_ptr<Opm::Deck>(),
std::shared_ptr<Opm::EclipseState> eclipseState = std::shared_ptr<Opm::EclipseState>() )
int execute(int argc, char** argv)
{
try {
// we always want to use the default locale, and thus spare us the trouble
// with incorrect locale settings.
resetLocale();
setupParallelism(argc, argv);
setupParallelism();
printStartupMessage();
const bool ok = setupParameters(argc, argv);
if (!ok) {
return EXIT_FAILURE;
}
setupEbosSimulator( deck, eclipseState );
setupEbosSimulator();
setupOutput();
setupLogging();
printPRTHeader();
@@ -147,15 +143,18 @@ namespace Opm
}
protected:
void setupParallelism(int argc, char** argv)
void setupParallelism()
{
// MPI setup.
// Must ensure an instance of the helper is created to initialise MPI.
// For a build without MPI the Dune::FakeMPIHelper is used, so rank will
// be 0 and size 1.
const Dune::MPIHelper& mpi_helper = Dune::MPIHelper::instance(argc, argv);
mpi_rank_ = mpi_helper.rank();
const int mpi_size = mpi_helper.size();
// determine the rank of the current process and the number of processes
// involved in the simulation. MPI must have already been initialized here.
#if HAVE_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank_);
int mpi_size;
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
#else
mpi_rank_ = 0;
const int mpi_size = 1;
#endif
output_cout_ = ( mpi_rank_ == 0 );
must_distribute_ = ( mpi_size > 1 );
@@ -409,7 +408,7 @@ namespace Opm
detail::ParallelFileMerger(output_path, deck_filename.stem().string()));
}
void setupEbosSimulator( std::shared_ptr<Opm::Deck>& dck, std::shared_ptr<Opm::EclipseState>& eclipseState)
void setupEbosSimulator()
{
std::string progName("flow_ebos");
std::string deckFile("--ecl-deck-file-name=");
@@ -417,10 +416,9 @@ namespace Opm
char* ptr[2];
ptr[ 0 ] = const_cast< char * > (progName.c_str());
ptr[ 1 ] = const_cast< char * > (deckFile.c_str());
EbosSimulatorParameter simParam( dck, eclipseState );
EbosSimulator::registerParameters();
Ewoms::setupParameters_< TypeTag > ( 2, ptr );
ebosSimulator_.reset(new EbosSimulator(simParam, /*verbose=*/false));
ebosSimulator_.reset(new EbosSimulator(/*verbose=*/false));
ebosSimulator_->model().applyInitialSolution();
// Create a grid with a global view.
@@ -808,6 +806,8 @@ namespace Opm
const Grid& globalGrid = this->globalGrid();
const auto& globalGridView = globalGrid.leafGridView();
typedef typename Grid::LeafGridView GridView;
typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
ElementMapper globalElemMapper(globalGridView);
const auto& cartesianCellIdx = globalGrid.globalCell();
@@ -881,6 +881,8 @@ namespace Opm
const Grid& globalGrid = this->globalGrid();
const auto& globalGridView = globalGrid.leafGridView();
typedef typename Grid::LeafGridView GridView;
typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
ElementMapper globalElemMapper(globalGridView);
const auto* globalTrans = &(ebosSimulator_->gridManager().globalTransmissibility());

View File

@@ -461,7 +461,7 @@ public:
{ return ebosSimulator_.gridManager().grid(); }
protected:
void handleAdditionalWellInflow(SimulatorTimer& timer,
void handleAdditionalWellInflow(SimulatorTimer& /*timer*/,
WellsManager& /* wells_manager */,
WellState& /* well_state */,
const Wells* /* wells */)
@@ -958,6 +958,9 @@ protected:
if ( active[Water] ) {
fluidState.setSaturation(FluidSystem::waterPhaseIdx, saturations[cellIdx*numPhases + pu.phase_pos[Water]]);
}
else {
fluidState.setSaturation(FluidSystem::waterPhaseIdx, 0.0);
}
fluidState.setSaturation(FluidSystem::oilPhaseIdx, saturations[cellIdx*numPhases + pu.phase_pos[Oil]]);
fluidState.setSaturation(FluidSystem::gasPhaseIdx, saturations[cellIdx*numPhases + pu.phase_pos[Gas]]);