mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
pass CartesianIndexMapper instead of the grid to the RelpermDiagnositics
This commit is contained in:
parent
3a0dbdc6e7
commit
c145722798
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
#include <opm/grid/CpGrid.hpp>
|
#include <opm/grid/CpGrid.hpp>
|
||||||
#include <opm/grid/cpgrid/GridHelpers.hpp>
|
#include <opm/grid/cpgrid/GridHelpers.hpp>
|
||||||
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||||
@ -700,14 +699,6 @@ protected:
|
|||||||
asImp_().filterConnections_();
|
asImp_().filterConnections_();
|
||||||
asImp_().updateOutputDir_();
|
asImp_().updateOutputDir_();
|
||||||
asImp_().finalizeInit_();
|
asImp_().finalizeInit_();
|
||||||
|
|
||||||
if (enableExperiments) {
|
|
||||||
if (asImp_().grid().size(0)) //grid not loadbalanced yet for ebos!
|
|
||||||
{
|
|
||||||
Opm::RelpermDiagnostics relpermDiagnostics;
|
|
||||||
relpermDiagnostics.diagnosis(*eclState_, asImp_().grid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void updateCartesianToCompressedMapping_()
|
void updateCartesianToCompressedMapping_()
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
#include "ecltracermodel.hh"
|
#include "ecltracermodel.hh"
|
||||||
#include "vtkecltracermodule.hh"
|
#include "vtkecltracermodule.hh"
|
||||||
|
|
||||||
|
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/pffgridvector.hh>
|
#include <opm/models/utils/pffgridvector.hh>
|
||||||
#include <opm/models/blackoil/blackoilmodel.hh>
|
#include <opm/models/blackoil/blackoilmodel.hh>
|
||||||
#include <opm/models/discretization/ecfv/ecfvdiscretization.hh>
|
#include <opm/models/discretization/ecfv/ecfvdiscretization.hh>
|
||||||
@ -839,6 +841,9 @@ public:
|
|||||||
maxTimeStepAfterWellEvent_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclMaxTimeStepSizeAfterWellEvent);
|
maxTimeStepAfterWellEvent_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclMaxTimeStepSizeAfterWellEvent);
|
||||||
restartShrinkFactor_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclRestartShrinkFactor);
|
restartShrinkFactor_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclRestartShrinkFactor);
|
||||||
maxFails_ = EWOMS_GET_PARAM(TypeTag, unsigned, MaxTimeStepDivisions);
|
maxFails_ = EWOMS_GET_PARAM(TypeTag, unsigned, MaxTimeStepDivisions);
|
||||||
|
|
||||||
|
Opm::RelpermDiagnostics relpermDiagnostics;
|
||||||
|
relpermDiagnostics.diagnosis(vanguard.eclState(), vanguard.cartesianIndexMapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -52,9 +52,9 @@ namespace Opm {
|
|||||||
///output if they're found.
|
///output if they're found.
|
||||||
///\param[in] eclState eclipse state.
|
///\param[in] eclState eclipse state.
|
||||||
///\param[in] grid unstructured grid.
|
///\param[in] grid unstructured grid.
|
||||||
template <class GridT>
|
template <class CartesianIndexMapper>
|
||||||
void diagnosis(const EclipseState& eclState,
|
void diagnosis(const EclipseState& eclState,
|
||||||
const GridT& grid);
|
const CartesianIndexMapper& cartesianIndexMapper);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum FluidSystem {
|
enum FluidSystem {
|
||||||
@ -91,9 +91,9 @@ namespace Opm {
|
|||||||
///Check endpoints in the saturation tables.
|
///Check endpoints in the saturation tables.
|
||||||
void unscaledEndPointsCheck_(const EclipseState& eclState);
|
void unscaledEndPointsCheck_(const EclipseState& eclState);
|
||||||
|
|
||||||
template <class GridT>
|
template <class CartesianIndexMapper>
|
||||||
void scaledEndPointsCheck_(const EclipseState& eclState,
|
void scaledEndPointsCheck_(const EclipseState& eclState,
|
||||||
const GridT& grid);
|
const CartesianIndexMapper& cartesianIndexMapper);
|
||||||
|
|
||||||
///For every table, need to deal with case by case.
|
///For every table, need to deal with case by case.
|
||||||
void swofTableCheck_(const Opm::SwofTable& swofTables,
|
void swofTableCheck_(const Opm::SwofTable& swofTables,
|
||||||
|
@ -31,28 +31,25 @@
|
|||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
template <class GridT>
|
template <class CartesianIndexMapper>
|
||||||
void RelpermDiagnostics::diagnosis(const Opm::EclipseState& eclState,
|
void RelpermDiagnostics::diagnosis(const Opm::EclipseState& eclState,
|
||||||
const GridT& grid)
|
const CartesianIndexMapper& cartesianIndexMapper)
|
||||||
{
|
{
|
||||||
OpmLog::info("\n===============Saturation Functions Diagnostics===============\n");
|
OpmLog::info("\n===============Saturation Functions Diagnostics===============\n");
|
||||||
phaseCheck_(eclState);
|
phaseCheck_(eclState);
|
||||||
satFamilyCheck_(eclState);
|
satFamilyCheck_(eclState);
|
||||||
tableCheck_(eclState);
|
tableCheck_(eclState);
|
||||||
unscaledEndPointsCheck_(eclState);
|
unscaledEndPointsCheck_(eclState);
|
||||||
scaledEndPointsCheck_(eclState, grid);
|
scaledEndPointsCheck_(eclState, cartesianIndexMapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class GridT>
|
template <class CartesianIndexMapper>
|
||||||
void RelpermDiagnostics::scaledEndPointsCheck_(const EclipseState& eclState,
|
void RelpermDiagnostics::scaledEndPointsCheck_(const EclipseState& eclState,
|
||||||
const GridT& grid)
|
const CartesianIndexMapper& cartesianIndexMapper)
|
||||||
{
|
{
|
||||||
// All end points are subject to round-off errors, checks should account for it
|
// All end points are subject to round-off errors, checks should account for it
|
||||||
const float tolerance = 1e-6;
|
const float tolerance = 1e-6;
|
||||||
const int nc = Opm::UgGridHelpers::numCells(grid);
|
const int nc = cartesianIndexMapper.compressedSize();
|
||||||
const auto& global_cell = Opm::UgGridHelpers::globalCell(grid);
|
|
||||||
const auto dims = Opm::UgGridHelpers::cartDims(grid);
|
|
||||||
const auto& compressedToCartesianIdx = Opm::compressedToCartesian(nc, global_cell);
|
|
||||||
const bool threepoint = eclState.runspec().endpointScaling().threepoint();
|
const bool threepoint = eclState.runspec().endpointScaling().threepoint();
|
||||||
scaledEpsInfo_.resize(nc);
|
scaledEpsInfo_.resize(nc);
|
||||||
EclEpsGridProperties epsGridProperties(eclState, false);
|
EclEpsGridProperties epsGridProperties(eclState, false);
|
||||||
@ -62,10 +59,7 @@ namespace Opm {
|
|||||||
std::string cellIdx;
|
std::string cellIdx;
|
||||||
{
|
{
|
||||||
std::array<int, 3> ijk;
|
std::array<int, 3> ijk;
|
||||||
int cartIdx = compressedToCartesianIdx[c];
|
cartesianIndexMapper.cartesianCoordinate(c, ijk);
|
||||||
ijk[0] = cartIdx % dims[0]; cartIdx /= dims[0];
|
|
||||||
ijk[1] = cartIdx % dims[1];
|
|
||||||
ijk[2] = cartIdx / dims[1];
|
|
||||||
cellIdx = "(" + std::to_string(ijk[0]) + ", " +
|
cellIdx = "(" + std::to_string(ijk[0]) + ", " +
|
||||||
std::to_string(ijk[1]) + ", " +
|
std::to_string(ijk[1]) + ", " +
|
||||||
std::to_string(ijk[2]) + ")";
|
std::to_string(ijk[2]) + ")";
|
||||||
|
@ -407,7 +407,6 @@ namespace Opm
|
|||||||
|
|
||||||
setupParallelism();
|
setupParallelism();
|
||||||
setupEbosSimulator();
|
setupEbosSimulator();
|
||||||
runDiagnostics();
|
|
||||||
createSimulator();
|
createSimulator();
|
||||||
|
|
||||||
// if run, do the actual work, else just initialize
|
// if run, do the actual work, else just initialize
|
||||||
@ -545,35 +544,6 @@ namespace Opm
|
|||||||
const Schedule& schedule() const
|
const Schedule& schedule() const
|
||||||
{ return ebosSimulator_->vanguard().schedule(); }
|
{ return ebosSimulator_->vanguard().schedule(); }
|
||||||
|
|
||||||
|
|
||||||
// Run diagnostics.
|
|
||||||
// Writes to:
|
|
||||||
// OpmLog singleton.
|
|
||||||
void runDiagnostics()
|
|
||||||
{
|
|
||||||
if (!this->output_cout_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run relperm diagnostics if we have more than one phase.
|
|
||||||
if (FluidSystem::numActivePhases() > 1) {
|
|
||||||
RelpermDiagnostics diagnostic;
|
|
||||||
if (mpi_size_ > 1) {
|
|
||||||
#if HAVE_MPI
|
|
||||||
this->grid().switchToGlobalView();
|
|
||||||
static_cast<ParallelEclipseState&>(this->eclState()).switchToGlobalProps();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
diagnostic.diagnosis(eclState(), this->grid());
|
|
||||||
if (mpi_size_ > 1) {
|
|
||||||
#if HAVE_MPI
|
|
||||||
this->grid().switchToDistributedView();
|
|
||||||
static_cast<ParallelEclipseState&>(this->eclState()).switchToDistributedProps();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the simulator.
|
// Run the simulator.
|
||||||
int runSimulator()
|
int runSimulator()
|
||||||
{
|
{
|
||||||
|
@ -36,29 +36,54 @@
|
|||||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||||
#include <opm/common/OpmLog/CounterLog.hpp>
|
#include <opm/common/OpmLog/CounterLog.hpp>
|
||||||
|
|
||||||
#include <opm/grid/UnstructuredGrid.h>
|
#include <opm/grid/CpGrid.hpp>
|
||||||
#include <opm/grid/cart_grid.h>
|
#include <dune/grid/common/mcmgmapper.hh>
|
||||||
#include <opm/grid/GridManager.hpp>
|
|
||||||
|
|
||||||
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
|
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||||
|
|
||||||
|
#if HAVE_DUNE_FEM
|
||||||
|
#include <dune/fem/misc/mpimanager.hh>
|
||||||
|
#else
|
||||||
|
#include <dune/common/parallel/mpihelper.hh>
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE ()
|
BOOST_AUTO_TEST_SUITE ()
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(diagnosis)
|
BOOST_AUTO_TEST_CASE(diagnosis)
|
||||||
{
|
{
|
||||||
|
// MPI setup.
|
||||||
|
int argcDummy = 1;
|
||||||
|
const char *tmp[] = {"test_relpermdiagnostic"};
|
||||||
|
char **argvDummy = const_cast<char**>(tmp);
|
||||||
|
|
||||||
|
#if HAVE_DUNE_FEM
|
||||||
|
Dune::Fem::MPIManager::initialize(argcDummy, argvDummy);
|
||||||
|
#else
|
||||||
|
Dune::MPIHelper::instance(argcDummy, argvDummy);
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace Opm;
|
using namespace Opm;
|
||||||
Parser parser;
|
Parser parser;
|
||||||
|
|
||||||
Opm::Deck deck = parser.parseFile("../tests/relpermDiagnostics.DATA");
|
Opm::Deck deck = parser.parseFile("../tests/relpermDiagnostics.DATA");
|
||||||
EclipseState eclState(deck);
|
EclipseState eclState(deck);
|
||||||
GridManager gm(eclState.getInputGrid());
|
typedef Dune::CpGrid Grid;
|
||||||
const UnstructuredGrid& grid = *gm.c_grid();
|
Grid grid = Grid();
|
||||||
|
grid.processEclipseFormat(&eclState.getInputGrid(),
|
||||||
|
/*isPeriodic=*/false,
|
||||||
|
/*flipNormals=*/false,
|
||||||
|
/*clipZ=*/false,
|
||||||
|
eclState.fieldProps().porv(true),
|
||||||
|
eclState.getInputNNC());
|
||||||
|
|
||||||
|
typedef Dune::CartesianIndexMapper<Grid> CartesianIndexMapper;
|
||||||
|
CartesianIndexMapper cartesianIndexMapper = CartesianIndexMapper(grid);
|
||||||
std::shared_ptr<CounterLog> counterLog = std::make_shared<CounterLog>(Log::DefaultMessageTypes);
|
std::shared_ptr<CounterLog> counterLog = std::make_shared<CounterLog>(Log::DefaultMessageTypes);
|
||||||
OpmLog::addBackend( "COUNTERLOG" , counterLog );
|
OpmLog::addBackend( "COUNTERLOG" , counterLog );
|
||||||
RelpermDiagnostics diagnostics;
|
RelpermDiagnostics diagnostics;
|
||||||
diagnostics.diagnosis(eclState, grid);
|
diagnostics.diagnosis(eclState, cartesianIndexMapper);
|
||||||
BOOST_CHECK_EQUAL(1, counterLog->numMessages(Log::MessageType::Warning));
|
BOOST_CHECK_EQUAL(1, counterLog->numMessages(Log::MessageType::Warning));
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user