15#include <dune/common/classname.hh>
16#include <dune/common/parallel/communication.hh>
17#include <dune/common/exceptions.hh>
18#include <dune/common/parallel/mpihelper.hh>
20#include <dune-grid-config.hh>
25#if HAVE_DUNE_UGGRID || DOXYGEN
28#include <dune/common/parallel/mpicommunication.hh>
56#include "uggrid/ugincludes.hh"
57#undef DUNE_UGINCLUDES_HH
62#include "uggrid/ugwrapper.hh"
67#include "uggrid/ug_undefs.hh"
87#include "uggrid/ugincludes.hh"
88#undef DUNE_UGINCLUDES_HH
93#include "uggrid/ugwrapper.hh"
97#include "uggrid/ug_undefs.hh"
103#include "uggrid/uggridgeometry.hh"
104#include "uggrid/uggridlocalgeometry.hh"
105#include "uggrid/uggridentity.hh"
106#include "uggrid/uggridentityseed.hh"
107#include "uggrid/uggridintersections.hh"
108#include "uggrid/uggridintersectioniterators.hh"
109#include "uggrid/uggridleveliterator.hh"
110#include "uggrid/uggridleafiterator.hh"
111#include "uggrid/uggridhieriterator.hh"
112#include "uggrid/uggridindexsets.hh"
113#include <dune/grid/uggrid/uggridviews.hh>
115#include "uggrid/ugmessagebuffer.hh"
116#include "uggrid/uglbgatherscatter.hh"
123template <
class DataHandle,
int Gr
idDim,
int codim>
126template <
class DataHandle,
int Gr
idDim,
int codim>
127DataHandle *Dune::UGMessageBuffer<DataHandle,GridDim,codim>::duneDataHandle_ =
nullptr;
129template <
class DataHandle,
int Gr
idDim,
int codim>
130int Dune::UGMessageBuffer<DataHandle,GridDim,codim>::level = -1;
148 UGGridLeafIntersection,
149 UGGridLevelIntersection,
150 UGGridLeafIntersectionIterator,
151 UGGridLevelIntersectionIterator,
152 UGGridHierarchicIterator,
154 UGGridLevelIndexSet< const UGGrid<dim> >,
155 UGGridLeafIndexSet< const UGGrid<dim> >,
156 UGGridIdSet< const UGGrid<dim> >,
157 typename UG_NS<dim>::UG_ID_TYPE,
158 UGGridIdSet< const UGGrid<dim> >,
159 typename UG_NS<dim>::UG_ID_TYPE,
161 UGGridLevelGridViewTraits,
162 UGGridLeafGridViewTraits,
229 template <
class Gr
idImp_>
231 template <
class Gr
idImp_>
240 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
242 template <
int codim_, PartitionIteratorType PiType_,
class Gr
idImp_>
246 static_assert(dim==2 || dim==3,
"Use UGGrid only for 2d and 3d!");
285 const int codim = Seed::codimension;
291 int size (
int level,
int codim)
const;
300 int size (
int level, GeometryType type)
const
306 int size (GeometryType type)
const
315 return numBoundarySegments_;
335 return *levelIndexSets_[level];
341 return leafIndexSet_;
441 template<
class DataHandle>
520 template<
class DataHandle>
558 template <
int codim,
class Gr
idView,
class DataHandle>
559 void communicateUG_(
const GridView& gv,
int level,
560 DataHandle &dataHandle,
564 typename UG_NS<dim>::DDD_IF_DIR ugIfDir;
567 ugIfDir = UG_NS<dim>::IF_FORWARD();
569 ugIfDir = UG_NS<dim>::IF_BACKWARD();
571 typedef UGMessageBuffer<DataHandle,dim,codim> UGMsgBuf;
572 UGMsgBuf::duneDataHandle_ = &dataHandle;
574 UGMsgBuf::level = level;
576 std::vector<typename UG_NS<dim>::DDD_IF> ugIfs = findDDDInterfaces(iftype, codim);
578 unsigned bufSize = UGMsgBuf::ugBufferSize(gv);
581 UGMsgBuf::grid_ =
this;
582 for (
unsigned i=0; i < ugIfs.size(); ++i)
583 UG_NS<dim>::DDD_IFOneway(multigrid_->dddContext(),
587 &UGMsgBuf::ugGather_,
588 &UGMsgBuf::ugScatter_);
592 std::vector<typename UG_NS<dim>::DDD_IF> findDDDInterfaces(
InterfaceType iftype,
631 refinementType_ = type;
683 std::vector<std::shared_ptr<UGGridLevelIndexSet<const UGGrid<dim> > > > levelIndexSets_;
704 static int numOfUGGrids;
711 bool someElementHasBeenMarkedForRefinement_;
718 bool someElementHasBeenMarkedForCoarsening_;
721 std::vector<std::shared_ptr<BoundarySegment<dim> > > boundarySegments_;
728 unsigned int numBoundarySegments_;
732 namespace Capabilities
749 template<
int dim,
int codim>
752 static const bool v =
true;
760 template<
int dim,
int codim>
763 static const bool v =
false;
773 static const bool v =
true;
783 static const bool v =
true;
789 template<
int dim,
int codim>
792 static const bool v = (codim>=0 && codim<=dim);
801 static const bool v =
true;
810 static const bool v =
false;
818 static const bool v =
true;
Base class for grid boundary segments of arbitrary geometry.
The specialization of the generic GridFactory for UGGrid.
CommunicationDirection
Define a type for communication direction parameter.
Definition gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition gridenums.hh:86
@ ForwardCommunication
communicate as given in InterfaceType
Definition gridenums.hh:171
Include standard header files.
Definition agrid.hh:60
Communication< No_Comm > UGCommunication
Definition uggrid.hh:138
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition common/capabilities.hh:58
static const bool v
Definition common/capabilities.hh:59
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition common/capabilities.hh:74
static const bool v
Definition common/capabilities.hh:75
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition common/capabilities.hh:97
static const bool v
Definition common/capabilities.hh:98
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition common/capabilities.hh:106
static const bool v
Definition common/capabilities.hh:107
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition common/capabilities.hh:115
static const bool v
Definition common/capabilities.hh:116
Specialize with 'true' if the grid implementation is thread safe, while it is not modified....
Definition common/capabilities.hh:169
static const bool v
Definition common/capabilities.hh:170
Wrapper class for entities.
Definition common/entity.hh:66
Base class for exceptions in Dune grid modules.
Definition exceptions.hh:20
Definition common/grid.hh:848
Traits::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition common/grid.hh:868
bool loadBalance()
default implementation of load balance does nothing and returns false
Definition common/grid.hh:962
A Traits struct that collects all associated types of one implementation.
Definition common/grid.hh:411
A traits struct that collects all associated types of one grid model.
Definition common/grid.hh:1013
Traits associated with a specific codim.
Definition common/grid.hh:1035
Provide a generic factory class for unstructured grids.
Definition common/gridfactory.hh:275
Grid view abstract base class.
Definition common/gridview.hh:66
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, UGCommunication, UGGridLevelGridViewTraits, UGGridLeafGridViewTraits, UGGridEntitySeed, UGGridLocalGeometry > Traits
Definition uggrid.hh:165
Front-end for the grid manager of the finite element toolbox UG3.
Definition uggrid.hh:208
void postAdapt()
Clean up refinement markers.
size_t numBoundarySegments() const
Return the number of boundary segments.
Definition uggrid.hh:312
void setRefinementType(RefinementType type)
Sets the type of grid refinement.
Definition uggrid.hh:630
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Query whether element is marked for refinement.
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Mark element for refinement.
friend class UGGridLeafIterator
Definition uggrid.hh:241
bool loadBalance(int minlevel=0)
Distributes this grid over the available nodes in a distributed machine.
~UGGrid() noexcept(false)
Destructor.
UGGridFamily< dim >::Traits Traits
Definition uggrid.hh:261
friend class UGGridLevelIterator
Definition uggrid.hh:243
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:521
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 UGGridLevelGridView
Definition uggrid.hh:232
UGGridFamily< dim > GridFamily
type of the used GridFamily for this grid
Definition uggrid.hh:258
bool loadBalance(const std::vector< Rank > &targetProcessors, unsigned int fromLevel)
Distribute this grid over a distributed machine.
const UGCommunication & comm() const
Definition uggrid.hh:551
bool mark(const typename Traits::template Codim< 0 >::Entity &e, typename UG_NS< dim >::RefinementRule rule, int side=0)
Mark method accepting a UG refinement rule.
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition uggrid.hh:331
void setClosureType(ClosureType type)
Sets the type of grid refinement closure.
Definition uggrid.hh:635
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition uggrid.hh:325
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition uggrid.hh:300
RefinementType
The different forms of grid refinement that UG supports.
Definition uggrid.hh:614
@ COPY
New level consists of the refined elements and the unrefined ones, too.
Definition uggrid.hh:618
@ LOCAL
New level consists only of the refined elements and the closure.
Definition uggrid.hh:616
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition uggrid.hh:306
void setPosition(const typename Traits::template Codim< dim >::Entity &e, const FieldVector< double, dim > &pos)
Sets a vertex to a new position.
int size(int level, int codim) const
Number of grid entities per level and codim.
UG::DOUBLE ctype
The type used to store coordinates.
Definition uggrid.hh:264
bool adapt()
Triggers the grid refinement process.
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition uggrid.hh:319
friend class UGGridLeafGridView
Definition uggrid.hh:230
void loadState(const std::string &filename)
Read entire grid hierarchy from disk.
bool loadBalance(DataHandle &dataHandle)
Distributes the grid and some data over the available nodes in a distributed machine.
Definition uggrid.hh:442
Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed) const
Create an Entity from an EntitySeed.
Definition uggrid.hh:283
unsigned int Rank
The type used for process ranks.
Definition uggrid.hh:267
void saveState(const std::string &filename) const
Save entire grid hierarchy to disk.
bool preAdapt()
returns true, if some elements might be coarsend during grid adaption, here always returns true
void globalRefine(int n)
Does uniform refinement.
UGGrid(UGCommunication comm={})
Default constructor.
ClosureType
Decide whether to add a green closure to locally refined grid sections or not.
Definition uggrid.hh:622
@ GREEN
Standard red/green refinement.
Definition uggrid.hh:624
@ NONE
No closure, results in nonconforming meshes.
Definition uggrid.hh:626
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition uggrid.hh:339
int size(int codim) const
number of leaf entities per codim in this process
Definition uggrid.hh:294
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.