include/meltpooldg/heat/heat_diffuse_operator.hpp Source File

Developer Documentation: include/meltpooldg/heat/heat_diffuse_operator.hpp Source File
Developer Documentation
heat_diffuse_operator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/aligned_vector.h>
4#include <deal.II/base/function.h>
5#include <deal.II/base/point.h>
6#include <deal.II/base/types.h>
7#include <deal.II/base/vectorization.h>
8
9#include <deal.II/grid/tria.h>
10
11#include <deal.II/lac/full_matrix.h>
12
13#include <deal.II/matrix_free/matrix_free.h>
14
25
26#include <map>
27#include <memory>
28#include <tuple>
29#include <utility>
30#include <vector>
31
32
33namespace MeltPoolDG::Heat
34{
35 /*
36 * This operator computes the residual and its consistent tangent of the discretized heat
37 * equation with temperature dependent material properties:
38 * ρ^(n) = ρ(T^(n)), c_p^(n) = c_p(T^(n)), k^(n) = k(T^(n))
39 *
40 * 1 / \
41 * R(T_b^(n+1)) = --- | N_a, ρ^(n+1) c_p^(n+1) N_b ( T_b^(n+1) - T_b^(n)) ) |
42 * dt \ /
43 * Ω
44 * / \
45 * + | ∇N_a, k^(n+1) ∇N_b T_b^(n+1)) |
46 * \ /
47 * Ω
48 * / \
49 * + | N_a, ρ^(n+1) c_p^(n+1) ∇N_b T_b^(n+1) · u |
50 * \ /
51 * Ω
52 * / \
53 * + | N_a, ρ^(n+1) c_p^(n+1) N_b T_b^(n+1) ∇·u | (this term is not yet considered @todo)
54 * \ /
55 * Ω
56 * / _ \ / _ \
57 * - | N_a, q_s | - | N_a, q | = 0
58 * \ / \ /
59 * Ω Γ
60 * N
61 *
62 *
63 * dR(T^(n+1)) 1 / \
64 * ----------- = --- | N_a, ρ^(n+1) c_p^(n+1) N_b |
65 * dT_b^(n+1) dt \ /
66 * Ω
67 * 1 / d ρ c_p | \
68 * + -- | N_a, ---------| N_b ( T_b^(n+1) - T_b^(n)) ) |
69 * dt \ d T | /
70 * |(n+1) Ω
71 * / d k | \
72 * + | ∇N_a, k^(n+1) ∇N_b + -----| ∇N_b T_b^(n+1) |
73 * \ d T | /
74 * |(n+1) Ω
75 * / \
76 * + | N_a, ρ^(n+1) c_p^(n+1) ( ∇N_b u + N_b ∇·u ) |
77 * \ /
78 * Ω
79 * / d ρ c_p | \
80 * + | N_a, ---------| ( ∇N_b T_b^(n+1) · u + N_b T_b^(n+1) ∇·u ) |
81 * \ d T | /
82 * |(n+1) Ω
83 * _ _
84 * / d q_s \ / d q \
85 * - | N_a, --------- | - | N_a, --------- |
86 * \ dT_b^(n+1) / \ dT_b^(n+1) /
87 * Ω Γ
88 * N
89 *
90 * with shape functions N_a and N_b, nodal temperature values T_b^(n+1), the density ρ, the
91 * specific heat capacity c_p and the conductivity k, source/sink terms q_s and prescribed
92 * fluxes q along Neumann boundaries. The heat flux may result from radiative losses
93 *
94 * _
95 * q = σ ϵ (T^4-T∞^4)
96 *
97 * with the Stefan-Boltzmann constant σ, the emissivity ϵ and the temperature of the surroundings
98 * T∞ as well as convective losses
99 *
100 * _
101 * q = α (T-T∞)
102 *
103 * with the convection coefficient denoted as α.
104 *
105 * We assume that the density and the specific heat capacity do not dependent on the temperature.
106 *
107 */
108
109 template <int dim, typename number>
111 {
112 private:
113 // to avoid compiler warnings regarding hidden overriden functions
114 using OperatorMatrixFree<dim, number>::create_rhs;
116 using OperatorMatrixFree<dim, number>::vmult;
117
120
124 const unsigned int heat_dof_idx;
125 const unsigned int heat_quad_idx;
126 const unsigned int heat_no_bc_dof_idx;
127
130 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>>
131 neumann_bc; //@todo find a nice way to provide BC
132 std::vector<dealii::types::boundary_id> bc_radiation_indices;
133 std::vector<dealii::types::boundary_id> bc_convection_indices;
134
136
137 // optional: flow velocity for internal convection
138 const unsigned int vel_dof_idx = dealii::numbers::invalid_unsigned_int;
140
141 // optional: level set heaviside field for two phase flow
142 const unsigned int ls_dof_idx = dealii::numbers::invalid_unsigned_int;
144
145 // optional: two phase flow with evaporation
147 unsigned int mass_flux_dof_idx = dealii::numbers::invalid_unsigned_int;
148 std::unique_ptr<Evaporation::EvaporativeCooling<number>> evaporative_cooling;
149
150 // optional: melting/solidification effects
152
153 // interpolation of the level set space to the temperature space
154 dealii::FullMatrix<number> ls_to_heat_grad_interpolation_matrix;
156
157 /*
158 * contribution to heat source due to evaporation;
159 * just for output purposes
160 */
163 mutable dealii::AlignedVector<dealii::VectorizedArray<number>> q_vapor;
164
165 // phase weighted delta function, only used for evaporative cooling
166 std::unique_ptr<const LevelSet::DeltaApproximationBase<number>> delta_phase_weighted;
167
168 mutable dealii::AlignedVector<dealii::VectorizedArray<number>> conductivity_at_q;
170
171 mutable dealii::AlignedVector<dealii::VectorizedArray<number>> rho_cp_at_q;
173
174 // for efficient ghost value update
175 mutable std::vector<bool> do_update_ghosts;
176
177 public:
179 const ScratchData<dim, dim, number> &scratch_data_in,
180 const std::shared_ptr<const BoundaryConditionManager<dim, number>> heat_bc_manager,
181 const HeatData<number> &data_in,
183 const unsigned int heat_dof_idx_in,
184 const unsigned int heat_quad_idx_in,
185 const unsigned int heat_no_bc_dof_idx,
186 const VectorType &temperature_in,
187 const VectorType &temperature_old_in,
188 const VectorType &heat_source_in,
189 const unsigned int vel_dof_idx_in = 0,
190 const VectorType *velocity_in = nullptr,
191 const unsigned int ls_dof_idx_in = 0,
192 const VectorType *level_set_as_heaviside_in = nullptr,
193 const bool do_solidifiaction_in = false);
194
195 void
196 register_evaporative_mass_flux(VectorType *evaporative_mass_flux_in,
197 const unsigned int mass_flux_dof_idx_in,
198 const Evaporation::EvaporationData<number> &evapor_data);
199
200 void
202 const std::vector<
203 std::tuple<const typename dealii::Triangulation<dim, dim>::cell_iterator /*cell*/,
204 std::vector<dealii::Point<dim>> /*quad_points*/,
205 std::vector<number> /*weights*/
207
208 void
209 pre() final;
210
211 void
212 post() final;
213 /*
214 * matrix-free implementation
215 */
216 void
217 vmult(VectorType &dst, const VectorType &src /*solution_update*/) const final;
218
219 void
220 tangent_cell_loop(const dealii::MatrixFree<dim, number> &matrix_free,
221 VectorType &dst,
222 const VectorType &src,
223 std::pair<unsigned int, unsigned int> cell_range) const;
224
225 /*
226 * compute the tangent of Robin-type boundary conditions for convection and radiation
227 */
228 void
229 tangent_boundary_loop(const dealii::MatrixFree<dim, number> &matrix_free,
230 VectorType &dst,
231 const VectorType &src,
232 std::pair<unsigned int, unsigned int> face_range) const;
233
234 void
236
237 void
239
240 void
241 rhs_cell_loop(const dealii::MatrixFree<dim, number> &matrix_free,
242 VectorType &dst,
243 const VectorType &src, /* temperature_old*/
244 std::pair<unsigned int, unsigned int> cell_range) const;
245
246 /*
247 * compute the RHS due to Neumann and Robin-type boundary conditions for convection and
248 * radiation
249 *
250 * @todo: add equations
251 */
252 void
253 rhs_boundary_loop(const dealii::MatrixFree<dim, number> &matrix_free,
254 VectorType &dst,
255 [[maybe_unused]] const VectorType &src,
256 std::pair<unsigned int, unsigned int> face_range) const;
257
258 void
259 rhs_cut_cell_loop(VectorType &dst) const;
260
264 void
265 create_rhs(VectorType &dst, const VectorType &src /*temperature_old*/) const final;
266
270 void
271 attach_vectors(std::vector<VectorType *> &vectors);
272
273 void
275
276 void
277 reinit() final;
278
279 void
280 attach_output_vectors(GenericDataOut<dim, number> &data_out) const;
281
282 private:
291 void
293 FECellIntegrator<dim, 1, number> &eval,
294 FECellIntegrator<dim, 1, number> &T_new_eval,
295 FECellIntegrator<dim, 1, number> &T_old_eval,
296 FECellIntegrator<dim, dim, number> &vel_eval,
297 FECellIntegrator<dim, 1, number> &heaviside_eval,
298 FECellIntegrator<dim, 1, number> &heaviside_interpolated_eval,
299 const std::unique_ptr<FECellIntegrator<dim, 1, number>> &mass_flux_eval,
300 bool do_reinit_cells) const;
301
310 void
311 tangent_local_boundary_operation(FEFaceIntegrator<dim, 1, number> &face_eval,
312 FEFaceIntegrator<dim, 1, number> &T_face_eval,
313 bool do_reinit_face) const;
320 void
322 [[maybe_unused]] SparseMatrixType &system_matrix,
323 const bool do_diagonal) const;
324
333 std::tuple<dealii::VectorizedArray<number>, dealii::VectorizedArray<number>>
334 get_material_parameters(const FECellIntegrator<dim, 1, number> &T_eval,
335 const FECellIntegrator<dim, 1, number> &heaviside_eval,
336 unsigned int q) const;
337
350 std::tuple<dealii::VectorizedArray<number>,
351 dealii::VectorizedArray<number>,
352 dealii::VectorizedArray<number>,
353 dealii::VectorizedArray<number>>
354 get_material_parameters_and_derivatives(const FECellIntegrator<dim, 1, number> &T_eval,
355 const FECellIntegrator<dim, 1, number> &heaviside_eval,
356 unsigned int q) const;
357
358 const std::vector<
359 std::tuple<const typename dealii::Triangulation<dim, dim>::cell_iterator /*cell*/,
360 std::vector<dealii::Point<dim>> /*quad_points*/,
361 std::vector<number> /*weights*/
362 >> *surface_mesh_info = nullptr;
363
364 Evaporation::EvaporCoolingInterfaceFluxType evaporative_cooling_interface_flux_type =
365 Evaporation::EvaporCoolingInterfaceFluxType::none;
366 };
367} // namespace MeltPoolDG::Heat
Definition boundary_conditions.hpp:17
A generic utility for managing simulation output data in the MeltPoolDG context.
Definition generic_data_out.hpp:32
Definition heat_diffuse_operator.hpp:111
void pre() final
Prepare for computations (e.g. update ghost values). Can be overridden by derived classes.
Definition heat_diffuse_operator.cpp:139
const VectorType & heat_source
Definition heat_diffuse_operator.hpp:135
dealii::AlignedVector< dealii::VectorizedArray< number > > conductivity_at_q
Definition heat_diffuse_operator.hpp:168
void create_rhs(VectorType &dst, const VectorType &src) const final
Definition heat_diffuse_operator.cpp:785
void rhs_cell_loop(const dealii::MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, std::pair< unsigned int, unsigned int > cell_range) const
Definition heat_diffuse_operator.cpp:395
dealii::AlignedVector< dealii::VectorizedArray< number > > rho_cp_at_q
Definition heat_diffuse_operator.hpp:171
const VectorType * level_set_as_heaviside
Definition heat_diffuse_operator.hpp:143
void rhs_cut_cell_loop(VectorType &dst) const
Definition heat_diffuse_operator.cpp:533
void vmult(VectorType &dst, const VectorType &src) const final
Definition heat_diffuse_operator.cpp:181
std::vector< bool > do_update_ghosts
Definition heat_diffuse_operator.hpp:175
const unsigned int heat_quad_idx
Definition heat_diffuse_operator.hpp:125
const unsigned int ls_dof_idx
Definition heat_diffuse_operator.hpp:142
void compute_inverse_diagonal_from_matrixfree(VectorType &diagonal) const final
Compute the inverse diagonal using matrix-free techniques.
Definition heat_diffuse_operator.cpp:273
const bool do_solidification
Definition heat_diffuse_operator.hpp:151
Evaporation::EvaporCoolingInterfaceFluxType evaporative_cooling_interface_flux_type
Definition heat_diffuse_operator.hpp:364
std::unique_ptr< Evaporation::EvaporativeCooling< number > > evaporative_cooling
Definition heat_diffuse_operator.hpp:148
std::tuple< dealii::VectorizedArray< number >, dealii::VectorizedArray< number >, dealii::VectorizedArray< number >, dealii::VectorizedArray< number > > get_material_parameters_and_derivatives(const FECellIntegrator< dim, 1, number > &T_eval, const FECellIntegrator< dim, 1, number > &heaviside_eval, unsigned int q) const
Definition heat_diffuse_operator.cpp:1172
void tangent_local_cell_operation(FECellIntegrator< dim, 1, number > &eval, FECellIntegrator< dim, 1, number > &T_new_eval, FECellIntegrator< dim, 1, number > &T_old_eval, FECellIntegrator< dim, dim, number > &vel_eval, FECellIntegrator< dim, 1, number > &heaviside_eval, FECellIntegrator< dim, 1, number > &heaviside_interpolated_eval, const std::unique_ptr< FECellIntegrator< dim, 1, number > > &mass_flux_eval, bool do_reinit_cells) const
Definition heat_diffuse_operator.cpp:957
const unsigned int heat_dof_idx
Definition heat_diffuse_operator.hpp:124
void internal_compute_diagonal_or_system_matrix(VectorType &diagonal, SparseMatrixType &system_matrix, const bool do_diagonal) const
Definition heat_diffuse_operator.cpp:299
void tangent_boundary_loop(const dealii::MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, std::pair< unsigned int, unsigned int > face_range) const
Definition heat_diffuse_operator.cpp:245
std::unique_ptr< const LevelSet::DeltaApproximationBase< number > > delta_phase_weighted
Definition heat_diffuse_operator.hpp:166
const Material< number > & material
Definition heat_diffuse_operator.hpp:123
bool do_level_set_temperature_gradient_interpolation
Definition heat_diffuse_operator.hpp:155
const VectorType & temperature_old
Definition heat_diffuse_operator.hpp:129
void attach_vectors(std::vector< VectorType * > &vectors)
Definition heat_diffuse_operator.cpp:810
const std::vector< std::tuple< const typename dealii::Triangulation< dim, dim >::cell_iterator, std::vector< dealii::Point< dim > >, std::vector< number > > > * surface_mesh_info
Definition heat_diffuse_operator.hpp:362
void register_evaporative_mass_flux(VectorType *evaporative_mass_flux_in, const unsigned int mass_flux_dof_idx_in, const Evaporation::EvaporationData< number > &evapor_data)
Definition heat_diffuse_operator.cpp:95
VectorType conductivity_vec
Definition heat_diffuse_operator.hpp:169
const VectorType & temperature
Definition heat_diffuse_operator.hpp:128
VectorType * evaporative_mass_flux
Definition heat_diffuse_operator.hpp:146
std::vector< dealii::types::boundary_id > bc_radiation_indices
Definition heat_diffuse_operator.hpp:132
const unsigned int heat_no_bc_dof_idx
Definition heat_diffuse_operator.hpp:126
const VectorType * velocity
Definition heat_diffuse_operator.hpp:139
void tangent_cell_loop(const dealii::MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, std::pair< unsigned int, unsigned int > cell_range) const
Definition heat_diffuse_operator.cpp:201
std::map< dealii::types::boundary_id, std::shared_ptr< dealii::Function< dim > > > neumann_bc
Definition heat_diffuse_operator.hpp:131
std::vector< dealii::types::boundary_id > bc_convection_indices
Definition heat_diffuse_operator.hpp:133
void distribute_constraints()
Definition heat_diffuse_operator.cpp:818
dealii::FullMatrix< number > ls_to_heat_grad_interpolation_matrix
Definition heat_diffuse_operator.hpp:154
const ScratchData< dim, dim, number > & scratch_data
Definition heat_diffuse_operator.hpp:121
const HeatData< number > & data
Definition heat_diffuse_operator.hpp:122
unsigned int mass_flux_dof_idx
Definition heat_diffuse_operator.hpp:147
void post() final
Finalize for computations (e.g. zero out ghost values). Can be overridden by derived classes.
Definition heat_diffuse_operator.cpp:161
VectorType evapor_heat_source
Definition heat_diffuse_operator.hpp:161
void register_surface_mesh(const std::vector< std::tuple< const typename dealii::Triangulation< dim, dim >::cell_iterator, std::vector< dealii::Point< dim > >, std::vector< number > > > &surface_mesh_info)
Definition heat_diffuse_operator.cpp:84
VectorType evapor_heat_source_projected
Definition heat_diffuse_operator.hpp:162
void attach_output_vectors(GenericDataOut< dim, number > &data_out) const
Definition heat_diffuse_operator.cpp:845
typename OperatorMatrixFree< dim, number >::VectorType VectorType
Definition heat_diffuse_operator.hpp:118
void reinit() final
Reinitialize data structures. Can be overridden by derived classes.
Definition heat_diffuse_operator.cpp:825
void compute_system_matrix_from_matrixfree(SparseMatrixType &system_matrix) const final
Compute a sparse matrix using matrix-free techniques.
Definition heat_diffuse_operator.cpp:288
dealii::AlignedVector< dealii::VectorizedArray< number > > q_vapor
Definition heat_diffuse_operator.hpp:163
void rhs_boundary_loop(const dealii::MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, std::pair< unsigned int, unsigned int > face_range) const
Definition heat_diffuse_operator.cpp:721
typename OperatorMatrixFree< dim, number >::SparseMatrixType SparseMatrixType
Definition heat_diffuse_operator.hpp:119
const unsigned int vel_dof_idx
Definition heat_diffuse_operator.hpp:138
void tangent_local_boundary_operation(FEFaceIntegrator< dim, 1, number > &face_eval, FEFaceIntegrator< dim, 1, number > &T_face_eval, bool do_reinit_face) const
Definition heat_diffuse_operator.cpp:1090
std::tuple< dealii::VectorizedArray< number >, dealii::VectorizedArray< number > > get_material_parameters(const FECellIntegrator< dim, 1, number > &T_eval, const FECellIntegrator< dim, 1, number > &heaviside_eval, unsigned int q) const
Definition heat_diffuse_operator.cpp:1135
VectorType rho_cp_vec
Definition heat_diffuse_operator.hpp:172
Definition material.hpp:96
Operator handling matrix-free computations.
Definition operator_base.hpp:190
dealii::TrilinosWrappers::SparseMatrix SparseMatrixType
Definition operator_base.hpp:194
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition operator_base.hpp:192
Container for shared scratch data between operations/operators.
Definition scratch_data.hpp:61
Definition apparent_capacity.hpp:9
dealii::FEFaceEvaluation< dim, -1, 0, n_components, number, VectorizedArrayType > FEFaceIntegrator
Definition fe_integrator.hpp:22
dealii::FEEvaluation< dim, -1, 0, n_components, number, VectorizedArrayType > FECellIntegrator
Definition fe_integrator.hpp:14
Definition dealii_tensor.hpp:10
Definition heat_data.hpp:18