1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
Loading...
Searching...
No Matches
richardson.hpp
Go to the documentation of this file.
1#pragma once
2/**
3 * @file richardson.hpp
4 * @brief Richardson explicit (central time - central space) scheme for the 1D heat equation.
5 */
6
7#include "../grid.hpp"
8#include "../method.hpp"
9#include <string>
10#include <vector>
11
12/**
13 * @class Richardson
14 * @brief Implementation of the explicit Richardson scheme (CTCS).
15 *
16 * The scheme reads:
17 * \f[
18 * T_i^{n+1} = T_i^{n-1} + 2 r \left( T_{i+1}^n - 2 T_i^n + T_{i-1}^n \right),
19 * \quad r = \frac{D \, \Delta t}{\Delta x^2}
20 * \f]
21 *
22 * It is a three-level scheme, therefore it requires both \f$T^{n-1}\f$ and \f$T^n\f$
23 * to produce \f$T^{n+1}\f$. Boundary conditions are not enforced here, but left
24 * to the solver.
25 */
26class Richardson : public Method
27{
28 public:
29 /**
30 * @brief Indicate that this is a three-level scheme.
31 * @return true always, since Richardson needs \f$T^{n-1}\f$.
32 */
33 bool uses_previous_step() const noexcept override
34 {
35 return true;
36 }
37
38 /**
39 * @brief Get human-readable name of the scheme.
40 * @return "Richardson"
41 */
42 std::string name() const override
43 {
44 return "Richardson";
45 }
46
47 /**
48 * @brief Advance one time step using the Richardson explicit scheme.
49 *
50 * This computes \f$T^{n+1}\f$ from \f$T^{n}\f$ and \f$T^{n-1}\f$.
51 * Interior nodes \f$i = 1, \dots, N-2\f$ are updated, while boundary
52 * nodes are left untouched (the solver will impose Dirichlet BCs).
53 *
54 * @param g Grid metadata (spacing and number of nodes)
55 * @param D Diffusivity [cm^2/h]
56 * @param dt Time step [h]
57 * @param Tprev Temperature field at previous time layer \f$T^{n-1}\f$
58 * @param Tcurr Temperature field at current time layer \f$T^{n}\f$
59 * @param Tnext Output temperature field to be filled with \f$T^{n+1}\f$
60 */
61 void step(const Grid& g,
62 double D,
63 double dt,
64 const std::vector<double>& Tprev,
65 const std::vector<double>& Tcurr,
66 std::vector<double>& Tnext) const override;
67};
Abstract interface for time-integration schemes solving the 1D heat equation.
Definition method.hpp:28
Implementation of the explicit Richardson scheme (CTCS).
void step(const Grid &g, double D, double dt, const std::vector< double > &Tprev, const std::vector< double > &Tcurr, std::vector< double > &Tnext) const override
Advance one time step using the Richardson explicit scheme.
bool uses_previous_step() const noexcept override
Indicate that this is a three-level scheme.
std::string name() const override
Get human-readable name of the scheme.
Uniform 1D spatial grid.
Uniform 1D grid on x ∈ [0, L], including both boundary nodes.
Definition grid.hpp:15