3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
gridmanager_oned.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_IO_GRID_MANAGER_ONED_HH
25#define DUMUX_IO_GRID_MANAGER_ONED_HH
26
27#include <dune/grid/onedgrid.hh>
28#include <dune/grid/io/file/dgfparser/dgfoned.hh>
29
30#ifndef DUMUX_IO_GRID_MANAGER_BASE_HH
32#endif
33
34namespace Dumux {
35
50template<>
51class GridManager<Dune::OneDGrid>
52: public GridManagerBase<Dune::OneDGrid>
53{
54public:
55 using Grid = Dune::OneDGrid;
57
61 void init(const std::string& modelParamGroup = "")
62 {
63
64 // try to create it from a DGF or msh file in GridParameterGroup.File
65 if (hasParamInGroup(modelParamGroup, "Grid.File"))
66 {
67 ParentType::makeGridFromDgfFile(getParamFromGroup<std::string>(modelParamGroup, "Grid.File"));
68 postProcessing_(modelParamGroup);
69 return;
70 }
71
72 // Look for the necessary keys to construct from the input file
73 else if (hasParamInGroup(modelParamGroup, "Grid.RightBoundary"))
74 {
75 // The required parameters
76 using CoordinateType = typename Grid::ctype;
77 const auto leftBoundary = getParamFromGroup<CoordinateType>(modelParamGroup, "Grid.LeftBoundary", 0.0);
78 const auto rightBoundary = getParamFromGroup<CoordinateType>(modelParamGroup, "Grid.RightBoundary");
79 const int cells = getParamFromGroup<int>(modelParamGroup, "Grid.Cells", 1);
80
81 ParentType::gridPtr() = std::make_shared<Grid>(cells, leftBoundary, rightBoundary);
82 postProcessing_(modelParamGroup);
83 return;
84 }
85
86 // Look for the necessary keys to construct from the input file with just a coordinates vector
87 else if (hasParamInGroup(modelParamGroup, "Grid.Coordinates"))
88 {
89 const auto coordinates = getParamFromGroup<std::vector<typename Grid::ctype>>(modelParamGroup, "Grid.Coordinates");
90 ParentType::gridPtr() = std::make_shared<Grid>(coordinates);
91 postProcessing_(modelParamGroup);
92 }
93
94 // Didn't find a way to construct the grid
95 else
96 {
97 const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
98 DUNE_THROW(ParameterException, "Please supply one of the parameters "
99 << prefix + "Grid.RightBoundary"
100 << ", or " << prefix + "Grid.Coordinates"
101 << ", or a grid file in " << prefix + "Grid.File");
102 }
103 }
104
108 void loadBalance() {}
109
110private:
114 void postProcessing_(const std::string& modelParamGroup)
115 {
116 // Set refinement type
117 const auto refType = getParamFromGroup<std::string>(modelParamGroup, "Grid.RefinementType", "Local");
118 if (refType == "Local")
119 ParentType::grid().setRefinementType(Dune::OneDGrid::RefinementType::LOCAL);
120 else if (refType == "Copy")
121 ParentType::grid().setRefinementType(Dune::OneDGrid::RefinementType::COPY);
122 else
123 DUNE_THROW(Dune::IOError, "OneGrid only supports 'Local' or 'Copy' as refinement type. Not '"<< refType<<"'!");
124
125 // Check if should refine the grid
126 ParentType::maybeRefineGrid(modelParamGroup);
127 loadBalance();
128 }
129};
130
131} // end namespace Dumux
132
133#endif
Provides a grid manager for all supported grid managers with input file interfaces....
bool hasParamInGroup(const std::string &paramGroup, const std::string &param)
Check whether a key exists in the parameter tree with a model group prefix.
Definition: parameters.hh:177
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Definition: deprecated.hh:149
Exception thrown if a run-time parameter is not specified correctly.
Definition: exceptions.hh:60
The grid manager (this is the class used by the user) for all supported grid managers that constructs...
Definition: gridmanager_base.hh:324
The grid manager base interface (public) and methods common to most grid manager specializations (pro...
Definition: gridmanager_base.hh:67
void loadBalance()
Call loadBalance() function of the grid.
Definition: gridmanager_base.hh:98
void init(const std::string &modelParamGroup="")
Make the grid. This is implemented by specializations of this method.
Definition: gridmanager_oned.hh:61
void loadBalance()
Call loadBalance() function of the grid. OneDGrid is not parallel an thus cannot communicate.
Definition: gridmanager_oned.hh:108
Dune::OneDGrid Grid
Definition: gridmanager_oned.hh:55