Skip to content
Snippets Groups Projects
Commit 721c5a22 authored by Bernd Flemisch's avatar Bernd Flemisch Committed by Timo Koch
Browse files

[io][vtk] enable reading unswitched pv names from input file

Also pass only the discretization method instead of the FVGridGeometry.
parent 9c44dfde
No related branches found
No related tags found
1 merge request!1039Feature/restart from vtk
......@@ -140,7 +140,10 @@ template<class ModelTraits>
std::string primaryVariableName(int pvIdx)
{
if (haveParam("LoadSolution.PrimaryVariableNames"))
DUNE_THROW(Dune::NotImplemented, "reading PrimaryVariableNames from input file");
{
static auto pvNames = getParam<std::vector<std::string>>("LoadSolution.PrimaryVariableNames");
return pvNames[pvIdx];
}
else
return ModelTraits::primaryVariableName(pvIdx);
}
......@@ -151,9 +154,9 @@ std::string primaryVariableName(int pvIdx)
* \brief load a solution vector from file
* \note Supports the following file extensions: *.vtu
*/
template <class FVGridGeometry, class SolutionVector, class PvNamesFunc>
template <class SolutionVector, class PvNamesFunc>
void loadSolution(const std::string& fileName,
const FVGridGeometry& fvGridGeometry,
DiscretizationMethod discMethod,
PvNamesFunc&& pvNamesFunc,
SolutionVector& sol)
{
......@@ -161,7 +164,7 @@ void loadSolution(const std::string& fileName,
if (extension == "vtu")
{
const auto dataType = FVGridGeometry::discMethod == DiscretizationMethod::box
const auto dataType = discMethod == DiscretizationMethod::box
? VTUReader::DataType::pointData : VTUReader::DataType::cellData;
loadSolutionFromVtuFile(fileName, dataType, pvNamesFunc, sol);
}
......
......@@ -36,7 +36,6 @@
#include <sstream>
namespace Dumux {
/*!
* \ingroup InputOutput
* \brief Load or save a state of a model to/from the harddisk.
......@@ -288,6 +287,8 @@ public:
"Restart::restartFileList()");
}
private:
std::string fileName_;
std::ifstream inStream_;
std::ofstream outStream_;
......
......@@ -138,7 +138,7 @@ int main(int argc, char** argv) try
{
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
auto fileName = getParam<std::string>("Restart.File");
loadSolution(fileName, *fvGridGeometry, primaryVariableName<ModelTraits>, x);
loadSolution(fileName, FVGridGeometry::discMethod, primaryVariableName<ModelTraits>, x);
}
else
problem->applyInitialSolution(x);
......
......@@ -107,7 +107,7 @@ int main(int argc, char** argv) try
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
auto fileName = getParam<std::string>("Restart.File");
loadSolution(fileName, *fvGridGeometry, primaryVariableName<ModelTraits, FluidSystem>, x);
loadSolution(fileName, FVGridGeometry::discMethod, primaryVariableName<ModelTraits, FluidSystem>, x);
}
else
problem->applyInitialSolution(x);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment