mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-07-07 04:53:03 -05:00
changed: move helpers for calculation pressure averages to separate compile unit
for reuse purposes
This commit is contained in:
parent
f5985ff02f
commit
38e9b5a100
|
@ -85,6 +85,7 @@ list (APPEND MAIN_SOURCE_FILES
|
|||
opm/simulators/utils/ParallelFileMerger.cpp
|
||||
opm/simulators/utils/ParallelRestart.cpp
|
||||
opm/simulators/utils/PartiallySupportedFlowKeywords.cpp
|
||||
opm/simulators/utils/PressureAverage.cpp
|
||||
opm/simulators/utils/readDeck.cpp
|
||||
opm/simulators/utils/SerializationPackers.cpp
|
||||
opm/simulators/utils/UnsupportedFlowKeywords.cpp
|
||||
|
@ -514,6 +515,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
|||
opm/simulators/utils/PropsCentroidsDataHandle.hpp
|
||||
opm/simulators/utils/SerializationPackers.hpp
|
||||
opm/simulators/utils/VectorVectorDataHandle.hpp
|
||||
opm/simulators/utils/PressureAverage.hpp
|
||||
opm/simulators/utils/readDeck.hpp
|
||||
opm/simulators/wells/ALQState.hpp
|
||||
opm/simulators/wells/BlackoilWellModel.hpp
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
|
||||
#include <opm/input/eclipse/Units/Units.hpp>
|
||||
|
||||
#include <opm/simulators/utils/PressureAverage.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
@ -1195,46 +1197,6 @@ isOutputCreationDirective_(const std::string& keyword)
|
|||
|| (keyword == "SAVE") || (keyword == "SFREQ"); // Not really supported
|
||||
}
|
||||
|
||||
template<class FluidSystem, class Scalar>
|
||||
Scalar EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
|
||||
pressureAverage_(const Scalar& pressurePvHydrocarbon,
|
||||
const Scalar& pvHydrocarbon,
|
||||
const Scalar& pressurePv,
|
||||
const Scalar& pv,
|
||||
const bool hydrocarbon)
|
||||
{
|
||||
if (hydrocarbon && (pvHydrocarbon > 1e-10))
|
||||
return pressurePvHydrocarbon / pvHydrocarbon;
|
||||
|
||||
return pressurePv / pv;
|
||||
}
|
||||
|
||||
template<class FluidSystem,class Scalar>
|
||||
typename EclGenericOutputBlackoilModule<FluidSystem,Scalar>::ScalarBuffer
|
||||
EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
|
||||
pressureAverage_(const ScalarBuffer& pressurePvHydrocarbon,
|
||||
const ScalarBuffer& pvHydrocarbon,
|
||||
const ScalarBuffer& pressurePv,
|
||||
const ScalarBuffer& pv,
|
||||
const bool hydrocarbon)
|
||||
{
|
||||
const std::size_t size = pressurePvHydrocarbon.size();
|
||||
assert(pvHydrocarbon.size() == size);
|
||||
assert(pressurePv.size() == size);
|
||||
assert(pv.size() == size);
|
||||
|
||||
ScalarBuffer fraction(size, 0.0);
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
fraction[i] = pressureAverage_(pressurePvHydrocarbon[i],
|
||||
pvHydrocarbon[i],
|
||||
pressurePv[i],
|
||||
pv[i],
|
||||
hydrocarbon);
|
||||
}
|
||||
|
||||
return fraction;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename IndexVector, typename IJKString>
|
||||
void logUniqueFailedCells(const std::string& messageTag,
|
||||
|
@ -1314,11 +1276,12 @@ void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
|
|||
outputFipLogImpl(const Inplace& inplace) const
|
||||
{
|
||||
{
|
||||
Scalar fieldHydroCarbonPoreVolumeAveragedPressure = pressureAverage_(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
Scalar fieldHydroCarbonPoreVolumeAveragedPressure =
|
||||
detail::pressureAverage(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
|
||||
std::unordered_map<Inplace::Phase, Scalar> initial_values;
|
||||
std::unordered_map<Inplace::Phase, Scalar> current_values;
|
||||
|
@ -1355,12 +1318,12 @@ outputFipLogImpl(const Inplace& inplace) const
|
|||
fipUnitConvert_(initial_values);
|
||||
fipUnitConvert_(current_values);
|
||||
|
||||
Scalar regHydroCarbonPoreVolumeAveragedPressure
|
||||
= pressureAverage_(inplace.get("FIPNUM", Inplace::Phase::PressureHydroCarbonPV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::HydroCarbonPV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::PressurePV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::DynamicPoreVolume, reg),
|
||||
true);
|
||||
Scalar regHydroCarbonPoreVolumeAveragedPressure =
|
||||
detail::pressureAverage(inplace.get("FIPNUM", Inplace::Phase::PressureHydroCarbonPV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::HydroCarbonPV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::PressurePV, reg),
|
||||
inplace.get("FIPNUM", Inplace::Phase::DynamicPoreVolume, reg),
|
||||
true);
|
||||
pressureUnitConvert_(regHydroCarbonPoreVolumeAveragedPressure);
|
||||
outputRegionFluidInPlace_(std::move(initial_values),
|
||||
std::move(current_values),
|
||||
|
@ -1514,22 +1477,21 @@ updateSummaryRegionValues(const Inplace& inplace,
|
|||
|
||||
if (this->summaryConfig_.hasKeyword("FPR")) {
|
||||
miscSummaryData["FPR"] =
|
||||
pressureAverage_(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
detail::pressureAverage(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
}
|
||||
|
||||
if (this->summaryConfig_.hasKeyword("FPRP")) {
|
||||
miscSummaryData["FPRP"] =
|
||||
pressureAverage_(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
false);
|
||||
detail::pressureAverage(inplace.get(Inplace::Phase::PressureHydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::HydroCarbonPV),
|
||||
inplace.get(Inplace::Phase::PressurePV),
|
||||
inplace.get(Inplace::Phase::DynamicPoreVolume),
|
||||
false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The region summary vectors should loop through the FIPxxx regions to
|
||||
|
@ -1549,20 +1511,20 @@ updateSummaryRegionValues(const Inplace& inplace,
|
|||
|
||||
for (const auto& node : this->RPRNodes_) {
|
||||
regionData[node.keyword()] =
|
||||
pressureAverage_(get_vector(node, Inplace::Phase::PressureHydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::HydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::PressurePV),
|
||||
get_vector(node, Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
detail::pressureAverage(get_vector(node, Inplace::Phase::PressureHydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::HydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::PressurePV),
|
||||
get_vector(node, Inplace::Phase::DynamicPoreVolume),
|
||||
true);
|
||||
}
|
||||
|
||||
for (const auto& node : this->RPRPNodes_) {
|
||||
regionData[node.keyword()] =
|
||||
pressureAverage_(get_vector(node, Inplace::Phase::PressureHydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::HydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::PressurePV),
|
||||
get_vector(node, Inplace::Phase::DynamicPoreVolume),
|
||||
false);
|
||||
detail::pressureAverage(get_vector(node, Inplace::Phase::PressureHydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::HydroCarbonPV),
|
||||
get_vector(node, Inplace::Phase::PressurePV),
|
||||
get_vector(node, Inplace::Phase::DynamicPoreVolume),
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,17 +330,6 @@ protected:
|
|||
|
||||
static bool isOutputCreationDirective_(const std::string& keyword);
|
||||
|
||||
static Scalar pressureAverage_(const Scalar& pressurePvHydrocarbon,
|
||||
const Scalar& pvHydrocarbon,
|
||||
const Scalar& pressurePv,
|
||||
const Scalar& pv,
|
||||
bool hydrocarbon);
|
||||
|
||||
static ScalarBuffer pressureAverage_(const ScalarBuffer& pressurePvHydrocarbon,
|
||||
const ScalarBuffer& pvHydrocarbon,
|
||||
const ScalarBuffer& pressurePv,
|
||||
const ScalarBuffer& pv,
|
||||
bool hydrocarbon);
|
||||
// Sum Fip values over regions.
|
||||
static ScalarBuffer regionSum(const ScalarBuffer& property,
|
||||
const std::vector<int>& regionId,
|
||||
|
|
81
opm/simulators/utils/PressureAverage.cpp
Normal file
81
opm/simulators/utils/PressureAverage.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
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/>.
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/utils/PressureAverage.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Opm {
|
||||
namespace detail {
|
||||
|
||||
template<class Scalar>
|
||||
Scalar
|
||||
pressureAverage(const Scalar pressurePvHydrocarbon,
|
||||
const Scalar pvHydrocarbon,
|
||||
const Scalar pressurePv,
|
||||
const Scalar pv,
|
||||
const bool hydrocarbon)
|
||||
{
|
||||
if (hydrocarbon && (pvHydrocarbon > 1e-10))
|
||||
return pressurePvHydrocarbon / pvHydrocarbon;
|
||||
|
||||
return pressurePv / pv;
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
std::vector<Scalar>
|
||||
pressureAverage(const std::vector<Scalar>& pressurePvHydrocarbon,
|
||||
const std::vector<Scalar>& pvHydrocarbon,
|
||||
const std::vector<Scalar>& pressurePv,
|
||||
const std::vector<Scalar>& pv,
|
||||
const bool hydrocarbon)
|
||||
{
|
||||
const std::size_t size = pressurePvHydrocarbon.size();
|
||||
assert(pvHydrocarbon.size() == size);
|
||||
assert(pressurePv.size() == size);
|
||||
assert(pv.size() == size);
|
||||
|
||||
std::vector<Scalar> fraction(size, 0.0);
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
fraction[i] = pressureAverage(pressurePvHydrocarbon[i],
|
||||
pvHydrocarbon[i],
|
||||
pressurePv[i],
|
||||
pv[i],
|
||||
hydrocarbon);
|
||||
}
|
||||
|
||||
return fraction;
|
||||
}
|
||||
|
||||
template double
|
||||
pressureAverage<double>(const double,
|
||||
const double,
|
||||
const double,
|
||||
const double,
|
||||
const bool);
|
||||
|
||||
template std::vector<double>
|
||||
pressureAverage<double>(const std::vector<double>&,
|
||||
const std::vector<double>&,
|
||||
const std::vector<double>&,
|
||||
const std::vector<double>&,
|
||||
const bool);
|
||||
|
||||
} // namespace detail
|
||||
} // namespace Opm
|
46
opm/simulators/utils/PressureAverage.hpp
Normal file
46
opm/simulators/utils/PressureAverage.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
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/>.
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PRESSURE_AVERAGE_HPP
|
||||
#define PRESSURE_AVERAGE_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
namespace detail {
|
||||
|
||||
//! \brief Calculates average pressure value.
|
||||
template<class Scalar>
|
||||
Scalar pressureAverage(const Scalar pressurePvHydrocarbon,
|
||||
const Scalar pvHydrocarbon,
|
||||
const Scalar pressurePv,
|
||||
const Scalar pv,
|
||||
const bool hydrocarbon);
|
||||
|
||||
//! \brief Calculates average pressure value for a vector.
|
||||
template<class Scalar>
|
||||
std::vector<Scalar>
|
||||
pressureAverage(const std::vector<Scalar>& pressurePvHydrocarbon,
|
||||
const std::vector<Scalar>& pvHydrocarbon,
|
||||
const std::vector<Scalar>& pressurePv,
|
||||
const std::vector<Scalar>& pv,
|
||||
const bool hydrocarbon);
|
||||
|
||||
} // namespace detail
|
||||
} // namespace Opm
|
||||
|
||||
#endif // PRESSURE_AVERAGE_HPP
|
Loading…
Reference in New Issue
Block a user