3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
checksolidsystem.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 *****************************************************************************/
28#ifndef DUMUX_CHECK_SOLIDSYSTEM_HH
29#define DUMUX_CHECK_SOLIDSYSTEM_HH
30
31#include <type_traits>
32#include <iostream>
33
34#include <dune/common/classname.hh>
35#include <dune/common/unused.hh>
36#include <dune/common/exceptions.hh>
37
38// include all solid states
41
42namespace Dumux {
43
44template<class Scalar, class SolidSystem>
46{
47 static_assert((SolidSystem::isInert() && SolidSystem::numInertComponents == SolidSystem::numComponents)
48 || !SolidSystem::isInert(), "numInertComponents == numComponents has to be equal to SolidSystem::isInert()");
49
50 // inert solid state
51 using Solidstate = std::conditional_t<SolidSystem::isInert(),
54 Solidstate sst;
55
56 int success = 0;
57 std::cout << "Testing solid system '" << Dune::className<SolidSystem>() << "'\n";
58
59 // output strings
60 std::string collectedErrors;
61 std::string collectedWarnings;
62
63 // make sure the solid system provides the number of phases and
64 // the number of components
65 enum
66 {
67 numComponents = SolidSystem::numComponents
68 };
69
70 // some value to make sure the return values of the solid system
71 // are convertible to scalars
72 Scalar DUNE_UNUSED val;
73
74 // test for componentName and isCompressible
75 for (int phaseIdx = 0; phaseIdx < numComponents; ++phaseIdx)
76 {
77 std::string name DUNE_UNUSED= SolidSystem::componentName(phaseIdx);
78 bool DUNE_UNUSED bVal = SolidSystem::isCompressible(phaseIdx);
79 val = SolidSystem::molarMass(phaseIdx);
80 }
81
82 // test for componentName
83 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
84 {
85 std::string name DUNE_UNUSED= SolidSystem::componentName(compIdx);
86 }
87
88 // test for name
89 std::string name DUNE_UNUSED = SolidSystem::name();
90
91 try
92 {
93 val = SolidSystem::heatCapacity(sst);
94 } catch (Dune::NotImplemented&)
95 {
96 collectedWarnings += "warning: SolidSystem::heatCapacity() is not implemented\n";
97 } catch (...)
98 {
99 collectedErrors += "error: SolidSystem::heatCapacity() throws exception!\n";
100 }
101
102 try
103 {
104 val = SolidSystem::thermalConductivity(sst);
105 } catch (Dune::NotImplemented&)
106 {
107 collectedWarnings += "warning: SolidSystem::thermalConductivity() is not implemented\n";
108 } catch (...)
109 {
110 collectedErrors += "error: SolidSystem::thermalConductivity() throws exception!\n";
111 }
112
113 try
114 {
115 val = SolidSystem::density(sst);
116 } catch (Dune::Exception &e)
117 {
118 collectedErrors += "error: SolidSystem::density() throws exception!\n";
119 }
120
121 std::cout << collectedErrors;
122 std::cout << collectedWarnings;
123 if (collectedErrors.empty()) // success
124 {
125 std::cout << "... successful" << std::endl;
126 std::cout << "----------------------------------" << std::endl;
127 return 0;
128 }
129 else
130 {
131 std::cout << "... failed" << std::endl;
132 std::cout << "----------------------------------" << std::endl;
133 return 1;
134 }
135 std::cout << "----------------------------------\n";
136 return success;
137}
138
139} // end namespace Dumux
140
141#endif // DUMUX_CHECK_SOLIDSYSTEM_HH
Represents all relevant thermodynamic quantities of a compositional solid system.
Represents all relevant thermodynamic quantities of a inert solid system.
bool success
Definition: test_tabulation.cc:34
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
int checkSolidSystem()
Definition: checksolidsystem.hh:45
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Represents all relevant thermodynamic quantities of a compositional solid system.
Definition: compositionalsolidstate.hh:37
Represents all relevant thermodynamic quantities of a inert solid system.
Definition: inertsolidstate.hh:35