Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
projects::Project Class Referenceabstract

#include <project.h>

Inheritance diagram for projects::Project:

Public Member Functions

 Project ()
virtual ~Project ()
virtual Real getCorrectNumberDensity (spatial_cell::SpatialCell *cell, const uint popID) const
virtual void getParameters ()
virtual bool initialize ()
virtual void hook (cuint &stage, const dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, fsgrids::perbspan perb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid) const
bool initialized ()
virtual void setProjectBField (fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid)
virtual void setupBeforeSetCell (const std::vector< CellID > &cells)
void setCell (spatial_cell::SpatialCell *cell)
 Set the perturbed fields and distribution of a cell according to the default simulation settings. This is used for the NOT_SYSBOUNDARY cells and some other system boundary conditions (e.g. Outflow).
virtual bool canRefine (spatial_cell::SpatialCell *cell) const
virtual bool shouldRefineCell (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, CellID id, Real r_max2) const
virtual bool shouldUnrefineCell (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, CellID id, Real r_max2) const
virtual bool refineSpatialCells (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
virtual uint64_t adaptRefinement (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
 Adapts refinement by one level according to the project. Returns true if any cells were refined, false if not.
virtual bool forceRefinement (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, int n) const
 Refine/unrefine spatial cells one level to the static criteria in the config.
virtual bool filterRefined (dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid) const
 Boxcar filters spatial cells that were recently refined.

Static Public Member Functions

static void addParameters ()

Protected Member Functions

virtual uint findBlocksToInitialize (spatial_cell::SpatialCell *cell, const uint popID) const
 Prepares a list of blocks to loop through when initialising.
void setVelocitySpace (const uint popID, spatial_cell::SpatialCell *cell) const
 Sets the distribution function in a cell.
virtual void calcCellParameters (spatial_cell::SpatialCell *cell, creal &t)
virtual Realf fillPhaseSpace (spatial_cell::SpatialCell *cell, const uint popID, const uint nRequested) const =0
void printPopulations ()
virtual bool rescalesDensity (const uint popID) const
void rescaleDensity (spatial_cell::SpatialCell *cell, const uint popID) const
Real getRandomNumber (std::default_random_engine &randGen) const
void setRandomSeed (uint64_t seedModifier, std::default_random_engine &randGen) const
void setRandomCellSeed (spatial_cell::SpatialCell *cell, std::default_random_engine &randGen) const

Private Attributes

uint seed
bool baseClassInitialized

Static Private Attributes

static char rngStateBuffer [256]

Detailed Description

Definition at line 75 of file project.h.

Constructor & Destructor Documentation

◆ Project()

projects::Project::Project ( )

Definition at line 69 of file project.cpp.

Here is the caller graph for this function:

◆ ~Project()

projects::Project::~Project ( )
virtual

Definition at line 73 of file project.cpp.

Member Function Documentation

◆ adaptRefinement()

uint64_t projects::Project::adaptRefinement ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid) const
virtual

Adapts refinement by one level according to the project. Returns true if any cells were refined, false if not.

Parameters
mpiGridgrid to refine
Returns
The amount of cells set to refine

Definition at line 516 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addParameters()

void projects::Project::addParameters ( void )
static

Register parameters that should be read in.

Definition at line 75 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcCellParameters()

void projects::Project::calcCellParameters ( spatial_cell::SpatialCell * cell,
creal & t )
protectedvirtual

Calculate potentially needed parameters for the given spatial cell at the given time.

Currently this function is only called during initialization.

The following array indices contain the coordinates of the "lower left corner" of the cell: CellParams::XCRD, CellParams::YCRD, and CellParams::ZCRD. The cell size is given in the following array indices: CellParams::DX, CellParams::DY, and CellParams::DZ.

Parameters
cellPointer to the spatial cell to be handled.
tThe current value of time. This is passed as a convenience. If you need more detailed information of the state of the simulation, you can read it from Parameters.

Print a warning message to stderr and abort, one should not use the base class functions.

Reimplemented in projects::Alfven, projects::Diffusion, projects::Dispersion, projects::Distributions, projects::Firehose, projects::Flowthrough, projects::Fluctuations, projects::Harris, projects::IPShock, projects::KHB, projects::Larmor, projects::LossCone, projects::Magnetosphere, projects::MultiPeak, projects::Riemann1, projects::Shock, projects::Shocktest, projects::test_fp, projects::TestHall, and projects::verificationLarmor.

Definition at line 296 of file project.cpp.

Here is the caller graph for this function:

◆ canRefine()

bool projects::Project::canRefine ( spatial_cell::SpatialCell * cell) const
virtual

Definition at line 421 of file project.cpp.

Here is the caller graph for this function:

◆ fillPhaseSpace()

virtual Realf projects::Project::fillPhaseSpace ( spatial_cell::SpatialCell * cell,
const uint popID,
const uint nRequested ) const
protectedpure virtual

Calculates the distribution function contents for the spatial cell and population in question NOTE: This function is called inside parallel region so it must be declared as const. This function will contain a loop over nRequested velocity blocks, with the block GlobalIDs provided in the GIDlist buffer, storing phase-space densities in the bufferData buffer.

Parameters
popIDParticle species ID.
Returns
The total stored number density of the cell for this population The physical unit of this quantity is 1/m^3.

Implemented in projects::Alfven, projects::Diffusion, projects::Dispersion, projects::Distributions, projects::Firehose, projects::Flowthrough, projects::Fluctuations, projects::Harris, projects::IPShock, projects::KHB, projects::Larmor, projects::LossCone, projects::Magnetosphere, projects::MultiPeak, projects::Riemann1, projects::Shock, projects::Shocktest, projects::Template, projects::test_fp, projects::TestHall, and projects::verificationLarmor.

Here is the caller graph for this function:

◆ filterRefined()

bool projects::Project::filterRefined ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid) const
virtual

Boxcar filters spatial cells that were recently refined.

Parameters
mpiGridgrid to filter

Definition at line 601 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findBlocksToInitialize()

uint projects::Project::findBlocksToInitialize ( spatial_cell::SpatialCell * cell,
const uint popID ) const
protectedvirtual

Prepares a list of blocks to loop through when initialising.

The base class version just prepares all blocks, which amounts to looping through the whole velocity space. This is very expensive and becomes prohibitive in cases where a large velocity space is needed with only small portions actually containing something. Use with care. NOTE: This function is called inside parallel region so it must be declared as const. The function stores the prepared blocks into cell->velocity_block_with_content_list and returns the count.

Reimplemented in projects::TriAxisSearch.

Definition at line 175 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forceRefinement()

bool projects::Project::forceRefinement ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
int n ) const
virtual

Refine/unrefine spatial cells one level to the static criteria in the config.

Parameters
mpiGridSpatial grid
nStatic refinement pass. 0th pass refines level 0 cells and unrefines max level cells, 1st pass refines level 1 and unrefines max level -1 etc.

Definition at line 591 of file project.cpp.

Here is the caller graph for this function:

◆ getCorrectNumberDensity()

Real projects::Project::getCorrectNumberDensity ( spatial_cell::SpatialCell * cell,
const uint popID ) const
virtual

Get correct number density base class function?

Reimplemented in projects::Flowthrough.

Definition at line 308 of file project.cpp.

Here is the caller graph for this function:

◆ getParameters()

◆ getRandomNumber()

Real projects::Project::getRandomNumber ( std::default_random_engine & randGen) const
protected

Get random number between 0 and 1.0. One should always first initialize the rng.

Parameters
rngDataBufferstruct of type random_data
Returns
Uniformly distributed random number between 0 and 1.

Definition at line 317 of file project.cpp.

Here is the caller graph for this function:

◆ hook()

void projects::Project::hook ( cuint & stage,
const dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
fsgrids::perbspan perb,
fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid ) const
virtual

Perform some operation at each time step in the main program loop.

Reimplemented in projects::Dispersion.

Definition at line 138 of file project.cpp.

Here is the caller graph for this function:

◆ initialize()

bool projects::Project::initialize ( void )
virtual

Initialize project. Can be used, e.g., to read in parameters from the input file.

Initialize the Project. Velocity mesh and particle population parameters are read from the configuration file, and corresponding internal variables are created here. NOTE: Each project must call this function!

Returns
If true, particle species and velocity meshes were created successfully.

Reimplemented in projects::Alfven, projects::Diffusion, projects::Dispersion, projects::Distributions, projects::Firehose, projects::Flowthrough, projects::Fluctuations, projects::Harris, projects::IPShock, projects::KHB, projects::Larmor, projects::LossCone, projects::Magnetosphere, projects::MultiPeak, projects::Riemann1, projects::Shock, projects::Shocktest, projects::Template, projects::test_fp, projects::TestHall, and projects::verificationLarmor.

Definition at line 113 of file project.cpp.

Here is the caller graph for this function:

◆ initialized()

bool projects::Project::initialized ( )

Check if base class has been initialized.

Returns
If true, base class was successfully initialized.

Definition at line 124 of file project.cpp.

Here is the caller graph for this function:

◆ printPopulations()

void projects::Project::printPopulations ( )
protected

Write simulated particle populations to logfile.

Definition at line 219 of file project.cpp.

Here is the call graph for this function:

◆ refineSpatialCells()

bool projects::Project::refineSpatialCells ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid) const
virtual

Reimplemented in projects::IPShock.

Definition at line 354 of file project.cpp.

Here is the caller graph for this function:

◆ rescaleDensity()

void projects::Project::rescaleDensity ( spatial_cell::SpatialCell * cell,
const uint popID ) const
protected

Rescale the distribution function of the given particle species so that the number density corresponds to the value returned by getCorrectNumberDensity.

Parameters
cellSpatial cell.
popIDID of the particle species.

Definition at line 272 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rescalesDensity()

bool projects::Project::rescalesDensity ( const uint popID) const
protectedvirtual

Check if the project wants to rescale densities.

Parameters
popIDID of the particle species.
Returns
If true, rescaleDensity is called for this species.

Reimplemented in projects::Flowthrough.

Definition at line 264 of file project.cpp.

Here is the caller graph for this function:

◆ setCell()

void projects::Project::setCell ( spatial_cell::SpatialCell * cell)

Set the perturbed fields and distribution of a cell according to the default simulation settings. This is used for the NOT_SYSBOUNDARY cells and some other system boundary conditions (e.g. Outflow).

Parameters
cellPointer to the cell to set.

Definition at line 150 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setProjectBField()

void projects::Project::setProjectBField ( fsgrids::perbspan perb,
fsgrids::bgbspan bgb,
fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid )
virtual

Set the background and perturbed magnetic fields for this project.

Parameters
perBGridGrid on which values of the perturbed field can be set if needed.
BgBGridGrid on which values for the background field can be set if needed, e.g. using the background field functions.
technicalTechnical fsgrid, available if some of its data is necessary.
See also
setBackgroundField, setBackgroundFieldToZero

Print a warning message to stderr and abort, one should not use the base class functions.

Reimplemented in projects::Alfven, projects::Diffusion, projects::Dispersion, projects::Distributions, projects::Firehose, projects::Flowthrough, projects::Fluctuations, projects::Harris, projects::IPShock, projects::KHB, projects::Larmor, projects::LossCone, projects::Magnetosphere, projects::MultiPeak, projects::Riemann1, projects::Shock, projects::Shocktest, projects::Template, projects::test_fp, projects::TestHall, and projects::verificationLarmor.

Definition at line 127 of file project.cpp.

Here is the caller graph for this function:

◆ setRandomCellSeed()

void projects::Project::setRandomCellSeed ( spatial_cell::SpatialCell * cell,
std::default_random_engine & randGen ) const
protected

Set random seed (thread-safe) that is always the same for this particular cellID. Can be used to make reproducible simulations that do not depend on number of processes or threads.

Parameters
cellSpatialCell used to infer CellID value to use as seed modifier
rngStateBufferbuffer where random number values are kept
rngDataBufferstruct of type random_data

Set random seed (thread-safe) that is always the same for this particular cellID. Can be used to make reproducible simulations that do not depend on number of processes or threads.

Parameters
cellSpatialCell used to infer CellID value to use as seed modifier

autotoc_md2

Parameters
randGenstd::default_random_engine& to use

Definition at line 336 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRandomSeed()

void projects::Project::setRandomSeed ( uint64_t seedModifier,
std::default_random_engine & randGen ) const
protected

Set random seed (thread-safe). Seed is based on the seed read in from cfg + the seedModifier parameter

Parameters
seedModifierCellID value to use as seed modifier
rngStateBufferbuffer where random number values are kept
rngDataBufferstruct of type random_data

Set random seed (thread-safe). Seed is based on the seed read in from cfg + the seedModifier parameter

Parameters
seedModifiervalue (e.g. CellID) to use as seed modifier

autotoc_md1

Parameters
randGenstd::default_random_engine& to use

Definition at line 326 of file project.cpp.

Here is the caller graph for this function:

◆ setupBeforeSetCell()

void projects::Project::setupBeforeSetCell ( const std::vector< CellID > & cells)
virtual

Setup data structures for subsequent setCell calls. This will most likely be empty for most projects, except for some advanced data juggling ones (like restart from a subset of a larger run)

Parameters
cellsLocal cellIDs of this task.

Definition at line 142 of file project.cpp.

Here is the caller graph for this function:

◆ setVelocitySpace()

void projects::Project::setVelocitySpace ( const uint popID,
spatial_cell::SpatialCell * cell ) const
protected

Sets the distribution function in a cell.

Uses the function findBlocksToInitialize and loops through the list returned by it to initialize the cells' velocity space. NOTE: This function is called inside parallel region so it must be declared as const.

See also
findBlocksToInitialize

Definition at line 235 of file project.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shouldRefineCell()

bool projects::Project::shouldRefineCell ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
CellID id,
Real r_max2 ) const
virtual

Definition at line 425 of file project.cpp.

Here is the caller graph for this function:

◆ shouldUnrefineCell()

bool projects::Project::shouldUnrefineCell ( dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
CellID id,
Real r_max2 ) const
virtual

Definition at line 470 of file project.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ baseClassInitialized

bool projects::Project::baseClassInitialized
private

If true, base class has been initialized.

Definition at line 226 of file project.h.

◆ rngStateBuffer

char projects::Project::rngStateBuffer
staticprivate

Definition at line 224 of file project.h.

◆ seed

uint projects::Project::seed
private

Definition at line 223 of file project.h.


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