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_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_RHS_OPERATOR_H_
23#define INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_RHS_OPERATOR_H_
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 IncNS
32{
33namespace Operators
34{
35template<int dim>
36struct RHSKernelData
37{
38 RHSKernelData()
39 : boussinesq_term(false),
40 boussinesq_dynamic_part_only(false),
41 thermal_expansion_coefficient(1.0),
42 reference_temperature(0.0)
43 {
44 }
45
46 std::shared_ptr<dealii::Function<dim>> f;
47
48 // Boussinesq term
49 bool boussinesq_term;
50 bool boussinesq_dynamic_part_only;
51 double thermal_expansion_coefficient;
52 double reference_temperature;
53 std::shared_ptr<dealii::Function<dim>> gravitational_force;
54};
55
56template<int dim, typename Number>
58{
59private:
60 typedef dealii::VectorizedArray<Number> scalar;
61 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
62
63 typedef CellIntegrator<dim, dim, Number> Integrator;
64 typedef CellIntegrator<dim, 1, Number> IntegratorScalar;
65
66public:
67 void
68 reinit(RHSKernelData<dim> const & data_in) const
69 {
70 data = data_in;
71 }
72
73 static MappingFlags
74 get_mapping_flags()
75 {
76 MappingFlags flags;
77
78 flags.cells = dealii::update_JxW_values |
79 dealii::update_quadrature_points; // q-points due to rhs function f
80
81 // no face integrals
82
83 return flags;
84 }
85
86 /*
87 * Volume flux, i.e., the term occurring in the volume integral
88 */
89 inline DEAL_II_ALWAYS_INLINE //
90 vector
91 get_volume_flux(Integrator const & integrator,
92 IntegratorScalar const & integrator_temperature,
93 unsigned int const q,
94 Number const & time) const
95 {
96 dealii::Point<dim, scalar> q_points = integrator.quadrature_point(q);
97
98 vector f = FunctionEvaluator<1, dim, Number>::value(*(data.f), q_points, time);
99
100 if(data.boussinesq_term)
101 {
102 vector g =
103 FunctionEvaluator<1, dim, Number>::value(*(data.gravitational_force), q_points, time);
104 scalar T = integrator_temperature.get_value(q);
105 scalar T_ref = data.reference_temperature;
106 // solve only for the dynamic pressure variations
107 if(data.boussinesq_dynamic_part_only)
108 f += g * (-data.thermal_expansion_coefficient * (T - T_ref));
109 else // includes hydrostatic component
110 f += g * (1.0 - data.thermal_expansion_coefficient * (T - T_ref));
111 }
112
113 return f;
114 }
115
116private:
117 mutable RHSKernelData<dim> data;
118};
119
120} // namespace Operators
121
122
123template<int dim>
124struct RHSOperatorData
125{
126 RHSOperatorData() : dof_index(0), quad_index(0), dof_index_scalar(2)
127 {
128 }
129
130 unsigned int dof_index;
131 unsigned int quad_index;
132
133 unsigned int dof_index_scalar;
134
136};
137
138template<int dim, typename Number>
139class RHSOperator
140{
141public:
142 typedef RHSOperator<dim, Number> This;
143
144 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
145
146 typedef std::pair<unsigned int, unsigned int> Range;
147
148 typedef CellIntegrator<dim, dim, Number> Integrator;
149
150 typedef CellIntegrator<dim, 1, Number> IntegratorScalar;
151
152 RHSOperator();
153
154 void
155 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
156 RHSOperatorData<dim> const & data);
157
158 void
159 evaluate(VectorType & dst, Number const evaluation_time) const;
160
161 void
162 evaluate_add(VectorType & dst, Number const evaluation_time) const;
163
164 void
165 set_temperature(VectorType const & T);
166
167private:
168 void
169 do_cell_integral(Integrator & integrator, IntegratorScalar & integrator_temperature) const;
170
171 void
172 cell_loop(dealii::MatrixFree<dim, Number> const & matrix_free,
173 VectorType & dst,
174 VectorType const & src,
175 Range const & cell_range) const;
176
177 dealii::MatrixFree<dim, Number> const * matrix_free;
178
180
181 mutable double time;
182
184
185 VectorType const * temperature;
186};
187
188} // namespace IncNS
189} // namespace ExaDG
190
191
192#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_RHS_OPERATOR_H_ \
193 */
Definition rhs_operator.h:58
Definition driver.cpp:33
Definition rhs_operator.h:37
Definition rhs_operator.h:125
Definition mapping_flags.h:31