Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
source_terms.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2019-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4// TODO : Refactor so the class itself is not a pointer, but contains a pointer
5// to a function. This would be a lot more coherent...
6
7#ifndef lethe_source_terms_h
8#define lethe_source_terms_h
9
11
12#include <deal.II/base/function.h>
13#include <deal.II/base/parameter_handler.h>
14#include <deal.II/base/parsed_function.h>
15
16#include <memory>
17
18using namespace dealii;
19/**
20 * The source term class provides an interface for all common
21 * Element required for the introduction of a source term in equations
22 * All equation-specific source term should derive
23 * from the base class but also call it's declare_parameters and
24 * parse_parameters routine. This allows specialized classes to focus on their
25 * specificity and forget about other non-specific elements that are generic to
26 * the calculation of analytical solutions
27 **/
28
29namespace SourceTerms
30{
31 template <int dim>
33 {
34 public:
36 {
38 std::make_shared<Functions::ParsedFunction<dim>>(dim + 1);
40 std::make_shared<Functions::ParsedFunction<dim>>(1);
41 tracer_source = std::make_shared<Functions::ParsedFunction<dim>>(1);
43 std::make_shared<Functions::ParsedFunction<dim>>(2);
44 }
45
46 /**
47 * @brief Declares parameters for the source terms.
48 *
49 * @param[in,out] prm The parameter handler object.
50 */
51 virtual void
52 declare_parameters(ParameterHandler &prm);
53
54 /**
55 * @brief Parses parameters for the source terms.
56 *
57 * @param[in] prm The parameter handler object.
58 */
59 virtual void
60 parse_parameters(ParameterHandler &prm);
61
62 /// Enable the Navier-Stokes source term
63 bool enable = true;
64
65 /// Velocity-pressure components
66 std::shared_ptr<Functions::ParsedFunction<dim>> navier_stokes_source;
67
68 /// Heat transfer source
69 std::shared_ptr<Functions::ParsedFunction<dim>> heat_transfer_source;
70
71 /// Tracer source
72 std::shared_ptr<Functions::ParsedFunction<dim>> tracer_source;
73
74 /// Cahn-Hilliard source
75 std::shared_ptr<Functions::ParsedFunction<dim>> cahn_hilliard_source;
76
77 /// QMOM source: scalars and particle size distribution of the moments
79 };
80
81 template <int dim>
82 void
84 {
85 prm.enter_subsection("source term");
86
87 prm.enter_subsection("fluid dynamics");
88 prm.declare_entry("enable",
89 Patterns::Tools::Convert<bool>::to_string(enable),
90 Patterns::Bool(),
91 "Enable the usage of a source term for the fluid solver");
92 navier_stokes_source->declare_parameters(prm, dim + 1);
93 prm.leave_subsection();
94
95 prm.enter_subsection("heat transfer");
96 heat_transfer_source->declare_parameters(prm);
97 prm.leave_subsection();
98
99 prm.enter_subsection("tracer");
100 tracer_source->declare_parameters(prm);
101 prm.leave_subsection();
102
103 prm.enter_subsection("cahn hilliard");
104 cahn_hilliard_source->declare_parameters(prm, 2);
105 prm.leave_subsection();
106
107 prm.enter_subsection("QMOM");
109 prm.leave_subsection();
110
111 prm.leave_subsection();
112 }
113
114 template <int dim>
115 void
117 {
118 prm.enter_subsection("source term");
119
120 prm.enter_subsection("fluid dynamics");
121 enable = prm.get_bool("enable");
122 navier_stokes_source->parse_parameters(prm);
123 prm.leave_subsection();
124
125 prm.enter_subsection("heat transfer");
126 heat_transfer_source->parse_parameters(prm);
127 prm.leave_subsection();
128
129 prm.enter_subsection("tracer");
130 tracer_source->parse_parameters(prm);
131 prm.leave_subsection();
132
133 prm.enter_subsection("cahn hilliard");
134 cahn_hilliard_source->parse_parameters(prm);
135 prm.leave_subsection();
136
137 prm.enter_subsection("QMOM");
138 qmom_source.parse_parameters(prm);
139 prm.leave_subsection();
140
141 prm.leave_subsection();
142 }
143} // namespace SourceTerms
144
145
146#endif
std::shared_ptr< Functions::ParsedFunction< dim > > tracer_source
Tracer source.
std::shared_ptr< Functions::ParsedFunction< dim > > heat_transfer_source
Heat transfer source.
std::shared_ptr< Functions::ParsedFunction< dim > > cahn_hilliard_source
Cahn-Hilliard source.
virtual void declare_parameters(ParameterHandler &prm)
Declares parameters for the source terms.
std::shared_ptr< Functions::ParsedFunction< dim > > navier_stokes_source
Velocity-pressure components.
bool enable
Enable the Navier-Stokes source term.
Parameters::QMOMFunctions< dim > qmom_source
QMOM source: scalars and particle size distribution of the moments.
virtual void parse_parameters(ParameterHandler &prm)
Parses parameters for the source terms.
Functions of space and time prescribing the fields of the QMOM physics. They are used for the initial...
static void declare_parameters(ParameterHandler &prm)
Declare the "scalars" and "distribution" subsections in the current subsection. All the functions are...