Loading...
Searching...
No Matches
index_set_header.icc
Go to the documentation of this file.
#ifndef _RHEOLEF_INDEX_SET_HEADER_ICC
#define _RHEOLEF_INDEX_SET_HEADER_ICC
// wrapper for std::set<size_t>: union as a+b and a += b and others goodies
//
// motivation: this class is useful for disarray<index_set,M> to send/receive variable-sized
// lists via MPI correctly
// disarray<index_set,M> is used by the geo class to manage connectivity
// and compute neighbours
//
// author: Pierre.Saramito@imag.fr
//
// date: 19 mai 2012
//
//
// note: this code is shared by:
// - index_set.h (with extension to serialization & mpi)
// - bamg2geo.cc
// - msh2geo.cc
// => avoid code redundancy
//
#include <set>
#include <algorithm>
namespace rheolef {
/*Class:index_set
NAME: index_set - a set of indexes (@PACKAGE@-@VERSION@)
SYNOPSIS:
A class for: l = @{1,3,...9@} i.e. a wrapper for STL @code{set<size_t>} with
some assignment operators, such as l1 += l2.
This class is suitable for use with the @code{disarray<T>} class, as @code{disarray<index_set>}
(@pxref{disarray class}).
AUTHOR: Pierre.Saramito@imag.fr
DATE: date: 23 march 2011
End:
*/
//<verbatim:
class index_set : public std::set<std::size_t> {
public:
// typedefs:
typedef std::set<std::size_t> base;
typedef std::size_t value_type;
typedef std::size_t size_type;
// allocators:
index_set ();
index_set (const index_set& x);
index_set& operator= (const index_set& x);
template <int N>
index_set& operator= (size_type x[N]);
void clear ();
// basic algebra:
void insert (size_type dis_i); // a := a union {dis_i}
index_set& operator+= (size_type dis_i); // idem
index_set& operator+= (const index_set& b); // a := a union b
// a := a union b
void inplace_union (const index_set& b);
void inplace_intersection (const index_set& b);
// c := a union b
friend void set_union (const index_set& a, const index_set& b, index_set& c);
friend void set_intersection (const index_set& a, const index_set& b, index_set& c);
// io:
friend std::istream& operator>> (std::istream& is, index_set& x);
friend std::ostream& operator<< (std::ostream& os, const index_set& x);
// boost mpi:
#ifdef _RHEOLEF_INDEX_SET_H
#ifdef _RHEOLEF_HAVE_MPI
template <class Archive>
void serialize (Archive& ar, const unsigned int version);
#endif // _RHEOLEF_HAVE_MPI
#endif // _RHEOLEF_INDEX_SET_H
};
//>verbatim:
#ifdef _RHEOLEF_INDEX_SET_H
// we are in the complete set_index.h, not in bamg2geo.cc or msh2geo.cc
// => complete index_set with mpi/serialization features
// for boost mpi and disarray<index_set>:
} // namespace rheolef
#include "rheolef/msg_util.h"
namespace rheolef { namespace details {
template<>
struct default_set_op_traits<index_set> {
using type = details::generic_set_plus_op;
};
template<>
struct is_container<index_set> : std::true_type {
typedef std::true_type type;
};
#ifdef _RHEOLEF_HAVE_MPI
template<>
struct is_container_of_mpi_datatype<index_set> : std::true_type {
typedef std::true_type type;
};
#endif // _RHEOLEF_HAVE_MPI
} // namespace details
#endif // _RHEOLEF_INDEX_SET_H
// -------------------------------------------------------------------
// inlined
// -------------------------------------------------------------------
inline
index_set::index_set()
: base()
{
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++" // warning/error but is ok
template<int N>
index_set&
index_set::operator= (size_t x[N])
{
base::clear();
for (size_t* iter = &(x[0]), *last = &(x[0])+N; iter != last; iter++) {
base::insert (*iter);
}
return *this;
}
#pragma GCC diagnostic pop
inline
void
index_set::clear ()
{
base::clear();
}
inline
void
index_set::insert (size_type dis_i)
{
base::insert (dis_i);
}
inline
index_set&
index_set::operator+= (size_type dis_i)
{
base::insert (dis_i);
return *this;
}
#ifdef _RHEOLEF_INDEX_SET_H
#ifdef _RHEOLEF_HAVE_MPI
template <class Archive>
void
index_set::serialize (Archive& ar, const unsigned int version)
{
ar & boost::serialization::base_object<base>(*this);
}
#endif // _RHEOLEF_HAVE_MPI
#endif // _RHEOLEF_INDEX_SET_H
} // namespace rheolef
#endif // _RHEOLEF_INDEX_SET_HEADER_ICC
rheolef::index_set
Definition index_set_header.icc:58
rheolef::index_set::operator>>
friend std::istream & operator>>(std::istream &is, index_set &x)
Definition index_set_body.icc:57
rheolef::index_set::base
std::set< std::size_t > base
Definition index_set_header.icc:63
rheolef::index_set::inplace_intersection
void inplace_intersection(const index_set &b)
Definition index_set_body.icc:126
rheolef::index_set::serialize
void serialize(Archive &ar, const unsigned int version)
Definition index_set_header.icc:174
rheolef::index_set::inplace_union
void inplace_union(const index_set &b)
Definition index_set_body.icc:96
rheolef::index_set::insert
void insert(size_type dis_i)
Definition index_set_header.icc:159
rheolef::index_set::operator=
index_set & operator=(const index_set &x)
Definition index_set_body.icc:40
rheolef::index_set::size_type
std::size_t size_type
Definition index_set_header.icc:65
rheolef::index_set::set_intersection
friend void set_intersection(const index_set &a, const index_set &b, index_set &c)
Definition index_set_body.icc:89
rheolef::index_set::clear
void clear()
Definition index_set_header.icc:153
rheolef::index_set::operator<<
friend std::ostream & operator<<(std::ostream &os, const index_set &x)
Definition index_set_body.icc:71
rheolef::index_set::value_type
std::size_t value_type
Definition index_set_header.icc:64
rheolef::index_set::set_union
friend void set_union(const index_set &a, const index_set &b, index_set &c)
Definition index_set_body.icc:82
rheolef::index_set::operator+=
index_set & operator+=(size_type dis_i)
Definition index_set_header.icc:165
rheolef::index_set::index_set
index_set()
Definition index_set_header.icc:133
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
N
size_t N
Definition neumann-laplace-check.cc:24
rheolef::details::default_set_op_traits< index_set >::type
details::generic_set_plus_op type
Definition index_set_header.icc:115
rheolef::details::is_container< index_set >::type
std::true_type type
Definition index_set_header.icc:119
rheolef::details::is_container_of_mpi_datatype< index_set >::type
std::true_type type
Definition index_set_header.icc:124
rheolef::details::is_container_of_mpi_datatype
Definition msg_util.h:240
rheolef::details::is_container
Definition msg_util.h:235