From 9ce3675c187d3f1f0806c39931ee597b047f215c Mon Sep 17 00:00:00 2001 From: Melanie Lipp <melanie.lipp@iws.uni-stuttgart.de> Date: Fri, 27 Aug 2021 11:23:57 +0200 Subject: [PATCH] [test][freeflow] Process second round of comments in MR to move createAnalyticalSolution to file and reuse for several tests. --- .../freeflow/navierstokes/analyticalsolutionvectors.hh | 6 +----- test/freeflow/navierstokes/angeli/main.cc | 2 +- test/freeflow/navierstokes/angeli/problem.hh | 10 ++++------ test/freeflow/navierstokes/channel/1d/main.cc | 2 +- test/freeflow/navierstokes/channel/2d/main.cc | 2 +- test/freeflow/navierstokes/channel/pipe/problem.hh | 2 +- test/freeflow/navierstokes/donea/main.cc | 2 +- test/freeflow/navierstokes/kovasznay/main.cc | 2 +- test/freeflow/navierstokes/sincos/main.cc | 2 +- 9 files changed, 12 insertions(+), 18 deletions(-) diff --git a/test/freeflow/navierstokes/analyticalsolutionvectors.hh b/test/freeflow/navierstokes/analyticalsolutionvectors.hh index ec5f4f8d19..90c0842538 100644 --- a/test/freeflow/navierstokes/analyticalsolutionvectors.hh +++ b/test/freeflow/navierstokes/analyticalsolutionvectors.hh @@ -33,10 +33,6 @@ template<class Problem, class Scalar = double> class NavierStokesAnalyticalSolutionVectors { using GridGeometry = std::decay_t<decltype(std::declval<Problem>().gridGeometry())>; - using GridView = typename GridGeometry::GridView; - using FVElementGeometry = typename GridGeometry::LocalView; - using SubControlVolume = typename FVElementGeometry::SubControlVolume; - using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; static constexpr int dimWorld = GridGeometry::GridView::dimensionworld; using VelocityVector = Dune::FieldVector<Scalar, dimWorld>; using Indices = typename Problem::Indices; @@ -57,7 +53,7 @@ public: auto fvGeometry = localView(problem_->gridGeometry()); - for (const auto& element : elements((problem_->gridGeometry()).gridView())) + for (const auto& element : elements(problem_->gridGeometry().gridView())) { fvGeometry.bindElement(element); for (const auto& scv : scvs(fvGeometry)) diff --git a/test/freeflow/navierstokes/angeli/main.cc b/test/freeflow/navierstokes/angeli/main.cc index 4160b03bee..e392b941a8 100644 --- a/test/freeflow/navierstokes/angeli/main.cc +++ b/test/freeflow/navierstokes/angeli/main.cc @@ -113,7 +113,7 @@ int main(int argc, char** argv) StaggeredVtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name()); using IOFields = GetPropType<TypeTag, Properties::IOFields>; IOFields::initOutputModule(vtkWriter); // Add model specific output fields - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem, tStart); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem, tStart); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); vtkWriter.addFaceField(analyticalSolVectors.getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); diff --git a/test/freeflow/navierstokes/angeli/problem.hh b/test/freeflow/navierstokes/angeli/problem.hh index 1bb5ef935a..adcad9b279 100644 --- a/test/freeflow/navierstokes/angeli/problem.hh +++ b/test/freeflow/navierstokes/angeli/problem.hh @@ -77,7 +77,6 @@ public: rho_ = getParam<Scalar>("Component.LiquidDensity", 1.0); useVelocityAveragingForDirichlet_ = getParam<bool>("Problem.UseVelocityAveragingForDirichlet", false); useVelocityAveragingForInitial_ = getParam<bool>("Problem.UseVelocityAveragingForInitial", false); - tStart_ = getParam<Scalar>("TimeLoop.TStart", 0.0); } /*! @@ -164,7 +163,7 @@ public: /*! * \brief Returns the analytical solution of the problem at a given time and position. * \param globalPos The global position - * \param time A parameter for consistent signatures. It is ignored here as this is a stationary test + * \param time The current simulation time */ PrimaryVariables analyticalSolution(const GlobalPosition& globalPos, Scalar time) const { @@ -193,7 +192,7 @@ public: PrimaryVariables initial(const SubControlVolume& scv) const { PrimaryVariables priVars(0.0); - priVars[Indices::pressureIdx] = analyticalSolution(scv.center(), tStart_)[Indices::pressureIdx]; + priVars[Indices::pressureIdx] = analyticalSolution(scv.center(), time_)[Indices::pressureIdx]; return priVars; } @@ -210,9 +209,9 @@ public: PrimaryVariables initial(const SubControlVolumeFace& scvf) const { if (useVelocityAveragingForInitial_) - return averagedVelocity_(scvf, tStart_); + return averagedVelocity_(scvf, time_); else - return analyticalSolution(scvf.center(), tStart_); + return analyticalSolution(scvf.center(), time_); } // \} @@ -248,7 +247,6 @@ private: Scalar time_ = 0; bool useVelocityAveragingForDirichlet_; bool useVelocityAveragingForInitial_; - Scalar tStart_; }; } // end namespace Dumux diff --git a/test/freeflow/navierstokes/channel/1d/main.cc b/test/freeflow/navierstokes/channel/1d/main.cc index 3c3631f149..8890c711d1 100644 --- a/test/freeflow/navierstokes/channel/1d/main.cc +++ b/test/freeflow/navierstokes/channel/1d/main.cc @@ -98,7 +98,7 @@ int main(int argc, char** argv) StaggeredVtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name()); IOFields::initOutputModule(vtkWriter); // Add model specific output fields - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); vtkWriter.addFaceField(analyticalSolVectors.getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); diff --git a/test/freeflow/navierstokes/channel/2d/main.cc b/test/freeflow/navierstokes/channel/2d/main.cc index 1c68c547e0..621d7bd483 100644 --- a/test/freeflow/navierstokes/channel/2d/main.cc +++ b/test/freeflow/navierstokes/channel/2d/main.cc @@ -119,7 +119,7 @@ int main(int argc, char** argv) if (problem->hasAnalyticalSolution()) { - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); diff --git a/test/freeflow/navierstokes/channel/pipe/problem.hh b/test/freeflow/navierstokes/channel/pipe/problem.hh index 625a5389c6..833363066c 100644 --- a/test/freeflow/navierstokes/channel/pipe/problem.hh +++ b/test/freeflow/navierstokes/channel/pipe/problem.hh @@ -117,7 +117,7 @@ public: return values; } - PrimaryVariables analyticalSolution(const GlobalPosition& globalPos) const + PrimaryVariables analyticalSolution(const GlobalPosition& globalPos, Scalar time = 0.0) const { PrimaryVariables values(0.0); diff --git a/test/freeflow/navierstokes/donea/main.cc b/test/freeflow/navierstokes/donea/main.cc index 03ca64680b..0576644ff8 100644 --- a/test/freeflow/navierstokes/donea/main.cc +++ b/test/freeflow/navierstokes/donea/main.cc @@ -100,7 +100,7 @@ int main(int argc, char** argv) StaggeredVtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name()); IOFields::initOutputModule(vtkWriter); // Add model specific output fields - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); vtkWriter.addFaceField(analyticalSolVectors.getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); diff --git a/test/freeflow/navierstokes/kovasznay/main.cc b/test/freeflow/navierstokes/kovasznay/main.cc index 9e2659443a..5f974f2aec 100644 --- a/test/freeflow/navierstokes/kovasznay/main.cc +++ b/test/freeflow/navierstokes/kovasznay/main.cc @@ -128,7 +128,7 @@ int main(int argc, char** argv) StaggeredVtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name()); IOFields::initOutputModule(vtkWriter); // Add model specific output fields - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); vtkWriter.addFaceField(analyticalSolVectors.getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); diff --git a/test/freeflow/navierstokes/sincos/main.cc b/test/freeflow/navierstokes/sincos/main.cc index 230d6c5393..9664be22cf 100644 --- a/test/freeflow/navierstokes/sincos/main.cc +++ b/test/freeflow/navierstokes/sincos/main.cc @@ -188,7 +188,7 @@ int main(int argc, char** argv) vtkWriter.addField(sourceX, "sourceX"); vtkWriter.addField(sourceY, "sourceY"); - Dumux::NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem, 0.0); + NavierStokesAnalyticalSolutionVectors<Problem> analyticalSolVectors(problem, 0.0); vtkWriter.addField(analyticalSolVectors.getAnalyticalPressureSolution(), "pressureExact"); vtkWriter.addField(analyticalSolVectors.getAnalyticalVelocitySolution(), "velocityExact"); vtkWriter.addFaceField(analyticalSolVectors.getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); -- GitLab