Dune Core Modules (2.8.0)

onedgrid.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ONE_D_GRID_HH
4#define DUNE_ONE_D_GRID_HH
5
6#include <tuple>
7#include <vector>
8#include <list>
9
11
15
17#include <dune/geometry/type.hh>
18
23#include "onedgrid/onedgridlist.hh"
24#include "onedgrid/nulliteratorfactory.hh"
25#include "onedgrid/onedgridentity.hh"
26#include "onedgrid/onedgridentityseed.hh"
27#include "onedgrid/onedgridintersections.hh"
28#include "onedgrid/onedgridintersectioniterators.hh"
29#include "onedgrid/onedgridleafiterator.hh"
30#include "onedgrid/onedgridviews.hh"
31#include "onedgrid/onedgridleveliterator.hh"
32#include "onedgrid/onedgridhieriterator.hh"
33#include "onedgrid/onedgridindexsets.hh"
34
35namespace Dune {
36
37 class OneDGrid;
38
44 template <int mydim, int coorddim, class GridImp>
46
47 struct OneDGridFamily
48 {
49 typedef GridTraits<1, // Grid dimension
50 1, // Dimension of the physical space
53 OneDGridEntity,
54 OneDGridLevelIterator,
55 OneDGridLeafIntersection,
56 OneDGridLevelIntersection,
57 OneDGridLeafIntersectionIterator,
58 OneDGridLevelIntersectionIterator,
59 OneDGridHierarchicIterator,
60 OneDGridLeafIterator,
61 OneDGridLevelIndexSet<const OneDGrid>,
62 OneDGridLeafIndexSet<const OneDGrid>,
63 OneDGridIdSet<const OneDGrid>,
64 unsigned int,
65 OneDGridIdSet<const OneDGrid>,
66 unsigned int,
68 OneDGridLevelGridViewTraits,
69 OneDGridLeafGridViewTraits,
70 OneDGridEntitySeed>
71 Traits;
72 };
73
74 //**********************************************************************
75 //
76 // --OneDGrid
77 //
78 //**********************************************************************
79
91 class OneDGrid : public GridDefaultImplementation <1, 1,typename OneDGridGeometry<0,1,OneDGrid>::ctype, OneDGridFamily>
92 {
93 // Grid and world dimension are hardwired in this grid
94 enum {dim = 1};
95 enum {dimworld = 1};
96
97 template <int , PartitionIteratorType, class >
98 friend class OneDGridLevelIterator;
99
100 friend class OneDGridHierarchicIterator<const OneDGrid>;
101
102 template <int codim_, int dim_, class GridImp_>
103 friend class OneDGridEntity;
104 friend class OneDGridHierarchicIterator<OneDGrid>;
105 friend class OneDGridLeafIntersection<const OneDGrid>;
106 friend class OneDGridLevelIntersection<const OneDGrid>;
107 friend class OneDGridLeafIntersectionIterator<const OneDGrid>;
108 friend class OneDGridLevelIntersectionIterator<const OneDGrid>;
109
110 friend class OneDGridLevelIndexSet<const OneDGrid>;
111 friend class OneDGridLeafIndexSet<const OneDGrid>;
112 friend class OneDGridIdSet<const OneDGrid>;
113
114 template <int codim_, PartitionIteratorType PiType_, class GridImp_>
115 friend class OneDGridLeafIterator;
116
117 friend class OneDGridLeafGridView<const OneDGrid>;
118 friend class OneDGridLevelGridView<const OneDGrid>;
119
120 template <class GridType_>
121 friend class GridFactory;
122
123 template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
124 friend class Entity;
125
127 OneDGrid();
128
129 // **********************************************************
130 // The Interface Methods
131 // **********************************************************
132
133 public:
134
138
140 typedef OneDGridFamily GridFamily;
141
142 //Provides the standard grid types
144
146 OneDGrid(const std::vector<ctype>& coords);
147
149 OneDGrid(int numElements, const ctype& leftBoundary, const ctype& rightBoundary);
150
153
158 int maxLevel() const {return entityImps_.size()-1;}
159
161 template <typename Seed>
162 static typename Traits::template Codim<Seed::codimension>::Entity
163 entity(const Seed& seed)
164 {
165 const int codim = Seed::codimension;
166 return typename Traits::template Codim<codim>::Entity(OneDGridEntity<codim,dim,const OneDGrid>(seed.impl().target()));
167 }
168
169
172 int size (int level, int codim) const {
173 switch (codim)
174 {
175 case 0:
176 return elements(level).size();
177 case 1:
178 return vertices(level).size();
179 default:
180 return 0;
181 }
182 }
183
184
185
187 int size (int codim) const
188 {
189 return leafIndexSet().size(codim);
190 }
191
193 int size (int level, GeometryType type) const
194 {
195 // There is only one type for each codim
196 return size(level,1-type.dim());
197 }
198
200 int size (GeometryType type) const
201 {
202 return leafIndexSet().size(type);
203 }
204
210 size_t numBoundarySegments() const
211 {
212 return 2;
213 }
214
217 {
218 return idSet_;
219 }
220
223 {
224 return idSet_;
225 }
226
228 const Traits::LevelIndexSet& levelIndexSet(int level) const
229 {
230 if (! levelIndexSets_[level]) {
231 levelIndexSets_[level] =
232 new OneDGridLevelIndexSet<const OneDGrid>(*this, level);
233 levelIndexSets_[level]->update();
234 }
235
236 return * levelIndexSets_[level];
237 }
238
241 {
242 return leafIndexSet_;
243 }
244
245
253 bool mark(int refCount, const Traits::Codim<0>::Entity& e );
254
261 int getMark(const Traits::Codim<0>::Entity& e ) const;
262
264 bool preAdapt();
265
267 bool adapt();
268
270 void postAdapt();
271
272 // **********************************************************
273 // End of Interface Methods
274 // **********************************************************
275
281 COPY
282 };
283
286 refinementType_ = type;
287 }
288
294 void globalRefine(int refCount);
295
296 // dummy parallel functions
297
298 const CollectiveCommunication &comm () const
299 {
300 return ccobj;
301 }
302
303
304 private:
305
307 OneDGridList<OneDEntityImp<0> >& vertices(int level) {
308 return std::get<0>(entityImps_[level]);
309 }
310
312 const OneDGridList<OneDEntityImp<0> >& vertices(int level) const {
313 return std::get<0>(entityImps_[level]);
314 }
315
317 OneDGridList<OneDEntityImp<1> >& elements(int level) {
318 return std::get<1>(entityImps_[level]);
319 }
320
322 const OneDGridList<OneDEntityImp<1> >& elements(int level) const {
323 return std::get<1>(entityImps_[level]);
324 }
325
327
329 void setIndices();
330
333 unsigned int getNextFreeId()
334 {
335 return freeIdCounter_++;
336 }
337
339 RefinementType refinementType_;
340
341 OneDGridList<OneDEntityImp<0> >::iterator getLeftUpperVertex(const OneDEntityImp<1>* eIt);
342
343 OneDGridList<OneDEntityImp<0> >::iterator getRightUpperVertex(const OneDEntityImp<1>* eIt);
344
348 OneDGridList<OneDEntityImp<1> >::iterator getLeftNeighborWithSon(OneDGridList<OneDEntityImp<1> >::iterator eIt);
349
350 // The vertices and elements of the grid hierarchy
351 std::vector<std::tuple<OneDGridList<OneDEntityImp<0> >,
352 OneDGridList<OneDEntityImp<1> > > > entityImps_;
353
354 // Our set of level indices
355 mutable std::vector<OneDGridLevelIndexSet<const OneDGrid>* > levelIndexSets_;
356
357 OneDGridLeafIndexSet<const OneDGrid> leafIndexSet_;
358
359 OneDGridIdSet<const OneDGrid> idSet_;
360
361 // Every entity gets a unique id, unless it is a copy of an entity on a coarser level.
362 // This is the counter that we use to create the unique id.
363 unsigned int freeIdCounter_;
364
368 bool reversedBoundarySegmentNumbering_;
369
370 }; // end Class OneDGrid
371
372 namespace Capabilities
373 {
385 template< >
387 {
388 static const bool v = true;
389 static const unsigned int topologyId = GeometryTypes::cube(1).id();
390 };
391
392
396 template<int cdim>
397 struct hasEntity< OneDGrid, cdim >
398 {
399 static const bool v = true;
400 };
401
406 template<int codim>
408 {
409 static const bool v = true;
410 };
411
415 template<>
417 {
418 static const bool v = true;
419 };
420
424 template<>
426 {
427 static const bool v = true;
428 };
429
430 }
431
432} // namespace Dune
433
434// Include the GridFactory specialization for OneDGrid, so everybody
435// who includes the grid also gets the factory. Since OneDGrid is
436// not a template class, it needs to be a complete type before
437// GridFactory<OneDGrid> can be defined. This is why the #include-
438// directive is at _the end_ of this file.
439#include <dune/grid/onedgrid/onedgridfactory.hh>
440
441
442#endif
A geometry implementation for axis-aligned hypercubes.
A geometry implementation for axis-aligned hypercubes.
Definition: axisalignedcubegeometry.hh:48
CoordType ctype
Type used for single coordinate coefficients.
Definition: axisalignedcubegeometry.hh:60
Wrapper class for entities.
Definition: entity.hh:64
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
constexpr unsigned int dim() const
Return dimension of the type.
Definition: type.hh:369
constexpr unsigned int id() const
Return the topology id of the type.
Definition: type.hh:374
Definition: grid.hh:851
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:312
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition: grid.hh:518
Id Set Interface.
Definition: indexidset.hh:450
Index Set Interface base class.
Definition: indexidset.hh:76
auto size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: indexidset.hh:221
One-dimensional adaptive grid.
Definition: onedgrid.hh:92
OneDGridGeometry< 0, 1, OneDGrid >::ctype ctype
The type used to store coordinates.
Definition: onedgrid.hh:137
const Traits::LevelIndexSet & levelIndexSet(int level) const
Get an index set for the given level.
Definition: onedgrid.hh:228
bool preAdapt()
Does nothing except return true if some element has been marked for refinement.
const Traits::LocalIdSet & localIdSet() const
Get the set of local ids.
Definition: onedgrid.hh:222
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition: onedgrid.hh:200
OneDGrid(const std::vector< ctype > &coords)
Constructor with an explicit set of coordinates.
void postAdapt()
Adaptation post-processing: Reset all adaptation state flags.
bool adapt()
Triggers the grid refinement process.
RefinementType
The different forms of grid refinement supported by OneDGrid.
Definition: onedgrid.hh:277
@ COPY
New level consists of the refined elements and the unrefined ones, too.
Definition: onedgrid.hh:281
@ LOCAL
New level consists only of the refined elements.
Definition: onedgrid.hh:279
size_t numBoundarySegments() const
Return the number of coarse grid boundary segments.
Definition: onedgrid.hh:210
~OneDGrid()
Destructor.
bool mark(int refCount, const Traits::Codim< 0 >::Entity &e)
Mark entity for refinement.
void setRefinementType(RefinementType type)
Sets the type of grid refinement.
Definition: onedgrid.hh:285
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: onedgrid.hh:193
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: onedgrid.hh:172
OneDGrid(int numElements, const ctype &leftBoundary, const ctype &rightBoundary)
Constructor for a uniform grid.
const Traits::LeafIndexSet & leafIndexSet() const
Get an index set for the leaf level.
Definition: onedgrid.hh:240
const Traits::GlobalIdSet & globalIdSet() const
Get the set of global ids.
Definition: onedgrid.hh:216
static Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed)
Create an Entity from an EntitySeed.
Definition: onedgrid.hh:163
int size(int codim) const
number of leaf entities per codim in this process
Definition: onedgrid.hh:187
OneDGridFamily GridFamily
GridFamily of OneDGrid.
Definition: onedgrid.hh:140
int maxLevel() const
Return maximum level defined in this grid.
Definition: onedgrid.hh:158
int getMark(const Traits::Codim< 0 >::Entity &e) const
return current adaptation marker of given entity
void globalRefine(int refCount)
Does one uniform refinement step.
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
Provide a generic factory class for unstructured grids.
Implements an utility class that provides collective communication methods for sequential programs.
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:470
Dune namespace.
Definition: alignedallocator.hh:11
AxisAlignedCubeGeometry< double, mydim, coorddim > OneDGridGeometry
The type used to for OneDGrid geometries.
Definition: onedgrid.hh:45
specialize with 'true' for all codims that a grid provides an iterator for (default=hasEntity<codim>:...
Definition: capabilities.hh:72
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:56
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:25
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:113
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:104
Static tag representing a codimension.
Definition: dimension.hh:22
Traits associated with a specific codim.
Definition: grid.hh:1006
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:984
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)