Page MenuHomec4science

ref_subset.hh
No OneTemporary

File Metadata

Created
Sun, Nov 3, 20:44

ref_subset.hh

/**
* @file ref_subset.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_SUBSET_HH__
#define __LIBMULTISCALE_REF_SUBSET_HH__
/* -------------------------------------------------------------------------- */
#include <map>
#include <vector>
/* -------------------------------------------------------------------------- */
#include "attached_object.hh"
#include "container_array.hh"
#include "pack_buffer.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
template <typename Cont> class RefSubset {
/* ------------------------------------------------------------------------ */
/* 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:
RefSubset(Cont &cont, UInt id, const std::string &name)
: container(cont), subset_id(id), name(name){};
virtual ~RefSubset(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
//! attach a vector of data to the subset
bool attachData(AttachedObject *obj);
//! detach a vector of data from the subset
void detachData(AttachedObject *obj);
//! build the mask for the sent atoms
void buildMasksForSentAtoms(MapRefToUInt &masks);
//! declare the atoms sent to other processors
void declareSentAtoms(MapRefToUInt &sent_atoms,
MapUIntToRefList &sent_reverse);
//! declare the atoms received from other processors
void declareRecvAtoms(MapRefToUInt &masks, MapUIntToRefList &recv_atoms);
//! pack attached data
void packAttachedData(std::map<UInt, PackBuffer> &buffer);
//! unpack attached data
void unpackAttachedData(std::map<UInt, PackBuffer> &buffer);
//! translate the internal references
void translateMovingReferences(MapRefToRef &moved);
//! fill remaining holes so that container is one pack
void fillRemainingHoles();
//! move last reference in the array (useful to fill holes)
void moveLastReference(UInt i_dest);
//! move reference in the array
void moveReference(UInt i_src, UInt i_dest);
//! resize container and attached values
void resize(UInt sz);
//! return the name of the subset
std::string getID() { return name; };
/* ------------------------------------------------------------------------ */
/* 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 subset
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;
// id of the subset
UInt subset_id;
// name
std::string name;
};
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_REF_SUBSET_HH__ */

Event Timeline