MaMiCo 1.2
Loading...
Searching...
No Matches
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
11namespace coupling {
12namespace paralleltopology {
13template <unsigned int dim> class XYZTopology;
14}
15} // namespace coupling
16
33public:
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
59private:
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_
This class performs the conversion rank <-> process coordinates.
Definition ParallelTopology.h:27
The XYZTopology orders the ranks in x-y-z manner.
Definition XYZTopology.h:32
XYZTopology(tarch::la::Vector< dim, unsigned int > numberProcesses)
Definition XYZTopology.h:35
unsigned int getRank(tarch::la::Vector< dim, unsigned int > processCoordinates, unsigned int topologyOffset) const
converts process coordinates into a rank.
Definition XYZTopology.h:51
virtual ~XYZTopology()
Definition XYZTopology.h:40
tarch::la::Vector< dim, unsigned int > getProcessCoordinates(unsigned int rank, unsigned int topologyOffset) const
converts rank into process coordinates.
Definition XYZTopology.h:42
Definition Vector.h:24
Definition ParallelTopology.h:12
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15
tarch::la::Vector< dim, unsigned int > initDivisionFactor(tarch::la::Vector< dim, unsigned int > numberCells)
Definition CouplingMDDefinitions.h:89
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