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
meshbase.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 
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 __MeshBase_H
30 #define __MeshBase_H 1
31 
32 #include <feel/feelcore/feel.hpp>
33 #include <feel/feelcore/context.hpp>
36 
37 namespace Feel
38 {
39 class SubMeshData;
40 
46 {
47  MESH_UPDATE_EDGES = ( 1 << 0 ),
48  MESH_UPDATE_FACES = ( 1 << 1 ),
49  MESH_CHECK = ( 1 << 2 ),
50  MESH_PARTITION = ( 1 << 3 ),
51  MESH_RENUMBER = ( 1 << 4 ),
52  MESH_ADD_ELEMENTS_INFO = ( 1 << 5 ),
53  MESH_PROPAGATE_MARKERS = ( 1 << 6 ),
54  MESH_REMOVE_PERIODIC_FACES_FROM_BOUNDARY = ( 1 << 7 )
55 
56 };
57 const uint16_type MESH_ALL_COMPONENTS = MESH_UPDATE_EDGES | MESH_UPDATE_FACES | MESH_CHECK | MESH_PARTITION | MESH_RENUMBER;
58 const uint16_type MESH_COMPONENTS_DEFAULTS = MESH_RENUMBER | MESH_CHECK;
59 
67 class MeshBase
68 {
69 public:
70 
71 
75 
83  typedef boost::tuple<size_type, size_type> face_processor_type;
84 
85 
86  typedef SubMeshData smd_type;
87  typedef boost::shared_ptr<smd_type> smd_ptrtype;
88 
90 
94 
98  MeshBase( WorldComm const& worldComm = Environment::worldComm() );
99 
103  MeshBase( MeshBase const& );
104 
108  virtual ~MeshBase();
109 
111 
115 
119  MeshBase& operator=( MeshBase const& m );
120 
122 
126 
131  bool isUpdatedForUse() const
132  {
133  return M_is_updated;
134  }
135 
139  virtual size_type numElements() const = 0;
140 
144  virtual size_type numFaces() const = 0;
145 
149  virtual size_type numPoints() const = 0;
150 
155  {
156  return M_n_vertices;
157  }
158 
162  uint16_type numberOfPartitions() const
163  {
164  return M_n_parts;
165  }
166 
170  bool isPartitioned() const;
171 
177  Context const& components() const
178  {
179  return M_components;
180  }
181 
188  {
189  return M_components;
190  }
191 
195  virtual double measure() const = 0;
196 
200  bool isParametric() const
201  {
202  return M_is_parametric;
203  }
204 
206 
210 
214  void setNumberOfPartitions( uint16_type n )
215  {
216  M_n_parts = n;
217  }
218 
223  {
224  M_n_vertices = n ;
225  }
226 
231  void setComponents( size_type components = MESH_ALL_COMPONENTS )
232  {
233  M_components = components;
234  }
235 
239  void setParametric( bool x )
240  {
241  M_is_parametric = x;
242  }
243 
245 
249 
254  virtual void clear();
255 
256 
260  virtual void updateForUse() = 0;
261 
266  virtual void updateForUse( size_type components );
267 
268 
272  virtual void partition ( const uint16_type n_parts ) = 0;
273 
277  WorldComm const& worldComm() const
278  {
279  return M_worldComm;
280  }
281 
282  virtual void setWorldComm( WorldComm const& _worldComm ) = 0;
283 
284  void setWorldCommMeshBase( WorldComm const& _worldComm )
285  {
286  M_worldComm = _worldComm;
287  }
288 
289  mpi::communicator const& comm() const
290  {
291  return M_worldComm.localComm();
292  }
293 
294  virtual void meshModified() = 0;
295 
297  void setSubMeshData( smd_ptrtype smd )
298  {
299  M_smd = smd;
300  }
301 
303  bool hasSubMeshData() const { return M_smd.use_count() > 0; }
304 
306  typename smd_type::mesh_ptrtype subMesh() const
307  {
308  CHECK( M_smd ) << "mesh doesn't have any submesh data\n";
309  return M_smd->mesh;
310  }
311 
313  bool isSubMeshFrom( MeshBase const* m ) const
314  {
315  DVLOG(4) << "isSubMeshFrom<mesh_ptrtype> called\n";
316  if ( !M_smd ) return false;
317  bool res= (M_smd->mesh.get() == m);
318  DVLOG(4) << "this isSubMeshFrom m: " << res << "\n";
319  return res;
320  }
322  bool isSubMeshFrom( boost::shared_ptr<MeshBase> m ) const
323  {
324  return isSubMeshFrom( m.get() );
325  }
326 
328  bool isParentMeshOf( boost::shared_ptr<MeshBase> m ) const
329  {
330  DVLOG(4) << "isParentMeshOf<mesh_ptrtype> called\n";
331  bool res = m->isSubMeshFrom( this );
332  if ( res == false ) return res;
333  DVLOG(4) << "this isParentMeshOf m: " << res << "\n";
334  return res;
335  }
336 #if 0
337  template<typename M>
338  bool isSubMeshFrom( boost::shared_ptr<M> m ) const
339  {
340  DVLOG(4) << "isSubMeshFrom<M> called\n";
341  return false;
342  }
343 #endif
344  template<typename M>
345  bool isSameMesh( M const* m ) const
346  {
347  bool same_mesh = ( dynamic_cast<void const*>( this ) == dynamic_cast<void const*>( m ) );
348  return same_mesh;
349  }
350 
351  template<typename M>
352  bool isSameMesh( boost::shared_ptr<M> m ) const
353  {
354  bool same_mesh = ( dynamic_cast<void const*>( this ) == dynamic_cast<void*>( m.get() ) );
355  return same_mesh;
356  }
357  template<typename M>
358  bool isRelatedTo( boost::shared_ptr<M> m ) const
359  {
360  bool same_mesh = isSameMesh(m);
361  DVLOG(4) << "same_mesh: " << same_mesh << "\n";
362  bool is_submesh_from = isSubMeshFrom( m );
363  DVLOG(4) << "isSubMeshFrom: " << is_submesh_from << "\n";
364  bool is_parentmesh_of = isParentMeshOf( m );
365  DVLOG(4) << "is_parentmesh_of: " << is_parentmesh_of << "\n";
366  return same_mesh || is_submesh_from || is_parentmesh_of;
367  }
368 
371  {
372  CHECK( M_smd ) << "mesh doesn't have any submesh data\n";
373  return M_smd->bm.left.find( id )->second;
374  }
375 
378  {
379  CHECK( M_smd ) << "mesh doesn't have any submesh data\n";
380  if ( M_smd->bm.right.find( id ) != M_smd->bm.right.end() )
381  return M_smd->bm.right.find( id )->second;
382  // the submesh element id has not been found, return invalid value
384  }
385 
387  size_type subMeshToMesh( boost::shared_ptr<MeshBase> m, size_type id ) const
388  {
389  if ( this == m.get() )
390  return id;
391  if ( isRelatedTo( m ) )
392  {
393  CHECK( M_smd ) << "mesh doesn't have any submesh data\n";
394  return M_smd->bm.left.find( id )->second;
395  }
397  }
398 
400  size_type meshToSubMesh( boost::shared_ptr<MeshBase> m, size_type id ) const
401  {
402  if ( this == m.get() )
403  return id;
404  if ( isRelatedTo( m ) )
405  {
406  CHECK( M_smd ) << "mesh doesn't have any submesh data\n";
407  if ( M_smd->bm.right.find( id ) != M_smd->bm.right.end() )
408  return M_smd->bm.right.find( id )->second;
409  // the submesh element id has not been found, return invalid value
410  // will return invalid_size_type_value
411  }
413  }
414 
416 
417 
418 
419 protected:
420 
424  void setUpdatedForUse( bool u )
425  {
426  M_is_updated = u;
427  }
428 
438  virtual void renumber() = 0;
439 
443  virtual void updateEntitiesCoDimensionOne() = 0;
444 
448  virtual void updateEntitiesCoDimensionTwo() = 0;
449 
453  virtual void check() const = 0;
454 
458  virtual void checkAndFixPermutation() = 0;
459 
460 
461 private:
462  friend class boost::serialization::access;
463  template<class Archive>
464  void serialize( Archive & ar, const unsigned int version )
465  {
466  ar & M_components;
467  ar & M_is_updated;
468  ar & M_is_parametric;
469  ar & M_n_vertices;
470  ar & M_n_parts;
471  }
472 private:
473 
477  Context M_components;
478 
482  bool M_is_updated;
483 
487  bool M_is_parametric;
488 
492  size_type M_n_vertices;
493 
503  uint16_type M_n_parts;
504 
505  WorldComm M_worldComm;
506 
507  // sub mesh data
508  smd_ptrtype M_smd;
509 
510 };
511 }
512 #endif /* __MeshBase_H */
size_type subMeshToMesh(size_type id) const
Definition: meshbase.hpp:370
virtual size_type numFaces() const =0
virtual size_type numElements() const =0
bool isPartitioned() const
Definition: meshbase.cpp:95
MeshBase & operator=(MeshBase const &m)
Definition: meshbase.cpp:60
base mesh class
Definition: meshbase.hpp:67
bool isParentMeshOf(boost::shared_ptr< MeshBase > m) const
Definition: meshbase.hpp:328
size_type meshToSubMesh(boost::shared_ptr< MeshBase > m, size_type id) const
Definition: meshbase.hpp:400
void setNumVertices(size_type n)
Definition: meshbase.hpp:222
void setUpdatedForUse(bool u)
Definition: meshbase.hpp:424
virtual void check() const =0
Context const & components() const
Definition: meshbase.hpp:177
boost::tuple< size_type, size_type > face_processor_type
Definition: meshbase.hpp:83
bool isParametric() const
Definition: meshbase.hpp:200
virtual void updateForUse()=0
size_type meshToSubMesh(size_type id) const
Definition: meshbase.hpp:377
size_type subMeshToMesh(boost::shared_ptr< MeshBase > m, size_type id) const
Definition: meshbase.hpp:387
virtual void partition(const uint16_type n_parts)=0
bool isSubMeshFrom(boost::shared_ptr< MeshBase > m) const
Definition: meshbase.hpp:322
void setNumberOfPartitions(uint16_type n)
Definition: meshbase.hpp:214
const size_type invalid_size_type_value
Definition: feelcore/feel.hpp:360
MeshComponents
Definition: meshbase.hpp:45
smd_type::mesh_ptrtype subMesh() const
Definition: meshbase.hpp:306
virtual ~MeshBase()
Definition: meshbase.cpp:56
MeshBase(WorldComm const &worldComm=Environment::worldComm())
Definition: meshbase.cpp:34
bool isSubMeshFrom(MeshBase const *m) const
Definition: meshbase.hpp:313
virtual void updateEntitiesCoDimensionTwo()=0
bool hasSubMeshData() const
Definition: meshbase.hpp:303
virtual void checkAndFixPermutation()=0
Context & components()
Definition: meshbase.hpp:187
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
data structure storing sub mesh data
Definition: submeshdata.hpp:45
virtual void updateEntitiesCoDimensionOne()=0
virtual void clear()
Definition: meshbase.cpp:76
bool isUpdatedForUse() const
Definition: meshbase.hpp:131
uint16_type numberOfPartitions() const
Definition: meshbase.hpp:162
void setComponents(size_type components=MESH_ALL_COMPONENTS)
Definition: meshbase.hpp:231
Context class.
Definition: feelcore/context.hpp:63
void setParametric(bool x)
Definition: meshbase.hpp:239
virtual void renumber()=0
virtual double measure() const =0
WorldComm const & worldComm() const
Definition: meshbase.hpp:277
void setSubMeshData(smd_ptrtype smd)
set sub mesh data
Definition: meshbase.hpp:297
virtual size_type numPoints() const =0
size_type numVertices() const
Definition: meshbase.hpp:154

Generated on Sun Dec 22 2013 13:11:07 for Feel++ by doxygen 1.8.5