Go to the documentation of this file.
13 #include <dune/common/classname.hh>
14 #include <dune/common/parallel/collectivecommunication.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/mpicollectivecommunication.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>
137 DataHandle *Dune::UGMessageBufferBase<DataHandle,GridDim,codim>::duneDataHandle_ = 0;
139 template <
class DataHandle,
int Gr
idDim,
int codim>
140 int Dune::UGMessageBufferBase<DataHandle,GridDim,codim>::level = -1;
147 class CollectiveCommunication<
Dune::UGGrid<dim> > :
148 public CollectiveCommunication< Dune::MPIHelper::MPICommunicator >
150 typedef CollectiveCommunication< Dune::MPIHelper::MPICommunicator > ParentType;
152 CollectiveCommunication()
153 : ParentType(MPIHelper::getCommunicator())
165 UGGridLeafIntersection,
166 UGGridLevelIntersection,
167 UGGridLeafIntersectionIterator,
168 UGGridLevelIntersectionIterator,
169 UGGridHierarchicIterator,
171 UGGridLevelIndexSet< const UGGrid<dim> >,
172 UGGridLeafIndexSet< const UGGrid<dim> >,
173 UGGridIdSet< const UGGrid<dim> >,
174 typename UG_NS<dim>::UG_ID_TYPE,
175 UGGridIdSet< const UGGrid<dim> >,
176 typename UG_NS<dim>::UG_ID_TYPE,
177 CollectiveCommunication<Dune::UGGrid<dim> >,
178 UGGridLevelGridViewTraits,
179 UGGridLeafGridViewTraits,
234 friend class UGGridGeometry<0,dim,const
UGGrid<dim> >;
235 friend class UGGridGeometry<dim,dim,const
UGGrid<dim> >;
236 friend class UGGridGeometry<1,2,const
UGGrid<dim> >;
237 friend class UGGridGeometry<2,3,const
UGGrid<dim> >;
239 friend class UGGridEntity <0,dim,const
UGGrid<dim> >;
240 friend class UGGridEntity <dim,dim,const
UGGrid<dim> >;
241 friend class UGGridHierarchicIterator<const
UGGrid<dim> >;
242 friend class UGGridLeafIntersection<const
UGGrid<dim> >;
243 friend class UGGridLevelIntersection<const
UGGrid<dim> >;
244 friend class UGGridLeafIntersectionIterator<const
UGGrid<dim> >;
245 friend class UGGridLevelIntersectionIterator<const
UGGrid<dim> >;
247 friend class UGGridLevelIndexSet<const
UGGrid<dim> >;
248 friend class UGGridLeafIndexSet<const
UGGrid<dim> >;
249 friend class UGGridIdSet<const
UGGrid<dim> >;
250 template <
class Gr
idImp_>
252 template <
class Gr
idImp_>
258 friend class UGLBGatherScatter;
261 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
263 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
267 static_assert(dim==2 || dim==3,
"Use UGGrid only for 2d and 3d!");
305 template <typename Seed>
306 typename
Traits::template Codim<Seed::codimension>::
Entity
309 const int codim = Seed::codimension;
315 int size (
int level,
int codim)
const;
339 return numBoundarySegments_;
358 DUNE_THROW(
GridError,
"levelIndexSet of nonexisting level " << level <<
" requested!");
359 return *levelIndexSets_[level];
365 return leafIndexSet_;
383 bool mark(
int refCount,
const typename Traits::template Codim<0>::Entity & e );
440 bool mark(
const typename Traits::template Codim<0>::Entity & e,
441 typename UG_NS<dim>::RefinementRule rule,
445 int getMark(
const typename Traits::template Codim<0>::Entity& e)
const;
465 template<
class DataHandle>
470 if (dataHandle.contains(dim, 0))
471 UGLBGatherScatter::template gather<0>(this->
leafGridView(), dataHandle);
474 if (dataHandle.contains(dim,dim))
475 UGLBGatherScatter::template gather<dim>(this->
leafGridView(), dataHandle);
484 if (dataHandle.contains(dim, 0))
485 UGLBGatherScatter::template scatter<0>(this->
leafGridView(), dataHandle);
488 if (dataHandle.contains(dim,dim))
489 UGLBGatherScatter::template scatter<dim>(this->
leafGridView(), dataHandle);
533 bool loadBalance(
const std::vector<Rank>& targetProcessors,
unsigned int fromLevel);
544 template<
class DataHandle>
545 bool loadBalance (
const std::vector<Rank>& targetProcessors,
unsigned int fromLevel, DataHandle& dataHandle)
552 UGLBGatherScatter::template gather<dim>(this->
leafGridView(), dataHandle);
564 UGLBGatherScatter::template scatter<dim>(this->
leafGridView(), dataHandle);
571 const CollectiveCommunication<UGGrid>&
comm ()
const
578 template <
class Gr
idView,
class DataHandle,
int codim>
579 void communicateUG_(
const GridView& gv,
int level,
580 DataHandle &dataHandle,
584 typename UG_NS<dim>::DDD_IF_DIR ugIfDir;
587 ugIfDir = UG_NS<dim>::IF_FORWARD();
589 ugIfDir = UG_NS<dim>::IF_BACKWARD();
591 typedef UGMessageBuffer<DataHandle,dim,codim> UGMsgBuf;
592 UGMsgBuf::duneDataHandle_ = &dataHandle;
594 UGMsgBuf::level = level;
596 std::vector<typename UG_NS<dim>::DDD_IF> ugIfs;
597 findDDDInterfaces_(ugIfs, iftype, codim);
599 unsigned bufSize = UGMsgBuf::ugBufferSize_(gv);
602 for (
unsigned i=0; i < ugIfs.size(); ++i)
603 UG_NS<dim>::DDD_IFOneway(ugIfs[i],
606 &UGMsgBuf::ugGather_,
607 &UGMsgBuf::ugScatter_);
610 void findDDDInterfaces_(std::vector<
typename UG_NS<dim>::DDD_IF > &dddIfaces,
626 dddIfaces.push_back(UG_NS<dim>::ElementVHIF());
633 dddIfaces.push_back(UG_NS<dim>::ElementSymmVHIF());
636 DUNE_THROW(GridError,
637 "Element communication not supported for "
638 "interfaces of type "
642 else if (codim == dim)
647 dddIfaces.push_back(UG_NS<dim>::BorderNodeSymmIF());
650 dddIfaces.push_back(UG_NS<dim>::BorderNodeSymmIF());
651 dddIfaces.push_back(UG_NS<dim>::NodeIF());
654 dddIfaces.push_back(UG_NS<dim>::NodeAllIF());
657 DUNE_THROW(GridError,
658 "Node communication not supported for "
659 "interfaces of type "
663 else if (codim == dim-1)
668 dddIfaces.push_back(UG_NS<dim>::BorderEdgeSymmIF());
671 dddIfaces.push_back(UG_NS<dim>::BorderEdgeSymmIF());
676 dddIfaces.push_back(UG_NS<dim>::EdgeSymmVHIF());
679 DUNE_THROW(GridError,
680 "Edge communication not supported for "
681 "interfaces of type "
691 dddIfaces.push_back(UG_NS<dim>::BorderVectorSymmIF());
694 DUNE_THROW(GridError,
695 "Face communication not supported for "
696 "interfaces of type "
702 DUNE_THROW(GridError,
703 "Communication for codim "
705 <<
" entities is not yet supported "
706 <<
" by the DUNE UGGrid interface!");
726 std::vector<
typename Traits::template Codim<0>::Entity>& childElements,
727 std::vector<unsigned char>& childElementSides)
const;
747 refinementType_ = type;
768 void setPosition(
const typename Traits::template Codim<dim>::Entity& e,
769 const FieldVector<double, dim>& pos);
781 void saveState(
const std::string& filename)
const;
787 void loadState(
const std::string& filename);
791 typename UG_NS<dim>::MultiGrid* multigrid_;
794 CollectiveCommunication<UGGrid> ccobj_;
801 void setIndices(
bool setLevelZero,
802 std::vector<unsigned int>* nodePermutation);
809 std::vector<std::shared_ptr<UGGridLevelIndexSet<const UGGrid<dim> > > > levelIndexSets_;
811 UGGridLeafIndexSet<const UGGrid<dim> > leafIndexSet_;
815 UGGridIdSet<const UGGrid<dim> > idSet_;
830 static int numOfUGGrids;
837 bool someElementHasBeenMarkedForRefinement_;
844 bool someElementHasBeenMarkedForCoarsening_;
850 static unsigned int heapSize_;
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
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:355
Wrapper class for entities.
Definition: common/entity.hh:63
void loadState(const std::string &filename)
Read entire grid hierarchy from disk.
Different resources needed by all grid implementations.
void globalRefine(int n)
Does uniform refinement.
Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed) const
Create an Entity from an EntitySeed.
Definition: uggrid.hh:307
IdSet< const GridImp, GlobalIdSetImp, GIDType > GlobalIdSet
The type of the global id set.
Definition: common/grid.hh:1135
static const bool v
Definition: common/capabilities.hh:57
@ COPY
New level consists of the refined elements and the unrefined ones, too.
Definition: uggrid.hh:734
static void setDefaultHeapSize(unsigned size)
Sets the default heap size.
Definition: uggrid.hh:761
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: common/capabilities.hh:112
UG::DOUBLE ctype
The type used to store coordinates.
Definition: uggrid.hh:285
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: common/capabilities.hh:103
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:86
A traits struct that collects all associated types of one grid model.
Definition: common/grid.hh:1063
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:169
void setRefinementType(RefinementType type)
Sets the type of grid refinement.
Definition: uggrid.hh:746
bool preAdapt()
returns true, if some elements might be coarsend during grid adaption, here always returns true
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
bool adapt()
Triggers the grid refinement process.
int size(int level, int codim) const
Number of grid entities per level and codim.
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:545
Traits::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: common/grid.hh:875
The specialization of the generic GridFactory for UGGrid.
void setPosition(const typename Traits::template Codim< dim >::Entity &e, const FieldVector< double, dim > &pos)
Sets a vertex to a new position.
friend class UGGridLevelGridView
Definition: uggrid.hh:253
~UGGrid() noexcept(false)
Destructor.
IndexSet< const GridImp, LevelIndexSetImp > LevelIndexSet
The type of the level index set.
Definition: common/grid.hh:1131
specialize with 'true' for all codims that a grid provides an iterator for (default=false)
Definition: common/capabilities.hh:71
void setClosureType(ClosureType type)
Sets the type of grid refinement closure.
Definition: uggrid.hh:751
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition: common/grid.hh:941
size_t numBoundarySegments() const
Return the number of boundary segments.
Definition: uggrid.hh:336
RefinementType
The different forms of grid refinement that UG supports.
Definition: uggrid.hh:730
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:263
A set of traits classes to store static information about grid implementation.
UGGridFamily< dim > GridFamily
type of the used GridFamily for this grid
Definition: uggrid.hh:279
IdSet< const GridImp, LocalIdSetImp, LIDType > LocalIdSet
The type of the local id set.
Definition: common/grid.hh:1137
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1026
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: common/capabilities.hh:55
IndexType size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:220
int size(int codim) const
number of leaf entities per codim in this process
Definition: uggrid.hh:318
ClosureType
Decide whether to add a green closure to locally refined grid sections or not.
Definition: uggrid.hh:738
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: uggrid.hh:324
@ GREEN
Standard red/green refinement.
Definition: uggrid.hh:740
const CollectiveCommunication< UGGrid > & comm() const
Definition: uggrid.hh:571
IndexSet< const GridImp, LeafIndexSetImp > LeafIndexSet
The type of the leaf index set.
Definition: common/grid.hh:1133
UGGridFamily< dim >::Traits Traits
Definition: uggrid.hh:282
static const bool v
Definition: common/capabilities.hh:73
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Query whether element is marked for refinement.
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
void saveState(const std::string &filename) const
Save entire grid hierarchy to disk.
@ All_All_Interface
send all and receive all entities
Definition: gridenums.hh:89
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: uggrid.hh:363
@ NONE
No closure, results in nonconforming meshes.
Definition: uggrid.hh:742
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, CollectiveCommunication< Dune::UGGrid< dim > >, UGGridLevelGridViewTraits, UGGridLeafGridViewTraits, UGGridEntitySeed, UGGridLocalGeometry > Traits
Definition: uggrid.hh:182
@ LOCAL
New level consists only of the refined elements and the closure.
Definition: uggrid.hh:732
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.
friend class UGGridLeafGridView
Definition: uggrid.hh:251
Base class for grid boundary segments of arbitrary geometry.
bool loadBalance(DataHandle &dataHandle)
Distributes the grid and some data over the available nodes in a distributed machine.
Definition: uggrid.hh:466
unsigned int Rank
The type used for process ranks.
Definition: uggrid.hh:288
UGGridFamily< dim > ::Traits Traits
The traits of this class.
Definition: common/grid.hh:864
Front-end for the grid manager of the finite element toolbox UG.
Definition: uggrid.hh:230
Grid view abstract base class.
Definition: common/gridview.hh:59
@ InteriorBorder_InteriorBorder_Interface
send/receive interior and border entities
Definition: gridenums.hh:85
static const bool v
Definition: common/capabilities.hh:114
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition: uggrid.hh:330
void postAdapt()
Clean up refinement markers.
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: uggrid.hh:343
Include standard header files.
Definition: agrid.hh:58
static const bool v
Definition: common/capabilities.hh:105
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: uggrid.hh:349
UGGrid()
Default constructor.
friend class UGGridLeafIterator
Definition: uggrid.hh:262
Definition: common/geometry.hh:24
friend class UGGridLevelIterator
Definition: uggrid.hh:264
Definition: uggrid.hh:159
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168