RepastHPC  2.3.1
SharedContinuousSpace.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  * SharedContinuousSpace.h
36  *
37  * Created on: Jul 20, 2010
38  * Author: nick
39  */
40 
41 #ifndef SHAREDCONTINUOUSSPACE_H_
42 #define SHAREDCONTINUOUSSPACE_H_
43 
44 #include <boost/mpi/communicator.hpp>
45 
46 #include "SharedBaseGrid.h"
47 
48 namespace repast {
49 
62 template<typename T, typename GPTransformer, typename Adder>
63 class SharedContinuousSpace: public SharedBaseGrid<T, GPTransformer, Adder, double> {
64 
65 protected:
66  virtual void synchMoveTo(const AgentId& id, const Point<double>& pt);
67 
68 private:
69 
71 
72 public:
73  virtual ~SharedContinuousSpace();
74  SharedContinuousSpace(std::string name, GridDimensions gridDims, std::vector<int> processDims, int buffer, boost::mpi::communicator* communicator);
75 
76 };
77 
78 template<typename T, typename GPTransformer, typename Adder>
80  std::vector<int> processDims, int buffer, boost::mpi::communicator* communicator) :
81  SharedBaseGrid<T, GPTransformer, Adder, double> (name, gridDims, processDims, buffer, communicator) {
82 }
83 
84 template<typename T, typename GPTransformer, typename Adder>
85 void SharedContinuousSpace<T, GPTransformer, Adder>::synchMoveTo(const AgentId& id, const Point<double>& pt) {
86  //unlikely chance that agent could have
87  // moved and then "died" and so removed from sending context, in which case
88  // it would never get sent to this grid.
89  if (SharedBaseGridType::GridBaseType::contains(id)) {
90  SharedBaseGridType::GridBaseType::moveTo(id, pt.coords());
91  }
92 }
93 
94 
95 template<typename T, typename GPTransformer, typename Adder>
96 SharedContinuousSpace<T, GPTransformer, Adder>::~SharedContinuousSpace() {
97 }
98 
99 }
100 
101 #endif /* SHAREDCONTINUOUSSPACE_H_ */
repast::SharedBaseGrid
Grid / Space implementation specialized for the distributed context.
Definition: SharedBaseGrid.h:168
repast::SharedContinuousSpace
Continuous space SharedBaseGrid implementation.
Definition: SharedContinuousSpace.h:63
repast::AgentId
Agent identity information.
Definition: AgentId.h:60
repast::GridDimensions
Basic structure for specifying grid dimenions.
Definition: GridDimensions.h:58
repast::Point< double >
repast::Projection::name
const std::string name() const
Gets the name of this projection.
Definition: Projection.h:164