Commit 92fadcb4 authored by Melanie Lipp's avatar Melanie Lipp Committed by Timo Koch

Rename CakeGridCreator to CakeGridManager and SubgridGridCreator to SubGridManager.

parent 9d73cfa1
......@@ -27,7 +27,7 @@
* | :- | :- |
* | \c container/test_container_io | Test for writing and reading sequence container to and from file |
* | \c gnuplotinterface/test_gnuplotinterface | tests the plotting of data sets, functions, and files |
* | \c gridcreator/test_gridcreator_gmsh | Test for gmsh interface of the grid creator |
* | \c gridmanager/test_gridmanager_gmsh | Test for gmsh interface of the grid manager |
*
* \section Implicit
* | Tests | | Fluidsystem | Gridmanager | Mass/Mole | Non-/Isothermal | Discretization | linearSolver | AdaptiveGrid | BoundaryCondition | Homogeneity | MaterialLaw | Permeability | Gravity | JacobianRecycling | PartialReassemble | Comments |
......
install(FILES
cakegridcreator.hh
cakegridmanager.hh
cpgridmanager.hh
gmshgriddatahandle.hh
griddata.hh
gridmanager.hh
subgridgridcreator.hh
subgridmanager.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/io/grid)
This diff is collapsed.
This diff is collapsed.
......@@ -26,13 +26,10 @@
#if HAVE_DUNE_SUBGRID
#include <memory>
#warning "This header is deprecated. Use the new subgridmanager."
#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 <dune/common/deprecated.hh>
#include "subgridgridmanager.hh"
namespace Dumux {
......@@ -41,63 +38,7 @@ namespace Dumux {
* \brief A grid creator for dune-subgrid.
*/
template <class HostGrid>
class SubgridGridCreator
{
static constexpr auto dim = HostGrid::dimension;
public:
using Grid = Dune::SubGrid<dim, HostGrid>;
/*!
* \brief Make the subgrid.
*/
template<class ElementSelector>
static std::unique_ptr<Grid> makeGrid(HostGrid& hostgrid,
const ElementSelector& selector,
const std::string& modelParamGroup = "")
{
// A unique pointer to the subgrid.
auto subgridPtr = std::make_unique<Grid>(hostgrid);
// A container to store the host grid elements' ids.
std::set<typename HostGrid::Traits::GlobalIdSet::IdType> elementsForSubgrid;
const auto& globalIDset = subgridPtr->getHostGrid().globalIdSet();
// Construct the subgrid.
subgridPtr->createBegin();
// Loop over all elements of the host grid and use the selector to
// choose which elements to add to the subgrid.
auto hostGridView = subgridPtr->getHostGrid().leafGridView();
for (const auto& e : elements(hostGridView))
if(selector(e))
elementsForSubgrid.insert(globalIDset.template id<0>(e));
subgridPtr->insertSetPartial(elementsForSubgrid);
subgridPtr->createEnd();
// If desired, write out the final subgrid as a dgf file.
if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToDGF", false))
{
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");
}
// If desired, write out the hostgrid as vtk file.
if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToVtk", false))
{
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());
vtkWriter.write(name);
}
// Return a unique pointer to the subgrid.
return subgridPtr;
}
};
using SubgridGridCreator DUNE_DEPRECATED_MSG("Use SubgridManager instead!") = SubgridManager<HostGrid>;
} // end namespace Dumux
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup InputOutput
* \brief A grid manager for dune-subgrid.
*/
#ifndef DUMUX_SUBGRID_MANAGER_HH
#define DUMUX_SUBGRID_MANAGER_HH
#if HAVE_DUNE_SUBGRID
#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>
namespace Dumux {
/*!
* \ingroup InputOutput
* \brief A grid manager for dune-subgrid.
*/
template <class HostGrid>
class SubgridManager
{
static constexpr auto dim = HostGrid::dimension;
public:
using Grid = Dune::SubGrid<dim, HostGrid>;
/*!
* \brief Make the subgrid.
*/
template<class ElementSelector>
static std::unique_ptr<Grid> makeGrid(HostGrid& hostgrid,
const ElementSelector& selector,
const std::string& modelParamGroup = "")
{
// A unique pointer to the subgrid.
auto subgridPtr = std::make_unique<Grid>(hostgrid);
// A container to store the host grid elements' ids.
std::set<typename HostGrid::Traits::GlobalIdSet::IdType> elementsForSubgrid;
const auto& globalIDset = subgridPtr->getHostGrid().globalIdSet();
// Construct the subgrid.
subgridPtr->createBegin();
// Loop over all elements of the host grid and use the selector to
// choose which elements to add to the subgrid.
auto hostGridView = subgridPtr->getHostGrid().leafGridView();
for (const auto& e : elements(hostGridView))
if(selector(e))
elementsForSubgrid.insert(globalIDset.template id<0>(e));
subgridPtr->insertSetPartial(elementsForSubgrid);
subgridPtr->createEnd();
// If desired, write out the final subgrid as a dgf file.
if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToDGF", false))
{
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");
}
// If desired, write out the hostgrid as vtk file.
if(getParamFromGroup<bool>(modelParamGroup, "Grid.WriteSubGridToVtk", false))
{
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());
vtkWriter.write(name);
}
// Return a unique pointer to the subgrid.
return subgridPtr;
}
};
} // end namespace Dumux
#endif // HAVE_DUNE_SUBGRID
#endif // DUMUX_SUBGRID_MANAGER_HH
......@@ -17,7 +17,7 @@
/*!
* \file
*
* \brief Test for the cake grid creator
* \brief Test for the cake grid manager
*/
#include<string>
......@@ -30,7 +30,7 @@
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/grid/cakegridcreator.hh>
#include <dumux/io/grid/cakegridmanager.hh>
#if HAVE_UG
#include <dune/grid/uggrid.hh>
......@@ -52,10 +52,10 @@ using Grid = Dune::UGGrid<dim>;
#endif
template<int dim>
void testCakeGridCreator(const std::string& name)
void testCakeGridManager(const std::string& name)
{
// using declarations
using GridManager = typename Dumux::CakeGridCreator<Grid<dim>>;
using GridManager = typename Dumux::CakeGridManager<Grid<dim>>;
GridManager gridManager;
// make the grid
......@@ -78,10 +78,10 @@ int main(int argc, char** argv) try
const auto name = Dumux::getParam<std::string>("Grid.Name");
// test 3-D
testCakeGridCreator<3>("cake-3d-" + name);
testCakeGridManager<3>("cake-3d-" + name);
// test 2-D
testCakeGridCreator<2>("cake-2d-" + name);
testCakeGridManager<2>("cake-2d-" + name);
return 0;
}
......
......@@ -16,7 +16,7 @@
*****************************************************************************/
/*!
* \file
* \brief Test for the cake grid creator
* \brief Test for the cake grid manager
*/
#include <config.h>
#include <iostream>
......@@ -29,7 +29,7 @@
#include <dumux/common/parameters.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/grid/subgridgridcreator.hh>
#include <dumux/io/grid/subgridmanager.hh>
#include <dumux/discretization/method.hh>
/*!
......@@ -110,9 +110,9 @@ int main(int argc, char** argv) try
CircleSelector<GlobalPosition> elementSelectorThree(center);
// Create three different subgrids from the same hostgrid.
auto subgridPtrOne = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorOne, "SubGridOne");
auto subgridPtrTwo = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorTwo, "SubGridTwo");
auto subgridPtrThree = SubgridGridCreator<HostGrid>::makeGrid(hostGrid, elementSelectorThree, "SubGridThree");
auto subgridPtrOne = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorOne, "SubGridOne");
auto subgridPtrTwo = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorTwo, "SubGridTwo");
auto subgridPtrThree = SubgridManager<HostGrid>::makeGrid(hostGrid, elementSelectorThree, "SubGridThree");
std::cout << "Constructing a host grid and three subgrids took " << timer.elapsed() << " seconds.\n";
......
......@@ -39,7 +39,7 @@
#include <dumux/discretization/method.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/grid/subgridgridcreator.hh>
#include <dumux/io/grid/subgridmanager.hh>
#include <dumux/porousmediumflow/1p/model.hh>
#include <dumux/material/components/simpleh2o.hh>
......@@ -156,8 +156,8 @@ int main(int argc, char** argv) try
auto elementSelector1 = [&lensLowerLeft, &lensUpperRight](const auto& element)
{ return !LensSpatialParams::pointInLens(element.geometry().center(), lensLowerLeft, lensUpperRight); };
auto subGrid0 = SubgridGridCreator<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector0);
auto subGrid1 = SubgridGridCreator<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector1);
auto subGrid0 = SubgridManager<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector0);
auto subGrid1 = SubgridManager<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector1);
////////////////////////////////////////////////////////////
// run instationary non-linear problem on this grid
......
......@@ -39,7 +39,7 @@
#include <dumux/discretization/method.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/grid/subgridgridcreator.hh>
#include <dumux/io/grid/subgridmanager.hh>
#include <dumux/porousmediumflow/1p/model.hh>
#include <dumux/porousmediumflow/2p/model.hh>
......@@ -158,8 +158,8 @@ int main(int argc, char** argv) try
auto elementSelector1 = [radius](const auto& element)
{ return element.geometry().center().two_norm() < radius; };
auto subGrid0 = SubgridGridCreator<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector0);
auto subGrid1 = SubgridGridCreator<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector1);
auto subGrid0 = SubgridManager<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector0);
auto subGrid1 = SubgridManager<FullDomainGrid>::makeGrid(gridManager.grid(), elementSelector1);
////////////////////////////////////////////////////////////
// run instationary non-linear problem on this grid
......
Markdown is supported
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