Reference Manual

Here is a description of the structures used in Menura, and defined in the file structures.h:

class simu_B_field_2
#include <structures.h>

Alternative type of field data structure.

The only way I found for allocating a multi-dimensional array on heap memory without recompiling when changing domain dimension. Not yet used in the code. Method used by smilei for their field variables.

Public Functions

inline simu_B_field_2(simu_param *sP)
inline ~simu_B_field_2()

Public Members

float ***B
struct simu_grid
#include <structures.h>

Contains the simulation grid with additional informations, such as obstacle position.

The simulation grid, 2D (resp. 3D), is described by 2 (resp. 3) one dimensional arrays of float containing the spatial coordinate of each node. Since the grid used in Menura is regular, all nodes sharing the same x-index share the same x-coordinate.

The bounds for macro-particle positions are defined here as well. No particle should ever be existing outside these bounds, or they will be deposited/mapped elsewhere than their simu-field->counts array, very bad.

The centre of the optional obstacle is also stored in simu_grid.

Public Members

float xGrid[len_x_cst + 4]

Grid of node coordinates along x.

float yGrid[len_y_cst + 4]

Grid of node coordinates along y.

float xMin
float xMax

Extremal position for particles along x.

float yMin
float yMax

Extremal position for particles along y.

float centre_x

Obstacle position (centre of solid body for instance) along x.

float centre_y

Obstacle position along y.

float zGrid[len_z_cst + 4]

Grid of node coordinates along z.

float zMin
float zMax

Extremal position for particles along z.

float centre_z

Obstacle position along z.

float grid_y_box[len_y_cst * mpi_nb_proc_y_cst + 4]
float rsq[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float r_true[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Distance from the centre of the obstacle, updated when the object moves, in identify_region_k.

struct simu_fields
#include <structures.h>

Contains all field values used in the solver, at the exception of the B-field. Conatins field buffers as well.

All fields contained in simu_fields are not followed in time, they are obtained by a combination of the magnetic field and the particles’ positions and speed.

MPI buffers are also included in this structure, with fixed size. The “steps” indicated below refer to the algorithm steps described in the technical publication of the code, also found in the gallery and in the main-loop comments.

Public Members

float E[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float curl_E[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float density[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float density_b[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float counts_s0[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float counts_s1[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float Lambda[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float Ji[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float Ji_b[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float flux_s0[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float flux_s1[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float ui_s0[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Ion bulk speed of species 0.

float ui_s1[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Ion bulk speed of species 1.

float ui[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Total ion bulk velocity.

float vi[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Total ion centre of mass velocity.

float Gamma[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float Jtot[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float pres_elec[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float stress_s0[6][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Macro-particle “numerical” pressure, species 0 (solar wind protons).

float stress_s1[6][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]

Macro-particle “numerical” pressure, species 1 (planetary ions).

int region_ID[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
int region_inner_boundary[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
int region_vacuum_boarder[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float vort[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float E_mot[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float E_hal[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float E_amb[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float E_res[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float smooth[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float smooth_patch[len_patch_cst][len_patch_cst][len_patch_cst]
float E_stag[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float buff_send_1d_y[4 * (len_x_cst + 4) * (len_z_cst + 4)]
float buff_reci_1d_y[4 * (len_x_cst + 4) * (len_z_cst + 4)]
float buff_send_1d_z[4 * (len_x_cst + 4) * (len_y_cst + 4)]
float buff_reci_1d_z[4 * (len_x_cst + 4) * (len_y_cst + 4)]
bool smooth_field = false
int smooth_idx[3] = {0}
int save_smooth[4][nb_it_max_cst] = {0}
int idx_save_smooth = 0
struct simu_B_field
#include <structures.h>

Contains the magnetic field, as well as the optional dipole field.

The B-field is the only field incremented and followed through time. It gets its own structure.

When a permanent dipole is simulated, it is contained in this structure as well. In the solar wind reference fram, in which the dipole moves, its description is updated a few times during each time step, using the additional potenital phi.

Public Members

float B[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
struct particles
#include <structures.h>

Contains all particles.

This is (nominally) by far the largest data structure, containing active as well as free particles, with the least amount of data for each particle: position, velocity, species, and whether this particle is free or not, i.e. active in the domain or available for representing a new particle to be injected in the domain.

Public Members

float rx[pool_size_cst]

x position.

float ry[pool_size_cst]

y position.

float rz[pool_size_cst]

z position.

float vx[pool_size_cst]

Speed along x.

float vy[pool_size_cst]

Speed along y.

float vz[pool_size_cst]

Speed along z.

bool active[pool_size_cst]

Active or free.

int ID[pool_size_cst]

Species.

struct simu_tank
#include <structures.h>

Contains all necessary (?) fields for Step 2 from Step 1, decaying turbulence, as well as Step-1-particle-related indices.

These fields are only stored on the host, since they are only introduced slice by slice in the simulation domain on the devices during Step 2.

The index of the current injection slice is stored here in idx_x.

Additional informations about particles from Step 1, are also stored here. Particles from Step 1 are ordered according to their x-position, distributed in slices corresponding to the injection in the domain during Step 2, as illustrated in the injection algorithm (cf gallery and technical publication). For this purpose, it is only necessary to save the ordered index of the first particle in each slice, given in indFirstPartSlice, as well as the total number of particles in each slice, given in sliceWidth.

Public Members

float B[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float E[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float Ji[3][len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
float density[len_x_cst + 4][len_y_cst + 4][len_z_cst + 4]
int idx_x = 0

The current index of the slice to be added, within [0, len_x_cst/nb_cell_per_shift_cst-1]

std::vector<size_t> idx_ordered

Indices of x-ordered Step 1 particles.

int sliceWidth[int(len_x_cst / nb_cell_per_shift_cst)]

How many particles in each slice.

int indFirstPartSlice[int(len_x_cst / nb_cell_per_shift_cst)]

Index of the first particle in each slice.

struct injector
#include <structures.h>

Used for the injection of fields and particles during Step 2.

Only a slice upstream of the domain is concerned here, including the two guard cells and an additional nb_cell_per_shift_cst. The same goes for the particles to be injected, contained in the same spatial slice, as discussed in simu_tank.

Public Members

float B[3][2 + nb_cell_per_shift_cst][len_y_cst + 4][len_z_cst + 4]
float E[3][2 + nb_cell_per_shift_cst][len_y_cst + 4][len_z_cst + 4]
float Ji[3][2 + nb_cell_per_shift_cst][len_y_cst + 4][len_z_cst + 4]
float density[2 + nb_cell_per_shift_cst][len_y_cst + 4][len_z_cst + 4]
float rx[injec_size_cst]

x-position of particles to be injected.

float ry[injec_size_cst]

y-position of particles to be injected.

float rz[injec_size_cst]

z-position of particles to be injected.

float vx[injec_size_cst]

x-speed of particles to be injected.

float vy[injec_size_cst]

y-speed of particles to be injected.

float vz[injec_size_cst]

z-speed of particles to be injected.

struct buff_part
#include <structures.h>

test3 Particle buffer, managing particles’ MPI communications and injection.

This structure contains all required information when particles need to be either injected or communicated from one MPI process to another.

Public Members

int idx_free[buff_size_cst]

An array containing indices of free particles, indices corresponding to the particles’ pool object.

int next_idx = 0

Gives a single temporary index of a particle.

float buff_send[7 * buff_size_cst]

Send buffer, containing pool indices of particles to be communicated out.

float buff_rece[7 * buff_size_cst]

Receive buffer, containing pool indices of particles to be communicated in.

int next_idx_comm = 0

Temporary index.

int nb_part_send = 0

Number of particles to be sent.

int nb_part_rece = 0

Number of particles to be received.

int exosphere[3][nb_part_add_pla_cst]
float exo_proba[len_x_cst * len_y_cst * len_z_cst]
struct moments
#include <structures.h>

Particles and fields house-keeping/moments data structure.

This structure contains various fields and particles global informations, mostly related to their moments (plasma moments and statistical moments). The time resolution of these time series is chosen through the constants len_save_t_cst

Public Members

float E_mag[len_save_t_cst] = {0}

Magnetic energy, sum(B_i^2).

float E_elec[len_save_t_cst] = {0}

Electric energy.

float E_kin[len_save_t_cst] = {0}

Particles kinetic energy.

float B_mean[3][len_save_t_cst] = {0}

B-field mean over the grid.

float B_var[3][len_save_t_cst] = {0}

B-field variance over the grid.

float div_B_mean[len_save_t_cst] = {0}

Mean of div(B) over the grid.

float div_B_var[len_save_t_cst] = {0}

Variacne of div(B) over the grid.

float div_B_max[len_save_t_cst] = {0}

Maximum of abs(div(B)) over the grid.

float dens_tot[len_save_t_cst] = {0}

Total density, sum(dens_tot).

float Ji_mean[3][len_save_t_cst] = {0}
float vel_part[3][len_save_t_cst] = {0}
float vel_th_part[3][len_save_t_cst] = {0}
float temp_tot[len_save_t_cst] = {0}
int nb_part_tot[len_save_t_cst] = {0}
struct fields_time_space
#include <structures.h>

Public Members

float E[3][len_save_t_cst][len_save_x_cst] = {0}
float Ji[3][len_save_t_cst][len_save_x_cst] = {0}
float B[3][len_save_t_cst][len_save_x_cst] = {0}
float density[len_save_t_cst][len_save_x_cst] = {0}
struct root_mean_sqr
#include <structures.h>

Public Members

float sum_B[3][len_save_t_cst] = {0}
float sum_sqr_B[3][len_save_t_cst] = {0}
float sum_ui[3][len_save_t_cst] = {0}
float sum_sqr_ui[3][len_save_t_cst] = {0}
float sum_J[3][len_save_t_cst] = {0}
float sum_sqr_J[3][len_save_t_cst] = {0}
struct trajectory
#include <structures.h>

Public Members

float rx[nb_traj_cst][len_traj_cst] = {0}
float ry[nb_traj_cst][len_traj_cst] = {0}
float rz[nb_traj_cst][len_traj_cst] = {0}
float vx[nb_traj_cst][len_traj_cst] = {0}
float vy[nb_traj_cst][len_traj_cst] = {0}
float vz[nb_traj_cst][len_traj_cst] = {0}
struct probes
#include <structures.h>

Public Members

float rx[nb_probes_cst][nb_it_max_cst]
float ry[nb_probes_cst][nb_it_max_cst]
float rz[nb_probes_cst][nb_it_max_cst]
bool active[nb_probes_cst]
float B[nb_probes_cst][3][nb_it_max_cst]
float E[nb_probes_cst][3][nb_it_max_cst]
float density[nb_probes_cst][nb_it_max_cst]
float Ji[nb_probes_cst][3][nb_it_max_cst]
float Jtot[nb_probes_cst][3][nb_it_max_cst]
struct house_keeping
#include <structures.h>

Public Members

int nbTruePart = 0
int nbFreeIndTot = 0
int nbPartSW[len_save_t_cst] = {0}
int nbPartPla[len_save_t_cst] = {0}
float simuTime[len_save_t_cst] = {0}
int runTime[len_save_t_cst] = {0}
int nb_part_comm_up[len_save_t_cst] = {0}
int nb_part_comm_down[len_save_t_cst] = {0}
int nb_pla_proba[len_save_t_cst] = {0}
int nb_patch_smooth[nb_it_max_cst] = {0}
struct state_solver
#include <structures.h>

Public Members

bool break_solver = false
int error_ID = 0
std::string cuda_error_str = "cudaSuccess"
std::string error_str2[20] = {std::string("Error ID 1, cudaMalloc of particles."), std::string("Error ID 2, cudaMalloc of fields."), std::string("Error ID 3, invalid B-field value."), std::string("Error ID 4, invalid E-field value."), std::string("Error ID 5, invalid Jtot value."), std::string("Error ID 6, invalid flux_s0 value."), std::string("Error ID 7, invalid density value."), std::string("Error ID 8, invalid new particle index."), std::string("Error ID 9, too many patches smoothed."), std::string("Error ID 10, empty."), std::string("Error ID 11, empty."), std::string("Error ID 12, empty."), std::string("Error ID 13, empty."), std::string("Error ID 14, empty."), std::string("Error ID 15, empty."), std::string("Error ID 16, empty."), std::string("Error ID 17, empty."), std::string("Error ID 18, empty."), std::string("Error ID 19, empty."), std::string("Error ID 20, empty.")}