MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
paralleltopology
XYZTopology.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_XYZTOPOLOGY_H_
6
#define _MOLECULARDYNAMICS_COUPLING_PARALLELTOPOLOGY_XYZTOPOLOGY_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
XYZTopology
;
14
}
15
}
// namespace coupling
16
32
template
<
unsigned
int
dim>
class
coupling::paralleltopology::XYZTopology
:
public
coupling::paralleltopology::ParallelTopology
<dim> {
33
public
:
35
XYZTopology
(
tarch::la::Vector<dim, unsigned int>
numberProcesses)
36
:
coupling
::
paralleltopology
::
ParallelTopology
<dim>(), _numberProcesses(numberProcesses),
37
_divisionFactor4NumberProcesses(
coupling
::
initDivisionFactor
<dim>(numberProcesses)) {}
38
40
virtual
~XYZTopology
() {}
41
42
tarch::la::Vector<dim, unsigned int>
getProcessCoordinates
(
unsigned
int
rank,
unsigned
int
topologyOffset)
const
{
43
#if (COUPLING_MD_DEBUG == COUPLING_MD_YES)
44
std::cout <<
"Rank="
<< rank
45
<<
" corresponds to process coordinates="
<<
coupling::getVectorCellIndex<dim>
(rank - topologyOffset, _divisionFactor4NumberProcesses)
46
<< std::endl;
47
#endif
48
return
coupling::getVectorCellIndex<dim>
(rank - topologyOffset, _divisionFactor4NumberProcesses);
49
}
50
51
unsigned
int
getRank
(
tarch::la::Vector<dim, unsigned int>
processCoordinates,
unsigned
int
topologyOffset)
const
{
52
unsigned
int
index = processCoordinates[dim - 1];
53
for
(
int
d = dim - 2; d > -1; d--) {
54
index = _numberProcesses[d] * index + processCoordinates[d];
55
}
56
return
index + topologyOffset;
57
}
58
59
private
:
60
/* number of processes */
61
const
tarch::la::Vector<dim, unsigned int>
_numberProcesses;
62
/* division factor for number of processes */
63
const
tarch::la::Vector<dim, unsigned int>
_divisionFactor4NumberProcesses;
64
};
65
66
#endif
// _MOLECULARDYNAMICS_COUPLING_PARALLELTOPOLOGY_XYZTOPOLOGY_H_
coupling::paralleltopology::ParallelTopology
This class performs the conversion rank <-> process coordinates.
Definition
ParallelTopology.h:27
coupling::paralleltopology::XYZTopology
The XYZTopology orders the ranks in x-y-z manner.
Definition
XYZTopology.h:32
coupling::paralleltopology::XYZTopology::XYZTopology
XYZTopology(tarch::la::Vector< dim, unsigned int > numberProcesses)
Definition
XYZTopology.h:35
coupling::paralleltopology::XYZTopology::getRank
unsigned int getRank(tarch::la::Vector< dim, unsigned int > processCoordinates, unsigned int topologyOffset) const
converts process coordinates into a rank.
Definition
XYZTopology.h:51
coupling::paralleltopology::XYZTopology::~XYZTopology
virtual ~XYZTopology()
Definition
XYZTopology.h:40
coupling::paralleltopology::XYZTopology::getProcessCoordinates
tarch::la::Vector< dim, unsigned int > getProcessCoordinates(unsigned int rank, unsigned int topologyOffset) const
converts rank into process coordinates.
Definition
XYZTopology.h:42
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
coupling::initDivisionFactor
tarch::la::Vector< dim, unsigned int > initDivisionFactor(tarch::la::Vector< dim, unsigned int > numberCells)
Definition
CouplingMDDefinitions.h:89
coupling::getVectorCellIndex
tarch::la::Vector< dim, unsigned int > getVectorCellIndex(unsigned int cellIndex, const tarch::la::Vector< dim, unsigned int > &divisionFactor)
converts linearised cell index to a vector cell index using predefined division factors.
Definition
CouplingMDDefinitions.h:108
Generated by
1.17.0