Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
fluid_dynamics_vans_matrix_free_operators.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_fluid_dynamics_vans_matrix_free_operators_h
5#define lethe_fluid_dynamics_vans_matrix_free_operators_h
6
8
10
11using namespace dealii;
12
13/**
14 * @brief Implements the matrix-free operator for the VANS equations
15 *
16 * @tparam dim An integer that denotes the number of spatial dimensions.
17 * @tparam number Abstract type for number across the class (i.e., double).
18 */
19template <int dim, typename number>
20class VANSOperator : public NavierStokesOperatorBase<dim, number>
21{
22public:
23 using FECellIntegrator = FEEvaluation<dim, -1, 0, dim + 1, number>;
24 using FEFaceIntegrator = FEFaceEvaluation<dim, -1, 0, dim + 1, number>;
25 using VectorType = LinearAlgebra::distributed::Vector<number>;
26
27
28 /**
29 * @brief Constructor for the VANS operator
30 *
31 * @param[in] cfd_dem_parameters The CFD-DEM parameters used for the
32 * simulation. These parameters are notably used to distinguish between
33 * model A and model B as well as to establish grad-div stabilization.
34 */
36 : NavierStokesOperatorBase<dim, number>()
38 {
39 AssertThrow(
40 this->cfd_dem_parameters.vans_model == Parameters::VANSModel::modelA,
41 ExcMessage(
42 "Only model A of the VANS equation is supported by the VANS matrix-free solver"));
43 }
44
45 /**
46 * @brief Compute the void fraction at the fluid quadrature point.
47 * This essentially calculates the void fraction, the void fraction
48 * gradient and the time derivative of the void fraction.
49 *
50 * @param[in] void_fraction_dof_handler The dof handler associated with the
51 * void fraction
52 *
53 * @param[in] void_fraction_solution The solution of the void fraction
54 *
55 * @param[in] time_derivative_void_fraction_solution The time derivative of
56 * the void fraction.
57 *
58 */
59 void
61 const DoFHandler<dim> &void_fraction_dof_handler,
62 const LinearAlgebra::distributed::Vector<double> &void_fraction_solution,
63 const LinearAlgebra::distributed::Vector<double>
64 &time_derivative_void_fraction_solution);
65
66 /**
67 * @brief Compute the terms required to assemble the particle-fluid forces at
68 * the gauss points. The function gathers the particle-fluid force (without
69 * drag), the particle-fluid drag and the particle velocity. The function
70 * assumes that the all of the fields gathered from the projectors are the
71 * forces acting on the particles due to the fluid. Consequently, since this
72 * aims to gather the forces that apply on the fluid due to the particles, a
73 * (-) multiplicator is applied during the gathering stage. With these three
74 * elements, the full particle-fluid coupling and its jacobian can be
75 * established within the matrix-free operator.
76 *
77 * @param[in] fp_force_dof_handler The dof handler associated with the
78 * particle-fluid forces.
79 * @param[in] fp_force_solution The solution of the particle-fluid forces.
80 * @param[in] fp_drag_dof_handler The dof handler associated with the
81 * drag force.
82 * @param[in] fp_drag_solution The solution of the drag force.
83 * @param[in] particle_velocity_dof_handler The dof handler associated with
84 * the particle velocity.
85 * @param[in] particle_velocity_solution The solution of the particle
86 * velocity.
87 * @param[in] momentum_transfer_coefficient_dof_handler The dof handler
88 * associated with the momentum transfer coefficient.
89 * @param[in] momentum_transfer_coefficient_solution The solution of the
90 * momentum transfer coefficient.
91 *
92 */
93 void
95 const DoFHandler<dim> &fp_force_dof_handler,
96 const LinearAlgebra::distributed::Vector<double> &fp_force_solution,
97 const DoFHandler<dim> &fp_drag_dof_handler,
98 const LinearAlgebra::distributed::Vector<double> &fp_drag_solution,
99 const DoFHandler<dim> &particle_velocity_dof_handler,
100 const LinearAlgebra::distributed::Vector<double>
101 &particle_velocity_solution,
102 const DoFHandler<dim> &momentum_transfer_coefficient_dof_handler,
103 const LinearAlgebra::distributed::Vector<double>
104 &momentum_transfer_coefficient_solution);
105
106 /**
107 * @brief Precompute the forcing term at the quadrature points. In addition to
108 * the momentum forcing term, this also precomputes the mass source term,
109 * which is the last component of the forcing function. As in the
110 * matrix-based solvers, the mass source term is added to the continuity
111 * equation and its momentum (mass source times velocity) is added to the
112 * momentum equation.
113 */
114 void
115 compute_forcing_term() override;
116
117protected:
118 /**
119 * @brief Store relevant values of the vector of the last newton step to use it
120 * in the Jacobian and pre-calculate the stabilization parameters tau and
121 * gamma.
122 *
123 * @param[in] newton_step Vector of the last newton step.
124 */
125 virtual void
127 const VectorType &newton_step) override;
128
129 /**
130 * @brief Perform cell integral on a cell batch without gathering and scattering
131 * the values, and according to the Jacobian of the discretized
132 * steady/transient VANS equations with stabilization.
133 *
134 * @param[in] integrator FEEvaluation object that allows to evaluate functions
135 * at quadrature points and perform cell integrations.
136 */
137 void
138 do_cell_integral_local(FECellIntegrator &integrator) const override;
139
140 /**
141 * @brief Perform cell integral on a cell batch with gathering and scattering
142 * the values, and according to the residual of the discretized
143 * steady/transient VANS equations with stabilization.
144 *
145 * @param[in] matrix_free Object that contains all data.
146 * @param[in,out] dst Global vector where the final result is added.
147 * @param[in] src Input vector with all values in all cells.
148 * @param[in] range Range of the cell batch.
149 */
150 void
152 const MatrixFree<dim, number> &matrix_free,
153 VectorType &dst,
154 const VectorType &src,
155 const std::pair<unsigned int, unsigned int> &range) const override;
156
157 /// Table with correct alignment for vectorization to store the values of the
158 /// void fraction
159 Table<2, VectorizedArray<number>> void_fraction;
160
161 /// Table with correct alignment for vectorization to store the values of the
162 /// void fraction gradient
163 Table<2, Tensor<1, dim, VectorizedArray<number>>> void_fraction_gradient;
164
165 /// Table with correct alignment for vectorization to store the values of the
166 /// time derivative of the void fraction
167 Table<2, VectorizedArray<number>> time_derivative_void_fraction;
168
169 /// Table with correct alignment for vectorization to store the values of the
170 /// mass source term, which is the last component of the forcing function
171 Table<2, VectorizedArray<number>> mass_source_terms;
172
173 /// Table with correct alignment for vectorization to store the values of the
174 /// particle-fluid forces (without drag). These are the volumetric forces
175 /// applied on the fluid by the particles, that is minus the projected
176 /// hydrodynamic forces applied on the particles, divided by the fluid
177 /// density.
178 Table<2, Tensor<1, dim, VectorizedArray<number>>> particle_fluid_force;
179
180 /// Table with correct alignment for vectorization to store the values of the
181 /// particle-fluid drag. The drag force in this table is volumetric, resulting
182 /// from the projection used, applied on the fluid by the particles and
183 /// divided by the fluid density. It is only gathered for an explicit drag
184 /// coupling.
185 Table<2, Tensor<1, dim, VectorizedArray<number>>> particle_fluid_drag;
186
187 /// Table with correct alignment for vectorization to store the values of the
188 /// particle velocity.
189 Table<2, Tensor<1, dim, VectorizedArray<number>>> particle_velocity;
190
191 /// Table with correct alignment for vectorization to store the values of the
192 /// momentum transfer coefficient.
193 Table<2, VectorizedArray<number>> momentum_transfer_coefficient;
194
195 /// Table with correct alignment for vectorization to store the values of the
196 /// grad-div gamma parameter
197 Table<2, VectorizedArray<number>> grad_div_gamma;
198
199 /// Internal copy of the CFD-DEM parameters. This is used for grad-div
200 /// stabilization and the drag coupling, but also to ensure that model A of
201 /// the VANS equations is used, since model B is not supported.
203};
204
205#endif
MatrixFree< dim, number > matrix_free
Object storing all the relevant data needed for the matrix free implementation.
void local_evaluate_residual(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const override
Perform cell integral on a cell batch with gathering and scattering the values, and according to the ...
void compute_particle_fluid_interaction(const DoFHandler< dim > &fp_force_dof_handler, const LinearAlgebra::distributed::Vector< double > &fp_force_solution, const DoFHandler< dim > &fp_drag_dof_handler, const LinearAlgebra::distributed::Vector< double > &fp_drag_solution, const DoFHandler< dim > &particle_velocity_dof_handler, const LinearAlgebra::distributed::Vector< double > &particle_velocity_solution, const DoFHandler< dim > &momentum_transfer_coefficient_dof_handler, const LinearAlgebra::distributed::Vector< double > &momentum_transfer_coefficient_solution)
Compute the terms required to assemble the particle-fluid forces at the gauss points....
void compute_forcing_term() override
Precompute the forcing term at the quadrature points. In addition to the momentum forcing term,...
LinearAlgebra::distributed::Vector< number > VectorType
Table< 2, VectorizedArray< number > > grad_div_gamma
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > particle_fluid_force
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > particle_velocity
Table< 2, VectorizedArray< number > > time_derivative_void_fraction
VANSOperator(const Parameters::CFDDEM &cfd_dem_parameters)
Constructor for the VANS operator.
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > void_fraction_gradient
const Parameters::CFDDEM cfd_dem_parameters
Table< 2, VectorizedArray< number > > momentum_transfer_coefficient
FEEvaluation< dim, -1, 0, dim+1, number > FECellIntegrator
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > particle_fluid_drag
Table< 2, VectorizedArray< number > > mass_source_terms
void do_cell_integral_local(FECellIntegrator &integrator) const override
Perform cell integral on a cell batch without gathering and scattering the values,...
FEFaceEvaluation< dim, -1, 0, dim+1, number > FEFaceIntegrator
Table< 2, VectorizedArray< number > > void_fraction
virtual void evaluate_non_linear_term_and_calculate_tau(const VectorType &newton_step) override
Store relevant values of the vector of the last newton step to use it in the Jacobian and pre-calcula...
void compute_void_fraction(const DoFHandler< dim > &void_fraction_dof_handler, const LinearAlgebra::distributed::Vector< double > &void_fraction_solution, const LinearAlgebra::distributed::Vector< double > &time_derivative_void_fraction_solution)
Compute the void fraction at the fluid quadrature point. This essentially calculates the void fractio...
@ modelA
Model A: volume-averaged continuity and momentum equations.
Parameters for the CFD-DEM coupled solver.
VANSModel vans_model
Volume-Averaged Navier-Stokes model formulation.
GlobalVectorType VectorType