diff --git a/dumux/porousmediumflow/2p1c/indices.hh b/dumux/porousmediumflow/2p1c/indices.hh index 15d5959f23e3422a484941ebb5b273e7b5e8840b..d53be4494b6666e4d3fa0c6bffd440bbf3f3f319 100644 --- a/dumux/porousmediumflow/2p1c/indices.hh +++ b/dumux/porousmediumflow/2p1c/indices.hh @@ -46,6 +46,8 @@ public: // Equation indices static const int conti0EqIdx = 0; //!< Index of the mass conservation equation for the water component. static const int energyEqIdx = 1; //<! The index for energy in equation vectors. + + static const int temperatureIdx = -99; //!< For compatibility reasons. Do not use. }; } // end namespace Dumux diff --git a/dumux/porousmediumflow/2p1c/volumevariables.hh b/dumux/porousmediumflow/2p1c/volumevariables.hh index 4f8cff6c9e8b291d6013a12a2092ce3456a0cd2a..660029e45f0ef1b12d7b211f6d905eb68bb17064 100644 --- a/dumux/porousmediumflow/2p1c/volumevariables.hh +++ b/dumux/porousmediumflow/2p1c/volumevariables.hh @@ -212,22 +212,8 @@ public: : priVars[pressureIdx] + pc_); } - // get temperature - Scalar temperature; - if (phasePresence == liquidPhaseOnly || phasePresence == gasPhaseOnly) - temperature = priVars[switchIdx]; - else if (phasePresence == twoPhases) - temperature = FluidSystem::vaporTemperature(fluidState, wPhaseIdx); - else - DUNE_THROW(Dune::InvalidStateException, "phasePresence: " << phasePresence << " is invalid."); - - Valgrind::CheckDefined(temperature); - - for(int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) - { - fluidState.setTemperature(phaseIdx, temperature); - } - solidState.setTemperature(temperature); + // set the temperature + updateTemperature(elemSol, problem, element, scv, fluidState, solidState); // set the densities for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) @@ -257,6 +243,45 @@ public: } } + //! Depending on the phase state, the fluid temperature is either obtained as a primary variable from the solution vector + //! or calculated from the liquid's vapor pressure. + template<class ElemSol, class Problem, class Element, class Scv> + void updateTemperature(const ElemSol& elemSol, + const Problem& problem, + const Element& element, + const Scv& scv, + FluidState& fluidState, + SolidState& solidState) + { + const auto& priVars = elemSol[scv.localDofIndex()]; + const auto phasePresence = priVars.state(); + const int wPhaseIdx = problem.spatialParams().template wettingPhase<FluidSystem>(element, scv, elemSol); + + // get temperature + Scalar fluidTemperature; + if (phasePresence == liquidPhaseOnly || phasePresence == gasPhaseOnly) + fluidTemperature = priVars[switchIdx]; + else if (phasePresence == twoPhases) + fluidTemperature = FluidSystem::vaporTemperature(fluidState, wPhaseIdx); + else + DUNE_THROW(Dune::InvalidStateException, "phasePresence: " << phasePresence << " is invalid."); + + Valgrind::CheckDefined(fluidTemperature); + + // the model assumes that all fluid phases have the same temperature + for (int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) + fluidState.setTemperature(phaseIdx, fluidTemperature); + + // the solid phase could have a different temperature + if (Traits::ModelTraits::numEnergyEq() == 1) + solidState.setTemperature(fluidTemperature); + else + { + const Scalar solidTemperature = elemSol[scv.localDofIndex()][Traits::ModelTraits::numEq()-1]; + solidState.setTemperature(solidTemperature); + } + } + /*! * \brief Returns the fluid state for the control-volume. */ diff --git a/test/porousmediumflow/2p1c/implicit/CMakeLists.txt b/test/porousmediumflow/2p1c/implicit/CMakeLists.txt index 05240ed1cab7a78928792a8bff55b393c310a92d..841843f002c690c9f2f4a29c79fc112099852a87 100644 --- a/test/porousmediumflow/2p1c/implicit/CMakeLists.txt +++ b/test/porousmediumflow/2p1c/implicit/CMakeLists.txt @@ -1,18 +1,23 @@ #add links to input files add_input_file_links() -dune_add_test(NAME test_2p1cni_box - SOURCES test_2p1c_fv.cc - COMPILE_DEFINITIONS TYPETAG=TwoPOneCNIBoxTypeTag +add_executable(test_2p1cni_tpfa EXCLUDE_FROM_ALL test_2p1c_fv.cc) +target_compile_definitions(test_2p1cni_tpfa PUBLIC "TYPETAG=TwoPOneCNICCTpfaTypeTag") + +add_executable(test_2p1cni_box EXCLUDE_FROM_ALL test_2p1c_fv.cc) +target_compile_definitions(test_2p1cni_box PUBLIC "TYPETAG=TwoPOneCNIBoxTypeTag") + + +dune_add_test(NAME test_2p1cni_box_waterwet + TARGET test_2p1cni_box COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/steaminjectionbox-reference.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_boxsteaminjection-00007.vtu --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p1cni_box test_boxsteaminjection.input") -dune_add_test(NAME test_2p1cni_tpfa - SOURCES test_2p1c_fv.cc - COMPILE_DEFINITIONS TYPETAG=TwoPOneCNICCTpfaTypeTag +dune_add_test(NAME test_2p1cni_tpfa_waterwet + TARGET test_2p1cni_tpfa COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/steaminjectioncc-reference.vtu @@ -20,8 +25,7 @@ dune_add_test(NAME test_2p1cni_tpfa --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p1cni_tpfa test_ccsteaminjection.input") dune_add_test(NAME test_2p1cni_box_gaswet - SOURCES test_2p1c_fv.cc - COMPILE_DEFINITIONS TYPETAG=TwoPOneCNIBoxTypeTag + TARGET test_2p1cni_box COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/steaminjectionbox_gaswet-reference.vtu @@ -31,8 +35,7 @@ dune_add_test(NAME test_2p1cni_box_gaswet -SpatialParams.GasWetting true") dune_add_test(NAME test_2p1cni_tpfa_gaswet - SOURCES test_2p1c_fv.cc - COMPILE_DEFINITIONS TYPETAG=TwoPOneCNICCTpfaTypeTag + TARGET test_2p1cni_tpfa COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/steaminjectioncc_gaswet-reference.vtu