The Solver class combines GoverningEquationSolver and BatchTracking to advance the governing equations forward in time, and advect the gas composition.
More...
#include <solver.hpp>
|
virtual | ~Solver () |
| Declared to avoid the inline compiler-generated default destructor.
|
|
| Solver (const arma::uword nGridPoints, const Config &config) |
| Construct from Config. More...
|
|
| Solver (const arma::uword nGridPoints, const std::string &energyEquation="InternalEnergy", const arma::vec &relaxationFactors={1, 1, 2/3.0}, const std::string &toleranceType="relative", const arma::vec &tolerances={0.001, 0.001, 0.001}, const bool bruteForce=false, const arma::uword maxIterations=200) |
| Construct from number of grid points and string to select discretizer. More...
|
|
virtual Pipeline | solve (const arma::uword dt, const Pipeline ¤t, const TimeStep &boundaryConditions, const Physics &physics) const |
| Solve the governing equations. More...
|
|
virtual Pipeline | solve (const arma::uword dt, const Pipeline ¤t, const BoundaryConditions &boundaryConditions, const Physics &physics) const |
| Solve the governing equations. More...
|
|
Pipeline | solveWithIterations (const arma::uword dt, const Pipeline ¤t, const BoundaryConditions &boundaryConditions, const Physics &physics) const |
| Solve the governing equations. More...
|
|
void | enableBruteForce () |
| Enable brute force solver, which always does m_maxIterations iterations.
|
|
void | setMaxIterations (const arma::uword maxIterations) |
| Set max iterations.
|
|
arma::uword | nIterations () const |
| Return the number of iterations performed during previous solution attempt.
|
|
const arma::vec & | relaxationFactors () const |
| Get (const ref) relaxation factors.
|
|
const std::string & | toleranceType () const |
| Get (const ref) tolerance type.
|
|
const arma::vec & | tolerances () const |
| Get (const ref) tolerances.
|
|
const GoverningEquationSolverBase & | governingEquationSolver () const |
| Get (const ref) GoverningEquationSolver.
|
|
The Solver class combines GoverningEquationSolver and BatchTracking to advance the governing equations forward in time, and advect the gas composition.
It operates on Pipeline instances, and returns a copy of the input, with updated flow, pressure, temperature, and composition (if batch tracking is enabled).
◆ Solver() [1/2]
Solver::Solver |
( |
const arma::uword |
nGridPoints, |
|
|
const Config & |
config |
|
) |
| |
Construct from Config.
- Parameters
-
nGridPoints | Number of grid points |
config | Config instance |
◆ Solver() [2/2]
Solver::Solver |
( |
const arma::uword |
nGridPoints, |
|
|
const std::string & |
energyEquation = "InternalEnergy" , |
|
|
const arma::vec & |
relaxationFactors = {1, 1, 2/3.0} , |
|
|
const std::string & |
toleranceType = "relative" , |
|
|
const arma::vec & |
tolerances = {0.001, 0.001, 0.001} , |
|
|
const bool |
bruteForce = false , |
|
|
const arma::uword |
maxIterations = 200 |
|
) |
| |
|
explicit |
Construct from number of grid points and string to select discretizer.
- Parameters
-
nGridPoints | Number of grid points. |
energyEquation | Type of energy equation ("InternalEnergy" or "Enthalpy") |
relaxationFactors | Relaxation factors, typically around 1. |
toleranceType | Tolerance type ("absolute" or "relative") |
tolerances | Convergence criteria |
bruteForce | Will always do maxIterations iterations and not check for convergence |
maxIterations | The maximum number of iterations to perform |
◆ differencesWithinTolerance()
static arma::uword Solver::differencesWithinTolerance |
( |
const Pipeline & |
guess, |
|
|
const Pipeline & |
previous, |
|
|
const arma::vec & |
tolerances, |
|
|
const std::string & |
toleranceType, |
|
|
const arma::vec & |
relaxationFactors |
|
) |
| |
|
static |
Check if differences between an old and a new state are within tolerances. This will either compare relative or absolute differences.
This is used to see if the iteration over solution of the governing equations have converged, by comparing differences between the two last iterations.
In the case of relative differences, we can run into issues if we have zero flow, so this is handled explicitly (temperature and pressure is never expected to reach zero in well-behaved simulations).
- Parameters
-
guess | |
previous | |
tolerances | |
toleranceType | |
relaxationFactors | |
- Returns
◆ makeGoverningEquationSolver() [1/2]
◆ makeGoverningEquationSolver() [2/2]
std::unique_ptr<GoverningEquationSolverBase> Solver::makeGoverningEquationSolver |
( |
const arma::uword |
nGridPoints, |
|
|
const std::string & |
discretizer |
|
) |
| |
|
private |
◆ solve() [1/2]
Solve the governing equations.
- See also
- solveWithIterations()
- Parameters
-
dt | Time step [s] |
current | Current pipeline state |
boundaryConditions | Boundary conditions |
physics | Physics instance to update derived properties and heat transfer |
- Returns
- Copy of current with updated properties.
◆ solve() [2/2]
Solve the governing equations.
- See also
- solveWithIterations()
- Parameters
-
dt | Time step [s] |
current | Current pipeline state |
boundaryConditions | Boundary conditions with time stamp |
physics | Physics instance to update derived properties and heat transfer |
- Returns
- Copy of current with updated properties.
◆ solveWithIterations()
Solve the governing equations.
TODO: Some more documentation here
- Parameters
-
dt | Time step [s] |
current | Pipeline state |
boundaryConditions | Boundary conditions |
physics | Physics instance to update derived properties and heat transfer |
- Returns
- Copy of current with updated properties.
◆ m_bruteForce
bool Solver::m_bruteForce |
|
private |
If we should use brute-force solving, which means not checking for convergence, but always performing m_maxIterations iterations.
◆ m_maxIterations
arma::uword Solver::m_maxIterations |
|
private |
The maximum number of iterations to perform, or (if m_bruteForce is true) the exact number of iterations to perform.
◆ m_nIterations
arma::uword Solver::m_nIterations = 0 |
|
mutableprivate |
The number of iterations performed during the previous solution attempt. This is mutable, and is updated in Solver::solve().
◆ m_toleranceType
std::string Solver::m_toleranceType |
|
private |
What kind of tolerance to use when checking convergence ("relative" or "absolute").
The documentation for this class was generated from the following file:
- D:/Code/transient-pipeline-flow-gh-pages/src/solver/solver.hpp