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