MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
paralleltopology
ZYXTopology.h
1
// Copyright (C) 2015 Technische Universitaet Muenchen
2
// This file is part of the Mamico project. For conditions of distribution
3
// and use, please see the copyright notice in Mamico's main folder, or at
4
// www5.in.tum.de/mamico
5
#ifndef _MOLECULARDYNAMICS_COUPLING_PARALLELTOPOLOGY_ZYXTOPOLOGY_H_
6
#define _MOLECULARDYNAMICS_COUPLING_PARALLELTOPOLOGY_ZYXTOPOLOGY_H_
7
8
#include "coupling/CouplingMDDefinitions.h"
9
#include "coupling/paralleltopology/ParallelTopology.h"
10
11
namespace
coupling
{
12
namespace
paralleltopology
{
13
template
<
unsigned
int
dim>
class
ZYXTopology
;
14
}
15
}
// namespace coupling
16
31
template
<
unsigned
int
dim>
class
coupling::paralleltopology::ZYXTopology
:
public
coupling::paralleltopology::ParallelTopology
<dim> {
32
public
:
34
ZYXTopology
(
tarch::la::Vector<dim, unsigned int>
numberProcesses)
35
:
coupling
::
paralleltopology
::
ParallelTopology
<dim>(), _numberProcesses(numberProcesses),
36
_divisionFactor4NumberProcesses(
initDivisionFactor
(numberProcesses)) {}
37
39
virtual
~ZYXTopology
() {}
40
41
tarch::la::Vector<dim, unsigned int>
getProcessCoordinates
(
unsigned
int
rank,
unsigned
int
topologyOffset)
const
{
42
tarch::la::Vector<dim, unsigned int>
processCoordinates(0);
43
unsigned
int
help = rank - topologyOffset;
44
for
(
unsigned
int
d = 0; d < dim; d++) {
45
processCoordinates[d] = help / _divisionFactor4NumberProcesses[d];
46
help = help - processCoordinates[d] * _divisionFactor4NumberProcesses[d];
47
}
48
#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
49
std::cout <<
"Rank="
<< rank <<
" corresponds to process coordinates="
<< processCoordinates << std::endl;
50
#endif
51
return
processCoordinates;
52
}
53
56
unsigned
int
getRank
(
tarch::la::Vector<dim, unsigned int>
processCoordinates,
unsigned
int
topologyOffset)
const
{
57
unsigned
int
rank = processCoordinates[0];
58
for
(
unsigned
int
d = 1; d < dim; d++) {
59
rank = rank * _numberProcesses[d] + processCoordinates[d];
60
}
61
return
rank + topologyOffset;
62
}
63
64
private
:
67
tarch::la::Vector<dim, unsigned int>
initDivisionFactor
(
tarch::la::Vector<dim, unsigned int>
numberProcesses)
const
{
68
tarch::la::Vector<dim, unsigned int>
div(1);
69
for
(
int
d = dim - 2; d > -1; d--) {
70
div[d] = div[d + 1] * numberProcesses[d + 1];
71
}
72
return
div;
73
}
74
75
/* number of processes */
76
const
tarch::la::Vector<dim, unsigned int>
_numberProcesses;
77
/* division factor */
78
const
tarch::la::Vector<dim, unsigned int>
_divisionFactor4NumberProcesses;
79
};
80
#endif
// _MOLECULARDYNAMICS_COUPLING_PARALLELTOPOLOGY_ZYXTOPOLOGY_H_
coupling::paralleltopology::ParallelTopology
This class performs the conversion rank <-> process coordinates.
Definition
ParallelTopology.h:27
coupling::paralleltopology::ZYXTopology
The ZYXTopology orders the ranks in z-y-x manner.
Definition
ZYXTopology.h:31
coupling::paralleltopology::ZYXTopology::getProcessCoordinates
tarch::la::Vector< dim, unsigned int > getProcessCoordinates(unsigned int rank, unsigned int topologyOffset) const
converts rank into process coordinates.
Definition
ZYXTopology.h:41
coupling::paralleltopology::ZYXTopology::ZYXTopology
ZYXTopology(tarch::la::Vector< dim, unsigned int > numberProcesses)
Definition
ZYXTopology.h:34
coupling::paralleltopology::ZYXTopology::initDivisionFactor
tarch::la::Vector< dim, unsigned int > initDivisionFactor(tarch::la::Vector< dim, unsigned int > numberProcesses) const
Definition
ZYXTopology.h:67
coupling::paralleltopology::ZYXTopology::getRank
unsigned int getRank(tarch::la::Vector< dim, unsigned int > processCoordinates, unsigned int topologyOffset) const
Definition
ZYXTopology.h:56
coupling::paralleltopology::ZYXTopology::~ZYXTopology
virtual ~ZYXTopology()
Definition
ZYXTopology.h:39
tarch::la::Vector
Definition
Vector.h:25
coupling::paralleltopology
Definition
ParallelTopology.h:12
coupling
everything necessary for coupling operations, is defined in here
Definition
AdditiveMomentumInsertion.h:15
Generated by
1.17.0