From 4e8b5b32492f887a6bb95aa625c0e77a0d2811f3 Mon Sep 17 00:00:00 2001 From: Kilian Date: Wed, 24 Apr 2019 11:58:16 +0200 Subject: [PATCH] [staggered][io] Enforce the use of decltype(partSol) as template argument * when passing the result of partial(sol) to the staggered vtkWriter, one has to make sure the type of the sol vec (Dune::MultitypeBlockVector storing references) passed to the constructor is the same as the one used as template argument * failing to do so results in a segfault * this commit ensures the correct types at compile time --- dumux/freeflow/navierstokes/staggered/fluxoversurface.hh | 6 +++++- dumux/io/staggeredvtkoutputmodule.hh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dumux/freeflow/navierstokes/staggered/fluxoversurface.hh b/dumux/freeflow/navierstokes/staggered/fluxoversurface.hh index 339ace3095..377631154f 100644 --- a/dumux/freeflow/navierstokes/staggered/fluxoversurface.hh +++ b/dumux/freeflow/navierstokes/staggered/fluxoversurface.hh @@ -143,11 +143,15 @@ public: /*! * \brief The constructor */ + template FluxOverSurface(const GridVariables& gridVariables, - const SolutionVector& sol) + const Sol& sol) : gridVariables_(gridVariables), sol_(sol) { + static_assert(std::is_same::value, "Make sure that sol has the same type as SolutionVector." + "Use StaggeredVtkOutputModule when calling the constructor."); + verbose_ = getParamFromGroup(problem_().paramGroup(), "FluxOverSurface.Verbose", false); } diff --git a/dumux/io/staggeredvtkoutputmodule.hh b/dumux/io/staggeredvtkoutputmodule.hh index 4dfbd9a11a..7f7beac107 100644 --- a/dumux/io/staggeredvtkoutputmodule.hh +++ b/dumux/io/staggeredvtkoutputmodule.hh @@ -82,8 +82,9 @@ class StaggeredVtkOutputModule public: + template StaggeredVtkOutputModule(const GridVariables& gridVariables, - const SolutionVector& sol, + const Sol& sol, const std::string& name, const std::string& paramGroup = "", Dune::VTK::DataMode dm = Dune::VTK::conforming, @@ -95,6 +96,9 @@ public: gridVariables.curGridVolVars().problem().fvGridGeometry().gridView().comm().size() ) { + static_assert(std::is_same::value, "Make sure that sol has the same type as SolutionVector." + "Use StaggeredVtkOutputModule when calling the constructor."); + // enable velocity output per default this->addVelocityOutput(std::make_shared>(gridVariables, sol)); writeFaceVars_ = getParamFromGroup(paramGroup, "Vtk.WriteFaceData", false); -- GitLab