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
points.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 __points_H
30 #define __points_H 1
31 
32 #include <boost/multi_index_container.hpp>
33 #include <boost/multi_index/member.hpp>
34 #include <boost/multi_index/mem_fun.hpp>
35 #include <boost/multi_index/ordered_index.hpp>
36 
37 #include <feel/feelmesh/geoelement.hpp>
38 
39 namespace Feel
40 {
41 namespace multi_index = boost::multi_index;
42 
44 
51 template<uint16_type nDim>
52 class Points
53 {
54 public:
55 
56 
60 
61  typedef GeoElement0D<nDim> point_type;
62  typedef multi_index::multi_index_container<
63  point_type,
64  multi_index::indexed_by<
65  // sort by employee::operator<
66  multi_index::ordered_unique<multi_index::identity<point_type> >,
67  // sort by less<int> on marker
68  multi_index::ordered_non_unique<multi_index::tag<detail::by_marker>,
69  multi_index::const_mem_fun<point_type,
70  Marker1 const&,
71  &point_type::marker> >,
72 
73  // sort by less<int> on processId
74  multi_index::ordered_non_unique<multi_index::tag<detail::by_pid>,
75  multi_index::const_mem_fun<point_type,
76  uint16_type,
77  &point_type::processId> >,
78 
79  // sort by less<int> on boundary
80  multi_index::ordered_non_unique<multi_index::tag<detail::by_location>,
81  multi_index::const_mem_fun<point_type,
82  bool,
83  &point_type::isOnBoundary> >
84  >
85  > points_type;
86 
87 
88  typedef typename points_type::iterator point_iterator;
89  typedef typename points_type::const_iterator point_const_iterator;
90 
91  typedef typename points_type::template index<detail::by_marker>::type marker_points;
92  typedef typename marker_points::iterator marker_point_iterator;
93  typedef typename marker_points::const_iterator marker_point_const_iterator;
94 
95  typedef typename points_type::template index<detail::by_pid>::type pid_points;
96  typedef typename pid_points::iterator pid_point_iterator;
97  typedef typename pid_points::const_iterator pid_point_const_iterator;
98 
99  typedef typename points_type::template index<detail::by_location>::type location_points;
100  typedef typename location_points::iterator location_point_iterator;
101  typedef typename location_points::const_iterator location_point_const_iterator;
102 
103 
104 
106 
110 
111  Points( WorldComm const& worldComm = Environment::worldComm() )
112  :
113  M_worldCommPoints( worldComm ),
114  M_points()
115  {}
116 
117  Points( Points const & f )
118  :
119  M_worldCommPoints( f.M_worldCommPoints ),
120  M_points( f.M_points )
121  {}
122 
123  virtual ~Points()
124  {}
125 
127 
131 
132  Points& operator=( Points const& e )
133  {
134  if ( this != &e )
135  {
136  M_worldCommPoints = e.M_worldCommPoints;
137  M_points = e.M_points;
138  }
139 
140  return *this;
141  }
142 
144 
148 
152  points_type & points()
153  {
154  return M_points;
155  }
156 
160  points_type const& points() const
161  {
162  return M_points;
163  }
164 
165 
166  virtual bool isEmpty() const
167  {
168  return M_points.empty();
169  }
170  bool isBoundaryPoint( point_type const & e ) const
171  {
172  return M_points.find( e )->isOnBoundary();
173  }
174  bool isBoundaryPoint( size_type const & id ) const
175  {
176  return M_points.find( point_type( id ) )->isOnBoundary();
177  }
178 
179 
180  point_type const& point( size_type i ) const
181  {
182  return *M_points.find( point_type( i ) );
183  };
184 
185  point_iterator beginPoint()
186  {
187  return M_points.begin();
188  }
189  point_const_iterator beginPoint() const
190  {
191  return M_points.begin();
192  }
193  point_iterator endPoint()
194  {
195  return M_points.end();
196  }
197  point_const_iterator endPoint() const
198  {
199  return M_points.end();
200  }
201 
202 
203  marker_point_iterator beginPointWithMarker( size_type m )
204  {
205  return M_points.template get<detail::by_marker>().lower_bound( Marker1(m) );
206  }
207  marker_point_const_iterator beginPointWithMarker( size_type m ) const
208  {
209  return M_points.template get<detail::by_marker>().lower_bound( Marker1(m) );
210  }
211  marker_point_iterator endPointWithMarker( size_type m )
212  {
213  return M_points.template get<detail::by_marker>().upper_bound( Marker1(m) );
214  }
215  marker_point_const_iterator endPointWithMarker( size_type m ) const
216  {
217  return M_points.template get<detail::by_marker>().upper_bound( Marker1(m) );
218  }
219 
220  point_iterator pointIterator( size_type i ) const
221  {
222  return M_points.find( point_type( i ) );
223  }
224 
225  bool hasPoint( size_type i ) const
226  {
227  return M_points.find( point_type( i ) ) != M_points.end();
228  }
235  typename points_type::template nth_index<0>::type &
236  pointsById()
237  {
238  return M_points.template get<0>();
239  }
240 
247  typename points_type::template nth_index<0>::type const&
248  pointsById() const
249  {
250  return M_points.template get<0>();
251  }
252 
259  marker_points &
260  pointsByMarker()
261  {
262  return M_points.template get<detail::by_marker>();
263  }
264 
271  marker_points const&
272  pointsByMarker() const
273  {
274  return M_points.template get<detail::by_marker>();
275  }
282  location_points &
283  pointsByLocation()
284  {
285  return M_points.template get<detail::by_location>();
286  }
287 
294  location_points const&
295  pointsByLocation() const
296  {
297  return M_points.template get<detail::by_location>();
298  }
299 
305  location_point_iterator beginInternalPoint()
306  {
307  return M_points.template get<detail::by_location>().lower_bound( INTERNAL );
308  }
314  location_point_iterator endInternalPoint()
315  {
316  return M_points.template get<detail::by_location>().upper_bound( INTERNAL );
317  }
318 
324  location_point_const_iterator beginInternalPoint() const
325  {
326  return M_points.template get<detail::by_location>().lower_bound( INTERNAL );
327  }
328 
334  location_point_const_iterator endInternalPoint() const
335  {
336  return M_points.template get<detail::by_location>().upper_bound( INTERNAL );
337  }
338 
344  location_point_iterator beginPointOnBoundary()
345  {
346  return M_points.template get<detail::by_location>().lower_bound( ON_BOUNDARY );
347  }
353  location_point_iterator endPointOnBoundary()
354  {
355  return M_points.template get<detail::by_location>().upper_bound( ON_BOUNDARY );
356  }
357 
363  location_point_const_iterator beginPointOnBoundary() const
364  {
365  return M_points.template get<detail::by_location>().lower_bound( ON_BOUNDARY );
366  }
367 
373  location_point_const_iterator endPointOnBoundary() const
374  {
375  return M_points.template get<detail::by_location>().upper_bound( ON_BOUNDARY );
376  }
377 
378 
379  std::pair<pid_point_iterator, pid_point_iterator>
380  pointsWithProcessId( size_type p ) const
381  {
382  return M_points.template get<detail::by_pid>().equal_range( p );
383  }
384 
386 
390 
391 
393 
397 
403  point_type const& addPoint( point_type const& f )
404  {
405  return *M_points.insert( f ).first;
406  }
407 
408  WorldComm const& worldCommPoints() const
409  {
410  return M_worldCommPoints;
411  }
412 
413  void setWorldCommPoints( WorldComm const& _worldComm )
414  {
415  M_worldCommPoints = _worldComm;
416  }
417 
419 
420 private:
421 
422  friend class boost::serialization::access;
423  template<class Archive>
424  void serialize( Archive & ar, const unsigned int version )
425  {
426  ar & M_points;
427  }
428 
429 private:
430  WorldComm M_worldCommPoints;
431 
432  points_type M_points;
433 };
435 } // Feel
436 #endif /* __points_H */

Generated on Fri Oct 25 2013 14:24:22 for Feel++ by doxygen 1.8.4