Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
analytical_solutions.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2019, 2021, 2023-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_analytical_solutions_h
5#define lethe_analytical_solutions_h
6
7#include <core/parameters.h>
9
10#include <deal.II/base/function.h>
11#include <deal.II/base/parsed_function.h>
12
13using namespace dealii;
14
15
16/**
17 * @brief Contains all the classes related to the calculation of the analytical solutions
18 * for the various physics.
19 **/
20
22{
23
24 /**
25 * @brief Implements analytical solutions for the Navier-Stokes equations
26 * and the other physics supported by lethe
27 *
28 * @tparam dim An integer that denotes the dimension of the space in which
29 * the flow is solved.
30
31 * The analytical solution class provides an all common
32 * element required for the calculation of analytical solution for all the
33 * physics supported by Lethe.
34 **/
35 template <int dim>
37 {
38 private:
39 /**
40 * Establishes if the calculation of the analytical solution is enabled or
41 * not
42 */
43 bool enable = false;
44
45 /**
46 * Filename used to store the L2 norm of the error
47 */
48 std::string filename = "L2Error";
49
50
51 /**
52 * @brief Construct a new AnalyticalSolution object.
53 *
54 * The constructor automatically sets the number of components
55 * of each equation manually since all equations currently supported have
56 * a set number of equations.
57 */
58 public:
60 : uvwp(dim + 1)
61 , temperature(1)
62 , tracer(1)
63 , cahn_hilliard(2)
64 , electromagnetics(4 * dim) // The 4 components correspond to the real and
65 // imaginary parts of E and H
66 {}
67
68 /**
69 * @brief Declare the parameters required by the analytical solution
70 * within a parameter file
71 *
72 * @param[in,out] prm The parameter handler object.
73 *
74 */
75 virtual void
76 declare_parameters(ParameterHandler &prm);
77
78 /**
79 * @brief Parse the parameters required by the analytical solution
80 * within a parameter file
81 *
82 * @param[in] prm The parameter handler object.
83 *
84 */
85 virtual void
86 parse_parameters(ParameterHandler &prm);
87
88 /**
89 * @brief Checks if the calculation of the error using the analytical
90 * solution is enabled. This option is there to prevent unnecessary
91 * calculations when no analytical solutions are required.
92 */
93 bool
95 {
96 return enable;
97 }
98
99
100 /**
101 * @brief Enables the usage of the analytical solution
102 */
103 void
104 set_enable(bool is_enable)
105 {
106 enable = is_enable;
107 }
108
109 /**
110 * @brief Get the file name associated with the output of the
111 * L2 norm of the error calculated using the analytical solution.
112 *
113 * @return filename A string that contains the filename used to output
114 * the L2 norm of the error.
115 */
116 std::string
118 {
119 return filename;
120 }
121
122
123 /**
124 * Controls if the L2 norm of the error is printed to the terminal
125 * during the simulation.
126 */
128
129 /**
130 * ParsedFunction that contains the analytical solution for the velocity
131 * components and the pressure.
132 */
133 Functions::ParsedFunction<dim> uvwp;
134
135 /**
136 * ParsedFunction that contains the analytical solution for the temperature.
137 */
138 Functions::ParsedFunction<dim> temperature;
139
140 /**
141 * ParsedFunction that contains the analytical solution for the tracer.
142 */
143 Functions::ParsedFunction<dim> tracer;
144
145 /**
146 * Functions that contain the analytical solution for the fields of the
147 * QMOM physics.
148 */
150
151 /**
152 * ParsedFunction that contains the analytical solution for the phase.
153 */
154 Functions::ParsedFunction<dim> phase;
155
156 /**
157 * ParsedFunction that contains the analytical solution for the phase order
158 * and the chemical potential.
159 */
160 Functions::ParsedFunction<dim> cahn_hilliard;
161
162 /**
163 * ParsedFunction that contains the analytical solution for the electric
164 * and magnetic fields (real and imaginary parts).
165 */
166 Functions::ParsedFunction<dim> electromagnetics;
167 };
168} // namespace AnalyticalSolutions
169
170#endif
Functions::ParsedFunction< dim > cahn_hilliard
Parameters::QMOMFunctions< dim > qmom
Functions::ParsedFunction< dim > temperature
virtual void declare_parameters(ParameterHandler &prm)
Declare the parameters required by the analytical solution within a parameter file.
void set_enable(bool is_enable)
Enables the usage of the analytical solution.
Functions::ParsedFunction< dim > electromagnetics
Functions::ParsedFunction< dim > phase
std::string get_filename()
Get the file name associated with the output of the L2 norm of the error calculated using the analyti...
Functions::ParsedFunction< dim > uvwp
Functions::ParsedFunction< dim > tracer
virtual void parse_parameters(ParameterHandler &prm)
Parse the parameters required by the analytical solution within a parameter file.
bool calculate_error()
Checks if the calculation of the error using the analytical solution is enabled. This option is there...
AnalyticalSolution()
Construct a new AnalyticalSolution object.
Contains all the classes related to the calculation of the analytical solutions for the various physi...
Functions of space and time prescribing the fields of the QMOM physics. They are used for the initial...