include/meltpooldg/compressible_flow/kernels.hpp Source File

Developer Documentation: include/meltpooldg/compressible_flow/kernels.hpp Source File
Developer Documentation
kernels.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/vectorization.h>
4
10
12{
21 template <int dim,
22 typename ConservedVariablesView,
23 typename WritableFluxView>
24 inline DEAL_II_ALWAYS_INLINE //
25 void
26 convective_flux(const ConservedVariablesView &conserved_variables, const WritableFluxView &flux)
27 {
28 const auto pressure = conserved_variables.pressure();
29
30 for (unsigned int d = 0; d < dim; ++d)
31 {
32 flux.density_flux()[d] = conserved_variables.momentum(d);
33 for (unsigned int e = 0; e < dim; ++e)
34 flux.momentum_flux(e)[d] =
35 conserved_variables.momentum(e) * conserved_variables.velocity(d);
36 flux.momentum_flux(d)[d] += pressure;
37 flux.energy_flux()[d] =
38 conserved_variables.velocity(d) * (conserved_variables.total_energy() + pressure);
39 }
40 }
41
48 template <int dim, typename number>
49 inline DEAL_II_ALWAYS_INLINE //
50 dealii::Tensor<1, dim, dealii::Tensor<1, dim, dealii::VectorizedArray<number>>>
52 const dealii::Tensor<1, dim, dealii::Tensor<1, dim, dealii::VectorizedArray<number>>>
53 &grad_velocity,
54 const dealii::VectorizedArray<number> dynamic_viscosity)
55 {
56 const dealii::VectorizedArray<number> div_u = 2. / 3. * trace(grad_velocity);
57
58 dealii::Tensor<1, dim, dealii::Tensor<1, dim, dealii::VectorizedArray<number>>> out;
59 for (unsigned int d = 0; d < dim; ++d)
60 {
61 for (unsigned int e = 0; e < dim; ++e)
62 out[d][e] = dynamic_viscosity * (grad_velocity[d][e] + grad_velocity[e][d]);
63 out[d][d] -= dynamic_viscosity * div_u;
64 }
65
66 return out;
67 }
68
80 template <int dim,
81 typename VectorizedArrayType,
82 typename DofStateView,
83 typename WritableFluxView>
84 inline DEAL_II_ALWAYS_INLINE //
85 void
86 diffusive_flux(const DofStateView &conserved_variables, const WritableFluxView &flux)
87 {
88 const auto viscous_stress =
89 viscous_stress_tensor(conserved_variables.grad_velocity(),
90 VectorizedArrayType(conserved_variables.dynamic_viscosity()));
91
92 const auto neg_heat_flux =
93 conserved_variables.thermal_conductivity() * conserved_variables.grad_temperature();
94
95 for (unsigned int d = 0; d < dim; ++d)
96 {
97 // density
98 flux.density_flux()[d] = 0.0;
99
100 // momentum
101 for (unsigned int e = 0; e < dim; ++e)
102 flux.momentum_flux(e)[d] = viscous_stress[e][d];
103
104 // energy
105 flux.energy_flux()[d] = neg_heat_flux[d];
106 for (unsigned int e = 0; e < dim; ++e)
107 flux.energy_flux()[d] += conserved_variables.velocity()[e] * viscous_stress[d][e];
108 }
109 }
110
111
112 template <int dim,
113 typename number,
114 typename ValueTypeIn = ConservedVariablesType<dim, number>,
115 typename FluxTypeIn = FluxType<dim, number>>
117 {
118 using ValueType = ValueTypeIn;
119 using PhysicalFluxType = FluxTypeIn;
120
123
127
134 flux(const ValueType &conserved_variables) const
135 {
137 DofStateViewType conserved_variables_view(conserved_variables, material);
138 convective_flux<dim, DofStateViewType, WritableFluxViewType>(conserved_variables_view,
140 return flux;
141 }
142
149 dealii::VectorizedArray<number>
150 local_maximum_wave_speed(const ValueType &u_m, const ValueType &u_p) const
151 {
152 return maximum_local_wave_speed<DofStateViewType, dealii::VectorizedArray<number>>(
154 }
155
156 private:
158 };
159
160
161 template <int dim,
162 typename number,
163 typename ValueTypeIn = ConservedVariablesType<dim, number>,
164 typename GradientTypeIn = ConservedVariablesGradientType<dim, number>,
165 typename FluxTypeIn = FluxType<dim, number>>
167 {
168 using ValueType = ValueTypeIn;
169 using GradientType = GradientTypeIn;
170 using PhysicalFluxType = FluxTypeIn;
171
175
183
191 flux(const ValueType &u, const GradientType &grad_u) const
192 {
194 diffusive_flux<dim, typename ValueType::value_type, DofStateViewType, WritableFluxViewType>(
196 return flux;
197 }
198
199 private:
201 };
202} // namespace MeltPoolDG::CompressibleFlow
This file contains various functions that can be used to set and evaluate boundary conditions for the...
Definition boundary_condition_functions.hpp:17
DEAL_II_ALWAYS_INLINE void diffusive_flux(const DofStateView &conserved_variables, const WritableFluxView &flux)
Definition kernels.hpp:86
DEAL_II_ALWAYS_INLINE dealii::Tensor< 1, dim, dealii::Tensor< 1, dim, dealii::VectorizedArray< number > > > viscous_stress_tensor(const dealii::Tensor< 1, dim, dealii::Tensor< 1, dim, dealii::VectorizedArray< number > > > &grad_velocity, const dealii::VectorizedArray< number > dynamic_viscosity)
Definition kernels.hpp:51
DEAL_II_ALWAYS_INLINE void convective_flux(const ConservedVariablesView &conserved_variables, const WritableFluxView &flux)
Definition kernels.hpp:26
dealii::Tensor< 1, n_conserved_variables< dim, n_species >, dealii::Tensor< 1, dim, dealii::VectorizedArray< number > > > FluxType
Definition data_types.hpp:51
dealii::Tensor< 1, n_conserved_variables< dim, n_species >, dealii::Tensor< 1, dim, VectorizedArrayType > > ConservedVariablesGradientType
Definition data_types.hpp:44
dealii::Tensor< 1, n_conserved_variables< dim, n_species >, VectorizedArrayType > ConservedVariablesType
Definition data_types.hpp:35
number trace(const dealii::Tensor< 1, dim, dealii::Tensor< 1, dim, number > > &in)
Definition dealii_tensor.hpp:246
This file provides a collection of view types for the compressible Navier–Stokes solver....
PhysicalFluxType flux(const ValueType &conserved_variables) const
Definition kernels.hpp:134
DofStateView< dim, number, const ValueType > DofStateViewType
Definition kernels.hpp:121
const MaterialPhaseData< number > & material
Definition kernels.hpp:157
ValueTypeIn ValueType
Definition kernels.hpp:118
dealii::VectorizedArray< number > local_maximum_wave_speed(const ValueType &u_m, const ValueType &u_p) const
Definition kernels.hpp:150
FluxTypeIn PhysicalFluxType
Definition kernels.hpp:119
ConvectiveFlux(const MaterialPhaseData< number > &material)
Definition kernels.hpp:124
FluxView< dim, PhysicalFluxType > WritableFluxViewType
Definition kernels.hpp:122
FluxView< dim, PhysicalFluxType > WritableFluxViewType
Definition kernels.hpp:174
DiffusiveFlux(const MaterialPhaseData< number > &material)
Definition kernels.hpp:180
ValueTypeIn ValueType
Definition kernels.hpp:168
const MaterialPhaseData< number > & material
Definition kernels.hpp:200
PhysicalFluxType flux(const ValueType &u, const GradientType &grad_u) const
Definition kernels.hpp:191
GradientTypeIn GradientType
Definition kernels.hpp:169
DofValueAndGradientStateView< dim, number, const ValueType, const GradientType > DofStateViewType
Definition kernels.hpp:173
FluxTypeIn PhysicalFluxType
Definition kernels.hpp:170
Definition state_views.hpp:151
decltype(auto) velocity(const unsigned int component) const
Definition state_views_mixins.hpp:60
Definition state_views.hpp:278
decltype(auto) dynamic_viscosity() const
Definition material_views_mixins.hpp:15
decltype(auto) thermal_conductivity() const
Definition material_views_mixins.hpp:21
Collection of material parameters for a specific fluid phase.
Definition material.hpp:119