Commit 1c997d48 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/modify_loadsolution' into 'master'

Feature/modify loadsolution

See merge request !2226
parents eaf00052 332e2eb0
......@@ -71,7 +71,7 @@ public:
{ return true; }
template<class EntityType>
size_t size (const EntityType &e) const
std::size_t size (const EntityType &e) const
{ return 1; }
template<class MessageBufferImp, class EntityType>
......@@ -82,7 +82,7 @@ public:
}
template<class MessageBufferImp, class EntityType>
void scatter(MessageBufferImp& buff, const EntityType& e, size_t n)
void scatter(MessageBufferImp& buff, const EntityType& e, std::size_t n)
{
const auto vIdx = mapper_.index(e);
FieldType tmp;
......@@ -102,20 +102,43 @@ private:
template <class SolutionVector, class PvNameFunc, class GridGeometry>
auto loadSolutionFromVtkFile(SolutionVector& sol,
const std::string fileName,
PvNameFunc&& pvNameFunc,
PvNameFunc&& targetPvNameFunc,
const GridGeometry& gridGeometry,
const VTKReader::DataType& dataType)
-> typename std::enable_if_t<!decltype(isValid(Detail::hasState())(sol[0]))::value, void>
{
VTKReader vtu(fileName);
using PrimaryVariables = typename SolutionVector::block_type;
using Scalar = typename PrimaryVariables::field_type;
constexpr auto dim = GridGeometry::GridView::dimension;
const std::size_t targetSolutionSize = PrimaryVariables::dimension;
std::size_t matchingLoadedArrays = 0;
for (std::size_t i = 0; i < targetSolutionSize; i++)
if (vtu.hasData(targetPvNameFunc(i,0), dataType))
matchingLoadedArrays++;
if (matchingLoadedArrays < targetSolutionSize)
std::cout << "The loaded solution does not provide a data array for each of the primary variables. \n"
<< "The target solution has "<< targetSolutionSize << " entries, "
<< "whereas the loaded solution provides only " << matchingLoadedArrays << " data array(s). \n"
<< "Make sure that the model concepts are compatible, "
<< "and be sure to provide initial conditions for the missing primary variables. \n";
for (size_t pvIdx = 0; pvIdx < PrimaryVariables::dimension; ++pvIdx)
for (std::size_t targetPvIdx = 0; targetPvIdx < targetSolutionSize; ++targetPvIdx)
{
const auto pvName = pvNameFunc(pvIdx, 0);
auto vec = vtu.readData<std::vector<Scalar>>(pvName, dataType);
std::vector<Scalar> vec;
const auto targetPvName = targetPvNameFunc(targetPvIdx, 0);
if (vtu.hasData(targetPvName, dataType))
vec = vtu.readData<std::vector<Scalar>>(targetPvName, dataType);
else
{
std::cout << "The loaded solution does not have a field named \"" << targetPvName << "\". "
<< "Make sure this field is filled using the initial method in the problem definition. \n";
continue;
}
if (dataType == VTKReader::DataType::cellData)
{
......@@ -123,7 +146,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
for (const auto& element : elements(gridGeometry.gridView(), Dune::Partitions::interior))
{
const auto eIdx = gridGeometry.elementMapper().index(element);
sol[eIdx][pvIdx] = vec[i++];
sol[eIdx][targetPvIdx] = vec[i++];
}
}
// for staggered face data (which is written out as VTK point data) we just read in the vector
......@@ -133,7 +156,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
DUNE_THROW(Dune::InvalidStateException, "Solution size (" << sol.size() << ") does not match input size (" << vec.size() << ")!");
for (std::size_t i = 0; i < sol.size(); ++i)
sol[i][pvIdx] = vec[i];
sol[i][targetPvIdx] = vec[i];
}
else
{
......@@ -146,7 +169,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
const auto vIdxGlobal = gridGeometry.vertexMapper().subIndex(element, vIdxLocal, dim);
if (!visited[vIdxGlobal])
{
sol[vIdxGlobal][pvIdx] = vec[i++];
sol[vIdxGlobal][targetPvIdx] = vec[i++];
visited[vIdxGlobal] = true;
}
}
......@@ -162,28 +185,55 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
template <class SolutionVector, class PvNameFunc, class GridGeometry>
auto loadSolutionFromVtkFile(SolutionVector& sol,
const std::string fileName,
PvNameFunc&& pvNameFunc,
PvNameFunc&& targetPvNameFunc,
const GridGeometry& gridGeometry,
const VTKReader::DataType& dataType)
-> typename std::enable_if_t<decltype(isValid(Detail::hasState())(sol[0]))::value, void>
{
VTKReader vtu(fileName);
// get states at each dof location
const auto stateAtDof = vtu.readData<std::vector<int>>("phase presence", dataType);
// determine all states that are present
std::unordered_set<int> states;
for (size_t i = 0; i < stateAtDof.size(); ++i)
for (std::size_t i = 0; i < stateAtDof.size(); ++i)
states.insert(stateAtDof[i]);
using PrimaryVariables = typename SolutionVector::block_type;
using Scalar = typename PrimaryVariables::field_type;
for (size_t pvIdx = 0; pvIdx < PrimaryVariables::dimension; ++pvIdx)
const std::size_t targetSolutionSize = PrimaryVariables::dimension;
std::unordered_set<std::string> matchingNames;
for (std::size_t i = 0; i < targetSolutionSize; i++)
for (const auto& state : states)
if ( vtu.hasData(targetPvNameFunc(i,state), dataType))
matchingNames.insert(targetPvNameFunc(i,state));
const std::size_t matchingLoadedArrays = matchingNames.size() - (states.size()-1);
if (matchingLoadedArrays < targetSolutionSize)
std::cout << "The loaded solution does not provide a data array for each of the primary variables. \n"
<< "The target solution has "<< targetSolutionSize << " entries, "
<< "whereas the loaded solution provides only " << matchingLoadedArrays << " data array(s). \n"
<< "Make sure that the model concepts are compatible, "
<< "and be sure to provide initial conditions for the missing primary variables. \n";
for (std::size_t targetPvIdx = 0; targetPvIdx < targetSolutionSize; ++targetPvIdx)
{
std::unordered_map<int, std::vector<Scalar>> data;
for (const auto& state : states)
data[state] = vtu.readData<std::vector<Scalar>>(pvNameFunc(pvIdx, state), dataType);
{
const auto targetPvName = targetPvNameFunc(targetPvIdx, state);
if (vtu.hasData(targetPvName, dataType))
data[state] = vtu.readData<std::vector<Scalar>>(targetPvName, dataType);
else
{
std::cout << "Loaded Solution does not have a field named \"" << targetPvName << "\". "
<< "Make sure this field is filled using the initial method in the problem definition. \n";
continue;
}
}
if (dataType == VTKReader::DataType::cellData)
{
......@@ -192,7 +242,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
{
const auto eIdx = gridGeometry.elementMapper().index(element);
const auto state = stateAtDof[i];
sol[eIdx][pvIdx] = data[state][i++];
sol[eIdx][targetPvIdx] = data[state][i++];
sol[eIdx].setState(state);
}
}
......@@ -209,7 +259,7 @@ auto loadSolutionFromVtkFile(SolutionVector& sol,
if (!visited[vIdxGlobal])
{
const auto state = stateAtDof[i];
sol[vIdxGlobal][pvIdx] = data[state][i++];
sol[vIdxGlobal][targetPvIdx] = data[state][i++];
sol[vIdxGlobal].setState(state);
visited[vIdxGlobal] = true;
}
......@@ -270,6 +320,7 @@ auto createPVNameFunction(const std::string& paramGroup = "")
* \brief load a solution vector from file
* \note Supports the following file extensions: *.vtu *.vtp *.pvtu, *.pvtp
* \param sol the solution vector to read from file
* \param loadedSolutionSize the dimension of the loaded solution's primary variables
* \param fileName the file name of the file to read from
* \param pvNameFunc a function with the signature std::string(int pvIdx)
* in case the primary variables have a state the signature is std::string(int pvIdx, int state)
......@@ -278,7 +329,7 @@ auto createPVNameFunction(const std::string& paramGroup = "")
template <class SolutionVector, class PvNameFunc, class GridGeometry>
void loadSolution(SolutionVector& sol,
const std::string& fileName,
PvNameFunc&& pvNameFunc,
PvNameFunc&& targetPvNameFunc,
const GridGeometry& gridGeometry)
{
const auto extension = fileName.substr(fileName.find_last_of(".") + 1);
......@@ -290,14 +341,14 @@ void loadSolution(SolutionVector& sol,
if (GridGeometry::discMethod == DiscretizationMethod::staggered && extension == "vtp")
dataType = VTKReader::DataType::pointData;
loadSolutionFromVtkFile(sol, fileName, pvNameFunc, gridGeometry, dataType);
loadSolutionFromVtkFile(sol, fileName, targetPvNameFunc, gridGeometry, dataType);
}
else if (extension == "pvtu" || extension == "pvtp")
{
if (GridGeometry::discMethod == DiscretizationMethod::staggered)
DUNE_THROW(Dune::NotImplemented, "reading staggered solution from a parallel vtk file");
loadSolutionFromVtkFile(sol, fileName, pvNameFunc, gridGeometry, dataType);
loadSolutionFromVtkFile(sol, fileName, targetPvNameFunc, gridGeometry, dataType);
}
else
DUNE_THROW(Dune::NotImplemented, "loadSolution for file with extension " << extension);
......@@ -324,7 +375,6 @@ void loadSolution(SolutionVector& sol,
}
}
}
} // end namespace Dumux
#endif
......@@ -63,12 +63,38 @@ public:
*/
explicit VTKReader(const std::string& fileName)
{
using namespace tinyxml2;
fileName_ = Dune::MPIHelper::getCollectiveCommunication().size() > 1 ?
getProcessFileName_(fileName) : fileName;
const auto eResult = doc_.LoadFile(fileName_.c_str());
if (eResult != tinyxml2::XML_SUCCESS)
DUNE_THROW(Dune::IOError, "Couldn't open XML file " << fileName_ << ".");
const XMLElement* pieceNode = getPieceNode_();
if (pieceNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'Piece' node in " << fileName_ << ".");
}
/*!
* \brief Reviews data from the vtk file to check if there is a data array with a specified name
* \param name the name attribute of the data array to read
* \param type the data array type
*/
bool hasData(const std::string& name, const DataType& type) const
{
using namespace tinyxml2;
const XMLElement* pieceNode = getPieceNode_();
const XMLElement* dataNode = getDataNode_(pieceNode, type);
if (dataNode == nullptr)
return false;
const XMLElement* dataArray = findDataArray_(dataNode, name);
if (dataArray == nullptr)
return false;
return true;
}
/*!
......@@ -83,9 +109,6 @@ public:
using namespace tinyxml2;
const XMLElement* pieceNode = getPieceNode_();
if (pieceNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'Piece' node in " << fileName_ << ".");
const XMLElement* dataNode = getDataNode_(pieceNode, type);
if (dataNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'PointData' or 'CellData' node in " << fileName_ << ".");
......@@ -170,9 +193,6 @@ private:
// get the first piece node
const XMLElement* pieceNode = getPieceNode_(pDoc, pvtkFileName);
if (pieceNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'Piece' node in " << pvtkFileName << ".");
const auto myrank = Dune::MPIHelper::getCollectiveCommunication().rank();
for (int rank = 0; rank < myrank; ++rank)
{
......@@ -200,9 +220,6 @@ private:
using namespace tinyxml2;
const XMLElement* pieceNode = getPieceNode_();
if (pieceNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'Piece' node in " << fileName_ << ".");
const XMLElement* pointsNode = pieceNode->FirstChildElement("Points")->FirstChildElement("DataArray");
if (pointsNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get data array of points in " << fileName_ << ".");
......@@ -291,9 +308,6 @@ private:
using namespace tinyxml2;
const XMLElement* pieceNode = getPieceNode_();
if (pieceNode == nullptr)
DUNE_THROW(Dune::IOError, "Couldn't get 'Piece' node in " << fileName_ << ".");
const XMLElement* cellDataNode = getDataNode_(pieceNode, DataType::cellData);
if (cellDataNode != nullptr)
{
......
add_input_file_links()
dune_symlink_to_source_files(FILES solutions)
# isothermal tests
add_executable(test_ff_rans2c_kepsilon EXCLUDE_FROM_ALL main.cc)
......@@ -107,6 +108,7 @@ dumux_add_test(NAME test_ff_rans2cni_kepsilon_wallfunction
dumux_add_test(NAME test_ff_rans2cni_komega
SOURCES main.cc
COMPILE_DEFINITIONS TYPETAG=FlatPlateNCNIKOmega
COMPILE_DEFINITIONS NONISOTHERMAL
LABELS freeflow rans
CMAKE_GUARD HAVE_UMFPACK
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
......@@ -116,7 +118,21 @@ dumux_add_test(NAME test_ff_rans2cni_komega
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_rans2cni_komega params_nonisothermal.input
-Problem.Name test_ff_rans2cni_komega
-Newton.TargetSteps 12")
target_compile_definitions(test_ff_rans2cni_komega PUBLIC "NONISOTHERMAL")
dumux_add_test(NAME test_ff_rans2cni_komega_loadsolution
TARGET test_ff_rans2cni_komega
LABELS freeflow rans loadsolution
CMAKE_GUARD HAVE_UMFPACK
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_ff_rans2cni_komega_loadsolution-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_ff_rans2cni_komega_loadsolution-00008.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_rans2cni_komega params_nonisothermal.input
-LoadSolution.RansCCFile ./solutions/komeganc_ccsolution.vtu
-LoadSolution.RansFaceFile ./solutions/komeganc_facesolution.vtp
-Problem.Name test_ff_rans2cni_komega_loadsolution
-TimeLoop.DtInitial 5.0
-TimeLoop.TEnd 200.0")
dumux_add_test(NAME test_ff_rans2cni_lowrekepsilon
SOURCES main.cc
......
......@@ -38,6 +38,7 @@
#include <dumux/common/dumuxmessage.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/properties.hh>
#include <dumux/io/loadsolution.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/staggeredvtkoutputmodule.hh>
#include <dumux/linear/seqsolverbackend.hh>
......@@ -119,7 +120,41 @@ int main(int argc, char** argv) try
SolutionVector x;
x[GridGeometry::cellCenterIdx()].resize(gridGeometry->numCellCenterDofs());
x[GridGeometry::faceIdx()].resize(gridGeometry->numFaceDofs());
// read in the restart files
problem->applyInitialSolution(x);
if (hasParam("LoadSolution.RansCCFile") && hasParam("LoadSolution.RansFaceFile"))
{
using TargetIOFields = GetPropType<TypeTag, Properties::IOFields>;
using TargetCellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
using TargetModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
using TargetFluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
const auto restartFileNameCC = getParam<std::string>("LoadSolution.RansCCFile");
const auto targetCCPVNameFunc = createCellCenterPVNameFunction<TargetIOFields,
TargetCellCenterPrimaryVariables,
TargetModelTraits,
TargetFluidSystem>();
loadSolution(x[GridGeometry::cellCenterIdx()],
restartFileNameCC,
targetCCPVNameFunc,
*gridGeometry);
// read in the face rans solution
const auto restartFileNameFace = getParam<std::string>("LoadSolution.RansFaceFile");
using TargetFacePrimaryVariables = GetPropType<TypeTag, Properties::FacePrimaryVariables>;
const auto facePVNameFunc = createFacePVNameFunction<TargetIOFields,
TargetFacePrimaryVariables,
TargetModelTraits,
TargetFluidSystem>();
loadSolution(x[GridGeometry::faceIdx()],
restartFileNameFace,
facePVNameFunc,
*gridGeometry);
}
else
std::cout << "No restart files provided in LoadSolution parameter group. "
<< "Starting with problem specified initial conditions \n";
problem->updateStaticWallProperties();
problem->updateDynamicWallProperties(x);
auto xOld = x;
......
This diff is collapsed.
<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian">
<PolyData>
<Piece NumberOfLines="0" NumberOfPoints="430">
<Points>
<DataArray type="Float32" Name="Coordinates" NumberOfComponents="3" format="ascii">
0.3 0 0 0.9 0 0 1.5 0 0 2.1 0 0 2.7 0 0 3.3 0 0 3.9 0 0 4.5 0 0 5.1 0 0 5.7 0 0 0.3 0.000239325 0 0.9 0.000239325 0 1.5 0.000239325 0 2.1 0.000239325 0 2.7 0.000239325 0 3.3 0.000239325 0
3.9 0.000239325 0 4.5 0.000239325 0 5.1 0.000239325 0 5.7 0.000239325 0 0.3 0.000574381 0 0.9 0.000574381 0 1.5 0.000574381 0 2.1 0.000574381 0 2.7 0.000574381 0 3.3 0.000574381 0 3.9 0.000574381 0 4.5 0.000574381 0 5.1 0.000574381 0 5.7 0.000574381 0 0.3 0.00104346 0 0.9 0.00104346 0
1.5 0.00104346 0 2.1 0.00104346 0 2.7 0.00104346 0 3.3 0.00104346 0 3.9 0.00104346 0 4.5 0.00104346 0 5.1 0.00104346 0 5.7 0.00104346 0 0.3 0.00170017 0 0.9 0.00170017 0 1.5 0.00170017 0 2.1 0.00170017 0 2.7 0.00170017 0 3.3 0.00170017 0 3.9 0.00170017 0 4.5 0.00170017 0
5.1 0.00170017 0 5.7 0.00170017 0 0.3 0.00261956 0 0.9 0.00261956 0 1.5 0.00261956 0 2.1 0.00261956 0 2.7 0.00261956 0 3.3 0.00261956 0 3.9 0.00261956 0 4.5 0.00261956 0 5.1 0.00261956 0 5.7 0.00261956 0 0.3 0.00390671 0 0.9 0.00390671 0 1.5 0.00390671 0 2.1 0.00390671 0
2.7 0.00390671 0 3.3 0.00390671 0 3.9 0.00390671 0 4.5 0.00390671 0 5.1 0.00390671 0 5.7 0.00390671 0 0.3 0.00570872 0 0.9 0.00570872 0 1.5 0.00570872 0 2.1 0.00570872 0 2.7 0.00570872 0 3.3 0.00570872 0 3.9 0.00570872 0 4.5 0.00570872 0 5.1 0.00570872 0 5.7 0.00570872 0
0.3 0.00823153 0 0.9 0.00823153 0 1.5 0.00823153 0 2.1 0.00823153 0 2.7 0.00823153 0 3.3 0.00823153 0 3.9 0.00823153 0 4.5 0.00823153 0 5.1 0.00823153 0 5.7 0.00823153 0 0.3 0.0117635 0 0.9 0.0117635 0 1.5 0.0117635 0 2.1 0.0117635 0 2.7 0.0117635 0 3.3 0.0117635 0
3.9 0.0117635 0 4.5 0.0117635 0 5.1 0.0117635 0 5.7 0.0117635 0 0.3 0.0167082 0 0.9 0.0167082 0 1.5 0.0167082 0 2.1 0.0167082 0 2.7 0.0167082 0 3.3 0.0167082 0 3.9 0.0167082 0 4.5 0.0167082 0 5.1 0.0167082 0 5.7 0.0167082 0 0.3 0.0236308 0 0.9 0.0236308 0
1.5 0.0236308 0 2.1 0.0236308 0 2.7 0.0236308 0 3.3 0.0236308 0 3.9 0.0236308 0 4.5 0.0236308 0 5.1 0.0236308 0 5.7 0.0236308 0 0.3 0.0333224 0 0.9 0.0333224 0 1.5 0.0333224 0 2.1 0.0333224 0 2.7 0.0333224 0 3.3 0.0333224 0 3.9 0.0333224 0 4.5 0.0333224 0
5.1 0.0333224 0 5.7 0.0333224 0 0.3 0.0468907 0 0.9 0.0468907 0 1.5 0.0468907 0 2.1 0.0468907 0 2.7 0.0468907 0 3.3 0.0468907 0 3.9 0.0468907 0 4.5 0.0468907 0 5.1 0.0468907 0 5.7 0.0468907 0 0.3 0.0658863 0 0.9 0.0658863 0 1.5 0.0658863 0 2.1 0.0658863 0
2.7 0.0658863 0 3.3 0.0658863 0 3.9 0.0658863 0 4.5 0.0658863 0 5.1 0.0658863 0 5.7 0.0658863 0 0.3 0.0924801 0 0.9 0.0924801 0 1.5 0.0924801 0 2.1 0.0924801 0 2.7 0.0924801 0 3.3 0.0924801 0 3.9 0.0924801 0 4.5 0.0924801 0 5.1 0.0924801 0 5.7 0.0924801 0
0.3 0.129712 0 0.9 0.129712 0 1.5 0.129712 0 2.1 0.129712 0 2.7 0.129712 0 3.3 0.129712 0 3.9 0.129712 0 4.5 0.129712 0 5.1 0.129712 0 5.7 0.129712 0 0.3 0.181835 0 0.9 0.181835 0 1.5 0.181835 0 2.1 0.181835 0 2.7 0.181835 0 3.3 0.181835 0
3.9 0.181835 0 4.5 0.181835 0 5.1 0.181835 0 5.7 0.181835 0 0.3 0.254809 0 0.9 0.254809 0 1.5 0.254809 0 2.1 0.254809 0 2.7 0.254809 0 3.3 0.254809 0 3.9 0.254809 0 4.5 0.254809 0 5.1 0.254809 0 5.7 0.254809 0 0.3 0.356972 0 0.9 0.356972 0
1.5 0.356972 0 2.1 0.356972 0 2.7 0.356972 0 3.3 0.356972 0 3.9 0.356972 0 4.5 0.356972 0 5.1 0.356972 0 5.7 0.356972 0 0.3 0.5 0 0.9 0.5 0 1.5 0.5 0 2.1 0.5 0 2.7 0.5 0 3.3 0.5 0 3.9 0.5 0 4.5 0.5 0
5.1 0.5 0 5.7 0.5 0 0 0.000119663 0 0.6 0.000119663 0 1.2 0.000119663 0 1.8 0.000119663 0 2.4 0.000119663 0 3 0.000119663 0 3.6 0.000119663 0 4.2 0.000119663 0 4.8 0.000119663 0 5.4 0.000119663 0 6 0.000119663 0 0 0.000406853 0 0.6 0.000406853 0 1.2 0.000406853 0
1.8 0.000406853 0 2.4 0.000406853 0 3 0.000406853 0 3.6 0.000406853 0 4.2 0.000406853 0 4.8 0.000406853 0 5.4 0.000406853 0 6 0.000406853 0 0 0.00080892 0 0.6 0.00080892 0 1.2 0.00080892 0 1.8 0.00080892 0 2.4 0.00080892 0 3 0.00080892 0 3.6 0.00080892 0 4.2 0.00080892 0
4.8 0.00080892 0 5.4 0.00080892 0 6 0.00080892 0 0 0.00137181 0 0.6 0.00137181 0 1.2 0.00137181 0 1.8 0.00137181 0 2.4 0.00137181 0 3 0.00137181 0 3.6 0.00137181 0 4.2 0.00137181 0 4.8 0.00137181 0 5.4 0.00137181 0 6 0.00137181 0 0 0.00215986 0 0.6 0.00215986 0
1.2 0.00215986 0 1.8 0.00215986 0 2.4 0.00215986 0 3 0.00215986 0 3.6 0.00215986 0 4.2 0.00215986 0 4.8 0.00215986 0 5.4 0.00215986 0 6 0.00215986 0 0 0.00326313 0 0.6 0.00326313 0 1.2 0.00326313 0 1.8 0.00326313 0 2.4 0.00326313 0 3 0.00326313 0 3.6 0.00326313 0
4.2 0.00326313 0 4.8 0.00326313 0 5.4 0.00326313 0 6 0.00326313 0 0 0.00480771 0 0.6 0.00480771 0 1.2 0.00480771 0 1.8 0.00480771 0 2.4 0.00480771 0 3 0.00480771 0 3.6 0.00480771 0 4.2 0.00480771 0 4.8 0.00480771 0 5.4 0.00480771 0 6 0.00480771 0 0 0.00697012 0
0.6 0.00697012 0 1.2 0.00697012 0 1.8 0.00697012 0 2.4 0.00697012 0 3 0.00697012 0 3.6 0.00697012 0 4.2 0.00697012 0 4.8 0.00697012 0 5.4 0.00697012 0 6 0.00697012 0 0 0.0099975 0 0.6 0.0099975 0 1.2 0.0099975 0 1.8 0.0099975 0 2.4 0.0099975 0 3 0.0099975 0
3.6 0.0099975 0 4.2 0.0099975 0 4.8 0.0099975 0 5.4 0.0099975 0 6 0.0099975 0 0 0.0142358 0 0.6 0.0142358 0 1.2 0.0142358 0 1.8 0.0142358 0 2.4 0.0142358 0 3 0.0142358 0 3.6 0.0142358 0 4.2 0.0142358 0 4.8 0.0142358 0 5.4 0.0142358 0 6 0.0142358 0
0 0.0201695 0 0.6 0.0201695 0 1.2 0.0201695 0 1.8 0.0201695 0 2.4 0.0201695 0 3 0.0201695 0 3.6 0.0201695 0 4.2 0.0201695 0 4.8 0.0201695 0 5.4 0.0201695 0 6 0.0201695 0 0 0.0284766 0 0.6 0.0284766 0 1.2 0.0284766 0 1.8 0.0284766 0 2.4 0.0284766 0
3 0.0284766 0 3.6 0.0284766 0 4.2 0.0284766 0 4.8 0.0284766 0 5.4 0.0284766 0 6 0.0284766 0 0 0.0401066 0 0.6 0.0401066 0 1.2 0.0401066 0 1.8 0.0401066 0 2.4 0.0401066 0 3 0.0401066 0 3.6 0.0401066 0 4.2 0.0401066 0 4.8 0.0401066 0 5.4 0.0401066 0
6 0.0401066 0 0 0.0563885 0 0.6 0.0563885 0 1.2 0.0563885 0 1.8 0.0563885 0 2.4 0.0563885 0 3 0.0563885 0 3.6 0.0563885 0 4.2 0.0563885 0 4.8 0.0563885 0 5.4 0.0563885 0 6 0.0563885 0 0 0.0791832 0 0.6 0.0791832 0 1.2 0.0791832 0 1.8 0.0791832 0
2.4 0.0791832 0 3 0.0791832 0 3.6 0.0791832 0 4.2 0.0791832 0 4.8 0.0791832 0 5.4 0.0791832 0 6 0.0791832 0 0 0.111096 0 0.6 0.111096 0 1.2 0.111096 0 1.8 0.111096 0 2.4 0.111096 0 3 0.111096 0 3.6 0.111096 0 4.2 0.111096 0 4.8 0.111096 0
5.4 0.111096 0 6 0.111096 0 0 0.155774 0 0.6 0.155774 0 1.2 0.155774 0 1.8 0.155774 0 2.4 0.155774 0 3 0.155774 0 3.6 0.155774 0 4.2 0.155774 0 4.8 0.155774 0 5.4 0.155774 0 6 0.155774 0 0 0.218322 0 0.6 0.218322 0 1.2 0.218322 0
1.8 0.218322 0 2.4 0.218322 0 3 0.218322 0 3.6 0.218322 0 4.2 0.218322 0 4.8 0.218322 0 5.4 0.218322 0 6 0.218322 0 0 0.30589 0 0.6 0.30589 0 1.2 0.30589 0 1.8 0.30589 0 2.4 0.30589 0 3 0.30589 0 3.6 0.30589 0 4.2 0.30589 0
4.8 0.30589 0 5.4 0.30589 0 6 0.30589 0 0 0.428486 0 0.6 0.428486 0 1.2 0.428486 0 1.8 0.428486 0 2.4 0.428486 0 3 0.428486 0 3.6 0.428486 0 4.2 0.428486 0 4.8 0.428486 0 5.4 0.428486 0 6 0.428486 0
</DataArray>
</Points>
<PointData Scalars="v" Vectors="faceVelocity">
<DataArray type="Float32" Name="v" NumberOfComponents="1" format="ascii">
0 0 0 0 0 0 0 0 0 0 3.94956e-05 1.97127e-07 3.58586e-08 1.33835e-08 6.06295e-09 3.27245e-09
2.15402e-09 1.64163e-09 1.19703e-09 1.04446e-09 9.34963e-05 1.11213e-06 2.06407e-07 7.70206e-08 3.48855e-08 1.88285e-08 1.23943e-08 9.44669e-09 6.88998e-09 5.97345e-09 0.000166627 3.5827e-06
6.80632e-07 2.53926e-07 1.1499e-07 6.20602e-08 4.08553e-08 3.1142e-08 2.272e-08 1.95518e-08 0.000264342 9.20499e-06 1.80459e-06 6.7316e-07 3.04762e-07 1.64473e-07 1.08287e-07 8.25519e-08
6.02498e-08 5.13297e-08 0.00039245 2.08738e-05 4.27391e-06 1.59467e-06 7.21752e-07 3.89498e-07 2.56483e-07 1.95565e-07 1.42807e-07 1.19971e-07 0.000555959 4.35125e-05 9.46025e-06 3.53485e-06
1.59952e-06 8.63224e-07 5.68598e-07 4.33677e-07 3.16911e-07 2.61045e-07 0.000756857 8.47267e-05 1.99884e-05 7.50354e-06 3.39606e-06 1.83337e-06 1.20833e-06 9.22058e-07 6.74457e-07 5.40386e-07
0.000990685 0.000154459 4.05893e-05 1.5425e-05 6.9948e-06 3.78097e-06 2.49485e-06 1.90512e-06 1.39529e-06 1.0755e-06 0.00124262 0.000261702 7.87545e-05 3.07921e-05 1.40752e-05 7.6418e-06
5.05225e-06 3.85776e-06 2.82915e-06 2.06778e-06 0.00148593 0.000406601 0.000143451 5.95214e-05 2.79565e-05 1.53975e-05 1.01988e-05 7.74149e-06 5.67983e-06 3.86664e-06 0.00168739 0.000572275
0.000239693 0.000110563 5.55863e-05 3.17723e-05 2.11154e-05 1.5755e-05 1.15372e-05 7.18371e-06 0.00182006 0.000727262 0.000359301 0.000191463 0.000107623 6.57123e-05 4.4396e-05 3.26152e-05
2.38539e-05 1.35155e-05 0.00187312 0.000840534 0.00047506 0.000293843 0.000189106 0.000126772 8.94128e-05 6.60957e-05 4.87393e-05 2.55447e-05 0.001849 0.000897946 0.000554813 0.000385716
0.000282266 0.000211585 0.000161015 0.000124013 9.41288e-05 4.70477e-05 0.00175206 0.000901338 0.000585736 0.000436687 0.00034931 0.000288703 0.000240737 0.000199724 0.0001607 7.95436e-05
0.00158226 0.000853663 0.000570271 0.000440832 0.000369673 0.000323797 0.000288632 0.000257074 0.000221385 0.00011195 0.00133562 0.000752 0.000509674 0.000401269 0.000344385 0.000310276
0.00028618 0.000265373 0.000238066 0.000123623 0.00100153 0.000587001 0.000400285 0.000317718 0.000275756 0.000251796 0.00023592 0.000222759 0.000202893 0.000107935 0.000568509 0.000345282
0.000235667 0.00018725 0.000163096 0.000149691 0.000141145 0.000134201 0.000122562 6.67098e-05 0 0 0 0 0 0 0 0
0 0 0.1 0.00098268 0.000488473 0.000398575 0.000365023 0.000349824 0.000341622 0.000336223 0.000332109 0.00032911 0.000326493 0.1 0.00329834 0.00165981
0.0013544 0.00124045 0.00118884 0.00116099 0.00114266 0.00112868 0.00111849 0.00110967 0.1 0.00645778 0.00329766 0.00269108 0.00246481 0.00236235 0.00230707 0.00227067
0.00224293 0.0022227 0.00220534 0.1 0.0107232 0.00558637 0.00455949 0.00417647 0.0040031 0.00390955 0.00384796 0.00380101 0.00376674 0.00373772 0.1 0.0163959
0.0087808 0.00716932 0.00656796 0.00629586 0.00614903 0.00605235 0.00597863 0.00592478 0.00588001 0.1 0.0237812 0.0132282 0.0108107 0.00990627 0.00949714 0.00927636
0.00913092 0.00901997 0.00893885 0.00887313 0.1 0.0331086 0.0193859 0.0158804 0.0145591 0.0139609 0.013638 0.013425 0.0132625 0.0131435 0.0130505 0.1
0.0443886 0.0278041 0.0229047 0.0210208 0.020165 0.0197019 0.019396 0.0191623 0.018991 0.0188638 0.1 0.057201 0.0389829 0.0324995 0.0298891 0.0286864
0.0280306 0.0275963 0.0272647 0.0270213 0.0268528 0.1 0.0704769 0.0528946 0.0450443 0.0415584 0.0398742 0.0389333 0.038309 0.0378379 0.0374922 0.0372741
0.1 0.0825386 0.0681792 0.0598378 0.0554142 0.0530196 0.0516006 0.0506547 0.0499604 0.049453 0.0491657 0.1 0.0917872 0.0821922 0.0747876 0.0697794
0.0665581 0.0644572 0.0630163 0.0619728 0.0612105 0.0608188 0.1 0.0976536 0.0926449 0.0875263 0.0829993 0.0793965 0.0766968 0.0747065 0.0732263 0.0721261
0.0715945 0.1 0.100762 0.0989494 0.0964308 0.0935294 0.0905873 0.0879088 0.0856475 0.0838185 0.0823852 0.0817063 0.1 0.102188 0.102112 0.101415
0.100266 0.098754 0.0970146 0.0952163 0.0935084 0.0920067 0.0912738 0.1 0.102738 0.103508 0.103759 0.103693 0.103365 0.1028 0.102028 0.101104
0.100126 0.099604 0.1 0.102845 0.104018 0.104716 0.105172 0.105463 0.105619 0.105647 0.105551 0.105359 0.105224 0.1 0.102737 0.104088
0.104984 0.105669 0.106231 0.106711 0.107123 0.107473 0.107762 0.10789 0.1 0.102546 0.103967 0.104934 0.105701 0.106363 0.106962 0.107519
0.108039 0.10851 0.108752 0.1 0.102385 0.103834 0.104823 0.105609 0.106293 0.106922 0.107514 0.108077 0.108592 0.108872
</DataArray>
<DataArray type="Float32" Name="faceVelocity" NumberOfComponents="3" format="ascii">
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.94956e-05 0 0 1.97127e-07 0 0 3.58586e-08 0 0 1.33835e-08 0 0 6.06295e-09 0 0 3.27245e-09 0
0 2.15402e-09 0 0 1.64163e-09 0 0 1.19703e-09 0 0 1.04446e-09 0 0 9.34963e-05 0 0 1.11213e-06 0 0 2.06407e-07 0 0 7.70206e-08 0 0 3.48855e-08 0 0 1.88285e-08 0 0 1.23943e-08 0 0 9.44669e-09 0 0 6.88998e-09 0 0 5.97345e-09 0 0 0.000166627 0 0 3.5827e-06 0
0 6.80632e-07 0 0 2.53926e-07 0 0 1.1499e-07 0 0 6.20602e-08 0 0 4.08553e-08 0 0 3.1142e-08 0 0 2.272e-08 0 0 1.95518e-08 0 0 0.000264342 0 0 9.20499e-06 0 0 1.80459e-06 0 0 6.7316e-07 0 0 3.04762e-07 0 0 1.64473e-07 0 0 1.08287e-07 0 0 8.25519e-08 0
0 6.02498e-08 0 0 5.13297e-08 0 0 0.00039245 0 0 2.08738e-05 0 0 4.27391e-06 0 0 1.59467e-06 0 0 7.21752e-07 0 0 3.89498e-07 0 0 2.56483e-07 0 0 1.95565e-07 0 0 1.42807e-07 0 0 1.19971e-07 0 0 0.000555959 0 0 4.35125e-05 0 0 9.46025e-06 0 0 3.53485e-06 0
0 1.59952e-06 0 0 8.63224e-07 0 0 5.68598e-07 0 0 4.33677e-07 0 0 3.16911e-07 0 0 2.61045e-07 0 0 0.000756857 0 0 8.47267e-05 0 0 1.99884e-05 0 0 7.50354e-06 0 0 3.39606e-06 0 0 1.83337e-06 0 0 1.20833e-06 0 0 9.22058e-07 0 0 6.74457e-07 0 0 5.40386e-07 0
0 0.000990685 0 0 0.000154459 0 0 4.05893e-05 0 0 1.5425e-05 0 0 6.9948e-06 0 0 3.78097e-06 0 0 2.49485e-06 0 0 1.90512e-06 0 0 1.39529e-06 0 0 1.0755e-06 0 0 0.00124262 0 0 0.000261702 0 0 7.87545e-05 0 0 3.07921e-05 0 0 1.40752e-05 0 0 7.6418e-06 0
0 5.05225e-06 0 0 3.85776e-06 0 0 2.82915e-06 0 0 2.06778e-06 0 0 0.00148593 0 0 0.000406601 0 0 0.000143451 0 0 5.95214e-05 0 0 2.79565e-05 0 0 1.53975e-05 0 0 1.01988e-05 0 0 7.74149e-06 0 0 5.67983e-06 0 0 3.86664e-06 0 0 0.00168739 0 0 0.000572275 0
0 0.000239693 0 0 0.000110563 0 0 5.55863e-05 0 0 3.17723e-05 0 0 2.11154e-05 0 0 1.5755e-05 0 0 1.15372e-05 0 0 7.18371e-06 0 0 0.00182006 0 0 0.000727262 0 0 0.000359301 0 0 0.000191463 0 0 0.000107623 0 0 6.57123e-05 0 0 4.4396e-05 0 0 3.26152e-05 0
0 2.38539e-05 0 0 1.35155e-05 0 0 0.00187312 0 0 0.000840534 0 0 0.00047506 0 0 0.000293843 0 0 0.000189106 0 0 0.000126772 0 0 8.94128e-05 0 0 6.60957e-05 0 0 4.87393e-05 0 0 2.55447e-05 0 0 0.001849 0 0 0.000897946 0 0 0.000554813 0 0 0.000385716 0
0 0.000282266 0 0 0.000211585 0 0 0.000161015 0 0 0.000124013 0 0 9.41288e-05 0 0 4.70477e-05 0 0 0.00175206 0 0 0.000901338 0 0 0.000585736 0 0 0.000436687 0 0 0.00034931 0 0 0.000288703 0 0 0.000240737 0 0 0.000199724 0 0 0.0001607 0 0 7.95436e-05 0
0 0.00158226 0 0 0.000853663 0 0 0.000570271 0 0 0.000440832 0 0 0.000369673 0 0 0.000323797 0 0 0.000288632 0 0 0.000257074 0 0 0.000221385 0 0 0.00011195 0 0 0.00133562 0 0 0.000752 0 0 0.000509674 0 0 0.000401269 0 0 0.000344385 0 0 0.000310276 0
0 0.00028618 0 0 0.000265373 0 0 0.000238066 0 0 0.000123623 0 0 0.00100153 0 0 0.000587001 0 0 0.000400285 0 0 0.000317718 0 0 0.000275756 0 0 0.000251796 0 0 0.00023592 0 0 0.000222759 0 0 0.000202893 0 0 0.000107935 0 0 0.000568509 0 0 0.000345282 0
0 0.000235667 0 0 0.00018725 0 0 0.000163096 0 0 0.000149691 0 0 0.000141145 0 0 0.000134201 0 0 0.000122562 0 0 6.67098e-05 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0.1 0 0 0.00098268 0 0 0.000488473 0 0 0.000398575 0 0 0.000365023 0 0 0.000349824 0 0 0.000341622 0 0 0.000336223 0 0 0.000332109 0 0 0.00032911 0 0 0.000326493 0 0 0.1 0 0 0.00329834 0 0 0.00165981 0 0
0.0013544 0 0 0.00124045 0 0 0.00118884 0 0 0.00116099 0 0 0.00114266 0 0 0.00112868 0 0 0.00111849 0 0 0.00110967 0 0 0.1 0 0 0.00645778 0 0 0.00329766 0 0 0.00269108 0 0 0.00246481 0 0 0.00236235 0 0 0.00230707 0 0 0.00227067 0 0
0.00224293 0 0 0.0022227 0 0 0.00220534 0 0 0.1 0 0 0.0107232 0 0 0.00558637 0 0 0.00455949 0 0 0.00417647 0 0 0.0040031 0 0 0.00390955 0 0 0.00384796 0 0 0.00380101 0 0 0.00376674 0 0 0.00373772 0 0 0.1 0 0 0.0163959 0 0
0.0087808 0 0 0.00716932 0 0 0.00656796 0 0 0.00629586 0 0 0.00614903 0 0 0.00605235 0 0 0.00597863 0 0 0.00592478 0 0 0.00588001 0 0 0.1 0 0 0.0237812 0 0 0.0132282 0 0 0.0108107 0 0 0.00990627 0 0 0.00949714 0 0 0.00927636 0 0
0.00913092 0 0 0.00901997 0 0 0.00893885 0 0 0.00887313 0 0 0.1 0 0 0.0331086 0 0 0.0193859 0 0 0.0158804 0 0 0.0145591 0 0 0.0139609 0 0 0.013638 0 0 0.013425 0 0 0.0132625 0 0 0.0131435 0 0 0.0130505 0 0 0.1 0 0
0.0443886 0 0 0.0278041 0 0 0.0229047 0 0 0.0210208 0 0 0.020165 0 0 0.0197019 0 0 0.019396 0 0 0.0191623 0 0 0.018991 0 0 0.0188638 0 0 0.1 0 0 0.057201 0 0 0.0389829 0 0 0.0324995 0 0 0.0298891 0 0 0.0286864 0 0
0.0280306 0 0 0.0275963 0 0 0.0272647 0 0 0.0270213 0 0 0.0268528 0 0 0.1 0 0 0.0704769 0 0 0.0528946 0 0 0.0450443 0 0 0.0415584 0 0 0.0398742 0 0 0.0389333 0 0 0.038309 0 0 0.0378379 0 0 0.0374922 0 0 0.0372741 0 0
0.1 0 0 0.0825386 0 0 0.0681792 0 0 0.0598378 0 0 0.0554142 0 0 0.0530196 0 0 0.0516006 0 0 0.0506547 0 0 0.0499604 0 0 0.049453 0 0 0.0491657 0 0 0.1 0 0 0.0917872 0 0 0.0821922 0 0 0.0747876 0 0 0.0697794 0 0
0.0665581 0 0 0.0644572 0 0 0.0630163 0 0 0.0619728 0 0 0.0612105 0 0 0.0608188 0 0 0.1 0 0 0.0976536 0 0 0.0926449 0 0 0.0875263 0 0 0.0829993 0 0 0.0793965 0 0 0.0766968 0 0 0.0747065 0 0 0.0732263 0 0 0.0721261 0 0
0.0715945 0 0 0.1 0 0 0.100762 0 0 0.0989494 0 0 0.0964308 0 0 0.0935294 0 0 0.0905873 0 0 0.0879088 0 0 0.0856475 0 0 0.0838185 0 0 0.0823852 0 0 0.0817063 0 0 0.1 0 0 0.102188 0 0 0.102112 0 0 0.101415 0 0
0.100266 0 0 0.098754 0 0 0.0970146 0 0 0.0952163 0 0 0.0935084 0 0 0.0920067 0 0 0.0912738 0 0 0.1 0 0 0.102738 0 0 0.103508 0 0 0.103759 0 0 0.103693 0 0 0.103365 0 0 0.1028 0 0 0.102028 0 0 0.101104 0 0
0.100126 0 0 0.099604 0 0 0.1 0 0 0.102845 0 0 0.104018 0 0 0.104716 0 0 0.105172 0 0 0.105463 0 0 0.105619 0 0 0.105647 0 0 0.105551 0 0 0.105359 0 0 0.105224 0 0 0.1 0 0 0.102737 0 0 0.104088 0 0
0.104984 0 0 0.105669 0 0 0.106231 0 0 0.106711 0 0 0.107123 0 0 0.107473 0 0 0.107762 0 0 0.10789 0 0 0.1 0 0 0.102546 0 0 0.103967 0 0 0.104934 0 0 0.105701 0 0 0.106363 0 0 0.106962 0 0 0.107519 0 0
0.108039 0 0 0.10851 0 0 0.108752 0 0 0.1 0 0 0.102385 0 0 0.103834 0 0 0.104823 0 0 0.105609 0 0 0.106293 0 0 0.106922 0 0 0.107514 0 0 0.108077 0 0 0.108592 0 0 0.108872 0 0
</DataArray>
</PointData>
</Piece>
</PolyData>
</VTKFile>
\ No newline at end of file
......@@ -74,25 +74,33 @@ int main(int argc, char** argv) try
}
Dumux::VTKReader::Data reorderedCellData = cellData, reorderedPointData = pointData;
for (const auto& data : cellData)
for (const auto& [name, data] : cellData)
{
auto& reorderedData = reorderedCellData[data.first];
for (unsigned int i = 0; i < data.second.size(); ++i)
reorderedData[elementIndex[i]] = data.second[i];
// sanity check
if (!vtkReader->hasData(name, Dumux::VTKReader::DataType::cellData))
DUNE_THROW(Dune::Exception, "Array " << name << " exists but hasData returns false!");
auto& reorderedData = reorderedCellData[name];
for (unsigned int i = 0; i < data.size(); ++i)
reorderedData[elementIndex[i]] = data[i];
}
for (const auto& data : pointData)
for (const auto& [name, data] : pointData)
{
auto& reorderedData = reorderedPointData[data.first];
for (unsigned int i = 0; i < data.second.size(); ++i)
reorderedData[vertexIndex[i]] = data.second[i];
// sanity check
if (!vtkReader->hasData(name, Dumux::VTKReader::DataType::pointData))
DUNE_THROW(Dune::Exception, "Array " << name << " exists but hasData returns false!");
auto& reorderedData = reorderedPointData[name];
for (unsigned int i = 0; i < data.size(); ++i)
reorderedData[vertexIndex[i]] = data[i];
}
Dune::VTKWriter<Grid::LeafGridView> vtkWriter(gridView);
for (const auto& data : reorderedCellData)
vtkWriter.addCellData(data.second, data.first);
for (const auto& data : reorderedPointData)
vtkWriter.addVertexData(data.second, data.first);
for (const auto& [name, data] : reorderedCellData)
vtkWriter.addCellData(data, name);
for (const auto& [name, data] : reorderedPointData)
vtkWriter.addVertexData(data, name);
vtkWriter.write(std::string(argv[2]));
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment