remove use of hidden private defines for poly and alugrid

- fixed polygrid
- renamed executables to include blackoil in name
This commit is contained in:
hnil 2023-08-01 13:41:51 +02:00 committed by Arne Morten Kvarving
parent 63d37bd6f2
commit 66ff026008
9 changed files with 109 additions and 124 deletions

View File

@ -317,8 +317,8 @@ endmacro (files_hook)
macro (tests_hook) macro (tests_hook)
endmacro (tests_hook) endmacro (tests_hook)
# all setup common to the OPM library modules is done here # all setup common to the OPM library modules is done here
include (OpmLibMain) include (OpmLibMain)
@ -559,12 +559,6 @@ foreach(OBJ ${FLOW_VARIANT_MODELS})
set_property(TARGET flow_lib${OBJ} PROPERTY EXCLUDE_FROM_ALL ${FLOW_VARIANTS_DEFAULT_ENABLE_IF}) set_property(TARGET flow_lib${OBJ} PROPERTY EXCLUDE_FROM_ALL ${FLOW_VARIANTS_DEFAULT_ENABLE_IF})
endforeach() endforeach()
add_library(flow_libblackoil_poly OBJECT flow/flow_ebos_blackoil_poly.cpp)
if(TARGET fmt::fmt)
target_link_libraries(flow_libblackoil_poly fmt::fmt)
endif()
set_property(TARGET flow_libblackoil_poly PROPERTY EXCLUDE_FROM_ALL ${FLOW_POLY_ONLY_DEFAULT_ENABLE_IF})
opm_add_test(flow opm_add_test(flow
ONLY_COMPILE ONLY_COMPILE
ALWAYS_ENABLE ALWAYS_ENABLE
@ -577,17 +571,15 @@ opm_add_test(flow
$<TARGET_OBJECTS:moduleVersion> $<TARGET_OBJECTS:moduleVersion>
) )
opm_add_test(flow_poly opm_add_test(flow_blackoil_polyhedralgrid
ONLY_COMPILE ONLY_COMPILE
ALWAYS_ENABLE ALWAYS_ENABLE
DEFAULT_ENABLE_IF ${FLOW_POLY_ONLY_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${FLOW_POLY_ONLY_DEFAULT_ENABLE_IF}
DEPENDS opmsimulators DEPENDS opmsimulators
LIBRARIES opmsimulators LIBRARIES opmsimulators
SOURCES SOURCES
flow/flow_blackoil_poly.cpp flow/flow_blackoil_polyhedralgrid.cpp
$<TARGET_OBJECTS:flow_libblackoil_poly>
$<TARGET_OBJECTS:moduleVersion>) $<TARGET_OBJECTS:moduleVersion>)
target_compile_definitions(flow_poly PRIVATE USE_POLYHEDRALGRID)
opm_add_test(flow_distribute_z opm_add_test(flow_distribute_z
ONLY_COMPILE ONLY_COMPILE
@ -608,7 +600,7 @@ if(dune-alugrid_FOUND)
set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "TRUE") set(FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF "TRUE")
endif() endif()
opm_add_test(flow_alugrid opm_add_test(flow_blackoil_alugrid
ONLY_COMPILE ONLY_COMPILE
ALWAYS_ENABLE ALWAYS_ENABLE
DEFAULT_ENABLE_IF ${FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF} DEFAULT_ENABLE_IF ${FLOW_ALUGRID_ONLY_DEFAULT_ENABLE_IF}
@ -617,7 +609,6 @@ if(dune-alugrid_FOUND)
SOURCES SOURCES
flow/flow_blackoil_alugrid.cpp flow/flow_blackoil_alugrid.cpp
$<TARGET_OBJECTS:moduleVersion>) $<TARGET_OBJECTS:moduleVersion>)
target_compile_definitions(flow_alugrid PRIVATE USE_ALUGRID)
endif() endif()
if (BUILD_FLOW) if (BUILD_FLOW)
@ -685,5 +676,3 @@ endif()
install(DIRECTORY doc/man1 DESTINATION ${CMAKE_INSTALL_MANDIR} install(DIRECTORY doc/man1 DESTINATION ${CMAKE_INSTALL_MANDIR}
FILES_MATCHING PATTERN "*.1") FILES_MATCHING PATTERN "*.1")

View File

@ -92,12 +92,17 @@ public:
using Grid = GetPropType<TypeTag, Properties::Grid>; using Grid = GetPropType<TypeTag, Properties::Grid>;
using EquilGrid = GetPropType<TypeTag, Properties::EquilGrid>; using EquilGrid = GetPropType<TypeTag, Properties::EquilGrid>;
using GridView = GetPropType<TypeTag, Properties::GridView>; using GridView = GetPropType<TypeTag, Properties::GridView>;
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using EquilCartesianIndexMapper = Dune::CartesianIndexMapper<EquilGrid>;
using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper, CartesianIndexMapper, Scalar>;
static constexpr int dimension = Grid::dimension;
static constexpr int dimensionworld = Grid::dimensionworld;
private: private:
using GridPointer = Grid*; using GridPointer = Grid*;
using EquilGridPointer = EquilGrid*; using EquilGridPointer = EquilGrid*;
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>; //using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using CartesianIndexMapperPointer = std::unique_ptr<CartesianIndexMapper>; //using CartesianIndexMapperPointer = std::unique_ptr<CartesianIndexMapper>;
public: public:
using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper, using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper,
@ -108,11 +113,17 @@ public:
simulator_( simulator ) simulator_( simulator )
{ {
this->callImplementationInit(); this->callImplementationInit();
// add a copy in standard vector format to fullfill new interface
const int* globalcellorg = this->grid().globalCell();
int num_cells = this->gridView().size(0);
globalcell_.resize(num_cells);
for(int i=0; i < num_cells; ++i){
globalcell_[i] = globalcellorg[i];
}
} }
~EclPolyhedralGridVanguard() ~EclPolyhedralGridVanguard()
{ {
delete grid_;
} }
/*! /*!
@ -155,7 +166,8 @@ public:
* (For parallel simulation runs.) * (For parallel simulation runs.)
*/ */
void loadBalance() void loadBalance()
{ /* do nothing: PolyhedralGrid is not parallel! */ } { /* do nothing: PolyhedralGrid is not parallel! */
}
/*! /*!
* \brief Returns the object which maps a global element index of the simulation grid * \brief Returns the object which maps a global element index of the simulation grid
@ -173,6 +185,18 @@ public:
const CartesianIndexMapper& equilCartesianIndexMapper() const const CartesianIndexMapper& equilCartesianIndexMapper() const
{ return *cartesianIndexMapper_; } { return *cartesianIndexMapper_; }
const std::vector<int>& globalCell()
{
return globalcell_;
}
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const {
return elemIndex;
}
unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const {
return elemIndex;
}
/*! /*!
* \brief Free the memory occupied by the global transmissibility object. * \brief Free the memory occupied by the global transmissibility object.
@ -204,11 +228,17 @@ public:
return this->cellCentroids_(this->cartesianIndexMapper()); return this->cellCentroids_(this->cartesianIndexMapper());
} }
std::vector<int> cellPartition() const
{
// not required for this type of grid yet (only from bdaBridge??)
return {};
}
protected: protected:
void createGrids_() void createGrids_()
{ {
grid_ = new Grid(this->eclState().getInputGrid(), this->eclState().fieldProps().porv(true)); grid_ = std::make_unique<Grid>(this->eclState().getInputGrid(), this->eclState().fieldProps().porv(true));
cartesianIndexMapper_ = std::make_unique<CartesianIndexMapper>(*grid_); cartesianIndexMapper_ = std::make_unique<CartesianIndexMapper>(*grid_);
this->updateGridView_();
this->updateCartesianToCompressedMapping_(); this->updateCartesianToCompressedMapping_();
this->updateCellDepths_(); this->updateCellDepths_();
} }
@ -220,10 +250,12 @@ protected:
Simulator& simulator_; Simulator& simulator_;
GridPointer grid_; std::unique_ptr<Grid> grid_;
CartesianIndexMapperPointer cartesianIndexMapper_; std::unique_ptr<CartesianIndexMapper> cartesianIndexMapper_;
//CartesianIndexMapperPointer cartesianIndexMapper_;
std::unordered_set<std::string> defunctWellNames_; std::unordered_set<std::string> defunctWellNames_;
std::vector<int> globalcell_;
}; };
} // namespace Opm } // namespace Opm

View File

@ -34,6 +34,7 @@
#include <ebos/eclactionhandler.hh> #include <ebos/eclactionhandler.hh>
#include <ebos/eclbaseaquifermodel.hh> #include <ebos/eclbaseaquifermodel.hh>
#include <ebos/eclcpgridvanguard.hh>
#include <ebos/ecldummygradientcalculator.hh> #include <ebos/ecldummygradientcalculator.hh>
#include <ebos/eclequilinitializer.hh> #include <ebos/eclequilinitializer.hh>
#include <ebos/eclfluxmodule.hh> #include <ebos/eclfluxmodule.hh>
@ -84,15 +85,6 @@
#include <opm/common/OpmLog/OpmLog.hpp> #include <opm/common/OpmLog/OpmLog.hpp>
#if USE_ALUGRID
#define DISABLE_ALUGRID_SFC_ORDERING 1
#include <ebos/eclalugridvanguard.hh>
#elif USE_POLYHEDRALGRID
#include <ebos/eclpolyhedralgridvanguard.hh>
#else
#include <ebos/eclcpgridvanguard.hh>
#endif
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <set> #include <set>
@ -108,19 +100,9 @@ namespace Opm::Properties {
namespace TTag { namespace TTag {
#if USE_ALUGRID
struct EclBaseProblem {
using InheritsFrom = std::tuple<VtkEclTracer, EclOutputBlackOil, EclAluGridVanguard>;
};
#elif USE_POLYHEDRALGRID
struct EclBaseProblem {
using InheritsFrom = std::tuple<VtkEclTracer, EclOutputBlackOil, EclPolyhedralGridVanguard>;
};
#else
struct EclBaseProblem { struct EclBaseProblem {
using InheritsFrom = std::tuple<VtkEclTracer, EclOutputBlackOil, EclCpGridVanguard>; using InheritsFrom = std::tuple<VtkEclTracer, EclOutputBlackOil, EclCpGridVanguard>;
}; };
#endif
} }
// The class which deals with ECL wells // The class which deals with ECL wells
@ -207,6 +189,7 @@ struct NumPressurePointsEquil {
}; };
// Set the problem property // Set the problem property
template<class TypeTag> template<class TypeTag>
struct Problem<TypeTag, TTag::EclBaseProblem> { struct Problem<TypeTag, TTag::EclBaseProblem> {
@ -531,6 +514,10 @@ struct EnableTemperature<TypeTag, TTag::EclBaseProblem> {
static constexpr bool value = true; static constexpr bool value = true;
}; };
template<class TypeTag>
struct EnableMech<TypeTag, TTag::EclBaseProblem> {
static constexpr bool value = false;
};
// disable all extensions supported by black oil model. this should not really be // disable all extensions supported by black oil model. this should not really be
// necessary but it makes things a bit more explicit // necessary but it makes things a bit more explicit
template<class TypeTag> template<class TypeTag>
@ -891,12 +878,9 @@ public:
readThermalParameters_(); readThermalParameters_();
// Re-ordering in case of ALUGrid // Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> gridToEquilGrid; std::function<unsigned int(unsigned int)> gridToEquilGrid = [&simulator](unsigned int i) {
#if USE_ALUGRID
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i); return simulator.vanguard().gridIdxToEquilGridIdx(i);
}; };
#endif // USE_ALUGRID
transmissibilities_.finishInit(gridToEquilGrid); transmissibilities_.finishInit(gridToEquilGrid);
const auto& initconfig = eclState.getInitConfig(); const auto& initconfig = eclState.getInitConfig();
@ -936,12 +920,9 @@ public:
eclWriter_->setTransmissibilities(&simulator.problem().eclTransmissibilities()); eclWriter_->setTransmissibilities(&simulator.problem().eclTransmissibilities());
// Re-ordering in case of ALUGrid // Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> equilGridToGrid; std::function<unsigned int(unsigned int)> equilGridToGrid = [&simulator](unsigned int i) {
#if USE_ALUGRID
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i); return simulator.vanguard().gridEquilIdxToGridIdx(i);
}; };
#endif // USE_ALUGRID
eclWriter_->writeInit(equilGridToGrid); eclWriter_->writeInit(equilGridToGrid);
} }
@ -1030,12 +1011,9 @@ public:
eclBroadcast(cc, eclState.getTransMult() ); eclBroadcast(cc, eclState.getTransMult() );
// Re-ordering in case of ALUGrid // Re-ordering in case of ALUGrid
std::function<unsigned int(unsigned int)> equilGridToGrid; std::function<unsigned int(unsigned int)> equilGridToGrid = [&simulator](unsigned int i) {
#if USE_ALUGRID
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i); return simulator.vanguard().gridEquilIdxToGridIdx(i);
}; };
#endif // USE_ALUGRID
// re-compute all quantities which may possibly be affected. // re-compute all quantities which may possibly be affected.
transmissibilities_.update(true, equilGridToGrid); transmissibilities_.update(true, equilGridToGrid);
@ -1177,12 +1155,9 @@ public:
int episodeIdx = this->episodeIndex(); int episodeIdx = this->episodeIndex();
// Re-ordering in case of Alugrid // Re-ordering in case of Alugrid
std::function<unsigned int(unsigned int)> gridToEquilGrid; std::function<unsigned int(unsigned int)> gridToEquilGrid = [&simulator](unsigned int i) {
#if USE_ALUGRID
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i); return simulator.vanguard().gridIdxToEquilGridIdx(i);
}; };
#endif // USE_ALUGRID
std::function<void(bool)> transUp = std::function<void(bool)> transUp =
[this,gridToEquilGrid](bool global) { [this,gridToEquilGrid](bool global) {

View File

@ -18,7 +18,8 @@
*/ */
#include "config.h" #include "config.h"
#include <opm/simulators/flow/Main.hpp> #include <opm/simulators/flow/Main.hpp>
#include <dune/alugrid/grid.hh>
#include <ebos/eclalugridvanguard.hh>
namespace Opm { namespace Opm {
namespace Properties { namespace Properties {
namespace TTag { namespace TTag {
@ -26,6 +27,21 @@ struct EclFlowProblemAlugrid {
using InheritsFrom = std::tuple<EclFlowProblem>; using InheritsFrom = std::tuple<EclFlowProblem>;
}; };
} }
template<class TypeTag>
struct Grid<TypeTag, TTag::EclFlowProblemAlugrid> {
static const int dim = 3;
using type = Dune::ALUGrid<dim, dim, Dune::cube, Dune::nonconforming,Dune::ALUGridMPIComm>;
};
// alugrid need cp grid as equilgrid
template<class TypeTag>
struct EquilGrid<TypeTag, TTag::EclFlowProblemAlugrid> {
using type = Dune::CpGrid;
};
template<class TypeTag>
struct Vanguard<TypeTag, TTag::EclFlowProblemAlugrid> {
using type = Opm::EclAluGridVanguard<TypeTag>;
};
template<class TypeTag> template<class TypeTag>
struct EclEnableAquifers<TypeTag, TTag::EclFlowProblemAlugrid> { struct EclEnableAquifers<TypeTag, TTag::EclFlowProblemAlugrid> {
static constexpr bool value = false; static constexpr bool value = false;

View File

@ -1,25 +0,0 @@
/*
Copyright 2020, NORCE AS
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 3 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/>.
*/
#include "config.h"
#include <flow/flow_ebos_blackoil_poly.hpp>
int main(int argc, char** argv)
{
return Opm::flowEbosBlackoilPolyMain(argc, argv);
}

View File

@ -18,6 +18,11 @@
*/ */
#include "config.h" #include "config.h"
#include <opm/simulators/flow/Main.hpp> #include <opm/simulators/flow/Main.hpp>
#include <opm/grid/polyhedralgrid.hh>
#include <ebos/eclpolyhedralgridvanguard.hh>
#include <ebos/equil/initstateequil_impl.hh>
#include <opm/models/blackoil/blackoillocalresidualtpfa.hh>
#include <opm/models/discretization/common/tpfalinearizer.hh>
namespace Opm { namespace Opm {
namespace Properties { namespace Properties {
@ -26,9 +31,33 @@ namespace Properties {
using InheritsFrom = std::tuple<EclFlowProblem>; using InheritsFrom = std::tuple<EclFlowProblem>;
}; };
} }
}
int flowEbosBlackoilPolyMain(int argc, char** argv) template<class TypeTag>
struct Linearizer<TypeTag, TTag::EclFlowProblemPoly> { using type = TpfaLinearizer<TypeTag>; };
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::EclFlowProblemPoly> { using type = BlackOilLocalResidualTPFA<TypeTag>; };
template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::EclFlowProblemPoly> { static constexpr bool value = false; };
template<class TypeTag>
struct Grid<TypeTag, TTag::EclFlowProblemPoly> {
using type = Dune::PolyhedralGrid<3, 3>;
};
template<class TypeTag>
struct EquilGrid<TypeTag, TTag::EclFlowProblemPoly> {
//using type = Dune::CpGrid;
using type = GetPropType<TypeTag, Properties::Grid>;
};
template<class TypeTag>
struct Vanguard<TypeTag, TTag::EclFlowProblemPoly> {
using type = Opm::EclPolyhedralGridVanguard<TypeTag>;
};
}
}
int main(int argc, char** argv)
{ {
using TypeTag = Opm::Properties::TTag::EclFlowProblemPoly; using TypeTag = Opm::Properties::TTag::EclFlowProblemPoly;
auto mainObject = std::make_unique<Opm::Main>(argc, argv); auto mainObject = std::make_unique<Opm::Main>(argc, argv);
@ -37,5 +66,3 @@ int flowEbosBlackoilPolyMain(int argc, char** argv)
mainObject.reset(); mainObject.reset();
return ret; return ret;
} }
}

View File

@ -1,29 +0,0 @@
/*
Copyright 2013, 2014, 2015 SINTEF ICT, Applied Mathematics.
Copyright 2014 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015, 2017 IRIS AS
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 3 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/>.
*/
#ifndef FLOW_BLACKOIL_POLY_HPP
#define FLOW_BLACKOIL_POLY_HPP
namespace Opm {
int flowEbosBlackoilPolyMain(int argc, char** argv);
}
#endif

View File

@ -37,10 +37,8 @@
#include <opm/simulators/aquifers/AquiferNumerical.hpp> #include <opm/simulators/aquifers/AquiferNumerical.hpp>
#include <opm/grid/CpGrid.hpp> #include <opm/grid/CpGrid.hpp>
#ifdef USE_POLYHEDRALGRID
#include <opm/grid/polyhedralgrid.hh> #include <opm/grid/polyhedralgrid.hh>
#endif #if HAVE_DUNE_ALUGRID
#if USE_ALUGRID
#include <dune/alugrid/grid.hh> #include <dune/alugrid/grid.hh>
#endif #endif
@ -65,14 +63,12 @@ class SupportsFaceTag<Dune::CpGrid>
{}; {};
#ifdef USE_POLYHEDRALGRID
template<> template<>
class SupportsFaceTag<Dune::PolyhedralGrid<3, 3>> class SupportsFaceTag<Dune::PolyhedralGrid<3, 3>>
: public std::bool_constant<true> : public std::bool_constant<true>
{}; {};
#endif
#if USE_ALUGRID #if HAVE_DUNE_ALUGRID
template<> template<>
class SupportsFaceTag<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>> class SupportsFaceTag<Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>>
: public std::bool_constant<true> : public std::bool_constant<true>

View File

@ -43,6 +43,8 @@
#include <ebos/alucartesianindexmapper.hh> #include <ebos/alucartesianindexmapper.hh>
#endif // HAVE_DUNE_ALUGRID #endif // HAVE_DUNE_ALUGRID
#include <opm/grid/polyhedralgrid.hh>
namespace Opm { namespace Opm {
namespace detail { namespace detail {
@ -387,7 +389,7 @@ using CommunicationType = Dune::CollectiveCommunication<int>;
const std::vector<Well>&, \ const std::vector<Well>&, \
const std::vector<int>&, \ const std::vector<int>&, \
const size_t, const bool); const size_t, const bool);
using PolyHedralGrid3D = Dune::PolyhedralGrid<3, 3>;
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
#if HAVE_MPI #if HAVE_MPI
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>; using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>;
@ -398,11 +400,13 @@ using CommunicationType = Dune::CollectiveCommunication<int>;
template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \ template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \
INSTANCE_GRID(Dim,Dune::CpGrid) \ INSTANCE_GRID(Dim,Dune::CpGrid) \
INSTANCE_GRID(Dim,ALUGrid3CN) \ INSTANCE_GRID(Dim,ALUGrid3CN) \
INSTANCE_GRID(Dim,PolyHedralGrid3D) \
INSTANCE_FLEX(Dim) INSTANCE_FLEX(Dim)
#else #else
#define INSTANCE(Dim) \ #define INSTANCE(Dim) \
template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \ template struct BdaSolverInfo<BM<Dim>,BV<Dim>>; \
INSTANCE_GRID(Dim,Dune::CpGrid) \ INSTANCE_GRID(Dim,Dune::CpGrid) \
INSTANCE_GRID(Dim,PolyHedralGrid3D) \
INSTANCE_FLEX(Dim) INSTANCE_FLEX(Dim)
#endif #endif
#else #else