Loading...
Searching...
No Matches
gridfire::solver::DirectNetworkSolver::TimestepContext Struct Referencefinal

Context for the timestep callback function for the DirectNetworkSolver. More...

`#include <solver.h>`

Inheritance diagram for gridfire::solver::DirectNetworkSolver::TimestepContext:

## Public Member Functions

TimestepContext (const double t, const boost::numeric::ublas::vector< double > &state, const double dt, const double cached_time, const double last_observed_time, const double last_step_time, const double t9, const double rho, const std::optional< StepDerivatives< double > > &cached_result, const int num_steps, const DynamicEngine &engine, const std::vector< fourdst::atomic::Species > &networkSpecies)

std::vector< std::tuple< std::string, std::string > > | describe () const override
| Describe the context for callback functions.
Public Member Functions inherited from gridfire::solver::SolverContextBase
virtual | ~SolverContextBase ()=default

## Public Attributes

const double | t
| Current time.
const boost::numeric::ublas::vector< double > & | state
| Current state of the system.
const double | dt
| Time step size.
const double | cached_time
| Cached time for the last observed state.
const double | last_observed_time
| Last time the state was observed.
const double | last_step_time
| Last step time.
const double | T9
| Temperature in units of 10^9 K.
const double | rho
| Density in g/cm^3.
const std::optional< StepDerivatives< double > > & | cached_result
| Cached result of the step derivatives.
const int | num_steps
| Total number of steps taken.
const DynamicEngine & | engine
| Reference to the dynamic engine.
const std::vector< fourdst::atomic::Species > & | networkSpecies

## Detailed Description

Context for the timestep callback function for the DirectNetworkSolver.

This struct contains the context that will be passed to the callback function at the end of each timestep. It includes the current time, state, timestep size, cached results, and other relevant information.

This type should be used when defining a callback function

Example:

#include "gridfire/solver/solver.h"
#include <ofstream>
#include <ranges>
static std::ofstream consumptionFile("consumption.txt");
void callback(const gridfire::solver::DirectNetworkSolver::TimestepContext& context) {
int H1Index = context.engine.getSpeciesIndex(fourdst::atomic::H_1);
int He4Index = context.engine.getSpeciesIndex(fourdst::atomic::He_4);
consumptionFile << context.t << "," << context.state(H1Index) << "," << context.state(He4Index) << "\n";
}
int main() {
... // Code to set up engine and solvers...
solver.set_callback(callback);
solver.evaluate(netIn);
consumptionFile.close();
}
gridfire::DynamicEngine::getSpeciesIndex
virtual int getSpeciesIndex(const fourdst::atomic::Species &species) const =0
Get the index of a species in the network.
gridfire::solver
Definition solver.h:18
solver.h
gridfire::solver::DirectNetworkSolver::TimestepContext
Context for the timestep callback function for the DirectNetworkSolver.
Definition solver.h:155
gridfire::solver::DirectNetworkSolver::TimestepContext::engine
const DynamicEngine & engine
Reference to the dynamic engine.
Definition solver.h:166
gridfire::solver::DirectNetworkSolver::TimestepContext::t
const double t
Current time.
Definition solver.h:156
gridfire::solver::DirectNetworkSolver::TimestepContext::state
const boost::numeric::ublas::vector< double > & state
Current state of the system.
Definition solver.h:157

## Constructor & Destructor Documentation

## TimestepContext()

gridfire::solver::DirectNetworkSolver::TimestepContext::TimestepContext | ( | const double | t,
|  | const boost::numeric::ublas::vector< double > & | state,
|  | const double | dt,
|  | const double | cached_time,
|  | const double | last_observed_time,
|  | const double | last_step_time,
|  | const double | t9,
|  | const double | rho,
|  | const std::optional< StepDerivatives< double > > & | cached_result,
|  | const int | num_steps,
|  | const DynamicEngine & | engine,
|  | const std::vector< fourdst::atomic::Species > & | networkSpecies )

## Member Function Documentation

## describe()

std::vector< std::tuple< std::string, std::string > > gridfire::solver::DirectNetworkSolver::TimestepContext::describe | ( |  | ) | const

overridevirtual

Describe the context for callback functions.

Returns
  A vector of tuples, each containing a string for the parameter's name and a string for its type.

This method provides a description of the context that will be passed to the callback function. The intent is that an end user can investigate the context and use this information to craft their own callback function.

Implements gridfire::solver::SolverContextBase.

## Member Data Documentation

## cached_result

const std::optional<StepDerivatives<double> >& gridfire::solver::DirectNetworkSolver::TimestepContext::cached_result

Cached result of the step derivatives.

## cached_time

const double gridfire::solver::DirectNetworkSolver::TimestepContext::cached_time

Cached time for the last observed state.

## dt

const double gridfire::solver::DirectNetworkSolver::TimestepContext::dt

Time step size.

## engine

const DynamicEngine& gridfire::solver::DirectNetworkSolver::TimestepContext::engine

Reference to the dynamic engine.

## last_observed_time

const double gridfire::solver::DirectNetworkSolver::TimestepContext::last_observed_time

Last time the state was observed.

## last_step_time

const double gridfire::solver::DirectNetworkSolver::TimestepContext::last_step_time

Last step time.

## networkSpecies

const std::vector<fourdst::atomic::Species>& gridfire::solver::DirectNetworkSolver::TimestepContext::networkSpecies

## num_steps

const int gridfire::solver::DirectNetworkSolver::TimestepContext::num_steps

Total number of steps taken.

## rho

const double gridfire::solver::DirectNetworkSolver::TimestepContext::rho

Density in g/cm^3.

## state

const boost::numeric::ublas::vector<double>& gridfire::solver::DirectNetworkSolver::TimestepContext::state

Current state of the system.

## t

const double gridfire::solver::DirectNetworkSolver::TimestepContext::t

Current time.

## T9

const double gridfire::solver::DirectNetworkSolver::TimestepContext::T9

Temperature in units of 10^9 K.

The documentation for this struct was generated from the following files:

- src/include/gridfire/solver/solver.h
- src/lib/solver/solver.cpp