Class MsgSpatial3D

Class Documentation

class MsgSpatial3D

3D Continuous spatial messaging functionality

User specifies the environment bounds and search radius When accessing messages, a search origin is specified A subset of messages, including those within radius of the search origin are returned The user must distance check that they fall within the search radius manually Unlike FLAMEGPU1, these spatial messages do not wrap over environment bounds.

class CUDAModelHandler : public MsgSpecialisationHandler

CUDA host side handler of spatial messages Allocates memory for and constructs PBM

Public Functions

explicit CUDAModelHandler(CUDAMessage &a)

Constructor

Initialises metadata, decides PBM size etc

Parameters

a – Parent CUDAMessage, used to access message settings, data ptrs etc

inline ~CUDAModelHandler() override

Destructor Frees all alocated memory

virtual void init(CUDAScatter &scatter, const unsigned int &streamId) override

Allocates memory for the constructed index. Sets data asthough message list is empty

Parameters
  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

virtual void buildIndex(CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream) override

Reconstructs the partition boundary matrix This should be called before reading newly output messages

Parameters
  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

virtual void allocateMetaDataDevicePtr() override

Allocates memory for the constructed index. The memory allocation is checked by build index.

virtual void freeMetaDataDevicePtr() override

Releases memory for the constructed index.

inline virtual const void *getMetaDataDevicePtr() const override

Returns a pointer to the metadata struct, this is required for reading the message data

struct Data : public MsgSpatial2D::Data

Internal data representation of Spatial3D messages within model description hierarchy

See

Description

Public Functions

virtual ~Data() = default
virtual std::unique_ptr<MsgSpecialisationHandler> getSpecialisationHander(CUDAMessage &owner) const override
virtual std::type_index getType() const override

Used internally to validate that the corresponding Msg type is attached via the agent function shim.

Returns

The std::type_index of the Msg type which must be used.

Public Members

float minZ
float maxZ

Protected Functions

virtual Data *clone(const std::shared_ptr<const ModelData> &newParent) override
Data(const std::shared_ptr<const ModelData>&, const Data &other)

Copy constructor This is unsafe, should only be used internally, use clone() instead

Data(const std::shared_ptr<const ModelData>&, const std::string &message_name)

Normal constructor, only to be called by ModelDescription

Friends

friend class ModelDescription
friend struct ModelData
class Description : public MsgBruteForce::Description

User accessible interface to Spatial3D messages within mode description hierarchy

See

Data

Public Functions

void setRadius(const float &r)
void setMinX(const float &x)
void setMinY(const float &y)
void setMinZ(const float &z)
void setMin(const float &x, const float &y, const float &z)
void setMaxX(const float &x)
void setMaxY(const float &y)
void setMaxZ(const float &z)
void setMax(const float &x, const float &y, const float &z)
float getRadius() const
float getMinX() const
float getMinY() const
float getMinZ() const
float getMaxX() const
float getMaxY() const
float getMaxZ() const

Protected Functions

Description(const std::shared_ptr<const ModelData> &_model, Data *const data)

Constructors

Description(const Description &other_message) = delete

Default copy constructor, not implemented

Description(Description &&other_message) noexcept = delete

Default move constructor, not implemented

Description &operator=(const Description &other_message) = delete

Default copy assignment, not implemented

Description &operator=(Description &&other_message) noexcept = delete

Default move assignment, not implemented

struct GridPos3D

Basic class to group 3 dimensional bin coordinates Would use glm::ivec3, but project does not currently have glm

Public Members

int x
int y
int z
class In

This class is accessible via DeviceAPI.message_in if MsgSpatial3D is specified in FLAMEGPU_AGENT_FUNCTION It gives access to functionality for reading spatially partitioned messages

Public Functions

__device__ inline In(Curve::NamespaceHash agentfn_hash, Curve::NamespaceHash msg_hash, const void *_metadata)

Constructer Initialises member variables

Parameters
  • agentfn_hash – Added to msg_hash to produce combined_hash

  • msg_hash – Added to agentfn_hash to produce combined_hash

  • _metadata – Reinterpreted as type MsgSpatial3D::MetaData

__device__ inline Filter operator()(const float &x, const float &y, const float &z) const

Returns a Filter object which provides access to message iterator for iterating a subset of messages including those within the radius of the search origin

Parameters
  • x – Search origin x coord

  • y – Search origin y coord

  • z – Search origin z coord

__forceinline__ __device__ inline float radius() const

Returns the search radius of the message list defined in the model description

class Filter

This class is created when a search origin is provided to MsgSpatial3D::In::operator()(float, float, float) It provides iterator access to a subset of the full message list, according to the provided search origin

See

MsgSpatial3D::In::operator()(float, float, float)

Public Functions

__device__ inline Filter(const MetaData *_metadata, const Curve::NamespaceHash &combined_hash, const float &x, const float &y, const float &z)

Constructor, takes the search parameters requried

Parameters
  • _metadata – Pointer to message list metadata

  • combined_hash – agentfn+message hash for accessing message data

  • x – Search origin x coord

  • y – Search origin y coord

  • z – search origin z coord

__device__ inline iterator begin(void) const

Returns an iterator to the start of the message list subset about the search origin

__device__ inline iterator end(void) const

Returns an iterator to the position beyond the end of the message list subset

Note

This iterator is the same for all message list subsets

class iterator

Stock iterator for iterating MsgSpatial3D::In::Filter::Message objects

Public Functions

__device__ inline iterator(const Filter &parent, const int &relative_cell_y, const int &relative_cell_z, const int &_cell_index_max, const int &_cell_index)

Constructor This iterator is constructed by MsgSpatial3D::In::Filter::begin()(float, float, float)

See

MsgSpatial3D::In::Operator()(float, float, float)

__device__ inline iterator(const Filter &parent)

False constructor Only used by Filter::end(), creates a null objct

__device__ inline iterator &operator++()

Moves to the next message (Prefix increment operator)

__device__ inline iterator operator++(int)

Moves to the next message (Postfix increment operator, returns value prior to increment)

__device__ inline bool operator==(const iterator &rhs) const

Equality operator Compares message

__device__ inline bool operator!=(const iterator &rhs) const

Inequality operator Compares message

__device__ inline Message &operator*()

Dereferences the iterator to return the message object, for accessing variables

__device__ inline Message *operator->()

Dereferences the iterator to return the message object, for accessing variables

class Message

Provides access to a specific message Returned by the iterator

See

In::Filter::iterator

Public Functions

__device__ inline Message(const Filter &parent, const int &relative_cell_y, const int &relative_cell_z, const int &_cell_index_max, const int &_cell_index)

Constructs a message and directly initialises all of it’s member variables

Note

See member variable documentation for their purposes

__device__ inline Message(const Filter &parent)

False minimal constructor used by iterator::end()

__device__ inline bool operator==(const Message &rhs) const

Equality operator Compares all internal member vars for equality

Note

Does not compare _parent

__device__ inline bool operator!=(const Message&) const

This should only be called to compare against end() It has been modified to check for end of iteration with minimal instructions Therefore it does not even perform the equality operation

Note

Use operator==() if proper equality is required

__device__ inline Message &operator++()

Updates the message to return variables from the next message in the message list

Returns

Returns itself

__device__ inline void nextStrip()

Utility function for deciding next strip to access

template<typename T, size_type N>
__device__ T getVariable(const char (&variable_name)[N]) const

Returns the value for the current message attached to the named variable

Parameters

variable_name – Name of the variable

Template Parameters
  • T – type of the variable

  • N – Length of variable name (this should be implicit if a string literal is passed to variable name)

Returns

The specified variable, else 0x0 if an error occurs

struct MetaData

MetaData required by spatial partitioning during message reads

Public Members

float min[3]

Minimum environment bounds

float max[3]

Maximum environment bounds

float radius

Search radius (also used as subdividision bin width)

unsigned int *PBM

Pointer to the partition boundary matrix in device memory The PBM is never stored on the host

unsigned int gridDim[3]

The number of subdividision bins in each dimensions

float environmentWidth[3]

max-lowerBound

class Out : public MsgBruteForce::Out

This class is accessible via DeviceAPI.message_out if MsgSpatial3D is specified in FLAMEGPU_AGENT_FUNCTION It gives access to functionality for outputting spatially partitioned messages

Public Functions

__device__ inline Out(Curve::NamespaceHash agentfn_hash, Curve::NamespaceHash msg_hash, const void*, unsigned int *scan_flag_messageOutput)

Constructer Initialises member variables

Parameters
  • agentfn_hash – Added to msg_hash to produce combined_hash

  • msg_hash – Added to agentfn_hash to produce combined_hash

  • scan_flag_messageOutput – Scan flag array for optional message output

__device__ inline void setLocation(const float &x, const float &y, const float &z) const

Sets the location for this agents message

Note

Convenience wrapper for setVariable()

Parameters
  • x – Message x coord

  • y – Message y coord

  • z – Message z coord