From 94a50424afef1ec480465bbede2389a11f933bf0 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Wed, 15 May 2019 17:41:18 +0200 Subject: [PATCH] [io][grid] Remove vtk output from subgrid manager --- dumux/io/grid/subgridmanager.hh | 21 ++++++++++++---- .../gridmanager/test_gridmanager_subgrid.cc | 24 +++++++++++++++---- .../test_gridmanager_subgrid.input | 2 -- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/dumux/io/grid/subgridmanager.hh b/dumux/io/grid/subgridmanager.hh index 8c4c8cb6cf..e5cd7e258e 100644 --- a/dumux/io/grid/subgridmanager.hh +++ b/dumux/io/grid/subgridmanager.hh @@ -29,12 +29,15 @@ #include <memory> #include <dune/subgrid/subgrid.hh> -#include <dune/grid/io/file/vtk.hh> -#include <dune/grid/io/file/dgfparser/dgfwriter.hh> #include <dumux/common/parameters.hh> #include <dumux/common/boundaryflag.hh> +// TODO: remove this after 3.1 is released +#include <dune/grid/io/file/vtk.hh> +// TODO: remove this after 3.1 is released +#include <dune/grid/io/file/dgfparser/dgfwriter.hh> + namespace Dumux { /*! @@ -71,24 +74,32 @@ public: // choose which elements to add to the subgrid. auto hostGridView = subgridPtr->getHostGrid().leafGridView(); for (const auto& e : elements(hostGridView)) - if(selector(e)) + if (selector(e)) elementsForSubgrid.insert(globalIDset.template id<0>(e)); subgridPtr->insertSetPartial(elementsForSubgrid); subgridPtr->createEnd(); + // TODO: remove this after 3.1 is released // If desired, write out the final subgrid as a dgf file. - if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToDGF", false)) + if (getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToDGF", false)) { + std::cerr << "Deprecation warning: SubGridManager: Grid.WriteSubGridToDGF is deprecated." + << "Use Dune::VTKWriter to write out your grid manually." << std::endl; + const auto postfix = getParamFromGroup<std::string>(modelParamGroup, "Problem.Name", ""); const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix; Dune::DGFWriter<typename Grid::LeafGridView> writer(subgridPtr->leafGridView()); writer.write(name + ".dgf"); } + // TODO: remove this after 3.1 is released // If desired, write out the hostgrid as vtk file. - if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToVtk", false)) + if (getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToVtk", false)) { + std::cerr << "Deprecation warning: SubGridManager: Grid.WriteSubGridToVtk is deprecated." + << "Use Dune::VTKWriter to write out your grid manually." << std::endl; + const auto postfix = getParamFromGroup<std::string>(modelParamGroup, "Problem.Name", ""); const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix; Dune::VTKWriter<typename Grid::LeafGridView> vtkWriter(subgridPtr->leafGridView()); diff --git a/test/io/gridmanager/test_gridmanager_subgrid.cc b/test/io/gridmanager/test_gridmanager_subgrid.cc index 0884ee3da7..bb70761272 100644 --- a/test/io/gridmanager/test_gridmanager_subgrid.cc +++ b/test/io/gridmanager/test_gridmanager_subgrid.cc @@ -110,15 +110,29 @@ int main(int argc, char** argv) try CircleSelector<GlobalPosition> elementSelectorThree(center); // Create three different subgrids from the same hostgrid. - auto subgridPtrOne = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorOne, "SubGridOne"); - auto subgridPtrTwo = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorTwo, "SubGridTwo"); - auto subgridPtrThree = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorThree, "SubGridThree"); + auto subgridPtrOne = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorOne); + auto subgridPtrTwo = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorTwo); + auto subgridPtrThree = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorThree); std::cout << "Constructing a host grid and three subgrids took " << timer.elapsed() << " seconds.\n"; // Write out the host grid and the subgrids. - Dune::VTKWriter<HostGrid::LeafGridView> vtkWriter(hostGrid.leafGridView()); - vtkWriter.write("hostgrid"); + { + Dune::VTKWriter<HostGrid::LeafGridView> vtkWriter(hostGrid.leafGridView()); + vtkWriter.write("hostgrid"); + } + { + Dune::VTKWriter<SubgridManager<HostGrid>::Grid::LeafGridView> vtkWriter(subgridPtrOne->leafGridView()); + vtkWriter.write("subgrid_one"); + } + { + Dune::VTKWriter<SubgridManager<HostGrid>::Grid::LeafGridView> vtkWriter(subgridPtrTwo->leafGridView()); + vtkWriter.write("subgrid_two"); + } + { + Dune::VTKWriter<SubgridManager<HostGrid>::Grid::LeafGridView> vtkWriter(subgridPtrThree->leafGridView()); + vtkWriter.write("subgrid_three"); + } return 0; } diff --git a/test/io/gridmanager/test_gridmanager_subgrid.input b/test/io/gridmanager/test_gridmanager_subgrid.input index f994441727..919c5aa3f4 100644 --- a/test/io/gridmanager/test_gridmanager_subgrid.input +++ b/test/io/gridmanager/test_gridmanager_subgrid.input @@ -8,5 +8,3 @@ Positions1 = 0 1 Cells0 = 1 Cells1 = 1 Refinement = 4 - -WriteSubGridToVtk = true -- GitLab