Line | Branch | Exec | Source |
---|---|---|---|
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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup MaterialTests | ||
10 | * \brief This file provides the actual code for the solid systems test. | ||
11 | * | ||
12 | * It is not directly in test_solidsystems.cc so that external modules | ||
13 | * like dumux-devel can use it easily | ||
14 | */ | ||
15 | |||
16 | #ifndef DUMUX_CHECK_SOLIDSYSTEM_HH | ||
17 | #define DUMUX_CHECK_SOLIDSYSTEM_HH | ||
18 | |||
19 | #include <type_traits> | ||
20 | #include <iostream> | ||
21 | |||
22 | #include <dune/common/classname.hh> | ||
23 | #include <dune/common/exceptions.hh> | ||
24 | |||
25 | // include all solid states | ||
26 | #include <dumux/material/solidstates/inertsolidstate.hh> | ||
27 | #include <dumux/material/solidstates/compositionalsolidstate.hh> | ||
28 | |||
29 | namespace Dumux { | ||
30 | |||
31 | template<class Scalar, class SolidSystem> | ||
32 | 22 | int checkSolidSystem() | |
33 | { | ||
34 | static_assert((SolidSystem::isInert() && SolidSystem::numInertComponents == SolidSystem::numComponents) | ||
35 | || !SolidSystem::isInert(), "numInertComponents == numComponents has to be equal to SolidSystem::isInert()"); | ||
36 | |||
37 | // inert solid state | ||
38 | using Solidstate = std::conditional_t<SolidSystem::isInert(), | ||
39 | InertSolidState<Scalar, SolidSystem>, | ||
40 | CompositionalSolidState<Scalar, SolidSystem>>; | ||
41 | Solidstate sst; | ||
42 | |||
43 | 22 | int success = 0; | |
44 |
1/2✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
66 | std::cout << "Testing solid system '" << Dune::className<SolidSystem>() << "'\n"; |
45 | |||
46 | // output strings | ||
47 | 22 | std::string collectedErrors; | |
48 | 22 | std::string collectedWarnings; | |
49 | |||
50 | // make sure the solid system provides the number of phases and | ||
51 | // the number of components | ||
52 | enum | ||
53 | { | ||
54 | numComponents = SolidSystem::numComponents | ||
55 | }; | ||
56 | |||
57 | // some value to make sure the return values of the solid system | ||
58 | // are convertible to scalars | ||
59 | [[maybe_unused]] Scalar val; | ||
60 | |||
61 | // test for componentName and isCompressible | ||
62 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 11 times.
|
50 | for (int phaseIdx = 0; phaseIdx < numComponents; ++phaseIdx) |
63 | { | ||
64 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
28 | [[maybe_unused]] std::string name = SolidSystem::componentName(phaseIdx); |
65 | 28 | [[maybe_unused]] bool bVal = SolidSystem::isCompressible(phaseIdx); | |
66 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
28 | val = SolidSystem::molarMass(phaseIdx); |
67 | } | ||
68 | |||
69 | // test for componentName | ||
70 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 11 times.
|
50 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
71 | { | ||
72 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
28 | [[maybe_unused]] std::string name = SolidSystem::componentName(compIdx); |
73 | } | ||
74 | |||
75 | // test for name | ||
76 | [[maybe_unused]] std::string name = SolidSystem::name(); | ||
77 | |||
78 | try | ||
79 | { | ||
80 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | val = SolidSystem::heatCapacity(sst); |
81 | } catch (Dune::NotImplemented&) | ||
82 | { | ||
83 | collectedWarnings += "warning: SolidSystem::heatCapacity() is not implemented\n"; | ||
84 | } catch (...) | ||
85 | { | ||
86 | collectedErrors += "error: SolidSystem::heatCapacity() throws exception!\n"; | ||
87 | } | ||
88 | |||
89 | try | ||
90 | { | ||
91 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
6 | val = SolidSystem::thermalConductivity(sst); |
92 | } catch (Dune::NotImplemented&) | ||
93 | { | ||
94 | collectedWarnings += "warning: SolidSystem::thermalConductivity() is not implemented\n"; | ||
95 | } catch (...) | ||
96 | { | ||
97 | collectedErrors += "error: SolidSystem::thermalConductivity() throws exception!\n"; | ||
98 | } | ||
99 | |||
100 | try | ||
101 | { | ||
102 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
22 | val = SolidSystem::density(sst); |
103 | } catch (Dune::Exception &e) | ||
104 | { | ||
105 | collectedErrors += "error: SolidSystem::density() throws exception!\n"; | ||
106 | } | ||
107 | |||
108 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
22 | std::cout << collectedErrors; |
109 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
22 | std::cout << collectedWarnings; |
110 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
22 | if (collectedErrors.empty()) // success |
111 | { | ||
112 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
|
22 | std::cout << "... successful" << std::endl; |
113 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
22 | std::cout << "----------------------------------" << std::endl; |
114 | return 0; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | ✗ | std::cout << "... failed" << std::endl; | |
119 |
0/2✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
22 | std::cout << "----------------------------------" << std::endl; |
120 | return 1; | ||
121 | } | ||
122 | std::cout << "----------------------------------\n"; | ||
123 | return success; | ||
124 | 22 | } | |
125 | |||
126 | } // end namespace Dumux | ||
127 | |||
128 | #endif | ||
129 |