mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4740 from akva2/isnumerical_aquifer_cell_separate_struct
isNumericalAquiferCell: put in separate struct for easier reuse
This commit is contained in:
68
opm/simulators/aquifers/AquiferGridUtils.hpp
Normal file
68
opm/simulators/aquifers/AquiferGridUtils.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright 2013, 2015 SINTEF ICT, Applied Mathematics.
|
||||
Copyright 2014, 2015 Dr. Blatt - HPC-Simulation-Software & Services
|
||||
Copyright 2014, 2015 Statoil ASA.
|
||||
Copyright 2015 NTNU
|
||||
Copyright 2015, 2016, 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 AQUIFER_GRID_UTILS_HEADER_INCLUDED
|
||||
#define AQUIFER_GRID_UTILS_HEADER_INCLUDED
|
||||
|
||||
#include <opm/grid/CpGrid.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class Grid>
|
||||
struct IsNumericalAquiferCell {
|
||||
IsNumericalAquiferCell(const Grid&)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
bool operator()(const T&) const { return false; }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct IsNumericalAquiferCell<Dune::CpGrid> {
|
||||
IsNumericalAquiferCell(const Dune::CpGrid& grid)
|
||||
: grid_(grid)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
bool operator()(const T& elem) const
|
||||
{
|
||||
const auto& aquiferCells = grid_.sortedNumAquiferCells();
|
||||
if (aquiferCells.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto candidate = std::lower_bound(aquiferCells.begin(),
|
||||
aquiferCells.end(), elem.index());
|
||||
return candidate != aquiferCells.end() && *candidate == elem.index();
|
||||
}
|
||||
|
||||
private:
|
||||
const Dune::CpGrid& grid_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
|
||||
#include <opm/simulators/aquifers/AquiferGridUtils.hpp>
|
||||
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
|
||||
#include <opm/simulators/flow/countGlobalCells.hpp>
|
||||
#include <opm/simulators/flow/partitionCells.hpp>
|
||||
@@ -1023,6 +1024,7 @@ namespace Opm {
|
||||
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
const auto& gridView = ebosSimulator().gridView();
|
||||
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
@@ -1036,7 +1038,7 @@ namespace Opm {
|
||||
ebosModel.dofTotalVolume(cell_idx);
|
||||
pvSumLocal += pvValue;
|
||||
|
||||
if (isNumericalAquiferCell(gridView.grid(), elem))
|
||||
if (isNumericalAquiferCell(elem))
|
||||
{
|
||||
numAquiferPvSumLocal += pvValue;
|
||||
}
|
||||
@@ -1075,6 +1077,7 @@ namespace Opm {
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
const auto& gridView = domain.view;
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
elemIt != elemEndIt;
|
||||
@@ -1095,7 +1098,7 @@ namespace Opm {
|
||||
ebosModel.dofTotalVolume(cell_idx);
|
||||
pvSumLocal += pvValue;
|
||||
|
||||
if (isNumericalAquiferCell(gridView.grid(), elem))
|
||||
if (isNumericalAquiferCell(elem))
|
||||
{
|
||||
numAquiferPvSumLocal += pvValue;
|
||||
}
|
||||
@@ -1157,13 +1160,14 @@ namespace Opm {
|
||||
const auto& ebosResid = ebosSimulator_.model().linearizer().residual();
|
||||
const auto& gridView = ebosSimulator().gridView();
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid());
|
||||
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interiorBorder))
|
||||
{
|
||||
// Skip cells of numerical Aquifer
|
||||
if (isNumericalAquiferCell(gridView.grid(), elem))
|
||||
if (isNumericalAquiferCell(elem))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1557,26 +1561,6 @@ namespace Opm {
|
||||
}
|
||||
|
||||
private:
|
||||
template<class T>
|
||||
bool isNumericalAquiferCell(const Dune::CpGrid& grid, const T& elem)
|
||||
{
|
||||
const auto& aquiferCells = grid.sortedNumAquiferCells();
|
||||
if (aquiferCells.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto candidate = std::lower_bound(aquiferCells.begin(), aquiferCells.end(),
|
||||
elem.index());
|
||||
return candidate != aquiferCells.end() && *candidate == elem.index();
|
||||
}
|
||||
|
||||
template<class G, class T>
|
||||
typename std::enable_if<!std::is_same<G,Dune::CpGrid>::value, bool>::type
|
||||
isNumericalAquiferCell(const G&, const T&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class FluidState, class Residual>
|
||||
void getMaxCoeff(const unsigned cell_idx,
|
||||
const IntensiveQuantities& intQuants,
|
||||
|
||||
Reference in New Issue
Block a user