Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
common.h File Reference
#include <limits>
#include <string>
#include <vector>
#include <span>
#include "definitions.h"
#include "arch/arch_device_api.h"
Include dependency graph for common.h:

Go to the source code of this file.

Classes

struct  fsgrids::technical
struct  globalflags

Namespaces

namespace  Neighborhoods
namespace  BlockParams
namespace  CellParams
namespace  bvolderivatives
namespace  vderivatives
namespace  fsgrids
namespace  sysboundarytype
namespace  compute
namespace  donow
namespace  hook
namespace  physicalconstants

Macros

#define CHECK_FLOAT(x)
#define sqr(x)
#define pow2(x)
#define pow3(x)
#define MASTER_RANK   0
#define MAX_BLOCKS_PER_DIM   256
#define WID   (4)

Typedefs

typedef std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > fsgrids::perbspan
typedef std::span< const std::array< Real, fsgrids::bfield::N_BFIELD > > fsgrids::constperbspan
typedef std::span< std::array< Real, fsgrids::efield::N_EFIELD > > fsgrids::efieldspan
typedef std::span< const std::array< Real, fsgrids::efield::N_EFIELD > > fsgrids::constefieldspan
typedef std::span< std::array< Real, fsgrids::ehall::N_EHALL > > fsgrids::ehallspan
typedef std::span< const std::array< Real, fsgrids::ehall::N_EHALL > > fsgrids::constehallspan
typedef std::span< std::array< Real, fsgrids::egradpe::N_EGRADPE > > fsgrids::egradpespan
typedef std::span< const std::array< Real, fsgrids::egradpe::N_EGRADPE > > fsgrids::constegradpespan
typedef std::span< std::array< Real, fsgrids::dperb::N_DPERB > > fsgrids::dperbspan
typedef std::span< const std::array< Real, fsgrids::dperb::N_DPERB > > fsgrids::constdperbspan
typedef std::span< std::array< Real, bgbfield::N_BGB > > fsgrids::bgbspan
typedef std::span< const std::array< Real, bgbfield::N_BGB > > fsgrids::constbgbspan
typedef std::span< std::array< Real, fsgrids::moments::N_MOMENTS > > fsgrids::momentsspan
typedef std::span< const std::array< Real, fsgrids::moments::N_MOMENTS > > fsgrids::constmomentsspan
typedef std::span< std::array< Real, fsgrids::dmoments::N_DMOMENTS > > fsgrids::dmomentsspan
typedef std::span< const std::array< Real, fsgrids::dmoments::N_DMOMENTS > > fsgrids::constdmomentsspan
typedef std::span< std::array< Real, fsgrids::volfields::N_VOL > > fsgrids::volspan
typedef std::span< const std::array< Real, fsgrids::volfields::N_VOL > > fsgrids::constvolspan
typedef std::span< technicalfsgrids::technicalspan
typedef std::span< const technicalfsgrids::consttechnicalspan

Enumerations

enum  {
  Neighborhoods::VLASOV_SOLVER , Neighborhoods::VLASOV_SOLVER_X , Neighborhoods::VLASOV_SOLVER_Y , Neighborhoods::VLASOV_SOLVER_Z ,
  Neighborhoods::VLASOV_SOLVER_TARGET_X , Neighborhoods::VLASOV_SOLVER_TARGET_Y , Neighborhoods::VLASOV_SOLVER_TARGET_Z , Neighborhoods::SYSBOUNDARIES ,
  Neighborhoods::SYSBOUNDARIES_EXTENDED , Neighborhoods::NEAREST , Neighborhoods::FULL , Neighborhoods::DIST_FUNC ,
  Neighborhoods::SHIFT_P_X , Neighborhoods::SHIFT_P_Y , Neighborhoods::SHIFT_P_Z , Neighborhoods::SHIFT_M_X ,
  Neighborhoods::SHIFT_M_Y , Neighborhoods::SHIFT_M_Z , Neighborhoods::VLASOV_SOLVER_X_GHOST , Neighborhoods::VLASOV_SOLVER_Y_GHOST ,
  Neighborhoods::VLASOV_SOLVER_Z_GHOST , Neighborhoods::VLASOV_SOLVER_GHOST , Neighborhoods::VLASOV_SOLVER_GHOST_REQNEIGH , Neighborhoods::N_NEIGHBORHOODS
}
enum  {
  BlockParams::VXCRD , BlockParams::VYCRD , BlockParams::VZCRD , BlockParams::DVX ,
  BlockParams::DVY , BlockParams::DVZ , BlockParams::N_VELOCITY_BLOCK_PARAMS
}
enum  {
  CellParams::XCRD , CellParams::YCRD , CellParams::ZCRD , CellParams::DX ,
  CellParams::DY , CellParams::DZ , CellParams::RHOM , CellParams::VX ,
  CellParams::VY , CellParams::VZ , CellParams::RHOQ , CellParams::RHOM_DT2 ,
  CellParams::VX_DT2 , CellParams::VY_DT2 , CellParams::VZ_DT2 , CellParams::RHOQ_DT2 ,
  CellParams::BGBXVOL , CellParams::BGBYVOL , CellParams::BGBZVOL , CellParams::PERBXVOL ,
  CellParams::PERBYVOL , CellParams::PERBZVOL , CellParams::EXGRADPE , CellParams::EYGRADPE ,
  CellParams::EZGRADPE , CellParams::RHOM_R , CellParams::VX_R , CellParams::VY_R ,
  CellParams::VZ_R , CellParams::RHOQ_R , CellParams::RHOM_V , CellParams::VX_V ,
  CellParams::VY_V , CellParams::VZ_V , CellParams::RHOQ_V , CellParams::P_11 ,
  CellParams::P_22 , CellParams::P_33 , CellParams::P_23 , CellParams::P_13 ,
  CellParams::P_12 , CellParams::P_11_DT2 , CellParams::P_22_DT2 , CellParams::P_33_DT2 ,
  CellParams::P_23_DT2 , CellParams::P_13_DT2 , CellParams::P_12_DT2 , CellParams::P_11_R ,
  CellParams::P_22_R , CellParams::P_33_R , CellParams::P_23_R , CellParams::P_13_R ,
  CellParams::P_12_R , CellParams::P_11_V , CellParams::P_22_V , CellParams::P_33_V ,
  CellParams::P_23_V , CellParams::P_12_V , CellParams::P_13_V , CellParams::EXVOL ,
  CellParams::EYVOL , CellParams::EZVOL , CellParams::MAXVDT , CellParams::MAXRDT ,
  CellParams::MAXFDT , CellParams::LBWEIGHTCOUNTER , CellParams::ISCELLSAVINGF , CellParams::FSGRID_RANK ,
  CellParams::FSGRID_BOUNDARYTYPE , CellParams::CELLID , CellParams::REFINEMENT_LEVEL , CellParams::CONNECTION ,
  CellParams::CONNECTION_FW_X , CellParams::CONNECTION_FW_Y , CellParams::CONNECTION_FW_Z , CellParams::CONNECTION_BW_X ,
  CellParams::CONNECTION_BW_Y , CellParams::CONNECTION_BW_Z , CellParams::CURVATUREX , CellParams::CURVATUREY ,
  CellParams::CURVATUREZ , CellParams::FLUXROPE , CellParams::AMR_DRHO , CellParams::AMR_DU ,
  CellParams::AMR_DPSQ , CellParams::AMR_DBSQ , CellParams::AMR_DB , CellParams::AMR_ALPHA1 ,
  CellParams::AMR_ALPHA2 , CellParams::P_ANISOTROPY , CellParams::AMR_VORTICITY , CellParams::RECENTLY_REFINED ,
  CellParams::BULKV_FORCING_X , CellParams::BULKV_FORCING_Y , CellParams::BULKV_FORCING_Z , CellParams::NU0 ,
  CellParams::N_SPATIAL_CELL_PARAMS
}
enum  {
  bvolderivatives::dPERBXVOLdx , bvolderivatives::dPERBXVOLdy , bvolderivatives::dPERBXVOLdz , bvolderivatives::dPERBYVOLdx ,
  bvolderivatives::dPERBYVOLdy , bvolderivatives::dPERBYVOLdz , bvolderivatives::dPERBZVOLdx , bvolderivatives::dPERBZVOLdy ,
  bvolderivatives::dPERBZVOLdz , bvolderivatives::N_BVOL_DERIVATIVES
}
enum  {
  vderivatives::dVxdx , vderivatives::dVxdy , vderivatives::dVxdz , vderivatives::dVydx ,
  vderivatives::dVydy , vderivatives::dVydz , vderivatives::dVzdx , vderivatives::dVzdy ,
  vderivatives::dVzdz , vderivatives::N_V_DERIVATIVES
}
enum  fsgrids::bfield : int { fsgrids::PERBX , fsgrids::PERBY , fsgrids::PERBZ , fsgrids::N_BFIELD }
enum  fsgrids::efield { fsgrids::EX , fsgrids::EY , fsgrids::EZ , fsgrids::N_EFIELD }
enum  fsgrids::ehall {
  fsgrids::EXHALL_000_100 , fsgrids::EYHALL_000_010 , fsgrids::EZHALL_000_001 , fsgrids::EYHALL_100_110 ,
  fsgrids::EZHALL_100_101 , fsgrids::EXHALL_010_110 , fsgrids::EZHALL_010_011 , fsgrids::EZHALL_110_111 ,
  fsgrids::EXHALL_001_101 , fsgrids::EYHALL_001_011 , fsgrids::EYHALL_101_111 , fsgrids::EXHALL_011_111 ,
  fsgrids::N_EHALL
}
enum  fsgrids::egradpe { fsgrids::EXGRADPE , fsgrids::EYGRADPE , fsgrids::EZGRADPE , fsgrids::N_EGRADPE }
enum  fsgrids::moments {
  fsgrids::RHOM , fsgrids::RHOQ , fsgrids::VX , fsgrids::VY ,
  fsgrids::VZ , fsgrids::P_11 , fsgrids::P_22 , fsgrids::P_33 ,
  fsgrids::N_MOMENTS
}
enum  fsgrids::dperb {
  fsgrids::dPERBxdy , fsgrids::dPERBxdz , fsgrids::dPERBydx , fsgrids::dPERBydz ,
  fsgrids::dPERBzdx , fsgrids::dPERBzdy , fsgrids::dPERBxdyy , fsgrids::dPERBxdzz ,
  fsgrids::dPERBxdyz , fsgrids::dPERBydxx , fsgrids::dPERBydzz , fsgrids::dPERBydxz ,
  fsgrids::dPERBzdxx , fsgrids::dPERBzdyy , fsgrids::dPERBzdxy , fsgrids::N_DPERB
}
enum  fsgrids::dmoments {
  fsgrids::drhomdx , fsgrids::drhomdy , fsgrids::drhomdz , fsgrids::drhoqdx ,
  fsgrids::drhoqdy , fsgrids::drhoqdz , fsgrids::dp11dx , fsgrids::dp11dy ,
  fsgrids::dp11dz , fsgrids::dp22dx , fsgrids::dp22dy , fsgrids::dp22dz ,
  fsgrids::dp33dx , fsgrids::dp33dy , fsgrids::dp33dz , fsgrids::dVxdx ,
  fsgrids::dVxdy , fsgrids::dVxdz , fsgrids::dVydx , fsgrids::dVydy ,
  fsgrids::dVydz , fsgrids::dVzdx , fsgrids::dVzdy , fsgrids::dVzdz ,
  fsgrids::dPedx , fsgrids::dPedy , fsgrids::dPedz , fsgrids::N_DMOMENTS
}
enum  fsgrids::bgbfield : int {
  fsgrids::BGBX , fsgrids::BGBY , fsgrids::BGBZ , fsgrids::BGBXVOL ,
  fsgrids::BGBYVOL , fsgrids::BGBZVOL , fsgrids::BGBXVDCORR , fsgrids::BGBYVDCORR ,
  fsgrids::BGBZVDCORR , fsgrids::dBGBxdy , fsgrids::dBGBxdz , fsgrids::dBGBydx ,
  fsgrids::dBGBydz , fsgrids::dBGBzdx , fsgrids::dBGBzdy , fsgrids::dBGBXVOLdx ,
  fsgrids::dBGBXVOLdy , fsgrids::dBGBXVOLdz , fsgrids::dBGBYVOLdx , fsgrids::dBGBYVOLdy ,
  fsgrids::dBGBYVOLdz , fsgrids::dBGBZVOLdx , fsgrids::dBGBZVOLdy , fsgrids::dBGBZVOLdz ,
  fsgrids::N_BGB
}
enum  fsgrids::volfields {
  fsgrids::PERBXVOL , fsgrids::PERBYVOL , fsgrids::PERBZVOL , fsgrids::dPERBXVOLdx ,
  fsgrids::dPERBXVOLdy , fsgrids::dPERBXVOLdz , fsgrids::dPERBYVOLdx , fsgrids::dPERBYVOLdy ,
  fsgrids::dPERBYVOLdz , fsgrids::dPERBZVOLdx , fsgrids::dPERBZVOLdy , fsgrids::dPERBZVOLdz ,
  fsgrids::EXVOL , fsgrids::EYVOL , fsgrids::EZVOL , fsgrids::CURVATUREX ,
  fsgrids::CURVATUREY , fsgrids::CURVATUREZ , fsgrids::N_VOL
}
enum  ionosphereParameters {
  SOURCE , SIGMA , SIGMA12 , SIGMA13 ,
  SIGMA21 , SIGMA22 , SIGMA23 , SIGMA31 ,
  SIGMA32 , SIGMA33 , SIGMAP , SIGMAH ,
  SIGMAPARALLEL , PRECIP , RHON , TEMPERATURE ,
  NODE_BX , NODE_BY , NODE_BZ , UPMAPPED_BX ,
  UPMAPPED_BY , UPMAPPED_BZ , SOLUTION , BEST_SOLUTION ,
  RESIDUAL , RRESIDUAL , ZPARAM , ZZPARAM ,
  PPPARAM , PPARAM , N_IONOSPHERE_PARAMETERS
}
enum  {
  sysboundarytype::DO_NOT_COMPUTE , sysboundarytype::NOT_SYSBOUNDARY , sysboundarytype::IONOSPHERE , sysboundarytype::OUTFLOW ,
  sysboundarytype::MAXWELLIAN , sysboundarytype::COPYSPHERE , sysboundarytype::OUTER_BOUNDARY_PADDING , sysboundarytype::N_SYSBOUNDARY_CONDITIONS
}
enum  { RK_ORDER1 , RK_ORDER2_STEP1 , RK_ORDER2_STEP2 }
enum  {
  donow::SAVE , donow::DORC , donow::DOLB , donow::DOMR ,
  donow::N_DONOW
}
enum  { hook::END_OF_TIME_STEP }

Functions

void bailout (const bool condition, const std::string &message)
 A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.
void bailout (const bool condition, const char *const file, const int line)
 A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.
void bailout (const bool condition, const std::string &message, const char *const file, const int line)
 A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.
void abort_mpi (const std::string str, const int err_type=0)
template<typename INT>
ARCH_HOSTDEV INT cellIndex (const INT &i, const INT &j, const INT &k)
template<typename T>
int sign (const T &value)
const std::vector< CellID > & getLocalCells ()

Variables

const uint compute::BX = (1 << 0)
const uint compute::BY = (1 << 1)
const uint compute::BZ = (1 << 2)
const uint compute::EX = (1 << 3)
const uint compute::EY = (1 << 4)
const uint compute::EZ = (1 << 5)
const int WID2 = WID*WID
const int WID3 = WID2*WID
const int SIZE_VELBLOCK = WID3
const Real physicalconstants::EPS_0 = 8.85418782e-12
const Real physicalconstants::MU_0 = 1.25663706e-6
const Real physicalconstants::K_B = 1.3806503e-23
const Real physicalconstants::CHARGE = 1.60217653e-19
const Real physicalconstants::MASS_ELECTRON = 9.10938188e-31
const Real physicalconstants::MASS_PROTON = 1.67262158e-27
const Real physicalconstants::R_E = 6.3712e6

Macro Definition Documentation

◆ CHECK_FLOAT

#define CHECK_FLOAT ( x)
Value:
{}

Definition at line 42 of file common.h.

◆ MASTER_RANK

#define MASTER_RANK   0

Definition at line 67 of file common.h.

◆ MAX_BLOCKS_PER_DIM

#define MAX_BLOCKS_PER_DIM   256

Definition at line 73 of file common.h.

◆ pow2

#define pow2 ( x)
Value:
sqr(x)
#define sqr(x)
Definition common.h:63

Definition at line 64 of file common.h.

◆ pow3

#define pow3 ( x)
Value:
((x)*(x)*(x))

Definition at line 65 of file common.h.

◆ sqr

#define sqr ( x)
Value:
((x)*(x))

Definition at line 63 of file common.h.

◆ WID

#define WID   (4)

Number of cells per coordinate in a velocity block. Defaults to the historical 4.

Definition at line 514 of file common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Steps in Runge-Kutta methods

Enumerator
RK_ORDER1 

First order method, one step (and initialisation)

RK_ORDER2_STEP1 

Two-step second order method, first step

RK_ORDER2_STEP2 

Two-step second order method, second step

Definition at line 508 of file common.h.

◆ ionosphereParameters

Enumerator
SOURCE 

Field aligned current source term (Ampere). Note: this is current, not density.

SIGMA 
SIGMA12 
SIGMA13 
SIGMA21 
SIGMA22 
SIGMA23 

Overall conductivity tensor

SIGMA31 
SIGMA32 
SIGMA33 
SIGMAP 

Scalar Pedersen conductivity

SIGMAH 

Scalar Hall conductivity

SIGMAPARALLEL 

Scalar parallel conductivity

PRECIP 

Precipitation

RHON 

Downmapped magnetospheric plasma number density

TEMPERATURE 

Downmapped electron temperature

NODE_BX 
NODE_BY 
NODE_BZ 

Magnetic field at the node

UPMAPPED_BX 
UPMAPPED_BY 
UPMAPPED_BZ 

Magnetic field at the upper and of the mapping fieldline

SOLUTION 

Currently considered solution potential

BEST_SOLUTION 

Best solution found so far

RESIDUAL 

Residual of the current solution

RRESIDUAL 
ZPARAM 
ZZPARAM 
PPPARAM 
PPARAM 
N_IONOSPHERE_PARAMETERS 

Definition at line 458 of file common.h.

Function Documentation

◆ abort_mpi()

void abort_mpi ( const std::string str,
const int err_type )

Helper function for error handling. err_type default to 0.

Definition at line 90 of file common.cpp.

Here is the caller graph for this function:

◆ bailout() [1/3]

void bailout ( const bool condition,
const char *const file,
const int line )

A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.

Parameters
conditionif true, bailout is initiated
filecode file where bailout was called (use FILE in the call)
linecode line where bailout was called (use LINE in the call)

Definition at line 68 of file common.cpp.

Here is the call graph for this function:

◆ bailout() [2/3]

void bailout ( const bool condition,
const std::string & message )

A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.

Parameters
conditionif true, bailout is initiated
messageinformation message printed to cerr

Definition at line 82 of file common.cpp.

Here is the call graph for this function:

◆ bailout() [3/3]

void bailout ( const bool condition,
const std::string & message,
const char *const file,
const int line )

A function to stop the simulation if the boolean condition is true. Raises a flag which gets MPI_Reduced and initiates bailout. [bailout] parameters set details.

Parameters
conditionif true, bailout is initiated
messageinformation message printed to cerr
filecode file where bailout was called (use FILE in the call)
linecode line where bailout was called (use LINE in the call)

Definition at line 36 of file common.cpp.

Here is the caller graph for this function:

◆ cellIndex()

template<typename INT>
ARCH_HOSTDEV INT cellIndex ( const INT & i,
const INT & j,
const INT & k )
inline

Get the cellindex in the velocity space block

Definition at line 522 of file common.h.

◆ getLocalCells()

const std::vector< CellID > & getLocalCells ( )

Get local cell IDs. This function creates a cached copy of the cell ID lists to significantly improve performance. The cell ID cache is recalculated every time the mesh partitioning changes.

Returns
Local cell IDs.

Definition at line 39 of file main.cpp.

Here is the caller graph for this function:

◆ sign()

template<typename T>
int sign ( const T & value)
inline

Definition at line 528 of file common.h.

Here is the caller graph for this function:

Variable Documentation

◆ SIZE_VELBLOCK

const int SIZE_VELBLOCK = WID3

Number of cells in a velocity block.

Definition at line 526 of file common.h.

◆ WID2

const int WID2 = WID*WID

Number of cells per 2D slab in a velocity block.

Definition at line 516 of file common.h.

◆ WID3

const int WID3 = WID2*WID

Number of cells in a velocity block.

Definition at line 517 of file common.h.