SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::eos::runtime::EOSView Class Referencefinal

A class to provide a runtime view of an EOS model and its relations. This class is used to provide a uniform interface for evaluating relations and partial derivatives at runtime. More...

#include <views.hpp>

Collaboration diagram for serif::eos::runtime::EOSView:
[legend]

Public Member Functions

template<typename EOS>
requires RuntimeEOSModel<std::remove_cvref_t<EOS>>
 EOSView (const EOS &eos) noexcept
 Constructs an EOSView from a runtime EOS model. This constructor is used to create a view of the EOS model and its relations at runtime.
 
template<typename EOS>
requires RuntimeEOSModel<std::remove_cvref_t<EOS>>
 EOSView (const EOS &&)=delete
 Deleted constructor to prevent constructing an EOSView from an rvalue EOS model. This is to prevent dangling references and ensure that the EOS model instance outlives the EOSView.
 
std::span< const dimensions::runtime::RuntimeRelationDescriptor > relations () const noexcept
 Returns a span of the runtime relation descriptors for the EOS model.
 
bool supports (const dimensions::runtime::ThermodynamicQuantityID outputQuantity, const std::span< const dimensions::runtime::ThermodynamicQuantityID > inputQuantities) const noexcept
 Determines if the EOS model supports a relation with the given output quantity and input quantities at runtime. This is used to check if a relation can be evaluated at runtime.
 
std::expected< dimensions::runtime::RuntimeQuantityValue, utils::errors::SERiFErrorCode > try_evaluate (const dimensions::runtime::ThermodynamicQuantityID outputQuantity, const std::span< const dimensions::runtime::RuntimeQuantityValue > inputQuantities) const
 Evaluates a relation with the given output quantity and input quantities at runtime. This is used to evaluate relations at runtime.
 
template<dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity OutputQuantity, dimensions::ThermodynamicQuantityValueType... InputValues>
std::expected< dimensions::QuantityValue< OutputQuantity >, utils::errors::SERiFErrorCode > try_evaluate (const InputValues... inputValues) const
 Evaluates a relation with the given output quantity and input quantities at runtime. This is used to evaluate relations at runtime.
 
std::expected< double, utils::errors::SERiFErrorCode > try_partial_derivative (const dimensions::runtime::ThermodynamicQuantityID outputQuantity, const dimensions::runtime::ThermodynamicQuantityID withRespectTo, const std::span< const dimensions::runtime::RuntimeQuantityValue > inputValues) const
 Evaluates a partial derivative of a relation with the given output quantity and input quantities at runtime. This is used to evaluate partial derivatives at runtime.
 
template<dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity OutputQuantity, dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity InputQuantity, dimensions::QuantityValueType... InputValues>
std::expected< dimensions::PartialDerivative< OutputQuantity, InputQuantity >, utils::errors::SERiFErrorCode > try_partial_derivative (const InputValues... inputValues) const
 Evaluates a partial derivative of a relation with the given output quantity and input quantities at runtime. This is used to evaluate partial derivatives at runtime.
 

Private Types

using RuntimeEvaluateFunction
 A type alias for a function pointer to a runtime evaluation function. This is used to store the evaluation function for the EOS model.
 
using RuntimePartialDerivativeFunction
 A type alias for a function pointer to a runtime partial derivative evaluation function. This is used to store the partial derivative evaluation function for the EOS model.
 

Private Member Functions

const dimensions::runtime::RuntimeRelationDescriptor * find_relation (const dimensions::runtime::ThermodynamicQuantityID outputQuantity, const std::span< const dimensions::runtime::ThermodynamicQuantityID > inputQuantities) const noexcept
 Finds a relation with the given output quantity and input quantities at runtime. This is used to find relations at runtime.
 
std::expected< const dimensions::runtime::RuntimeRelationDescriptor *, utils::errors::SERiFErrorCode > validate_relation_request (const dimensions::runtime::ThermodynamicQuantityID outputQuantity, const std::span< const dimensions::runtime::RuntimeQuantityValue > inputValues) const
 Validates a relation request with the given output quantity and input quantities at runtime. This is used to validate relations at runtime.
 

Static Private Member Functions

template<typename Value>
static std::expected< Value, utils::errors::SERiFErrorCode > runtime_failure (const utils::errors::SERiFErrorCode code)
 A helper function to handle runtime failures. This is used to simplify the usage of std::expected in the runtime system.
 

Private Attributes

const void * m_object
 Type erased pointer to the EOS model instance.
 
std::span< const dimensions::runtime::RuntimeRelationDescriptor > m_relations
 A span of the runtime relation descriptors for the EOS model.
 
RuntimeEvaluateFunction m_evaluate
 A function pointer to the runtime evaluation function for the EOS model.
 
RuntimePartialDerivativeFunction m_partialDerivative
 A function pointer to the runtime partial derivative evaluation function for the EOS model.
 

Detailed Description

A class to provide a runtime view of an EOS model and its relations. This class is used to provide a uniform interface for evaluating relations and partial derivatives at runtime.

Member Typedef Documentation

◆ RuntimeEvaluateFunction

Initial value:
std::expected<double, utils::errors::SERiFErrorCode> (*)(
const void*,
std::span<const dimensions::runtime::RuntimeQuantityValue>
)
Runtime resolvable ID for a thermodynamic quantity. Used in conjunction with concepts to resolve comp...
Definition runtime.hpp:25

A type alias for a function pointer to a runtime evaluation function. This is used to store the evaluation function for the EOS model.

◆ RuntimePartialDerivativeFunction

Initial value:
std::expected<double, utils::errors::SERiFErrorCode> (*)(
const void*,
std::span<const dimensions::runtime::RuntimeQuantityValue>
)

A type alias for a function pointer to a runtime partial derivative evaluation function. This is used to store the partial derivative evaluation function for the EOS model.

Constructor & Destructor Documentation

◆ EOSView() [1/2]

template<typename EOS>
requires RuntimeEOSModel<std::remove_cvref_t<EOS>>
serif::eos::runtime::EOSView::EOSView ( const EOS & eos)
inlineexplicitnoexcept

Constructs an EOSView from a runtime EOS model. This constructor is used to create a view of the EOS model and its relations at runtime.

Template Parameters
EOSThe type of the EOS model to view.
Parameters
eosThe EOS model instance to view.

◆ EOSView() [2/2]

template<typename EOS>
requires RuntimeEOSModel<std::remove_cvref_t<EOS>>
serif::eos::runtime::EOSView::EOSView ( const EOS && )
explicitdelete

Deleted constructor to prevent constructing an EOSView from an rvalue EOS model. This is to prevent dangling references and ensure that the EOS model instance outlives the EOSView.

Template Parameters
EOSThe type of the EOS model to view.
Parameters
eosThe EOS model instance to view.

Member Function Documentation

◆ find_relation()

const dimensions::runtime::RuntimeRelationDescriptor * serif::eos::runtime::EOSView::find_relation ( const dimensions::runtime::ThermodynamicQuantityID outputQuantity,
const std::span< const dimensions::runtime::ThermodynamicQuantityID > inputQuantities ) const
inlinenodiscardprivatenoexcept

Finds a relation with the given output quantity and input quantities at runtime. This is used to find relations at runtime.

Parameters
outputQuantityThe output quantity to find the relation for.
inputQuantitiesThe input quantities to find the relation for.
Returns
A pointer to the runtime relation descriptor if found, nullptr otherwise.
Todo
move to implementation file to clean things up a bit.

◆ relations()

std::span< const dimensions::runtime::RuntimeRelationDescriptor > serif::eos::runtime::EOSView::relations ( ) const
inlinenodiscardnoexcept

Returns a span of the runtime relation descriptors for the EOS model.

Returns
A span of the runtime relation descriptors.
Todo
Move this to the implementation file to clean things up a bit.

◆ runtime_failure()

template<typename Value>
static std::expected< Value, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::runtime_failure ( const utils::errors::SERiFErrorCode code)
inlinestaticnodiscardprivate

A helper function to handle runtime failures. This is used to simplify the usage of std::expected in the runtime system.

Template Parameters
ValueThe type of the value to return.
Parameters
codeThe SERiFErrorCode to return.
Returns
A std::unexpected containing the SERiFErrorCode.

◆ supports()

bool serif::eos::runtime::EOSView::supports ( const dimensions::runtime::ThermodynamicQuantityID outputQuantity,
const std::span< const dimensions::runtime::ThermodynamicQuantityID > inputQuantities ) const
inlinenodiscardnoexcept

Determines if the EOS model supports a relation with the given output quantity and input quantities at runtime. This is used to check if a relation can be evaluated at runtime.

Parameters
outputQuantityThe output quantity to check.
inputQuantitiesThe input quantities to check.
Returns
True if the relation is supported, false otherwise.

◆ try_evaluate() [1/2]

std::expected< dimensions::runtime::RuntimeQuantityValue, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::try_evaluate ( const dimensions::runtime::ThermodynamicQuantityID outputQuantity,
const std::span< const dimensions::runtime::RuntimeQuantityValue > inputQuantities ) const
inlinenodiscard

Evaluates a relation with the given output quantity and input quantities at runtime. This is used to evaluate relations at runtime.

Parameters
outputQuantityThe output quantity to evaluate.
inputQuantitiesThe input quantities to evaluate.
Returns
A std::expected containing the result of the evaluation or a SERiFErrorCode if the evaluation failed.

◆ try_evaluate() [2/2]

template<dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity OutputQuantity, dimensions::ThermodynamicQuantityValueType... InputValues>
std::expected< dimensions::QuantityValue< OutputQuantity >, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::try_evaluate ( const InputValues... inputValues) const
inlinenodiscard

Evaluates a relation with the given output quantity and input quantities at runtime. This is used to evaluate relations at runtime.

Template Parameters
OutputQuantityThe output quantity to evaluate.
InputValuesThe input values to evaluate.
Returns
A std::expected containing the result of the evaluation or a SERiFErrorCode if the evaluation failed.

◆ try_partial_derivative() [1/2]

std::expected< double, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::try_partial_derivative ( const dimensions::runtime::ThermodynamicQuantityID outputQuantity,
const dimensions::runtime::ThermodynamicQuantityID withRespectTo,
const std::span< const dimensions::runtime::RuntimeQuantityValue > inputValues ) const
inlinenodiscard

Evaluates a partial derivative of a relation with the given output quantity and input quantities at runtime. This is used to evaluate partial derivatives at runtime.

Parameters
outputQuantityThe output quantity to evaluate.
withRespectToThe input quantity with respect to which the partial derivative is taken.
inputValuesThe input values to evaluate.
Returns
A std::expected containing the result of the evaluation or a SERiFErrorCode if the evaluation failed.

◆ try_partial_derivative() [2/2]

template<dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity OutputQuantity, dimensions::runtime::RuntimeIdentifiedThermodynamicQuantity InputQuantity, dimensions::QuantityValueType... InputValues>
std::expected< dimensions::PartialDerivative< OutputQuantity, InputQuantity >, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::try_partial_derivative ( const InputValues... inputValues) const
inlinenodiscard

Evaluates a partial derivative of a relation with the given output quantity and input quantities at runtime. This is used to evaluate partial derivatives at runtime.

Template Parameters
OutputQuantityThe output quantity to evaluate.
InputQuantityThe input quantity with respect to which the partial derivative is taken.
InputValuesThe types of the input values.
Parameters
inputValuesThe input values to evaluate.
Returns
A std::expected containing the result of the evaluation or a SERiFErrorCode if the evaluation failed.

◆ validate_relation_request()

std::expected< const dimensions::runtime::RuntimeRelationDescriptor *, utils::errors::SERiFErrorCode > serif::eos::runtime::EOSView::validate_relation_request ( const dimensions::runtime::ThermodynamicQuantityID outputQuantity,
const std::span< const dimensions::runtime::RuntimeQuantityValue > inputValues ) const
inlinenodiscardprivate

Validates a relation request with the given output quantity and input quantities at runtime. This is used to validate relations at runtime.

Parameters
outputQuantityThe output quantity to validate.
inputValuesThe input values to validate.
Returns
A std::expected containing a pointer to the runtime relation descriptor if valid, or a SERiFErrorCode if invalid.

Member Data Documentation

◆ m_evaluate

RuntimeEvaluateFunction serif::eos::runtime::EOSView::m_evaluate
private

A function pointer to the runtime evaluation function for the EOS model.

◆ m_object

const void* serif::eos::runtime::EOSView::m_object
private

Type erased pointer to the EOS model instance.

◆ m_partialDerivative

RuntimePartialDerivativeFunction serif::eos::runtime::EOSView::m_partialDerivative
private

A function pointer to the runtime partial derivative evaluation function for the EOS model.

◆ m_relations

std::span<const dimensions::runtime::RuntimeRelationDescriptor> serif::eos::runtime::EOSView::m_relations
private

A span of the runtime relation descriptors for the EOS model.


The documentation for this class was generated from the following file: