WaSH Docs
Classes | Typedefs | Enumerations | Functions | Variables
wash Namespace Reference

TODO: Consider having this as a private header in WISB/WS2ST/etc implementations. More...

Classes

class  ForceKernel
 Force Kernel Class. More...
 
class  Kernel
 Parent Kernel Class. More...
 
class  Particle
 
class  ReductionKernel
 Reduction Kernel implements a reduction operation over the particles to a specifed variable. More...
 
class  UpdateKernel
 Update Kernel Class. More...
 
class  Vec
 Custom vector class for WaSH simulation. More...
 
class  VoidKernel
 Void Kernel has no arguments/return. More...
 

Typedefs

using ForceFuncT = std::function< void(Particle &, const std::vector< Particle >::const_iterator &, const std::vector< Particle >::const_iterator &)>
 
using UpdateFuncT = std::function< void(Particle &)>
 
using MapFuncT = std::function< double(const Particle &)>
 
using VoidFuncT = std::function< void()>
 
using NeighborsFuncT = std::function< void(Particle &)>
 
using SimulationVecT = Vec< double, DIM >
 
typedef Vec< double, 2 > Vec2D
 
typedef Vec< double, 3 > Vec3D
 

Enumerations

enum  ReduceOp { max, min, sum, prod }
 Type of reduction operation to perform in a reduce kernel.
 

Functions

io::IOManager create_io (const std::string format, const size_t output_nth, const bool use_gather=false, const size_t rank=0, const size_t size=1, const bool timings=true)
 Set-up the IO options for the simulation. More...
 
std::vector< double > copy_variables ()
 Copy the variables of the simulation. More...
 
std::vector< std::string > get_variables_names ()
 
template<typename T >
int64_t diff_ms (std::chrono::time_point< T > time1, std::chrono::time_point< T > time2)
 
template<typename... Args>
std::string string_format (const std::string &format, Args... args)
 Helper function to format to a c++ string. More...
 
template<typename T >
int sgn (T val)
 Helper function for the pure sign of a numerical type. More...
 
template<typename T , size_t N, size_t... I>
auto make_tuple (std::array< T, N > &arr, std::index_sequence< I... >)
 
template<typename T , size_t N>
auto make_tuple (std::array< T, N > &arr)
 
template<typename T , size_t N, size_t M>
auto make_tuple (std::array< T, N > &arr)
 
uint64_t get_max_iterations ()
 Get the max iterations of the simulation. More...
 
void set_max_iterations (const uint64_t iterations)
 Set the max number of iterations. More...
 
void set_bounding_box (const double min, const double max, const bool periodic)
 Set the bounding box dimensions and periodicity type. More...
 
void set_bounding_box (const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax, const bool x_periodic, const bool y_periodic, const bool z_periodic)
 Set the bounding box dimensions and periodicity type in 3 dimensions.
 
void add_force_scalar (const std::string force)
 Add a scalar force to the simulation. More...
 
void add_force_vector (const std::string force)
 Add a n-dim vector force to the simulation. More...
 
void add_variable (const std::string variable, double init_value=0.0)
 Add a scalar variable to the simulation. More...
 
void add_init_update_kernel (const UpdateFuncT func)
 Add an initialisation update kernel (will be executed for each particle) More...
 
void add_init_void_kernel (const VoidFuncT func)
 Add an initialization void kernel to the simulation - run once. More...
 
void add_force_kernel (const ForceFuncT func)
 Add a force kernel to the simulation which will loop over the particles and their neighbourhood. More...
 
void add_update_kernel (const UpdateFuncT func)
 Add an update kernel to the simulation which will loop over the particles. More...
 
void add_reduction_kernel (const MapFuncT map_func, const ReduceOp reduce_op, double *variable)
 Add a reduction kernel to the simulation which will loop over the particles. More...
 
void add_void_kernel (const VoidFuncT func)
 Add a void kernel to the simulation. More...
 
void set_default_neighbor_search (const unsigned max_count)
 Set the neighborhood search to use the provided default which uses the smoothing length of the particle and returns at most max_count neighbours. More...
 
void set_neighbor_search_kernel (const NeighborsFuncT func, const unsigned max_count)
 Sets the neighbourhood search to use a custom function. More...
 
double get_variable (const std::string &variable)
 Get the value of a variable. More...
 
double * use_variable (const std::string &variable)
 Returns a reference to a variable useful for e.g. reduction kernels. More...
 
void set_variable (const std::string &variable, const double value)
 Set the value of a variable. More...
 
void start ()
 Get the vector of all particles in the simulation. More...
 
void set_simulation_name (const std::string name)
 Set the name of the simulation, used in IO. More...
 
void set_output_file_name (const std::string name)
 Set the output file name of the simulation. More...
 
double eucdist (const Particle &p, const Particle &q)
 TODO: Move eucdist calculation to the paticle header? More...
 
void set_particle_count (const size_t count)
 Set the number of particles to be used in the simulation. More...
 
size_t get_particle_count ()
 Get the number of particles used in the simulation. More...
 
void set_dimension (int dim)
 Set the dimensionality of the simulation. More...
 
void set_io (const std::string format, size_t output_nth, bool timings=true)
 Set the IO parameters used for the simulation.
 
double constexpr sqrtNewtonRaphson (double x, double curr, double prev)
 
double constexpr sqrt (double x)
 
std::vector< Particle > & get_global_particles ()
 
std::vector< Particle > & get_particles ()
 
std::ostream & operator<< (std::ostream &os, const Particle &p)
 
std::string get_simulation_name ()
 
std::string get_output_file_name ()
 
std::vector< std::string > get_forces_scalar ()
 
std::vector< std::string > get_forces_vector ()
 
std::vector< std::string > get_variables ()
 
std::tuple< int, int > init_mpi ()
 
cstone::Domain< uint64_t, double, cstone::CpuTag > init_domain (int rank, int n_ranks, size_t num_particles)
 
void recreate_particles (unsigned count_with_halos, size_t start_idx, size_t end_idx)
 
void sync_domain (cstone::Domain< uint64_t, double, cstone::CpuTag > &domain, std::vector< size_t > &keys, std::vector< double > &s1, std::vector< double > &s2, std::vector< double > &s3)
 
std::vector< std::string > get_force_scalars_names ()
 
std::vector< std::string > get_force_vectors_names ()
 
void reset_neighbour_data ()
 
void initialise_particles (size_t particle_count)
 
void create_particles ()
 
ParticleData * get_particle_data ()
 

Variables

uint64_t max_iterations
 
size_t particle_cnt
 
double box_xmin
 
double box_ymin
 
double box_zmin
 
double box_xmax
 
double box_ymax
 
double box_zmax
 
std::vector< std::unique_ptr< Kernel > > init_kernels
 
std::vector< std::unique_ptr< Kernel > > loop_kernels
 
NeighborsFuncT neighbors_kernel
 
std::function< unsigned(unsigned, unsigned)> neighbors_func
 
unsigned neighbors_max
 
std::vector< unsigned > neighbors_cnt
 
std::vector< unsigned > neighbors_data
 
std::unordered_map< std::string, double > variables
 
size_t force_cnt
 
std::unordered_map< std::string, size_t > force_map
 
std::array< std::vector< double >, MAX_FORCES > force_data
 
std::vector< Particleparticles
 
std::vector< Particlelocal_particles
 
std::string simulation_name
 
std::string output_file_name
 
bool started
 
cstone::BoundaryType box_xtype
 
cstone::BoundaryType box_ytype
 
cstone::BoundaryType box_ztype
 
std::string out_format
 
size_t output_nth
 
bool timings
 
size_t particle_count
 
size_t out_nth
 
bool out_timing
 
NeighborsFuncT neighbours_kernel
 
unsigned max_neighbours
 
std::vector< unsigned > neighbour_counts
 
std::vector< std::vector< Particle > > neighbour_data
 
std::vector< std::string > forces_scalar = { "mass", "density", "smoothing_length" }
 
std::vector< std::string > forces_vector = { "pos", "vel", "acc" }
 
ParticleData * particle_data = nullptr
 
cstone::Domain< uint64_t, double, cstone::CpuTag > * domain
 
unsigned start_idx
 
unsigned end_idx
 

Detailed Description

TODO: Consider having this as a private header in WISB/WS2ST/etc implementations.

Function Documentation

◆ add_force_kernel()

void wash::add_force_kernel ( const ForceFuncT  func)

Add a force kernel to the simulation which will loop over the particles and their neighbourhood.

Parameters
funcReference to the kernel function

◆ add_force_scalar()

void wash::add_force_scalar ( const std::string  force)

Add a scalar force to the simulation.

Parameters
forceName of the force

◆ add_force_vector()

void wash::add_force_vector ( const std::string  force)

Add a n-dim vector force to the simulation.

Parameters
forceName of the force

◆ add_init_update_kernel()

void wash::add_init_update_kernel ( const UpdateFuncT  func)

Add an initialisation update kernel (will be executed for each particle)

Parameters
funcReference to the kernel function

◆ add_init_void_kernel()

void wash::add_init_void_kernel ( const VoidFuncT  func)

Add an initialization void kernel to the simulation - run once.

Parameters
funcReference to the kernel function

◆ add_reduction_kernel()

void wash::add_reduction_kernel ( const MapFuncT  map_func,
const ReduceOp  reduce_op,
double *  variable 
)

Add a reduction kernel to the simulation which will loop over the particles.

Extracts a value from each particle using map_func, then aggregates these values using reduce_op. The result will be saved to variable.

Parameters
map_funcFunction to map each particle to
reduce_opThe reduction operator type to use in the reduction
variableVariable to store the result in

◆ add_update_kernel()

void wash::add_update_kernel ( const UpdateFuncT  func)

Add an update kernel to the simulation which will loop over the particles.

Parameters
funcReference to the kernel function

◆ add_variable()

void wash::add_variable ( const std::string  variable,
double  init_value = 0.0 
)

Add a scalar variable to the simulation.

Parameters
variableName of the variable
init_valueThe initial value of the variable

◆ add_void_kernel()

void wash::add_void_kernel ( const VoidFuncT  func)

Add a void kernel to the simulation.

Parameters
funcReference to the kernel function

◆ copy_variables()

std::vector< double > wash::copy_variables ( )

Copy the variables of the simulation.

Returns
std::vector<double*>

◆ create_io()

io::IOManager wash::create_io ( const std::string  format,
const size_t  output_nth,
const bool  use_gather = false,
const size_t  rank = 0,
const size_t  size = 1,
const bool  timings = true 
)

Set-up the IO options for the simulation.

Parameters
format
output_nth
rankMPI Rank
sizeMPI Size
Returns
io::IOManager IO Interface for simulation / particular rank

◆ eucdist()

double wash::eucdist ( const Particle p,
const Particle q 
)

TODO: Move eucdist calculation to the paticle header?

Compute the euclidean distance between two particles

Parameters
pFirst particle
qSecond particle
Returns
double

◆ get_max_iterations()

uint64_t wash::get_max_iterations ( )

Get the max iterations of the simulation.

Returns
uint64_t

◆ get_particle_count()

size_t wash::get_particle_count ( )

Get the number of particles used in the simulation.

Returns
size_t

◆ get_variable()

double wash::get_variable ( const std::string &  variable)

Get the value of a variable.

Parameters
variableName of the variable
Returns
double

◆ set_bounding_box()

void wash::set_bounding_box ( const double  min,
const double  max,
const bool  periodic 
)

Set the bounding box dimensions and periodicity type.

TODO: impl bounding box methods even though they likely don't have any function in wser.

◆ set_default_neighbor_search()

void wash::set_default_neighbor_search ( const unsigned  max_count)

Set the neighborhood search to use the provided default which uses the smoothing length of the particle and returns at most max_count neighbours.

Parameters
max_countMaximum number of neighbours to return

◆ set_dimension()

void wash::set_dimension ( int  dim)

Set the dimensionality of the simulation.

Parameters
dim2, or 3

◆ set_max_iterations()

void wash::set_max_iterations ( const uint64_t  iterations)

Set the max number of iterations.

Parameters
iterations

◆ set_neighbor_search_kernel()

void wash::set_neighbor_search_kernel ( const NeighborsFuncT  func,
const unsigned  max_count 
)

Sets the neighbourhood search to use a custom function.

Parameters
funcReference to the search function
max_countMaximum number of neighbours(?)

◆ set_output_file_name()

void wash::set_output_file_name ( const std::string  name)

Set the output file name of the simulation.

Parameters
nameName to use

◆ set_particle_count()

void wash::set_particle_count ( const size_t  count)

Set the number of particles to be used in the simulation.

Parameters
count

◆ set_simulation_name()

void wash::set_simulation_name ( const std::string  name)

Set the name of the simulation, used in IO.

Parameters
nameName to use

◆ set_variable()

void wash::set_variable ( const std::string &  variable,
const double  value 
)

Set the value of a variable.

Parameters
variableName of the variable
valueValue to set it to

◆ sgn()

template<typename T >
int wash::sgn ( val)

Helper function for the pure sign of a numerical type.

Template Parameters
T
Parameters
valnumerical value
Returns
+1 if positive, -1 if negative

◆ start()

void wash::start ( )

Get the vector of all particles in the simulation.

Returns
std::vector<Particle>& Starts the simulation

TODO: what's this?

TODO: what's this?

◆ string_format()

template<typename... Args>
std::string wash::string_format ( const std::string &  format,
Args...  args 
)

Helper function to format to a c++ string.

Template Parameters
Args
Parameters
formatstandard style format string
argsarguments for the format string
Returns
std::string

◆ use_variable()

double * wash::use_variable ( const std::string &  variable)

Returns a reference to a variable useful for e.g. reduction kernels.

Parameters
variable
Returns
double*