From 530157c092e274b02dd051f4960fe74599d1daf3 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 21 Jun 2022 15:53:25 +0200 Subject: [PATCH] fixing the compilation of test_chiflash one reason is some code does not compile with DUNE2.6. And DUNE2.6 is still supported by OPM. --- opm/material/constraintsolvers/ChiFlash.hpp | 19 +++++++++++-------- tests/test_chiflash.cpp | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/opm/material/constraintsolvers/ChiFlash.hpp b/opm/material/constraintsolvers/ChiFlash.hpp index ae12cba7b..5b0c48b83 100644 --- a/opm/material/constraintsolvers/ChiFlash.hpp +++ b/opm/material/constraintsolvers/ChiFlash.hpp @@ -1062,8 +1062,11 @@ protected: (primary_fluid_state, primary_z, pri_jac, pri_res); } - SecondaryNewtonMatrix xx; - pri_jac.solve(xx,sec_jac); + // the following code does not compile with DUNE2.6 + // SecondaryNewtonMatrix xx; + // pri_jac.solve(xx, sec_jac); + pri_jac.invert(); + sec_jac.template leftmultiply(pri_jac); using InputEval = typename FluidState::Scalar; using ComponentVectorMoleFraction = Dune::FieldVector; @@ -1095,11 +1098,11 @@ protected: std::vector deri(num_deri, 0.); // derivatives from P for (unsigned idx = 0; idx < num_deri; ++idx) { - deri[idx] = - xx[compIdx][0] * p_l.derivative(idx); + deri[idx] = - sec_jac[compIdx][0] * p_l.derivative(idx); } for (unsigned cIdx = 0; cIdx < numComponents; ++cIdx) { - const double pz = -xx[compIdx][cIdx + 1]; + const double pz = -sec_jac[compIdx][cIdx + 1]; const auto& zi = z[cIdx]; for (unsigned idx = 0; idx < num_deri; ++idx) { deri[idx] += pz * zi.derivative(idx); @@ -1110,10 +1113,10 @@ protected: } // handling y for (unsigned idx = 0; idx < num_deri; ++idx) { - deri[idx] = - xx[compIdx + numComponents][0]* p_v.derivative(idx); + deri[idx] = - sec_jac[compIdx + numComponents][0]* p_v.derivative(idx); } for (unsigned cIdx = 0; cIdx < numComponents; ++cIdx) { - const double pz = -xx[compIdx + numComponents][cIdx + 1]; + const double pz = -sec_jac[compIdx + numComponents][cIdx + 1]; const auto& zi = z[cIdx]; for (unsigned idx = 0; idx < num_deri; ++idx) { deri[idx] += pz * zi.derivative(idx); @@ -1126,10 +1129,10 @@ protected: // handling derivatives of L std::vector deriL(num_deri, 0.); for (unsigned idx = 0; idx < num_deri; ++idx) { - deriL[idx] = - xx[2*numComponents][0] * p_v.derivative(idx); + deriL[idx] = - sec_jac[2*numComponents][0] * p_v.derivative(idx); } for (unsigned cIdx = 0; cIdx < numComponents; ++cIdx) { - const double pz = -xx[2*numComponents][cIdx + 1]; + const double pz = -sec_jac[2*numComponents][cIdx + 1]; const auto& zi = z[cIdx]; for (unsigned idx = 0; idx < num_deri; ++idx) { deriL[idx] += pz * zi.derivative(idx); diff --git a/tests/test_chiflash.cpp b/tests/test_chiflash.cpp index cbb66fcac..10975a612 100644 --- a/tests/test_chiflash.cpp +++ b/tests/test_chiflash.cpp @@ -87,8 +87,8 @@ void testChiFlash() typename FluidSystem::template ParameterCache paramCache; paramCache.updatePhase(fluid_state, FluidSystem::oilPhaseIdx); paramCache.updatePhase(fluid_state, FluidSystem::gasPhaseIdx); - fluid_state.setDensity(FluidSystem::oilPhaseIdx, FluidSystem::density(fs, paramCache, FluidSystem::oilPhaseIdx)); - fluid_state.setDensity(FluidSystem::gasPhaseIdx, FluidSystem::density(fs, paramCache, FluidSystem::gasPhaseIdx)); + fluid_state.setDensity(FluidSystem::oilPhaseIdx, FluidSystem::density(fluid_state, paramCache, FluidSystem::oilPhaseIdx)); + fluid_state.setDensity(FluidSystem::gasPhaseIdx, FluidSystem::density(fluid_state, paramCache, FluidSystem::gasPhaseIdx)); } ComponentVector z(0.); // TODO; z needs to be normalized.