C++ mpi module for stochmagnet_main Package
Public Member Functions | Protected Member Functions | List of all members
SM_Network Class Referenceabstract

This class is describes a network composed by. More...

#include <SM_Network.h>

Inheritance diagram for SM_Network:
Inheritance graph
[legend]
Collaboration diagram for SM_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...
 
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...
 
virtual void computeBoundingBox (std::array< tReal, SM_Constants::DIM > &bbMinPoint, std::array< tReal, SM_Constants::DIM > &bbSize) const =0
 get the min point and size of the bunding box More...
 
virtual void updateState ()
 update the state of the network It computes the bounding box
 
virtual void updateConnectionValues (const tReal &noiseRate, SM_StochasticFunctionsInterface &randomF, const tReal &J, const std::function< void(const tReal &, const tReal &, const tReal &, tReal &)> &F)=0
 compute the connection values of the particles in [startInddex,endIndex[ More...
 
tBoolean saveToFile (const tString &fileName) const
 save the network into file More...
 
tBoolean loadFromFile (const tString &fileName)
 load the network from file More...
 
virtual tString toString () const override
 turn the class into a string representation 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...
 

Protected Member Functions

 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...
 
virtual void saveStatesToFile (std::ofstream &file) const
 save the state of the network More...
 
virtual void loadStatesFromFile (std::ifstream &file, tInteger &version, tDimension &d)
 load the state of the network 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

 

Additional Inherited Members

- 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...
 

Detailed Description

This class is describes a network composed by.

data attributes :

The state attributes are:

A network is built by the SM_NetworkBuilder interface implemented in network package of Stoch Magnet module

The network file format is a comment whose first word is a key to read the value of the key after it. Each comment line begins with '#'.

#version
1
#dimension
3
#periodicity per direction
isPx isPy isPz
#particles number
nPs
#halo particles number
nHs
#neighboring particles number
nNeighbors
#particles data : <index> <P.k> <neighbors number> <neighbors list>
i P.x P.y P.z n i0 i1 ... i{n-1}

Halo particles has no neigbor particles. An halo particle line contains only its index and coordinates.

Author
Stephane Despreaux
Version
3.0

Member Function Documentation

◆ computeAloneParticlesNumber()

tIndex SM_Network::computeAloneParticlesNumber ( ) const
inline

return the particles number without any connection

Returns
the number of particles without any connections

◆ computeBoundingBox()

virtual void SM_Network::computeBoundingBox ( std::array< tReal, SM_Constants::DIM > &  bbMinPoint,
std::array< tReal, SM_Constants::DIM > &  bbSize 
) const
pure virtual

get the min point and size of the bunding box

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

Implemented in SMOMPI_Network.

◆ copy()

virtual void SM_Network::copy ( const SM_Network network)
inlinevirtual

copy the network

Parameters
[in]network: the network to copy

◆ getBoundingBoxMinPoint()

const std::array<tReal,SM_Constants::DIM>& SM_Network::getBoundingBoxMinPoint ( ) const
inline

get the min point of the boudning box

Returns
the min point of the bounding box

◆ getBoundingBoxSize()

const std::array<tReal,SM_Constants::DIM>& SM_Network::getBoundingBoxSize ( ) const
inline

get the size of the boudning box

Returns
the size of the bounding box

◆ getConnectionsNumber()

tIndex SM_Network::getConnectionsNumber ( ) const
inline

get the number of connections

Returns
the number of connections

◆ getConnectionValue() [1/2]

tReal& SM_Network::getConnectionValue ( const tIndex &  i,
const tIndex &  j,
tBoolean &  isFound 
)
inline

get the value of the connection between particle i and j fro writing

Parameters
[in]i: index of the particle
[in]j: index of the particle
[out]isFoundtrue if the connection (i,j) exists
Returns
the value

◆ getConnectionValue() [2/2]

const tReal& SM_Network::getConnectionValue ( const tIndex &  i,
const tIndex &  j,
tBoolean &  isFound 
) const
inline

get the value of the connection between particle i and j for reading

Parameters
[in]i: index of the particle
[in]j: index of the particle
[out]isFoundtrue if the connection (i,j) exists
Returns
the value

◆ getConnectionValues() [1/4]

std::valarray<tReal>& SM_Network::getConnectionValues ( )
inline

get the connection values for writing

Returns
the connection values

◆ getConnectionValues() [2/4]

const std::valarray<tReal>& SM_Network::getConnectionValues ( ) const
inline

get the connection values for reading

Returns
the connection values

◆ getConnectionValues() [3/4]

tReal* SM_Network::getConnectionValues ( const tIndex &  i)
inline

get the connections values of the particle i for writing

Parameters
[in]i: index of the particle
Returns
the connection values of the particle j. The number of values is the number of the neighboring particles of the particle i

◆ getConnectionValues() [4/4]

const tReal* SM_Network::getConnectionValues ( const tIndex &  i) const
inline

get the connections values of the particle i for reading

Parameters
[in]i: index of the particle
Returns
the connection values of the particle j. The number of values is the number of the neighboring particles of the particle i

◆ getConnectionValuesNumber()

tIndex SM_Network::getConnectionValuesNumber ( ) const
inline

get the number of connection values

Returns
the number of connection values

◆ getContentsMemorySize()

virtual tMemSize SM_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 CORE_Object.

Reimplemented in SMOMPI_Network.

◆ getHaloParticlesNumber()

const tInteger& SM_Network::getHaloParticlesNumber ( ) const
inline

return the halo particles number

Returns
the number of halo particles

◆ getIndex()

const int& SM_Network::getIndex ( ) const
inline

create new instance of the network

Returns
an unique pointer to a new instance of this class

index of the network for network defined with many parts for mpi version

◆ getMemorySize()

virtual tMemSize SM_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_Object.

Reimplemented in SMOMPI_Network.

◆ getNeighboringParticlesList() [1/3]

std::valarray<tIndex>& SM_Network::getNeighboringParticlesList ( )
inline

get the neighbors indices

Returns
the neighborsIndices as indices of neighbors for each particle of size mParticlesNumber x sum on i of neighborsNumber[i]

◆ getNeighboringParticlesList() [2/3]

const std::valarray<tIndex>& SM_Network::getNeighboringParticlesList ( ) const
inline

get the neighbors indices

Returns
the neighborsIndices as indices of neighbors for each particle of size mParticlesNumber x sum on i of neighborsNumber[i]

◆ getNeighboringParticlesList() [3/3]

const tIndex* SM_Network::getNeighboringParticlesList ( const tIndex &  i) const
inline

get the index of neighboring particles list for the particle i for reading

Parameters
[in]i: index of the particle

◆ getNeighboringParticlesNumber() [1/2]

tIndex SM_Network::getNeighboringParticlesNumber ( ) const
inline

get the number of connections

Returns
the number of connections

◆ getNeighboringParticlesNumber() [2/2]

tIndex SM_Network::getNeighboringParticlesNumber ( const tIndex &  i) const
inline

get the number of neighboring particles for the particle i for writing

Parameters
[in]i: index of the particle
Returns
the number of neighboring particles for the particle i

◆ getNeighboringParticlesNumberOffset() [1/2]

std::valarray<tIndex>& SM_Network::getNeighboringParticlesNumberOffset ( )
inline

get the index of the array mNeighboringParticlesList of the first neighbor of the particle p

Returns
the index of the array mNeighboringParticlesList of the particle p

◆ getNeighboringParticlesNumberOffset() [2/2]

const std::valarray<tIndex>& SM_Network::getNeighboringParticlesNumberOffset ( ) const
inline

get the index of the array mNeighboringParticlesList of the first neighbor of the particle p

Returns
the index of the array mNeighboringParticlesList of the particle p

◆ getParticlesCoordinates() [1/2]

SM_RealField& SM_Network::getParticlesCoordinates ( )
inline

void get particles coordinates

Returns
coordinates of the particles

◆ getParticlesCoordinates() [2/2]

const SM_RealField& SM_Network::getParticlesCoordinates ( ) const
inline

void get particles coordinates

Returns
coordinates of the particles

◆ getParticlesNumber()

const tInteger& SM_Network::getParticlesNumber ( ) const
inline

return the particles number

Returns
the number of particles

◆ getPeriodicity()

const std::array<tBoolean,SM_Constants::DIM>& SM_Network::getPeriodicity ( ) const
inline

get periodicity per direction

Returns
periodicity per direction

◆ hasConnectionValues()

tBoolean SM_Network::hasConnectionValues ( ) const
inline

has connection values

Returns
true if the connections have more than 1 value

◆ loadFromFile()

tBoolean SM_Network::loadFromFile ( const tString &  fileName)

load the network from file

Parameters
[in]fileNameaboslute name of the file to load
Returns
false if the file does not exist or in bad format

◆ loadStatesFromFile()

void SM_Network::loadStatesFromFile ( std::ifstream &  file,
tInteger &  version,
tDimension &  d 
)
protectedvirtual

load the state of the network

Parameters
[in,out]file: file to load the state
[out]version: version of the loading file network
[out]d: dimension of the particles of the network

Reimplemented in SMOMPI_Network.

◆ saveStatesToFile()

void SM_Network::saveStatesToFile ( std::ofstream &  file) const
protectedvirtual

save the state of the network

Parameters
[in,out]file: file to save the state

Reimplemented in SMOMPI_Network.

◆ saveToFile()

tBoolean SM_Network::saveToFile ( const tString &  fileName) const

save the network into file

Parameters
[in]fileNameabsolute name file to save
Returns
false if the file does not exist or in bad format

The format of the core:

#version
1
#dimension
3
#periodicity per direction
isPx isPy isPz
#particles number
nPs
#halo particles number
nHs
#neighboring particles number
nNeighbors
#particles data : <index> <P.k> <neighbors number> <neighbors list>
i P.x P.y P.z n i0 i1 ... i{n-1}

◆ setIndex() [1/2]

void SM_Network::setIndex ( const int &  index,
const int &  rootIndex,
const int &  indicesNumber 
)
inline

set the index of the network

Parameters
[in]indexindex of the network
[in]rootIndexindex of the network (-1 if no root)
[in]indicesNumbernumber of index usually the index of the network is the core id for mpi version -1 otherwise

◆ setIndex() [2/2]

void SM_Network::setIndex ( const int &  index,
const int &  rootIndex,
const int &  indicesNumber,
const tString &  prefix 
)
inline

set the index of the network

Parameters
[in]indexindex of the network
[in]rootIndexindex of the network (-1 if no root)
[in]indicesNumbernumber of index
[in]prefix: prefix of the index usually the index of the network is the core id for mpi version -1 otherwise

◆ setNeighboringParticlesList() [1/2]

void SM_Network::setNeighboringParticlesList ( const std::valarray< tUCInt > &  neighborsNumber,
const std::vector< tIndex > &  neighborsList 
)
inline

set the neighboring particles list and its offset

Parameters
[in]neighborsNumbernumber of neighbors for each particle of size mParticlesNumber
[in]neighborsListindices of neighbors for each particle of size mParticlesNumber x sum of neighborsNumber[i]

◆ setNeighboringParticlesList() [2/2]

void SM_Network::setNeighboringParticlesList ( std::valarray< tUCInt > &&  neighborsNumber,
std::valarray< tIndex > &&  neighborsList 
)
inline

set the neighbors list and offset for list

Parameters
[in]neighborsNumbernumber of neighbors for each particle of size mParticlesNumber
[in]neighborsListindices of neighbors for each particle of size mParticlesNumber x sum_i neighborsNumber[i]

◆ setParticlesCoordinates() [1/3]

void SM_Network::setParticlesCoordinates ( const SM_RealField coords)
inline

void set particles coordinates

Parameters
[in]coords: coordinates of the particles

◆ setParticlesCoordinates() [2/3]

void SM_Network::setParticlesCoordinates ( const std::initializer_list< tReal > &  coords)
inline

void set particles 3D-coordinates

Parameters
[in]coordslist of 3D-coordinates

◆ setParticlesCoordinates() [3/3]

void SM_Network::setParticlesCoordinates ( std::initializer_list< tReal > &&  coords)
inline

void set particles 3D-coordinates

Parameters
[in]coordslist of 3D-coordinates

◆ setParticlesNumber()

void SM_Network::setParticlesNumber ( const tInteger &  nParticles)
inline

set the particles number

Parameters
[in]nParticles: number of particles

◆ setPeriodicity() [1/3]

void SM_Network::setPeriodicity ( const std::array< tBoolean, SM_Constants::DIM > &  period)
inline

set periodicity

Parameters
[in]period: periodicity per direction

◆ setPeriodicity() [2/3]

void SM_Network::setPeriodicity ( const std::initializer_list< tBoolean > &&  period)
inline

set periodicity

Parameters
[in]period: periodicity per direction

◆ setPeriodicity() [3/3]

void SM_Network::setPeriodicity ( const std::vector< tBoolean > &  period)
inline

set periodicity

Parameters
[in]period: periodicity per direction

◆ setSize()

void SM_Network::setSize ( const tInteger &  nParticles,
const tInteger &  nHaloParticles 
)
inline

set the size of the network

Parameters
[in]nParticles: number of particles
[in]nHaloParticles: number of halo particles

◆ toString()

tString SM_Network::toString ( ) const
overridevirtual

turn the class into a string representation

Returns
a string representation of the class

Reimplemented from CORE_Object.

Reimplemented in SMOMPI_Network.

◆ updateConnectionValues()

virtual void SM_Network::updateConnectionValues ( const tReal &  noiseRate,
SM_StochasticFunctionsInterface randomF,
const tReal &  J,
const std::function< void(const tReal &, const tReal &, const tReal &, tReal &)> &  F 
)
pure virtual

compute the connection values of the particles in [startInddex,endIndex[

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

Implemented in SMOMPI_Network.

◆ updateConnectionValuesSlice()

void SM_Network::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 
)
protected

compute the connection values of the particles in [startInddex,endIndex[

Parameters
[in]startIndex: start index of the particle to compute the connection values
[in]endIndexend index of the particle to compute the connection values
[in]noiseRate: noise rate
[in,out]randomF: random function
[in]J: J value
[in]F: function depending on the random function randomF

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