mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Remove non-AD overload of muWat().
The AD version is made a little smarter, detecting the case of input with no derivatives. Existing use of the non-AD rewritten.
This commit is contained in:
parent
5a390f0d27
commit
965be0471f
@ -311,30 +311,6 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
|
|||||||
|
|
||||||
// ------ Viscosity ------
|
// ------ Viscosity ------
|
||||||
|
|
||||||
/// Water viscosity.
|
|
||||||
/// \param[in] pw Array of n water pressure values.
|
|
||||||
/// \param[in] T Array of n temperature values.
|
|
||||||
/// \param[in] cells Array of n cell indices to be associated with the pressure values.
|
|
||||||
/// \return Array of n viscosity values.
|
|
||||||
V BlackoilPropsAdFromDeck::muWat(const V& pw,
|
|
||||||
const V& T,
|
|
||||||
const Cells& cells) const
|
|
||||||
{
|
|
||||||
if (!phase_usage_.phase_used[Water]) {
|
|
||||||
OPM_THROW(std::runtime_error, "Cannot call muWat(): water phase not present.");
|
|
||||||
}
|
|
||||||
const int n = cells.size();
|
|
||||||
mapPvtRegions(cells);
|
|
||||||
assert(pw.size() == n);
|
|
||||||
V mu(n);
|
|
||||||
V dmudp(n);
|
|
||||||
V dmudr(n);
|
|
||||||
const double* rs = 0;
|
|
||||||
|
|
||||||
props_[phase_usage_.phase_pos[Water]]->mu(n, pvt_region_.data(), pw.data(), T.data(), rs,
|
|
||||||
mu.data(), dmudp.data(), dmudr.data());
|
|
||||||
return mu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Oil viscosity.
|
/// Oil viscosity.
|
||||||
/// \param[in] po Array of n oil pressure values.
|
/// \param[in] po Array of n oil pressure values.
|
||||||
@ -437,6 +413,9 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
|
|||||||
|
|
||||||
props_[phase_usage_.phase_pos[Water]]->mu(n, pvt_region_.data(), pw.value().data(), T.value().data(), rs,
|
props_[phase_usage_.phase_pos[Water]]->mu(n, pvt_region_.data(), pw.value().data(), T.value().data(), rs,
|
||||||
mu.data(), dmudp.data(), dmudr.data());
|
mu.data(), dmudp.data(), dmudr.data());
|
||||||
|
if (pw.derivative().empty()) {
|
||||||
|
return ADB::constant(mu);
|
||||||
|
} else {
|
||||||
ADB::M dmudp_diag = spdiag(dmudp);
|
ADB::M dmudp_diag = spdiag(dmudp);
|
||||||
const int num_blocks = pw.numBlocks();
|
const int num_blocks = pw.numBlocks();
|
||||||
std::vector<ADB::M> jacs(num_blocks);
|
std::vector<ADB::M> jacs(num_blocks);
|
||||||
@ -445,6 +424,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck&
|
|||||||
}
|
}
|
||||||
return ADB::function(mu, jacs);
|
return ADB::function(mu, jacs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Oil viscosity.
|
/// Oil viscosity.
|
||||||
/// \param[in] po Array of n oil pressure values.
|
/// \param[in] po Array of n oil pressure values.
|
||||||
|
@ -134,15 +134,6 @@ namespace Opm
|
|||||||
|
|
||||||
// ------ Viscosity ------
|
// ------ Viscosity ------
|
||||||
|
|
||||||
/// Water viscosity.
|
|
||||||
/// \param[in] pw Array of n water pressure values.
|
|
||||||
/// \param[in] T Array of n temperature values.
|
|
||||||
/// \param[in] cells Array of n cell indices to be associated with the pressure values.
|
|
||||||
/// \return Array of n viscosity values.
|
|
||||||
V muWat(const V& pw,
|
|
||||||
const V& T,
|
|
||||||
const Cells& cells) const;
|
|
||||||
|
|
||||||
/// Oil viscosity.
|
/// Oil viscosity.
|
||||||
/// \param[in] po Array of n oil pressure values.
|
/// \param[in] po Array of n oil pressure values.
|
||||||
/// \param[in] T Array of n temperature values.
|
/// \param[in] T Array of n temperature values.
|
||||||
|
@ -94,16 +94,6 @@ namespace Opm
|
|||||||
|
|
||||||
// ------ Viscosity ------
|
// ------ Viscosity ------
|
||||||
|
|
||||||
/// Water viscosity.
|
|
||||||
/// \param[in] pw Array of n water pressure values.
|
|
||||||
/// \param[in] T Array of n temperature values.
|
|
||||||
/// \param[in] cells Array of n cell indices to be associated with the pressure values.
|
|
||||||
/// \return Array of n viscosity values.
|
|
||||||
virtual
|
|
||||||
V muWat(const V& pw,
|
|
||||||
const V& T,
|
|
||||||
const Cells& cells) const = 0;
|
|
||||||
|
|
||||||
/// Oil viscosity.
|
/// Oil viscosity.
|
||||||
/// \param[in] po Array of n oil pressure values.
|
/// \param[in] po Array of n oil pressure values.
|
||||||
/// \param[in] T Array of n temperature values.
|
/// \param[in] T Array of n temperature values.
|
||||||
|
@ -553,20 +553,7 @@ namespace {
|
|||||||
|
|
||||||
V ImpesTPFAAD::fluidMu(const int phase, const V& p, const V& T, const std::vector<int>& cells) const
|
V ImpesTPFAAD::fluidMu(const int phase, const V& p, const V& T, const std::vector<int>& cells) const
|
||||||
{
|
{
|
||||||
switch (phase) {
|
return fluidMu(phase, ADB::constant(p), ADB::constant(T), cells).value();
|
||||||
case Water:
|
|
||||||
return fluid_.muWat(p, T, cells);
|
|
||||||
case Oil: {
|
|
||||||
V dummy_rs = V::Zero(p.size(), 1) * p;
|
|
||||||
std::vector<PhasePresence> cond(dummy_rs.size());
|
|
||||||
|
|
||||||
return fluid_.muOil(p, T, dummy_rs, cond, cells);
|
|
||||||
}
|
|
||||||
case Gas:
|
|
||||||
return fluid_.muGas(p, T, cells);
|
|
||||||
default:
|
|
||||||
OPM_THROW(std::runtime_error, "Unknown phase index " << phase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ BOOST_FIXTURE_TEST_CASE(ViscosityValue, TestFixture<SetupSimple>)
|
|||||||
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
||||||
|
|
||||||
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
||||||
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
||||||
|
|
||||||
V Vpw;
|
V Vpw;
|
||||||
Vpw.resize(cells.size());
|
Vpw.resize(cells.size());
|
||||||
@ -143,7 +144,7 @@ BOOST_FIXTURE_TEST_CASE(ViscosityValue, TestFixture<SetupSimple>)
|
|||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
||||||
|
|
||||||
const Opm::BlackoilPropsAdFromDeck::V VmuWat = boprops_ad.muWat(Vpw, T, cells);
|
const V VmuWat = boprops_ad.muWat(ADB::constant(Vpw), ADB::constant(T), cells).value();
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
BOOST_REQUIRE_EQUAL(Vpw.size(), cells.size());
|
||||||
|
|
||||||
@ -159,6 +160,7 @@ BOOST_FIXTURE_TEST_CASE(ViscosityAD, TestFixture<SetupSimple>)
|
|||||||
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
const Opm::BlackoilPropsAdFromDeck::Cells cells(5, 0);
|
||||||
|
|
||||||
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
typedef Opm::BlackoilPropsAdFromDeck::V V;
|
||||||
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
||||||
|
|
||||||
V Vpw;
|
V Vpw;
|
||||||
Vpw.resize(cells.size());
|
Vpw.resize(cells.size());
|
||||||
@ -173,7 +175,7 @@ BOOST_FIXTURE_TEST_CASE(ViscosityAD, TestFixture<SetupSimple>)
|
|||||||
|
|
||||||
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
typedef Opm::BlackoilPropsAdFromDeck::ADB ADB;
|
||||||
|
|
||||||
const V VmuWat = boprops_ad.muWat(Vpw, T, cells);
|
const V VmuWat = boprops_ad.muWat(ADB::constant(Vpw), ADB::constant(T), cells).value();
|
||||||
for (V::Index i = 0, n = Vpw.size(); i < n; ++i) {
|
for (V::Index i = 0, n = Vpw.size(); i < n; ++i) {
|
||||||
const std::vector<int> bp(1, grid.c_grid()->number_of_cells);
|
const std::vector<int> bp(1, grid.c_grid()->number_of_cells);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user