1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
Loading...
Searching...
No Matches
method.cpp
Go to the documentation of this file.
1/**
2 * @file method.cpp
3 * @brief Factory implementation for numerical schemes.
4 */
5
6#include "method.hpp"
7
8// Include headers for ALL specific schemes
11#include "methods/laasonen.hpp"
13#include <memory>
14#include <stdexcept>
15
16// =============================================================================
17// FACTORY FUNCTION
18// =============================================================================
19
20/**
21 * @brief Build a concrete numerical method from the requested scheme kind.
22 *
23 * @param scheme Identifier of the requested scheme.
24 * @return std::unique_ptr<Method> Owning pointer to the created scheme.
25 * @throws std::invalid_argument if the scheme is not supported.
26 */
27std::unique_ptr<Method> make_method(SchemeKind scheme)
28{
29 switch (scheme)
30 {
32 return std::make_unique<Laasonen>();
33
35 return std::make_unique<DuFortFrankel>();
36
38 return std::make_unique<Richardson>();
39
41 return std::make_unique<CrankNicolson>();
42
43 default:
44 throw std::invalid_argument("make_method: unsupported or unknown scheme");
45 }
46}
DuFort–Frankel explicit method (3-level scheme).
std::unique_ptr< Method > make_method(SchemeKind scheme)
Build a concrete numerical method from the requested scheme kind.
Definition method.cpp:27
SchemeKind
Enumeration of the numerical schemes available in the solver.
Definition method.hpp:13
@ Laasonen
Simple Implicit (forward time, central space).
Definition method.hpp:16
@ DuFortFrankel
Modified Richardson (explicit, stable).
Definition method.hpp:15
@ CrankNicolson
Trapezoidal Implicit (second order accuracy).
Definition method.hpp:17
@ Richardson
Central time, central space (explicit, unstable).
Definition method.hpp:14
Richardson explicit (central time - central space) scheme for the 1D heat equation.