Merge pull request #3992 from akva2/ecl_modernization

Some small modernization changes in ecl classes
This commit is contained in:
Bård Skaflestad 2022-08-10 13:26:25 +02:00 committed by GitHub
commit 766543dd18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 74 additions and 74 deletions

View File

@ -85,7 +85,7 @@ public:
int idx_;
};
typedef typename Dune::PersistentContainer<Grid, GlobalCellIndex> GlobalIndexContainer;
using GlobalIndexContainer = typename Dune::PersistentContainer<Grid, GlobalCellIndex>;
public:
// constructor copying cartesian index to persistent container
@ -174,7 +174,7 @@ public:
public:
/** \brief dimension of the grid */
static const int dimension = Grid::dimension ;
static constexpr int dimension = Grid::dimension ;
/** \brief constructor taking grid */
CartesianIndexMapper(const Grid& grid,
@ -222,17 +222,17 @@ public:
void cartesianCoordinate(const int compressedElementIndex, std::array<int, dimension>& coords) const
{
int gc = cartesianIndex(compressedElementIndex);
if (dimension == 3) {
if constexpr (dimension == 3) {
coords[0] = gc % cartesianDimensions()[0];
gc /= cartesianDimensions()[0];
coords[1] = gc % cartesianDimensions()[1];
coords[2] = gc / cartesianDimensions()[1];
}
else if (dimension == 2) {
else if constexpr (dimension == 2) {
coords[0] = gc % cartesianDimensions()[0];
coords[1] = gc / cartesianDimensions()[0];
}
else if (dimension == 1)
else if constexpr (dimension == 1)
coords[0] = gc ;
else
throw std::invalid_argument("cartesianCoordinate not implemented for dimension " + std::to_string(dimension));
@ -241,7 +241,7 @@ public:
template <class GridView>
std::unique_ptr<GlobalIndexDataHandle<GridView> > dataHandle(const GridView& gridView)
{
typedef GlobalIndexDataHandle<GridView> DataHandle ;
using DataHandle = GlobalIndexDataHandle<GridView>;
assert(&grid_ == &gridView.grid());
return std::make_unique<DataHandle>(gridView, cartesianIndex_);
}

View File

@ -52,7 +52,7 @@ public:
using IndexMapType = std::vector<int>;
using IndexMapStorageType = std::vector<IndexMapType>;
static const int dimension = Grid::dimension;
static constexpr int dimension = Grid::dimension;
enum { ioRank = 0 };

View File

@ -85,7 +85,7 @@ template <class TypeTag>
class EclAluGridVanguard : public EclBaseVanguard<TypeTag>
{
friend class EclBaseVanguard<TypeTag>;
typedef EclBaseVanguard<TypeTag> ParentType;
using ParentType = EclBaseVanguard<TypeTag>;
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
@ -95,13 +95,13 @@ public:
using Grid = GetPropType<TypeTag, Properties::Grid>;
using EquilGrid = GetPropType<TypeTag, Properties::EquilGrid>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
typedef Dune::CartesianIndexMapper<Grid> CartesianIndexMapper;
typedef Dune::CartesianIndexMapper<EquilGrid> EquilCartesianIndexMapper;
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using EquilCartesianIndexMapper = Dune::CartesianIndexMapper<EquilGrid>;
using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper, CartesianIndexMapper, Scalar>;
typedef Dune::FromToGridFactory<Grid> Factory;
using Factory = Dune::FromToGridFactory<Grid>;
static const int dimension = Grid::dimension;
static const int dimensionworld = Grid::dimensionworld;
static constexpr int dimension = Grid::dimension;
static constexpr int dimensionworld = Grid::dimensionworld;
public:
EclAluGridVanguard(Simulator& simulator)
: EclBaseVanguard<TypeTag>(simulator)
@ -146,10 +146,10 @@ public:
void releaseEquilGrid()
{
delete equilCartesianIndexMapper_;
equilCartesianIndexMapper_ = 0;
equilCartesianIndexMapper_ = nullptr;
delete equilGrid_;
equilGrid_ = 0;
equilGrid_ = nullptr;
}
/*!
@ -170,17 +170,17 @@ public:
if (grid().size(0))
{
globalTrans_.reset(new TransmissibilityType(this->eclState(),
this->gridView(),
this->cartesianIndexMapper(),
this->grid(),
this->cellCentroids(),
getPropValue<TypeTag,
Properties::EnableEnergy>(),
getPropValue<TypeTag,
Properties::EnableDiffusion>()));
// Re-ordering for ALUGrid
globalTrans_->update(false, [&](unsigned int i) { return gridEquilIdxToGridIdx(i);});
globalTrans_ = std::make_unique<TransmissibilityType>(this->eclState(),
this->gridView(),
this->cartesianIndexMapper(),
this->grid(),
this->cellCentroids(),
getPropValue<TypeTag,
Properties::EnableEnergy>(),
getPropValue<TypeTag,
Properties::EnableDiffusion>());
// Re-ordering for ALUGrid
globalTrans_->update(false, [&](unsigned int i) { return gridEquilIdxToGridIdx(i);});
}
}
@ -293,7 +293,7 @@ protected:
}
this->equilGrid_ = std::make_unique<Dune::CpGrid>(EclGenericVanguard::comm());
// Note: removed_cells is guaranteed to be empty on ranks other than 0.
// Note: removed_cells is guaranteed to be empty on ranks other than 0.
auto removed_cells =
this->equilGrid_->processEclipseFormat(input_grid,
&this->eclState(),

View File

@ -79,7 +79,7 @@ class EclCpGridVanguard : public EclBaseVanguard<TypeTag>
GetPropType<TypeTag, Properties::Scalar>>
{
friend class EclBaseVanguard<TypeTag>;
typedef EclBaseVanguard<TypeTag> ParentType;
using ParentType = EclBaseVanguard<TypeTag>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
@ -91,7 +91,7 @@ public:
using EquilGrid = GetPropType<TypeTag, Properties::EquilGrid>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper, CartesianIndexMapper, Scalar>;
static const int dimensionworld = Grid::dimensionworld;
static constexpr int dimensionworld = Grid::dimensionworld;
private:
using Element = typename GridView::template Codim<0>::Entity;

View File

@ -52,7 +52,7 @@ class EclDummyGradientCalculator
enum { dimWorld = GridView::dimensionworld };
typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
using DimVector = Dune::FieldVector<Scalar, dimWorld>;
public:
static void registerParameters()

View File

@ -156,11 +156,11 @@ public:
}
// set the salt concentration
if (enableBrine)
if constexpr (enableBrine)
fluidState.setSaltConcentration(initialState.saltConcentration()[elemIdx]);
//set the (solid) salt saturation
if (enableSaltPrecipitation)
if constexpr (enableSaltPrecipitation)
fluidState.setSaltSaturation(initialState.saltSaturation()[elemIdx]);
}
}

View File

@ -58,9 +58,9 @@ class EclTransBaseProblem;
template <class TypeTag>
struct EclTransFluxModule
{
typedef EclTransIntensiveQuantities<TypeTag> FluxIntensiveQuantities;
typedef EclTransExtensiveQuantities<TypeTag> FluxExtensiveQuantities;
typedef EclTransBaseProblem<TypeTag> FluxBaseProblem;
using FluxIntensiveQuantities = EclTransIntensiveQuantities<TypeTag>;
using FluxExtensiveQuantities = EclTransExtensiveQuantities<TypeTag>;
using FluxBaseProblem = EclTransBaseProblem<TypeTag>;
/*!
* \brief Register all run-time parameters for the flux module.
@ -115,10 +115,10 @@ class EclTransExtensiveQuantities
enum { enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
typedef MathToolbox<Evaluation> Toolbox;
typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
typedef Dune::FieldVector<Evaluation, dimWorld> EvalDimVector;
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
using Toolbox = MathToolbox<Evaluation>;
using DimVector = Dune::FieldVector<Scalar, dimWorld>;
using EvalDimVector = Dune::FieldVector<Evaluation, dimWorld>;
using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
public:
/*!

View File

@ -51,7 +51,7 @@ public:
using TracerMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, 1, 1>>;
using TracerVector = Dune::BlockVector<Dune::FieldVector<Scalar,1>>;
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
static const int dimWorld = Grid::dimensionworld;
static constexpr int dimWorld = Grid::dimensionworld;
/*!
* \brief Return the number of tracers considered by the tracerModel.
*/

View File

@ -65,9 +65,9 @@ namespace Opm {
template <class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>
class EclGenericWriter
{
typedef Dune::CartesianIndexMapper<Grid> CartesianIndexMapper;
typedef Dune::CartesianIndexMapper<EquilGrid> EquilCartesianIndexMapper;
{
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using EquilCartesianIndexMapper = Dune::CartesianIndexMapper<EquilGrid>;
using CollectDataToIORankType = CollectDataToIORank<Grid,EquilGrid,GridView>;
using TransmissibilityType = EclTransmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>;
@ -103,7 +103,7 @@ public:
{
simulation_report_ = report;
}
protected:
const TransmissibilityType& globalTrans() const;
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const;

View File

@ -65,7 +65,7 @@ namespace Opm {
template <class TypeTag>
class EclNewtonMethod : public BlackOilNewtonMethod<TypeTag>
{
typedef BlackOilNewtonMethod<TypeTag> ParentType;
using ParentType = BlackOilNewtonMethod<TypeTag>;
using DiscNewtonMethod = GetPropType<TypeTag, Properties::DiscNewtonMethod>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
@ -79,7 +79,7 @@ class EclNewtonMethod : public BlackOilNewtonMethod<TypeTag>
using Linearizer = GetPropType<TypeTag, Properties::Linearizer>;
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
static const unsigned numEq = getPropValue<TypeTag, Properties::NumEq>();
static constexpr unsigned numEq = getPropValue<TypeTag, Properties::NumEq>();
static constexpr int contiSolventEqIdx = Indices::contiSolventEqIdx;
static constexpr int contiPolymerEqIdx = Indices::contiPolymerEqIdx;

View File

@ -76,7 +76,7 @@ template <class TypeTag>
class EclPolyhedralGridVanguard : public EclBaseVanguard<TypeTag>
{
friend class EclBaseVanguard<TypeTag>;
typedef EclBaseVanguard<TypeTag> ParentType;
using ParentType = EclBaseVanguard<TypeTag>;
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
@ -89,10 +89,10 @@ public:
using TransmissibilityType = EclTransmissibility<Grid, GridView, ElementMapper, Scalar>;
private:
typedef Grid* GridPointer;
typedef EquilGrid* EquilGridPointer;
typedef Dune::CartesianIndexMapper<Grid> CartesianIndexMapper;
typedef std::unique_ptr<CartesianIndexMapper> CartesianIndexMapperPointer;
using GridPointer = Grid*;
using EquilGridPointer = EquilGrid*;
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using CartesianIndexMapperPointer = std::unique_ptr<CartesianIndexMapper>;
public:
EclPolyhedralGridVanguard(Simulator& simulator)

View File

@ -869,10 +869,10 @@ public:
#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 (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
if constexpr (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
transmissibilities_.finishInit(gridToEquilGrid);
@ -1046,10 +1046,10 @@ public:
using Grid = GetPropType<TypeTag, Properties::Grid>;
typename std::is_same<Grid, Dune::ALUGrid<3, 3, Dune::cube,
Dune::nonconforming>>::type isAlugrid;
if (isAlugrid) {
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
if constexpr (isAlugrid) {
equilGridToGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridEquilIdxToGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
@ -1197,10 +1197,10 @@ public:
#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 (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
if constexpr (isAlugrid) {
gridToEquilGrid = [&simulator](unsigned int i) {
return simulator.vanguard().gridIdxToEquilGridIdx(i);
};
}
#endif // HAVE_DUNE_ALUGRID
@ -2766,11 +2766,11 @@ private:
tempiData = fp.get_double("TEMPI");
// initial salt concentration data
if (enableBrine)
if constexpr (enableBrine)
saltData = fp.get_double("SALT");
// initial precipitated salt saturation data
if (enableSaltPrecipitation)
if constexpr (enableSaltPrecipitation)
saltpData = fp.get_double("SALTP");
// calculate the initial fluid states
@ -2790,13 +2790,13 @@ private:
//////
// set salt concentration
//////
if (enableBrine)
if constexpr (enableBrine)
dofFluidState.setSaltConcentration(saltData[dofIdx]);
//////
// set precipitated salt saturation
//////
if (enableSaltPrecipitation)
if constexpr (enableSaltPrecipitation)
dofFluidState.setSaltSaturation(saltpData[dofIdx]);
//////

View File

@ -101,7 +101,7 @@ private:
const auto& vanguard = simulator_.vanguard();
const auto& gridView = vanguard.gridView();
typedef MathToolbox<Evaluation> Toolbox;
using Toolbox = MathToolbox<Evaluation>;
// loop over the whole grid and compute the maximum gravity adjusted pressure
// difference between two EQUIL regions.
auto elemIt = gridView.template begin</*codim=*/ 0>();

View File

@ -57,8 +57,8 @@ namespace Fem {
template<int codim>
struct GridEntityAccess<Dune::cpgrid::Entity<codim> >
{
typedef Dune::cpgrid::Entity<codim> EntityType;
typedef EntityType GridEntityType;
using EntityType = Dune::cpgrid::Entity<codim>;
using GridEntityType = EntityType;
static const GridEntityType& gridEntity(const EntityType& entity)
{ return entity; }

View File

@ -70,7 +70,7 @@ namespace Opm {
template <class TypeTag>
class VtkEclTracerModule : public BaseOutputModule<TypeTag>
{
typedef BaseOutputModule<TypeTag> ParentType;
using ParentType = BaseOutputModule<TypeTag>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
@ -80,11 +80,11 @@ namespace Opm {
using GridView = GetPropType<TypeTag, Properties::GridView>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
static const int vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
typedef ::Opm::VtkMultiWriter<GridView, vtkFormat> VtkMultiWriter;
static constexpr int vtkFormat = getPropValue<TypeTag, Properties::VtkOutputFormat>();
using VtkMultiWriter = ::Opm::VtkMultiWriter<GridView, vtkFormat>;
typedef typename ParentType::ScalarBuffer ScalarBuffer;
using ScalarBuffer = typename ParentType::ScalarBuffer;
public:
VtkEclTracerModule(const Simulator& simulator)