diff --git a/dumux/io/loadsolution.hh b/dumux/io/loadsolution.hh index b5dfdbb590c9a2e2b05763e412419a4ca5fc1f60..6c95e18946386b749eeeb9728c93b43cfb530fe6 100644 --- a/dumux/io/loadsolution.hh +++ b/dumux/io/loadsolution.hh @@ -126,8 +126,20 @@ auto loadSolutionFromVtuFile(const std::string fileName, template<class ModelTraits, class FluidSystem> std::string primaryVariableName(int pvIdx, int state) { - if (haveParam("LoadSolution.PrimaryVariableNames")) - DUNE_THROW(Dune::NotImplemented, "reading PrimaryVariableNames from input file"); + using std::pow; + static auto numStates = pow(2, ModelTraits::numPhases()) - 1; + const auto paramNameWithState = "LoadSolution.PriVarNamesState" + std::to_string(state); + + if (haveParam("LoadSolution.PriVarNames")) + { + DUNE_THROW(Dune::NotImplemented, "please provide LoadSolution.PriVarNamesState1..." << numStates + << " or remove LoadSolution.PriVarNames to use default names"); + } + else if (haveParam(paramNameWithState)) + { + const auto pvNames = getParam<std::vector<std::string>>(paramNameWithState); + return pvNames[pvIdx]; + } else return ModelTraits::template primaryVariableName<FluidSystem>(pvIdx, state); } @@ -139,9 +151,9 @@ std::string primaryVariableName(int pvIdx, int state) template<class ModelTraits> std::string primaryVariableName(int pvIdx) { - if (haveParam("LoadSolution.PrimaryVariableNames")) + if (haveParam("LoadSolution.PriVarNames")) { - static auto pvNames = getParam<std::vector<std::string>>("LoadSolution.PrimaryVariableNames"); + static auto pvNames = getParam<std::vector<std::string>>("LoadSolution.PriVarNames"); return pvNames[pvIdx]; } else diff --git a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.input b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.input index a2933a09dc15ec698f390c3eace73a307eb34ea1..48f074e96ddfc04974d3407f187df36c2924b483 100644 --- a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.input +++ b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.input @@ -19,3 +19,8 @@ PressureLow = 1e5 # [Pa] lower pressure limit for tabularization PressureHigh = 3e7 # [Pa] upper pressure limit for tabularization TemperatureLow = 312.15 # [Pa] lower temperature limit for tabularization TemperatureHigh = 314.15 # [Pa] upper temperature limit for tabularization + +[LoadSolution] +PriVarNamesState1 = pw x_w^N2 +PriVarNamesState2 = pw x_n^H2O +PriVarNamesState3 = pw Sn