Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
qmom_field_function.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4/**
5 * @file qmom_field_function.h
6 * @brief Vector-valued function of the fields of the quadrature method of
7 * moments (QMOM) physics: the scalars and the raw moments of a particle size
8 * distribution, computed with the QMOMKit library.
9 */
10
11#ifndef lethe_qmom_field_function_h
12#define lethe_qmom_field_function_h
13
15
16#include <deal.II/base/exceptions.h>
17#include <deal.II/base/function.h>
18#include <deal.II/base/point.h>
19
20#include <deal.II/lac/vector.h>
21
22#include <string>
23#include <vector>
24
25using namespace dealii;
26
27/**
28 * @brief Exception thrown when the QMOM physics is enabled but Lethe was not
29 * linked with QMOMKit.
30 */
32 QMOMWithoutQMOMKitError,
33 "The \"qmom\" physics is enabled, but Lethe was compiled without QMOMKit. "
34 "Reconfigure Lethe with -DLETHE_WITH_QMOMKIT=ON and "
35 "-DQMOMKIT_DIR=/path/to/qmomkit/installation to use this physics.");
36
37/**
38 * @brief Function of all the QMOM fields, built from the functions of the
39 * scalars and from the particle size distribution.
40 *
41 * It has one component per field, n_scalars + n_moments components in total.
42 * The scalars come first, then the moments:
43 * - components 0 to n_scalars - 1 are the scalars: component c is scalar c;
44 * - components n_scalars to n_scalars + n_moments - 1 are the moments:
45 * component c is the moment M_k, with k = c - n_scalars.
46 *
47 * For example, with 2 scalars and 4 moments, components 0 and 1 are the
48 * scalars 0 and 1, and components 2, 3, 4 and 5 are the moments M_0, M_1, M_2
49 * and M_3. Without scalars, component c is the moment M_c.
50 *
51 * Scalar c is given by expression c of the scalars function, so the scalar
52 * expressions must be given in the same order as the scalar names.
53 *
54 * The moments are the raw moments of the particle size distribution, scaled by
55 * the number density: M_k = n E[L^k], where n is the number density in
56 * particles per m^3 and L the particle size in m. They are computed
57 * analytically by QMOMKit, and are all zero if the distribution type is none.
58 *
59 * @tparam dim Number of spatial dimensions.
60 */
61template <int dim>
62class QMOMFieldFunction : public Function<dim>
63{
64public:
65 /**
66 * @brief Constructor. Verifies that the scalars function has one component
67 * per scalar, unless there are no scalars, and that QMOMKit is available if
68 * the moments are computed from a particle size distribution.
69 *
70 * @param[in] functions Functions of the scalars and particle size
71 * distribution.
72 * @param[in] n_scalars Number of scalars transported by the QMOM physics.
73 * @param[in] n_moments Number of moments transported by the QMOM physics.
74 * @param[in] description Description of the functions (e.g. "initial
75 * conditions"), used in the error message.
76 */
78 const unsigned int n_scalars,
79 const unsigned int n_moments,
80 const std::string &description);
81
82 /**
83 * @brief Evaluate one component of the function: scalar component if
84 * component < n_scalars, moment M_{component - n_scalars} otherwise.
85 *
86 * Evaluating a moment computes all the moments at p. Use vector_value() to
87 * evaluate several moments at the same point.
88 *
89 * @param[in] p Point at which the function is evaluated.
90 * @param[in] component Index of the field, between 0 and
91 * n_scalars + n_moments - 1 (see the class description).
92 *
93 * @return Value of the component at p.
94 */
95 double
96 value(const Point<dim> &p, const unsigned int component) const override;
97
98 /**
99 * @brief Evaluate all the components of the function. The moments are
100 * computed once for all of them.
101 *
102 * @param[in] p Point at which the function is evaluated.
103 * @param[out] values Values of all the components at p, of size
104 * n_scalars + n_moments: values[i] is scalar i for i < n_scalars and
105 * values[n_scalars + k] is the moment M_k.
106 */
107 void
108 vector_value(const Point<dim> &p, Vector<double> &values) const override;
109
110 /**
111 * @brief Evaluate the scalars only, indexed from 0 regardless of the
112 * moments.
113 *
114 * @param[in] p Point at which the function is evaluated.
115 * @param[out] values Values of the scalars at p, of size n_scalars:
116 * values[i] is scalar i.
117 */
118 void
119 scalar_values(const Point<dim> &p, Vector<double> &values) const;
120
121 /**
122 * @brief Evaluate the moments only, indexed from 0 regardless of the
123 * scalars. The moments are computed once for all of them.
124 *
125 * @param[in] p Point at which the function is evaluated.
126 * @param[out] values Values of the moments at p, of size n_moments:
127 * values[k] is the moment M_k.
128 */
129 void
130 moment_values(const Point<dim> &p, Vector<double> &values) const;
131
132 /**
133 * @brief Set the time of the function and of the underlying functions.
134 *
135 * @param[in] new_time New time.
136 */
137 void
138 set_time(const double new_time) override;
139
140private:
141 /**
142 * @brief Compute the raw moments of the particle size distribution at a
143 * point.
144 *
145 * @param[in] p Point at which the distribution is evaluated.
146 *
147 * @return Raw moments M_0 to M_{n_moments - 1}.
148 */
149 std::vector<double>
150 compute_moments(const Point<dim> &p) const;
151
152 /// Functions of the scalars and particle size distribution
154
155 /// Number of scalars
156 const unsigned int n_scalars;
157
158 /// Number of moments
159 const unsigned int n_moments;
160};
161
162#endif
double value(const Point< dim > &p, const unsigned int component) const override
Evaluate one component of the function: scalar component if component < n_scalars,...
void vector_value(const Point< dim > &p, Vector< double > &values) const override
Evaluate all the components of the function. The moments are computed once for all of them.
Parameters::QMOMFunctions< dim > functions
Functions of the scalars and particle size distribution.
const unsigned int n_scalars
Number of scalars.
void moment_values(const Point< dim > &p, Vector< double > &values) const
Evaluate the moments only, indexed from 0 regardless of the scalars. The moments are computed once fo...
void set_time(const double new_time) override
Set the time of the function and of the underlying functions.
QMOMFieldFunction(const Parameters::QMOMFunctions< dim > &functions, const unsigned int n_scalars, const unsigned int n_moments, const std::string &description)
Constructor. Verifies that the scalars function has one component per scalar, unless there are no sca...
const unsigned int n_moments
Number of moments.
std::vector< double > compute_moments(const Point< dim > &p) const
Compute the raw moments of the particle size distribution at a point.
void scalar_values(const Point< dim > &p, Vector< double > &values) const
Evaluate the scalars only, indexed from 0 regardless of the moments.
DeclExceptionMsg(QMOMWithoutQMOMKitError, "The \"qmom\" physics is enabled, but Lethe was compiled without QMOMKit. " "Reconfigure Lethe with -DLETHE_WITH_QMOMKIT=ON and " "-DQMOMKIT_DIR=/path/to/qmomkit/installation to use this physics.")
Exception thrown when the QMOM physics is enabled but Lethe was not linked with QMOMKit.
Functions of space and time prescribing the fields of the QMOM physics. They are used for the initial...