GridFire v0.7.1_rc2 General Purpose Nuclear Network

Loading...
Searching...
No Matches
Public Member Functions | List of all members
gridfire::policy::NetworkPolicy Class Referenceabstract

Abstract interface for policies that construct DynamicEngine networks from a seed composition. More...

`#include <policy_abstract.h>`

Inheritance diagram for gridfire::policy::NetworkPolicy:
[legend]

## Public Member Functions
virtual | ~NetworkPolicy ()=default
virtual std::string | name () const =0
| Human-readable name for the policy.
virtual const std::set< fourdst::atomic::Species > & | get_seed_species () const =0
| Returns the seed species the policy requires to initialize the network.
virtual const reaction::ReactionSet & | get_seed_reactions () const =0
| Returns the set of seed reactions the policy requires.
virtual engine::DynamicEngine & | construct ()=0
| Construct and return a DynamicEngine instance (or engine view stack) satisfying the policy.
virtual NetworkPolicyStatus | get_status () const =0
| Returns the current verification/construction status of the policy.
virtual const std::vector< std::unique_ptr< engine::DynamicEngine > > & | get_engine_stack () const =0
virtual std::vector< engine::EngineTypes > | get_engine_types_stack () const =0
virtual const std::unique_ptr< partition::PartitionFunction > & | get_partition_function () const =0

## Detailed Description

Abstract interface for policies that construct DynamicEngine networks from a seed composition.

A NetworkPolicy provides three main pieces of information:

- A name identifying the policy.
- A set of seed species and seed reactions required to initialize the network.
- A constructor method that returns a fully constructed DynamicEngine (or view stack) built to satisfy the policy.

Concrete implementations include `MainSequencePolicy` (see `stellar_policy.h`) and may throw policy-specific exceptions during construction (for example when required reactions or species are missing).

Example
  // Example usage (see tests/graphnet_sandbox/main.cpp for a complete example):
  // fourdst::composition::Composition comp = prepared composition
  // gridfire::policy::LowMassMainSequencePolicy policy(comp);
  // // construct() returns a reference to a DynamicEngine (could be a view stack)
  // DynamicEngine &engine = policy.construct();
  // // engine can now be passed to a solver (e.g. CVODESolverStrategy)

## Constructor & Destructor Documentation

## ◆ ~NetworkPolicy()

virtual gridfire::policy::NetworkPolicy::~NetworkPolicy | ( |  | ) |
| virtual default

## Member Function Documentation

## ◆ construct()

virtual engine::DynamicEngine & gridfire::policy::NetworkPolicy::construct | ( |  | ) |
| pure virtual

Construct and return a DynamicEngine instance (or engine view stack) satisfying the policy.

Implementations typically build one or more engine layers (GraphEngine, MultiscalePartitioningEngineView, AdaptiveEngineView, etc.) and return a reference to the top-most DynamicEngine. The storage lifetime of the returned reference is implementation-defined (usually owned by the policy instance).

Returns
  DynamicEngine& reference to a running/constructed engine ready for solver consumption.

Exceptions

  gridfire::exceptions::MissingKeyReactionError | if required reactions are not present in the constructed network (see `gridfire/exceptions/error_policy.h`).
  gridfire::exceptions::MissingSeedSpeciesError | if required seed species are missing from the initializing composition.
  gridfire::exceptions::PolicyError | for other construction/verification failures.

Example
  DynamicEngine &engine = policy.construct();
  solver::CVODESolverStrategy solver(engine);
  NetOut out = solver.evaluate(netIn, true);
  gridfire::solver::CVODESolverStrategy
  Stiff ODE integrator backed by SUNDIALS CVODE (BDF) for network + energy.
  Definition CVODE_solver_strategy.h:81
  gridfire::NetOut
  Definition types.h:37

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_engine_stack()

virtual const std::vector< std::unique_ptr< engine::DynamicEngine > > & gridfire::policy::NetworkPolicy::get_engine_stack | ( |  | ) | const
| pure virtual

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_engine_types_stack()

virtual std::vector< engine::EngineTypes > gridfire::policy::NetworkPolicy::get_engine_types_stack | ( |  | ) | const
| pure virtual

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_partition_function()

virtual const std::unique_ptr< partition::PartitionFunction > & gridfire::policy::NetworkPolicy::get_partition_function | ( |  | ) | const
| pure virtual

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_seed_reactions()

virtual const reaction::ReactionSet & gridfire::policy::NetworkPolicy::get_seed_reactions | ( |  | ) | const
| pure virtual

Returns the set of seed reactions the policy requires.

The ReactionSet describes reactions that must be present in the constructed network for the policy to be considered satisfied. Concrete policies often implement their reaction requirements by composing one or more ReactionChainPolicy instances (see `chains.h`).

Example
  const reaction::ReactionSet &reactions = policy.get_seed_reactions();
  // inspect reaction IDs or count
  std::cout << "Policy requires " << reactions.size() << " reactions" << std::endl;
  gridfire::reaction::ReactionSet
  Definition reaction.h:842
  gridfire::reaction::ReactionSet::size
  size_t size() const
  Gets the number of reactions in the set.
  Definition reaction.h:903

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_seed_species()

virtual const std::set< fourdst::atomic::Species > & gridfire::policy::NetworkPolicy::get_seed_species | ( |  | ) | const
| pure virtual

Returns the seed species the policy requires to initialize the network.

The returned set contains atomic species identifiers (fourdst::atomic::Species) which the policy expects to be present in the initial composition used to build the network.

Implementations should return a copy or an immutable reference to their internal set of required seed species.

Example
  const auto seeds = policy.get_seed_species();
  for (const auto &s : seeds) { std::cout << s.name() << std::endl; }

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ get_status()

virtual NetworkPolicyStatus gridfire::policy::NetworkPolicy::get_status | ( |  | ) | const
| pure virtual

Returns the current verification/construction status of the policy.

The status reports whether the policy has been initialized and whether the constructed network satisfies the policy's key requirements.

Example
  NetworkPolicyStatus s = policy.getStatus();
  if (s != NetworkPolicyStatus::INITIALIZED_VERIFIED) { // handle error }
  gridfire::policy::NetworkPolicyStatus
  NetworkPolicyStatus
  Lifecycle/verification status for a NetworkPolicy instance.
  Definition policy_abstract.h:38
  gridfire::policy::NetworkPolicyStatus::INITIALIZED_VERIFIED
  @ INITIALIZED_VERIFIED

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

## ◆ name()

virtual std::string gridfire::policy::NetworkPolicy::name | ( |  | ) | const
| pure virtual

Human-readable name for the policy.

Returns
  a std::string identifying the policy implementation (e.g. "MainSequencePolicy").

Example
  std::string n = policy.name();
  std::cout << "Using policy: " << n << std::endl;

Implemented in gridfire::policy::MainSequencePolicy, and PyNetworkPolicy.

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

- src/include/gridfire/policy/policy_abstract.h