WaSH Docs
Namespaces | Macros | Functions
wash.hpp File Reference

The public facing API for all Wash programs to be written with. More...

#include <chrono>
#include <cassert>
#include <functional>
#include <optional>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>
#include "io.hpp"
#include "particle.hpp"
#include "particle_data.hpp"
#include "util.hpp"
#include "vector.hpp"
#include "kernels.hpp"

Go to the source code of this file.

Namespaces

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

Macros

#define defineWashForceKernel(kernel_name, particle_name)
 Define a wash force kernel function with a name and particle parameter The force kernel iterates through all particles in the simulation and their neighbours. More...
 
#define defineWashVoidKernel(kernel_name)   void kernel_name (void)
 Define a wash void kernel function with a given name. The void kernel is executed once every simulation loop. More...
 
#define defineWashUpdateKernel(kernel_name, particle_name)   void kernel_name (wash::Particle& particle_name)
 Define a wash update kernel function with a name and particle parameter The update kernel is executed once for every particle in the simulation every loop. More...
 
#define defineWashReductionKernel(kernel_name, particle_name)   double kernel_name (const wash::Particle& particle_name)
 Define a wash reduction kernel function with a name and particle parameter The reduction kernel returns a single value from each particle in the simulation. More...
 
#define washForEachNeighbour(var_name, body)
 Define a for loop across the particle's neighbourhood. This should only be used within a force kernel. More...
 

Functions

uint64_t wash::get_max_iterations ()
 Get the max iterations of the simulation. More...
 
void wash::set_max_iterations (const uint64_t iterations)
 Set the max number of iterations. More...
 
void wash::set_bounding_box (const double min, const double max, const bool periodic)
 Set the bounding box dimensions and periodicity type. More...
 
void wash::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 wash::add_force_scalar (const std::string force)
 Add a scalar force to the simulation. More...
 
void wash::add_force_vector (const std::string force)
 Add a n-dim vector force to the simulation. More...
 
void wash::add_variable (const std::string variable, double init_value=0.0)
 Add a scalar variable to the simulation. More...
 
void wash::add_init_update_kernel (const UpdateFuncT func)
 Add an initialisation update kernel (will be executed for each particle) More...
 
void wash::add_init_void_kernel (const VoidFuncT func)
 Add an initialization void kernel to the simulation - run once. More...
 
void wash::add_force_kernel (const ForceFuncT func)
 Add a force kernel to the simulation which will loop over the particles and their neighbourhood. More...
 
void wash::add_update_kernel (const UpdateFuncT func)
 Add an update kernel to the simulation which will loop over the particles. More...
 
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. More...
 
void wash::add_void_kernel (const VoidFuncT func)
 Add a void kernel to the simulation. More...
 
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. More...
 
void wash::set_neighbor_search_kernel (const NeighborsFuncT func, const unsigned max_count)
 Sets the neighbourhood search to use a custom function. More...
 
double wash::get_variable (const std::string &variable)
 Get the value of a variable. More...
 
double * wash::use_variable (const std::string &variable)
 Returns a reference to a variable useful for e.g. reduction kernels. More...
 
void wash::set_variable (const std::string &variable, const double value)
 Set the value of a variable. More...
 
void wash::start ()
 Get the vector of all particles in the simulation. More...
 
void wash::set_simulation_name (const std::string name)
 Set the name of the simulation, used in IO. More...
 
void wash::set_output_file_name (const std::string name)
 Set the output file name of the simulation. More...
 
double wash::eucdist (const Particle &p, const Particle &q)
 TODO: Move eucdist calculation to the paticle header? More...
 
void wash::set_particle_count (const size_t count)
 Set the number of particles to be used in the simulation. More...
 
size_t wash::get_particle_count ()
 Get the number of particles used in the simulation. More...
 
void wash::set_dimension (int dim)
 Set the dimensionality of the simulation. More...
 
void wash::set_io (const std::string format, size_t output_nth, bool timings=true)
 Set the IO parameters used for the simulation.
 

Detailed Description

The public facing API for all Wash programs to be written with.

Authors
Wash Project Group
Version
0.1
Date
2024-02-12

Implementations:

Dimensionality:

Macro Definition Documentation

◆ defineWashForceKernel

#define defineWashForceKernel (   kernel_name,
  particle_name 
)
Value:
void kernel_name (wash::Particle& particle_name, \
const std::vector<wash::Particle>::const_iterator& begin, \
const std::vector<wash::Particle>::const_iterator& end)
Definition: particle.hpp:13

Define a wash force kernel function with a name and particle parameter The force kernel iterates through all particles in the simulation and their neighbours.

Parameters
kernel_nameName of the kernel function
particle_nameName of the particle parameter

◆ defineWashReductionKernel

#define defineWashReductionKernel (   kernel_name,
  particle_name 
)    double kernel_name (const wash::Particle& particle_name)

Define a wash reduction kernel function with a name and particle parameter The reduction kernel returns a single value from each particle in the simulation.

Parameters
kernel_nameName of the kernel
particle_nameName of the particle parameter

◆ defineWashUpdateKernel

#define defineWashUpdateKernel (   kernel_name,
  particle_name 
)    void kernel_name (wash::Particle& particle_name)

Define a wash update kernel function with a name and particle parameter The update kernel is executed once for every particle in the simulation every loop.

Parameters
kernel_nameName of the kernel
particle_nameName of the particle parameter

◆ defineWashVoidKernel

#define defineWashVoidKernel (   kernel_name)    void kernel_name (void)

Define a wash void kernel function with a given name. The void kernel is executed once every simulation loop.

Parameters
kernel_nameName of the kernel function

◆ washForEachNeighbour

#define washForEachNeighbour (   var_name,
  body 
)
Value:
_Pragma("omp simd")\
for (auto it = begin; it != end; it++) {\
const auto& var_name = *it;\
{ body }\
}

Define a for loop across the particle's neighbourhood. This should only be used within a force kernel.

Parameters
var_nameVariable name of the neighbour. Marked const.
bodyBody of the loop, to be run for every neighbouring particle.