GooseEPM v0.11.0
Loading...
Searching...
No Matches
GooseEPM::AvalancheSegmenter< Dimension > Class Template Reference

Segment event in spatially correlated avalanches. More...

#include <GooseEPM/System.h>

Public Member Functions

 AvalancheSegmenter (const std::array< size_t, Dim > &shape, const array_type::tensor< size_t, 1 > &idx, const array_type::tensor< double, 1 > &t)
 
size_t nlabels ()
 Current number of labels (including the background).
 
void prune ()
 Prune: renumber labels to lowest possible label, see also AvalancheSegmenter::nlabels.
 
void change_labels (const array_type::tensor< size_t, 1 > &new_label)
 Apply renumbering.
 
void reorder (const array_type::tensor< ptrdiff_t, 1 > &labels)
 Reorder the labels.
 
void advance (size_t n=1)
 Advance n yielding events.
 
void advance_to (double t, bool floor=false)
 Advance to the yielding events closest to a time t.
 
std::string repr () const
 Basic class info.
 
const auto & shape () const
 Shape of AvalancheSegmenter::s and AvalancheSegmenter::labels.
 
auto size () const
 Size of AvalancheSegmenter::s and AvalancheSegmenter::labels (== prod(shape)).
 
const auto & s () const
 Per block, how many times it has yielded.
 
const auto & labels () const
 Per block, the label (0 for background).
 
size_t nstep ()
 Number of yielding events taken into account.
 
auto t () const
 Time of each entry in m_idx.
 

Static Public Attributes

static constexpr size_t Dim = Dimension
 Dimensionality of the system.
 

Detailed Description

template<size_t Dimension>
class GooseEPM::AvalancheSegmenter< Dimension >

Segment event in spatially correlated avalanches.

Template Parameters
DimensionDimensionality of the system.

A sequence of yielding blocks and their times is given. Event-per-event the number of times each block has yielded is updated (AvalancheSegmenter::s), and it is determined if the 'failing' block is connected to a previously failed cluster. Depending on the number of clusters it is connected to:

  • 0: A new label is created.
  • 1: The block is added to the cluster (is assigned the label of that cluster).
  • > 2: The block and all connected clusters are labeled using the lowest of all labels. The labels of the merged clusters are not reused until AvalancheSegmenter::prune is called.

Note that:

Definition at line 2136 of file System.h.

Constructor & Destructor Documentation

◆ AvalancheSegmenter()

template<size_t Dimension>
GooseEPM::AvalancheSegmenter< Dimension >::AvalancheSegmenter ( const std::array< size_t, Dim > &  shape,
const array_type::tensor< size_t, 1 > &  idx,
const array_type::tensor< double, 1 > &  t 
)
inline
Parameters
shapeShape of the system.
idxSequence of yielding blocks (flat-index).
tTime of each entry in m_idx.
Todo:
  • Make t optional.
  • Allow different kernels. Current: [1 1 1] in 1d, [[0 1 0], [1 1 1], [0 1 0]] in 2d.

Definition at line 2185 of file System.h.

Member Function Documentation

◆ advance()

template<size_t Dimension>
void GooseEPM::AvalancheSegmenter< Dimension >::advance ( size_t  n = 1)
inline

Advance n yielding events.

Parameters
nNumber of yielding events to advance.

Definition at line 2390 of file System.h.

◆ advance_to()

template<size_t Dimension>
void GooseEPM::AvalancheSegmenter< Dimension >::advance_to ( double  t,
bool  floor = false 
)
inline

Advance to the yielding events closest to a time t.

Parameters
tTime to advance to.
floorIf true, the time is rounded down to the nearest time step, otherwise the closest time step is selected.

Definition at line 2472 of file System.h.

◆ change_labels()

template<size_t Dimension>
void GooseEPM::AvalancheSegmenter< Dimension >::change_labels ( const array_type::tensor< size_t, 1 > &  new_label)
inline

Apply renumbering.

Parameters
new_labelList of new labels for each label (in use). For each current label i, the new label is new_label[i].
Note
  • new_label.size >= segmenter.nlabels
  • Internal assumption: max(new_label) < segmenter.size + 1.

Definition at line 2281 of file System.h.

◆ labels()

template<size_t Dimension>
const auto & GooseEPM::AvalancheSegmenter< Dimension >::labels ( ) const
inline

Per block, the label (0 for background).

Returns
array of signed integers.

Definition at line 2541 of file System.h.

◆ nlabels()

template<size_t Dimension>
size_t GooseEPM::AvalancheSegmenter< Dimension >::nlabels ( )
inline

Current number of labels (including the background).

Note
If AvalancheSegmenter::prune has been called (or no clusters where merged), segmenter.nlabels == max(segmenter.labels) + 1 == unique(segmenter.labels).size. Otherwise this is just an upper bound.
Returns
unsigned integer.

Definition at line 2225 of file System.h.

◆ nstep()

template<size_t Dimension>
size_t GooseEPM::AvalancheSegmenter< Dimension >::nstep ( )
inline

Number of yielding events taken into account.

The events that are taken into account are idx[:segmenter.nstep]. By definition sum(segmenter.s) == segmenter.nstep.

Returns
unsigned integer.

Definition at line 2554 of file System.h.

◆ prune()

template<size_t Dimension>
void GooseEPM::AvalancheSegmenter< Dimension >::prune ( )
inline

Prune: renumber labels to lowest possible label, see also AvalancheSegmenter::nlabels.

Note
This might change all labels.

Definition at line 2234 of file System.h.

◆ reorder()

template<size_t Dimension>
void GooseEPM::AvalancheSegmenter< Dimension >::reorder ( const array_type::tensor< ptrdiff_t, 1 > &  labels)
inline

Reorder the labels.

Parameters
labelsList new order of labels (unique(segmenter.labels) in desired order).

Definition at line 2302 of file System.h.

◆ repr()

template<size_t Dimension>
std::string GooseEPM::AvalancheSegmenter< Dimension >::repr ( ) const
inline

Basic class info.

Returns
std::string

Definition at line 2502 of file System.h.

◆ s()

template<size_t Dimension>
const auto & GooseEPM::AvalancheSegmenter< Dimension >::s ( ) const
inline

Per block, how many times it has yielded.

Returns
array of unsigned integers.

Definition at line 2530 of file System.h.

◆ shape()

template<size_t Dimension>
const auto & GooseEPM::AvalancheSegmenter< Dimension >::shape ( ) const
inline

Shape of AvalancheSegmenter::s and AvalancheSegmenter::labels.

Returns
Shape

Definition at line 2512 of file System.h.

◆ size()

template<size_t Dimension>
auto GooseEPM::AvalancheSegmenter< Dimension >::size ( ) const
inline

Size of AvalancheSegmenter::s and AvalancheSegmenter::labels (== prod(shape)).

Returns
Size

Definition at line 2521 of file System.h.

◆ t()

template<size_t Dimension>
auto GooseEPM::AvalancheSegmenter< Dimension >::t ( ) const
inline

Time of each entry in m_idx.

Returns
double

Definition at line 2563 of file System.h.

Member Data Documentation

◆ Dim

template<size_t Dimension>
constexpr size_t GooseEPM::AvalancheSegmenter< Dimension >::Dim = Dimension
staticconstexpr

Dimensionality of the system.

Definition at line 2138 of file System.h.


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