ExaDG
Loading...
Searching...
No Matches
momentum_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_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_MOMENTUM_OPERATOR_H_
23#define EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_MOMENTUM_OPERATOR_H_
24
25// ExaDG
26#include <exadg/incompressible_navier_stokes/spatial_discretization/generalized_newtonian_model.h>
27#include <exadg/incompressible_navier_stokes/spatial_discretization/operators/convective_operator.h>
28#include <exadg/incompressible_navier_stokes/spatial_discretization/operators/viscous_operator.h>
29#include <exadg/incompressible_navier_stokes/spatial_discretization/turbulence_model.h>
30#include <exadg/incompressible_navier_stokes/user_interface/viscosity_model_data.h>
31#include <exadg/operators/mass_kernel.h>
32#include <exadg/operators/operator_base.h>
33
34namespace ExaDG
35{
36namespace IncNS
37{
38template<int dim>
39struct MomentumOperatorData : public OperatorBaseData
40{
41 MomentumOperatorData()
42 : OperatorBaseData(), unsteady_problem(false), convective_problem(false), viscous_problem(false)
43 {
44 }
45
46 bool unsteady_problem;
47 bool convective_problem;
48 bool viscous_problem;
49
50 TurbulenceModelData turbulence_model_data;
51 GeneralizedNewtonianModelData generalized_newtonian_model_data;
52
53 Operators::ConvectiveKernelData convective_kernel_data;
54 Operators::ViscousKernelData viscous_kernel_data;
55
56 std::shared_ptr<BoundaryDescriptorU<dim> const> bc;
57};
58
59template<int dim, typename Number>
60class MomentumOperator : public OperatorBase<dim, Number, dim>
61{
62private:
63 typedef dealii::VectorizedArray<Number> scalar;
64 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
65 typedef dealii::Tensor<2, dim, dealii::VectorizedArray<Number>> tensor;
66
67 typedef OperatorBase<dim, Number, dim> Base;
68
69 typedef typename Base::VectorType VectorType;
70 typedef typename Base::IntegratorCell IntegratorCell;
71 typedef typename Base::IntegratorFace IntegratorFace;
72
73public:
74 // required by preconditioner interfaces
75 typedef Number value_type;
76
77 MomentumOperator();
78
83 void
84 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
85 dealii::AffineConstraints<Number> const & affine_constraints,
86 MomentumOperatorData<dim> const & data,
87 dealii::Mapping<dim> const & mapping);
88
89 void
90 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
91 dealii::AffineConstraints<Number> const & affine_constraints,
92 MomentumOperatorData<dim> const & data,
93 std::shared_ptr<Operators::ViscousKernel<dim, Number>> viscous_kernel,
94 std::shared_ptr<Operators::ConvectiveKernel<dim, Number>> convective_kernel);
95
97 get_data() const;
98
100 get_convective_kernel_data() const;
101
103 get_viscous_kernel_data() const;
104
105 VectorType const &
106 get_velocity() const;
107
108 /*
109 * Interface required by Newton solver.
110 */
111 void
112 set_solution_linearization(VectorType const & velocity);
113
114 /*
115 * Update of operator (required, e.g., for multigrid).
116 */
117 void
118 update_after_grid_motion();
119
120 void
121 set_velocity_copy(VectorType const & velocity) const;
122
123 void
124 set_velocity_ptr(VectorType const & velocity) const;
125
126 Number
127 get_scaling_factor_mass_operator() const;
128
129 void
130 set_scaling_factor_mass_operator(Number const & number);
131
132 void
133 update_viscosity(VectorType const & velocity) const;
134
135 /*
136 * Interfaces of OperatorBase.
137 */
138 void
139 rhs(VectorType & dst) const final;
140
141 void
142 rhs_add(VectorType & dst) const final;
143
144 void
145 evaluate(VectorType & dst, VectorType const & src) const final;
146
147 void
148 evaluate_add(VectorType & dst, VectorType const & src) const final;
149
150private:
151 void
152 reinit_cell_derived(IntegratorCell & integrator, unsigned int const cell) const final;
153
154 void
155 reinit_face_derived(IntegratorFace & integrator_m,
156 IntegratorFace & integrator_p,
157 unsigned int const face) const final;
158
159 void
160 reinit_boundary_face_derived(IntegratorFace & integrator_m, unsigned int const face) const final;
161
162 void
163 reinit_face_cell_based_derived(IntegratorFace & integrator_m,
164 IntegratorFace & integrator_p,
165 unsigned int const cell,
166 unsigned int const face,
167 dealii::types::boundary_id const boundary_id) const final;
168
169 // linearized operator
170 void
171 do_cell_integral(IntegratorCell & integrator) const final;
172
173 // linearized operator
174 void
175 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const final;
176
177 // linearized operator
178 void
179 do_face_int_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const final;
180
181 // linearized operator
182
183 // TODO
184 // This function is currently only needed due to limitations of deal.II which do
185 // currently not allow to access neighboring data in case of cell-based face loops.
186 // Once this functionality is available, this function should be removed again.
187 void
188 do_face_int_integral_cell_based(IntegratorFace & integrator_m,
189 IntegratorFace & integrator_p) const final;
190
191 // linearized operator
192 void
193 do_face_ext_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const final;
194
195 // linearized operator
196 void
197 do_boundary_integral(IntegratorFace & integrator,
198 OperatorType const & operator_type,
199 dealii::types::boundary_id const & boundary_id) const final;
200
201 MomentumOperatorData<dim> operator_data;
202
203 std::shared_ptr<MassKernel<dim, Number>> mass_kernel;
204 std::shared_ptr<Operators::ConvectiveKernel<dim, Number>> convective_kernel;
205 std::shared_ptr<Operators::ViscousKernel<dim, Number>> viscous_kernel;
206
207 // Flag signaling that the `viscous_kernel` is managed by this class.
208 bool viscous_kernel_own_storage;
209
210 // Variable viscosity models for when `viscous_kernel` is managed by this class.
211 mutable TurbulenceModel<dim, Number> turbulence_model_own_storage;
212 mutable GeneralizedNewtonianModel<dim, Number> generalized_newtonian_model_own_storage;
213
214 double scaling_factor_mass;
215};
216
217} // namespace IncNS
218} // namespace ExaDG
219
220#endif /* EXADG_INCOMPRESSIBLE_NAVIER_STOKES_SPATIAL_DISCRETIZATION_OPERATORS_MOMENTUM_OPERATOR_H_ \
221 */
Definition generalized_newtonian_model.h:37
void initialize(dealii::MatrixFree< dim, Number > const &matrix_free, dealii::AffineConstraints< Number > const &affine_constraints, MomentumOperatorData< dim > const &data, dealii::Mapping< dim > const &mapping)
Definition momentum_operator.cpp:35
Definition convective_operator.h:64
Definition viscous_operator.h:64
Definition turbulence_model.h:37
Definition driver.cpp:33
Definition viscosity_model_data.h:92
Definition momentum_operator.h:40
Definition convective_operator.h:38
Definition viscous_operator.h:41
Definition viscosity_model_data.h:51