Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
edges.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-09-03
7 
8  Copyright (C) 2005,2006 EPFL
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __edges_H
30 #define __edges_H 1
31 
32 
33 #include <boost/multi_index_container.hpp>
34 #include <boost/multi_index/member.hpp>
35 #include <boost/multi_index/mem_fun.hpp>
36 #include <boost/multi_index/ordered_index.hpp>
37 
38 #include <feel/feelmesh/geoelement.hpp>
39 
40 namespace Feel
41 {
42 namespace multi_index = boost::multi_index;
43 
45 
52 template<typename EdgeType,typename FaceType>
53 class Edges
54 {
55 public:
56 
57 
61 
62  typedef typename mpl::if_<mpl::equal_to<mpl::int_<EdgeType::nRealDim>, mpl::int_<3> >,
63  mpl::identity<GeoElement1D<3, EdgeType,SubFaceOfMany<FaceType> > >,
64  mpl::identity<boost::none_t> >::type::type edge_type;
65 
66 
67  typedef multi_index::multi_index_container<
68  edge_type,
69  multi_index::indexed_by<
70  // sort by employee::operator<
71  multi_index::ordered_unique<multi_index::identity<edge_type> >,
72  // sort by less<int> on marker
73  multi_index::ordered_non_unique<multi_index::tag<detail::by_marker>,
74  multi_index::const_mem_fun<edge_type,
75  Marker1 const&,
76  &edge_type::marker> >,
77 
78  // sort by less<int> on processId
79  multi_index::ordered_non_unique<multi_index::tag<detail::by_pid>,
80  multi_index::const_mem_fun<edge_type,
81  uint16_type,
82  &edge_type::processId> >,
83 
84  // sort by less<int> on boundary
85  multi_index::ordered_non_unique<multi_index::tag<detail::by_location>,
86  multi_index::const_mem_fun<edge_type,
87  bool,
88  &edge_type::isOnBoundary> >
89  >
90  > edges_type;
91 
92 
93  typedef typename edges_type::iterator edge_iterator;
94  typedef typename edges_type::const_iterator edge_const_iterator;
95  typedef typename edges_type::template index<detail::by_marker>::type marker_edges;
96 
97  typedef typename marker_edges::iterator marker_edge_iterator;
98  typedef typename marker_edges::const_iterator marker_edge_const_iterator;
99 
100  typedef typename edges_type::template index<detail::by_pid>::type pid_edges;
101  typedef typename pid_edges::iterator pid_edge_iterator;
102  typedef typename pid_edges::const_iterator pid_edge_const_iterator;
103 
104  typedef typename edges_type::template index<detail::by_location>::type location_edges;
105  typedef typename location_edges::iterator location_edge_iterator;
106  typedef typename location_edges::const_iterator location_edge_const_iterator;
107 
109 
113 
114  Edges( WorldComm const& worldComm = Environment::worldComm() )
115  :
116  M_worldCommEdges( worldComm ),
117  M_edges()
118  {}
119 
120  Edges( Edges const & f )
121  :
122  M_worldCommEdges( f.M_worldCommEdges ),
123  M_edges( f.M_edges )
124  {}
125 
126  ~Edges()
127  {}
128 
130 
134 
135 
137 
141 
145  edges_type & edges()
146  {
147  return M_edges;
148  }
149 
153  edges_type const& edges() const
154  {
155  return M_edges;
156  }
157 
161  WorldComm const& worldCommFaces() const
162  {
163  return M_worldCommEdges;
164  }
165 
169  bool isEmpty() const
170  {
171  return M_edges.empty();
172  }
173 
174  bool isBoundaryEdge( edge_type const & e ) const
175  {
176  return M_edges.find( e )->isOnBoundary();
177  }
178  bool isBoundaryEdge( size_type const & id ) const
179  {
180  return M_edges.find( edge_type( id ) )->isOnBoundary();
181  }
182 
183  edge_type const& edge( size_type i ) const
184  {
185  return *M_edges.find( edge_type( i ) );
186  }
187 
188  edge_iterator edgeIterator( size_type i ) const
189  {
190  return M_edges.find( edge_type( i ) );
191  }
192 
193  edge_iterator beginEdge()
194  {
195  return M_edges.begin();
196  }
197  edge_const_iterator beginEdge() const
198  {
199  return M_edges.begin();
200  }
201  edge_iterator endEdge()
202  {
203  return M_edges.end();
204  }
205  edge_const_iterator endEdge() const
206  {
207  return M_edges.end();
208  }
209 
214  std::pair<marker_edge_iterator, marker_edge_iterator>
215  edgesWithMarker( size_type m, size_type p ) const
216  {
217  //return M_edges.template get<detail::by_marker>().equal_range( boost::make_tuple( Marker1( m ), p ) );
218  return M_edges.template get<detail::by_marker>().equal_range( Marker1( m ) );
219  }
220 
221 
222  marker_edge_iterator beginEdgeWithMarker( size_type m )
223  {
224  return M_edges.template get<detail::by_marker>().lower_bound( Marker1( m ) );
225  }
226  marker_edge_const_iterator beginEdgeWithMarker( size_type m ) const
227  {
228  return M_edges.template get<detail::by_marker>().lower_bound( Marker1( m ) );
229  }
230  marker_edge_iterator endEdgeWithMarker( size_type m )
231  {
232  return M_edges.template get<detail::by_marker>().upper_bound( Marker1( m ) );
233  }
234  marker_edge_const_iterator endEdgeWithMarker( size_type m ) const
235  {
236  return M_edges.template get<detail::by_marker>().upper_bound( Marker1( m ) );
237  }
238 
245  typename edges_type::template nth_index<0>::type &
246  edgesById()
247  {
248  return M_edges.template get<0>();
249  }
250 
257  typename edges_type::template nth_index<0>::type const&
258  edgesById() const
259  {
260  return M_edges.template get<0>();
261  }
262 
269  marker_edges &
270  edgesByMarker()
271  {
272  return M_edges.template get<detail::by_marker>();
273  }
274 
281  marker_edges const&
282  edgesByMarker() const
283  {
284  return M_edges.template get<detail::by_marker>();
285  }
292  location_edges &
293  edgesByLocation()
294  {
295  return M_edges.template get<detail::by_location>();
296  }
297 
304  location_edges const&
305  edgesByLocation() const
306  {
307  return M_edges.template get<detail::by_location>();
308  }
309 
315  location_edge_iterator beginInternalEdge()
316  {
317  return M_edges.template get<detail::by_location>().lower_bound( INTERNAL );
318  }
324  location_edge_iterator endInternalEdge()
325  {
326  return M_edges.template get<detail::by_location>().upper_bound( INTERNAL );
327  }
328 
334  location_edge_const_iterator beginInternalEdge() const
335  {
336  return M_edges.template get<detail::by_location>().lower_bound( INTERNAL );
337  }
338 
344  location_edge_const_iterator endInternalEdge() const
345  {
346  return M_edges.template get<detail::by_location>().upper_bound( INTERNAL );
347  }
348 
354  location_edge_iterator beginEdgeOnBoundary()
355  {
356  return M_edges.template get<detail::by_location>().lower_bound( ON_BOUNDARY );
357  }
363  location_edge_iterator endEdgeOnBoundary()
364  {
365  return M_edges.template get<detail::by_location>().upper_bound( ON_BOUNDARY );
366  }
367 
373  location_edge_const_iterator beginEdgeOnBoundary() const
374  {
375  return M_edges.template get<detail::by_location>().lower_bound( ON_BOUNDARY );
376  }
377 
383  location_edge_const_iterator endEdgeOnBoundary() const
384  {
385  return M_edges.template get<detail::by_location>().upper_bound( ON_BOUNDARY );
386  }
387 
392  std::pair<pid_edge_iterator, pid_edge_iterator>
393  edgesWithProcessId( size_type p ) const
394  {
395  return M_edges.template get<detail::by_pid>().equal_range( p );
396  }
397 
399 
403 
404 
406 
410 
416  edge_type const& addEdge( edge_type& f )
417  {
418  f.setId( M_edges.size() );
419  return *M_edges.insert( f ).first;
420  }
421 
422  void setWorldCommEdges( WorldComm const& _worldComm )
423  {
424  M_worldCommEdges = _worldComm;
425  }
426 
428 
429 private:
430 
431  friend class boost::serialization::access;
432  template<class Archive>
433  void serialize( Archive & ar, const unsigned int version )
434  {
435  ar & M_edges;
436  }
437 
438 private:
439  WorldComm M_worldCommEdges;
440  edges_type M_edges;
441 };
443 } // Feel
444 #endif /* __edges_H */

Generated on Sun Oct 20 2013 08:24:56 for Feel++ by doxygen 1.8.4