RepastHPC  2.3.1
CartesianTopology.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * CartesianTopology.h
36  *
37  * Created on: July 28, 2015
38  * Author: jtm
39  */
40 
41 #ifndef CARTESIANTOPOLOGY_H_
42 #define CARTESIANTOPOLOGY_H_
43 
44 #include <map>
45 #include "mpi.h"
46 #include <boost/mpi.hpp>
47 
48 #include "GridDimensions.h"
49 #include "RelativeLocation.h"
50 
51 using namespace std;
52 
53 namespace repast {
54 
56 
57 private:
58  bool periodic;
59  std::vector<int> procsPerDim;
60 
61 public:
62  MPI_Comm topologyComm;
63 
64  CartesianTopology(std::vector<int> processesPerDim, bool spaceIsPeriodic, boost::mpi::communicator* world);
65  virtual ~CartesianTopology();
66 
71  int getRank(std::vector<int>& loc, std::vector<int>& relLoc);
72 
77  void getCoordinates(int rank, std::vector<int>& coords);
78 
83  GridDimensions getDimensions(int rank, GridDimensions globalBoundaries);
84 
89  GridDimensions getDimensions(std::vector<int>& pCoordinates, GridDimensions globalBoundaries);
90 
100  RelativeLocation trim(int rank, RelativeLocation volume);
101 
108  bool matches(std::vector<int> processesPerDim, bool spaceIsPeriodic);
109 };
110 }
111 
112 #endif /* DIFFUSIONLAYERND_H_ */
repast::CartesianTopology
Definition: CartesianTopology.h:55
repast::GridDimensions
Basic structure for specifying grid dimenions.
Definition: GridDimensions.h:58
repast::RelativeLocation
A RelativeLocation is a vector of integers that express a relative location in a coordinate system; t...
Definition: RelativeLocation.h:103