dune-foamgrid  2.7-git
foamgrid.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set ts=8 sw=4 et sts=4:
3 #ifndef DUNE_FOAMGRID_HH
4 #define DUNE_FOAMGRID_HH
5 
10 #include <array>
11 #include <list>
12 #include <set>
13 #include <map>
14 #include <tuple>
15 #include <utility>
16 #include <type_traits>
17 
18 
19 #include <dune/common/version.hh>
20 #if DUNE_VERSION_LT(DUNE_COMMON,2,7)
21 #include <dune/common/parallel/collectivecommunication.hh>
22 #else
23 #include <dune/common/parallel/communication.hh>
24 #endif
25 
26 #include <dune/common/stdstreams.hh>
27 #include <dune/grid/common/capabilities.hh>
28 #include <dune/grid/common/grid.hh>
29 
30 // Implementation classes
32 #include "foamgrid/foamgridedge.hh"
34 
35 // The components of the FoamGrid interface
44 
45 namespace Dune {
46 
47 // Forward declaration
48 template <int dimgrid, int dimworld, class ctype = double>
49 class FoamGrid;
50 
51 
53 template<int dimgrid, int dimworld, class ctype>
55 {
56  typedef GridTraits<
57  dimgrid, // dimgrid
58  dimworld, // dimworld
72  unsigned int, // global id type
74  unsigned int, // local id type
75  CollectiveCommunication<Dune::FoamGrid<dimgrid, dimworld, ctype> > ,
76  DefaultLevelGridViewTraits,
77  DefaultLeafGridViewTraits,
79  > Traits;
80 };
81 
82 
83 
89 template <int dimgrid, int dimworld, class ct>
90 class FoamGrid :
91  public GridDefaultImplementation <dimgrid, dimworld, ct, FoamGridFamily<dimgrid, dimworld, ct> >
92 {
93 
94  friend class FoamGridLevelIndexSet<const FoamGrid >;
95  friend class FoamGridLeafIndexSet<const FoamGrid >;
96  friend class FoamGridIdSet<const FoamGrid >;
97  friend class FoamGridHierarchicIterator<const FoamGrid >;
98  friend class FoamGridLevelIntersectionIterator<const FoamGrid >;
99  friend class FoamGridLeafIntersectionIterator<const FoamGrid >;
100  friend class FoamGridLevelIntersection<const FoamGrid >;
101 
102  template<int codim, PartitionIteratorType pitype, class GridImp_>
103  friend class FoamGridLevelIterator;
104 
105  template<int codim, PartitionIteratorType pitype, class GridImp_>
106  friend class FoamGridLeafIterator;
107 
108  template <class GridType_>
109  friend class GridFactory;
110 
111  template <int dimgrid_, int dimworld_, class ct_>
112  friend class GridFactoryBase;
113 
114  template<int codim_, int dim_, class GridImp_>
115  friend class FoamGridEntity;
116 
117 public:
118 
120  static_assert(dimgrid==1 || dimgrid==2, "Use FoamGrid only for 1d and 2d grids!");
121 
122  //**********************************************************
123  // The Interface Methods
124  //**********************************************************
125 
128 
131 
133  typedef ct ctype;
134 
138  : entityImps_(makeEntityImps_())
139  , levelIndexSets_(1) // we always have level 0 (even if it's empty)
140  , leafIndexSet_(*this)
141  , freeIdCounter_(0)
142  , globalRefined(0)
143  , numBoundarySegments_(0)
144  , growing_(false)
145  {}
146 
149  {
150  // Delete level index sets
151  for (size_t i=0; i<levelIndexSets_.size(); i++)
152  if (levelIndexSets_[i])
153  delete (levelIndexSets_[i]);
154  }
155 
156 
159  int maxLevel() const {
160  return entityImps_.size()-1;
161  }
162 
163 
165  template<int codim>
166  typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const {
167  if (level<0 || level>maxLevel())
168  DUNE_THROW(Dune::GridError, "LevelIterator in nonexisting level " << level << " requested!");
169 
170  return Dune::FoamGridLevelIterator<codim,All_Partition, const Dune::FoamGrid<dimgrid, dimworld, ctype> >(std::get<dimgrid-codim>(entityImps_[level]).begin());
171  }
172 
173 
175  template<int codim>
176  typename Traits::template Codim<codim>::LevelIterator lend (int level) const {
177  if (level<0 || level>maxLevel())
178  DUNE_THROW(GridError, "LevelIterator in nonexisting level " << level << " requested!");
179 
180  return Dune::FoamGridLevelIterator<codim,All_Partition, const Dune::FoamGrid<dimgrid, dimworld, ctype> >(std::get<dimgrid-codim>(entityImps_[level]).end());
181  }
182 
183 
185  template<int codim, PartitionIteratorType PiType>
186  typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const {
187  if (level<0 || level>maxLevel())
188  DUNE_THROW(Dune::GridError, "LevelIterator in nonexisting level " << level << " requested!");
189 
190  return Dune::FoamGridLevelIterator<codim,PiType, const Dune::FoamGrid<dimgrid, dimworld, ctype> >(std::get<dimgrid-codim>(entityImps_[level]).begin());
191  }
192 
193 
195  template<int codim, PartitionIteratorType PiType>
196  typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const {
197  if (level<0 || level>maxLevel())
198  DUNE_THROW(GridError, "LevelIterator in nonexisting level " << level << " requested!");
199 
200  return Dune::FoamGridLevelIterator<codim,PiType, const Dune::FoamGrid<dimgrid, dimworld, ctype> >(std::get<dimgrid-codim>(entityImps_[level]).end());
201  }
202 
203 
205  template<int codim>
206  typename Traits::template Codim<codim>::LeafIterator leafbegin() const {
208  }
209 
210 
212  template<int codim>
213  typename Traits::template Codim<codim>::LeafIterator leafend() const {
215  }
216 
217 
219  template<int codim, PartitionIteratorType PiType>
220  typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const {
222  }
223 
224 
226  template<int codim, PartitionIteratorType PiType>
227  typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const {
229  }
230 
231 
234  int size (int level, int codim) const {
235 
236  // Turn dynamic index into static index
237  if ((codim==2 && dimgrid==2) || (codim==1 && dimgrid==1))
238  return std::get<0>(entityImps_[level]).size();
239  if ((codim==1 && dimgrid==2))
240  return std::get<1>(entityImps_[level]).size();
241  if (codim==0)
242  return std::get<dimgrid>(entityImps_[level]).size();
243 
244  return 0;
245  }
246 
247 
249  int size (int codim) const{
250  return leafIndexSet().size(codim);
251  }
252 
253 
255  int size (int level, GeometryType type) const {
256  return this->levelIndexSet(level).size(type);
257  }
258 
259 
261  int size (GeometryType type) const
262  {
263  return this->leafIndexSet().size(type);
264  }
265 
267  size_t numBoundarySegments() const
268  {
269  return numBoundarySegments_;
270  }
271 
273  const typename Traits::GlobalIdSet& globalIdSet() const{
274  return idSet_;
275  }
276 
277 
279  const typename Traits::LocalIdSet& localIdSet() const{
280  return idSet_;
281  }
282 
283 
285  const typename Traits::LevelIndexSet& levelIndexSet(int level) const
286  {
287  if (level<0 || level>maxLevel())
288  DUNE_THROW(GridError, "LevelIndexSet for nonexisting level " << level << " requested!");
289 
290  if (! levelIndexSets_[level])
291  {
292  levelIndexSets_[level] = new FoamGridLevelIndexSet<const FoamGrid>(*this, level);
293  levelIndexSets_[level]->update();
294  }
295  return *levelIndexSets_[level];
296  }
297 
298 
300  const typename Traits::LeafIndexSet& leafIndexSet() const
301  {
302  return leafIndexSet_;
303  }
304 
306  template <class EntitySeed>
307  static typename Traits::template Codim<EntitySeed::codimension>::Entity
308  entity(const EntitySeed& seed)
309  {
310  const int codim = EntitySeed::codimension;
311  typedef typename Traits::template Codim<codim>::Entity Entity;
312  return Entity(FoamGridEntity<codim, dimgrid, const FoamGrid>(seed.impl().target()));
313  }
314 
315 
318 
319 
323  void globalRefine (int refCount = 1);
324 
335  bool mark(int refCount, const typename Traits::template Codim<0>::Entity & e)
336  {
337  if (!e.isLeaf())
338  return false;
339 
341  if (refCount>=1)
343  else if (refCount<0)
345  else
347 
348  return true;
349  }
350 
355  int getMark(const typename Traits::template Codim<0>::Entity & e) const
356  {
357  switch(e.impl().target_->markState_)
358  {
361  return 0;
363  return 1;
365  return -1;
366  }
367  return 0;
368  }
369 
371  bool preAdapt();
372 
374  bool adapt();
375 
377  void postAdapt();
378 
389  void setPosition(const typename Traits::template Codim<dimgrid>::Entity & e,
390  const FieldVector<ctype, dimworld>& pos);
391 
394 
399  unsigned int insertVertex(const FieldVector<ctype,dimworld>& pos)
400  {
401  if(!growing_) initializeGrowth_();
402 
403  // the final level of the vertex will be the minimum common vertex level of the new element
404  verticesToInsert_.push_back(FoamGridEntityImp<0, dimgrid, dimworld, ctype>(0, pos, -verticesToInsert_.size()-1)); // initialize with some invalid id
405  FoamGridEntityImp<0, dimgrid, dimworld, ctype>& newVertex = verticesToInsert_.back();
406  newVertex.isNew_ = true;
407  // new vertices are numbered consecutively starting from
408  // the highest available index in the leaf index set +1
409  newVertex.growthInsertionIndex_ = this->leafGridView().size(dimgrid) - 1 + verticesToInsert_.size();
410  return newVertex.growthInsertionIndex_;
411  }
412 
419  unsigned int insertElement(const GeometryType& type,
420  const std::vector<unsigned int>& vertices)
421  {
422  // foamgrid only supports simplices until now
423  assert(type.isTriangle() || type.isLine());
424  assert(vertices.size() == dimgrid + 1);
425 
426  // the final level of the element will be the minimum common vertex level
427  elementsToInsert_.push_back(FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>(0, -elementsToInsert_.size()-1)); // initialize with some invalid id
428  FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>& newElement = elementsToInsert_.back();
429  assert(vertices.size() == newElement.vertex_.size());
430 
431  for(std::size_t i = 0; i < vertices.size(); i++)
432  {
433  if(int(vertices[i]) >= this->leafGridView().size(dimgrid))
434  {
435  // initialize with pointer to vertex in verticesToInsert_ vector, later overwrite with actual pointer
436  auto vIt = verticesToInsert_.begin();
437  std::advance(vIt, vertices[i] - this->leafGridView().size(dimgrid));
438  newElement.vertex_[i] = &*vIt;
439  }
440  else
441  {
442  // make sure the index to vertex map has been initialized
443  if(!growing_) initializeGrowth_();
444  // the vertex already exists in the grid, initialize with leaf vertex, later overwrite with lowest level father
445  assert(indexToVertexMap_[vertices[i]]->isLeaf());
446  newElement.vertex_[i] = indexToVertexMap_[vertices[i]];
447  }
448  }
449  newElement.isNew_ = true;
450  newElement.growthInsertionIndex_ = elementsToInsert_.size()-1;
451  return newElement.growthInsertionIndex_;
452  }
453 
461  unsigned int insertElement(const GeometryType& type,
462  const std::vector<unsigned int>& vertices,
463  const std::shared_ptr<VirtualFunction<FieldVector<ctype,dimgrid>,FieldVector<ctype,dimworld> > >& elementParametrization)
464  {
465  auto growthInsertionIndex = insertElement(type, vertices);
466  // save the pointer to the element parametrization
467  elementsToInsert_.back().elementParametrization_ = elementParametrization;
468  return growthInsertionIndex;
469  }
470 
474  void removeElement(const typename Traits::template Codim<0>::Entity & e)
475  {
476  // save entity for later, actual removal happens in grow()
477  elementsToRemove_.push_back(const_cast<FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>*> (e.impl().target_));
478  }
479 
481  bool preGrow();
482 
484  bool grow();
485 
487  void postGrow();
488 
497  unsigned int growthInsertionIndex(const typename Traits::template Codim<0>::Entity & e) const
498  {
499  int idx = e.impl().target_->growthInsertionIndex_;
500  assert(idx >= 0);
501  return static_cast<unsigned int>(idx);
502  }
503 
512  unsigned int growthInsertionIndex(const typename Traits::template Codim<dimgrid>::Entity & e) const
513  {
514  int idx = e.impl().target_->growthInsertionIndex_;
515  assert(idx >= 0);
516  return static_cast<unsigned int>(idx);
517  }
518 
523 
525  unsigned int overlapSize(int codim) const {
526  return 0;
527  }
528 
529 
531  unsigned int ghostSize(int codim) const {
532  return 0;
533  }
534 
535 
537  unsigned int overlapSize(int level, int codim) const {
538  return 0;
539  }
540 
541 
543  unsigned int ghostSize(int level, int codim) const {
544  return 0;
545  }
546 
549  template<class DataHandle>
550  bool loadBalance(DataHandle& data)
551  {
552  return loadBalance();
553  }
554 
555  bool loadBalance()
556  {
557  if (comm().size() > 1)
558  DUNE_THROW(Dune::NotImplemented, "Load balancing not implemented. Foamgrid does not run in parallel yet!");
559  return false;
560  }
561 
573  template<class T, template<class> class P, int codim>
574  void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level) const
575  {}
576 
580  template<class DataHandle>
581  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
582  {}
583 
584  template<class DataHandle>
585  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
586  {}
587 
589  const typename Traits::CollectiveCommunication& comm () const
590  {
591  return ccobj_;
592  }
596  // **********************************************************
597  // End of Interface Methods
598  // **********************************************************
599 
600  private:
601 
603  void initializeGrowth_()
604  {
605  // update the index to vertex map
606  indexToVertexMap_.resize(this->leafGridView().size(dimgrid));
607  for (const auto& vertex : vertices(this->leafGridView()))
608  {
609  std::size_t index = leafIndexSet().index(vertex);
610  indexToVertexMap_[index] = const_cast<FoamGridEntityImp<0, dimgrid ,dimworld, ctype>*>(vertex.impl().target_);
611  }
612 
613  // tell the grid it's ready for growth
614  growing_ = true;
615  }
616 
618  void erasePointersToEntities(std::list<FoamGridEntityImp<dimgrid, dimgrid ,dimworld, ctype> >& elements);
619 
624  template<int i>
625  void eraseVanishedEntities(std::list<FoamGridEntityImp<i, dimgrid, dimworld, ctype> >& levelEntities);
626 
629  void coarsenSimplexElement(FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>& element);
630 
634  void refineSimplexElement(FoamGridEntityImp<2, dimgrid, dimworld, ctype>& element,
635  int refCount);
637  void refineSimplexElement(FoamGridEntityImp<1, dimgrid, dimworld, ctype>& element,
638  int refCount);
639 
641  bool removeSimplexElement(FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>& element);
642 
652  void overwriteFineLevelNeighbours(FoamGridEntityImp<dimgrid-1, dimgrid, dimworld, ctype>& edge,
653  const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* son,
654  const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* father);
655 
662  void addElementForFacet(const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* element,
663  FoamGridEntityImp<dimgrid-1, dimgrid, dimworld, ctype>* facet);
664 
666  void addNewFacet(FoamGridEntityImp<0, dimgrid, dimworld, ctype>* &facet,
667  std::array<FoamGridEntityImp<0, dimgrid, dimworld, ctype>*,dimgrid> vertexArray,
668  int level);
669 
671  void addNewFacet(FoamGridEntityImp<1, dimgrid, dimworld, ctype>* &facet,
672  std::array<FoamGridEntityImp<0, dimgrid, dimworld, ctype>*,dimgrid> vertexArray,
673  int level);
674 
676  void setIndices();
677 
681  unsigned int getNextFreeId()
682  {
683  return freeIdCounter_++;
684  }
685 
687  void computeTwoZeroConnectivity()
688  {
689  // the elements vector for vertices is already available as they are facets in 1d grids
690  for(int level = 0; level <= maxLevel(); ++level)
691  {
692  // do it everytime freshly so that we don't have to take care of 2-0 connectivity in adaptivity
693  for(auto&& vertex : std::get<0>(entityImps_[level]))
694  vertex.elements_.clear();
695 
696  for(auto eIt = std::get<dimgrid>(entityImps_[level]).begin(); eIt != std::get<dimgrid>(entityImps_[level]).end(); ++eIt)
697  for(auto&& vertex : eIt->vertex_)
698  vertex->elements_.push_back(&*eIt);
699  }
700  }
701 
703  typename Traits::CollectiveCommunication ccobj_;
704 
705  template<std::size_t... dimEntity>
706  static auto makeEntityImpsImpl_(std::index_sequence<dimEntity...>, std::size_t numLevels)
707  { return std::vector<std::tuple<std::list<FoamGridEntityImp<dimEntity, dimgrid, dimworld, ctype>>...>>(numLevels); }
708 
709  // Create the lists of vertices, edges, elements for each level
710  static auto makeEntityImps_(std::size_t numLevels = 1)
711  { return makeEntityImpsImpl_(std::make_index_sequence<dimgrid+1>{}, numLevels); }
712 
713  // The vector type for tuple of lists of vertices, edges, elements for each level
714  using EntityImps = std::decay_t<decltype(makeEntityImps_())>;
715 
716  // The tuple type of lists of vertices, edges, elements
717  using EntityTuple = typename EntityImps::value_type;
718 
720  EntityImps entityImps_;
721 
723  mutable std::vector<FoamGridLevelIndexSet<const FoamGrid>*> levelIndexSets_;
724 
727 
730 
732  unsigned int freeIdCounter_;
733 
735  int globalRefined;
736 
738  std::size_t numBoundarySegments_;
739 
740  // True if the last call to preadapt returned true
741  bool willCoarsen;
742 
744  std::vector<FoamGridEntityImp<0, dimgrid, dimworld, ctype>* > indexToVertexMap_;
745 
747  std::vector<FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* > elementsToRemove_;
748 
750  std::list<FoamGridEntityImp<0, dimgrid, dimworld, ctype> > verticesToInsert_;
751 
753  std::list<FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype> > elementsToInsert_;
754 
756  bool growing_;
757 
758 }; // end Class FoamGrid
759 
761 
762 
763 namespace Capabilities
764 {
769  template<int dimgrid, int dimworld, class ctype, int codim>
770  struct hasEntity< FoamGrid<dimgrid, dimworld, ctype>, codim>
771  {
772  static const bool v = true;
773  };
774 
776  template <int dimgrid, int dimworld, class ctype>
777  struct isLevelwiseConforming< FoamGrid<dimgrid, dimworld, ctype> >
778  {
779  static const bool v = false;
780  };
781 
783  template <int dimgrid, int dimworld, class ctype>
784  struct isLeafwiseConforming< FoamGrid<dimgrid, dimworld, ctype> >
785  {
786  static const bool v = false;
787  };
788 }
789 
790 } // namespace Dune
791 
792 
793 // The factory should be present whenever the user includes foamgrid.hh.
794 // However since the factory needs to know the grid the include directive
795 // comes here at the end.
797 
798 #endif
The FoamGridEntity class.
Implementation of EntitySeed for the FoamGrid grid manager.
The specialization of the generic GridFactory for FoamGrid.
The FoamGridGeometry class.
The FoamGridHierarchicIterator class.
The index and id sets for the FoamGrid class.
The FoamGridLeafIntersectionIterator and FoamGridLevelIntersectionIterator classes.
The FoamGridLeafIterator class.
The FoamGridLevelIterator class.
Definition: dgffoam.cc:6
Element specialization of FoamGridEntityImp. Element is a grid entity of topological codimension 0 an...
Definition: foamgridelements.hh:18
The implementation of entities in a FoamGrid.
Definition: foamgridentity.hh:54
Iterator over all entities of a given codimension and level of a grid.
Definition: foamgridleveliterator.hh:18
Definition: foamgridintersectioniterators.hh:239
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: foamgridintersectioniterators.hh:28
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: foamgridhierarchiciterator.hh:24
The EntitySeed class provides the minmal information needed to restore an Entity using the grid.
Definition: foamgridentityseed.hh:21
Specialization of the generic GridFactory for FoamGrid<dimgrid, dimworld>
Definition: foamgridfactory.hh:31
Definition: foamgridgeometry.hh:21
Definition: foamgridindexsets.hh:26
Definition: foamgridindexsets.hh:200
Definition: foamgridindexsets.hh:417
Definition: foamgridintersections.hh:252
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: foamgridintersections.hh:386
Iterator over all entities of a given codimension and level of a grid.
Definition: foamgridleafiterator.hh:15
The actual entity implementation.
Definition: foamgridvertex.hh:47
Vertex specialization of FoamGridEntityImp.
Definition: foamgridvertex.hh:53
int growthInsertionIndex_
If this vertex was created in a growth step this will be the index of insertion So if this is the fir...
Definition: foamgridvertex.hh:148
bool isNew_
If the vertex was newly inserted (at run-time)
Definition: foamgridvertex.hh:141
void removeElement(const typename Traits::template Codim< 0 >::Entity &e)
Mark an element for removal from the grid.
Definition: foamgrid.hh:474
const Traits::CollectiveCommunication & comm() const
Definition: foamgrid.hh:589
unsigned int overlapSize(int level, int codim) const
Size of the overlap on a given level.
Definition: foamgrid.hh:537
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
Definition: foamgrid.hh:255
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: foamgrid.hh:227
size_t numBoundarySegments() const
The number of boundary edges on the coarsest level.
Definition: foamgrid.hh:267
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: foamgrid.hh:186
void setPosition(const typename Traits::template Codim< dimgrid >::Entity &e, const FieldVector< ctype, dimworld > &pos)
Sets a (leaf) vertex to a new position.
Definition: foamgrid.cc:1416
void communicate(T &t, InterfaceType iftype, CommunicationDirection dir, int level) const
The communication interface.
Definition: foamgrid.hh:574
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: foamgrid.hh:279
FoamGrid()
Constructor, constructs an empty grid.
Definition: foamgrid.hh:137
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: foamgrid.hh:166
friend class FoamGridLeafIndexSet< const FoamGrid >
Definition: foamgrid.hh:95
friend class GridFactory
Definition: foamgrid.hh:109
bool preGrow()
Book-keeping routine to be called before growth.
Definition: foamgrid.cc:994
FoamGridFamily< dimgrid, dimworld, ct >::Traits Traits
Exports various types belonging to this grid class.
Definition: foamgrid.hh:130
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark entity for refinement.
Definition: foamgrid.hh:335
FoamGridFamily< dimgrid, dimworld, ct > GridFamily
FoamGrid is only implemented for 1 and 2 dimension.
Definition: foamgrid.hh:120
unsigned int insertVertex(const FieldVector< ctype, dimworld > &pos)
Add new vertex to be added the grid.
Definition: foamgrid.hh:399
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: foamgrid.hh:300
~FoamGrid()
Destructor.
Definition: foamgrid.hh:148
unsigned int growthInsertionIndex(const typename Traits::template Codim< 0 >::Entity &e) const
The index of insertion if the element was created in the current growth step. If this is the first el...
Definition: foamgrid.hh:497
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: foamgrid.hh:196
void postGrow()
Clean up isNew markers.
Definition: foamgrid.cc:1319
friend class FoamGridLevelIndexSet< const FoamGrid >
Definition: foamgrid.hh:94
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Return refinement mark for entity.
Definition: foamgrid.hh:355
unsigned int insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
Add a new element to be added to the grid.
Definition: foamgrid.hh:419
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: foamgrid.hh:581
friend class FoamGridIdSet< const FoamGrid >
Definition: foamgrid.hh:96
bool loadBalance(DataHandle &data)
Distributes this grid over the available nodes in a distributed machine.
Definition: foamgrid.hh:550
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: foamgrid.hh:285
bool preAdapt()
Book-keeping routine to be called before adaptation.
Definition: foamgrid.cc:152
void postAdapt()
Clean up refinement markers.
Definition: foamgrid.cc:317
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: foamgrid.hh:585
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: foamgrid.hh:261
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: foamgrid.hh:273
void globalRefine(int refCount=1)
Refine the grid uniformly.
Definition: foamgrid.cc:3
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: foamgrid.hh:176
ct ctype
The type used to store coordinates.
Definition: foamgrid.hh:133
bool loadBalance()
Definition: foamgrid.hh:555
unsigned int overlapSize(int codim) const
Size of the overlap on the leaf level.
Definition: foamgrid.hh:525
unsigned int ghostSize(int level, int codim) const
Size of the ghost cell layer on a given level.
Definition: foamgrid.hh:543
unsigned int ghostSize(int codim) const
Size of the ghost cell layer on the leaf level.
Definition: foamgrid.hh:531
static Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed)
Create an Entity from an EntitySeed.
Definition: foamgrid.hh:308
int maxLevel() const
Definition: foamgrid.hh:159
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: foamgrid.hh:206
bool grow()
Triggers the grid growth process.
Definition: foamgrid.cc:1001
unsigned int growthInsertionIndex(const typename Traits::template Codim< dimgrid >::Entity &e) const
The index of insertion if the vertex was created in the current growth step. If this is the first ver...
Definition: foamgrid.hh:512
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: foamgrid.hh:234
bool adapt()
Triggers the grid refinement process.
Definition: foamgrid.cc:206
int size(int codim) const
number of leaf entities per codim in this process
Definition: foamgrid.hh:249
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: foamgrid.hh:213
unsigned int insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices, const std::shared_ptr< VirtualFunction< FieldVector< ctype, dimgrid >, FieldVector< ctype, dimworld > > > &elementParametrization)
Add a new element to be added to the grid.
Definition: foamgrid.hh:461
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: foamgrid.hh:220
Encapsulates loads of types exported by FoamGrid.
Definition: foamgrid.hh:55
GridTraits< dimgrid, dimworld, Dune::FoamGrid< dimgrid, dimworld, ctype >, FoamGridGeometry, FoamGridEntity, FoamGridLevelIterator, FoamGridLeafIntersection, FoamGridLevelIntersection, FoamGridLeafIntersectionIterator, FoamGridLevelIntersectionIterator, FoamGridHierarchicIterator, FoamGridLeafIterator, FoamGridLevelIndexSet< const FoamGrid< dimgrid, dimworld, ctype > >, FoamGridLeafIndexSet< const FoamGrid< dimgrid, dimworld, ctype > >, FoamGridIdSet< const FoamGrid< dimgrid, dimworld, ctype > >, unsigned int, FoamGridIdSet< const FoamGrid< dimgrid, dimworld, ctype > >, unsigned int, CollectiveCommunication< Dune::FoamGrid< dimgrid, dimworld, ctype > >, DefaultLevelGridViewTraits, DefaultLeafGridViewTraits, FoamGridEntitySeed > Traits
Definition: foamgrid.hh:79