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
geoentity.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-08-10
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 __GeoEntity_H
30 #define __GeoEntity_H 1
31 
35 
36 namespace Feel
37 {
38 
46 template<typename Entity>
47 class GeoEntity
48  :
49  boost::equality_comparable<GeoEntity<Entity> >,
50  boost::less_than_comparable<GeoEntity<Entity> >,
51  boost::less_than_comparable<GeoEntity<Entity>, size_type>,
52 public Entity
53 
54 {
55 public:
56 
57 
61 
62  typedef Entity super;
65  typedef typename super::topological_face_type face_type;
66  typedef face_type GeoBShape;
67  typedef typename Entity::edge_permutation_type edge_permutation_type;
68  typedef typename Entity::face_permutation_type face_permutation_type;
69 
70  static const size_type Shape = super::Shape;
71  static const size_type Geometry = super::Geometry;
72 
73  static const uint16_type nDim = super::nDim;
74  static const uint16_type nOrder = super::nOrder;
75  static const uint16_type nRealDim = super::nRealDim;
76 
77 
78  static const uint16_type numVertices = super::numVertices;
79  static const uint16_type numFaces = super::numFaces;
80  static const uint16_type numGeometricFaces = super::numGeometricFaces;
81  static const uint16_type numTopologicalFaces = super::numTopologicalFaces;
82  static const uint16_type numEdges = super::numEdges;
83  static const uint16_type numNormals = super::numNormals;
84 
85  static const uint16_type numPoints = super::numPoints;
86  static const uint16_type nbPtsPerVertex = super::nbPtsPerVertex;
87  static const uint16_type nbPtsPerEdge = super::nbPtsPerEdge;
88  static const uint16_type nbPtsPerFace = super::nbPtsPerFace;
89  static const uint16_type nbPtsPerVolume = super::nbPtsPerVolume;
90 
91  typedef Entity convex_type;
92 
93  static const bool is_simplex = super::is_simplex;
94  static const bool is_hypercube = super::is_hypercube;
95 
99  template<typename T = double>
101  {
103  };
105 
109 
110  GeoEntity()
111  :
112  super(),
113  M_id( 0 ),
114  M_entity( MESH_ENTITY_INTERNAL ),
115  M_geometry( Geometry ),
116  M_shape( Shape ),
117  M_boundaryEntityDimension( invalid_uint16_type_value ),
118  M_npids( 1 ),
119  M_pid( 0 ),
120  M_pidInPartition( 0 ),
121  M_neighor_pids(),
122  M_idInOthersPartitions(),
123  M_elist()
124  {}
125 
126  explicit GeoEntity( size_type i,
127  size_type geometry = Geometry,
128  size_type shape = Shape,
129  size_type context = MESH_ENTITY_INTERNAL )
130  :
131  super(),
132  M_id( i ),
133  M_entity( context ),
134  M_geometry( geometry ),
135  M_shape( shape ),
136  M_boundaryEntityDimension( invalid_uint16_type_value ),
137  M_npids( 1 ),
138  M_pid( 0 ),
139  M_pidInPartition( 0 ),
140  M_neighor_pids(),
141  M_idInOthersPartitions(),
142  M_elist()
143  {}
144 
145  GeoEntity( GeoEntity const& __me )
146  :
147  super(),
148  M_id( __me.M_id ),
149  M_entity( __me.M_entity ),
150  M_geometry( __me.M_geometry ),
151  M_shape( __me.M_shape ),
152  M_boundaryEntityDimension( __me.M_boundaryEntityDimension ),
153  M_npids( __me.M_npids ),
154  M_pid( __me.M_pid ),
155  M_pidInPartition( __me.M_pidInPartition ),
156  M_neighor_pids( __me.M_neighor_pids ),
157  M_idInOthersPartitions( __me.M_idInOthersPartitions ),
158  M_elist( __me.M_elist )
159  {}
160 
161  GeoEntity& operator=( GeoEntity const& __me )
162  {
163  if ( this != &__me )
164  {
165  M_id = __me.M_id;
166  M_entity = __me.M_entity;
167  M_geometry = __me.M_geometry;
168  M_shape = __me.M_shape;
169  M_boundaryEntityDimension = __me.M_boundaryEntityDimension;
170  M_npids = __me.M_npids;
171  M_pid = __me.M_pid;
172  M_pidInPartition = __me.M_pidInPartition;
173  M_neighor_pids = __me.M_neighor_pids;
174  M_idInOthersPartitions = __me.M_idInOthersPartitions;
175  M_elist = __me.M_elist;
176  }
177 
178  return *this;
179  }
180 
181  virtual ~GeoEntity()
182  {}
183 
185 
189  bool operator==( GeoEntity const& e ) const
190  {
191  return M_id == e.id();
192  }
193  bool operator<( GeoEntity const& e ) const
194  {
195  return M_id < e.id();
196  }
197 
198  bool operator<( size_type __i ) const
199  {
200  return M_id < __i;
201  }
202 
204 
208 
209  size_type id() const
210  {
211  return M_id;
212  }
213 
214 
221  uint16_type refDim() const
222  {
223  return super::nDim;
224  }
225 
231  uint16_type nPoints() const
232  {
233  return super::numPoints;
234  }
235 
241  uint16_type nVertices() const
242  {
243  return super::numVertices;
244  }
245 
251  uint16_type nEdges() const
252  {
253  return super::numEdges;
254  }
255 
261  uint16_type nFaces() const
262  {
263  return super::numFaces;
264  }
265 
271  constexpr uint16_type nTopologicalFaces() const
272  {
273  return super::numTopologicalFaces;
274  }
275 
281  uint16_type nGeometricFaces() const
282  {
283  return super::numGeometricFaces;
284  }
285 
291  uint16_type nNormals() const
292  {
293  return super::numNormals;
294  }
295 
296 
303  bool hasShape( size_type __shape ) const
304  {
305  return M_shape.test( __shape );
306  }
307 
311  bool isAVolume() const
312  {
313  return M_geometry.test( GEOMETRY_VOLUME );
314  }
315 
319  bool isASurface() const
320  {
321  return M_geometry.test( GEOMETRY_SURFACE );
322  }
323 
327  bool isALine() const
328  {
329  return M_geometry.test( GEOMETRY_LINE );
330  }
331 
335  bool isAPoint() const
336  {
337  return M_geometry.test( GEOMETRY_POINT );
338  }
339 
343  bool isAPointShape() const
344  {
345  return M_shape.test( SHAPE_POINT );
346  }
347 
351  bool isALineShape() const
352  {
353  return M_shape.test( SHAPE_LINE );
354  }
355 
359  bool isATriangleShape() const
360  {
361  return M_shape.test( SHAPE_TRIANGLE );
362  }
363 
367  bool isAQuadrangleShape() const
368  {
369  return M_shape.test( SHAPE_QUAD );
370  }
371 
375  bool isATetrahedraShape() const
376  {
377  return M_shape.test( SHAPE_TETRA );
378  }
379 
383  bool isAHexahedraShape() const
384  {
385  return M_shape.test( SHAPE_HEXA );
386  }
387 
391  bool isLinear() const
392  {
393  return M_shape.test( SHAPE_LINEAR );
394  }
395 
399  bool isBilinear() const
400  {
401  return M_shape.test( SHAPE_BILINEAR );
402  }
403 
407  bool isQuadratic() const
408  {
409  return M_shape.test( SHAPE_QUADRATIC );
410  }
411 
415  bool isInternal() const
416  {
417  return M_entity.test( MESH_ENTITY_INTERNAL );
418  }
419 
420 
425  bool isOnBoundary() const
426  {
427  return M_entity.test( MESH_ENTITY_BOUNDARY );
428  }
429 
433  uint16_type boundaryEntityDimension() const
434  {
435  return M_boundaryEntityDimension;
436  }
440  bool isGhostCell() const
441  {
442  //return (this->worldComm().localRank()!=M_pid);
443  //mpi::communicator world;
444  //return (world.rank()!=M_pid);
445  return ( M_pidInPartition!=M_pid );
446  }
447 
451  uint16_type processId() const
452  {
453  return M_pid;
454  }
455 
460  void setProcessId( uint16_type pid )
461  {
462  M_pid = pid ;
463  }
464 
468  uint16_type pidInPartition() const
469  {
470  return M_pidInPartition;
471  }
476  void setProcessIdInPartition( uint16_type pid )
477  {
478  M_pidInPartition = pid ;
479  }
480 
484  uint16_type partitionId() const
485  {
486  return M_pid;
487  }
488 
493  uint16_type numberOfPartitions() const
494  {
495  return M_npids;
496  }
497 
502  {
503  return M_neighor_pids.size();
504  }
505 
511  {
512  return M_neighor_pids.size() > 0;
513  }
514 
518  std::vector<int> const& neighborPartitionIds() const
519  {
520  return M_neighor_pids;
521  }
525  std::vector<int> & neighborPartitionIds()
526  {
527  return M_neighor_pids;
528  }
529 
533  void setIdInOthersPartitions( uint16_type pid, size_type id )
534  {
535  M_idInOthersPartitions.insert( std::make_pair( pid, id ) );
536  }
537 
541  size_type idInOthersPartitions( uint16_type pid ) const
542  {
543  return M_idInOthersPartitions.find( pid )->second;
544  }
545 
549  std::map<uint16_type, size_type> const& idInOthersPartitions() const
550  {
551  return M_idInOthersPartitions;
552  }
553 
557  std::map<uint16_type, size_type> & idInOthersPartitions()
558  {
559  return M_idInOthersPartitions;
560  }
561 
568  bool active() const
569  {
570  return true;
571  }
572 
576  virtual double measure() const = 0;
577 
579 
583  void setId( size_type id )
584  {
585  M_id = id;
586  }
587 
592  void setOnBoundary( bool b, uint16_type ent_d = invalid_uint16_type_value )
593  {
594  if ( b )
595  {
596  M_entity.set( MESH_ENTITY_BOUNDARY );
597  M_entity.clear( MESH_ENTITY_INTERNAL );
598  }
599  else
600  {
601  M_entity.clear( MESH_ENTITY_BOUNDARY );
602  M_entity.set( MESH_ENTITY_INTERNAL );
603  }
604  M_boundaryEntityDimension = ent_d;
605  }
606 
611  void setNumberOfPartitions( uint16_type np )
612  {
613  M_npids = np;
614  }
615 
619  void setNumberOfNeighborPartitions( uint16_type nep )
620  {
621  FEELPP_ASSERT( M_npids -1 == M_neighor_pids.size() )( M_npids )( M_neighor_pids ).error( "invalid partitioning data" );
622  M_neighor_pids.size();
623  }
624 
628  void setNeighborPartitionIds( std::vector<int> const& npids )
629  {
630  M_neighor_pids = npids;
631  }
632 
634 
638 
642  static uint16_type eToP( uint16_type const __localEdge, uint16_type const __point )
643  {
644  return super::e2p( __localEdge, __point );
645  }
646 
650  static uint16_type fToP( uint16_type const __localFace, uint16_type const __point )
651  {
652  return super::f2p( __localFace, __point );
653  }
654 
658  static uint16_type fToE( uint16_type const __localFace, uint16_type const __edge )
659  {
660  return super::f2e( __localFace, __edge );
661  }
662 
667  {
668  M_elist.insert( e );
669  return *this;
670  }
671 
676  {
677  return M_elist.size();
678  }
679 
683  std::set<size_type> const& elements() const
684  {
685  return M_elist;
686  }
687  std::set<size_type>& elements()
688  {
689  return M_elist;
690  }
691 
692 
697  {
698  M_elistGhost.insert( boost::make_tuple( proc,e ) );
699  return *this;
700  }
701 
706  {
707  return M_elistGhost.size();
708  }
709 
713  std::set<boost::tuple<int,size_type> > const& elementsGhost() const
714  {
715  return M_elistGhost;
716  }
717  std::set<boost::tuple<int,size_type> >& elementsGhost()
718  {
719  return M_elistGhost;
720  }
721 
723 
724 
725 
726 protected:
727 
728 private:
729 
730  friend class boost::serialization::access;
731  template<class Archive>
732  void serialize( Archive & ar, const unsigned int version )
733  {
734  DVLOG(2) << "Serializing GeoEntity...\n";
735  DVLOG(2) << " - id...\n";
736  ar & M_id;
737  DVLOG(2) << " - id:" << M_id << "\n";
738  DVLOG(2) << " - entity...\n";
739  ar & M_entity;
740  DVLOG(2) << " - entity:" << M_entity.context() << "\n";
741  DVLOG(2) << " - geometry...\n";
742  ar & M_geometry;
743  DVLOG(2) << " - geometry:" << M_geometry.context() << "\n";
744  DVLOG(2) << " - shape...\n";
745  ar & M_shape;
746  DVLOG(2) << " - shape:" << M_shape.context() << "\n";
747  DVLOG(2) << " - npids...\n";
748  ar & M_npids;
749  DVLOG(2) << " - npids:" << M_npids << "\n";
750  DVLOG(2) << " - pid...\n";
751  ar & M_pid;
752  DVLOG(2) << " - pid:" << M_pid << "\n";
753  ar & M_pidInPartition;
754  ar & M_neighor_pids;
755  ar & M_idInOthersPartitions;
756  }
757 
758 private:
759 
760 
761  size_type M_id;
762 
763  Context M_entity;
764  Context M_geometry;
765  Context M_shape;
766 
768  uint16_type M_boundaryEntityDimension;
769 
770  uint16_type M_npids;
771  uint16_type M_pid;
772  uint16_type M_pidInPartition;
773  std::vector<int> M_neighor_pids;
774  std::map<uint16_type, size_type> M_idInOthersPartitions;
775 
777  std::set<size_type> M_elist;
779  std::set<boost::tuple<int,size_type> > M_elistGhost;
780 
781 };
782 
783 typedef GeoEntity<Simplex<0, 1> > GeoPoint;
784 
785 // simplices
786 typedef GeoEntity<Simplex<1, 1> > LinearLine;
787 typedef GeoEntity<Simplex<2, 1> > LinearTriangle;
788 typedef GeoEntity<Simplex<3, 1> > LinearTetra;
789 typedef GeoEntity<Simplex<1, 2> > QuadraticLine;
790 typedef GeoEntity<Simplex<2, 2> > QuadraticTriangle;
791 typedef GeoEntity<Simplex<3, 2> > QuadraticTetra;
792 
793 // tensor products
794 typedef GeoEntity<Hypercube<2, 1> > LinearQuad;
795 typedef GeoEntity<Hypercube<3, 1> > LinearHexa;
796 typedef GeoEntity<Hypercube<2, 2> > QuadraticQuad;
797 typedef GeoEntity<Hypercube<3, 2> > QuadraticHexa;
798 
799 } // Feel
800 
801 #endif /* __GeoEntity_H */

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