RepastHPC  2.3.1
Public Member Functions | Protected Attributes | List of all members
repast::ValueLayerNDSU< T > Class Template Reference

ValueLayerNDSU is a version of the ValueLayerND class that facilitates SynchronousUpdating: that is, a process can use the current values in the value layer and create a set of new values, then 'switch' to using the new values. More...

#include <ValueLayerND.h>

Inheritance diagram for repast::ValueLayerNDSU< T >:
repast::AbstractValueLayerND< T > repast::DiffusionLayerND< T >

Public Member Functions

 ValueLayerNDSU (vector< int > processesPerDim, GridDimensions globalBoundaries, int bufferSize, bool periodic, T initialValue=0, T initialBufferZoneValue=0)
 
virtual void initialize (T initialValue, bool fillBufferZone=false, bool fillLocal=true)
 Inherited from AbstractValueLayerND.
 
virtual void initialize (T initialLocalValue, T initialBufferZoneValue)
 Inherited from AbstractValueLayerND.
 
virtual T addValueAt (T val, Point< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual T addValueAt (T val, vector< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual T setValueAt (T val, Point< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual T setValueAt (T val, vector< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual T getValueAt (Point< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual T getValueAt (vector< int > location, bool &errFlag)
 Inherited from AbstractValueLayerND.
 
virtual void synchronize ()
 Inherited from AbstractValueLayerND.
 
virtual void write (string fileLocation, string filetag, bool writeSharedBoundaryAreas=false)
 Write this rank's data to a CSV file.
 
void switchValueLayer ()
 Switch from one value layer to the other.
 
virtual T addSecondaryValueAt (T val, Point< int > location, bool &errFlag)
 Adds the specified value to the value in the non-current data bank at the given location. More...
 
virtual T addSecondaryValueAt (T val, vector< int > location, bool &errFlag)
 Adds the specified value to the value in the non-current data bank at the given location. More...
 
virtual T setSecondaryValueAt (T val, Point< int > location, bool &errFlag)
 Sets the specified value to the value in the non-current data bank at the given location. More...
 
virtual T setSecondaryValueAt (T val, vector< int > location, bool &errFlag)
 Sets the specified value to the value in the non-current data bank at the given location. More...
 
virtual T getSecondaryValueAt (Point< int > location, bool &errFlag)
 Gets the specified value to the value in the non-current data bank at the given location. More...
 
virtual T getSecondaryValueAt (vector< int > location, bool &errFlag)
 Gets the specified value to the value in the non-current data bank at the given location. More...
 
virtual void copyCurrentToSecondary ()
 Copies the data in the current value layer to the secondary layer.
 
virtual void copySecondaryToCurrent ()
 Copies the data in the secondary layer to the current value layer.
 
void flowback ()
 ValueLayerNDSU can do something that no other value layer- or, in fact, any other object in Repast HPC- can do: it can take information from non-local processes and allow it to flow back to the local process. More...
 
- Public Member Functions inherited from repast::AbstractValueLayerND< T >
virtual bool isInLocalBounds (vector< int > coords)
 Returns true only if the coordinates given are within the local boundaries. More...
 
virtual bool isInLocalBounds (Point< int > location)
 
const GridDimensionsgetLocalBoundaries ()
 Gets the local boundaries for this process's part of the value layer. More...
 

Protected Attributes

T * dataSpace1
 
T * dataSpace2
 
T * currentDataSpace
 
T * otherDataSpace
 
- Protected Attributes inherited from repast::AbstractValueLayerND< T >
CartesianTopologycartTopology
 
GridDimensions localBoundaries
 
int length
 
int numDims
 
bool globalSpaceIsPeriodic
 
vector< int > places
 
vector< int > strides
 
vector< DimensionDatum< T > > dimensionData
 
RankDatumneighborData
 
int neighborCount
 
MPI_Request * requests
 
int instanceID
 
int syncCount
 

Additional Inherited Members

- Static Public Attributes inherited from repast::AbstractValueLayerND< T >
static int instanceCount = 0
 
- Protected Member Functions inherited from repast::AbstractValueLayerND< T >
 AbstractValueLayerND (vector< int > processesPerDim, GridDimensions globalBoundaries, int bufferSize, bool periodic)
 Constructor. More...
 
vector< int > getIndexes (vector< int > location, bool isSimplified=false)
 Gets a vector of the indexed locations. More...
 
int getIndex (vector< int > location, bool isSimplified=false)
 Given a location in global simulation coordinates, get the offset from the global base pointer to the position in the global array representing that location. More...
 
int getIndex (Point< int > location)
 Given a location in global simulation coordinates, get the offset from the global base pointer to the position in the global array representing that location. More...
 

Detailed Description

template<typename T>
class repast::ValueLayerNDSU< T >

ValueLayerNDSU is a version of the ValueLayerND class that facilitates SynchronousUpdating: that is, a process can use the current values in the value layer and create a set of new values, then 'switch' to using the new values.

It does this by using two memory banks.

Member Function Documentation

◆ addSecondaryValueAt() [1/2]

template<typename T >
T repast::ValueLayerNDSU< T >::addSecondaryValueAt ( val,
Point< int >  location,
bool &  errFlag 
)
virtual

Adds the specified value to the value in the non-current data bank at the given location.

Parameters
valValue to be added
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the new value in the cell

◆ addSecondaryValueAt() [2/2]

template<typename T >
T repast::ValueLayerNDSU< T >::addSecondaryValueAt ( val,
vector< int >  location,
bool &  errFlag 
)
virtual

Adds the specified value to the value in the non-current data bank at the given location.

Parameters
valValue to be added
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the new value in the cell

◆ flowback()

template<typename T >
void repast::ValueLayerNDSU< T >::flowback

ValueLayerNDSU can do something that no other value layer- or, in fact, any other object in Repast HPC- can do: it can take information from non-local processes and allow it to flow back to the local process.

This is strictly forbidden in every other context in Repast HPC. Consider a local process 0 with an Agent 'A' in one corner of its space. Because 'A' is in the buffer zone, copies of 'A' are made on the other processes adjacent to process 0; in a normal 2-D space this could include three other processes, p1, p2, and p3. Now suppose that p1, p2, and p3 are all allowed to modify their copies of Agent 'A', and then, further, that we wish to migrate these changes back to process 0. How do we reconcile the changes? In general there is no answer.

ValueLayerNDSU, however, makes one special provision for allowing non- local information to flow back to the local process. Assume that as in the agent example, there is a corner of the value layer on p0 that is adjacent to p1, p2, and p3. Copies of the space are made to the other processes. Now assume that these other processes add values to these regions of space. The simulation is responsible for assuring that these additive operations are independent of the simulation synchronization: that in the specific simulation being undertaken, the additions that are occurring without synchronization are semantically acceptable.

The 'flowback' method takes these values and performs what is akin to an MPI 'gather' operation: taking the values from processes p1, p2, and p3 and adding them to the values on p0. The result of the operation is that the values on each process reflect the original values plus the values that were found in the non-local processes, with all values summed.

N.B.: All values in the secondary layer are set to zeros. Values on the original process inside and outside the buffer zones are unchanged. To update the values outside the buffer zones to their new values, perform a 'synchronize' operation after the 'flowback' operation is completed.

◆ getSecondaryValueAt() [1/2]

template<typename T >
T repast::ValueLayerNDSU< T >::getSecondaryValueAt ( Point< int >  location,
bool &  errFlag 
)
virtual

Gets the specified value to the value in the non-current data bank at the given location.

Parameters
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the value in the cell

◆ getSecondaryValueAt() [2/2]

template<typename T >
T repast::ValueLayerNDSU< T >::getSecondaryValueAt ( vector< int >  location,
bool &  errFlag 
)
virtual

Gets the specified value to the value in the non-current data bank at the given location.

Parameters
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the new value in the cell

◆ setSecondaryValueAt() [1/2]

template<typename T >
T repast::ValueLayerNDSU< T >::setSecondaryValueAt ( val,
Point< int >  location,
bool &  errFlag 
)
virtual

Sets the specified value to the value in the non-current data bank at the given location.

Parameters
valValue to be added
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the new value in the cell

◆ setSecondaryValueAt() [2/2]

template<typename T >
T repast::ValueLayerNDSU< T >::setSecondaryValueAt ( val,
vector< int >  location,
bool &  errFlag 
)
virtual

Sets the specified value to the value in the non-current data bank at the given location.

Parameters
valValue to be added
locationlocation where value is to be placed @errFlag a flag that will be set to 'false' if an error occurs
Returns
the new value in the cell

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