include/meltpooldg/phase_change/incompressible_newtonian_evaporation_material.hpp Source File

Developer Documentation: include/meltpooldg/phase_change/incompressible_newtonian_evaporation_material.hpp Source File
Developer Documentation
incompressible_newtonian_evaporation_material.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/tensor.h>
4#include <deal.II/base/vectorization.h>
5
6#include <deal.II/lac/la_parallel_block_vector.h>
7#include <deal.II/lac/la_parallel_vector.h>
8
9#include <deal.II/matrix_free/evaluation_flags.h>
10
15
16#include <functional>
17
18
20{
37 template <int dim, typename number>
39 : public Flow::IncompressibleMaterialBase<dim, number>
40 {
41 private:
42 using BlockVectorType = dealii::LinearAlgebra::distributed::BlockVector<number>;
43
44 public:
47 const std::function<const dealii::VectorizedArray<number>
48 &(const unsigned int cell, const unsigned int q)> get_viscosity,
50 const dealii::LinearAlgebra::distributed::Vector<number> &heaviside,
51 const unsigned int normal_dof_idx,
52 const unsigned int ls_hanging_nodes_dof_idx,
53 const unsigned int velocity_quad_idx)
63 {}
64
70 void
71 reinit(const dealii::Tensor<2, dim, dealii::VectorizedArray<number>> &velocity_gradient,
72 const unsigned int cell_idx,
73 const unsigned int quad_idx) final
74 {
75 grad_u = velocity_gradient;
76 div_u = dealii::trace(velocity_gradient);
77
78 viscosity = get_viscosity(cell_idx, quad_idx);
79
80 // read normal vector values only for first quadrature point
81 if (quad_idx == 0 || cell_idx != cell)
82 {
83 normal_vals.reinit(cell_idx);
84 normal_vals.read_dof_values_plain(normal_vector);
85 normal_vals.evaluate(dealii::EvaluationFlags::values);
86
87 ls_vals.reinit(cell_idx);
88 ls_vals.read_dof_values_plain(heaviside);
89 ls_vals.evaluate(dealii::EvaluationFlags::values);
90 }
91
92 normal = normalize<dim>(normal_vals.get_value(quad_idx), 1e-10);
93 hs = ls_vals.get_value(quad_idx);
94
95 cell = cell_idx;
96 }
97
109 dealii::Tensor<2, dim, dealii::VectorizedArray<number>>
110 get_tau() final
111 {
112 const auto mask = dealii::compare_and_apply_mask<dealii::SIMDComparison::less_than>(
113 hs,
114 1.0,
115 dealii::compare_and_apply_mask<dealii::SIMDComparison::greater_than>(hs, 0, 1.0, 0.0),
116 0);
117
118 return 2. * viscosity *
119 (0.5 * (grad_u + transpose(grad_u)) - mask * div_u * outer_product(normal, normal));
120 }
121
142 dealii::Tensor<2, dim, dealii::VectorizedArray<number>>
144 {
145 // Since the velocity DoFs occur linear in the expression for tau, the vmult of the derivative
146 // is the same operation, except with a different meaning of grad_u, i.e. shape functions
147 // gradient times correction values for the velocity DoFs from the linear solver.
148 return get_tau();
149
150 // @note alternative, in case we want to convert this function to a real material tangent and
151 // leave the multiplication with the velocity gradient to the external code.
152 //
153 // const auto identity = Tensor<4,dim,VectorizedArray<number>>(identity_tensor<dim,
154 // VectorizedArray<number>>()); const auto identity2 =
155 // Tensor<2,dim,VectorizedArray<number>>(unit_symmetric_tensor<dim,
156 // VectorizedArray<number>>());
157
158 // const auto temp = 2. * viscosity * (identity - outer_product(identity2,
159 // outer_product(normal, normal))); return double_contract<0,0,1,1>(temp, grad_u);
160 }
161
165 void
167 {
168 normal_update_ghosts = !normal_vector.has_ghost_elements();
170 normal_vector.update_ghost_values();
171
172 ls_update_ghosts = !heaviside.has_ghost_elements();
174 heaviside.update_ghost_values();
175 }
176
180 void
182 {
184 normal_vector.zero_out_ghost_values();
185
187 heaviside.zero_out_ghost_values();
188 }
189
190 private:
192 const std::function<const dealii::VectorizedArray<number> &(const unsigned int cell,
193 const unsigned int q)>
196 const dealii::LinearAlgebra::distributed::Vector<number> &heaviside;
197 const unsigned int normal_dof_idx;
198 const unsigned int ls_hanging_nodes_dof_idx;
199 const unsigned int velocity_quad_idx;
202
203 // temporary quadrature point values
204 dealii::Tensor<2, dim, dealii::VectorizedArray<number>> grad_u;
205 dealii::VectorizedArray<number> div_u;
206 dealii::VectorizedArray<number> viscosity;
207 dealii::Tensor<1, dim, dealii::VectorizedArray<number>> normal;
208 dealii::VectorizedArray<number> hs;
209 unsigned int cell;
210
211 mutable bool ls_update_ghosts = true;
212 mutable bool normal_update_ghosts = true;
213 };
214} // namespace MeltPoolDG::Evaporation
Definition incompressible_newtonian_evaporation_material.hpp:40
unsigned int cell
Definition incompressible_newtonian_evaporation_material.hpp:209
const std::function< const dealii::VectorizedArray< number > &(const unsigned int cell, const unsigned int q)> get_viscosity
Definition incompressible_newtonian_evaporation_material.hpp:194
dealii::LinearAlgebra::distributed::BlockVector< number > BlockVectorType
Definition incompressible_newtonian_evaporation_material.hpp:42
dealii::Tensor< 2, dim, dealii::VectorizedArray< number > > get_tau() final
Definition incompressible_newtonian_evaporation_material.hpp:110
bool normal_update_ghosts
Definition incompressible_newtonian_evaporation_material.hpp:212
FECellIntegrator< dim, dim, number > normal_vals
Definition incompressible_newtonian_evaporation_material.hpp:200
dealii::VectorizedArray< number > viscosity
Definition incompressible_newtonian_evaporation_material.hpp:206
void zero_out_ghost_values() final
Definition incompressible_newtonian_evaporation_material.hpp:181
const unsigned int velocity_quad_idx
Definition incompressible_newtonian_evaporation_material.hpp:199
dealii::Tensor< 2, dim, dealii::VectorizedArray< number > > get_vmult_d_tau_d_grad_vel() final
Definition incompressible_newtonian_evaporation_material.hpp:143
const unsigned int ls_hanging_nodes_dof_idx
Definition incompressible_newtonian_evaporation_material.hpp:198
const ScratchData< dim, dim, number > & scratch_data
Definition incompressible_newtonian_evaporation_material.hpp:191
const dealii::LinearAlgebra::distributed::Vector< number > & heaviside
Definition incompressible_newtonian_evaporation_material.hpp:196
IncompressibleNewtonianFluidEvaporationMaterial(const ScratchData< dim, dim, number > &scratch_data, const std::function< const dealii::VectorizedArray< number > &(const unsigned int cell, const unsigned int q)> get_viscosity, const BlockVectorType &normal_vector, const dealii::LinearAlgebra::distributed::Vector< number > &heaviside, const unsigned int normal_dof_idx, const unsigned int ls_hanging_nodes_dof_idx, const unsigned int velocity_quad_idx)
Definition incompressible_newtonian_evaporation_material.hpp:45
void update_ghost_values() final
Definition incompressible_newtonian_evaporation_material.hpp:166
FECellIntegrator< dim, 1, number > ls_vals
Definition incompressible_newtonian_evaporation_material.hpp:201
bool ls_update_ghosts
Definition incompressible_newtonian_evaporation_material.hpp:211
dealii::Tensor< 2, dim, dealii::VectorizedArray< number > > grad_u
Definition incompressible_newtonian_evaporation_material.hpp:204
void reinit(const dealii::Tensor< 2, dim, dealii::VectorizedArray< number > > &velocity_gradient, const unsigned int cell_idx, const unsigned int quad_idx) final
Definition incompressible_newtonian_evaporation_material.hpp:71
const unsigned int normal_dof_idx
Definition incompressible_newtonian_evaporation_material.hpp:197
const BlockVectorType & normal_vector
Definition incompressible_newtonian_evaporation_material.hpp:195
dealii::VectorizedArray< number > hs
Definition incompressible_newtonian_evaporation_material.hpp:208
dealii::Tensor< 1, dim, dealii::VectorizedArray< number > > normal
Definition incompressible_newtonian_evaporation_material.hpp:207
dealii::VectorizedArray< number > div_u
Definition incompressible_newtonian_evaporation_material.hpp:205
Base class for the shear stress computation of an incompressible fluid material.
Definition incompressible_flow_material_base.hpp:24
Container for shared scratch data between operations/operators.
Definition scratch_data.hpp:61
Definition evaporation_data.hpp:15
dealii::Tensor< 1, T2_dim, dealii::Tensor< 1, T1_dim, number > > transpose(const dealii::Tensor< 1, T1_dim, dealii::Tensor< 1, T2_dim, number > > &in)
Definition dealii_tensor.hpp:232
dealii::FEEvaluation< dim, -1, 0, n_components, number, VectorizedArrayType > FECellIntegrator
Definition fe_integrator.hpp:14