Merge pull request #4269 from akva2/istlsolverebos_alugrid

ISTLSolverEbos: instance for ALUGrid
This commit is contained in:
Markus Blatt 2022-11-16 21:36:43 +01:00 committed by GitHub
commit ccdb2eda93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 80 additions and 86 deletions

View File

@ -499,23 +499,25 @@ opm_add_test(flow_distribute_z
${FLOW_TGTS}
$<TARGET_OBJECTS:moduleVersion>
)
if (NOT BUILD_FLOW_ALU_GRID)
set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "FALSE")
else()
set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "TRUE")
endif()
# the production oriented general-purpose ECL simulator
opm_add_test(flow_alugrid
ONLY_COMPILE
ALWAYS_ENABLE
DEFAULT_ENABLE_IF ${FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF}
DEPENDS opmsimulators
LIBRARIES opmsimulators
SOURCES
flow/flow_blackoil_alugrid.cpp
$<TARGET_OBJECTS:moduleVersion>)
target_compile_definitions(flow_alugrid PRIVATE USE_ALUGRID)
if(dune-alugrid_FOUND)
if (NOT BUILD_FLOW_ALU_GRID)
set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "FALSE")
else()
set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "TRUE")
endif()
opm_add_test(flow_alugrid
ONLY_COMPILE
ALWAYS_ENABLE
DEFAULT_ENABLE_IF ${FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF}
DEPENDS opmsimulators
LIBRARIES opmsimulators
SOURCES
flow/flow_blackoil_alugrid.cpp
$<TARGET_OBJECTS:moduleVersion>)
target_compile_definitions(flow_alugrid PRIVATE USE_ALUGRID)
endif()
if (BUILD_FLOW)
install(TARGETS flow DESTINATION bin)

View File

@ -32,6 +32,8 @@
#include "alucartesianindexmapper.hh"
#include <opm/models/common/multiphasebaseproperties.hh>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/common/fromtogridfactory.hh>
#include <dune/alugrid/dgf.hh>
@ -286,13 +288,17 @@ protected:
// view; on rank 0 we have undistributed data for the entire grid, on
// the other ranks the EclipseState is empty.
if (mpiRank == 0) {
// Processing grid
input_grid = &this->eclState().getInputGrid();
global_porv = this->eclState().fieldProps().porv(true);
OpmLog::info("\nProcessing grid");
}
// Processing grid
input_grid = &this->eclState().getInputGrid();
global_porv = this->eclState().fieldProps().porv(true);
OpmLog::info("\nProcessing grid");
}
#if HAVE_MPI
this->equilGrid_ = std::make_unique<Dune::CpGrid>(EclGenericVanguard::comm());
#else
this->equilGrid_ = std::make_unique<Dune::CpGrid>();
#endif
// Note: removed_cells is guaranteed to be empty on ranks other than 0.
auto removed_cells =
this->equilGrid_->processEclipseFormat(input_grid,

View File

@ -30,10 +30,6 @@
#include "collecttoiorank.hh"
#include <ebos/ecltransmissibility.hh>
#if HAVE_DUNE_ALUGRID
#include "alucartesianindexmapper.hh"
#include <dune/alugrid/common/fromtogridfactory.hh>
#endif // HAVE_DUNE_ALUGRID
#include <opm/models/parallel/tasklets.hh>
#include <opm/simulators/timestepping/SimulatorReport.hpp>

View File

@ -742,7 +742,7 @@ public:
const auto cellIndex = activeIndex(elem);
return {
cellIndex,
static_cast<int>(cellIndex),
cartesianIndex(cellIndex),
elem.partitionType() == Dune::InteriorEntity
};

View File

@ -30,17 +30,6 @@
#if USE_ALUGRID
#define DISABLE_ALUGRID_SFC_ORDERING 1
#if !HAVE_DUNE_ALUGRID
#warning "ALUGrid was indicated to be used for the ECL black oil simulator, but this "
#warning "requires the presence of dune-alugrid >= 2.4. Falling back to Dune::CpGrid"
#undef USE_ALUGRID
#define USE_ALUGRID 0
#endif
#else
#define USE_ALUGRID 0
#endif
#if USE_ALUGRID
#include "eclalugridvanguard.hh"
#elif USE_POLYHEDRALGRID
#include "eclpolyhedralgridvanguard.hh"
@ -888,15 +877,11 @@ public:
// Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> gridToEquilGrid;
#ifdef HAVE_DUNE_ALUGRID
using Grid = GetPropType<TypeTag, Properties::Grid>;
typename std::is_same<Grid, Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>>::type isAlugrid;
if constexpr (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
#if USE_ALUGRID
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
#endif // USE_ALUGRID
transmissibilities_.finishInit(gridToEquilGrid);
const auto& initconfig = eclState.getInitConfig();
@ -973,13 +958,11 @@ public:
// Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> equilGridToGrid;
#ifdef HAVE_DUNE_ALUGRID
if (isAlugrid) {
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
#if USE_ALUGRID
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
#endif // USE_ALUGRID
eclWriter_->writeInit(equilGridToGrid);
}
@ -1068,16 +1051,11 @@ public:
// Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> equilGridToGrid;
#ifdef HAVE_DUNE_ALUGRID
using Grid = GetPropType<TypeTag, Properties::Grid>;
typename std::is_same<Grid, Dune::ALUGrid<3, 3, Dune::cube,
Dune::nonconforming>>::type isAlugrid;
if constexpr (isAlugrid) {
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
#if USE_ALUGRID
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
#endif // USE_ALUGRID
// re-compute all quantities which may possibly be affected.
transmissibilities_.update(true, equilGridToGrid);
@ -1219,15 +1197,11 @@ public:
// Re-ordering in case of Alugrid
std::function<unsigned int(unsigned int)> gridToEquilGrid;
#ifdef HAVE_DUNE_ALUGRID
using Grid = GetPropType<TypeTag, Properties::Grid>;
typename std::is_same<Grid, Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>>::type isAlugrid;
if constexpr (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
#if USE_ALUGRID
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
#endif // USE_ALUGRID
std::function<void(bool)> transUp =
[this,gridToEquilGrid](bool global) {

View File

@ -33,12 +33,6 @@
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/3d/gridview.hh>
#include "alucartesianindexmapper.hh"
#endif // HAVE_DUNE_ALUGRID
#include <array>
#include <map>
#include <tuple>

View File

@ -40,7 +40,7 @@
#ifdef USE_POLYHEDRALGRID
#include <opm/grid/polyhedralgrid.hh>
#endif
#if HAVE_DUNE_ALUGRID
#if USE_ALUGRID
#include <dune/alugrid/grid.hh>
#endif
@ -71,7 +71,7 @@ class SupportsFaceTag<Dune::PolyhedralGrid<3, 3>>
{};
#endif
#if HAVE_DUNE_ALUGRID
#if USE_ALUGRID
template<>
class SupportsFaceTag<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>>
: public std::bool_constant<true>

View File

@ -37,6 +37,11 @@
#include <iostream>
#endif
#if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh>
#include <ebos/alucartesianindexmapper.hh>
#endif // HAVE_DUNE_ALUGRID
namespace Opm {
namespace detail {
@ -346,16 +351,33 @@ using CommunicationType = Dune::CollectiveCommunication<int>;
template struct FlexibleSolverInfo<BM<Dim>,BV<Dim>,CommunicationType>;
#if HAVE_CUDA || HAVE_OPENCL || HAVE_FPGA || HAVE_AMGCL || HAVE_ROCALUTION
#define INSTANCE_GRID(Dim, Grid) \
template void BdaSolverInfo<BM<Dim>,BV<Dim>>:: \
prepare(const Grid&, \
const Dune::CartesianIndexMapper<Grid>&, \
const std::vector<Well>&, \
const std::vector<int>&, \
const size_t, const bool);
#if HAVE_DUNE_ALUGRID
#if HAVE_MPI
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>;
#else
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>;
#endif //HAVE_MPI
#define INSTANCE(Dim) \
template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \
template void BdaSolverInfo<BM<Dim>,BV<Dim>>:: \
prepare<Dune::CpGrid>(const Dune::CpGrid&, \
const Dune::CartesianIndexMapper<Dune::CpGrid>&, \
const std::vector<Well>&, \
const std::vector<int>&, \
const size_t, const bool); \
INSTANCE_GRID(Dim,Dune::CpGrid) \
INSTANCE_GRID(Dim,ALUGrid3CN) \
INSTANCE_FLEX(Dim)
#else
#define INSTANCE(Dim) \
template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \
INSTANCE_GRID(Dim,Dune::CpGrid) \
INSTANCE_FLEX(Dim)
#endif
#else
#define INSTANCE(Dim) \
INSTANCE_FLEX(Dim)
#endif