Peano 4

Simple spherical mass accumulator. More...
#include <MassAccumulator.h>
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 
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.
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.
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.
Definition at line 55 of file MassAccumulator.h.
applications::exahype2::euler::sphericalaccretion::MassAccumulator::MassAccumulator  (  double  shellWidth = 0.01, 
double  threshold = 0.01 ) 
shellWidth  Defines the width of the individual shells 
threshold  After 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.
void applications::exahype2::euler::sphericalaccretion::MassAccumulator::addMass  (  double  mass, 
double  radius ) 
Definition at line 30 of file MassAccumulator.cpp.
void applications::exahype2::euler::sphericalaccretion::MassAccumulator::finishAccumulation  (  ) 
Finalise data accumulation for next time step.
The routine runs through a sequence of steps:
For the cutoff 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 cutoff: the bigger bucket is one we should definitely still take into account. I take the maximum over all of these cutoff 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().

private 
Identifies the right bucket.
There's no guarantee that such a bucket does exist already
Definition at line 25 of file MassAccumulator.cpp.
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().
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.
radius 
Definition at line 40 of file MassAccumulator.cpp.
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.
Definition at line 174 of file MassAccumulator.cpp.
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.
Definition at line 181 of file MassAccumulator.cpp.

private 

staticprivate 
Definition at line 57 of file MassAccumulator.h.

private 
Definition at line 74 of file MassAccumulator.h.

private 
Holds accumulated mass per shell.
Definition at line 72 of file MassAccumulator.h.

private 
Definition at line 59 of file MassAccumulator.h.

private 
Definition at line 61 of file MassAccumulator.h.
Referenced by petsc.Project.Project::__generate_solver_repository(), peano4.dastgen2.MPIAndStorageAspect.MPIAndStorageAspect::__str__(), package.Exahype2::cmake_args(), PointWiseClawPackAdaptiveTimeStepSize.PointWiseClawPackAdaptiveTimeStepSize::create_data_structures(), peano4.toolbox.particles.api.UpdateParticleGridAssociation_Reassign.UpdateParticleGridAssociation_Reassign::get_body_of_operation(), and package.Exahype2::setup_run_environment().
Definition at line 62 of file MassAccumulator.h.