HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
Loading...
Searching...
No Matches
TestCase.hpp
Go to the documentation of this file.
1// Class to provide various test cases (diffusion, exact solution, and their derivatives)
2//
3//
4// Author: Jerome Droniou (jerome.droniou@monash.edu)
5//
6
7/*
8*
9* This library was developed around HHO methods, although some parts of it have a more
10* general purpose. If you use this code or part of it in a scientific publication,
11* please mention the following book as a reference for the underlying principles
12* of HHO schemes:
13*
14* The Hybrid High-Order Method for Polytopal Meshes: Design, Analysis, and Applications.
15* D. A. Di Pietro and J. Droniou. 2019, 516p.
16* url: https://hal.archives-ouvertes.fr/hal-02151813.
17*
18*/
19
20#ifndef _TEST_CASE_HPP
21#define _TEST_CASE_HPP
22
23#include "basis.hpp"
24
25
26using namespace HArDCore3D;
27
35
38 {
39 // Constructor
41 const FType<double> value,
44 )
45 : value(value),
48 {
49 // Do nothing
50 }
51
52 // Members
56 };
57
60 {
61 // Constructor
65 const size_t degree
66 )
67 : value(value),
70 {
71 // Do nothing
72 }
73
74 // Members
77 const size_t degree;
78 };
79
82 {
83 // Constructor
99
100 // Default constructor
102 : value([](const VectorRd x, const Cell *cell) -> VectorRd { return VectorRd::Zero();}),
103 divergence([](const VectorRd x, const Cell *cell) -> double { return 0;}),
104 is_zero(true),
105 is_divergence_zero(true),
106 is_divergence_constant(true)
107 {
108 // Do nothing
109 }
110
111 // Members
117 };
118
121 {
122 // Constructor
125 const bool is_zero,
126 const bool is_constant
127 )
128 : value(value),
131 {
132 // Do nothing
133 }
134
135 // Default constructor
137 : value([](const VectorRd x, const Cell *cell) -> double { return 0.;}),
138 is_zero(true),
139 is_constant(true)
140 {
141 // Do nothing
142 }
143
144 // Members
148 };
149
150// ----------------------------------------------------------------------------
151// Class definition
152// ----------------------------------------------------------------------------
153
155class TestCase {
156
157public:
159 TestCase(
160 std::vector<int> iTC
161 );
162
164 inline Solution get_solution();
165
167 inline Diffusion get_diffusion();
168
170 inline Advection get_advection();
171
173 inline Reaction get_reaction();
174
177
180
182 void validate();
183
184
185private:
186 // Parameters: id of test case, pi
187 std::vector<int> m_iTC;
188 const double pi = acos(-1);
189 const double eps = 1e-5;
190
191// Advection, reaction, etc and functions to create them
192 Solution m_sol;
193 Diffusion m_diff;
194 Advection m_advec;
195 Reaction m_reac;
196
197 Solution create_solution(const size_t n);
198 Diffusion create_diffusion(const size_t n);
199 Advection create_advection(const size_t n);
200 Reaction create_reaction(const size_t n);
201
202};
203
204inline Solution TestCase::get_solution() { return m_sol; }
205inline Diffusion TestCase::get_diffusion() { return m_diff; }
206inline Advection TestCase::get_advection() { return m_advec; }
207inline Reaction TestCase::get_reaction() { return m_reac; }
208
210
211#endif //_TEST_CASE_HPP
The TestCase class provides definition of test cases.
Definition TestCase.hpp:155
void validate()
Check if the provided test cases are valid (within range, and combination of solution/diffusion valid...
Definition TestCase.cpp:407
CellFType< double > diff_source()
Returns the diffusion source term.
Definition TestCase.cpp:383
Advection get_advection()
Returns the advection.
Definition TestCase.hpp:206
Diffusion get_diffusion()
Returns the diffusion.
Definition TestCase.hpp:205
CellFType< double > diff_advec_reac_source()
Returns the diffusion-advection-reaction source term.
Definition TestCase.cpp:394
Reaction get_reaction()
Returns the reaction.
Definition TestCase.hpp:207
Solution get_solution()
Returns the solution.
Definition TestCase.hpp:204
std::function< T(const VectorRd &, const Cell *)> CellFType
type for function of point. T is the return type of the function
Definition basis.hpp:58
std::function< T(const VectorRd &)> FType
type for function of point. T is the return type of the function
Definition basis.hpp:55
@ Matrix
Definition basis.hpp:67
Definition ddr-magnetostatics.hpp:41
Structure to store an advection velocity and its divergence, together with various flags.
Definition TestCase.hpp:82
CellFType< VectorRd > value
Definition TestCase.hpp:112
bool is_zero
Definition TestCase.hpp:114
CellFType< double > divergence
Definition TestCase.hpp:113
Advection()
Definition TestCase.hpp:101
bool is_divergence_constant
Definition TestCase.hpp:116
Advection(const CellFType< VectorRd > value, const CellFType< double > divergence, const bool is_zero, const bool is_divergence_zero, const bool is_divergence_constant)
Definition TestCase.hpp:84
bool is_divergence_zero
Definition TestCase.hpp:115
Structure to store a diffusion tensor and its row-wise divergence.
Definition TestCase.hpp:60
const CellFType< MatrixRd > value
Definition TestCase.hpp:75
const CellFType< VectorRd > divergence
Definition TestCase.hpp:76
Diffusion(const CellFType< MatrixRd > value, const CellFType< VectorRd > divergence, const size_t degree)
Definition TestCase.hpp:62
const size_t degree
Definition TestCase.hpp:77
Structure to store a reaction term, together with various flags.
Definition TestCase.hpp:121
Reaction()
Definition TestCase.hpp:136
CellFType< double > value
Definition TestCase.hpp:145
Reaction(const CellFType< double > value, const bool is_zero, const bool is_constant)
Definition TestCase.hpp:123
bool is_constant
Definition TestCase.hpp:147
bool is_zero
Definition TestCase.hpp:146
Structure to store a solution and its derivatives.
Definition TestCase.hpp:38
const FType< double > value
Definition TestCase.hpp:53
const CellFType< VectorRd > gradient
Definition TestCase.hpp:54
Solution(const FType< double > value, const CellFType< VectorRd > gradient, const CellFType< MatrixRd > hessian)
Definition TestCase.hpp:40
const CellFType< MatrixRd > hessian
Definition TestCase.hpp:55