Commit 6126af8b authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[staggered][test] Allow possibility to write face velocity for two tests

* test_donea
* test_kovasznay
* do not write Scalar value of face velocity, redundant
parent 0a7d6aa1
......@@ -54,8 +54,6 @@ public:
const bool writeFaceVars_ = getParamFromGroup<bool>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "Vtk.WriteFaceData", false);
if(writeFaceVars_)
{
vtk.addFaceVariable([](const FaceVariables& f){ return f.velocitySelf(); }, "scalarFaceVelocity");
auto faceVelocityVector = [](const SubControlVolumeFace& scvf, const FaceVariables& f)
{
GlobalPosition velocity(0.0);
......@@ -63,7 +61,7 @@ public:
return velocity;
};
vtk.addFaceVariable(faceVelocityVector, "vectorFaceVelocity");
vtk.addFaceVariable(faceVelocityVector, "faceVelocity");
}
if(GET_PROP_VALUE(TypeTag, EnableEnergyBalance))
......
......@@ -369,6 +369,14 @@ public:
return analyticalVelocity_;
}
/*!
* \brief Returns the analytical solution for the velocity at the faces
*/
auto& getAnalyticalVelocitySolutionOnFace() const
{
return analyticalVelocityOnFace_;
}
private:
/*!
......@@ -378,6 +386,7 @@ private:
{
analyticalPressure_.resize(this->fvGridGeometry().numCellCenterDofs());
analyticalVelocity_.resize(this->fvGridGeometry().numCellCenterDofs());
analyticalVelocityOnFace_.resize(this->fvGridGeometry().numFaceDofs());
for (const auto& element : elements(this->fvGridGeometry().gridView()))
......@@ -390,20 +399,16 @@ private:
auto ccDofPosition = scv.dofPosition();
auto analyticalSolutionAtCc = analyticalSolution(ccDofPosition);
// TODO: velocities on faces
// GlobalPosition velocityVector(0.0);
// for (auto&& scvf : scvfs(fvGeometry))
// {
// auto faceDofIdx = scvf.dofIndex();
// auto faceDofPosition = scvf.center();
// auto dirIdx = scvf.directionIndex();
// auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition);
// // scalarFaceVelocityExact[faceDofIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
//
// GlobalPosition tmp(0.0);
// tmp[dirIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
// vectorFaceVelocityExact[faceDofIdx] = std::move(tmp);
// }
// velocities on faces
for (auto&& scvf : scvfs(fvGeometry))
{
const auto faceDofIdx = scvf.dofIndex();
const auto faceDofPosition = scvf.center();
const auto dirIdx = scvf.directionIndex();
const auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition);
analyticalVelocityOnFace_[faceDofIdx][dirIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
}
analyticalPressure_[ccDofIdx] = analyticalSolutionAtCc[pressureIdx];
analyticalVelocity_[ccDofIdx] = analyticalSolutionAtCc[faceIdx];
}
......@@ -420,6 +425,7 @@ private:
bool printL2Error_;
std::vector<Scalar> analyticalPressure_;
std::vector<GlobalPosition> analyticalVelocity_;
std::vector<GlobalPosition> analyticalVelocityOnFace_;
};
} //end namespace
......
......@@ -365,6 +365,14 @@ public:
return analyticalVelocity_;
}
/*!
* \brief Returns the analytical solution for the velocity at the faces
*/
auto& getAnalyticalVelocitySolutionOnFace() const
{
return analyticalVelocityOnFace_;
}
private:
/*!
......@@ -374,7 +382,7 @@ private:
{
analyticalPressure_.resize(this->fvGridGeometry().numCellCenterDofs());
analyticalVelocity_.resize(this->fvGridGeometry().numCellCenterDofs());
analyticalVelocityOnFace_.resize(this->fvGridGeometry().numFaceDofs());
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
......@@ -386,20 +394,16 @@ private:
auto ccDofPosition = scv.dofPosition();
auto analyticalSolutionAtCc = analyticalSolution(ccDofPosition);
// TODO: velocities on faces
// GlobalPosition velocityVector(0.0);
// for (auto&& scvf : scvfs(fvGeometry))
// {
// auto faceDofIdx = scvf.dofIndex();
// auto faceDofPosition = scvf.center();
// auto dirIdx = scvf.directionIndex();
// auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition);
// // scalarFaceVelocityExact[faceDofIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
//
// GlobalPosition tmp(0.0);
// tmp[dirIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
// vectorFaceVelocityExact[faceDofIdx] = std::move(tmp);
// }
// velocities on faces
for (auto&& scvf : scvfs(fvGeometry))
{
const auto faceDofIdx = scvf.dofIndex();
const auto faceDofPosition = scvf.center();
const auto dirIdx = scvf.directionIndex();
const auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition);
analyticalVelocityOnFace_[faceDofIdx][dirIdx] = analyticalSolutionAtFace[faceIdx][dirIdx];
}
analyticalPressure_[ccDofIdx] = analyticalSolutionAtCc[pressureIdx];
analyticalVelocity_[ccDofIdx] = analyticalSolutionAtCc[faceIdx];
}
......@@ -425,6 +429,7 @@ private:
bool printL2Error_;
std::vector<Scalar> analyticalPressure_;
std::vector<GlobalPosition> analyticalVelocity_;
std::vector<GlobalPosition> analyticalVelocityOnFace_;
};
} //end namespace
......
......@@ -52,7 +52,6 @@
#include <dumux/discretization/methods.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/staggeredvtkoutputmodule.hh>
/*!
......@@ -162,6 +161,7 @@ int main(int argc, char** argv) try
VtkOutputFields::init(vtkWriter); //! Add model specific output fields
vtkWriter.addField(problem->getAnalyticalPressureSolution(), "pressureExact", 1);
vtkWriter.addField(problem->getAnalyticalVelocitySolution(), "velocityExact", GridView::dimensionworld);
vtkWriter.addFaceField(problem->getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact");
vtkWriter.write(0.0);
// instantiate time loop
......
......@@ -18,4 +18,5 @@ MaxSteps = 10
MaxRelativeShift = 1e-5
[Vtk]
AddVelocity = 1
WriteFaceData = false
AddVelocity = true
......@@ -51,7 +51,7 @@
#include <dumux/discretization/methods.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/staggeredvtkoutputmodule.hh>
/*!
* \brief Provides an interface for customizing error messages associated with
......@@ -156,10 +156,11 @@ int main(int argc, char** argv) try
// intialize the vtk output module
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
StaggeredVtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputFields::init(vtkWriter); //! Add model specific output fields
vtkWriter.addField(problem->getAnalyticalPressureSolution(), "pressureExact", 1);
vtkWriter.addField(problem->getAnalyticalVelocitySolution(), "velocityExact", GridView::dimensionworld);
vtkWriter.addFaceField(problem->getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact");
vtkWriter.write(0.0);
// instantiate time loop
......
......@@ -21,4 +21,5 @@ MaxSteps = 10
MaxRelativeShift = 1e-5
[Vtk]
WriteFaceData = false
AddVelocity = true
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