Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
index_set_header.icc
Go to the documentation of this file.
1#ifndef _RHEOLEF_INDEX_SET_HEADER_ICC
2#define _RHEOLEF_INDEX_SET_HEADER_ICC
23// wrapper for std::set<size_t>: union as a+b and a += b and others goodies
24//
25// motivation: this class is useful for disarray<index_set,M> to send/receive variable-sized
26// lists via MPI correctly
27// disarray<index_set,M> is used by the geo class to manage connectivity
28// and compute neighbours
29//
30// author: Pierre.Saramito@imag.fr
31//
32// date: 19 mai 2012
33//
34//
35// note: this code is shared by:
36// - index_set.h (with extension to serialization & mpi)
37// - bamg2geo.cc
38// - msh2geo.cc
39// => avoid code redundancy
40//
41#include <set>
42#include <algorithm>
43
44namespace rheolef {
45
46/*Class:index_set
47NAME: index_set - a set of indexes (@PACKAGE@-@VERSION@)
48SYNOPSIS:
49 A class for: l = @{1,3,...9@} i.e. a wrapper for STL @code{set<size_t>} with
50 some assignment operators, such as l1 += l2.
51 This class is suitable for use with the @code{disarray<T>} class, as @code{disarray<index_set>}
52 (@pxref{disarray class}).
53AUTHOR: Pierre.Saramito@imag.fr
54DATE: date: 23 march 2011
55End:
56*/
57//<verbatim:
58class index_set : public std::set<std::size_t> {
59public:
60
61// typedefs:
62
63 typedef std::set<std::size_t> base;
64 typedef std::size_t value_type;
65 typedef std::size_t size_type;
66
67// allocators:
68
69 index_set ();
70 index_set (const index_set& x);
72 template <int N>
74 void clear ();
75
76// basic algebra:
77
78 void insert (size_type dis_i); // a := a union {dis_i}
79 index_set& operator+= (size_type dis_i); // idem
80 index_set& operator+= (const index_set& b); // a := a union b
81
82 // a := a union b
83 void inplace_union (const index_set& b);
84 void inplace_intersection (const index_set& b);
85
86 // c := a union b
87 friend void set_union (const index_set& a, const index_set& b, index_set& c);
88 friend void set_intersection (const index_set& a, const index_set& b, index_set& c);
89
90// io:
91
92 friend std::istream& operator>> (std::istream& is, index_set& x);
93 friend std::ostream& operator<< (std::ostream& os, const index_set& x);
94
95// boost mpi:
96
97#ifdef _RHEOLEF_INDEX_SET_H
98#ifdef _RHEOLEF_HAVE_MPI
99 template <class Archive>
100 void serialize (Archive& ar, const unsigned int version);
101#endif // _RHEOLEF_HAVE_MPI
102#endif // _RHEOLEF_INDEX_SET_H
103};
104//>verbatim:
105
106#ifdef _RHEOLEF_INDEX_SET_H
107// we are in the complete set_index.h, not in bamg2geo.cc or msh2geo.cc
108// => complete index_set with mpi/serialization features
109// for boost mpi and disarray<index_set>:
110} // namespace rheolef
111#include "rheolef/msg_util.h"
112namespace rheolef { namespace details {
113template<>
114struct default_set_op_traits<index_set> {
115 using type = details::generic_set_plus_op;
116};
117template<>
118struct is_container<index_set> : std::true_type {
119 typedef std::true_type type;
120};
121#ifdef _RHEOLEF_HAVE_MPI
122template<>
123struct is_container_of_mpi_datatype<index_set> : std::true_type {
124 typedef std::true_type type;
125};
126#endif // _RHEOLEF_HAVE_MPI
127} // namespace details
128#endif // _RHEOLEF_INDEX_SET_H
129// -------------------------------------------------------------------
130// inlined
131// -------------------------------------------------------------------
132inline
134 : base()
135{
136}
137#pragma GCC diagnostic push
138#pragma GCC diagnostic ignored "-Weffc++" // warning/error but is ok
139template<int N>
142{
143 base::clear();
144 for (size_t* iter = &(x[0]), *last = &(x[0])+N; iter != last; iter++) {
145 base::insert (*iter);
146 }
147 return *this;
148}
149#pragma GCC diagnostic pop
150
151inline
152void
154{
155 base::clear();
156}
157inline
158void
160{
161 base::insert (dis_i);
162}
163inline
166{
167 base::insert (dis_i);
168 return *this;
169}
170#ifdef _RHEOLEF_INDEX_SET_H
171#ifdef _RHEOLEF_HAVE_MPI
172template <class Archive>
173void
174index_set::serialize (Archive& ar, const unsigned int version)
175{
176 ar & boost::serialization::base_object<base>(*this);
177}
178#endif // _RHEOLEF_HAVE_MPI
179#endif // _RHEOLEF_INDEX_SET_H
180
181} // namespace rheolef
182#endif // _RHEOLEF_INDEX_SET_HEADER_ICC
friend std::istream & operator>>(std::istream &is, index_set &x)
std::set< std::size_t > base
void inplace_intersection(const index_set &b)
void serialize(Archive &ar, const unsigned int version)
void inplace_union(const index_set &b)
void insert(size_type dis_i)
index_set & operator=(const index_set &x)
friend void set_intersection(const index_set &a, const index_set &b, index_set &c)
friend std::ostream & operator<<(std::ostream &os, const index_set &x)
friend void set_union(const index_set &a, const index_set &b, index_set &c)
index_set & operator+=(size_type dis_i)
This file is part of Rheolef.
size_t N