C++ mpi module for stochmagnet_main Package
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SMOMPI_Network Class Reference

This class describes an MPI implementation of interface class SM_Network . It implements the abstract virtuam methods of the base class SM_Network : More...

#include <SMOMPI_Network.h>

Inheritance diagram for SMOMPI_Network:
Inheritance graph
[legend]
Collaboration diagram for SMOMPI_Network:
Collaboration graph
[legend]

Public Member Functions

virtual tMemSize getMemorySize () const
 return the memory size of the class and the memory size of all its attributes/associations More...
 
virtual tMemSize getContentsMemorySize () const
 return the memory size of the included associations More...
 
void setConnectedCoresNumber (const tMPIInteger &nConnectedCores)
 set connected cores number
 
const std::valarray< tMPICoreId > & getConnectedCores () const
 get the connected cores
 
std::valarray< tMPICoreId > & getConnectedCores ()
 get the connected cores
 
void setBoundParticlesNumber (const tIndex &n)
 set the bound particles number
 
const std::valarray< tIndex > & getBoundParticles () const
 get bound particles list
 
std::valarray< tIndex > & getBoundParticles ()
 get bound particles list
 
const std::valarray< tMPIInteger > & getBoundParticlesOffset () const
 get bound particles list offset
 
std::valarray< tMPIInteger > & getBoundParticlesOffset ()
 get bound particles list offset
 
const std::valarray< tMPIInteger > & getHaloParticlesOffset () const
 get halo particles list offset
 
std::valarray< tMPIInteger > & getHaloParticlesOffset ()
 get halo particles list offset
 
const std::vector< tMPIInteger > & getHaloConnectionsTag () const
 get halo connections tag
 
std::vector< tMPIInteger > & getHaloConnectionsTag ()
 get halo connections tag
 
tBoolean mpiExchangeFieldValues (SM_RealField &F)
 exchange the data of F between connected cores More...
 
virtual tString toString () const override
 return the string representation of the class
 
- Public Member Functions inherited from SM_Network
virtual void copy (const SM_Network &network)
 copy the network More...
 
const int & getIndex () const
 create new instance of the network More...
 
const int & getRootIndex () const
 index of the root network for network defined with many parts for mpi version
 
const int & getIndicesNumber () const
 get the number of network parts
 
const tString & getIndexPrefix () const
 index of the root network for network defined with many parts for mpi version
 
void setIndex (const int &index, const int &rootIndex, const int &indicesNumber)
 set the index of the network More...
 
void setIndex (const int &index, const int &rootIndex, const int &indicesNumber, const tString &prefix)
 set the index of the network More...
 
void setPeriodicity (const std::initializer_list< tBoolean > &&period)
 set periodicity More...
 
void setPeriodicity (const std::array< tBoolean, SM_Constants::DIM > &period)
 set periodicity More...
 
void setPeriodicity (const std::vector< tBoolean > &period)
 set periodicity More...
 
const std::array< tBoolean, SM_Constants::DIM > & getPeriodicity () const
 get periodicity per direction More...
 
void setParticlesNumber (const tInteger &nParticles)
 set the particles number More...
 
void setSize (const tInteger &nParticles, const tInteger &nHaloParticles)
 set the size of the network More...
 
const tInteger & getParticlesNumber () const
 return the particles number More...
 
const tInteger & getHaloParticlesNumber () const
 return the halo particles number More...
 
void setParticlesCoordinates (std::initializer_list< tReal > &&coords)
 void set particles 3D-coordinates More...
 
void setParticlesCoordinates (const std::initializer_list< tReal > &coords)
 void set particles 3D-coordinates More...
 
void setParticlesCoordinates (const SM_RealField &coords)
 void set particles coordinates More...
 
const SM_RealFieldgetParticlesCoordinates () const
 void get particles coordinates More...
 
SM_RealFieldgetParticlesCoordinates ()
 void get particles coordinates More...
 
const std::valarray< tIndex > & getNeighboringParticlesList () const
 get the neighbors indices More...
 
std::valarray< tIndex > & getNeighboringParticlesList ()
 get the neighbors indices More...
 
tIndex getNeighboringParticlesNumber () const
 get the number of connections More...
 
tIndex getConnectionsNumber () const
 get the number of connections More...
 
const std::valarray< tIndex > & getNeighboringParticlesNumberOffset () const
 get the index of the array mNeighboringParticlesList of the first neighbor of the particle p More...
 
std::valarray< tIndex > & getNeighboringParticlesNumberOffset ()
 get the index of the array mNeighboringParticlesList of the first neighbor of the particle p More...
 
const tIndex * getNeighboringParticlesList (const tIndex &i) const
 get the index of neighboring particles list for the particle i for reading More...
 
tIndex getNeighboringParticlesNumber (const tIndex &i) const
 get the number of neighboring particles for the particle i for writing More...
 
void setNeighboringParticlesList (std::valarray< tUCInt > &&neighborsNumber, std::valarray< tIndex > &&neighborsList)
 set the neighbors list and offset for list More...
 
void setNeighboringParticlesList (const std::valarray< tUCInt > &neighborsNumber, const std::vector< tIndex > &neighborsList)
 set the neighboring particles list and its offset More...
 
tIndex computeAloneParticlesNumber () const
 return the particles number without any connection More...
 
tBoolean hasConnectionValues () const
 has connection values More...
 
tIndex getConnectionValuesNumber () const
 get the number of connection values More...
 
const std::valarray< tReal > & getConnectionValues () const
 get the connection values for reading More...
 
std::valarray< tReal > & getConnectionValues ()
 get the connection values for writing More...
 
tReal & getConnectionValue (const tIndex &i, const tIndex &j, tBoolean &isFound)
 get the value of the connection between particle i and j fro writing More...
 
const tReal & getConnectionValue (const tIndex &i, const tIndex &j, tBoolean &isFound) const
 get the value of the connection between particle i and j for reading More...
 
const tReal * getConnectionValues (const tIndex &i) const
 get the connections values of the particle i for reading More...
 
tReal * getConnectionValues (const tIndex &i)
 get the connections values of the particle i for writing More...
 
const std::array< tReal, SM_Constants::DIM > & getBoundingBoxMinPoint () const
 get the min point of the boudning box More...
 
const std::array< tReal, SM_Constants::DIM > & getBoundingBoxSize () const
 get the size of the boudning box More...
 
tBoolean saveToFile (const tString &fileName) const
 save the network into file More...
 
tBoolean loadFromFile (const tString &fileName)
 load the network from file More...
 
- Public Member Functions inherited from SM_Object
 SM_Object (void)
 create
 
virtual ~SM_Object (void)
 destroy
 
- Public Member Functions inherited from CORE_Object
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 

Static Public Member Functions

static CORE_UniquePointer< SelfClassNew ()
 build a new instance of a BCC structure More...
 
static void ComputeConnectionTag (const tIndex &p, const tIndex &q, tMPITag &tag)
 compute the connection tag between particle (p,q) More...
 
- Static Public Member Functions inherited from CORE_Object
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack
 
static void DisableMemoryStack ()
 disable the memory stack
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Protected Member Functions

 SMOMPI_Network (void)
 create a network class
 
virtual ~SMOMPI_Network (void)
 destroy
 
virtual void computeBoundingBox (std::array< tReal, SM_Constants::DIM > &bbMinPoint, std::array< tReal, SM_Constants::DIM > &bbSize) const final
 get the min point and size of the bunding box depend on X More...
 
virtual void saveStatesToFile (std::ofstream &file) const override
 save the state of the network
 
virtual void loadStatesFromFile (std::ifstream &file, tInteger &version, tDimension &d) override
 load the state of the network
 
virtual void updateState () override
 compute the network stae More...
 
virtual void updateConnectionValues (const tReal &noiseRate, SM_StochasticFunctionsInterface &randomF, const tReal &J, const std::function< void(const tReal &, const tReal &, const tReal &, tReal &)> &F) final
 compute the connection values of the particles More...
 
- Protected Member Functions inherited from SM_Network
 SM_Network (void)
 create a network class
 
virtual ~SM_Network (void)
 destroy
 
void updateConnectionValuesSlice (const tIndex &startIndex, const tIndex &endIndex, const tReal &noiseRate, SM_StochasticFunctionsInterface &randomF, const tReal &J, const std::function< void(const tReal &, const tReal &, const tReal &, tReal &)> &F)
 compute the connection values of the particles in [startInddex,endIndex[ More...
 
- Protected Member Functions inherited from CORE_Object
 CORE_Object ()
 build an instance of the object
 
virtual ~CORE_Object ()
 destroy the instance of object std

 

Detailed Description

This class describes an MPI implementation of interface class SM_Network . It implements the abstract virtuam methods of the base class SM_Network :

It has the data attributes :

It has the state attributes: -mBoundFieldValues : the values on bound particles with the same size of mBoundParticles x SM_Constants::DIM -mRequests : the mpi communication requests list

The main method of the class is to exchange data between 2 connected networks SMOMPI_Network::mpiExchangeFieldValues(SM_RealField& F)

Author
Stephane Despreaux
Version
3.0

Member Function Documentation

◆ computeBoundingBox()

void SMOMPI_Network::computeBoundingBox ( std::array< tReal, SM_Constants::DIM > &  bbMinPoint,
std::array< tReal, SM_Constants::DIM > &  bbSize 
) const
finalprotectedvirtual

get the min point and size of the bunding box depend on X

Parameters
[out]bbMinPoint: min point of the bounding box
[out]bbSize: size of the bouding box

Implements SM_Network.

◆ ComputeConnectionTag()

static void SMOMPI_Network::ComputeConnectionTag ( const tIndex &  p,
const tIndex &  q,
tMPITag &  tag 
)
inlinestatic

compute the connection tag between particle (p,q)

Parameters
[in]p: global index of the particle p in the whole network
[in]q: global index of the particle q in the whole network
[out]tagtag of the connection (p,q) p<q tag=q.(q-1)/2 + p for no diagonal store

◆ getContentsMemorySize()

virtual tMemSize SMOMPI_Network::getContentsMemorySize ( ) const
inlinevirtual

return the memory size of the included associations

Returns
the memory size of the storage in bytes 1 Kb = 1024 bytes 1 Mb = 1024 Kb 1 Gb = 1024 Mb 1 Tb = 1024 Gb 1 Hb = 1024 Tb

Reimplemented from SM_Network.

◆ getMemorySize()

virtual tMemSize SMOMPI_Network::getMemorySize ( ) const
inlinevirtual

return the memory size of the class and the memory size of all its attributes/associations

Returns
the memory size of the class and the memory size of its attributes/associations in bytes The mamory size is :
  • the added size of the base classes which contains:
    • the primary attributes size depends on the order: (first delare the smallest attributes size
    • all virtual functions costs <pointer-size> (4 32xor 8 64x) bytes by virtual function
    • virtual inherihtance will increase of (4 or 8) bytes
  • we add the size of the contains values of the attributes : for example the size of a string is the length of the string 1 octet = 1 byte 1 Ko = 1024 bytes 1 Mo = 1024 Ko 1 Go = 1024 Mo

Reimplemented from SM_Network.

◆ mpiExchangeFieldValues()

tBoolean SMOMPI_Network::mpiExchangeFieldValues ( SM_RealField F)

exchange the data of F between connected cores

Parameters
[in,out]F: field to exhange data
Returns
true

The algorithm is as follow

  • the core This i-receive MPI data for connected core j within F[haloParticles[j][0],...haloParticles[j][n]] where
    • n=mHaloParticlesOffset[j+1]-mHaloParticlesOffset[j]: number of halo particles in core j
    • haloParticles[j][k]=mParticlesNumber + mHaloParticlesOffset[j]+k
  • for each connected core j, the core This does
    • build the bound values for all bound particles which are halo particles of core j mBoundValues[b]=F[boundParticles[j][k] where
      • n is the number of bound particles in core j =mBoundParticlesOffset[j+1]-mBoundParticlesOffset[j]
      • k is the index of the bound particles in [0,n[
      • s is the number of bound particles
      • b=mBoundParticlesOffset[j]+k in [0,s[
      • boundParticles[j][k]=mBoundParticles[mBoundParticlesOffset[j]+k]
    • i-send the bound values to core j
  • the core This waits for all the i-send and i-receive MPI communication finishing

◆ New()

static CORE_UniquePointer<SelfClass> SMOMPI_Network::New ( )
inlinestatic

build a new instance of a BCC structure

Returns
an unique pointer of a BCC structure

◆ updateConnectionValues()

void SMOMPI_Network::updateConnectionValues ( const tReal &  noiseRate,
SM_StochasticFunctionsInterface randomF,
const tReal &  J,
const std::function< void(const tReal &, const tReal &, const tReal &, tReal &)> &  F 
)
finalprotectedvirtual

compute the connection values of the particles

Parameters
[in]noiseRate: noise rate
[in,out]randomF: random function
[in]J: J value
[in]Ffunction dependind on the random function randomF

Implements SM_Network.

◆ updateState()

void SMOMPI_Network::updateState ( )
overrideprotectedvirtual

compute the network stae

  • compute bounding box
  • neigboring particles number per core

Reimplemented from SM_Network.


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