1#ifndef __CMA_UTILS_TRANSITIONNER_HPP__
2#define __CMA_UTILS_TRANSITIONNER_HPP__
4#include "cma_read/reactorstate.hpp"
5#include "cma_utils/cache_hydro_state.hpp"
6#include "cma_utils/iteration_state.hpp"
7#include <cma_read/flow_iterator.hpp>
8#include <cma_read/neighbors.hpp>
11#include <transitionner/proxy_cache.hpp>
26 class ProxyPreCalculatedHydroState;
48 std::size_t _n_per_flowmap,
49 std::size_t number_time_step,
50 std::unique_ptr<CmaRead::FlowIterator>&& _iterator,
74 std::span<double> volumeLiq,
75 std::span<double> volumeGas,
76 const CmaRead::Neighbors::Neighbors_const_view_t& neighbors);
97 [[nodiscard]] virtual const CmaRead::ReactorState&
110 get_neighbors_view(const CmaRead::Neighbors::Neighbors_const_view_t& liquid_neighbors);
122 std::unordered_map<std::
string, std::span<const
double>>&& info);
135 std::span<
double> volumeLiq,
136 std::span<
double> volumeGas,
137 const CmaRead::Neighbors::Neighbors_const_view_t& neighbors);
163 [[nodiscard]]
size_t size() const noexcept;
168 [[nodiscard]] const CmaRead::ReactorState&
get_unchecked(
size_t index) const noexcept;
215 [[nodiscard]]
inline const CmaRead::ReactorState&
218 return iterator->get_unchecked(index);
Manages the reading, caching, and transitioning of flowmaps for simulation timesteps.
Definition transitionner.hpp:38
bool two_phase_flow
Is two_phase_flow.
Definition transitionner.hpp:180
std::unique_ptr< CmaRead::FlowIterator > iterator
Iterator that reads flowmap.
Definition transitionner.hpp:187
std::size_t n_flowmap
Number of flowmap.
Definition transitionner.hpp:182
virtual ~FlowMapTransitionner()=default
virtual void update_flow()=0
Calculate the current state based on the selected method, may be caching or direct calculation.
bool need_liquid_state_calculation() const noexcept
Check if liquid state has to calculated or can be use via caching.
Definition transitionner.hpp:207
FlowMapTransitionner & operator=(FlowMapTransitionner &&)=default
FlowMapTransitionner()=default
virtual CmaUtils::ProxyPreCalculatedHydroState & current_liq_hydro_state()=0
Get current liquid state read from CmaRead.
std::size_t repetition_count
How many flowmaps (different or not) have been used.
Definition transitionner.hpp:184
virtual CmaUtils::ProxyPreCalculatedHydroState & current_gas_hydro_state()=0
Get current gas state read from CmaRead.
IterationState common_advance(NeighborsView< HostSpace > host_view, std::unordered_map< std::string, std::span< const double > > &&info)
Operation required by all methods in order to perform advance function .
Definition transitionner.cpp:141
static NeighborsView< HostSpace > get_neighbors_view(const CmaRead::Neighbors::Neighbors_const_view_t &liquid_neighbors)
Converts the provided neighbors' data into a Kokkos view.
Definition transitionner.cpp:52
FlowMapTransitionner(FlowMapTransitionner &&)=default
FlowMapTransitionner(const FlowMapTransitionner &)=delete
virtual const CmaRead::ReactorState & get_current_reactor_state() const noexcept=0
Provides a const reference to the current reactor state.
FlowMapTransitionner(std::size_t _n_flowmap, std::size_t _n_per_flowmap, std::size_t number_time_step, std::unique_ptr< CmaRead::FlowIterator > &&_iterator, bool is_two_phase_flow)
FlowMapTransitionner & operator=(const FlowMapTransitionner &)=delete
size_t getFlowIndex() const noexcept
Return the index of the current ProxyPreCalculatedHydroState.
Definition transitionner.hpp:190
std::size_t n_timestep
Total number of timestep.
Definition transitionner.hpp:183
IterationState advance()
Advances the simulation by one timestep.
Definition transitionner.cpp:116
std::vector< CmaUtils::ProxyPreCalculatedHydroState > liquid_pc
Buffer for liquid state.
Definition transitionner.hpp:171
std::size_t current_flowmap_count
Definition transitionner.hpp:185
void update_flow_worker(std::span< double > flows, std::span< double > volumeLiq, std::span< double > volumeGas, const CmaRead::Neighbors::Neighbors_const_view_t &neighbors)
ONLY for MPI_WORKER Calculate the current state based on the selected method, may be caching or direc...
Definition transitionner.cpp:72
std::vector< CmaUtils::ProxyPreCalculatedHydroState > gas_pc
Buffer for gas state.
Definition transitionner.hpp:172
bool is_two_phase_flow() const noexcept
Checks whether a gas flowmap is provided.
Definition transitionner.hpp:202
size_t size() const noexcept
Get the number of load flowmap.
Definition transitionner.hpp:197
std::size_t n_per_flowmap
Number of iteration per flowmap.
Definition transitionner.hpp:181
void update_counters()
Update flow and iteration counters.
Definition transitionner.cpp:152
const CmaRead::ReactorState & get_unchecked(size_t index) const noexcept
Direct read state from iterator.
Definition transitionner.hpp:216
IterationState advance_worker(std::span< double > flows, std::span< double > volumeLiq, std::span< double > volumeGas, const CmaRead::Neighbors::Neighbors_const_view_t &neighbors)
Advances the simulation by one timestep from a MPI Wroker.
Definition transitionner.cpp:129
void calculate_full_state(const CmaRead::ReactorState &reactor_state, CmaUtils::ProxyPreCalculatedHydroState &liq_hydro_state, CmaUtils::ProxyPreCalculatedHydroState &gas_hydro_state) const
Calculate the whole state (liquid+gas+neighbor) for the current time step.
Definition transitionner.cpp:96
std::size_t get_n_timestep() const noexcept
Returns the total number of expected simulation timesteps.
Definition transitionner.cpp:166
Proxy class for PreCalculatedHydroState used to fill this struct with data from an external library.
Definition proxy_cache.hpp:20
Namespace to handle algorithms and structures related to reading compartment mesh.
Definition host_specific.hpp:17
FlowmapTransitionMethod
Defines the transition methods used between flowmaps.
Definition transitionner.hpp:20
@ Discontinuous
Represents a sharp, abrupt transition.
@ InterpolationFO
Represents a smooth transition using first-order interpolation.
Kokkos:: View< std::size_t **, Kokkos::LayoutRight, Space, Kokkos::MemoryTraits< Kokkos::RandomAccess > > NeighborsView
Definition iteration_state.hpp:11
Structure to store information about the reactor state during simulation.
Definition iteration_state.hpp:21