HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge 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//namespace HArDCore2D
26//{ // Forward declaration
27//class Cell;
28//}
29
30using namespace HArDCore2D;
31
37// @addtogroup TestCases
39
40// Types
41template <typename T>
42using CellFType = std::function<T(const VectorRd &, const Cell *)>;
43
46 {
47 // Constructor
49 const FType<double> value,
52 )
53 : value(value),
56 {
57 // Do nothing
58 }
59
60 // Members
64 };
65
68 {
69 // Constructor
73 const size_t degree
74 )
75 : value(value),
78 {
79 // Do nothing
80 }
81
82 // Members
85 const size_t degree;
86 };
87
90 {
91 // Constructor
107
108 // Default constructor
110 : value([](const VectorRd x, const Cell *cell) -> VectorRd { return VectorRd::Zero();}),
111 divergence([](const VectorRd x, const Cell *cell) -> double { return 0;}),
112 is_zero(true),
113 is_divergence_zero(true),
114 is_divergence_constant(true)
115 {
116 // Do nothing
117 }
118
119 // Members
125 };
126
129 {
130 // Constructor
133 const bool is_zero,
134 const bool is_constant
135 )
136 : value(value),
139 {
140 // Do nothing
141 }
142
143 // Default constructor
145 : value([](const VectorRd x, const Cell *cell) -> double { return 0.;}),
146 is_zero(true),
147 is_constant(true)
148 {
149 // Do nothing
150 }
151
152 // Members
156 };
157
158// ----------------------------------------------------------------------------
159// Class definition
160// ----------------------------------------------------------------------------
161
164{
165
166public:
168 TestCase(
169 std::vector<int> iTC
170 );
171
173 inline Solution get_solution();
174
176 inline Diffusion get_diffusion();
177
179 inline Advection get_advection();
180
182 inline Reaction get_reaction();
183
186
189
191 inline double get_lambda();
192
194 void validate();
195
196
197
198private:
199 // Parameters: id of test case, pi
200 std::vector<int> m_iTC;
201 const double pi = acos(-1);
202 const double sqrt2 = std::pow(2, 0.5);
203 const double eps = 1e-5; // constant for rotating diffusion case
204
205 // Generic parameter (e.g. for changing anisotropy etc.)
206 double _lambda;
207
208 // Advection, reaction, etc and functions to create them
209 Solution m_sol;
210 Diffusion m_diff;
211 Advection m_advec;
212 Reaction m_reac;
213
214 Solution create_solution(const size_t n);
215 Diffusion create_diffusion(const size_t n);
216 Advection create_advection(const size_t n);
217 Reaction create_reaction(const size_t n);
218
219};
220
221inline double TestCase::get_lambda() { return _lambda; };
222inline Solution TestCase::get_solution() { return m_sol; };
223inline Diffusion TestCase::get_diffusion() { return m_diff; };
224inline Advection TestCase::get_advection() { return m_advec; };
225inline Reaction TestCase::get_reaction() { return m_reac; };
226
228
229#endif //_TEST_CASE_HPP
std::function< T(const VectorRd &, const Cell *)> CellFType
type for function of a point, that could be discontinuous between cells. T is the type of value of th...
Definition TestCase.hpp:42
The TestCase class provides definition of test cases.
Definition TestCase.hpp:164
void validate()
Check if the provided test cases are valid (within range, and combination of solution/diffusion valid...
Definition TestCase.cpp:538
CellFType< double > diff_source()
Returns the diffusion source term.
Definition TestCase.cpp:514
Advection get_advection()
Returns the advection.
Definition TestCase.hpp:224
Diffusion get_diffusion()
Returns the diffusion.
Definition TestCase.hpp:223
double get_lambda()
Returns the value of the parameter lambda.
Definition TestCase.hpp:221
CellFType< double > diff_advec_reac_source()
Returns the diffusion-advection-reaction source term.
Definition TestCase.cpp:525
Reaction get_reaction()
Returns the reaction.
Definition TestCase.hpp:225
Solution get_solution()
Returns the solution.
Definition TestCase.hpp:222
Eigen::Vector2d VectorRd
Definition basis.hpp:55
std::function< T(const VectorRd &)> FType
type for function of point. T is the type of value of the function
Definition basis.hpp:64
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition ddr-klplate.hpp:27
Structure to store an advection velocity and its divergence, together with various flags.
Definition TestCase.hpp:90
CellFType< VectorRd > value
Definition TestCase.hpp:120
bool is_zero
Definition TestCase.hpp:122
CellFType< double > divergence
Definition TestCase.hpp:121
Advection()
Definition TestCase.hpp:109
bool is_divergence_constant
Definition TestCase.hpp:124
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:92
bool is_divergence_zero
Definition TestCase.hpp:123
Structure to store a diffusion tensor and its row-wise divergence.
Definition TestCase.hpp:68
const CellFType< MatrixRd > value
Definition TestCase.hpp:83
const CellFType< VectorRd > divergence
Definition TestCase.hpp:84
Diffusion(const CellFType< MatrixRd > value, const CellFType< VectorRd > divergence, const size_t degree)
Definition TestCase.hpp:70
const size_t degree
Definition TestCase.hpp:85
Structure to store a reaction term, together with various flags.
Definition TestCase.hpp:129
Reaction()
Definition TestCase.hpp:144
CellFType< double > value
Definition TestCase.hpp:153
Reaction(const CellFType< double > value, const bool is_zero, const bool is_constant)
Definition TestCase.hpp:131
bool is_constant
Definition TestCase.hpp:155
bool is_zero
Definition TestCase.hpp:154
Structure to store a solution and its derivatives.
Definition TestCase.hpp:46
const FType< double > value
Definition TestCase.hpp:61
const CellFType< VectorRd > gradient
Definition TestCase.hpp:62
Solution(const FType< double > value, const CellFType< VectorRd > gradient, const CellFType< MatrixRd > hessian)
Definition TestCase.hpp:48
const CellFType< MatrixRd > hessian
Definition TestCase.hpp:63