Walls

See also the user interface.

Base classes

class Wall : public mirheo::MirSimulationObject

Physical boundaries of the simulation.

A wall is composed of its surface. Additionally, frozen particles can be created from that surface and attached to the wall.

Subclassed by mirheo::SDFBasedWall

Public Functions

Wall(const MirState *state, const std::string &name)

Construct a Wall.

Parameters
  • state: The simulation state.
  • name: The name of the wall.

virtual void setup(MPI_Comm &comm) = 0

Initialize the wall internal state.

This must be called before any other wall operations that involve its surface.

Parameters
  • comm: The MPI Cartesian communicator of the simulation.

virtual void attachFrozen(ParticleVector *pv) = 0

Set frozen particles to the wall.

The frozen particles may be modified in the operation (velocities set to the wall’s one).

Parameters
  • pv: The frozen particles.

virtual void removeInner(ParticleVector *pv) = 0

Remove particles inside the walls.

If pv is an

ObjectVector, any object with at least one particle will be removed by this operation.
Parameters

virtual void attach(ParticleVector *pv, CellList *cl, real maximumPartTravel) = 0

Register a ParticleVector that needs to be bounced from the wall.

Multiple

ParticleVector can be registered by calling this method several times. The parameter maximumPartTravel is used for performance, lower leading to higher performances. Note that if it is too low, some particles may be ignored and not bounced and end up inside the walls (see bounce()).
Parameters
  • pv: The particles to be bounced. Will be ignored if it is the same as the frozen particles.
  • cl: Cell lists corresponding to pv.
  • maximumPartTravel: The estimated maximum distance traveled by one particle over a single time step.

virtual void detachAllCellLists() = 0

Clean up all information regarding cell lists generated by attach.

virtual void bounce(cudaStream_t stream) = 0

Bounce the particles attached to the wall.

The particles that are bounced must be registered previously exactly once with

attach().
Parameters
  • stream: The stream to execute the bounce operation on.

virtual void setPrerequisites(ParticleVector *pv)

Set properties needed by the particles to be bounced.

Must be called just after

setup() and before any bounce(). Default: ask nothing.
Parameters
  • pv: Particles to add additional properties to.

virtual void check(cudaStream_t stream) = 0

Counts number of particles inside the walls and report it in the logs.

The particles that are counted must be previously attached to the walls by calling

attach().
Parameters
  • stream: The stream to execute the check operation on.

class SDFBasedWall : public mirheo::Wall

Wall with surface represented via a signed distance function (SDF).

The surface of the wall is the zero level set of its SDF. The SDF has positive values outside the simulation domain (called inside the walls), and is negative inside the simulation domain.

Subclassed by mirheo::SimpleStationaryWall< InsideWallChecker >

Public Functions

virtual void sdfPerParticle(LocalParticleVector *lpv, GPUcontainer *sdfs, GPUcontainer *gradients, real gradientThreshold, cudaStream_t stream) = 0

Compute the wall SDF at particles positions.

Parameters
  • lpv: Input particles.
  • sdfs: Values of the SDF at the particle positions.
  • gradients: Gradients of the SDF at the particle positions. Can be disabled by passing a nullptr.
  • gradientThreshold: Compute gradients for particles that are only within that distance. Irrelevant if gradients is nullptr.
  • stream: The stream to execute the operation on.

virtual void sdfPerPosition(GPUcontainer *positions, GPUcontainer *sdfs, cudaStream_t stream) = 0

Compute the wall SDF at given positions.

Parameters
  • positions: Input positions.
  • sdfs: Values of the SDF at the given positions.
  • stream: The stream to execute the operation on.

virtual void sdfOnGrid(real3 gridH, GPUcontainer *sdfs, cudaStream_t stream) = 0

Compute the wall SDF on a uniform grid.

This method will resize the sdfs container internally.

Parameters
  • gridH: grid spacing.
  • sdfs: Values of the SDF at the grid nodes positions.
  • stream: The stream to execute the operation on.

virtual PinnedBuffer<double3> *getCurrentBounceForce() = 0

Get accumulated force of particles on the wall at the previous bounce() operation..

Derived classes

template <class InsideWallChecker>
class SimpleStationaryWall : public mirheo::SDFBasedWall

SDF based Wall with zero velocity boundary conditions.

Template Parameters
  • InsideWallChecker: Wall shape representation.

Subclassed by mirheo::WallWithVelocity< InsideWallChecker, VelocityField >

Public Functions

SimpleStationaryWall(const MirState *state, const std::string &name, InsideWallChecker &&insideWallChecker)

Construct a SimpleStationaryWall object.

Parameters
  • state: The simulation state.
  • name: The wall name.
  • insideWallChecker: A functor that represents the wall surface (see stationary_walls/).

void setup(MPI_Comm &comm)

Initialize the wall internal state.

This must be called before any other wall operations that involve its surface.

Parameters
  • comm: The MPI Cartesian communicator of the simulation.

void setPrerequisites(ParticleVector *pv)

Set properties needed by the particles to be bounced.

Must be called just after

setup() and before any bounce(). Default: ask nothing.
Parameters
  • pv: Particles to add additional properties to.

void attachFrozen(ParticleVector *pv)

Set frozen particles to the wall.

The frozen particles may be modified in the operation (velocities set to the wall’s one).

Parameters
  • pv: The frozen particles.

void removeInner(ParticleVector *pv)

Remove particles inside the walls.

If pv is an

ObjectVector, any object with at least one particle will be removed by this operation.
Parameters

void attach(ParticleVector *pv, CellList *cl, real maximumPartTravel)

Register a ParticleVector that needs to be bounced from the wall.

Multiple

ParticleVector can be registered by calling this method several times. The parameter maximumPartTravel is used for performance, lower leading to higher performances. Note that if it is too low, some particles may be ignored and not bounced and end up inside the walls (see bounce()).
Parameters
  • pv: The particles to be bounced. Will be ignored if it is the same as the frozen particles.
  • cl: Cell lists corresponding to pv.
  • maximumPartTravel: The estimated maximum distance traveled by one particle over a single time step.

void detachAllCellLists()

Clean up all information regarding cell lists generated by attach.

void bounce(cudaStream_t stream)

Bounce the particles attached to the wall.

The particles that are bounced must be registered previously exactly once with

attach().
Parameters
  • stream: The stream to execute the bounce operation on.

void check(cudaStream_t stream)

Counts number of particles inside the walls and report it in the logs.

The particles that are counted must be previously attached to the walls by calling

attach().
Parameters
  • stream: The stream to execute the check operation on.

void sdfPerParticle(LocalParticleVector *lpv, GPUcontainer *sdfs, GPUcontainer *gradients, real gradientThreshold, cudaStream_t stream)

Compute the wall SDF at particles positions.

Parameters
  • lpv: Input particles.
  • sdfs: Values of the SDF at the particle positions.
  • gradients: Gradients of the SDF at the particle positions. Can be disabled by passing a nullptr.
  • gradientThreshold: Compute gradients for particles that are only within that distance. Irrelevant if gradients is nullptr.
  • stream: The stream to execute the operation on.

void sdfPerPosition(GPUcontainer *positions, GPUcontainer *sdfs, cudaStream_t stream)

Compute the wall SDF at given positions.

Parameters
  • positions: Input positions.
  • sdfs: Values of the SDF at the given positions.
  • stream: The stream to execute the operation on.

void sdfOnGrid(real3 gridH, GPUcontainer *sdfs, cudaStream_t stream)

Compute the wall SDF on a uniform grid.

This method will resize the sdfs container internally.

Parameters
  • gridH: grid spacing.
  • sdfs: Values of the SDF at the grid nodes positions.
  • stream: The stream to execute the operation on.

InsideWallChecker &getChecker()

get a reference of the wall surfae representation.

PinnedBuffer<double3> *getCurrentBounceForce()

Get accumulated force of particles on the wall at the previous bounce() operation..

template <class InsideWallChecker, class VelocityField>
class WallWithVelocity : public mirheo::SimpleStationaryWall<InsideWallChecker>

SDF-based wall with non zero velocity boundary conditions.

Template Parameters
  • InsideWallChecker: Wall shape representation.
  • VelocityField: Wall velocity representation.

Public Functions

WallWithVelocity(const MirState *state, const std::string &name, InsideWallChecker &&insideWallChecker, VelocityField &&velField)

Construct a WallWithVelocity object.

Parameters
  • state: The simulation state.
  • name: The wall name.
  • insideWallChecker: A functor that represents the wall surface (see stationary_walls/).
  • velField: A functor that represents the wall velocity (see velocity_field/).

void setup(MPI_Comm &comm)

Initialize the wall internal state.

This must be called before any other wall operations that involve its surface.

Parameters
  • comm: The MPI Cartesian communicator of the simulation.

void attachFrozen(ParticleVector *pv)

Set frozen particles to the wall.

The frozen particles may be modified in the operation (velocities set to the wall’s one).

Parameters
  • pv: The frozen particles.

void bounce(cudaStream_t stream)

Bounce the particles attached to the wall.

The particles that are bounced must be registered previously exactly once with

attach().
Parameters
  • stream: The stream to execute the bounce operation on.

Wall shapes

class StationaryWallBox

Represents a box shape.

Public Functions

StationaryWallBox(real3 lo, real3 hi, bool inside)

Construct a StationaryWallBox.

Parameters
  • lo: Lower bounds of the box (in global coordinates).
  • hi: Upper bounds of the box (in global coordinates).
  • inside: Domain is inside the box if set to true.

void setup(MPI_Comm &comm, DomainInfo domain)

Synchronize internal state with simulation.

Parameters
  • comm: MPI carthesia communicator
  • domain: Domain info

const StationaryWallBox &handler() const

Get a handler of the shape representation usable on the device.

real operator()(real3 r) const

Get the SDF of the current shape at a given position.

Return
The SDF value
Parameters
  • r: position in local coordinates

class StationaryWallCylinder

Represents a cylinder along one of the main axes.

Public Types

enum Direction

Represents the direction of the main axis of the cylinder.

Values:

x
y
z

Public Functions

StationaryWallCylinder(real2 center, real radius, Direction dir, bool inside)

Construct a StationaryWallCylinder.

Parameters
  • center: Center of the cylinder in global coordinates in the plane perpendicular to the direction
  • radius: Radius of the cylinder
  • dir: The direction of the main axis.
  • inside: Domain is inside the cylinder if set to true.

void setup(MPI_Comm &comm, DomainInfo domain)

Synchronize internal state with simulation.

Parameters
  • comm: MPI carthesia communicator
  • domain: Domain info

const StationaryWallCylinder &handler() const

Get a handler of the shape representation usable on the device.

real operator()(real3 r) const

Get the SDF of the current shape at a given position.

Return
The SDF value
Parameters
  • r: position in local coordinates

class StationaryWallPlane

Represents a planar wall.

Public Functions

StationaryWallPlane(real3 normal, real3 pointThrough)

Construct a StationaryWallPlane.

Parameters
  • normal: Normal of the wall, pointing inside the walls.
  • pointThrough: One point inside the plane, in global coordinates.

void setup(MPI_Comm &comm, DomainInfo domain)

Synchronize internal state with simulation.

Parameters
  • comm: MPI carthesia communicator
  • domain: Domain info

const StationaryWallPlane &handler() const

Get a handler of the shape representation usable on the device.

real operator()(real3 r) const

Get the SDF of the current shape at a given position.

Return
The SDF value
Parameters
  • r: position in local coordinates

class StationaryWallSDF

Represent an arbitrary SDF field on a grid.

Public Functions

StationaryWallSDF(const MirState *state, std::string sdfFileName, real3 sdfH)

Construct a StationaryWallSDF from a file.

Parameters
  • state: Simulation state
  • sdfFileName: The input file name
  • sdfH: The grid spacing

StationaryWallSDF(StationaryWallSDF&&)

Move ctor.

void setup(MPI_Comm &comm, DomainInfo domain)

Synchronize internal state with simulation.

Parameters
  • comm: MPI carthesia communicator
  • domain: Domain info

const FieldDeviceHandler &handler() const

Get a handler of the shape representation usable on the device.

class StationaryWallSphere

Represents a sphere shape.

Public Functions

StationaryWallSphere(real3 center, real radius, bool inside)

Construct a StationaryWallSphere.

Parameters
  • center: Center of the sphere in global coordinates
  • radius: Radius of the sphere
  • inside: Domain is inside the box if set to true.

void setup(MPI_Comm &comm, DomainInfo domain)

Synchronize internal state with simulation.

Parameters
  • comm: MPI carthesia communicator
  • domain: Domain info

const StationaryWallSphere &handler() const

Get a handler of the shape representation usable on the device.

real operator()(real3 r) const

Get the SDF of the current shape at a given position.

Return
The SDF value
Parameters
  • r: position in local coordinates

Velocity fields

class VelocityFieldNone

Zero velocity field.

Public Functions

void setup(real t, DomainInfo domain)

to fit the interface

const VelocityFieldNone &handler() const

get a handler that can be used on device

real3 operator()(real3 r) const

Evaluate the velocity field at a given position.

Return
The velocity value
Parameters
  • r: The position in local coordinates

class VelocityFieldOscillate

Oscillating velocity field in time.

\[\mathbf{v}(t) = \cos{\frac {2 \pi t}{T}} \mathbf{v},\]

where \(T\) is the period.

Public Functions

VelocityFieldOscillate(real3 vel, real period)

Construct a VelocityFieldOscillate object.

Parameters
  • vel: The maximum velocity vector
  • period: Oscillating period in simulation time. Fails if negative.

void setup(real t, DomainInfo domain)

Synchronize with simulation state.

Must be called at every time step.

Parameters

const VelocityFieldOscillate &handler() const

get a handler that can be used on the device.

real3 operator()(real3 r) const

Evaluate the velocity field at a given position.

Return
The velocity value
Parameters
  • r: The position in local coordinates

class VelocityFieldRotate

Rotating velocity field (constant in time).

The field is defined by a center and an angular velocity:

\[\mathbf{v}(\mathbf{r}) = \mathbf{\omega} \times (\mathbf{r} - \mathbf{c})\]

Public Functions

VelocityFieldRotate(real3 omega, real3 center)

Construct a VelocityFieldRotate object.

Parameters
  • omega: The angular velocity
  • center: Center of rotation in global coordinates

void setup(real t, DomainInfo domain)

Synchronize with simulation state.

Must be called at every time step.

Parameters

const VelocityFieldRotate &handler() const

get a handler that can be used on the device.

real3 operator()(real3 r) const

Evaluate the velocity field at a given position.

Return
The velocity value
Parameters
  • r: The position in local coordinates

class VelocityFieldTranslate

Constant velocity field.

Public Functions

VelocityFieldTranslate(real3 vel)

Construct a VelocityFieldTranslate.

Parameters
  • vel: The constant velocity

void setup(real t, DomainInfo domain)

to fir the interface

const VelocityFieldTranslate &handler() const

get a handler that can be used on the device

real3 operator()(real3 r) const

Evaluate the velocity field at a given position.

Return
The velocity value
Parameters
  • r: The position in local coordinates