version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_PNM_BASE_PORE_PROPERTIES_HH
13#define DUMUX_PNM_BASE_PORE_PROPERTIES_HH
14
15#include <cmath>
16#include <string>
17#include <dune/common/exceptions.hh>
18
20
22enum class Shape
24
26inline std::string shapeToString(Shape s)
27{
28 switch (s)
29 {
30 case Shape::square: return "Square";
31 case Shape::circle: return "Circle";
32 case Shape::cube: return "Cube";
33 case Shape::sphere: return "Sphere";
34 case Shape::cylinder: return "Cylinder";
35 case Shape::tetrahedron: return "Tetrahedron";
36 case Shape::octahedron: return "Octahedron";
37 case Shape::icosahedron: return "Icosahedron";
38 case Shape::dodecahedron: return "Dodecahedron";
39 default: DUNE_THROW(Dune::InvalidStateException, "Unknown shape!");
40 }
41}
42
44inline Shape shapeFromString(const std::string& s)
45{
47 else if (s == shapeToString(Shape::circle)) return Shape::circle;
48 else if (s == shapeToString(Shape::cube)) return Shape::cube;
49 else if (s == shapeToString(Shape::sphere)) return Shape::sphere;
50 else if (s == shapeToString(Shape::cylinder)) return Shape::cylinder;
55 else DUNE_THROW(Dune::InvalidStateException, s << " is not a valid shape");
56}
57
58
60template<class Scalar>
61inline Scalar volume(Shape shape, Scalar inscribedRadius)
62{
63 switch(shape)
64 {
65 case Shape::cube: return 8*inscribedRadius*inscribedRadius*inscribedRadius; break;
66 case Shape::sphere: return 4.0/3.0*M_PI*inscribedRadius*inscribedRadius*inscribedRadius; break;
67 case Shape::circle: return M_PI*inscribedRadius*inscribedRadius; break;
68 case Shape::square: return 4.0*inscribedRadius*inscribedRadius; break;
69 case Shape::tetrahedron: return 13.85*inscribedRadius*inscribedRadius*inscribedRadius; break;
70 case Shape::octahedron: return 6.93*inscribedRadius*inscribedRadius*inscribedRadius; break;
71 case Shape::icosahedron: return 5.05*inscribedRadius*inscribedRadius*inscribedRadius; break;
72 case Shape::dodecahedron: return 5.55*inscribedRadius*inscribedRadius*inscribedRadius; break;
73 default : DUNE_THROW(Dune::InvalidStateException, "Unsupported geometry");
74 }
75}
76
77
79template<class Scalar>
80inline Scalar volume(Shape shape, Scalar inscribedRadius, Scalar height)
81{
82 switch(shape)
83 {
84 case Shape::cylinder: return M_PI*inscribedRadius*inscribedRadius*height; break;
85 default : DUNE_THROW(Dune::InvalidStateException, "Unsupported geometry");
86 }
87}
88
89} // end Dumux::PoreNetwork::Pore
90
91#endif
Definition: poreproperties.hh:19
Shape shapeFromString(const std::string &s)
Get the shape from a string description of the shape.
Definition: poreproperties.hh:44
std::string shapeToString(Shape s)
Get the shape from a string description of the shape.
Definition: poreproperties.hh:26
Scalar volume(Shape shape, Scalar inscribedRadius)
Returns the volume of a given geometry based on the inscribed radius.
Definition: poreproperties.hh:61
Shape
Collection of different pore-body shapes.
Definition: poreproperties.hh:23
constexpr Shape shape(const Scalar shapeFactor) noexcept
Returns the shape for a given shape factor.
Definition: throatproperties.hh:165