3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
poreproperties.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_PNM_BASE_PORE_PROPERTIES_HH
25#define DUMUX_PNM_BASE_PORE_PROPERTIES_HH
26
27#include <cmath>
28#include <string>
29#include <dune/common/exceptions.hh>
30
32
34enum class Shape
36
38inline std::string shapeToString(Shape s)
39{
40 switch (s)
41 {
42 case Shape::square: return "Square";
43 case Shape::circle: return "Circle";
44 case Shape::cube: return "Cube";
45 case Shape::sphere: return "Sphere";
46 case Shape::cylinder: return "Cylinder";
47 case Shape::tetrahedron: return "Tetrahedron";
48 case Shape::octahedron: return "Octahedron";
49 case Shape::icosahedron: return "Icosahedron";
50 case Shape::dodecahedron: return "Dodecahedron";
51 default: DUNE_THROW(Dune::InvalidStateException, "Unknown shape!");
52 }
53}
54
56inline Shape shapeFromString(const std::string& s)
57{
59 else if (s == shapeToString(Shape::circle)) return Shape::circle;
60 else if (s == shapeToString(Shape::cube)) return Shape::cube;
61 else if (s == shapeToString(Shape::sphere)) return Shape::sphere;
62 else if (s == shapeToString(Shape::cylinder)) return Shape::cylinder;
67 else DUNE_THROW(Dune::InvalidStateException, s << " is not a valid shape");
68}
69
70
72template<class Scalar>
73inline Scalar volume(Shape shape, Scalar inscribedRadius)
74{
75 switch(shape)
76 {
77 case Shape::cube: return 8*inscribedRadius*inscribedRadius*inscribedRadius; break;
78 case Shape::sphere: return 4.0/3.0*M_PI*inscribedRadius*inscribedRadius*inscribedRadius; break;
79 case Shape::circle: return M_PI*inscribedRadius*inscribedRadius; break;
80 case Shape::square: return 4.0*inscribedRadius*inscribedRadius; break;
81 case Shape::tetrahedron: return 13.85*inscribedRadius*inscribedRadius*inscribedRadius; break;
82 case Shape::octahedron: return 6.93*inscribedRadius*inscribedRadius*inscribedRadius; break;
83 case Shape::icosahedron: return 5.05*inscribedRadius*inscribedRadius*inscribedRadius; break;
84 case Shape::dodecahedron: return 5.55*inscribedRadius*inscribedRadius*inscribedRadius; break;
85 default : DUNE_THROW(Dune::InvalidStateException, "Unsupported geometry");
86 }
87}
88
89
91template<class Scalar>
92inline Scalar volume(Shape shape, Scalar inscribedRadius, Scalar height)
93{
94 switch(shape)
95 {
96 case Shape::cylinder: return M_PI*inscribedRadius*inscribedRadius*height; break;
97 default : DUNE_THROW(Dune::InvalidStateException, "Unsupported geometry");
98 }
99}
100
101} // end Dumux::PoreNetwork::Pore
102
103#endif
Definition: poreproperties.hh:31
Shape shapeFromString(const std::string &s)
Get the shape from a string description of the shape.
Definition: poreproperties.hh:56
std::string shapeToString(Shape s)
Get the shape from a string description of the shape.
Definition: poreproperties.hh:38
Scalar volume(Shape shape, Scalar inscribedRadius)
Returns the volume of a given geometry based on the inscribed radius.
Definition: poreproperties.hh:73
Shape
Collection of different pore-body shapes.
Definition: poreproperties.hh:35
constexpr Shape shape(const Scalar shapeFactor) noexcept
Returns the shape for a given shape factor.
Definition: throatproperties.hh:177