Page MenuHomec4science

ref_set.hh
No OneTemporary

File Metadata

Created
Fri, Jun 28, 23:50

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 <map>
#include <vector>
/* -------------------------------------------------------------------------- */
#include "attached_object.hh"
#include "container_array.hh"
#include "pack_buffer.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template <typename Cont> class RefSet {
using Ref = typename Cont::Ref;
using MapRefToUInt = std::map<Ref, UInt, typename Ref::RefComparator>;
using MapRefToRef = std::map<Ref, Ref, typename Ref::RefComparator>;
using MapUIntToRefList = std::map<UInt, std::vector<Ref>>;
using MapUIntToUIntList = std::map<UInt, std::vector<UInt>>;
public:
RefSet(Cont &cont, const std::string &name) : container(cont), name(name){};
virtual ~RefSet(){};
//! 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();
//! return the container being this reference set
Cont &getContainer() { return container; };
private:
//! list of attached objects
std::vector<AttachedObject *> attached;
//! 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