ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
postprocessor
solution_field.h
1
/* ______________________________________________________________________
2
*
3
* ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4
*
5
* Copyright (C) 2021 by the ExaDG authors
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
* ______________________________________________________________________
20
*/
21
22
#ifndef EXADG_POSTPROCESSOR_SOLUTION_FIELD_H_
23
#define EXADG_POSTPROCESSOR_SOLUTION_FIELD_H_
24
25
// deal.II
26
#include <deal.II/dofs/dof_handler.h>
27
#include <deal.II/lac/la_parallel_vector.h>
28
29
namespace
ExaDG
30
{
31
enum class
SolutionFieldType
32
{
33
scalar,
34
vector,
35
cellwise
36
};
37
38
template
<
int
dim,
typename
Number>
39
class
SolutionField :
public
dealii::EnableObserverPointer
40
{
41
public
:
42
using
VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
43
44
SolutionField()
45
: initialize_vector([](VectorType &) {}),
46
recompute_solution_field([](VectorType &, VectorType
const
&) {}),
47
type(SolutionFieldType::scalar),
48
name(
"solution"
),
49
dof_handler(
nullptr
),
50
is_available(
false
)
51
{
52
}
53
58
void
59
reinit
()
60
{
61
initialize_vector(solution_vector);
62
}
63
67
void
68
invalidate
()
69
{
70
is_available =
false
;
71
}
72
73
void
74
evaluate(
VectorType
const
& src)
75
{
76
if
(not is_available)
77
{
78
recompute_solution_field(solution_vector, src);
79
is_available =
true
;
80
}
81
}
82
83
VectorType
const
&
84
get()
const
85
{
86
AssertThrow(is_available,
87
dealii::ExcMessage(
"You are trying to access a Vector that is invalid."
));
88
89
return
solution_vector;
90
}
91
92
VectorType
const
&
93
evaluate_get(VectorType
const
& src)
94
{
95
evaluate(src);
96
97
return
get();
98
}
99
100
std::string
const
&
101
get_name()
const
102
{
103
return
name;
104
}
105
106
dealii::DoFHandler<dim>
const
&
107
get_dof_handler()
const
108
{
109
return
*dof_handler;
110
}
111
112
SolutionFieldType
113
get_type()
const
114
{
115
return
type;
116
}
117
118
// TODO: these element variables should not be public but instead be passed to the reinit function
119
std::function<void(VectorType &)> initialize_vector;
120
121
std::function<void(VectorType &, VectorType
const
&)> recompute_solution_field;
122
123
SolutionFieldType type;
124
125
std::string name;
126
127
dealii::DoFHandler<dim>
const
* dof_handler;
128
129
private
:
130
bool
is_available;
131
VectorType solution_vector;
132
};
133
134
}
// namespace ExaDG
135
136
#endif
/* EXADG_POSTPROCESSOR_SOLUTION_FIELD_H_ */
ExaDG::VectorType
ExaDG::SolutionField::reinit
void reinit()
Definition
solution_field.h:59
ExaDG::SolutionField::invalidate
void invalidate()
Definition
solution_field.h:68
ExaDG
Definition
driver.cpp:33
Generated by
1.17.0