|
1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
|
#include <solver.hpp>

Public Member Functions | |
| HeatSolver (const PhysParams &phys, const NumParams &num, SchemeKind scheme) | |
| Construct the solver with physical and numerical parameters and a scheme kind. | |
| void | run (const std::function< void(double, const Grid &, const std::vector< double > &)> &onDump) |
| Run the simulation from t=0 to t=tEnd. | |
Private Member Functions | |
| void | apply_dirichlet (std::vector< double > &T) const |
| Apply Dirichlet boundary conditions (Tsur) at both ends of the vector. | |
| void | init_field () |
| Initialize the temperature field with Tin and enforce boundary conditions. | |
| void | bootstrap_if_needed () |
| Perform a warm-up step when the method needs two previous time levels. | |
Private Attributes | |
| PhysParams | phys_ |
| Physical parameters (copied for convenience). | |
| NumParams | num_ |
| Numerical parameters (copied for convenience). | |
| Grid | grid_ |
| Spatial grid built from phys/num input. | |
| std::unique_ptr< Method > | method_ |
| Selected time integration method. | |
| bool | uses_prev_step_ = false |
| True when the method requires T^{n-1}. | |
| std::vector< double > | T_ |
| Current solution (typically holds T^n). | |
| std::vector< double > | Tprev_ |
| Previous solution (stores T^{n-1} when required). | |
| std::vector< double > | next_ |
| Buffer used to store the next time layer T^{n+1}. | |
Definition at line 14 of file solver.hpp.
| HeatSolver::HeatSolver | ( | const PhysParams & | phys, |
| const NumParams & | num, | ||
| SchemeKind | scheme ) |
Construct the solver with physical and numerical parameters and a scheme kind.
| phys | Physical parameters (D [cm^2/h], L [cm], Tin, Tsur). |
| num | Numerical parameters (dx [cm], dt [h], tEnd [h], outEvery [h]). |
| scheme | Selected time-stepping scheme (e.g. DuFort-Frankel). |
Definition at line 10 of file solver.cpp.

|
private |
Apply Dirichlet boundary conditions (Tsur) at both ends of the vector.
| T | Temperature field updated in-place |
Definition at line 34 of file solver.cpp.

|
private |
Perform a warm-up step when the method needs two previous time levels.
We call the scheme once with T^{n-1} = T^{n} = T^0 so that T_ holds T^1 while Tprev_ keeps a copy of T^0 (needed by three-level methods).
Definition at line 47 of file solver.cpp.


|
private |
Initialize the temperature field with Tin and enforce boundary conditions.
Definition at line 41 of file solver.cpp.


| void HeatSolver::run | ( | const std::function< void(double, const Grid &, const std::vector< double > &)> & | onDump | ) |
Run the simulation from t=0 to t=tEnd.
| onDump | Callback executed at t=0 and then every outEvery hours: onDump(time, grid, T). Use it to write CSV, compute errors, etc. |
Definition at line 83 of file solver.cpp.


|
private |
Spatial grid built from phys/num input.
Definition at line 35 of file solver.hpp.
|
private |
Selected time integration method.
Definition at line 36 of file solver.hpp.
|
private |
Buffer used to store the next time layer T^{n+1}.
Definition at line 41 of file solver.hpp.
|
private |
Numerical parameters (copied for convenience).
Definition at line 34 of file solver.hpp.
|
private |
Physical parameters (copied for convenience).
Definition at line 33 of file solver.hpp.
|
private |
Current solution (typically holds T^n).
Definition at line 39 of file solver.hpp.
|
private |
Previous solution (stores T^{n-1} when required).
Definition at line 40 of file solver.hpp.
|
private |
True when the method requires T^{n-1}.
Definition at line 37 of file solver.hpp.