Go to the documentation of this file.
13 #include <dune/common/classname.hh>
14 #include <dune/common/parallel/communication.hh>
15 #include <dune/common/exceptions.hh>
16 #include <dune/common/parallel/mpihelper.hh>
17 #include <dune/common/deprecated.hh>
23 #if HAVE_UG || DOXYGEN
26 #include <dune/common/parallel/mpicommunication.hh>
52 #ifdef UG_USE_NEW_DIMENSION_DEFINES
58 #include "uggrid/ugincludes.hh"
63 #include "uggrid/ugwrapper.hh"
68 #include "uggrid/ug_undefs.hh"
69 #ifdef UG_USE_NEW_DIMENSION_DEFINES
91 #ifdef UG_USE_NEW_DIMENSION_DEFINES
97 #include "uggrid/ugincludes.hh"
102 #include "uggrid/ugwrapper.hh"
106 #include "uggrid/ug_undefs.hh"
108 #ifdef UG_USE_NEW_DIMENSION_DEFINES
116 #include "uggrid/uggridgeometry.hh"
117 #include "uggrid/uggridlocalgeometry.hh"
118 #include "uggrid/uggridentity.hh"
119 #include "uggrid/uggridentityseed.hh"
120 #include "uggrid/uggridintersections.hh"
121 #include "uggrid/uggridintersectioniterators.hh"
122 #include "uggrid/uggridleveliterator.hh"
123 #include "uggrid/uggridleafiterator.hh"
124 #include "uggrid/uggridhieriterator.hh"
125 #include "uggrid/uggridindexsets.hh"
126 #include <dune/grid/uggrid/uggridviews.hh>
128 #include "uggrid/ugmessagebuffer.hh"
129 #include "uggrid/uglbgatherscatter.hh"
136 template <
class DataHandle,
int Gr
idDim,
int codim>
139 template <
class DataHandle,
int Gr
idDim,
int codim>
140 DataHandle *Dune::UGMessageBufferBase<DataHandle,GridDim,codim>::duneDataHandle_ = 0;
142 template <
class DataHandle,
int Gr
idDim,
int codim>
143 int Dune::UGMessageBufferBase<DataHandle,GridDim,codim>::level = -1;
161 UGGridLeafIntersection,
162 UGGridLevelIntersection,
163 UGGridLeafIntersectionIterator,
164 UGGridLevelIntersectionIterator,
165 UGGridHierarchicIterator,
167 UGGridLevelIndexSet< const UGGrid<dim> >,
168 UGGridLeafIndexSet< const UGGrid<dim> >,
169 UGGridIdSet< const UGGrid<dim> >,
170 typename UG_NS<dim>::UG_ID_TYPE,
171 UGGridIdSet< const UGGrid<dim> >,
172 typename UG_NS<dim>::UG_ID_TYPE,
174 UGGridLevelGridViewTraits,
175 UGGridLeafGridViewTraits,
230 friend class UGGridGeometry<0,dim,const
UGGrid<dim> >;
231 friend class UGGridGeometry<dim,dim,const
UGGrid<dim> >;
232 friend class UGGridGeometry<1,2,const
UGGrid<dim> >;
233 friend class UGGridGeometry<2,3,const
UGGrid<dim> >;
235 friend class UGGridEntity <0,dim,const
UGGrid<dim> >;
236 friend class UGGridEntity <1,dim,const
UGGrid<dim> >;
237 friend class UGGridEntity <dim,dim,const
UGGrid<dim> >;
238 friend class UGEdgeEntity <dim,const
UGGrid<dim> >;
239 friend class UGGridHierarchicIterator<const
UGGrid<dim> >;
240 friend class UGGridLeafIntersection<const
UGGrid<dim> >;
241 friend class UGGridLevelIntersection<const
UGGrid<dim> >;
242 friend class UGGridLeafIntersectionIterator<const
UGGrid<dim> >;
243 friend class UGGridLevelIntersectionIterator<const
UGGrid<dim> >;
245 friend class UGGridLevelIndexSet<const
UGGrid<dim> >;
246 friend class UGGridLeafIndexSet<const
UGGrid<dim> >;
247 friend class UGGridIdSet<const
UGGrid<dim> >;
248 template <
class Gr
idImp_>
250 template <
class Gr
idImp_>
256 friend class UGLBGatherScatter;
259 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
261 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
265 static_assert(dim==2 || dim==3,
"Use UGGrid only for 2d and 3d!");
300 template <typename Seed>
301 typename
Traits::template Codim<Seed::codimension>::
Entity
304 const int codim = Seed::codimension;
305 return typename Traits::template Codim<codim>::Entity(UGGridEntity<codim,dim,
const UGGrid<dim> >(seed.impl().target(),
this));
310 int size (
int level,
int codim)
const;
334 return numBoundarySegments_;
353 DUNE_THROW(
GridError,
"levelIndexSet of nonexisting level " << level <<
" requested!");
354 return *levelIndexSets_[level];
360 return leafIndexSet_;
378 bool mark(
int refCount,
const typename Traits::template Codim<0>::Entity & e );
435 bool mark(
const typename Traits::template Codim<0>::Entity & e,
436 typename UG_NS<dim>::RefinementRule rule,
440 int getMark(
const typename Traits::template Codim<0>::Entity& e)
const;
460 template<
class DataHandle>
465 if (dataHandle.contains(dim, 0))
466 UGLBGatherScatter::template gather<0>(this->
leafGridView(), dataHandle);
469 if (dataHandle.contains(dim,dim))
470 UGLBGatherScatter::template gather<dim>(this->
leafGridView(), dataHandle);
479 if (dataHandle.contains(dim, 0))
480 UGLBGatherScatter::template scatter<0>(this->
leafGridView(), dataHandle);
483 if (dataHandle.contains(dim,dim))
484 UGLBGatherScatter::template scatter<dim>(this->
leafGridView(), dataHandle);
528 bool loadBalance(
const std::vector<Rank>& targetProcessors,
unsigned int fromLevel);
539 template<
class DataHandle>
540 bool loadBalance (
const std::vector<Rank>& targetProcessors,
unsigned int fromLevel, DataHandle& dataHandle)
547 UGLBGatherScatter::template gather<dim>(this->
leafGridView(), dataHandle);
559 UGLBGatherScatter::template scatter<dim>(this->
leafGridView(), dataHandle);
573 template <
int codim,
class Gr
idView,
class DataHandle>
574 void communicateUG_(
const GridView& gv,
int level,
575 DataHandle &dataHandle,
579 typename UG_NS<dim>::DDD_IF_DIR ugIfDir;
582 ugIfDir = UG_NS<dim>::IF_FORWARD();
584 ugIfDir = UG_NS<dim>::IF_BACKWARD();
586 typedef UGMessageBuffer<DataHandle,dim,codim> UGMsgBuf;
587 UGMsgBuf::duneDataHandle_ = &dataHandle;
589 UGMsgBuf::level = level;
591 std::vector<typename UG_NS<dim>::DDD_IF> ugIfs;
592 findDDDInterfaces_(ugIfs, iftype, codim);
594 unsigned bufSize = UGMsgBuf::ugBufferSize_(gv);
597 UGMsgBuf::grid_ =
this;
598 for (
unsigned i=0; i < ugIfs.size(); ++i)
599 UG_NS<dim>::DDD_IFOneway(
600 #
if DUNE_UGGRID_HAVE_DDDCONTEXT
601 multigrid_->dddContext(),
606 &UGMsgBuf::ugGather_,
607 &UGMsgBuf::ugScatter_);
610 void findDDDInterfaces_(std::vector<
typename UG_NS<dim>::DDD_IF > &dddIfaces,
614 #if DUNE_UGGRID_HAVE_DDDCONTEXT
615 # define DDD_CONTEXT multigrid_->dddContext()
631 dddIfaces.push_back(UG_NS<dim>::ElementVHIF(DDD_CONTEXT));
638 dddIfaces.push_back(UG_NS<dim>::ElementSymmVHIF(DDD_CONTEXT));
641 DUNE_THROW(GridError,
642 "Element communication not supported for "
643 "interfaces of type "
647 else if (codim == dim)
652 dddIfaces.push_back(UG_NS<dim>::BorderNodeSymmIF(DDD_CONTEXT));
655 dddIfaces.push_back(UG_NS<dim>::BorderNodeSymmIF(DDD_CONTEXT));
656 dddIfaces.push_back(UG_NS<dim>::NodeIF(DDD_CONTEXT));
659 dddIfaces.push_back(UG_NS<dim>::NodeAllIF(DDD_CONTEXT));
662 DUNE_THROW(GridError,
663 "Node communication not supported for "
664 "interfaces of type "
668 else if (codim == dim-1)
673 dddIfaces.push_back(UG_NS<dim>::BorderEdgeSymmIF(DDD_CONTEXT));
676 dddIfaces.push_back(UG_NS<dim>::BorderEdgeSymmIF(DDD_CONTEXT));
681 dddIfaces.push_back(UG_NS<dim>::EdgeSymmVHIF(DDD_CONTEXT));
684 DUNE_THROW(GridError,
685 "Edge communication not supported for "
686 "interfaces of type "
696 dddIfaces.push_back(UG_NS<dim>::BorderVectorSymmIF(DDD_CONTEXT));
699 DUNE_THROW(GridError,
700 "Face communication not supported for "
701 "interfaces of type "
707 DUNE_THROW(GridError,
708 "Communication for codim "
710 <<
" entities is not yet supported "
711 <<
" by the DUNE UGGrid interface!");
732 std::vector<
typename Traits::template Codim<0>::Entity>& childElements,
733 std::vector<unsigned char>& childElementSides)
const;
753 refinementType_ = type;
774 void setPosition(
const typename Traits::template Codim<dim>::Entity& e,
775 const FieldVector<double, dim>& pos);
787 void saveState(
const std::string& filename)
const;
793 void loadState(
const std::string& filename);
797 typename UG_NS<dim>::MultiGrid* multigrid_;
807 void setIndices(
bool setLevelZero,
808 std::vector<unsigned int>* nodePermutation);
815 std::vector<std::shared_ptr<UGGridLevelIndexSet<const UGGrid<dim> > > > levelIndexSets_;
817 UGGridLeafIndexSet<const UGGrid<dim> > leafIndexSet_;
821 UGGridIdSet<const UGGrid<dim> > idSet_;
836 static int numOfUGGrids;
843 bool someElementHasBeenMarkedForRefinement_;
850 bool someElementHasBeenMarkedForCoarsening_;
853 std::vector<std::shared_ptr<BoundarySegment<dim> > > boundarySegments_;
860 unsigned int numBoundarySegments_;
864 namespace Capabilities
884 static const bool v =
true;
893 static const bool v =
true;
903 static const bool v =
true;
913 static const bool v =
true;
922 static const bool v =
true;
931 static const bool v =
false;
938 #endif // HAVE_UG || DOXYGEN
939 #endif // DUNE_UGGRID_HH
GridTraits< dim, dim, Dune::UGGrid< dim >, UGGridGeometry, UGGridEntity, UGGridLevelIterator, UGGridLeafIntersection, UGGridLevelIntersection, UGGridLeafIntersectionIterator, UGGridLevelIntersectionIterator, UGGridHierarchicIterator, UGGridLeafIterator, UGGridLevelIndexSet< const UGGrid< dim > >, UGGridLeafIndexSet< const UGGrid< dim > >, UGGridIdSet< const UGGrid< dim > >, typename UG_NS< dim >::UG_ID_TYPE, UGGridIdSet< const UGGrid< dim > >, typename UG_NS< dim >::UG_ID_TYPE, UGCollectiveCommunication, UGGridLevelGridViewTraits, UGGridLeafGridViewTraits, UGGridEntitySeed, UGGridLocalGeometry > Traits
Definition: uggrid.hh:178
static const bool v
Definition: common/capabilities.hh:105
specialize with 'true' for all codims that a grid provides an iterator for (default=false)
Definition: common/capabilities.hh:71
static void setDefaultHeapSize(unsigned size) DUNE_DEPRECATED_MSG("Do not set the UGGrid default heap size---it is ignored anyway!")
Sets the default heap size.
Definition: uggrid.hh:767
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:112
RefinementType
The different forms of grid refinement that UG supports.
Definition: uggrid.hh:736
static const bool v
Definition: common/capabilities.hh:57
DUNE_DEPRECATED_MSG("use the facade class' `impl()` method instead") static typename std
return real implementation of interface class
Definition: common/grid.hh:1007
CollectiveCommunication< No_Comm > UGCollectiveCommunication
Definition: uggrid.hh:151
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:55
void saveState(const std::string &filename) const
Save entire grid hierarchy to disk.
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
Front-end for the grid manager of the finite element toolbox UG.
Definition: uggrid.hh:226
IdSet< const GridImp, GlobalIdSetImp, GIDType > GlobalIdSet
The type of the global id set.
Definition: common/grid.hh:1136
@ InteriorBorder_InteriorBorder_Interface
send/receive interior and border entities
Definition: gridenums.hh:85
static const bool v
Definition: common/capabilities.hh:114
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: common/grid.hh:941
bool loadBalance(DataHandle &dataHandle)
Distributes the grid and some data over the available nodes in a distributed machine.
Definition: uggrid.hh:461
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:269
unsigned int Rank
The type used for process ranks.
Definition: uggrid.hh:286
void setClosureType(ClosureType type)
Sets the type of grid refinement closure.
Definition: uggrid.hh:757
void setPosition(const typename Traits::template Codim< dim >::Entity &e, const FieldVector< double, dim > &pos)
Sets a vertex to a new position.
ClosureType
Decide whether to add a green closure to locally refined grid sections or not.
Definition: uggrid.hh:744
~UGGrid() noexcept(false)
Destructor.
@ All_All_Interface
send all and receive all entities
Definition: gridenums.hh:89
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition: uggrid.hh:325
void postAdapt()
Clean up refinement markers.
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: uggrid.hh:358
friend class UGGridLeafIterator
Definition: uggrid.hh:260
static const bool v
Definition: common/capabilities.hh:73
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark element for refinement.
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: uggrid.hh:350
Definition: uggrid.hh:155
UGGridFamily< dim > GridFamily
type of the used GridFamily for this grid
Definition: uggrid.hh:277
void setRefinementType(RefinementType type)
Sets the type of grid refinement.
Definition: uggrid.hh:752
void loadState(const std::string &filename)
Read entire grid hierarchy from disk.
Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed) const
Create an Entity from an EntitySeed.
Definition: uggrid.hh:302
bool adapt()
Triggers the grid refinement process.
int size(int level, int codim) const
Number of grid entities per level and codim.
A set of traits classes to store static information about grid implementation.
@ NONE
No closure, results in nonconforming meshes.
Definition: uggrid.hh:748
Definition: common/geometry.hh:24
friend class UGGridLevelGridView
Definition: uggrid.hh:251
IdSet< const GridImp, LocalIdSetImp, LIDType > LocalIdSet
The type of the local id set.
Definition: common/grid.hh:1138
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: uggrid.hh:319
UG::DOUBLE ctype
The type used to store coordinates.
Definition: uggrid.hh:283
IndexSet< const GridImp, LevelIndexSetImp > LevelIndexSet
The type of the level index set.
Definition: common/grid.hh:1132
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:103
A traits struct that collects all associated types of one grid model.
Definition: common/grid.hh:1064
Grid view abstract base class.
Definition: common/gridview.hh:59
friend class UGGridLeafGridView
Definition: uggrid.hh:249
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:86
@ LOCAL
New level consists only of the refined elements and the closure.
Definition: uggrid.hh:738
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:169
UGGridFamily< dim >::Traits Traits
Definition: uggrid.hh:280
friend class UGGridLevelIterator
Definition: uggrid.hh:262
bool loadBalance(const std::vector< Rank > &targetProcessors, unsigned int fromLevel, DataHandle &dataHandle)
Distributes the grid over the processes of a parallel machine, and sends data along with it.
Definition: uggrid.hh:540
@ GREEN
Standard red/green refinement.
Definition: uggrid.hh:746
@ COPY
New level consists of the refined elements and the unrefined ones, too.
Definition: uggrid.hh:740
int size(int codim) const
number of leaf entities per codim in this process
Definition: uggrid.hh:313
UGGrid(UGCollectiveCommunication comm={})
Default constructor.
Base class for grid boundary segments of arbitrary geometry.
void globalRefine(int n)
Does uniform refinement.
const UGCollectiveCommunication & comm() const
Definition: uggrid.hh:566
IndexType size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:220
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: uggrid.hh:338
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: uggrid.hh:344
bool preAdapt()
returns true, if some elements might be coarsend during grid adaption, here always returns true
The specialization of the generic GridFactory for UGGrid.
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
size_t numBoundarySegments() const
Return the number of boundary segments.
Definition: uggrid.hh:331
Different resources needed by all grid implementations.
Traits::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: common/grid.hh:875
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Query whether element is marked for refinement.
Include standard header files.
Definition: agrid.hh:58
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
Wrapper class for entities.
Definition: common/entity.hh:63
void getChildrenOfSubface(const typename Traits::template Codim< 0 >::Entity &e, int elementSide, int maxl, std::vector< typename Traits::template Codim< 0 >::Entity > &childElements, std::vector< unsigned char > &childElementSides) const
Rudimentary substitute for a hierarchic iterator on faces.
IndexSet< const GridImp, LeafIndexSetImp > LeafIndexSet
The type of the leaf index set.
Definition: common/grid.hh:1134