Peano 4
Loading...
Searching...
No Matches
applications::exahype2::euler::sphericalaccretion::MassAccumulator Class Reference

Simple spherical mass accumulator. More...

#include <MassAccumulator.h>

Collaboration diagram for applications::exahype2::euler::sphericalaccretion::MassAccumulator:

Public Member Functions

 MassAccumulator (double shellWidth=0.01, double threshold=0.01)
 
void addMass (double mass, double radius)
 
double getMass_piecewiseConstantInterpolation (double radius) const
 If you try to read the mass for a distance where we had no accumulation yet, then this routine returns 0.
 
double getMass_linearInterpolation (double radius) const
 
void finishAccumulation ()
 Finalise data accumulation for next time step.
 
double getMaxRelevantRadius () const
 Return the biggest radius which contributes towards mass.
 
double getTotalMass () const
 This routine returns the total mass.
 

Private Member Functions

int getBucket (double radius) const
 Identifies the right bucket.
 

Private Attributes

tarch::multicore::BooleanSemaphore _semaphore
 
const double _shellWidth
 
const double _threshold
 
std::vector< double_currentMass
 Holds mass per shell.
 
std::vector< double_previousMassAccumulated
 Holds accumulated mass per shell.
 
double _maxDistanceThatMakesContribution
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

Simple spherical mass accumulator.

The idea of this accumulator is that you call it for each volume and the accumulator then, well, accumulates these volumes. For this, it splits the domain around a point into shells, and it keeps track how much mass you find per shell. We discretise the domain into shells, and keep track of some 1d data (mass per shell). Most applications don't use the bookkeeping for the actual mass, but only track the mass resulting from overdensities.

Internally, the accumulator holds two copies of the mass: the current one into which we accumulate, and the data from the previous accumulation. This way, we can roll over the data after a time step and thus effectively reset the accumulation, without loosing the original data.

Thread safety and MPI

The class is thread safe. Every rank should have one instance of this class. At the end of each time step, the instances synchronise automatically.

Bucketing

We split the area around a point into shells of fixed size. The number of shells is not fixed a priori, i.e. in theory it could grow as the buckets are built up upon demand.

Interpolation

Author
Han Zhang, Tobias Weinzierl

Definition at line 55 of file MassAccumulator.h.

Constructor & Destructor Documentation

◆ MassAccumulator()

applications::exahype2::euler::sphericalaccretion::MassAccumulator::MassAccumulator ( double shellWidth = 0.01,
double threshold = 0.01 )
Parameters
shellWidthDefines the width of the individual shells
thresholdAfter a time step, we accumulate the shells from inside to outside. If an additional outer shell's relative contribution to the total mass so far is smaller than threshold, we throw all further shells away.

Definition at line 18 of file MassAccumulator.cpp.

Member Function Documentation

◆ addMass()

void applications::exahype2::euler::sphericalaccretion::MassAccumulator::addMass ( double mass,
double radius )

Definition at line 30 of file MassAccumulator.cpp.

◆ finishAccumulation()

void applications::exahype2::euler::sphericalaccretion::MassAccumulator::finishAccumulation ( )

Finalise data accumulation for next time step.

The routine runs through a sequence of steps:

  • Allreduce _currentMass such that all data from all ranks is available on all ranks. The reduction operator is the sum.
  • Roll over the current data set into previousMassAccumulated and clear that latter. It is, from now on, available for the next accumulation again.
  • Compute accumulated data by running through shells inside-out. _currentMass holds the mass per shell, but eventually we are interested in the accumulated mass, i.e. the integral from the center over the radius r. Note that some shells can be empty as either no (over-)mass is there anymore or a shell was not hit by an integration point or finite volume centre. So the accumulated result is monotonously growing (usually), but the growth is not strict monotonously growing.
  • Find out from which radius on the accumulated data makes no big difference anymore. Truncate the data series here. We effectively now know the maximum radius which makes a difference to the mass accumulation.

Cut off radius

For the cut-off radius, I run through all differences between successive accumulated shells/buckets. If two successive buckets have a (relative) difference which is bigger than 1.0+_threshold, i.e. they differ significantly, this is a potential cut-off: the bigger bucket is one we should definitely still take into account. I take the maximum over all of these cut-off candidates.

It is important that we analyse all bucket differences: We cannot stop this analysis early, as some shells might be empty (see reasons above). So even if two buckets i and i+1 do not differ at all, it might still be that i+1 and i+2 differ significantly.

Definition at line 95 of file MassAccumulator.cpp.

References tarch::mpi::Rank::allReduce(), assertion2, tarch::la::equals(), tarch::mpi::Rank::getInstance(), tarch::services::ServiceRepository::getInstance(), tarch::mpi::Rank::isGlobalMaster(), logDebug, logInfo, and tarch::services::ServiceRepository::receiveDanglingMessages().

Here is the call graph for this function:

◆ getBucket()

int applications::exahype2::euler::sphericalaccretion::MassAccumulator::getBucket ( double radius) const
private

Identifies the right bucket.

There's no guarantee that such a bucket does exist already

Definition at line 25 of file MassAccumulator.cpp.

◆ getMass_linearInterpolation()

double applications::exahype2::euler::sphericalaccretion::MassAccumulator::getMass_linearInterpolation ( double radius) const

Definition at line 54 of file MassAccumulator.cpp.

References assertion, assertion6, tarch::la::greaterEquals(), and tarch::la::smallerEquals().

Here is the call graph for this function:

◆ getMass_piecewiseConstantInterpolation()

double applications::exahype2::euler::sphericalaccretion::MassAccumulator::getMass_piecewiseConstantInterpolation ( double radius) const

If you try to read the mass for a distance where we had no accumulation yet, then this routine returns 0.

The routine therefore is safe to use even in the first time step, where _previousMass is definitely empty.

Parameters
radius

Definition at line 40 of file MassAccumulator.cpp.

◆ getMaxRelevantRadius()

double applications::exahype2::euler::sphericalaccretion::MassAccumulator::getMaxRelevantRadius ( ) const

Return the biggest radius which contributes towards mass.

We know after each step that only a finite number of shells contain meaningful data. The number of shells that we maintain is bounded. We furthermore assume that the solution does not change suddenly, i.e. the mass distribution evolves smoothly in time. This makes us assume that the number of relevant shells grows at most by one per time step, which in turn defines the maximum radius which actually makes a contribution to the total mass.

Returns
Max radius which we think might yield meaningful data

Definition at line 174 of file MassAccumulator.cpp.

◆ getTotalMass()

double applications::exahype2::euler::sphericalaccretion::MassAccumulator::getTotalMass ( ) const

This routine returns the total mass.

This is the mass accumulated in all shells, i.e. the accumulated mass of the biggest shell.

Returns
Total mass accumulated

Definition at line 181 of file MassAccumulator.cpp.

Field Documentation

◆ _currentMass

std::vector<double> applications::exahype2::euler::sphericalaccretion::MassAccumulator::_currentMass
private

Holds mass per shell.

Is used to accumulate data.

Definition at line 67 of file MassAccumulator.h.

◆ _log

tarch::logging::Log applications::exahype2::euler::sphericalaccretion::MassAccumulator::_log
staticprivate

Definition at line 57 of file MassAccumulator.h.

◆ _maxDistanceThatMakesContribution

double applications::exahype2::euler::sphericalaccretion::MassAccumulator::_maxDistanceThatMakesContribution
private

Definition at line 74 of file MassAccumulator.h.

◆ _previousMassAccumulated

std::vector<double> applications::exahype2::euler::sphericalaccretion::MassAccumulator::_previousMassAccumulated
private

Holds accumulated mass per shell.

Definition at line 72 of file MassAccumulator.h.

◆ _semaphore

tarch::multicore::BooleanSemaphore applications::exahype2::euler::sphericalaccretion::MassAccumulator::_semaphore
private

Definition at line 59 of file MassAccumulator.h.

◆ _shellWidth

◆ _threshold

const double applications::exahype2::euler::sphericalaccretion::MassAccumulator::_threshold
private

Definition at line 62 of file MassAccumulator.h.


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