Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::analysis::PerFrameDistributionStore Class Reference

Thread-safe repository for per-frame 1D distribution curves and their ensemble mean. More...

#include <PerFrameDistributionStore.hpp>

Classes

struct  MeanFrameWindow

Public Types

using FrameCurveArray = std::array<std::vector<real_t>, METRIC_COUNT>
using FrameCurveGenerator = std::function<FrameCurveArray(std::size_t)>

Public Member Functions

 PerFrameDistributionStore (std::size_t total_frames)
 Constructs a store pre-allocated for a specific total frame count.
void setBins (DistributionMetric metric, std::vector< real_t > bins)
 Sets the shared bin coordinates for a metric.
void setMeanCurve (DistributionMetric metric, std::vector< real_t > mean_curve)
 Sets the ensemble mean curve for a metric.
void setFrameCurve (DistributionMetric metric, std::size_t frame_idx, std::vector< real_t > curve)
 Sets the 1D distribution curve for a specific trajectory frame.
std::size_t getTotalFrames () const noexcept
 Returns the total trajectory frame count allocated in this store.
bool hasData (DistributionMetric metric) const noexcept
 Checks if bins and curves are available for a given metric.
bool hasFrame (DistributionMetric metric, std::size_t frame_idx) const noexcept
 Checks if curve data is populated for a specific frame index.
const std::vector< real_t > & getBins (DistributionMetric metric) const
 Retrieves the shared bin coordinates for a metric.
const std::vector< real_t > & getMeanCurve (DistributionMetric metric) const
 Retrieves the ensemble mean curve for a metric.
const std::vector< real_t > & getFrameCurve (DistributionMetric metric, std::size_t frame_idx) const
 Retrieves the curve for a specific frame index.
const MetricCurveData & getMetricData (DistributionMetric metric) const
 Retrieves const reference to the full metric curve dataset.
MetricCurveData & getMetricData (DistributionMetric metric)
 Retrieves mutable reference to the full metric curve dataset.
void configureMeanFrames (MeanFrameWindow window)
 Records the strided [start_frame, start_frame + sample_count * stride) mean window.
void markFrameInMean (std::size_t frame_idx, bool in_mean=true)
 Explicitly marks whether a single frame contributed to the ensemble mean.
bool isFrameInMean (std::size_t frame_idx) const noexcept
 Queries whether a trajectory frame contributed to the ensemble mean.
void setFrameGenerator (FrameCurveGenerator generator)
 Installs an on-demand 1D curve generator for frames outside the initial mean range.
void clearFrameGenerator () noexcept
 Detaches any active lazy frame generator.
bool needsFrameGeneration (std::size_t frame_idx) const noexcept
 Checks whether any metric with a populated mean curve is missing a curve for frame_idx.
void ensureFrame (std::size_t frame_idx) const
 Lazily computes and caches missing 1D curves for frame_idx if a generator is attached.

Static Public Attributes

static constexpr std::size_t METRIC_COUNT = 4

Private Member Functions

bool needsFrameGenerationUnlocked (std::size_t frame_idx) const noexcept

Static Private Member Functions

static std::size_t toIndex (DistributionMetric metric) noexcept

Private Attributes

std::shared_mutex mutex_
std::mutex generation_mutex_
std::size_t total_frames_ {0}
std::array< MetricCurveData, METRIC_COUNT > metrics_
bool has_explicit_mean_mask_ {false}
std::vector< uint8_t > in_mean_mask_
FrameCurveGenerator frame_generator_

Static Private Attributes

static const std::vector< real_t > EMPTY_CURVE {}

Detailed Description

Thread-safe repository for per-frame 1D distribution curves and their ensemble mean.

Designed to provide ultra-low latency scrub playback in 3D viewers. Holds compact 1D curves (~2.5 KB per frame) without retaining heavy 3D structures or partial matrices.

Member Typedef Documentation

◆ FrameCurveArray

◆ FrameCurveGenerator

Constructor & Destructor Documentation

◆ PerFrameDistributionStore()

correlation::analysis::PerFrameDistributionStore::PerFrameDistributionStore ( std::size_t total_frames)
explicit

Constructs a store pre-allocated for a specific total frame count.

Parameters
[in]total_framesTotal number of frames across the full trajectory.
Here is the call graph for this function:

Member Function Documentation

◆ clearFrameGenerator()

void correlation::analysis::PerFrameDistributionStore::clearFrameGenerator ( )
noexcept

Detaches any active lazy frame generator.

◆ configureMeanFrames()

void correlation::analysis::PerFrameDistributionStore::configureMeanFrames ( MeanFrameWindow window)

Records the strided [start_frame, start_frame + sample_count * stride) mean window.

Parameters
[in]windowSampled frame window parameters accumulated into the mean.

◆ ensureFrame()

void correlation::analysis::PerFrameDistributionStore::ensureFrame ( std::size_t frame_idx) const

Lazily computes and caches missing 1D curves for frame_idx if a generator is attached.

Parameters
[in]frame_idxZero-based trajectory frame index.
Here is the call graph for this function:

◆ getBins()

const std::vector< real_t > & correlation::analysis::PerFrameDistributionStore::getBins ( DistributionMetric metric) const
nodiscard

Retrieves the shared bin coordinates for a metric.

Parameters
[in]metricTarget distribution identifier.
Returns
Const reference to bins vector.
Here is the call graph for this function:

◆ getFrameCurve()

const std::vector< real_t > & correlation::analysis::PerFrameDistributionStore::getFrameCurve ( DistributionMetric metric,
std::size_t frame_idx ) const
nodiscard

Retrieves the curve for a specific frame index.

Parameters
[in]metricTarget distribution identifier.
[in]frame_idxZero-based trajectory frame index.
Returns
Const reference to the frame's curve vector (or empty vector if unpopulated).
Here is the call graph for this function:

◆ getMeanCurve()

const std::vector< real_t > & correlation::analysis::PerFrameDistributionStore::getMeanCurve ( DistributionMetric metric) const
nodiscard

Retrieves the ensemble mean curve for a metric.

Parameters
[in]metricTarget distribution identifier.
Returns
Const reference to mean curve vector.
Here is the call graph for this function:

◆ getMetricData() [1/2]

MetricCurveData & correlation::analysis::PerFrameDistributionStore::getMetricData ( DistributionMetric metric)
nodiscard

Retrieves mutable reference to the full metric curve dataset.

Parameters
[in]metricTarget distribution identifier.
Returns
Mutable reference to MetricCurveData.
Here is the call graph for this function:

◆ getMetricData() [2/2]

const MetricCurveData & correlation::analysis::PerFrameDistributionStore::getMetricData ( DistributionMetric metric) const
nodiscard

Retrieves const reference to the full metric curve dataset.

Parameters
[in]metricTarget distribution identifier.
Returns
Const reference to MetricCurveData.
Here is the call graph for this function:

◆ getTotalFrames()

std::size_t correlation::analysis::PerFrameDistributionStore::getTotalFrames ( ) const
nodiscardnoexcept

Returns the total trajectory frame count allocated in this store.

Returns
Number of frames.

◆ hasData()

bool correlation::analysis::PerFrameDistributionStore::hasData ( DistributionMetric metric) const
nodiscardnoexcept

Checks if bins and curves are available for a given metric.

Parameters
[in]metricTarget distribution identifier.
Returns
True if valid bins and data exist.
Here is the call graph for this function:

◆ hasFrame()

bool correlation::analysis::PerFrameDistributionStore::hasFrame ( DistributionMetric metric,
std::size_t frame_idx ) const
nodiscardnoexcept

Checks if curve data is populated for a specific frame index.

Parameters
[in]metricTarget distribution identifier.
[in]frame_idxZero-based trajectory frame index.
Returns
True if curve data is present.
Here is the call graph for this function:

◆ isFrameInMean()

bool correlation::analysis::PerFrameDistributionStore::isFrameInMean ( std::size_t frame_idx) const
nodiscardnoexcept

Queries whether a trajectory frame contributed to the ensemble mean.

Parameters
[in]frame_idxZero-based trajectory frame index.
Returns
True if frame was included in ensemble mean (or if no explicit mask was configured).

◆ markFrameInMean()

void correlation::analysis::PerFrameDistributionStore::markFrameInMean ( std::size_t frame_idx,
bool in_mean = true )

Explicitly marks whether a single frame contributed to the ensemble mean.

Parameters
[in]frame_idxZero-based trajectory frame index.
[in]in_meanTrue if included in ensemble mean.

◆ needsFrameGeneration()

bool correlation::analysis::PerFrameDistributionStore::needsFrameGeneration ( std::size_t frame_idx) const
nodiscardnoexcept

Checks whether any metric with a populated mean curve is missing a curve for frame_idx.

Parameters
[in]frame_idxZero-based trajectory frame index.
Returns
True if at least one active metric curve is still unpopulated for frame_idx.
Here is the call graph for this function:

◆ needsFrameGenerationUnlocked()

bool correlation::analysis::PerFrameDistributionStore::needsFrameGenerationUnlocked ( std::size_t frame_idx) const
nodiscardprivatenoexcept
Here is the caller graph for this function:

◆ setBins()

void correlation::analysis::PerFrameDistributionStore::setBins ( DistributionMetric metric,
std::vector< real_t > bins )

Sets the shared bin coordinates for a metric.

Parameters
[in]metricTarget distribution identifier.
[in]binsBin values along the x-axis.
Here is the call graph for this function:

◆ setFrameCurve()

void correlation::analysis::PerFrameDistributionStore::setFrameCurve ( DistributionMetric metric,
std::size_t frame_idx,
std::vector< real_t > curve )

Sets the 1D distribution curve for a specific trajectory frame.

Parameters
[in]metricTarget distribution identifier.
[in]frame_idxZero-based trajectory frame index.
[in]curveNormalized 1D curve values for the frame.
Here is the call graph for this function:

◆ setFrameGenerator()

void correlation::analysis::PerFrameDistributionStore::setFrameGenerator ( FrameCurveGenerator generator)

Installs an on-demand 1D curve generator for frames outside the initial mean range.

Parameters
[in]generatorCallback computing [RDF, PAD, SQ, XRD] curves for a given frame index.

◆ setMeanCurve()

void correlation::analysis::PerFrameDistributionStore::setMeanCurve ( DistributionMetric metric,
std::vector< real_t > mean_curve )

Sets the ensemble mean curve for a metric.

Parameters
[in]metricTarget distribution identifier.
[in]mean_curveNormalized mean curve values.
Here is the call graph for this function:

◆ toIndex()

std::size_t correlation::analysis::PerFrameDistributionStore::toIndex ( DistributionMetric metric)
staticnodiscardprivatenoexcept
Here is the caller graph for this function:

Member Data Documentation

◆ EMPTY_CURVE

const std::vector< real_t > correlation::analysis::PerFrameDistributionStore::EMPTY_CURVE {}
staticprivate

◆ frame_generator_

FrameCurveGenerator correlation::analysis::PerFrameDistributionStore::frame_generator_
private

◆ generation_mutex_

std::mutex correlation::analysis::PerFrameDistributionStore::generation_mutex_
mutableprivate

◆ has_explicit_mean_mask_

bool correlation::analysis::PerFrameDistributionStore::has_explicit_mean_mask_ {false}
private

◆ in_mean_mask_

std::vector<uint8_t> correlation::analysis::PerFrameDistributionStore::in_mean_mask_
private

◆ METRIC_COUNT

std::size_t correlation::analysis::PerFrameDistributionStore::METRIC_COUNT = 4
staticconstexpr

◆ metrics_

std::array<MetricCurveData, METRIC_COUNT> correlation::analysis::PerFrameDistributionStore::metrics_
mutableprivate

◆ mutex_

std::shared_mutex correlation::analysis::PerFrameDistributionStore::mutex_
mutableprivate

◆ total_frames_

std::size_t correlation::analysis::PerFrameDistributionStore::total_frames_ {0}
private

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