1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
Loading...
Searching...
No Matches
crank_nicolson.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "method.hpp"
4#include <string>
5
6/**
7 * @brief Crank-Nicolson scheme implementation.
8 */
9class CrankNicolson : public Method
10{
11 public:
12 std::string name() const override
13 {
14 return "Crank-Nicolson";
15 }
16
17 bool uses_previous_step() const noexcept override
18 {
19 return false;
20 }
21
22 /**
23 * @brief Advance one time step using Crank-Nicolson scheme.
24 */
25 void step(const Grid& g,
26 double D,
27 double dt,
28 const std::vector<double>& Tprev,
29 const std::vector<double>& Tcurr,
30 std::vector<double>& Tnext) const override;
31};
Crank-Nicolson scheme implementation.
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 Crank-Nicolson scheme.
std::string name() const override
Get human-readable name of the scheme.
bool uses_previous_step() const noexcept override
Indicates if the scheme requires data from time step n-1.
Abstract interface for time-integration schemes solving the 1D heat equation.
Definition method.hpp:28
Uniform 1D grid on x ∈ [0, L], including both boundary nodes.
Definition grid.hpp:15