SubdomainGraphNodes.hpp 6.32 KB
Newer Older
incardon's avatar
incardon committed
1
#ifndef SUBDOMAIN_NODES_HPP
incardon's avatar
incardon committed
2
#define SUBDOMAIN_NODES_HPP
incardon's avatar
incardon committed
3

Pietro Incardona's avatar
Pietro Incardona committed
4 5 6 7
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/include/at_c.hpp>
#include "Grid/Encap.hpp"

incardon's avatar
incardon committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/* In a decomposition graph each node represent a sub-domain while an edge represent
 * an interaction between sub-domain (it mean that they have to communicate).
 *
 * Here we list the of property that a vertex node can carry with a brief
 * explanation:
 *
 * x = position x of the sub-domain
 * y = position y of the sub-domain
 * z = position z of the sub-domain
 * communication = is the estimated total communication produced by the sub-domain
 * computation = the total computation produced by the sub-domain
 * memory = estimated memory required by the sub-domain
 * id = which processor own this sub-domain
 * sub-id = sub-decomposition where each group of sub-domain is organized in an
 *          hyper-cube
 *
 * Here we list the properties that an edge node can carry with a brief explanation
 *
 * communication = is the estimated communication between sub-domains
 *
 */

/* \brief Sub-domain vertex graph node
 *
 */

struct nm_v
{
	//! The node contain 3 unsigned long integer for communication computation memory and id
37
	typedef boost::fusion::vector<float[3], size_t, size_t, size_t, size_t, long int, size_t> type;
incardon's avatar
incardon committed
38 39 40 41 42 43 44 45 46 47 48 49 50

	//! type of the positional field
	typedef float s_type;

	//! Attributes name
	struct attributes
	{
		static const std::string name[];
	};

	//! The data
	type data;

tonynsyde's avatar
tonynsyde committed
51
	//! pos property id in boost::fusion::vector
incardon's avatar
incardon committed
52
	static const unsigned int x = 0;
tonynsyde's avatar
tonynsyde committed
53 54
	//! migration property id in boost::fusion::vector
	static const unsigned int migration = 1;
incardon's avatar
incardon committed
55
	//! computation property id in boost::fusion::vector
tonynsyde's avatar
tonynsyde committed
56 57 58 59 60 61 62 63 64
	static const unsigned int computation = 2;
	//! global_id property id in boost::fusion::vector
	static const unsigned int global_id = 3;
	//! id property id in boost::fusion::vector
	static const unsigned int id = 4;
	//! sub_id property id in boost::fusion::vector
	static const unsigned int sub_id = 5;
	//! proc_id property id in boost::fusion::vector
	static const unsigned int proc_id = 6;
incardon's avatar
incardon committed
65 66

	//! total number of properties boost::fusion::vector
Pietro Incardona's avatar
Pietro Incardona committed
67
	static const unsigned int max_prop = 7;
tonynsyde's avatar
tonynsyde committed
68 69 70 71 72 73 74

	//! default constructor
	nm_v()
	{

	}

tonynsyde's avatar
tonynsyde committed
75 76 77 78 79 80 81 82 83 84 85 86 87
	inline nm_v(const nm_v & p)
	{
		boost::fusion::at_c<0>(data)[0] = boost::fusion::at_c<0>(p.data)[0];
		boost::fusion::at_c<0>(data)[1] = boost::fusion::at_c<0>(p.data)[1];
		boost::fusion::at_c<0>(data)[2] = boost::fusion::at_c<0>(p.data)[2];
		boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
		boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
		boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
		boost::fusion::at_c<4>(data) = boost::fusion::at_c<4>(p.data);
		boost::fusion::at_c<5>(data) = boost::fusion::at_c<5>(p.data);
		boost::fusion::at_c<6>(data) = boost::fusion::at_c<6>(p.data);
	}

tonynsyde's avatar
tonynsyde committed
88 89
	template<unsigned int dim, typename Mem> inline nm_v(const encapc<dim, nm_v, Mem> & p)
	{
tonynsyde's avatar
tonynsyde committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
		this->operator=(p);
	}

	template<unsigned int dim, typename Mem> inline nm_v & operator=(const encapc<dim, nm_v, Mem> & p)
	{
		boost::fusion::at_c<0>(data)[0] = p.template get<0>()[0];
		boost::fusion::at_c<0>(data)[1] = p.template get<0>()[1];
		boost::fusion::at_c<0>(data)[2] = p.template get<0>()[2];
		boost::fusion::at_c<1>(data) = p.template get<1>();
		boost::fusion::at_c<2>(data) = p.template get<2>();
		boost::fusion::at_c<3>(data) = p.template get<3>();
		boost::fusion::at_c<4>(data) = p.template get<4>();
		boost::fusion::at_c<5>(data) = p.template get<5>();
		boost::fusion::at_c<6>(data) = p.template get<6>();

		return *this;
	}

	template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data))
	{
		return boost::fusion::at_c<id>(data);
	}

	template<unsigned int id> inline auto get() const -> const decltype(boost::fusion::at_c < id > (data))
	{
		return boost::fusion::at_c<id>(data);
	}

	static bool noPointers()
	{
		return true;
tonynsyde's avatar
tonynsyde committed
121 122
	}

incardon's avatar
incardon committed
123 124 125 126 127 128 129 130 131
};

/*! \brief sub-domain edge graph node
 *
 */

struct nm_e
{
	//! The node contain 3 unsigned long integer for comunication computation and memory
tonynsyde's avatar
tonynsyde committed
132
	typedef boost::fusion::vector<size_t, size_t, size_t> type;
incardon's avatar
incardon committed
133 134 135 136 137 138 139 140 141 142 143 144

	//! Attributes name
	struct attributes
	{
		static const std::string name[];
	};

	//! The data
	type data;

	//! computation property id in boost::fusion::vector
	static const unsigned int communication = 0;
tonynsyde's avatar
tonynsyde committed
145 146
	static const unsigned int srcgid = 1;
	static const unsigned int dstgid = 2;
incardon's avatar
incardon committed
147
	//! total number of properties boost::fusion::vector
tonynsyde's avatar
tonynsyde committed
148
	static const unsigned int max_prop = 3;
tonynsyde's avatar
tonynsyde committed
149 150 151 152 153 154 155 156

	nm_e()
	{

	}

	template<unsigned int dim, typename Mem> inline nm_e(const encapc<dim, nm_e, Mem> & p)
	{
tonynsyde's avatar
tonynsyde committed
157 158 159
		boost::fusion::at_c<0>(data) = p.template get<0>();
		boost::fusion::at_c<1>(data) = p.template get<1>();
		boost::fusion::at_c<2>(data) = p.template get<2>();
tonynsyde's avatar
tonynsyde committed
160 161

	}
tonynsyde's avatar
tonynsyde committed
162 163 164 165 166 167 168 169 170 171

	template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data))
	{
		return boost::fusion::at_c<id>(data);
	}

	static bool noPointers()
	{
		return true;
	}
incardon's avatar
incardon committed
172 173 174 175 176 177 178 179 180 181 182
};

/*! \brief Reduced sub-domain vertex graph node
 *
 * It contain only the processor id for each node
 *
 */

struct nm_part_v
{
	//! The node contain 3 unsigned long integer for comunication computation and memory
tonynsyde's avatar
tonynsyde committed
183
	typedef boost::fusion::vector<size_t, size_t> type;
incardon's avatar
incardon committed
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

	typedef float s_type;

	//! Attributes name
	struct attributes
	{
		static const std::string name[];
	};

	//! The data

	type data;

	//! partition id in the boost::fusion::vector
	static const unsigned int id = 0;
	//! partition id in the boost::fusion::vector
	static const unsigned int sub_id = 1;

	//! total number of properties
	static const unsigned int max_prop = 2;
tonynsyde's avatar
tonynsyde committed
204 205 206 207 208 209 210 211 212

	//! default constructor
	nm_part_v()
	{

	}

	template<unsigned int dim, typename Mem> inline nm_part_v(const encapc<dim, nm_part_v, Mem> & p)
	{
tonynsyde's avatar
tonynsyde committed
213 214
		boost::fusion::at_c<0>(data) = p.template get<0>();
		boost::fusion::at_c<1>(data) = p.template get<1>();
tonynsyde's avatar
tonynsyde committed
215 216
	}

incardon's avatar
incardon committed
217 218 219 220 221
	static inline bool noPointers()
	{
		return true;
	}

incardon's avatar
incardon committed
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
};

/*! \brief Reduced edge graph node
 *
 * It contain only the communication between nodes
 *
 */

struct nm_part_e
{
	//! The node contain 3 unsigned long integer for comunication computation and memory
	typedef boost::fusion::vector<> type;

	//! The data

	type data;

	//! total number of properties
	static const unsigned int max_prop = 0;
tonynsyde's avatar
tonynsyde committed
241 242 243 244 245 246

	//! Attributes name
	struct attributes
	{
		static const std::string name[];
	};
incardon's avatar
incardon committed
247 248 249 250 251

	static inline bool noPointers()
	{
		return true;
	}
incardon's avatar
incardon committed
252 253
};

tonynsyde's avatar
tonynsyde committed
254

255

incardon's avatar
incardon committed
256
#endif