From 6126af8b37b75453ef9df1248e0e63b6f68eb061 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Wed, 15 Nov 2017 10:02:03 +0100 Subject: [PATCH] [staggered][test] Allow possibility to write face velocity for two tests * test_donea * test_kovasznay * do not write Scalar value of face velocity, redundant --- dumux/freeflow/staggered/vtkoutputfields.hh | 4 +-- test/freeflow/staggered/doneatestproblem.hh | 34 ++++++++++-------- .../staggered/kovasznaytestproblem.hh | 35 +++++++++++-------- test/freeflow/staggered/test_donea.cc | 2 +- test/freeflow/staggered/test_donea.input | 3 +- test/freeflow/staggered/test_kovasznay.cc | 5 +-- test/freeflow/staggered/test_kovasznay.input | 1 + 7 files changed, 48 insertions(+), 36 deletions(-) diff --git a/dumux/freeflow/staggered/vtkoutputfields.hh b/dumux/freeflow/staggered/vtkoutputfields.hh index 8e848827ad..4a46bf86be 100644 --- a/dumux/freeflow/staggered/vtkoutputfields.hh +++ b/dumux/freeflow/staggered/vtkoutputfields.hh @@ -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)) diff --git a/test/freeflow/staggered/doneatestproblem.hh b/test/freeflow/staggered/doneatestproblem.hh index bc2ff22e55..8b5c043e18 100644 --- a/test/freeflow/staggered/doneatestproblem.hh +++ b/test/freeflow/staggered/doneatestproblem.hh @@ -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 diff --git a/test/freeflow/staggered/kovasznaytestproblem.hh b/test/freeflow/staggered/kovasznaytestproblem.hh index 5864b28038..c24cf07a47 100644 --- a/test/freeflow/staggered/kovasznaytestproblem.hh +++ b/test/freeflow/staggered/kovasznaytestproblem.hh @@ -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 diff --git a/test/freeflow/staggered/test_donea.cc b/test/freeflow/staggered/test_donea.cc index 70ba090206..a5dfb91d0c 100644 --- a/test/freeflow/staggered/test_donea.cc +++ b/test/freeflow/staggered/test_donea.cc @@ -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 diff --git a/test/freeflow/staggered/test_donea.input b/test/freeflow/staggered/test_donea.input index fb629d84f2..d58cec3d52 100644 --- a/test/freeflow/staggered/test_donea.input +++ b/test/freeflow/staggered/test_donea.input @@ -18,4 +18,5 @@ MaxSteps = 10 MaxRelativeShift = 1e-5 [Vtk] -AddVelocity = 1 +WriteFaceData = false +AddVelocity = true diff --git a/test/freeflow/staggered/test_kovasznay.cc b/test/freeflow/staggered/test_kovasznay.cc index d175057a31..216877cb32 100644 --- a/test/freeflow/staggered/test_kovasznay.cc +++ b/test/freeflow/staggered/test_kovasznay.cc @@ -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 diff --git a/test/freeflow/staggered/test_kovasznay.input b/test/freeflow/staggered/test_kovasznay.input index 4372ca4e49..1bcc53d179 100644 --- a/test/freeflow/staggered/test_kovasznay.input +++ b/test/freeflow/staggered/test_kovasznay.input @@ -21,4 +21,5 @@ MaxSteps = 10 MaxRelativeShift = 1e-5 [Vtk] +WriteFaceData = false AddVelocity = true -- GitLab