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
mesh2d.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-11-09
7 
8  Copyright (C) 2005,2006 EPFL
9  Copyright (C) 2007 Université Joseph Fourier (Grenoble I)
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __Mesh2D_H
31 #define __Mesh2D_H 1
32 
33 
34 #include <iomanip>
35 #include <fstream>
36 #include <cstdlib>
37 
38 #include <boost/archive/binary_iarchive.hpp>
39 #include <boost/archive/binary_oarchive.hpp>
40 #include <boost/timer.hpp>
41 
42 #include <boost/shared_ptr.hpp>
43 #include <boost/foreach.hpp>
44 #include <boost/multi_array.hpp>
45 #include <boost/multi_index_container.hpp>
46 #include <boost/multi_index/member.hpp>
47 #include <boost/multi_index/mem_fun.hpp>
48 #include <boost/multi_index/ordered_index.hpp>
49 #include <boost/numeric/ublas/io.hpp>
50 #include <boost/mpl/print.hpp>
51 
52 
53 
54 #include <feel/feelcore/feel.hpp>
56 
58 
59 #include <feel/feelmesh/geoelement.hpp>
60 
62 #include <feel/feelmesh/faces.hpp>
63 #include <feel/feelmesh/points.hpp>
65 
66 namespace Feel
67 {
83 template<typename Shape>
84 class Mesh2D
85  :
86  public VisitableBase<>,
87  public MeshBase,
88  public Elements<Shape>,
89  public Points<Shape::nRealDim>,
90  public Faces<typename Shape::template shape<1,Shape::nOrder,Shape::nRealDim>::type,
91  typename Elements<Shape>::element_type>
92 {
93  // check at compilation time that the shape has indeed dimension 2
94  BOOST_STATIC_ASSERT( Shape::nDim == 2 );
95 
96 public:
97 
98 
102 
103  static const uint16_type nDim = Shape::nRealDim;
104 
105  typedef typename VisitableBase<>::return_type return_type;
106 
107  typedef VisitableBase<> super_visitable;
108  typedef MeshBase super;
109 
110  typedef Elements<Shape> super_elements;
111  typedef typename super_elements::elements_type elements_type;
112  typedef typename super_elements::element_type element_type;
113  typedef typename super_elements::element_iterator element_iterator;
114  typedef typename super_elements::element_const_iterator element_const_iterator;
115  typedef typename super_elements::update_element_neighbor_type update_element_neighbor_type;
116 
117  typedef Points<Shape::nRealDim> super_points;
118  typedef typename super_points::points_type points_type;
119  typedef typename super_points::point_type point_type;
120 
121  typedef Faces<typename Shape::template shape<1,Shape::nOrder,Shape::nRealDim>::type,
122  typename super_elements::element_type> super_faces;
123  typedef typename super_faces::face_iterator face_iterator;
124  typedef typename super_faces::faces_type faces_type;
125  typedef typename super_faces::face_type face_type;
126  typedef face_type edge_type;
127 
128  typedef super_faces super_edges;
129  typedef typename super_edges::marker_face_iterator marker_edge_iterator;
130  typedef typename super_edges::marker_face_const_iterator marker_edge_const_iterator;
131  typedef typename super_edges::location_face_iterator location_edge_iterator;
132  typedef typename super_edges::location_face_const_iterator location_edge_const_iterator;
133 
134  typedef Mesh2D<Shape> self_type;
135  typedef boost::shared_ptr<self_type> self_ptrtype;
136 
137  typedef typename element_type::edge_permutation_type edge_permutation_type;
138  typedef typename element_type::face_permutation_type face_permutation_type;
139 
140  typedef typename super::face_processor_type face_processor_type;
142 
146 
150  Mesh2D( WorldComm const& worldComm = Environment::worldComm() )
151  :
152  super_visitable(),
153  super( worldComm ),
154  super_elements( worldComm ),
155  super_points( worldComm ),
156  super_faces( worldComm )
157  {
158  DVLOG(2) << "[Mesh2D] constructor...\n";
159  }
160 
164  Mesh2D( Mesh2D const & m )
165  :
166  super_visitable(),
167  super( m ),
168  super_elements( m ),
169  super_points( m ),
170  super_faces( m )
171  {}
172 
176  ~Mesh2D() {}
177 
179 
183 
184  Mesh2D& operator=( Mesh2D const& m )
185  {
186  if ( this != &m )
187  {
188  super::operator=( m );
192  }
193 
194  return *this;
195  }
196 
197 
199 
203 
207  bool isEmpty() const
208  {
209  return ( super_elements::isEmpty() &&
212  }
213 
214 
219  {
220  return this->elements().size();
221  }
222 
228  {
229  return super_elements::element_type::numLocalEdges;
230  }
231 
237  {
238  return super_elements::element_type::numLocalEdges;
239  }
240 
245  {
246  return super_elements::element_type::numLocalVertices;
247  }
248 
253  {
254  return this->faces().size();
255  }
256 
261  {
262  return this->faces().size();
263  }
264 
265 
270  {
271  return this->points().size();
272  }
273 
275 
279 
280 
282 
286 
287  face_iterator beginEdge() { return this->beginFace(); }
288  face_iterator endEdge() { return this->endFace(); }
289  faces_type edges() { return this->faces(); }
290 
291  void setWorldComm( WorldComm const& _worldComm )
292  {
293  this->setWorldCommMeshBase( _worldComm );
294  this->setWorldCommElements( _worldComm );
295  this->setWorldCommFaces( _worldComm );
296  this->setWorldCommPoints( _worldComm );
297  }
298 
299 
304  virtual void clear()
305  {
306  this->elements().clear();
307  this->points().clear();
308  this->faces().clear();
309  FEELPP_ASSERT( isEmpty() ).error( "all mesh containers should be empty after a clear." );
310  }
311 
312 
313 
314  FEELPP_DEFINE_VISITABLE();
316 
317 
318 
319 protected:
320 
325  void renumber()
326  {
327  FEELPP_ASSERT( 0 ).error( "invalid call" );
328  }
329 
335  {
336  updateEntitiesCoDimensionOnePermutation( mpl::bool_<Shape::nDim==Shape::nRealDim>() );
337  }
338 
339  void
340  updateEntitiesCoDimensionOnePermutation( mpl::bool_<false> )
341  {}
342 
343  void updateEntitiesCoDimensionOnePermutation( mpl::bool_<true> )
344  {
345  for ( typename super_elements::element_iterator elt = this->beginElement();
346  elt != this->endElement(); ++elt )
347  {
348  for ( uint16_type j = 0; j < element_type::numEdges; j++ )
349  {
350  if ( elt->face( j ).isConnectedTo1() &&
351  elt->face( j ).ad_second() == elt->id() )
352  {
353  this->elements().modify( elt,
354  detail::UpdateEdgePermutation<edge_permutation_type>( elt->face( j ).pos_second(),
355  edge_permutation_type( edge_permutation_type::REVERSE_PERMUTATION ) ) );
356  }
357  }
358  }
359  }
360 
361 
366  {
367  // no-op
368  }
369 
370 
371 private:
372 
373  friend class boost::serialization::access;
374  template<class Archive>
375  void serialize( Archive & ar, const unsigned int version )
376  {
377  ar & boost::serialization::base_object<super>( *this );
378  DVLOG(2) << "Serializing points\n";
379  std::string str;
380  str = "points";
381  ar & str;
382  ar & boost::serialization::base_object<super_points>( *this );
383 #if 1
384  str = "faces";
385  ar & str;
386  DVLOG(2) << "Serializing faces\n";
387  ar & boost::serialization::base_object<super_faces>( *this );
388 #endif
389  str = "elements";
390  ar & str;
391  DVLOG(2) << "Serializing elements\n";
392  ar & boost::serialization::base_object<super_elements>( *this );
393  }
394 
395 
396 
397 };
398 
399 } // Feel
400 
401 #endif /* __Mesh2D_H */

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