grid_dist_amr_key.hpp 1.47 KB
Newer Older
1 2 3 4 5 6 7 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
/*
 * grid_dist_amr_key.hpp
 *
 *  Created on: Sep 23, 2017
 *      Author: i-bird
 */

#ifndef SRC_AMR_GRID_DIST_AMR_KEY_HPP_
#define SRC_AMR_GRID_DIST_AMR_KEY_HPP_

/*! \brief Amr grid distributed key
 *
 * \tparam dim dimensionality
 *
 */
template<unsigned int dim>
class grid_dist_amr_key
{
	//! actual level
	size_t lvl;

	//! actual position in the distributed grid
	grid_dist_key_dx<dim> key;


public:

	/*! \constructor
	 *
	 * \param lvl level
	 * \param key distributed grid key
	 * \param offsets to move between levels
	 *
	 */
	inline grid_dist_amr_key(size_t lvl,
			          grid_dist_key_dx<dim> key)
	:lvl(lvl),key(key)
	{}

	/*! \brief Return the grid key
	 *
	 * \return the distributed key
	 *
	 */
	inline const grid_dist_key_dx<dim> & getKey() const
	{
		return key;
	}

	/*! \brief Return the grid key (as reference)
	 *
	 * \return the distributed key
	 *
	 */
	inline grid_dist_key_dx<dim> & getKeyRef()
	{
		return key;
	}


	/*! \brief Return the level
	 *
	 * \return the level
	 *
	 */
	inline size_t getLvl() const
	{
		return lvl;
	}

	/*! \brief Return the level
	 *
	 * \param lvl level to set
	 *
	 */
	inline void setLvl(size_t lvl)
	{
		this->lvl = lvl;
	}

	/*! \brief Create a new key moving the old one
	 *
	 * \param s dimension id
	 * \param s number of steps
	 *
	 * \return new key
	 *
	 */
	inline grid_dist_amr_key<dim> moveSpace(size_t d,size_t s)
	{
		return grid_dist_amr_key<dim>(lvl,key.move(d,s));
	}
};




#endif /* SRC_AMR_GRID_DIST_AMR_KEY_HPP_ */