METHOD
Data Class Reference

#include <simData.h>

Public Member Functions

int id (int var, int i, int j, int k)
 
double sigmaFunc (double *cons, double *prims, double *aux, int i=-1, int j=-1, int k=-1)
 
void initData (PlatformEnv *env, int nOptionalSimArgs=0, std::vector< double > optionalSimArgs=std::vector< double >(), std::vector< std::string > optionalSimArgNames=std::vector< std::string >())
 
 Data (int nx, int ny, int nz, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, double endTime, PlatformEnv *env, double cfl=0.5, int Ng=4, double gamma=5.0/3.0, double sigma=1e3, double cp=0.1, double mu1=-1.0e4, double mu2=1.0e4, int frameskip=10, int reportItersPeriod=1, bool funtionalSigma=false, double gam=12)
 
 Data (DataArgsBase args, PlatformEnv *env)
 
 ~Data ()
 

Public Attributes

double endTime
 
double cfl
 
int Ng
 
double gamma
 
double sigma
 
int memSet
 
int bcsSet
 
double cp
 
int frameSkip
 
int reportItersPeriod
 
bool functionalSigma
 
double gam
 
double t =-1
 
double dt
 
int iters
 
int dims
 
std::vector< double > optionalSimArgs
 
std::vector< std::string > optionalSimArgNames
 
int nOptionalSimArgs =0
 
int nx
 
int ny
 
int nz
 
double xmin
 
double xmax
 
double ymin
 
double ymax
 
double zmin
 
double zmax
 
int Ncons
 
int Nprims
 
int Naux
 
double mu1
 
double mu2
 
double * cons
 
double * prims
 
double * aux
 
double * f
 
double * fnet
 
double * source
 
double * sourceExtension
 
double * x
 
double * y
 
double * z
 
double alphaX
 
double alphaY
 
double alphaZ
 
double dx
 
double dy
 
double dz
 
int Nx
 
int Ny
 
int Nz
 
int Ntot
 
std::vector< std::string > consLabels
 
std::vector< std::string > primsLabels
 
std::vector< std::string > auxLabels
 
int is
 
int js
 
int ks
 
int ie
 
int je
 
int ke
 

Detailed Description

Data object

Class contains all the data of the simulation relevant to any of the other modules. Containing it in this way prevents issues of cyclic includes, also results in Simulation as more of an interface than a class that needs to be known to lower objects—good practice.

Usage

Call the constructor with at least: the number of cells and domain limits in the x, y, and z direction, and the simulation end time. As ghost cells are automatically added to the domain, there would be a minimum number of total cells in any direction of nine—as a result, running 2D simulations would be 9x slower than necessary. To combat this, you can request zero cells in the z-direction which is equivalent to a 2D domain where Nz=1. Keep this behaviour in mind when constructing new models.
Other variables, such as the courant factor, can also be set in the constructor but by default have sensible values that should work for most set ups, these can largely be ignored unless the simulation is failing to converge.
Selecting a model will automatically set the number of cons prims and aux vars, both inside the model class and in the data class (although it is the data class values that are accessed by the various functions).
The elementID function data.id(var, i, j, k) is a useful shortcut for accessing data belonging to a specific cell, where var is the id of the variable in the array we wish to access, and \((i, j, k)\) corresond to the \( (x, y, z)\) coordinates of the cell we wish to access. Note: this includes ghost cells, so in practice these values can range from \( 0 \le (i,j,k) < (nx,ny,nz)+2 Ng \) or \(0 \le (i,j,k) < (Nx,Ny,Nz) \) assuming we are working in 3D. To speed up this method, however, we have defined a macro in each file with the same functionality
For 2D simulations, k=0 at all times, and similarly j=0 for 1D simulations.

Definition at line 49 of file simData.h.

Constructor & Destructor Documentation

◆ Data() [1/2]

Data::Data ( int  nx,
int  ny,
int  nz,
double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax,
double  endTime,
PlatformEnv env,
double  cfl = 0.5,
int  Ng = 4,
double  gamma = 5.0/3.0,
double  sigma = 1e3,
double  cp = 0.1,
double  mu1 = -1.0e4,
double  mu2 = 1.0e4,
int  frameskip = 10,
int  reportItersPeriod = 1,
bool  funtionalSigma = false,
double  gam = 12 
)

Constructor – all vars specified by comma separated list.

Allocates the memory required for the state arrays and sets the simulation constants to the given values. Does not set initial state, thats done by the initialFunc object.
Parameters
nxnumber of physical cells in x-direction
nynumber of physical cells in y-direction
nznumber of physical cells in z-direction
xminminimum value of x domain
xmaxmaximum value of x domain
yminminimum value of y domain
ymaxmaximum value of y domain
zminminimum value of z domain
zmaxmaximum value of z domain
envenvironment object containing platform details eg MPI ranks
endTimedesired end time of the simulation
cflcourant factor
Ngnumber of ghost cells in each direction
gammaadiabatic index
sigmavalue of conductivity
cptime scale for divergence cleaning. cp = 1 / kappa
mu1charge mass ratio of species 1
mu2charge mass ratio of species 2
frameskipnumber of timesteps per file output
reportItersPeriodperiod with which time step data is reported to screen during program execution

◆ Data() [2/2]

Data::Data ( DataArgsBase  args,
PlatformEnv env 
)

Constructor.

Allocates the memory required for the state arrays and sets the simulation constants to the given values. Does not set initial state, thats done by the initialFunc object.
Parameters
argssimulation arguments such as cfl, sigma etc, as read from checkpoint restart file
envenvironment object containing platform details eg MPI ranks

◆ ~Data()

Data::~Data ( )
inline

Definition at line 231 of file simData.h.

Member Function Documentation

◆ id()

int Data::id ( int  var,
int  i,
int  j,
int  k 
)
inline

Element ID function.

To access the 2nd conserved variable at (x, y) = (12, 4) for example, we call elem=data.id(2, 12, 4) and use this in d.cons[elem].
Parameters
varthe variable number, eg cons[0] is energy, cons[1] is x-momentum etc.
icell number in the x-direction
jcell number in the y-direction
kcell number in the z-direction

Definition at line 142 of file simData.h.

◆ initData()

void Data::initData ( PlatformEnv env,
int  nOptionalSimArgs = 0,
std::vector< double >  optionalSimArgs = std::vector< double >(),
std::vector< std::string >  optionalSimArgNames = std::vector< std::string >() 
)

Initialiser.

Allocates the memory required for the state arrays and sets the simulation constants to the given values. Does not set initial state, thats done by the initialFunc object. Called automatically from constructors after setting object vars. This is separated from the constructor to avoid duplicated code between the two available constructors for Data.

◆ sigmaFunc()

double Data::sigmaFunc ( double *  cons,
double *  prims,
double *  aux,
int  i = -1,
int  j = -1,
int  k = -1 
)

General form of conductivity.

In general, the conductivity may depend upon the environment (e.g. density, magnetic field strength etc.). This is the interface for calculating the conductivity. REALLY, this should be made as its own class and passed to the physics model, but I'm being lazy this once because thesis+timeline=reasons. Maybe a task for the interested reader...?
Parameters
[in]*conspointer to conserved vector work array. Size is \(N_{cons} \times N_x \times N_y \times N_z\) or \(N_{cons}\) if any \(i, j, k < 0\)
[in]*primspointer to primitive vector work array. Size is \(N_{prims} \times N_x \times N_y \times N_z\) or \(N_{cons}\) if any \(i, j, k < 0\)
[in]*auxpointer to auxilliary vector work array. Size is \(N_{aux} \times N_x \times N_y \times N_z\) or \(N_{cons}\) if any \(i, j, k < 0\)
icell number in the x-direction, default is -1. If \(i < 0\), cons, prims, and are for a single cell.
jcell number in the y-direction, default is -1. If \(j < 0\), cons, prims, and are for a single cell.
kcell number in the z-direction, default is -1. If \(k < 0\), cons, prims, and are for a single cell.
Returns
sig the value of the conductivity

Member Data Documentation

◆ alphaX

double Data::alphaX

Max wave speed in specified direction. As we are evolving EM fields, this is always the speed of light.

Definition at line 99 of file simData.h.

◆ alphaY

double Data::alphaY

Max wave speed in specified direction. As we are evolving EM fields, this is always the speed of light.

Definition at line 99 of file simData.h.

◆ alphaZ

double Data::alphaZ

Max wave speed in specified direction. As we are evolving EM fields, this is always the speed of light.

Definition at line 99 of file simData.h.

◆ aux

double * Data::aux

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ auxLabels

std::vector<std::string> Data::auxLabels

Vector of labels for the specified variables.

Definition at line 113 of file simData.h.

◆ bcsSet

int Data::bcsSet

Indicator that boundary conditions have been created (before this information about the domain decomposition used in MPI version will not be correct).

Definition at line 69 of file simData.h.

◆ cfl

double Data::cfl

Courant factor.

Definition at line 58 of file simData.h.

◆ cons

double* Data::cons

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ consLabels

std::vector<std::string> Data::consLabels

Vector of labels for the specified variables.

Definition at line 113 of file simData.h.

◆ cp

double Data::cp

Constant divergence cleaning term.

Definition at line 75 of file simData.h.

◆ dims

int Data::dims

Number of dimensions of simulation.

Definition at line 118 of file simData.h.

◆ dt

double Data::dt

Width of current timestep.

Definition at line 101 of file simData.h.

◆ dx

double Data::dx

Witdth of specified spatial step.

Definition at line 101 of file simData.h.

◆ dy

double Data::dy

Witdth of specified spatial step.

Definition at line 101 of file simData.h.

◆ dz

double Data::dz

Witdth of specified spatial step.

Definition at line 101 of file simData.h.

◆ endTime

double Data::endTime

End time of simulation.

Definition at line 58 of file simData.h.

◆ f

double * Data::f

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ fnet

double * Data::fnet

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ frameSkip

int Data::frameSkip

Number of timesteps per file output.

Definition at line 80 of file simData.h.

◆ functionalSigma

bool Data::functionalSigma

Are we using a functional (vs homogeneous) conductivity?

Definition at line 84 of file simData.h.

◆ gam

double Data::gam

Exponent in the functional conductivity.

Definition at line 86 of file simData.h.

◆ gamma

double Data::gamma

Adiabatic index.

Definition at line 66 of file simData.h.

◆ ie

int Data::ie

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ is

int Data::is

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ iters

int Data::iters

Number of iterations that have been completed.

Definition at line 107 of file simData.h.

◆ je

int Data::je

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ js

int Data::js

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ ke

int Data::ke

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ ks

int Data::ks

Cell IDs for interior grid points.

Definition at line 118 of file simData.h.

◆ memSet

int Data::memSet

Indicator that memory has been allocated for state vectors.

Definition at line 69 of file simData.h.

◆ mu1

double Data::mu1

Charge mass ratio of specified fluid species, q/m (for two fluid model)

Definition at line 75 of file simData.h.

◆ mu2

double Data::mu2

Charge mass ratio of specified fluid species, q/m (for two fluid model)

Definition at line 75 of file simData.h.

◆ Naux

int Data::Naux

Number of specified variables.

Definition at line 69 of file simData.h.

◆ Ncons

int Data::Ncons

Number of specified variables.

Definition at line 69 of file simData.h.

◆ Ng

int Data::Ng

Number of ghost cells.

Definition at line 64 of file simData.h.

◆ nOptionalSimArgs

int Data::nOptionalSimArgs =0

Number of elements to include in optionalSimArgs array.

Definition at line 128 of file simData.h.

◆ Nprims

int Data::Nprims

Number of specified variables.

Definition at line 69 of file simData.h.

◆ Ntot

int Data::Ntot

Total number of compute cells in domain in the specified direction.

Definition at line 107 of file simData.h.

◆ nx

int Data::nx

Number of physical cells in specified direction.

Definition at line 54 of file simData.h.

◆ Nx

int Data::Nx

Total number of compute cells in domain in the specified direction.

Definition at line 107 of file simData.h.

◆ ny

int Data::ny

Number of physical cells in specified direction.

Definition at line 54 of file simData.h.

◆ Ny

int Data::Ny

Total number of compute cells in domain in the specified direction.

Definition at line 107 of file simData.h.

◆ nz

int Data::nz

Number of physical cells in specified direction.

Definition at line 54 of file simData.h.

◆ Nz

int Data::Nz

Total number of compute cells in domain in the specified direction.

Definition at line 107 of file simData.h.

◆ optionalSimArgNames

std::vector<std::string> Data::optionalSimArgNames

Names of optionalSimArgs array elements.

Definition at line 126 of file simData.h.

◆ optionalSimArgs

std::vector<double> Data::optionalSimArgs

Array of optional arguments that depend on the simulation being run.

Definition at line 124 of file simData.h.

◆ prims

double * Data::prims

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ primsLabels

std::vector<std::string> Data::primsLabels

Vector of labels for the specified variables.

Definition at line 113 of file simData.h.

◆ reportItersPeriod

int Data::reportItersPeriod

Period with which time step data is reported to screen during program execution.

Definition at line 82 of file simData.h.

◆ sigma

double Data::sigma

Resistivity.

Definition at line 66 of file simData.h.

◆ source

double * Data::source

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ sourceExtension

double * Data::sourceExtension

Pointer to specified work array.

Definition at line 89 of file simData.h.

◆ t

double Data::t =-1

Current time.

Definition at line 101 of file simData.h.

◆ x

double * Data::x

Specified coordinate location of the center of the compute cells (incl ghost cells)

Definition at line 89 of file simData.h.

◆ xmax

double Data::xmax

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.

◆ xmin

double Data::xmin

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.

◆ y

double * Data::y

Specified coordinate location of the center of the compute cells (incl ghost cells)

Definition at line 89 of file simData.h.

◆ ymax

double Data::ymax

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.

◆ ymin

double Data::ymin

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.

◆ z

double * Data::z

Specified coordinate location of the center of the compute cells (incl ghost cells)

Definition at line 89 of file simData.h.

◆ zmax

double Data::zmax

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.

◆ zmin

double Data::zmin

Positional limits of domain in specified direction.

Definition at line 58 of file simData.h.


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