Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
vans_assemblers.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#include <core/bdf.h>
6#include <core/utilities.h>
7
9
11
12#include <deal.II/base/tensor.h>
13
14#include <type_traits>
15
16namespace
17{
18 // Normalize the deal.II curl result to the scalar out-of-plane vorticity
19 // needed by the 2D VANS lift model. This accepts both currently-supported
20 // deal.II representations: a scalar curl and Tensor<1,1>.
21 template <typename CurlType>
22 double
23 extract_out_of_plane_vorticity(const CurlType &curl)
24 {
25 if constexpr (std::is_arithmetic_v<std::decay_t<CurlType>>)
26 return curl;
27 else
28 return curl[0];
29 }
30} // namespace
31
32template <int dim>
33void
35 const NavierStokesScratchData<dim> &scratch_data,
37{
38 // Kinematic viscosity at Gauss points
39 const std::vector<double> &viscosity_vector =
40 scratch_data.kinematic_viscosity;
41
42 // Loop and quadrature informations
43 const auto &JxW_vec = scratch_data.JxW;
44 const unsigned int n_q_points = scratch_data.n_q_points;
45 const unsigned int n_dofs = scratch_data.n_dofs;
46 const double h = scratch_data.cell_size;
47
48 // Copy data elements
49 auto &strong_residual_vec = copy_data.strong_residual;
50 auto &strong_jacobian_vec = copy_data.strong_jacobian;
51 auto &local_matrix = copy_data.local_matrix;
52
53 // Time steps and inverse time steps which is used for stabilization constant
54 std::vector<double> time_steps_vector =
55 this->simulation_control->get_time_steps_vector();
56 const double dt = time_steps_vector[0];
57 const double sdt = 1. / dt;
58
59 // Loop over the quadrature points
60 for (unsigned int q = 0; q < n_q_points; ++q)
61 {
62 // Gather into local variables the relevant fields
63 const double kinematic_viscosity = viscosity_vector[q];
64 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
65 const Tensor<1, dim> previous_velocity =
66 scratch_data.previous_velocity_values[0][q];
67 const Tensor<2, dim> velocity_gradient =
68 scratch_data.velocity_gradients[q];
69 const Tensor<1, dim> velocity_laplacian =
70 scratch_data.velocity_laplacians[q];
71
72 const Tensor<1, dim> pressure_gradient =
73 scratch_data.pressure_gradients[q];
74
75 const double void_fraction = scratch_data.void_fraction_values[q];
76 const Tensor<1, dim> void_fraction_gradients =
77 scratch_data.void_fraction_gradient_values[q];
78
79 // Forcing term
80 const Tensor<1, dim> force = scratch_data.force[q];
81 double mass_source = scratch_data.mass_source[q];
82
83 double u_mag = 0;
84 // Calculation of the magnitude of the velocity for the
85 // stabilization parameter
86 if (cfd_dem.implicit_stabilization)
87 u_mag = std::max(velocity.norm(), 1e-12);
88 else
89 {
90 if (this->simulation_control->get_current_time() ==
91 this->simulation_control->get_time_step())
92 u_mag = std::max(velocity.norm(), 1e-12);
93 else
94 u_mag = std::max(previous_velocity.norm(), 1e-12);
95 }
96
97 // Grad-div weight factor
98 const double gamma =
99 calculate_gamma(u_mag, kinematic_viscosity, h, cfd_dem.cstar);
100
101 // Store JxW in local variable for faster access;
102 const double JxW = JxW_vec[q];
103
104 // Calculation of the GLS stabilization parameter. The
105 // stabilization parameter used is different if the simulation
106 // is steady or unsteady. In the unsteady case it includes the
107 // value of the time step
108 const double tau =
109 this->simulation_control->get_assembly_method() ==
112 kinematic_viscosity,
113 h) :
115 kinematic_viscosity,
116 h,
117 sdt);
118
119 // Calculate the strong residual for GLS stabilization
120 auto strong_residual = velocity_gradient * velocity * void_fraction +
121 // Mass Source
122 mass_source * velocity
123 // Pressure
124 + pressure_gradient -
125 // Kinematic viscosity and Force
126 kinematic_viscosity * velocity_laplacian -
127 force * void_fraction + strong_residual_vec[q];
128
129 // Pressure scaling factor
130 const double pressure_scaling_factor =
131 scratch_data.pressure_scaling_factor;
132
133 // We loop over the column first to prevent recalculation
134 // of the strong jacobian in the inner loop
135 for (unsigned int j = 0; j < n_dofs; ++j)
136 {
137 const auto &phi_u_j = scratch_data.phi_u[q][j];
138 const auto &grad_phi_u_j = scratch_data.grad_phi_u[q][j];
139 const auto &laplacian_phi_u_j = scratch_data.laplacian_phi_u[q][j];
140
141 const auto &grad_phi_p_j =
142 pressure_scaling_factor * scratch_data.grad_phi_p[q][j];
143
144 strong_jacobian_vec[q][j] +=
145 (velocity_gradient * phi_u_j * void_fraction +
146 grad_phi_u_j * velocity * void_fraction +
147 // Mass Source
148 mass_source * phi_u_j +
149 // Pressure
150 grad_phi_p_j
151 // Kinematic viscosity
152 - kinematic_viscosity * laplacian_phi_u_j);
153 }
154
155 for (unsigned int i = 0; i < n_dofs; ++i)
156 {
157 const int component_i = scratch_data.components[i];
158 const auto &phi_u_i = scratch_data.phi_u[q][i];
159 const auto &grad_phi_u_i = scratch_data.grad_phi_u[q][i];
160 const auto &div_phi_u_i = scratch_data.div_phi_u[q][i];
161 const auto &phi_p_i = scratch_data.phi_p[q][i];
162 const auto &grad_phi_p_i = scratch_data.grad_phi_p[q][i];
163
164 for (unsigned int j = 0; j < n_dofs; ++j)
165 {
166 const int component_j = scratch_data.components[j];
167 const auto &phi_u_j = scratch_data.phi_u[q][j];
168 const auto &grad_phi_u_j = scratch_data.grad_phi_u[q][j];
169 const auto &div_phi_u_j = scratch_data.div_phi_u[q][j];
170
171 const auto &phi_p_j =
172 pressure_scaling_factor * scratch_data.phi_p[q][j];
173
174 const auto &strong_jac = strong_jacobian_vec[q][j];
175
176 // Pressure
177 double local_matrix_ij =
178 component_j == dim ? -div_phi_u_i * phi_p_j : 0;
179
180 if (component_i == dim)
181 {
182 // Continuity
183 local_matrix_ij +=
184 phi_p_i * ((void_fraction * div_phi_u_j) +
185 (phi_u_j * void_fraction_gradients));
186
187 // PSPG GLS term
188 local_matrix_ij += tau * (strong_jac * grad_phi_p_i);
189 }
190
191 if (component_i < dim && component_j < dim)
192 {
193 // Convection
194 local_matrix_ij +=
195 ((velocity_gradient * phi_u_j * void_fraction * phi_u_i) +
196 (grad_phi_u_j * void_fraction * velocity * phi_u_i));
197
198 if (component_i == component_j)
199 {
200 local_matrix_ij +=
201 // Deviatoric stress tensor
202 kinematic_viscosity * (grad_phi_u_j[component_j] *
203 grad_phi_u_i[component_i])
204 // Mass source
205 + mass_source * phi_u_j * phi_u_i;
206 }
207 }
208
209 // The jacobian matrix for the SUPG formulation
210 // currently does not include the jacobian of the stabilization
211 // parameter tau. Our experience has shown that does not alter the
212 // number of newton iteration for convergence, but greatly
213 // simplifies assembly.
214 if (SUPG && component_i < dim)
215 {
216 local_matrix_ij +=
217 tau * (strong_jac * grad_phi_u_i * velocity +
218 strong_residual * grad_phi_u_i * phi_u_j);
219 }
220
221 // Grad-div stabilization
222 if (cfd_dem.grad_div == true)
223 {
224 local_matrix_ij += gamma *
225 (div_phi_u_j * void_fraction +
226 phi_u_j * void_fraction_gradients) *
227 div_phi_u_i;
228 }
229
230 local_matrix_ij *= JxW;
231 local_matrix(i, j) += local_matrix_ij;
232 }
233 }
234 }
235}
236
237template <int dim>
238void
240 const NavierStokesScratchData<dim> &scratch_data,
242{
243 // Scheme and physical properties
244 const std::vector<double> &viscosity_vector =
245 scratch_data.kinematic_viscosity;
246
247 // Loop and quadrature informations
248 const auto &JxW_vec = scratch_data.JxW;
249 const unsigned int n_q_points = scratch_data.n_q_points;
250 const unsigned int n_dofs = scratch_data.n_dofs;
251 const double h = scratch_data.cell_size;
252
253 // Copy data elements
254 auto &strong_residual_vec = copy_data.strong_residual;
255 auto &local_rhs = copy_data.local_rhs;
256
257 // Time steps and inverse time steps which is used for stabilization constant
258 std::vector<double> time_steps_vector =
259 this->simulation_control->get_time_steps_vector();
260 const double dt = time_steps_vector[0];
261 const double sdt = 1. / dt;
262
263 // Loop over the quadrature points
264 for (unsigned int q = 0; q < n_q_points; ++q)
265 {
266 // Physical property
267 const double kinematic_viscosity = viscosity_vector[q];
268
269 // Velocity
270 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
271 const Tensor<1, dim> previous_velocity =
272 scratch_data.previous_velocity_values[0][q];
273 const double velocity_divergence = scratch_data.velocity_divergences[q];
274 const Tensor<2, dim> velocity_gradient =
275 scratch_data.velocity_gradients[q];
276 const Tensor<1, dim> velocity_laplacian =
277 scratch_data.velocity_laplacians[q];
278
279 // Pressure
280 const double pressure = scratch_data.pressure_values[q];
281 const Tensor<1, dim> pressure_gradient =
282 scratch_data.pressure_gradients[q];
283
284 // Void Fraction
285 const double void_fraction = scratch_data.void_fraction_values[q];
286 const Tensor<1, dim> void_fraction_gradients =
287 scratch_data.void_fraction_gradient_values[q];
288
289 // Forcing term
290 const Tensor<1, dim> force = scratch_data.force[q];
291 double mass_source = scratch_data.mass_source[q];
292
293 double u_mag = 0;
294 // Calculation of the magnitude of the
295 // velocity for the stabilization parameter
296 if (cfd_dem.implicit_stabilization)
297 u_mag = std::max(velocity.norm(), 1e-12);
298 else
299 {
300 if (this->simulation_control->get_current_time() ==
301 this->simulation_control->get_time_step())
302 u_mag = std::max(velocity.norm(), 1e-12);
303 else
304 u_mag = std::max(previous_velocity.norm(), 1e-12);
305 }
306
307 // Grad-div weight factor
308 const double gamma =
309 calculate_gamma(u_mag, kinematic_viscosity, h, cfd_dem.cstar);
310
311 // Store JxW in local variable for faster access;
312 const double JxW = JxW_vec[q];
313
314 // Calculation of the GLS stabilization parameter. The
315 // stabilization parameter used is different if the simulation
316 // is steady or unsteady. In the unsteady case it includes the
317 // value of the time step
318 const double tau =
319 this->simulation_control->get_assembly_method() ==
322 kinematic_viscosity,
323 h) :
325 kinematic_viscosity,
326 h,
327 sdt);
328
329 // Calculate the strong residual for GLS stabilization
330 auto strong_residual = velocity_gradient * velocity * void_fraction +
331 // Mass Source
332 mass_source * velocity
333 // Pressure
334 + pressure_gradient -
335 // Kinematic viscosity and Force
336 kinematic_viscosity * velocity_laplacian -
337 force * void_fraction + strong_residual_vec[q];
338
339 // Assembly of the right-hand side
340 for (unsigned int i = 0; i < n_dofs; ++i)
341 {
342 const int component_i = scratch_data.components[i];
343 const auto phi_u_i = scratch_data.phi_u[q][i];
344 const auto grad_phi_u_i = scratch_data.grad_phi_u[q][i];
345 const auto phi_p_i = scratch_data.phi_p[q][i];
346 const auto grad_phi_p_i = scratch_data.grad_phi_p[q][i];
347 const auto div_phi_u_i = scratch_data.div_phi_u[q][i];
348
349 double local_rhs_i = 0;
350
351 // Navier-Stokes Residual
352 if (component_i < dim)
353 local_rhs_i +=
354 // Momentum
355 -kinematic_viscosity *
356 scalar_product(velocity_gradient, grad_phi_u_i) -
357 velocity_gradient * velocity * void_fraction * phi_u_i
358 // Mass Source
359 - mass_source * velocity * phi_u_i
360 // Pressure and Force
361 + pressure * div_phi_u_i + force * void_fraction * phi_u_i;
362
363 if (component_i == dim)
364 // Continuity
365 local_rhs_i += -(velocity_divergence * void_fraction +
366 velocity * void_fraction_gradients - mass_source) *
367 phi_p_i;
368
369 // PSPG GLS term
370 local_rhs_i += -tau * (strong_residual * grad_phi_p_i);
371
372 // SUPG GLS term
373 if (SUPG && component_i < dim)
374 {
375 local_rhs_i +=
376 -tau * (strong_residual * (grad_phi_u_i * velocity));
377 }
378
379 // Grad-div stabilization
380 if (cfd_dem.grad_div == true)
381 {
382 local_rhs_i -= gamma *
383 (void_fraction * velocity_divergence +
384 velocity * void_fraction_gradients) *
385 div_phi_u_i;
386 }
387
388 local_rhs(i) += local_rhs_i * JxW;
389 }
390 }
391}
392
393template class VANSAssemblerCoreModelB<2>;
394template class VANSAssemblerCoreModelB<3>;
395
396template <int dim>
397void
399 const NavierStokesScratchData<dim> &scratch_data,
401{
402 // Scheme and physical properties
403 const std::vector<double> &viscosity_vector =
404 scratch_data.kinematic_viscosity;
405
406 // Loop and quadrature informations
407 const auto &JxW_vec = scratch_data.JxW;
408 const unsigned int n_q_points = scratch_data.n_q_points;
409 const unsigned int n_dofs = scratch_data.n_dofs;
410 const double h = scratch_data.cell_size;
411
412 // Copy data elements
413 auto &strong_residual_vec = copy_data.strong_residual;
414 auto &strong_jacobian_vec = copy_data.strong_jacobian;
415 auto &local_matrix = copy_data.local_matrix;
416
417 // Time steps and inverse time steps which is used for stabilization constant
418 std::vector<double> time_steps_vector =
419 this->simulation_control->get_time_steps_vector();
420 const double dt = time_steps_vector[0];
421 const double sdt = 1. / dt;
422
423 // Grad-div weight factor
424
425 // Loop over the quadrature points
426 for (unsigned int q = 0; q < n_q_points; ++q)
427 {
428 // Physical properties
429 const double kinematic_viscosity = viscosity_vector[q];
430
431 // Gather into local variables the relevant fields
432 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
433 const Tensor<1, dim> previous_velocity =
434 scratch_data.previous_velocity_values[0][q];
435 const Tensor<2, dim> velocity_gradient =
436 scratch_data.velocity_gradients[q];
437 const Tensor<1, dim> velocity_laplacian =
438 scratch_data.velocity_laplacians[q];
439 const Tensor<1, dim> velocity_gradient_divergence =
440 scratch_data.velocity_gradient_divergence[q];
441
442 const Tensor<1, dim> pressure_gradient =
443 scratch_data.pressure_gradients[q];
444
445 const double void_fraction = scratch_data.void_fraction_values[q];
446 const Tensor<1, dim> void_fraction_gradients =
447 scratch_data.void_fraction_gradient_values[q];
448
449 // Forcing term
450 const Tensor<1, dim> force = scratch_data.force[q];
451 double mass_source = scratch_data.mass_source[q];
452
453 double u_mag = 0;
454 // Calculation of the magnitude of the velocity for the
455 // stabilization parameter
456 if (cfd_dem.implicit_stabilization)
457 u_mag = std::max(velocity.norm(), 1e-12);
458 else
459 {
460 if (this->simulation_control->get_current_time() ==
461 this->simulation_control->get_time_step())
462 u_mag = std::max(velocity.norm(), 1e-12);
463 else
464 u_mag = std::max(previous_velocity.norm(), 1e-12);
465 }
466
467 // Grad-div weight factor
468 const double gamma =
469 calculate_gamma(u_mag, kinematic_viscosity, h, cfd_dem.cstar);
470
471 // Store JxW in local variable for faster access;
472 const double JxW = JxW_vec[q];
473
474 // Calculation of the GLS stabilization parameter. The
475 // stabilization parameter used is different if the simulation
476 // is steady or unsteady. In the unsteady case it includes the
477 // value of the time step
478 const double tau =
479 this->simulation_control->get_assembly_method() ==
482 kinematic_viscosity,
483 h) :
485 kinematic_viscosity,
486 h,
487 sdt);
488
489 // Calculate the strong residual for GLS stabilization
490 auto strong_residual =
491 // Term εfuj∂jui
492 velocity_gradient * velocity * void_fraction
493 // Mass Source: mass_source*ui
494 + mass_source * velocity
495 // Pressure: εf∂ip
496 + void_fraction * pressure_gradient
497 // Kinematic viscosity laplacian term: -νfεf∂j∂jui
498 - void_fraction * kinematic_viscosity * velocity_laplacian
499 // Term -νfεf∂j∂iuj = -νfεf∂i∂juj
500 - void_fraction * kinematic_viscosity * velocity_gradient_divergence
501 // Force: -fi*εf
502 - force * void_fraction + strong_residual_vec[q];
503
504 // Pressure scaling factor
505 const double pressure_scaling_factor =
506 scratch_data.pressure_scaling_factor;
507
508 // We loop over the column first to prevent recalculation
509 // of the strong jacobian in the inner loop
510 for (unsigned int j = 0; j < n_dofs; ++j)
511 {
512 const auto &phi_u_j = scratch_data.phi_u[q][j];
513 const auto &grad_phi_u_j = scratch_data.grad_phi_u[q][j];
514 const auto &laplacian_phi_u_j = scratch_data.laplacian_phi_u[q][j];
515 const auto &gradient_divergence_phi_u_j =
516 scratch_data.gradient_divergence_phi_u[q][j];
517
518 const auto &grad_phi_p_j =
519 pressure_scaling_factor * scratch_data.grad_phi_p[q][j];
520
521 strong_jacobian_vec[q][j] +=
522 (velocity_gradient * phi_u_j * void_fraction +
523 grad_phi_u_j * velocity * void_fraction
524 // Mass Source
525 + mass_source * phi_u_j
526 // Pressure
527 + void_fraction * grad_phi_p_j
528 // Kinematic viscosity
529 - void_fraction * kinematic_viscosity * laplacian_phi_u_j -
530 void_fraction * kinematic_viscosity * gradient_divergence_phi_u_j);
531 }
532
533 for (unsigned int i = 0; i < n_dofs; ++i)
534 {
535 const int component_i = scratch_data.components[i];
536 const auto &phi_u_i = scratch_data.phi_u[q][i];
537 const auto &grad_phi_u_i = scratch_data.grad_phi_u[q][i];
538 const auto &div_phi_u_i = scratch_data.div_phi_u[q][i];
539 const auto &phi_p_i = scratch_data.phi_p[q][i];
540 const auto &grad_phi_p_i = scratch_data.grad_phi_p[q][i];
541
542 for (unsigned int j = 0; j < n_dofs; ++j)
543 {
544 const int component_j = scratch_data.components[j];
545 const auto &phi_u_j = scratch_data.phi_u[q][j];
546 const auto &grad_phi_u_j = scratch_data.grad_phi_u[q][j];
547 const auto &div_phi_u_j = scratch_data.div_phi_u[q][j];
548 const auto &phi_p_j =
549 pressure_scaling_factor * scratch_data.phi_p[q][j];
550
551 const auto &strong_jac = strong_jacobian_vec[q][j];
552
553 // Pressure
554 double local_matrix_ij =
555 -(div_phi_u_i * phi_p_j * void_fraction +
556 phi_p_j * void_fraction_gradients * phi_u_i);
557
558 if (component_i == dim)
559 {
560 local_matrix_ij +=
561 phi_p_i * ((void_fraction * div_phi_u_j) +
562 (phi_u_j * void_fraction_gradients));
563
564 // PSPG GLS term
565 local_matrix_ij += tau * (strong_jac * grad_phi_p_i);
566 }
567
568 if (component_i < dim && component_j < dim)
569 {
570 // Convection
571 local_matrix_ij +=
572 ((velocity_gradient * phi_u_j * void_fraction * phi_u_i) +
573 (grad_phi_u_j * void_fraction * velocity * phi_u_i));
574
575 if (component_i == component_j)
576 {
577 local_matrix_ij += void_fraction * kinematic_viscosity *
578 (grad_phi_u_j[component_j] *
579 grad_phi_u_i[component_i]) +
580 kinematic_viscosity * grad_phi_u_j *
581 void_fraction_gradients * phi_u_i +
582 mass_source * phi_u_j * phi_u_i;
583 }
584 // Compute term ν_fε_f ∂_j(ϕ_i) ∂_i(δu_j) +
585 // ν_f ϕ_i ∂_i(δu_j) ∂_j(ε_f) (i and j are vector components)
586 // Using the tensor product
587 // local_matrix_ij += void_fraction * kinematic_viscosity *
588 // scalar_product(transpose(grad_phi_u_j),
589 // grad_phi_u_i)
590 // +
591 // kinematic_viscosity *
592 // void_fraction_gradients *
593 // grad_phi_u_j * phi_u_i;
594 // Using component_i and component_j if the improvement in
595 // performance is worth it
596 local_matrix_ij += void_fraction * kinematic_viscosity *
597 grad_phi_u_i[component_i][component_j] *
598 grad_phi_u_j[component_j][component_i] +
599 kinematic_viscosity *
600 grad_phi_u_j[component_j][component_i] *
601 void_fraction_gradients[component_j] *
602 phi_u_i[component_i];
603 }
604
605 // The jacobian matrix for the SUPG formulation
606 // currently does not include the jacobian of the stabilization
607 // parameter tau. Our experience has shown that does not alter the
608 // number of newton iteration for convergence, but greatly
609 // simplifies assembly.
610 if (SUPG && component_i < dim)
611 {
612 local_matrix_ij +=
613 tau * (strong_jac * grad_phi_u_i * velocity +
614 strong_residual * grad_phi_u_i * phi_u_j);
615 }
616
617 // Grad-div stabilization
618 if (cfd_dem.grad_div == true)
619 {
620 local_matrix_ij += gamma *
621 (div_phi_u_j * void_fraction +
622 phi_u_j * void_fraction_gradients) *
623 div_phi_u_i;
624 }
625
626 local_matrix_ij *= JxW;
627 local_matrix(i, j) += local_matrix_ij;
628 }
629 }
630 }
631}
632
633template <int dim>
634void
636 const NavierStokesScratchData<dim> &scratch_data,
638{
639 // Scheme and physical properties
640 const std::vector<double> &viscosity_vector =
641 scratch_data.kinematic_viscosity;
642
643 // Loop and quadrature informations
644 const auto &JxW_vec = scratch_data.JxW;
645 const unsigned int n_q_points = scratch_data.n_q_points;
646 const unsigned int n_dofs = scratch_data.n_dofs;
647 const double h = scratch_data.cell_size;
648
649 // Copy data elements
650 auto &strong_residual_vec = copy_data.strong_residual;
651 auto &local_rhs = copy_data.local_rhs;
652
653 // Time steps and inverse time steps which is used for stabilization constant
654 std::vector<double> time_steps_vector =
655 this->simulation_control->get_time_steps_vector();
656 const double dt = time_steps_vector[0];
657 const double sdt = 1. / dt;
658
659 // Loop over the quadrature points
660 for (unsigned int q = 0; q < n_q_points; ++q)
661 {
662 // Physical properties
663 const double kinematic_viscosity = viscosity_vector[q];
664
665 // Velocity
666 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
667 const Tensor<1, dim> previous_velocity =
668 scratch_data.previous_velocity_values[0][q];
669 const double velocity_divergence = scratch_data.velocity_divergences[q];
670 const Tensor<2, dim> velocity_gradient =
671 scratch_data.velocity_gradients[q];
672 const Tensor<1, dim> velocity_laplacian =
673 scratch_data.velocity_laplacians[q];
674 const Tensor<1, dim> velocity_gradient_divergence =
675 scratch_data.velocity_gradient_divergence[q];
676
677 // Pressure
678 const double pressure = scratch_data.pressure_values[q];
679 const Tensor<1, dim> pressure_gradient =
680 scratch_data.pressure_gradients[q];
681
682 // Void Fraction
683 const double void_fraction = scratch_data.void_fraction_values[q];
684 const Tensor<1, dim> void_fraction_gradients =
685 scratch_data.void_fraction_gradient_values[q];
686
687 // Forcing term
688 const Tensor<1, dim> force = scratch_data.force[q];
689 double mass_source = scratch_data.mass_source[q];
690
691 double u_mag = 0;
692 // Calculation of the magnitude of the
693 // velocity for the stabilization parameter
694 if (cfd_dem.implicit_stabilization)
695 u_mag = std::max(velocity.norm(), 1e-12);
696 else
697 {
698 if (this->simulation_control->get_current_time() ==
699 this->simulation_control->get_time_step())
700 u_mag = std::max(velocity.norm(), 1e-12);
701 else
702 u_mag = std::max(previous_velocity.norm(), 1e-12);
703 }
704
705 // Grad-div weight factor
706 const double gamma =
707 calculate_gamma(u_mag, kinematic_viscosity, h, cfd_dem.cstar);
708
709 // Store JxW in local variable for faster access;
710 const double JxW = JxW_vec[q];
711
712 // Calculation of the GLS stabilization parameter. The
713 // stabilization parameter used is different if the simulation
714 // is steady or unsteady. In the unsteady case it includes the
715 // value of the time step
716 const double tau =
717 this->simulation_control->get_assembly_method() ==
720 kinematic_viscosity,
721 h) :
723 kinematic_viscosity,
724 h,
725 sdt);
726
727 // Calculate the strong residual for GLS stabilization
728 auto strong_residual =
729 // Term εfuj∂jui
730 velocity_gradient * velocity * void_fraction
731 // Mass Source: mass_source*ui
732 + mass_source * velocity
733 // Pressure: εf∂ip
734 + void_fraction * pressure_gradient
735 // Kinematic viscosity laplacian term: -νfεf∂j∂jui
736 - void_fraction * kinematic_viscosity * velocity_laplacian
737 // Term -νfεf∂j∂iuj = -νfεf∂i∂juj
738 - void_fraction * kinematic_viscosity * velocity_gradient_divergence
739 // Force: -fi*εf
740 - force * void_fraction + strong_residual_vec[q];
741
742 // Assembly of the right-hand side
743 for (unsigned int i = 0; i < n_dofs; ++i)
744 {
745 const int component_i = scratch_data.components[i];
746
747 const auto phi_u_i = scratch_data.phi_u[q][i];
748 const auto grad_phi_u_i = scratch_data.grad_phi_u[q][i];
749 const auto phi_p_i = scratch_data.phi_p[q][i];
750 const auto grad_phi_p_i = scratch_data.grad_phi_p[q][i];
751 const auto div_phi_u_i = scratch_data.div_phi_u[q][i];
752
753 // Navier-Stokes Residual
754 double local_rhs_i = 0;
755
756 if (component_i < dim)
757 local_rhs_i += (
758 // Momentum
759 -(void_fraction * kinematic_viscosity *
760 scalar_product(velocity_gradient, grad_phi_u_i) +
761 kinematic_viscosity * velocity_gradient *
762 void_fraction_gradients * phi_u_i) -
763 (void_fraction * kinematic_viscosity * div_phi_u_i *
764 velocity_divergence +
765 kinematic_viscosity * velocity_divergence *
766 void_fraction_gradients * phi_u_i) -
767 velocity_gradient * velocity * void_fraction * phi_u_i
768 // Mass Source
769 - mass_source * velocity * phi_u_i
770 // Pressure and Force
771 + (void_fraction * pressure * div_phi_u_i +
772 pressure * void_fraction_gradients * phi_u_i) +
773 force * void_fraction * phi_u_i);
774
775 if (component_i == dim)
776 // Continuity
777 local_rhs_i -= (velocity_divergence * void_fraction +
778 velocity * void_fraction_gradients - mass_source) *
779 phi_p_i;
780
781 // PSPG GLS term
782 local_rhs_i += -tau * (strong_residual * grad_phi_p_i);
783
784 // SUPG GLS term
785 if (SUPG)
786 {
787 local_rhs_i +=
788 -tau * (strong_residual * (grad_phi_u_i * velocity));
789 }
790
791 // Grad-div stabilization
792 if (cfd_dem.grad_div == true)
793 {
794 local_rhs_i -= gamma *
795 (void_fraction * velocity_divergence +
796 velocity * void_fraction_gradients) *
797 div_phi_u_i;
798 }
799
800 local_rhs_i *= JxW;
801 local_rhs(i) += local_rhs_i;
802 }
803 }
804}
805
806template class VANSAssemblerCoreModelA<2>;
807template class VANSAssemblerCoreModelA<3>;
808
809template <int dim>
810void
812 const NavierStokesScratchData<dim> &scratch_data,
814{
815 // Loop and quadrature informations
816 const auto &JxW = scratch_data.JxW;
817 const unsigned int n_q_points = scratch_data.n_q_points;
818 const unsigned int n_dofs = scratch_data.n_dofs;
819
820 // Copy data elements
821 auto &strong_residual = copy_data.strong_residual;
822 auto &strong_jacobian = copy_data.strong_jacobian;
823 auto &local_matrix = copy_data.local_matrix;
824
825 // Time stepping information
826 const auto method = this->simulation_control->get_assembly_method();
827 // Vector for the BDF coefficients
828 const Vector<double> &bdf_coefs =
829 this->simulation_control->get_bdf_coefficients();
830 std::vector<Tensor<1, dim>> velocity(1 +
832
833 // Loop over the quadrature points
834 for (unsigned int q = 0; q < n_q_points; ++q)
835 {
836 velocity[0] = scratch_data.velocity_values[q];
837 for (unsigned int p = 0; p < number_of_previous_solutions(method); ++p)
838 velocity[p + 1] = scratch_data.previous_velocity_values[p][q];
839
840 double void_fraction = scratch_data.void_fraction_values[q];
841
842 for (unsigned int p = 0; p < number_of_previous_solutions(method) + 1;
843 ++p)
844 {
845 strong_residual[q] += bdf_coefs[p] * velocity[p] * void_fraction;
846 }
847
848 for (unsigned int j = 0; j < n_dofs; ++j)
849 {
850 strong_jacobian[q][j] +=
851 void_fraction * bdf_coefs[0] * scratch_data.phi_u[q][j];
852 }
853
854 for (unsigned int i = 0; i < n_dofs; ++i)
855 {
856 const Tensor<1, dim> &phi_u_i = scratch_data.phi_u[q][i];
857 for (unsigned int j = 0; j < n_dofs; ++j)
858 {
859 const Tensor<1, dim> &phi_u_j = scratch_data.phi_u[q][j];
860
861 local_matrix(i, j) +=
862 void_fraction * phi_u_j * phi_u_i * bdf_coefs[0] * JxW[q];
863 }
864 }
865 }
866}
867
868template <int dim>
869void
871 const NavierStokesScratchData<dim> &scratch_data,
873{
874 // Physical properties
875 const std::vector<double> &kinematic_viscosity =
876 scratch_data.kinematic_viscosity;
877
878 // Loop and quadrature informations
879 const double h = scratch_data.cell_size;
880 const auto &JxW = scratch_data.JxW;
881 const unsigned int n_q_points = scratch_data.n_q_points;
882 const unsigned int n_dofs = scratch_data.n_dofs;
883
884 // Copy data elements
885 auto &strong_residual = copy_data.strong_residual;
886 auto &local_rhs = copy_data.local_rhs;
887
888 // Time stepping information
889 const auto method = this->simulation_control->get_assembly_method();
890 // Vector for the BDF coefficients
891 const Vector<double> &bdf_coefs =
892 this->simulation_control->get_bdf_coefficients();
893 std::vector<Tensor<1, dim>> velocity(1 +
895 std::vector<double> void_fraction(1 + number_of_previous_solutions(method));
896
897 // Loop over the quadrature points
898 for (unsigned int q = 0; q < n_q_points; ++q)
899 {
900 velocity[0] = scratch_data.velocity_values[q];
901 for (unsigned int p = 0; p < number_of_previous_solutions(method); ++p)
902 velocity[p + 1] = scratch_data.previous_velocity_values[p][q];
903
904 void_fraction[0] = scratch_data.void_fraction_values[q];
905 for (unsigned int p = 0; p < number_of_previous_solutions(method); ++p)
906 void_fraction[p + 1] = scratch_data.previous_void_fraction_values[p][q];
907
908 for (unsigned int p = 0; p < number_of_previous_solutions(method) + 1;
909 ++p)
910 {
911 strong_residual[q] += bdf_coefs[p] * velocity[p] * void_fraction[0];
912 }
913 double u_mag = 0;
914
915 if (cfd_dem.implicit_stabilization)
916 u_mag = std::max(velocity[0].norm(), 1e-12);
917 else
918 {
919 // Grad-div weight factor used to be constant 0.1
920 if (this->simulation_control->get_current_time() ==
921 this->simulation_control->get_time_step())
922 u_mag = std::max(velocity[0].norm(), 1e-12);
923 else
924 u_mag = std::max(velocity[1].norm(), 1e-12);
925 }
926
927 // Grad-div weight factor
928 const double gamma =
929 calculate_gamma(u_mag, kinematic_viscosity[q], h, cfd_dem.cstar);
930
931 for (unsigned int i = 0; i < n_dofs; ++i)
932 {
933 const auto phi_u_i = scratch_data.phi_u[q][i];
934 const auto div_phi_u_i = scratch_data.div_phi_u[q][i];
935 double local_rhs_i = 0;
936
937 for (unsigned int p = 0; p < number_of_previous_solutions(method) + 1;
938 ++p)
939 {
940 local_rhs_i -=
941 (bdf_coefs[p] * void_fraction[0] * (velocity[p] * phi_u_i));
942
943 if (cfd_dem.void_fraction_time_derivative == true)
944 {
945 local_rhs_i -= bdf_coefs[p] *
946 (void_fraction[p] * scratch_data.phi_p[q][i]);
947
948 if (cfd_dem.grad_div == true)
949 {
950 local_rhs_i -=
951 gamma * (bdf_coefs[p] * void_fraction[p]) * div_phi_u_i;
952 }
953 }
954 }
955 local_rhs(i) += local_rhs_i * JxW[q];
956 }
957 }
958}
959
960template class VANSAssemblerBDF<2>;
961template class VANSAssemblerBDF<3>;
962
963template <int dim, typename PropertiesIndex>
964void
967 NavierStokesScratchData<dim> &scratch_data)
968{
969 // Physical Properties
970 Assert(
971 !scratch_data.properties_manager.is_non_newtonian(),
972 RequiresConstantViscosity(
973 "VANSAssemblerDiFelice<dim>::calculate_particle_fluid_interactions"));
974
975 Assert(
977 RequiresConstantDensity(
978 "VANSAssemblerDiFelice<dim>::calculate_particle_fluid_interactions"));
979
980 double cell_void_fraction = 0;
981 double C_d = 0;
982 const auto &relative_velocity =
984 const auto &Re_p = scratch_data.Re_particle;
985 const auto &density = scratch_data.density_at_particle_location;
986 auto &beta_drag = scratch_data.beta_drag;
987
988 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
989 // store the drag if the coupling is explicit.
990 auto &explicit_particle_volumetric_acceleration_on_fluid =
992
993 Tensor<1, dim> drag_force;
994
995 const auto pic = scratch_data.pic;
996 beta_drag = 0;
997 // i_particle is an index that runs from 0 to n_particles_in_cell.
998 // It is used to access vectors of particle-specific variables and dependent
999 // quantities needed to compute the fluid’s effect on each particle in the
1000 // cell.
1001
1002 unsigned int i_particle = 0;
1003
1004 // Loop over particles in cell
1005 for (auto &particle : pic)
1006 {
1007 auto particle_properties = particle.get_properties();
1008
1009 cell_void_fraction =
1010 std::min(scratch_data.cell_void_fraction[i_particle], 1.0);
1011
1012 // Di Felice Drag Model CD Calculation
1013 C_d = Utilities::fixed_power<2>((0.63 + 4.8 / sqrt(Re_p[i_particle]))) *
1014 pow(cell_void_fraction,
1015 2 - (3.7 - 0.65 * exp(-Utilities::fixed_power<2>(
1016 1.5 - log10(Re_p[i_particle])) *
1017 0.5)));
1018
1019 double momentum_transfer_coefficient =
1020 (0.5 * C_d * M_PI *
1021 Utilities::fixed_power<2>(particle_properties[PropertiesIndex::dp]) /
1022 4) *
1023 relative_velocity[i_particle].norm();
1024
1027 {
1028 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1029 momentum_transfer_coefficient;
1030 beta_drag += momentum_transfer_coefficient;
1031 }
1032 else // Explicit drag model.
1033 {
1034 explicit_particle_volumetric_acceleration_on_fluid -=
1035 momentum_transfer_coefficient * relative_velocity[i_particle] /
1036 scratch_data.cell_volume;
1037 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1038 0;
1039 }
1040
1041 drag_force = density[i_particle] * momentum_transfer_coefficient *
1042 relative_velocity[i_particle];
1043
1044 for (int d = 0; d < dim; ++d)
1045 {
1046 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1047 }
1048
1049 i_particle += 1;
1050 }
1051
1052 beta_drag = beta_drag / scratch_data.cell_volume;
1053}
1054
1056template class VANSAssemblerDiFelice<2,
1059template class VANSAssemblerDiFelice<3,
1061
1062template <int dim, typename PropertiesIndex>
1063void
1065 NavierStokesScratchData<dim> &scratch_data)
1066{
1067 // Physical Properties
1068 Assert(!scratch_data.properties_manager.is_non_newtonian(),
1069 RequiresConstantViscosity(
1070 "VANSAssemblerRong<dim>::calculate_particle_fluid_interactions"));
1071
1072 Assert(scratch_data.properties_manager.density_is_constant(),
1073 RequiresConstantDensity(
1074 "VANSAssemblerRong<dim>::calculate_particle_fluid_interactions"));
1075
1076 double cell_void_fraction = 0;
1077 double C_d = 0;
1078 const auto &relative_velocity =
1080 const auto &Re_p = scratch_data.Re_particle;
1081 const auto &density = scratch_data.density_at_particle_location;
1082 auto &beta_drag = scratch_data.beta_drag;
1083
1084 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
1085 // store the drag if the coupling is explicit.
1086 auto &explicit_particle_volumetric_acceleration_on_fluid =
1088
1089 Tensor<1, dim> drag_force;
1090
1091 const auto pic = scratch_data.pic;
1092 beta_drag = 0;
1093 unsigned int i_particle = 0;
1094
1095 // Loop over particles in cell
1096 for (auto &particle : pic)
1097 {
1098 auto particle_properties = particle.get_properties();
1099
1100 cell_void_fraction =
1101 std::min(scratch_data.cell_void_fraction[i_particle], 1.0);
1102
1103 // Rong Drag Model CD Calculation
1104 C_d =
1105 Utilities::fixed_power<2>((0.63 + 4.8 / sqrt(Re_p[i_particle]))) *
1106 pow(cell_void_fraction,
1107 2 -
1108 (2.65 * (cell_void_fraction + 1) -
1109 (5.3 - (3.5 * cell_void_fraction)) *
1110 Utilities::fixed_power<2>(cell_void_fraction) *
1111 exp(-Utilities::fixed_power<2>(1.5 - log10(Re_p[i_particle])) *
1112 0.5)));
1113
1114 double momentum_transfer_coefficient =
1115 (0.5 * C_d * M_PI *
1116 Utilities::fixed_power<2>(particle_properties[PropertiesIndex::dp]) *
1117 0.25) *
1118 relative_velocity[i_particle].norm();
1119
1122 {
1123 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1124 momentum_transfer_coefficient;
1125 beta_drag += momentum_transfer_coefficient;
1126 }
1127 else // Explicit drag model.
1128 {
1129 explicit_particle_volumetric_acceleration_on_fluid -=
1130 momentum_transfer_coefficient * relative_velocity[i_particle] /
1131 scratch_data.cell_volume;
1132 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1133 0;
1134 }
1135 drag_force = density[i_particle] * momentum_transfer_coefficient *
1136 relative_velocity[i_particle];
1137
1138 for (int d = 0; d < dim; ++d)
1139 {
1140 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1141 }
1142
1143 i_particle += 1;
1144 }
1145
1146 beta_drag = beta_drag / scratch_data.cell_volume;
1147}
1148
1153
1154template <int dim, typename PropertiesIndex>
1155void
1158 NavierStokesScratchData<dim> &scratch_data)
1159{
1160 // Physical Properties
1161 Assert(
1162 !scratch_data.properties_manager.is_non_newtonian(),
1163 RequiresConstantViscosity(
1164 "VANSAssemblerDallavalle<dim>::calculate_particle_fluid_interactions"));
1165
1166 Assert(
1168 RequiresConstantDensity(
1169 "VANSAssemblerDallavalle<dim>::calculate_particle_fluid_interactions"));
1170
1171 double C_d = 0;
1172 const auto &relative_velocity =
1174 const auto &Re_p = scratch_data.Re_particle;
1175 const auto &density = scratch_data.density_at_particle_location;
1176 auto &beta_drag = scratch_data.beta_drag;
1177
1178 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
1179 // store the drag if the coupling is explicit.
1180 auto &explicit_particle_volumetric_acceleration_on_fluid =
1182
1183 Tensor<1, dim> drag_force;
1184
1185 const auto pic = scratch_data.pic;
1186 beta_drag = 0;
1187 unsigned int i_particle = 0;
1188
1189 // Loop over particles in cell
1190 for (auto &particle : pic)
1191 {
1192 auto particle_properties = particle.get_properties();
1193
1194 // Dallavalle Drag Model CD Calculation
1195 C_d = Utilities::fixed_power<2>(0.63 + 4.8 / sqrt(Re_p[i_particle]));
1196
1197 double momentum_transfer_coefficient =
1198 (0.5 * C_d * M_PI *
1199 Utilities::fixed_power<2>(particle_properties[PropertiesIndex::dp]) *
1200 0.25) *
1201 relative_velocity[i_particle].norm();
1202
1205 {
1206 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1207 momentum_transfer_coefficient;
1208 beta_drag += momentum_transfer_coefficient;
1209 }
1210 else // Explicit drag model.
1211 {
1212 explicit_particle_volumetric_acceleration_on_fluid -=
1213 momentum_transfer_coefficient * relative_velocity[i_particle] /
1214 scratch_data.cell_volume;
1215 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1216 0;
1217 }
1218
1219 drag_force = density[i_particle] * momentum_transfer_coefficient *
1220 relative_velocity[i_particle];
1221
1222 for (int d = 0; d < dim; ++d)
1223 {
1224 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1225 }
1226
1227 i_particle += 1;
1228 }
1229
1230 beta_drag = beta_drag / scratch_data.cell_volume;
1231}
1232
1233template class VANSAssemblerDallavalle<2,
1235template class VANSAssemblerDallavalle<
1236 2,
1238template class VANSAssemblerDallavalle<3,
1240template class VANSAssemblerDallavalle<
1241 3,
1243
1244template <int dim, typename PropertiesIndex>
1245void
1248 NavierStokesScratchData<dim> &scratch_data)
1249{
1250 // Physical Properties
1251 Assert(
1252 !scratch_data.properties_manager.is_non_newtonian(),
1253 RequiresConstantViscosity(
1254 "VANSAssemblerKochHill<dim>::calculate_particle_fluid_interactions"));
1255
1256 Assert(
1258 RequiresConstantDensity(
1259 "VANSAssemblerKochHill<dim>::calculate_particle_fluid_interactions"));
1260
1261 double cell_void_fraction = 0;
1262 const auto &relative_velocity =
1264 const auto &Re_p = scratch_data.Re_particle;
1265 const auto &density = scratch_data.density_at_particle_location;
1266 const auto &kinematic_viscosity =
1268 auto &beta_drag = scratch_data.beta_drag;
1269
1270 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
1271 // store the drag if the coupling is explicit.
1272 auto &explicit_particle_volumetric_acceleration_on_fluid =
1274
1275 Tensor<1, dim> drag_force;
1276
1277 const auto pic = scratch_data.pic;
1278 beta_drag = 0;
1279 unsigned int i_particle = 0;
1280
1281 double f0 = 0;
1282
1283 // Loop over particles in cell
1284 for (auto &particle : pic)
1285 {
1286 auto particle_properties = particle.get_properties();
1287
1288 cell_void_fraction =
1289 std::min(scratch_data.cell_void_fraction[i_particle], 1.0);
1290
1291 // Koch and Hill Drag Model Calculation
1292 if ((1 - cell_void_fraction) < 0.4)
1293 {
1294 f0 = (1 + 3 * sqrt((1 - cell_void_fraction + DBL_MIN) / 2) +
1295 (135.0 / 64) * (1 - cell_void_fraction) *
1296 log(1 - cell_void_fraction + DBL_MIN) +
1297 16.14 * (1 - cell_void_fraction)) /
1298 (1 + 0.681 * (1 - cell_void_fraction) -
1299 8.48 * Utilities::fixed_power<2>(1 - cell_void_fraction) +
1300 8.16 * Utilities::fixed_power<3>(1 - cell_void_fraction));
1301 }
1302 else if ((1 - cell_void_fraction) >= 0.4)
1303 {
1304 f0 = 10 * (1 - cell_void_fraction) /
1305 Utilities::fixed_power<3>(cell_void_fraction);
1306 }
1307
1308 double f3 = 0.0673 + 0.212 * (1 - cell_void_fraction) +
1309 0.0232 / Utilities::fixed_power<5>(cell_void_fraction);
1310
1311 double momentum_transfer_coefficient =
1312 ((18 * kinematic_viscosity[i_particle] *
1313 Utilities::fixed_power<2>(cell_void_fraction) *
1314 (1 - cell_void_fraction)) /
1315 Utilities::fixed_power<2>(particle_properties[PropertiesIndex::dp])) *
1316 (f0 + 0.5 * f3 * Re_p[i_particle]) *
1317 (M_PI * pow(particle_properties[PropertiesIndex::dp], dim) /
1318 (2 * dim)) /
1319 (1 - cell_void_fraction + DBL_MIN);
1320
1323 {
1324 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1325 momentum_transfer_coefficient;
1326 beta_drag += momentum_transfer_coefficient;
1327 }
1328 else // Explicit drag model.
1329 {
1330 explicit_particle_volumetric_acceleration_on_fluid -=
1331 momentum_transfer_coefficient * relative_velocity[i_particle] /
1332 scratch_data.cell_volume;
1333 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1334 0;
1335 }
1336
1337 drag_force = density[i_particle] * momentum_transfer_coefficient *
1338 relative_velocity[i_particle];
1339
1340 for (int d = 0; d < dim; ++d)
1341 {
1342 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1343 }
1344
1345 i_particle += 1;
1346 }
1347
1348 beta_drag = beta_drag / scratch_data.cell_volume;
1349}
1350
1352template class VANSAssemblerKochHill<2,
1355template class VANSAssemblerKochHill<3,
1357
1358template <int dim, typename PropertiesIndex>
1359void
1362 NavierStokesScratchData<dim> &scratch_data)
1363{
1364 // Physical Properties
1365 Assert(
1366 !scratch_data.properties_manager.is_non_newtonian(),
1367 RequiresConstantViscosity(
1368 "VANSAssemblerBeetstra<dim>::calculate_particle_fluid_interactions"));
1369
1370 Assert(
1372 RequiresConstantDensity(
1373 "VANSAssemblerBeetstra<dim>::calculate_particle_fluid_interactions"));
1374
1375 double cell_void_fraction = 0;
1376 double F0 = 0;
1377 const auto &relative_velocity =
1379 const auto &Re_p = scratch_data.Re_particle;
1380 const auto &density = scratch_data.density_at_particle_location;
1381 const auto &kinematic_viscosity =
1383 auto &beta_drag = scratch_data.beta_drag;
1384
1385 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
1386 // store the drag if the coupling is explicit.
1387 auto &explicit_particle_volumetric_acceleration_on_fluid =
1389
1390 Tensor<1, dim> drag_force;
1391
1392 const auto pic = scratch_data.pic;
1393 beta_drag = 0;
1394 unsigned int i_particle = 0;
1395
1396 // Loop over particles in cell
1397 for (auto &particle : pic)
1398 {
1399 auto particle_properties = particle.get_properties();
1400
1401 cell_void_fraction =
1402 std::min(scratch_data.cell_void_fraction[i_particle], 1.0);
1403
1404 // Beetstra drag coefficient
1405 F0 = 10 * (1 - cell_void_fraction) /
1406 Utilities::fixed_power<2>(cell_void_fraction) +
1407 Utilities::fixed_power<2>(cell_void_fraction) *
1408 (1 + 1.5 * sqrt((1 - cell_void_fraction + DBL_MIN))) +
1409 0.413 * (Re_p[i_particle]) /
1410 (24 * Utilities::fixed_power<2>(cell_void_fraction)) *
1411 ((1 / cell_void_fraction) +
1412 3 * (1 - cell_void_fraction) * cell_void_fraction +
1413 8.4 * pow((Re_p[i_particle]), -0.343)) /
1414 (1 + pow(10, 3 * (1 - cell_void_fraction)) *
1415 pow((Re_p[i_particle]),
1416 -(1 + 4 * (1 - cell_void_fraction)) * 0.5));
1417
1418 double momentum_transfer_coefficient =
1419 F0 * 3 * M_PI * kinematic_viscosity[i_particle] * cell_void_fraction *
1420 particle_properties[PropertiesIndex::dp];
1421
1424 {
1425 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1426 momentum_transfer_coefficient;
1427 beta_drag += momentum_transfer_coefficient;
1428 }
1429 else // Explicit drag model.
1430 {
1431 explicit_particle_volumetric_acceleration_on_fluid -=
1432 momentum_transfer_coefficient * relative_velocity[i_particle] /
1433 scratch_data.cell_volume;
1434 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1435 0;
1436 }
1437
1438 drag_force = density[i_particle] * momentum_transfer_coefficient *
1439 relative_velocity[i_particle];
1440
1441 for (int d = 0; d < dim; ++d)
1442 {
1443 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1444 }
1445
1446 i_particle += 1;
1447 }
1448
1449 beta_drag = beta_drag / scratch_data.cell_volume;
1450}
1451
1453template class VANSAssemblerBeetstra<2,
1456template class VANSAssemblerBeetstra<3,
1458
1459template <int dim, typename PropertiesIndex>
1460void
1463 NavierStokesScratchData<dim> &scratch_data)
1464{
1465 // Physical Properties
1466 Assert(
1467 !scratch_data.properties_manager.is_non_newtonian(),
1468 RequiresConstantViscosity(
1469 "VANSAssemblerGidaspow<dim>::calculate_particle_fluid_interactions"));
1470
1471 Assert(
1473 RequiresConstantDensity(
1474 "VANSAssemblerGidaspow<dim>::calculate_particle_fluid_interactions"));
1475
1476 double cell_void_fraction = 0;
1477 const auto &relative_velocity =
1479 const auto &Re_p = scratch_data.Re_particle;
1480 const auto &density = scratch_data.density_at_particle_location;
1481 const auto &kinematic_viscosity =
1483 auto &beta_drag = scratch_data.beta_drag;
1484
1485 // The explicit_particle_volumetric_acceleration_on_fluid variable is used to
1486 // store the drag if the coupling is explicit.
1487 auto &explicit_particle_volumetric_acceleration_on_fluid =
1489
1490
1491 Tensor<1, dim> drag_force;
1492
1493 const auto pic = scratch_data.pic;
1494 double momentum_transfer_coefficient = 0;
1495 beta_drag = 0;
1496 unsigned int i_particle = 0;
1497
1498 // Loop over particles in cell
1499 for (auto &particle : pic)
1500 {
1501 auto particle_properties = particle.get_properties();
1502
1503 cell_void_fraction =
1504 std::min(scratch_data.cell_void_fraction[i_particle], 1.0);
1505
1506 // Gidaspow Drag Model
1507 double particle_density =
1508 particle_properties[PropertiesIndex::mass] /
1509 (M_PI *
1510 Utilities::fixed_power<dim>(particle_properties[PropertiesIndex::dp]) /
1511 (2.0 * dim));
1512
1513 if (cell_void_fraction > 0.8)
1514 {
1515 momentum_transfer_coefficient =
1516 (18 * pow(cell_void_fraction, -3.65) *
1517 (1 + 0.15 * pow(Re_p[i_particle], 0.687))) *
1518 (particle_properties[PropertiesIndex::mass] *
1519 kinematic_viscosity[i_particle] /
1520 (Utilities::fixed_power<2, double>(
1521 particle_properties[PropertiesIndex::dp]) *
1522 particle_density));
1523 }
1524 else
1525 {
1526 // Assuming the sphericity of particles = 1
1527 momentum_transfer_coefficient =
1528 (150 * (1 - cell_void_fraction) /
1529 Utilities::fixed_power<2, double>(cell_void_fraction) +
1530 1.75 * Re_p[i_particle] /
1531 Utilities::fixed_power<2, double>(cell_void_fraction)) *
1532 (particle_properties[PropertiesIndex::mass] *
1533 kinematic_viscosity[i_particle] /
1534 (Utilities::fixed_power<2, double>(
1535 particle_properties[PropertiesIndex::dp]) *
1536 particle_density));
1537 }
1538
1541 {
1542 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1543 momentum_transfer_coefficient;
1544 beta_drag += momentum_transfer_coefficient;
1545 }
1546 else // Explicit drag model.
1547 {
1548 explicit_particle_volumetric_acceleration_on_fluid -=
1549 momentum_transfer_coefficient * relative_velocity[i_particle] /
1550 scratch_data.cell_volume;
1551 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1552 0;
1553 }
1554
1555 particle_properties[PropertiesIndex::momentum_transfer_coefficient] =
1556 momentum_transfer_coefficient;
1557
1558 drag_force = density[i_particle] * momentum_transfer_coefficient *
1559 relative_velocity[i_particle];
1560
1561
1562 for (int d = 0; d < dim; ++d)
1563 {
1564 particle_properties[PropertiesIndex::fem_drag_x + d] += drag_force[d];
1565 }
1566
1567 i_particle += 1;
1568 }
1569
1570 beta_drag = beta_drag / scratch_data.cell_volume;
1571}
1572
1574template class VANSAssemblerGidaspow<2,
1577template class VANSAssemblerGidaspow<3,
1579
1580template <int dim, typename PropertiesIndex>
1581void
1584 NavierStokesScratchData<dim> &scratch_data)
1585{
1586 // Physical Properties
1587 Assert(
1588 !scratch_data.properties_manager.is_non_newtonian(),
1589 RequiresConstantViscosity(
1590 "VANSAssemblerSaffmanMei<dim>::calculate_particle_fluid_interactions"));
1591
1592 Assert(
1594 RequiresConstantDensity(
1595 "VANSAssemblerSaffmanMei<dim>::calculate_particle_fluid_interactions"));
1596
1597 // This implementation follows the formulation in the book "Multiphase Flows
1598 // with Droplets and Particles" by Crowe et al. (2011) and the brief
1599 // communication article "An approximate expression for the shear lift force
1600 // on a spherical particle at finite reynolds number" by Mei (1992)
1601 double C_s = 0;
1602 double alpha = 0;
1603
1604 const auto &relative_velocity =
1606 const auto &Re_p = scratch_data.Re_particle;
1607 const auto &density = scratch_data.density_at_particle_location;
1608 const auto &kinematic_viscosity =
1610
1611 auto &vorticity_2d =
1613 auto &vorticity_3d =
1615 auto &explicit_particle_volumetric_acceleration_on_fluid =
1617
1618 Tensor<1, dim> lift_force;
1619
1620 const auto pic = scratch_data.pic;
1621 unsigned int i_particle = 0;
1622
1623 if constexpr (dim == 2)
1624 {
1625 for (auto &particle : pic)
1626 {
1627 auto particle_properties = particle.get_properties();
1628 // The 2D Saffman-Mei formulation only needs the scalar out-of-plane
1629 // vorticity. Extract it once here so the rest of the branch is
1630 // independent of the deal.II curl storage type.
1631 const double vorticity_z =
1632 extract_out_of_plane_vorticity(vorticity_2d[i_particle]);
1633
1634 // Saffman-Mei coefficient
1635 alpha = 0.5 * particle_properties[PropertiesIndex::dp] /
1636 relative_velocity[i_particle].norm() *
1637 (std::abs(vorticity_z) + 1e-12);
1638
1639 if (Re_p[i_particle] <= 40)
1640 C_s = (1 - 0.3314 * sqrt(alpha)) * exp(-0.1 * Re_p[i_particle]) +
1641 0.3314 * sqrt(alpha);
1642 else if (Re_p[i_particle] > 40)
1643 C_s = 0.0524 * sqrt(alpha * Re_p[i_particle]);
1644
1645 // In 2D, the curl of the fluid velocity is a scalar aligned with the
1646 // out-of-plane direction. The lift force is therefore the in-plane
1647 // cross product u_rel x (0, 0, omega_z).
1648 lift_force[0] =
1649 C_s * 1.61 * particle_properties[PropertiesIndex::dp] *
1650 particle_properties[PropertiesIndex::dp] * density[i_particle] *
1651 sqrt(kinematic_viscosity[i_particle] + DBL_MIN) /
1652 sqrt(std::abs(vorticity_z) + 1e-12) *
1653 (relative_velocity[i_particle][1] * vorticity_z);
1654
1655 lift_force[1] =
1656 C_s * 1.61 * particle_properties[PropertiesIndex::dp] *
1657 particle_properties[PropertiesIndex::dp] * density[i_particle] *
1658 sqrt(kinematic_viscosity[i_particle] + DBL_MIN) /
1659 sqrt(std::abs(vorticity_z) + 1e-12) *
1660 (-relative_velocity[i_particle][0] * vorticity_z);
1661
1662 for (int d = 0; d < dim; ++d)
1663 {
1664 // Apply lift force on the particle
1665 particle_properties
1666 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
1667 lift_force[d];
1668
1669 // Apply lift force on the fluid
1670 explicit_particle_volumetric_acceleration_on_fluid[d] -=
1671 lift_force[d] /
1672 (density[i_particle] * scratch_data.cell_volume);
1673 }
1674
1675 i_particle += 1;
1676 }
1677 }
1678 else if constexpr (dim == 3)
1679 {
1680 for (auto &particle : pic)
1681 {
1682 auto particle_properties = particle.get_properties();
1683
1684 // Saffman-Mei coefficient C_s
1685 alpha = 0.5 * particle_properties[PropertiesIndex::dp] /
1686 relative_velocity[i_particle].norm() *
1687 (vorticity_3d[i_particle].norm() + 1e-12);
1688
1689 if (Re_p[i_particle] <= 40)
1690 C_s = (1 - 0.3314 * sqrt(alpha)) * exp(-0.1 * Re_p[i_particle]) +
1691 0.3314 * sqrt(alpha);
1692 else if (Re_p[i_particle] > 40)
1693 C_s = 0.0524 * sqrt(alpha * Re_p[i_particle]);
1694
1695 // Vorticity tensor
1696 Tensor<1, 3> vorticity = vorticity_3d[i_particle];
1697
1698 lift_force =
1699 C_s * 1.61 * particle_properties[PropertiesIndex::dp] *
1700 particle_properties[PropertiesIndex::dp] * density[i_particle] *
1701 sqrt(kinematic_viscosity[i_particle] + DBL_MIN) /
1702 sqrt(vorticity.norm() + 1e-12) *
1703 (cross_product_3d(relative_velocity[i_particle], vorticity));
1704
1705 for (int d = 0; d < dim; ++d)
1706 {
1707 // Apply lift force on the particle
1708 particle_properties
1709 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
1710 lift_force[d];
1711
1712 // Apply lift force on the fluid
1713 explicit_particle_volumetric_acceleration_on_fluid[d] -=
1714 lift_force[d] /
1715 (density[i_particle] * scratch_data.cell_volume);
1716 }
1717 i_particle += 1;
1718 }
1719 }
1720}
1721
1722template class VANSAssemblerSaffmanMei<2,
1724template class VANSAssemblerSaffmanMei<
1725 2,
1727template class VANSAssemblerSaffmanMei<3,
1729template class VANSAssemblerSaffmanMei<
1730 3,
1732
1733template <int dim, typename PropertiesIndex>
1734void
1737 NavierStokesScratchData<dim> &scratch_data)
1738{
1739 // Physical Properties
1740 Assert(scratch_data.properties_manager.density_is_constant(),
1741 RequiresConstantDensity(
1742 "VANSAssemblerMagnus<dim>::calculate_particle_fluid_interactions"));
1743
1744 // This implementation follows the formulation in the book "Multiphase Flows
1745 // with Droplets and Particles" by Crowe et al. (2011).
1746 double C_m = 0.;
1747
1748 const auto &relative_velocity =
1750 const auto &Re_p = scratch_data.Re_particle;
1751 const auto &density = scratch_data.density_at_particle_location;
1752
1753 auto &explicit_particle_volumetric_acceleration_on_fluid =
1755
1756 Tensor<1, dim> lift_force;
1757
1758 const auto pic = scratch_data.pic;
1759 unsigned int i_particle = 0;
1760
1761 if constexpr (dim == 2)
1762 {
1763 for (auto &particle : pic)
1764 {
1765 auto particle_properties = particle.get_properties();
1766
1767 // Add factor to rotational velocity to avoid divisions by zero
1768 double omega_z =
1769 particle_properties[PropertiesIndex::omega_z] + 1e-15;
1770
1771 double omega_norm = abs(omega_z);
1772
1773 // Spin parameter
1774 double spin_parameter = particle_properties[PropertiesIndex::dp] *
1775 omega_norm /
1776 (2.0 * relative_velocity[i_particle].norm());
1777
1778 // Magnus lift coefficient
1779 if (spin_parameter > 1.0 && spin_parameter < 6.0 &&
1780 Re_p[i_particle] > 10.0 && Re_p[i_particle] < 140.0)
1781 {
1782 // Oesterlé and Dinh (1998)
1783 C_m = 0.45 + (2 * spin_parameter - 0.45) *
1784 exp(-0.075 * pow(spin_parameter, 0.4) *
1785 pow(Re_p[i_particle], 0.7));
1786 }
1787 else
1788 C_m = 2.0 * spin_parameter;
1789
1790 // Magnus Lift force
1791 lift_force[0] =
1792 0.5 * C_m * particle_properties[PropertiesIndex::dp] *
1793 density[i_particle] * relative_velocity[i_particle].norm() *
1794 (omega_z / omega_norm * relative_velocity[i_particle][1]);
1795
1796 lift_force[1] =
1797 0.5 * C_m * particle_properties[PropertiesIndex::dp] *
1798 density[i_particle] * relative_velocity[i_particle].norm() *
1799 (omega_z / omega_norm * relative_velocity[i_particle][0]);
1800
1801 for (int d = 0; d < dim; ++d)
1802 {
1803 // Apply lift force on the particle
1804 particle_properties
1805 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
1806 lift_force[d];
1807
1808 // Apply lift force on the fluid
1809 explicit_particle_volumetric_acceleration_on_fluid[d] -=
1810 lift_force[d] /
1811 (density[i_particle] * scratch_data.cell_volume);
1812 }
1813 i_particle += 1;
1814 }
1815 }
1816
1817 else if constexpr (dim == 3)
1818 {
1819 for (auto &particle : pic)
1820 {
1821 auto particle_properties = particle.get_properties();
1822
1823 Tensor<1, dim> omega;
1824
1825 for (int d = 0; d < dim; ++d)
1826 {
1827 omega[d] =
1828 particle_properties[PropertiesIndex::omega_x + d] + 1e-15;
1829 }
1830
1831 // Spin parameter
1832 double spin_parameter = particle_properties[PropertiesIndex::dp] *
1833 omega.norm() /
1834 (2.0 * relative_velocity[i_particle].norm());
1835
1836 // Magnus lift coefficient
1837 if (spin_parameter > 1.0 && spin_parameter < 6.0 &&
1838 Re_p[i_particle] > 10.0 && Re_p[i_particle] < 140.0)
1839 {
1840 // Oesterlé and Dinh (1998)
1841 C_m = 0.45 + (2 * spin_parameter - 0.45) *
1842 exp(-0.075 * pow(spin_parameter, 0.4) *
1843 pow(Re_p[i_particle], 0.7));
1844 }
1845 else
1846 C_m = 2.0 * spin_parameter;
1847
1848 Tensor<1, dim> rotational_vector = omega / omega.norm();
1849
1850 // Magnus Lift force
1851 lift_force = 0.125 * M_PI *
1852 Utilities::fixed_power<2>(
1853 particle_properties[PropertiesIndex::dp]) *
1854 C_m * density[i_particle] *
1855 relative_velocity[i_particle].norm() *
1856 (cross_product_3d(rotational_vector,
1857 relative_velocity[i_particle]));
1858
1859 for (int d = 0; d < dim; ++d)
1860 {
1861 // Apply lift force on the particle
1862 particle_properties
1863 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
1864 lift_force[d];
1865
1866 // Apply lift force on the fluid
1867 explicit_particle_volumetric_acceleration_on_fluid[d] -=
1868 lift_force[d] /
1869 (density[i_particle] * scratch_data.cell_volume);
1870 }
1871 i_particle += 1;
1872 }
1873 }
1874}
1875
1880
1881template <int dim, typename PropertiesIndex>
1882void
1885 NavierStokesScratchData<dim> &scratch_data)
1886{
1887 // Physical Properties
1888 Assert(
1889 !scratch_data.properties_manager.is_non_newtonian(),
1890 RequiresConstantViscosity(
1891 "VANSAssemblerViscousTorque<dim>::calculate_particle_fluid_interactions"));
1892
1893 Assert(
1895 RequiresConstantDensity(
1896 "VANSAssemblerViscousTorque<dim>::calculate_particle_fluid_interactions"));
1897
1898 const auto &density = scratch_data.density_at_particle_location;
1899 const auto &kinematic_viscosity =
1901 const auto pic = scratch_data.pic;
1902
1903 unsigned int i_particle = 0;
1904
1905 // Loop over particles in cell
1906 for (auto &particle : pic)
1907 {
1908 auto particle_properties = particle.get_properties();
1909
1910 // Extract constant factor to avoid remultiplying it during the loop
1911 const double factor = M_PI *
1912 Utilities::fixed_power<3, double>(
1913 particle_properties[PropertiesIndex::dp]) *
1914 kinematic_viscosity[i_particle] *
1915 density[i_particle] * 0.5;
1916
1917 for (int d = 0; d < dim; d++)
1918 {
1919 particle_properties[PropertiesIndex::fem_torque_x + d] -=
1920 factor * particle_properties[PropertiesIndex::omega_x + d];
1921 }
1922 i_particle += 1;
1923 }
1924}
1925
1926template class VANSAssemblerViscousTorque<
1927 2,
1929template class VANSAssemblerViscousTorque<
1930 2,
1932template class VANSAssemblerViscousTorque<
1933 3,
1935template class VANSAssemblerViscousTorque<
1936 3,
1938
1939template <int dim, typename PropertiesIndex>
1940void
1943 NavierStokesScratchData<dim> &scratch_data)
1944{
1945 // Physical Properties
1946 Assert(
1947 !scratch_data.properties_manager.is_non_newtonian(),
1948 RequiresConstantViscosity(
1949 "VANSAssemblerVorticalTorque<dim>::calculate_particle_fluid_interactions"));
1950
1951 Assert(
1953 RequiresConstantDensity(
1954 "VANSAssemblerVorticalTorque<dim>::calculate_particle_fluid_interactions"));
1955
1956 const auto &density = scratch_data.density_at_particle_location;
1957 const auto &kinematic_viscosity =
1959
1960 auto &vorticity_3d =
1962
1963 const auto pic = scratch_data.pic;
1964
1965 // Local index used to access the local fields calculated at the particle
1966 // location
1967 unsigned int i_particle = 0;
1968
1969 // Loop over particles in cell
1970 for (auto &particle : pic)
1971 {
1972 auto particle_properties = particle.get_properties();
1973
1974 // Extract constant factor to avoid remultiplying it during the loop
1975 const double factor = M_PI *
1976 Utilities::fixed_power<3, double>(
1977 particle_properties[PropertiesIndex::dp]) *
1978 kinematic_viscosity[i_particle] *
1979 density[i_particle] * 0.5;
1980
1981 for (int d = 0; d < dim; d++)
1982 {
1983 // Calculate and apply viscous torque
1984 particle_properties[PropertiesIndex::fem_torque_x + d] +=
1985 factor * vorticity_3d[i_particle][d];
1986 }
1987 i_particle += 1;
1988 }
1989}
1990
1991template class VANSAssemblerVorticalTorque<
1992 2,
1994template class VANSAssemblerVorticalTorque<
1995 2,
1997template class VANSAssemblerVorticalTorque<
1998 3,
2000template class VANSAssemblerVorticalTorque<
2001 3,
2003
2004template <int dim, typename PropertiesIndex>
2005void
2008 NavierStokesScratchData<dim> &scratch_data)
2009{
2010 // Physical Properties
2011 Assert(
2013 RequiresConstantDensity(
2014 "VANSAssemblerBuoyancy<dim>::calculate_particle_fluid_interactions"));
2015
2016 const auto pic = scratch_data.pic;
2017 Tensor<1, 3> buoyancy_force;
2018
2019 const auto &density = scratch_data.density_at_particle_location;
2020
2021 unsigned int i_particle = 0;
2022
2023 // Loop over particles in cell
2024 for (auto &particle : pic)
2025 {
2026 auto particle_properties = particle.get_properties();
2027
2028 // Buoyancy Force
2029 buoyancy_force = -gravity * (4.0 / 3) * M_PI *
2030 Utilities::fixed_power<3>(
2031 (particle_properties[PropertiesIndex::dp] / 2.0));
2032
2033 for (int d = 0; d < dim; ++d)
2034 {
2035 particle_properties[PropertiesIndex::fem_force_one_way_coupling_x +
2036 d] += buoyancy_force[d] * density[i_particle];
2037 }
2038 i_particle += 1;
2039 }
2040}
2041
2043template class VANSAssemblerBuoyancy<2,
2046template class VANSAssemblerBuoyancy<3,
2048
2049template <int dim, typename PropertiesIndex>
2050void
2053 NavierStokesScratchData<dim> &scratch_data)
2054{
2055 // Physical Properties
2056 Assert(
2058 RequiresConstantDensity(
2059 "VANSAssemblerPressureForce<dim>::calculate_particle_fluid_interactions"));
2060
2061 const auto pic = scratch_data.pic;
2062 auto &explicit_particle_volumetric_acceleration_on_fluid =
2064 auto pressure_gradients =
2066 Tensor<1, dim> pressure_force;
2067
2068 unsigned int i_particle = 0;
2069
2070 const auto &density = scratch_data.density_at_particle_location;
2071
2072 // Loop over particles in cell
2073 for (auto &particle : pic)
2074 {
2075 auto particle_properties = particle.get_properties();
2076
2077 // Pressure Force
2078 pressure_force = -(M_PI *
2079 Utilities::fixed_power<dim>(
2080 particle_properties[PropertiesIndex::dp]) /
2081 (2 * dim)) *
2082 pressure_gradients[i_particle];
2083
2084 for (int d = 0; d < dim; ++d)
2085 {
2086 // Apply pressure force to the particles only, when we are solving
2087 // model A of the VANS. When we are solving Model B, apply the
2088 // pressure force back on the fluid by lumping it in the
2089 // explicit_particle_volumetric_acceleration_on_fluid.
2090 if (cfd_dem.vans_model == Parameters::VANSModel::modelA)
2091 {
2092 particle_properties
2093 [PropertiesIndex::fem_force_one_way_coupling_x + d] +=
2094 pressure_force[d] * density[i_particle];
2095 }
2096 if (cfd_dem.vans_model == Parameters::VANSModel::modelB)
2097 {
2098 particle_properties
2099 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
2100 pressure_force[d] * density[i_particle];
2101 explicit_particle_volumetric_acceleration_on_fluid[d] -=
2102 pressure_force[d] / scratch_data.cell_volume;
2103 }
2104 }
2105
2106 i_particle += 1;
2107 }
2108}
2109
2110template class VANSAssemblerPressureForce<
2111 2,
2113template class VANSAssemblerPressureForce<
2114 2,
2116template class VANSAssemblerPressureForce<
2117 3,
2119template class VANSAssemblerPressureForce<
2120 3,
2122
2123template <int dim, typename PropertiesIndex>
2124void
2127 NavierStokesScratchData<dim> &scratch_data)
2128{
2129 // Kinematic viscosity and density are currently assumed constant within the
2130 // same fluid phase. Physical Properties
2131 Assert(
2132 !scratch_data.properties_manager.is_non_newtonian(),
2133 RequiresConstantViscosity(
2134 "VANSAssemblerShearForce<dim>::calculate_particle_fluid_interactions"));
2135
2136 Assert(
2138 RequiresConstantDensity(
2139 "VANSAssemblerShearForce<dim>::calculate_particle_fluid_interactions"));
2140
2141 const auto pic = scratch_data.pic;
2142 auto &explicit_particle_volumetric_acceleration_on_fluid =
2144 auto &velocity_laplacians =
2146 Tensor<1, dim> shear_force;
2147
2148 unsigned int i_particle = 0;
2149
2150 const auto &density = scratch_data.density_at_particle_location;
2151 const std::vector<double> &kinematic_viscosity =
2153
2154 // Loop over particles in cell
2155 for (auto &particle : pic)
2156 {
2157 auto particle_properties = particle.get_properties();
2158
2159 // Shear Force
2160 shear_force = -(M_PI *
2161 Utilities::fixed_power<dim>(
2162 particle_properties[PropertiesIndex::dp]) /
2163 (2 * dim)) *
2164 kinematic_viscosity[i_particle] *
2165 velocity_laplacians[i_particle];
2166
2167 for (int d = 0; d < dim; ++d)
2168 {
2169 // Apply shear force to the particles only, when we are solving
2170 // model A of the VANS. When we are solving Model B, apply the shear
2171 // force back on the fluid by lumping it in the
2172 // explicit_particle_volumetric_acceleration_on_fluid.
2173
2174 if (cfd_dem.vans_model == Parameters::VANSModel::modelA)
2175 {
2176 particle_properties
2177 [PropertiesIndex::fem_force_one_way_coupling_x + d] +=
2178 shear_force[d] * density[i_particle];
2179 }
2180 if (cfd_dem.vans_model == Parameters::VANSModel::modelB)
2181 {
2182 particle_properties
2183 [PropertiesIndex::fem_force_two_way_coupling_x + d] +=
2184 shear_force[d] * density[i_particle];
2185 explicit_particle_volumetric_acceleration_on_fluid[d] -=
2186 shear_force[d] / scratch_data.cell_volume;
2187 }
2188 }
2189
2190 i_particle += 1;
2191 }
2192}
2193
2194template class VANSAssemblerShearForce<2,
2196template class VANSAssemblerShearForce<
2197 2,
2199template class VANSAssemblerShearForce<3,
2201template class VANSAssemblerShearForce<
2202 3,
2204
2205template <int dim>
2206void
2208 const NavierStokesScratchData<dim> &scratch_data,
2210{
2211 // Loop and quadrature information
2212 const auto &JxW_vec = scratch_data.JxW;
2213 const unsigned int n_q_points = scratch_data.n_q_points;
2214 const unsigned int n_dofs = scratch_data.n_dofs;
2215
2216 // Copy data elements
2217 auto &strong_residual = copy_data.strong_residual;
2218 auto &strong_jacobian = copy_data.strong_jacobian;
2219 auto &local_matrix = copy_data.local_matrix;
2220 auto beta_drag = scratch_data.beta_drag;
2221 auto &explicit_particle_volumetric_acceleration_on_fluid =
2223 const Tensor<1, dim> average_particles_velocity =
2224 scratch_data.average_particle_velocity;
2225
2226 // Loop over the quadrature points
2227 for (unsigned int q = 0; q < n_q_points; ++q)
2228 {
2229 // Gather into local variables the relevant fields
2230 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
2231
2232 // Store JxW in local variable for faster access;
2233 const double JxW = JxW_vec[q];
2234
2235 // Subtraction of forces applied on fluid from the residual for GLS
2236 // stabilization
2237 strong_residual[q] -=
2238 // drag applied on fluid
2239 (-beta_drag * (velocity - average_particles_velocity)
2240 // other two-way coupling forces applied on the fluid
2241 + explicit_particle_volumetric_acceleration_on_fluid);
2242
2243 for (unsigned int j = 0; j < n_dofs; ++j)
2244 {
2245 const auto &phi_u_j = scratch_data.phi_u[q][j];
2246 strong_jacobian[q][j] +=
2247 // Drag Force
2248 beta_drag * phi_u_j;
2249 }
2250
2251 for (unsigned int i = 0; i < n_dofs; ++i)
2252 {
2253 const auto &phi_u_i = scratch_data.phi_u[q][i];
2254
2255 for (unsigned int j = 0; j < n_dofs; ++j)
2256 {
2257 const auto &phi_u_j = scratch_data.phi_u[q][j];
2258
2259 local_matrix(i, j) += // Drag Force
2260 beta_drag * phi_u_j * phi_u_i * JxW;
2261 }
2262 }
2263 }
2264}
2265
2266template <int dim>
2267void
2269 const NavierStokesScratchData<dim> &scratch_data,
2271{
2272 // Loop and quadrature information
2273 const auto &JxW_vec = scratch_data.JxW;
2274 const unsigned int n_q_points = scratch_data.n_q_points;
2275 const unsigned int n_dofs = scratch_data.n_dofs;
2276
2277 // Copy data elements
2278 auto &strong_residual = copy_data.strong_residual;
2279 auto &local_rhs = copy_data.local_rhs;
2280 auto beta_drag = scratch_data.beta_drag;
2281 auto &explicit_particle_volumetric_acceleration_on_fluid =
2283 const Tensor<1, dim> average_particles_velocity =
2284 scratch_data.average_particle_velocity;
2285
2286 // Loop over the quadrature points
2287 for (unsigned int q = 0; q < n_q_points; ++q)
2288 {
2289 // Velocity
2290 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
2291
2292 // Store JxW in local variable for faster access;
2293 const double JxW = JxW_vec[q];
2294
2295 // Calculate the strong residual for GLS stabilization
2296 // No need to have separate codes for models A and B here, as the
2297 // correct forces are included in
2298 // explicit_particle_volumetric_acceleration_on_fluid in the
2299 // particle-fluid interaction assemblers, depending on the VANS model.
2300
2301 // Subtraction of forces applied on fluid from the residual for GLS
2302 // stabilization
2303 strong_residual[q] -=
2304 // drag applied on fluid
2305 (-beta_drag * (velocity - average_particles_velocity)
2306 // other two-way coupling forces applied on the fluid
2307 + explicit_particle_volumetric_acceleration_on_fluid);
2308
2309 // Assembly of the right-hand side
2310 for (unsigned int i = 0; i < n_dofs; ++i)
2311 {
2312 const auto phi_u_i = scratch_data.phi_u[q][i];
2313
2314 local_rhs(i) +=
2315 // + drag applied on fluid
2316 (-beta_drag * (velocity - average_particles_velocity) +
2317 // + other two-way coupling forces applied on the fluid
2318 explicit_particle_volumetric_acceleration_on_fluid) *
2319 phi_u_i * JxW;
2320 }
2321 }
2322}
2323template class VANSAssemblerFPI<2>;
2324template class VANSAssemblerFPI<3>;
2325
2326template <int dim>
2327void
2329 const NavierStokesScratchData<dim> &scratch_data,
2331{
2332 // Loop and quadrature information
2333 const auto &JxW_vec = scratch_data.JxW;
2334 const unsigned int n_q_points = scratch_data.n_q_points;
2335 const unsigned int n_dofs = scratch_data.n_dofs;
2336 // The CFD-DEM solver only supports constant density for now
2337 const double density = scratch_data.density_scale;
2338
2339 // Copy data elements
2340 auto &strong_residual = copy_data.strong_residual;
2341 auto &strong_jacobian = copy_data.strong_jacobian;
2342 auto &local_matrix = copy_data.local_matrix;
2343
2344 // Loop over the quadrature points
2345 for (unsigned int q = 0; q < n_q_points; ++q)
2346 {
2347 const Tensor<1, dim> &two_way_coupling_force =
2348 -scratch_data.particle_two_way_coupling_force_values[q] / density;
2349 const Tensor<1, dim> &fluid_drag =
2350 -scratch_data.particle_drag_values[q] / density;
2351 const double &beta_drag =
2353 const Tensor<1, dim> particles_velocity =
2354 scratch_data.particle_velocity_values[q];
2355 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
2356
2357 // Store JxW in local variable for faster access;
2358 const double JxW = JxW_vec[q];
2359
2360 // Subtraction of forces applied on fluid from the residual for GLS
2361 // stabilization
2362 // If the coupling is explicit, beta_drag is zero. Otherwise, fluid_drag
2363 // is zero.
2364 strong_residual[q] -=
2365 (fluid_drag - beta_drag * (velocity - particles_velocity) +
2366 two_way_coupling_force);
2367
2368 for (unsigned int j = 0; j < n_dofs; ++j)
2369 {
2370 const auto &phi_u_j = scratch_data.phi_u[q][j];
2371 strong_jacobian[q][j] +=
2372 // Drag Force
2373 beta_drag * phi_u_j;
2374 }
2375
2376 for (unsigned int i = 0; i < n_dofs; ++i)
2377 {
2378 const auto &phi_u_i = scratch_data.phi_u[q][i];
2379
2380 for (unsigned int j = 0; j < n_dofs; ++j)
2381 {
2382 const auto &phi_u_j = scratch_data.phi_u[q][j];
2383
2384 local_matrix(i, j) += // Drag Force
2385 beta_drag * phi_u_j * phi_u_i * JxW;
2386 }
2387 }
2388 }
2389}
2390
2391template <int dim>
2392void
2394 const NavierStokesScratchData<dim> &scratch_data,
2396{
2397 // Loop and quadrature information
2398 const auto &JxW_vec = scratch_data.JxW;
2399 const unsigned int n_q_points = scratch_data.n_q_points;
2400 const unsigned int n_dofs = scratch_data.n_dofs;
2401 // The CFD-DEM solver only supports constant density for now
2402 const double density = scratch_data.density_scale;
2403
2404 // Copy data elements
2405 auto &strong_residual = copy_data.strong_residual;
2406 auto &local_rhs = copy_data.local_rhs;
2407
2408 // Loop over the quadrature points
2409 for (unsigned int q = 0; q < n_q_points; ++q)
2410 {
2411 const Tensor<1, dim> &two_way_coupling_force =
2412 -scratch_data.particle_two_way_coupling_force_values[q] / density;
2413 const Tensor<1, dim> &fluid_drag =
2414 -scratch_data.particle_drag_values[q] / density;
2415 const double &beta_drag =
2417 const Tensor<1, dim> particles_velocity =
2418 scratch_data.particle_velocity_values[q];
2419 const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
2420
2421 // Store JxW in local variable for faster access;
2422 const double JxW = JxW_vec[q];
2423
2424 // Calculate the strong residual for GLS stabilization
2425 // Drag Force and other two-way coupling forces
2426 // If the coupling is explicit, beta_drag is zero. Otherwise, fluid_drag
2427 // is zero.
2428 strong_residual[q] -=
2429 (fluid_drag - beta_drag * (velocity - particles_velocity) +
2430 two_way_coupling_force);
2431
2432 // Assembly of the right-hand side
2433 for (unsigned int i = 0; i < n_dofs; ++i)
2434 {
2435 const auto phi_u_i = scratch_data.phi_u[q][i];
2436 // Drag Force
2437 // The distinction between Model A and B of the VANS equations is
2438 // made in the shear and pressure forces assemblers.
2439 // If the coupling is explicit, beta_drag is zero. Otherwise,
2440 // fluid_drag is zero.
2441 local_rhs(i) +=
2442 (fluid_drag - beta_drag * (velocity - particles_velocity) +
2443 two_way_coupling_force) *
2444 phi_u_i * JxW;
2445 }
2446 }
2447}
2448template class VANSAssemblerFPIProjection<2>;
2449template class VANSAssemblerFPIProjection<3>;
unsigned int number_of_previous_solutions(const Parameters::SimulationControl::TimeSteppingMethod method)
Get the number of previous time steps for a specific BDF scheme.
Definition bdf.h:97
Class that stores the information required by the assembly procedure for a Navier-Stokes equation....
std::vector< Tensor< 1, dim > > force
std::vector< velocity_curl_type_2d > fluid_velocity_curls_at_particle_location_2d
std::vector< Tensor< 1, dim > > void_fraction_gradient_values
std::vector< std::vector< Tensor< 1, dim > > > previous_velocity_values
std::vector< unsigned int > components
std::vector< double > cell_void_fraction
std::vector< Tensor< 2, dim > > velocity_gradients
std::vector< Tensor< 1, dim > > particle_two_way_coupling_force_values
std::vector< Tensor< 1, dim > > fluid_particle_relative_velocity_at_particle_location
std::vector< double > particle_momentum_transfer_coefficient_values
Table< 2, Tensor< 1, dim > > phi_u
std::vector< double > void_fraction_values
std::vector< Tensor< 1, dim > > particle_velocity_values
std::vector< double > kinematic_viscosity
std::vector< Tensor< 1, dim > > velocity_values
Table< 2, Tensor< 2, dim > > grad_phi_u
std::vector< velocity_curl_type_3d > fluid_velocity_curls_at_particle_location_3d
Particles::ParticleHandler< dim >::particle_iterator_range pic
Table< 2, Tensor< 1, dim > > laplacian_phi_u
std::vector< std::vector< double > > previous_void_fraction_values
std::vector< Tensor< 1, dim > > velocity_gradient_divergence
std::vector< Tensor< 1, dim > > particle_drag_values
std::vector< Tensor< 1, dim > > fluid_velocity_laplacian_at_particle_location
std::vector< double > velocity_divergences
std::vector< double > density_at_particle_location
std::vector< double > kinematic_viscosity_at_particle_location
Table< 2, Tensor< 1, dim > > grad_phi_p
std::vector< Tensor< 1, dim > > pressure_gradients
Tensor< 1, dim > explicit_particle_volumetric_acceleration_on_fluid
std::vector< Tensor< 1, dim > > fluid_pressure_gradients_at_particle_location
Table< 2, Tensor< 1, dim > > gradient_divergence_phi_u
std::vector< Tensor< 1, dim > > velocity_laplacians
const PhysicalPropertiesManager properties_manager
Class responsible for storing the information calculated using the assembly of stabilized Tensor<1,...
Definition copy_data.h:166
FullMatrix< double > local_matrix
Definition copy_data.h:204
std::vector< Tensor< 1, dim > > strong_residual
Definition copy_data.h:207
std::vector< std::vector< Tensor< 1, dim > > > strong_jacobian
Definition copy_data.h:208
Assembler for the transient term arising from BDF time integration for the VANS equations.
virtual void assemble_matrix(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the matrix.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
virtual void assemble_rhs(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the right-hand side.
const std::shared_ptr< SimulationControl > simulation_control
Shared pointer to the simulation control object.
Assembler for the drag force using the Beetstra model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Beetstra model....
Assembler for the buoyancy force on particles in the VANS equations.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the buoyancy force on particles.
const Tensor< 1, 3 > gravity
Gravity acceleration applied to the particles.
Assembler for the core of Model A of the Volume-Averaged Navier-Stokes (VANS) equations.
const bool SUPG
Flag indicating whether SUPG stabilization is used.
const std::shared_ptr< SimulationControl > simulation_control
Shared pointer to the simulation control object.
virtual void assemble_rhs(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the right-hand side.
virtual void assemble_matrix(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the matrix.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
Assembler for the core of Model B of the Volume-Averaged Navier-Stokes (VANS) equations.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
const std::shared_ptr< SimulationControl > simulation_control
Shared pointer to the simulation control object.
virtual void assemble_matrix(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the matrix.
const bool SUPG
Flag indicating whether SUPG stabilization is used.
virtual void assemble_rhs(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the right-hand side.
Assembler for the drag force using the Dallavalle model.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Dallavalle model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
Assembler for the drag force using the Di Felice model.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Di Felice model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
Assembler for the fluid-particle interactions (FPI) in the VANS equations when the forces are project...
virtual void assemble_rhs(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the right-hand side.
virtual void assemble_matrix(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the matrix.
Assembler for the fluid-particle interactions (FPI) in the VANS equations, such as the drag force.
virtual void assemble_matrix(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the matrix.
virtual void assemble_rhs(const NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > &copy_data) override
Assemble the right-hand side.
Assembler for the drag force using the Gidaspow model.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Gidaspow model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
Assembler for the drag force using the Koch and Hill drag model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Koch-Hill model.
Assembler for the lift force using the Magnus model.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the Magnus lift force on particles.
Assembler for the pressure force on particles.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the pressure force on particles.
Assembler for the drag force using the Rong model.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the particle-fluid interactions resulting from drag, using the Rong model.
Assembler for the lift force using the Saffman-Mei model.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the Saffman-Mei lift force on particles.
Assembler for the shear force on particles.
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the shear force on particles.
const Parameters::CFDDEM cfd_dem
CFD-DEM simulation parameters.
Assembler for the viscous dissipative torque due to particle rotation as defined by Derksen (2004).
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the viscous torque dissipation on particles.
Assembler for the viscous dissipative torque due to fluid vorticity as defined by Derksen (2004).
virtual void calculate_particle_fluid_interactions(NavierStokesScratchData< dim > &scratch_data) override
Calculate the vortical torque on particles.
@ velocity
Velocity vector field from fluid dynamics.
@ pressure
Pressure scalar field from fluid dynamics.
@ void_fraction
PropertiesIndex
Particle property indices for CFD-DEM multiphysics simulations.
PropertiesIndex
Particle property indices for CFD-DEM simulations.
@ modelA
Model A: volume-averaged continuity and momentum equations.
@ modelB
Model B: alternative VANS formulation.
@ semi_implicit
Semi-implicit drag coupling.
@ fully_implicit
Fully implicit drag coupling.
Simulation control classes for managing time-stepping and iteration control in Lethe.
double calculate_navier_stokes_gls_tau_transient(const double u_mag, const double kinematic_viscosity, const double h, const double sdt)
Calculate the stabilization parameter for the transient Navier-Stokes equations.
double calculate_navier_stokes_gls_tau_steady(const double u_mag, const double kinematic_viscosity, const double h)
Calculate the stabilization parameter for the Navier-Stokes equations in steady-state.
Assemblers for the Volume-Averaged Navier-Stokes (VANS) equations.
double calculate_gamma(double velocity, double kinematic_viscosity, double, double c_star)
Calculate the grad-div stabilization constant for the VANS equations.