ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
operators
rhs_operator.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_OPERATORS_RHS_OPERATOR_H_
23
#define EXADG_OPERATORS_RHS_OPERATOR_H_
24
25
// ExaDG
26
#include <exadg/functions_and_boundary_conditions/evaluate_functions.h>
27
#include <exadg/matrix_free/integrators.h>
28
#include <exadg/operators/mapping_flags.h>
29
30
namespace
ExaDG
31
{
32
namespace
Operators
33
{
34
template
<
int
dim>
35
struct
RHSKernelData
36
{
37
std::shared_ptr<dealii::Function<dim>> f;
38
};
39
40
template
<
int
dim,
typename
Number,
int
n_components = 1>
41
class
RHSKernel
42
{
43
private
:
44
typedef
CellIntegrator<dim, n_components, Number> IntegratorCell;
45
46
static
unsigned
int
const
rank =
47
(n_components == 1) ? 0 : ((n_components == dim) ? 1 : dealii::numbers::invalid_unsigned_int);
48
49
typedef
dealii::VectorizedArray<Number> scalar;
50
typedef
dealii::Tensor<rank, dim, scalar> value;
51
52
public
:
53
void
54
reinit(
RHSKernelData<dim>
const
& data_in)
const
55
{
56
data = data_in;
57
}
58
59
static
MappingFlags
60
get_mapping_flags()
61
{
62
MappingFlags
flags;
63
64
flags.cells = dealii::update_JxW_values |
65
dealii::update_quadrature_points;
// q-points due to rhs function f
66
67
// no face integrals
68
69
return
flags;
70
}
71
72
/*
73
* Volume flux, i.e., the term occurring in the volume integral
74
*/
75
inline
DEAL_II_ALWAYS_INLINE
//
76
value
77
get_volume_flux(IntegratorCell
const
& integrator,
78
unsigned
int
const
q,
79
Number
const
& time)
const
80
{
81
dealii::Point<dim, scalar> q_points = integrator.quadrature_point(q);
82
83
return
FunctionEvaluator<rank, dim, Number>::value(*(data.f), q_points, time);
84
}
85
86
private
:
87
mutable
RHSKernelData<dim>
data;
88
};
89
90
}
// namespace Operators
91
92
93
template
<
int
dim>
94
struct
RHSOperatorData
95
{
96
RHSOperatorData() : dof_index(0), quad_index(0)
97
{
98
}
99
100
unsigned
int
dof_index;
101
unsigned
int
quad_index;
102
103
Operators::RHSKernelData<dim>
kernel_data;
104
};
105
106
template
<
int
dim,
typename
Number,
int
n_components = 1>
107
class
RHSOperator
108
{
109
private
:
110
typedef
dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
111
112
typedef
RHSOperator<dim, Number, n_components> This;
113
114
typedef
CellIntegrator<dim, n_components, Number> IntegratorCell;
115
116
typedef
std::pair<unsigned int, unsigned int> Range;
117
118
public
:
119
/*
120
* Constructor.
121
*/
122
RHSOperator();
123
124
/*
125
* Initialization.
126
*/
127
void
128
initialize(dealii::MatrixFree<dim, Number>
const
& matrix_free,
129
RHSOperatorData<dim>
const
& data);
130
131
/*
132
* Evaluate operator and overwrite dst-vector.
133
*/
134
void
135
evaluate(VectorType & dst,
double
const
evaluation_time)
const
;
136
137
/*
138
* Evaluate operator and add to dst-vector.
139
*/
140
void
141
evaluate_add(VectorType & dst,
double
const
evaluation_time)
const
;
142
143
private
:
144
void
145
do_cell_integral(IntegratorCell & integrator)
const
;
146
147
/*
148
* The right-hand side operator involves only cell integrals so we only need a function looping
149
* over all cells and computing the cell integrals.
150
*/
151
void
152
cell_loop(dealii::MatrixFree<dim, Number>
const
& matrix_free,
153
VectorType & dst,
154
VectorType
const
& src,
155
Range
const
& cell_range)
const
;
156
157
dealii::MatrixFree<dim, Number>
const
* matrix_free;
158
159
RHSOperatorData<dim>
data;
160
161
mutable
double
time;
162
163
Operators::RHSKernel<dim, Number, n_components>
kernel;
164
};
165
166
}
// namespace ExaDG
167
168
#endif
/* EXADG_OPERATORS_RHS_OPERATOR_H_ */
ExaDG::Operators::RHSKernel
Definition
rhs_operator.h:42
ExaDG
Definition
driver.cpp:33
ExaDG::MappingFlags
Definition
mapping_flags.h:31
ExaDG::Operators::RHSKernelData
Definition
rhs_operator.h:36
ExaDG::RHSOperatorData
Definition
rhs_operator.h:95
Generated by
1.17.0