2016-01-05 12:32:36 -06:00
|
|
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
// vi: set et ts=4 sw=4 sts=4:
|
|
|
|
/*
|
|
|
|
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 2 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/>.
|
2016-03-14 07:21:47 -05:00
|
|
|
|
|
|
|
Consult the COPYING file in the top-level source directory of this
|
|
|
|
module for the precise wording of the license and the list of
|
|
|
|
copyright holders.
|
2016-01-05 12:32:36 -06:00
|
|
|
*/
|
|
|
|
/*!
|
|
|
|
* \file
|
2019-09-05 10:04:39 -05:00
|
|
|
* \copydoc Opm::EclBaseVanguard
|
2016-01-05 12:32:36 -06:00
|
|
|
*/
|
2018-02-01 09:26:58 -06:00
|
|
|
#ifndef EWOMS_ECL_BASE_VANGUARD_HH
|
|
|
|
#define EWOMS_ECL_BASE_VANGUARD_HH
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2019-09-16 03:13:06 -05:00
|
|
|
#include <opm/models/io/basevanguard.hh>
|
2019-09-16 03:58:20 -05:00
|
|
|
#include <opm/models/utils/propertysystem.hh>
|
|
|
|
#include <opm/models/utils/parametersystem.hh>
|
2020-05-15 02:23:01 -05:00
|
|
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
2021-05-05 05:13:25 -05:00
|
|
|
#include <ebos/eclgenericvanguard.hh>
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
#include <opm/grid/common/GridEnums.hpp>
|
|
|
|
#include <opm/grid/common/CartesianIndexMapper.hpp>
|
2021-12-14 01:30:15 -06:00
|
|
|
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp>
|
|
|
|
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
2021-05-15 07:41:05 -05:00
|
|
|
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
|
2016-12-30 07:09:51 -06:00
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
#include <array>
|
2021-05-05 05:13:25 -05:00
|
|
|
#include <optional>
|
2019-09-19 17:49:40 -05:00
|
|
|
#include <unordered_set>
|
|
|
|
#include <vector>
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2016-01-05 12:32:36 -06:00
|
|
|
template <class TypeTag>
|
2018-02-01 09:26:58 -06:00
|
|
|
class EclBaseVanguard;
|
2018-06-14 09:06:05 -05:00
|
|
|
}
|
|
|
|
|
2020-08-21 06:42:08 -05:00
|
|
|
namespace Opm::Properties {
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2020-08-27 03:30:29 -05:00
|
|
|
namespace TTag {
|
|
|
|
struct EclBaseVanguard {};
|
|
|
|
}
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2018-02-01 09:26:58 -06:00
|
|
|
// declare the properties required by the for the ecl simulator vanguard
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EquilGrid {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EnableOpmRstFile {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EclStrictParsing {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct SchedRestart {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EclOutputInterval {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct IgnoreKeywords {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct EdgeWeightsMethod {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct OwnerCellsFirst {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2020-09-29 09:14:45 -05:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct SerialPartitioning {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
|
2021-01-06 04:52:48 -06:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct ZoltanImbalanceTol {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
|
2021-01-21 05:39:58 -06:00
|
|
|
template<class TypeTag, class MyTypeTag>
|
|
|
|
struct AllowDistributedWells {
|
|
|
|
using type = UndefinedProperty;
|
|
|
|
};
|
|
|
|
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct IgnoreKeywords<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr auto value = "";
|
|
|
|
};
|
|
|
|
template<class TypeTag>
|
|
|
|
struct EclDeckFileName<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr auto value = "";
|
|
|
|
};
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct EclOutputInterval<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr int value = -1;
|
|
|
|
};
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct EnableOpmRstFile<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = false;
|
|
|
|
};
|
|
|
|
template<class TypeTag>
|
|
|
|
struct EclStrictParsing<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = false;
|
|
|
|
};
|
|
|
|
template<class TypeTag>
|
|
|
|
struct SchedRestart<TypeTag, TTag::EclBaseVanguard> {
|
2021-10-25 05:14:33 -05:00
|
|
|
static constexpr bool value = false;
|
2020-08-27 04:38:38 -05:00
|
|
|
};
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct EdgeWeightsMethod<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr int value = 1;
|
|
|
|
};
|
2020-08-27 04:38:38 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct OwnerCellsFirst<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = true;
|
|
|
|
};
|
2020-09-29 09:14:45 -05:00
|
|
|
template<class TypeTag>
|
|
|
|
struct SerialPartitioning<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = false;
|
|
|
|
};
|
2018-06-14 09:06:05 -05:00
|
|
|
|
2021-01-06 04:52:48 -06:00
|
|
|
template<class TypeTag>
|
|
|
|
struct ZoltanImbalanceTol<TypeTag, TTag::EclBaseVanguard> {
|
2021-05-04 02:43:38 -05:00
|
|
|
static constexpr double value = 1.1;
|
2021-01-06 04:52:48 -06:00
|
|
|
};
|
|
|
|
|
2021-01-21 05:39:58 -06:00
|
|
|
template<class TypeTag>
|
|
|
|
struct AllowDistributedWells<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = false;
|
|
|
|
};
|
2021-01-25 07:48:30 -06:00
|
|
|
|
2021-01-27 07:41:10 -06:00
|
|
|
template<class T1, class T2>
|
|
|
|
struct UseMultisegmentWell;
|
|
|
|
|
2021-01-25 07:48:30 -06:00
|
|
|
// Same as in BlackoilModelParametersEbos.hpp but for here.
|
|
|
|
template<class TypeTag>
|
|
|
|
struct UseMultisegmentWell<TypeTag, TTag::EclBaseVanguard> {
|
|
|
|
static constexpr bool value = true;
|
|
|
|
};
|
2020-08-21 06:42:08 -05:00
|
|
|
} // namespace Opm::Properties
|
2018-06-14 09:06:05 -05:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2016-01-05 12:32:36 -06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \ingroup EclBlackOilSimulator
|
|
|
|
*
|
|
|
|
* \brief Helper class for grid instantiation of ECL file-format using problems.
|
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
2021-05-05 05:13:25 -05:00
|
|
|
class EclBaseVanguard : public BaseVanguard<TypeTag>,
|
|
|
|
public EclGenericVanguard
|
2016-01-05 12:32:36 -06:00
|
|
|
{
|
2020-08-26 03:49:52 -05:00
|
|
|
using ParentType = BaseVanguard<TypeTag>;
|
|
|
|
using Implementation = GetPropType<TypeTag, Properties::Vanguard>;
|
|
|
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
|
|
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
2020-12-08 09:09:01 -06:00
|
|
|
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
|
2016-01-05 12:32:36 -06:00
|
|
|
|
2020-08-27 02:13:30 -05:00
|
|
|
enum { enableExperiments = getPropValue<TypeTag, Properties::EnableExperiments>() };
|
2019-04-04 07:37:37 -05:00
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
public:
|
2020-08-26 03:49:52 -05:00
|
|
|
using Grid = GetPropType<TypeTag, Properties::Grid>;
|
|
|
|
using GridView = GetPropType<TypeTag, Properties::GridView>;
|
2016-01-05 12:32:36 -06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static const int dimension = Grid::dimension;
|
2021-09-30 04:50:22 -05:00
|
|
|
static const int dimensionworld = Grid::dimensionworld;
|
2020-12-08 09:09:01 -06:00
|
|
|
using Element = typename GridView::template Codim<0>::Entity;
|
2021-01-07 04:41:25 -06:00
|
|
|
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
|
2020-12-08 09:09:01 -06:00
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
|
|
|
|
public:
|
|
|
|
/*!
|
2018-02-01 09:26:58 -06:00
|
|
|
* \brief Register the common run-time parameters for all ECL simulator vanguards.
|
2016-01-05 12:32:36 -06:00
|
|
|
*/
|
|
|
|
static void registerParameters()
|
|
|
|
{
|
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, std::string, EclDeckFileName,
|
|
|
|
"The name of the file which contains the ECL deck to be simulated");
|
2018-06-15 07:34:50 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, int, EclOutputInterval,
|
|
|
|
"The number of report steps that ought to be skipped between two writes of ECL results");
|
2018-09-17 04:21:49 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, EnableOpmRstFile,
|
|
|
|
"Include OPM-specific keywords in the ECL restart file to enable restart of OPM simulators from these files");
|
2018-10-08 16:24:58 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, std::string, IgnoreKeywords,
|
|
|
|
"List of Eclipse keywords which should be ignored. As a ':' separated string.");
|
2019-01-07 09:02:13 -06:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, EclStrictParsing,
|
|
|
|
"Use strict mode for parsing - all errors are collected before the applicaton exists.");
|
2020-03-04 08:17:30 -06:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, SchedRestart,
|
|
|
|
"When restarting: should we try to initialize wells and groups from historical SCHEDULE section.");
|
2019-07-08 08:50:34 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, int, EdgeWeightsMethod,
|
|
|
|
"Choose edge-weighing strategy: 0=uniform, 1=trans, 2=log(trans).");
|
2020-03-08 09:45:27 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, OwnerCellsFirst,
|
2019-12-05 08:49:10 -06:00
|
|
|
"Order cells owned by rank before ghost/overlap cells.");
|
2020-09-29 09:14:45 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, SerialPartitioning,
|
|
|
|
"Perform partitioning for parallel runs on a single process.");
|
2021-05-04 02:43:38 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, double, ZoltanImbalanceTol,
|
2021-01-21 05:39:58 -06:00
|
|
|
"Tolerable imbalance of the loadbalancing provided by Zoltan (default: 1.1).");
|
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, AllowDistributedWells,
|
|
|
|
"Allow the perforations of a well to be distributed to interior of multiple processes");
|
2021-01-25 07:48:30 -06:00
|
|
|
// register here for the use in the tests without BlackoildModelParametersEbos
|
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, UseMultisegmentWell, "Use the well model for multi-segment wells instead of the one for single-segment wells");
|
2021-01-06 04:52:48 -06:00
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Create the grid for problem data files which use the ECL file format.
|
|
|
|
*
|
|
|
|
* This is the file format used by the commercial ECLiPSE simulator. Usually it uses
|
|
|
|
* a cornerpoint description of the grid.
|
|
|
|
*/
|
2018-02-01 09:26:58 -06:00
|
|
|
EclBaseVanguard(Simulator& simulator)
|
2016-01-05 12:32:36 -06:00
|
|
|
: ParentType(simulator)
|
|
|
|
{
|
2021-05-05 05:13:25 -05:00
|
|
|
fileName_ = EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName);
|
2019-07-08 08:50:34 -05:00
|
|
|
edgeWeightsMethod_ = Dune::EdgeWeightMethod(EWOMS_GET_PARAM(TypeTag, int, EdgeWeightsMethod));
|
2020-03-08 09:45:27 -05:00
|
|
|
ownersFirst_ = EWOMS_GET_PARAM(TypeTag, bool, OwnerCellsFirst);
|
2020-09-29 09:14:45 -05:00
|
|
|
serialPartitioning_ = EWOMS_GET_PARAM(TypeTag, bool, SerialPartitioning);
|
2021-05-04 02:43:38 -05:00
|
|
|
zoltanImbalanceTol_ = EWOMS_GET_PARAM(TypeTag, double, ZoltanImbalanceTol);
|
2021-01-21 05:39:58 -06:00
|
|
|
enableDistributedWells_ = EWOMS_GET_PARAM(TypeTag, bool, AllowDistributedWells);
|
2021-05-05 05:13:25 -05:00
|
|
|
ignoredKeywords_ = EWOMS_GET_PARAM(TypeTag, std::string, IgnoreKeywords);
|
|
|
|
eclStrictParsing_ = EWOMS_GET_PARAM(TypeTag, bool, EclStrictParsing);
|
2021-03-08 10:17:09 -06:00
|
|
|
int output_param = EWOMS_GET_PARAM(TypeTag, int, EclOutputInterval);
|
|
|
|
if (output_param >= 0)
|
2021-05-05 05:13:25 -05:00
|
|
|
outputInterval_ = output_param;
|
|
|
|
useMultisegmentWell_ = EWOMS_GET_PARAM(TypeTag, bool, UseMultisegmentWell);
|
|
|
|
enableExperiments_ = enableExperiments;
|
2019-01-07 03:04:44 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
init();
|
2016-01-05 12:32:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-07 04:41:25 -06:00
|
|
|
const CartesianIndexMapper& cartesianMapper() const
|
|
|
|
{ return asImp_().cartesianIndexMapper(); }
|
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
/*!
|
|
|
|
* \brief Returns the number of logically Cartesian cells in each direction
|
|
|
|
*/
|
|
|
|
const std::array<int, dimension>& cartesianDimensions() const
|
|
|
|
{ return asImp_().cartesianIndexMapper().cartesianDimensions(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the overall number of cells of the logically Cartesian grid
|
|
|
|
*/
|
|
|
|
int cartesianSize() const
|
|
|
|
{ return asImp_().cartesianIndexMapper().cartesianSize(); }
|
2016-12-02 11:47:59 -06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the overall number of cells of the logically EquilCartesian grid
|
|
|
|
*/
|
|
|
|
int equilCartesianSize() const
|
|
|
|
{ return asImp_().equilCartesianIndexMapper().cartesianSize(); }
|
2016-01-05 12:32:36 -06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the Cartesian cell id for identifaction with ECL data
|
|
|
|
*/
|
|
|
|
unsigned cartesianIndex(unsigned compressedCellIdx) const
|
|
|
|
{ return asImp_().cartesianIndexMapper().cartesianIndex(compressedCellIdx); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Return the index of the cells in the logical Cartesian grid
|
|
|
|
*/
|
|
|
|
unsigned cartesianIndex(const std::array<int,dimension>& coords) const
|
|
|
|
{
|
|
|
|
unsigned cartIndex = coords[0];
|
|
|
|
int factor = cartesianDimensions()[0];
|
|
|
|
for (unsigned i = 1; i < dimension; ++i) {
|
|
|
|
cartIndex += coords[i]*factor;
|
|
|
|
factor *= cartesianDimensions()[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return cartIndex;
|
|
|
|
}
|
|
|
|
|
2020-12-08 09:09:01 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return compressed index from cartesian index
|
|
|
|
*
|
2021-10-19 09:50:42 -05:00
|
|
|
* \return compressed index of cell is in interior, -1 otherwise
|
|
|
|
*
|
2020-12-08 09:09:01 -06:00
|
|
|
*/
|
|
|
|
int compressedIndex(int cartesianCellIdx) const
|
|
|
|
{
|
2021-09-22 02:22:25 -05:00
|
|
|
auto index_pair = cartesianToCompressed_.find(cartesianCellIdx);
|
|
|
|
if (index_pair!=cartesianToCompressed_.end())
|
|
|
|
return index_pair->second;
|
|
|
|
else
|
|
|
|
return -1;
|
2020-12-08 09:09:01 -06:00
|
|
|
}
|
|
|
|
|
2021-10-19 09:50:42 -05:00
|
|
|
/*!
|
|
|
|
* \brief Return compressed index from cartesian index only in interior
|
|
|
|
*
|
|
|
|
* \return compressed index of cell is in interior, -1 otherwise
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int compressedIndexForInterior(int cartesianCellIdx) const
|
|
|
|
{
|
|
|
|
auto index_pair = cartesianToCompressed_.find(cartesianCellIdx);
|
|
|
|
if (index_pair == cartesianToCompressed_.end() ||
|
|
|
|
!is_interior_[index_pair->second])
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return index_pair->second;
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 12:32:36 -06:00
|
|
|
/*!
|
|
|
|
* \brief Extract Cartesian index triplet (i,j,k) of an active cell.
|
|
|
|
*
|
|
|
|
* \param [in] cellIdx Active cell index.
|
|
|
|
* \param [out] ijk Cartesian index triplet
|
|
|
|
*/
|
|
|
|
void cartesianCoordinate(unsigned cellIdx, std::array<int,3>& ijk) const
|
|
|
|
{ return asImp_().cartesianIndexMapper().cartesianCoordinate(cellIdx, ijk); }
|
|
|
|
|
2016-01-17 14:15:18 -06:00
|
|
|
/*!
|
|
|
|
* \brief Returns the Cartesian cell id given an element index for the grid used for equilibration
|
|
|
|
*/
|
|
|
|
unsigned equilCartesianIndex(unsigned compressedEquilCellIdx) const
|
|
|
|
{ return asImp_().equilCartesianIndexMapper().cartesianIndex(compressedEquilCellIdx); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Extract Cartesian index triplet (i,j,k) of an active cell of the grid used for EQUIL.
|
|
|
|
*
|
|
|
|
* \param [in] cellIdx Active cell index.
|
|
|
|
* \param [out] ijk Cartesian index triplet
|
|
|
|
*/
|
|
|
|
void equilCartesianCoordinate(unsigned cellIdx, std::array<int,3>& ijk) const
|
|
|
|
{ return asImp_().equilCartesianIndexMapper().cartesianCoordinate(cellIdx, ijk); }
|
|
|
|
|
2020-09-22 07:12:15 -05:00
|
|
|
|
2020-12-08 09:09:01 -06:00
|
|
|
/*!
|
2020-09-24 14:51:59 -05:00
|
|
|
* \brief Returns the depth of a degree of freedom [m]
|
2020-12-08 09:09:01 -06:00
|
|
|
*
|
|
|
|
* For ECL problems this is defined as the average of the depth of an element and is
|
|
|
|
* thus slightly different from the depth of an element's centroid.
|
|
|
|
*/
|
|
|
|
Scalar cellCenterDepth(unsigned globalSpaceIdx) const
|
|
|
|
{
|
|
|
|
return cellCenterDepth_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
2021-05-25 08:49:14 -05:00
|
|
|
const std::vector<Scalar>& cellCenterDepths() const
|
|
|
|
{
|
|
|
|
return cellCenterDepth_;
|
|
|
|
}
|
|
|
|
|
2020-09-24 14:51:59 -05:00
|
|
|
/*!
|
|
|
|
* \brief Returns the thickness of a degree of freedom [m]
|
|
|
|
*
|
|
|
|
* For ECL problems this is defined as the average of the depths of the top surface
|
|
|
|
* corners minus the average of the depths of the bottom surface corners
|
|
|
|
* The cell thickness is computed only when needed.
|
|
|
|
*/
|
|
|
|
Scalar cellThickness(unsigned globalSpaceIdx) const
|
|
|
|
{
|
|
|
|
assert(!cellThickness_.empty());
|
|
|
|
return cellThickness_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
2020-10-05 05:43:55 -05:00
|
|
|
/*!
|
|
|
|
* \brief Get the number of cells in the global leaf grid view.
|
|
|
|
* \warn This is a collective operation that needs to be called
|
|
|
|
* on all ranks.
|
|
|
|
*/
|
2020-10-05 13:02:13 -05:00
|
|
|
std::size_t globalNumCells() const
|
2020-10-05 05:43:55 -05:00
|
|
|
{
|
|
|
|
const auto& grid = asImp_().grid();
|
|
|
|
if (grid.comm().size() == 1)
|
|
|
|
{
|
|
|
|
return grid.leafGridView().size(0);
|
|
|
|
}
|
|
|
|
const auto& gridView = grid.leafGridView();
|
2020-10-05 07:23:21 -05:00
|
|
|
constexpr int codim = 0;
|
|
|
|
constexpr auto Part = Dune::Interior_Partition;
|
|
|
|
auto local_cells = std::distance(gridView.template begin<codim, Part>(),
|
|
|
|
gridView.template end<codim, Part>());
|
|
|
|
return grid.comm().sum(local_cells);
|
2020-10-05 05:43:55 -05:00
|
|
|
}
|
|
|
|
|
2019-10-01 14:18:17 -05:00
|
|
|
protected:
|
2021-09-30 04:50:22 -05:00
|
|
|
/*!
|
|
|
|
* \brief Get function to query cell centroids for a distributed grid.
|
|
|
|
*
|
|
|
|
* Currently this only non-empty for a loadbalanced CpGrid.
|
|
|
|
* It is a function return the centroid for the given element
|
|
|
|
* index.
|
|
|
|
* \param cartMapper The cartesian index mapper for lookup of
|
|
|
|
* cartesian indices
|
|
|
|
*/
|
|
|
|
template<class CartMapper>
|
|
|
|
std::function<std::array<double,dimensionworld>(int)>
|
|
|
|
cellCentroids_(const CartMapper& cartMapper) const
|
|
|
|
{
|
|
|
|
return [this, cartMapper](int elemIdx) {
|
|
|
|
const auto& centroids = this->centroids_;
|
|
|
|
auto rank = this->gridView().comm().rank();
|
|
|
|
std::array<double,dimensionworld> centroid;
|
|
|
|
if (rank == 0) {
|
|
|
|
unsigned cartesianCellIdx = cartMapper.cartesianIndex(elemIdx);
|
|
|
|
centroid = this->eclState().getInputGrid().getCellCenter(cartesianCellIdx);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
std::copy(centroids.begin() + elemIdx * dimensionworld,
|
|
|
|
centroids.begin() + (elemIdx + 1) * dimensionworld,
|
|
|
|
centroid.begin());
|
|
|
|
}
|
|
|
|
return centroid;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-10-01 14:18:17 -05:00
|
|
|
void callImplementationInit()
|
|
|
|
{
|
|
|
|
asImp_().createGrids_();
|
|
|
|
asImp_().filterConnections_();
|
2021-05-04 02:23:43 -05:00
|
|
|
std::string outputDir = EWOMS_GET_PARAM(TypeTag, std::string, OutputDir);
|
|
|
|
bool enableEclCompatFile = !EWOMS_GET_PARAM(TypeTag, bool, EnableOpmRstFile);
|
|
|
|
asImp_().updateOutputDir_(outputDir, enableEclCompatFile);
|
2019-10-01 14:18:17 -05:00
|
|
|
asImp_().finalizeInit_();
|
|
|
|
}
|
2021-05-05 05:13:25 -05:00
|
|
|
|
2020-12-08 09:09:01 -06:00
|
|
|
void updateCartesianToCompressedMapping_()
|
|
|
|
{
|
|
|
|
size_t num_cells = asImp_().grid().leafGridView().size(0);
|
2021-10-19 09:50:42 -05:00
|
|
|
is_interior_.resize(num_cells);
|
|
|
|
|
|
|
|
ElementMapper elemMapper(this->gridView(), Dune::mcmgElementLayout());
|
|
|
|
for (const auto& element : elements(this->gridView()))
|
|
|
|
{
|
|
|
|
const auto elemIdx = elemMapper.index(element);
|
|
|
|
unsigned cartesianCellIdx = cartesianIndex(elemIdx);
|
|
|
|
cartesianToCompressed_[cartesianCellIdx] = elemIdx;
|
|
|
|
if (element.partitionType() == Dune::InteriorEntity)
|
|
|
|
{
|
|
|
|
is_interior_[elemIdx] = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_interior_[elemIdx] = 0;
|
|
|
|
}
|
2020-12-08 09:09:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateCellDepths_()
|
|
|
|
{
|
|
|
|
int numCells = this->gridView().size(/*codim=*/0);
|
|
|
|
cellCenterDepth_.resize(numCells);
|
|
|
|
|
|
|
|
ElementMapper elemMapper(this->gridView(), Dune::mcmgElementLayout());
|
|
|
|
auto elemIt = this->gridView().template begin</*codim=*/0>();
|
|
|
|
const auto& elemEndIt = this->gridView().template end</*codim=*/0>();
|
2021-01-29 07:31:35 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
const auto num_aqu_cells = this->allAquiferCells();
|
2021-01-29 07:31:35 -06:00
|
|
|
|
2020-12-08 09:09:01 -06:00
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
const Element& element = *elemIt;
|
|
|
|
const unsigned int elemIdx = elemMapper.index(element);
|
|
|
|
cellCenterDepth_[elemIdx] = cellCenterDepth(element);
|
2020-11-09 06:48:12 -06:00
|
|
|
|
2021-02-02 15:30:48 -06:00
|
|
|
if (!num_aqu_cells.empty()) {
|
2020-11-09 06:48:12 -06:00
|
|
|
const unsigned int global_index = cartesianIndex(elemIdx);
|
2021-01-29 07:31:35 -06:00
|
|
|
const auto search = num_aqu_cells.find(global_index);
|
|
|
|
if (search != num_aqu_cells.end()) {
|
|
|
|
// updating the cell depth using aquifer cell depth
|
|
|
|
cellCenterDepth_[elemIdx] = search->second->depth;
|
2020-11-09 06:48:12 -06:00
|
|
|
}
|
|
|
|
}
|
2020-12-08 09:09:01 -06:00
|
|
|
}
|
|
|
|
}
|
2020-09-24 14:51:59 -05:00
|
|
|
void updateCellThickness_()
|
|
|
|
{
|
2021-05-05 05:13:25 -05:00
|
|
|
if (!this->drsdtconEnabled())
|
2020-09-24 14:51:59 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
ElementMapper elemMapper(this->gridView(), Dune::mcmgElementLayout());
|
|
|
|
|
|
|
|
int numElements = this->gridView().size(/*codim=*/0);
|
|
|
|
cellThickness_.resize(numElements);
|
|
|
|
|
|
|
|
auto elemIt = this->gridView().template begin</*codim=*/0>();
|
|
|
|
const auto& elemEndIt = this->gridView().template end</*codim=*/0>();
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
const Element& element = *elemIt;
|
|
|
|
const unsigned int elemIdx = elemMapper.index(element);
|
|
|
|
cellThickness_[elemIdx] = asImp_().computeCellThickness(element);
|
|
|
|
}
|
|
|
|
}
|
2020-12-08 09:09:01 -06:00
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
private:
|
2020-09-24 14:51:59 -05:00
|
|
|
// computed from averaging cell corner depths
|
2020-12-08 09:09:01 -06:00
|
|
|
Scalar cellCenterDepth(const Element& element) const
|
|
|
|
{
|
|
|
|
typedef typename Element::Geometry Geometry;
|
|
|
|
static constexpr int zCoord = Element::dimension - 1;
|
|
|
|
Scalar zz = 0.0;
|
|
|
|
|
2021-03-18 12:13:24 -05:00
|
|
|
const Geometry& geometry = element.geometry();
|
2020-12-08 09:09:01 -06:00
|
|
|
const int corners = geometry.corners();
|
|
|
|
for (int i=0; i < corners; ++i)
|
|
|
|
zz += geometry.corner(i)[zCoord];
|
|
|
|
|
|
|
|
return zz/Scalar(corners);
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:32:36 -06:00
|
|
|
Implementation& asImp_()
|
|
|
|
{ return *static_cast<Implementation*>(this); }
|
|
|
|
|
|
|
|
const Implementation& asImp_() const
|
|
|
|
{ return *static_cast<const Implementation*>(this); }
|
|
|
|
|
2020-03-04 14:06:21 -06:00
|
|
|
protected:
|
|
|
|
/*! \brief The cell centroids after loadbalance was called.
|
|
|
|
* Empty otherwise. Used by EclTransmissibilty.
|
|
|
|
*/
|
|
|
|
std::vector<double> centroids_;
|
2020-12-08 09:09:01 -06:00
|
|
|
|
|
|
|
/*! \brief Mapping between cartesian and compressed cells.
|
|
|
|
* It is initialized the first time it is called
|
|
|
|
*/
|
2021-09-22 02:22:25 -05:00
|
|
|
std::unordered_map<int,int> cartesianToCompressed_;
|
2020-12-08 09:09:01 -06:00
|
|
|
|
2020-09-24 14:51:59 -05:00
|
|
|
/*! \brief Cell center depths
|
2020-12-08 09:09:01 -06:00
|
|
|
*/
|
|
|
|
std::vector<Scalar> cellCenterDepth_;
|
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
/*! \brief Cell thickness
|
2020-09-24 14:51:59 -05:00
|
|
|
*/
|
|
|
|
std::vector<Scalar> cellThickness_;
|
2021-10-19 09:50:42 -05:00
|
|
|
|
|
|
|
/*! \brief Whether a cells is in the interior.
|
|
|
|
*/
|
|
|
|
std::vector<int> is_interior_;
|
2016-01-05 12:32:36 -06:00
|
|
|
};
|
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
} // namespace Opm
|
2016-01-05 12:32:36 -06:00
|
|
|
|
|
|
|
#endif
|