Page MenuHomec4science

ref_set.hh
No OneTemporary

File Metadata

Created
Sun, Oct 20, 22:27

ref_set.hh

/**
* @file ref_set.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Mon Sep 08 23:40:22 2014
*
* @brief This file contains the interface of containers of references 4 the migration system
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_REF_SET_HH__
#define __LIBMULTISCALE_REF_SET_HH__
/* -------------------------------------------------------------------------- */
#include <vector>
#include <map>
/* -------------------------------------------------------------------------- */
#include "container_array.hh"
#include "pack_buffer.hh"
#include "attached_object.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template <typename Cont>
class RefSet {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
typedef typename Cont::Ref Ref;
typedef std::map<Ref,UInt,typename Ref::RefComparator> MapRefToUInt;
typedef std::map<Ref,Ref,typename Ref::RefComparator> MapRefToRef;
typedef std::map<UInt,std::vector<Ref> > MapUIntToRefList;
typedef std::map<UInt,std::vector<UInt> > MapUIntToUIntList;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
RefSet(Cont & cont, const std::string & name):
container(cont),name(name){};
virtual ~RefSet(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
//!attach a vector of data to the set
void attachData(AttachedObject * obj);
//!detach a vector of data from the set
void detachData(AttachedObject * obj);
//! declare the atoms sent to other processors
void declareSentAtoms(MapRefToUInt & sent_atoms, MapUIntToRefList & sent_reverse);
//! declare the atoms received from other processors
void declareRecvAtoms(MapUIntToRefList & recv_atoms);
//! pack attached data
void packAttachedData(std::map<UInt,PackBuffer> & buffer);
//! unpack attached data
void unpackAttachedData(std::map<UInt,PackBuffer> & buffer);
//! move reference in the array
void moveAttachedValues(UInt i_src,UInt i_dest);
//! resize the attached vectors to fit the container size
void resize();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
Cont & getContainer(){return container;};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
//! list of attached objects
std::vector<AttachedObject*> attached;
// // list of holes created by the gone atoms
// std::vector<int> holes;
//! container of references that constitutes the set
Cont & container;
//!map new proc to the list of refs that have been sent
MapUIntToRefList sent;
//!map new proc to the list of refs indexes that have been sent
MapUIntToUIntList sent_indexes;
//!map old proc to the list of refs that have been received
MapUIntToRefList recv;
//!map old proc to the list of refs indexes that have been received
MapUIntToUIntList recv_indexes;
// name
std::string name;
};
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_REF_SET_HH__ */

Event Timeline