Dune Core Modules (2.4.2)

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 <vector>
7#include <list>
8
11#include <dune/common/tuples.hh>
12
16
17#include <dune/geometry/genericgeometry/topologytypes.hh>
18
23#include "onedgrid/onedgridlist.hh"
24#include "onedgrid/nulliteratorfactory.hh"
25#include "onedgrid/onedgridentity.hh"
26#include "onedgrid/onedgridentitypointer.hh"
27#include "onedgrid/onedgridentityseed.hh"
28#include "onedgrid/onedgridgeometry.hh"
29#include "onedgrid/onedgridintersections.hh"
30#include "onedgrid/onedgridintersectioniterators.hh"
31#include "onedgrid/onedgridleveliterator.hh"
32#include "onedgrid/onedgridleafiterator.hh"
33#include "onedgrid/onedgridhieriterator.hh"
34#include "onedgrid/onedgridindexsets.hh"
35
36namespace Dune {
37
38 class OneDGrid;
39
40 template<int dim, int dimw>
41 struct OneDGridFamily
42 {
43 typedef GridTraits<dim,dimw,Dune::OneDGrid,
44 OneDGridGeometry,
45 OneDGridEntity,
46 OneDGridEntityPointer,
47 OneDGridLevelIterator,
48 OneDGridLeafIntersection,
49 OneDGridLevelIntersection,
50 OneDGridLeafIntersectionIterator,
51 OneDGridLevelIntersectionIterator,
52 OneDGridHierarchicIterator,
53 OneDGridLeafIterator,
54 OneDGridLevelIndexSet<const OneDGrid>,
55 OneDGridLeafIndexSet<const OneDGrid>,
56 OneDGridIdSet<const OneDGrid>,
57 unsigned int,
58 OneDGridIdSet<const OneDGrid>,
59 unsigned int,
60 CollectiveCommunication<Dune::OneDGrid>,
61 DefaultLevelGridViewTraits,
62 DefaultLeafGridViewTraits,
63 OneDGridEntitySeed>
64 Traits;
65 };
66
67 //**********************************************************************
68 //
69 // --OneDGrid
70 //
71 //**********************************************************************
72
84 class OneDGrid : public GridDefaultImplementation <1, 1,double,OneDGridFamily<1,1> >
85 {
86 // Grid and world dimension are hardwired in this grid
87 enum {dim = 1};
88 enum {dimworld = 1};
89
90 template <int, class >
91 friend class OneDGridEntityPointer;
92
93 template <int , PartitionIteratorType, class >
94 friend class OneDGridLevelIterator;
95
96 friend class OneDGridHierarchicIterator<const OneDGrid>;
97
98 template <int codim_, int dim_, class GridImp_>
99 friend class OneDGridEntity;
100 friend class OneDGridHierarchicIterator<OneDGrid>;
101 friend class OneDGridLeafIntersection<const OneDGrid>;
102 friend class OneDGridLevelIntersection<const OneDGrid>;
103 friend class OneDGridLeafIntersectionIterator<const OneDGrid>;
104 friend class OneDGridLevelIntersectionIterator<const OneDGrid>;
105
106 friend class OneDGridLevelIndexSet<const OneDGrid>;
107 friend class OneDGridLeafIndexSet<const OneDGrid>;
108 friend class OneDGridIdSet<const OneDGrid>;
109
110 template <int codim_, PartitionIteratorType PiType_, class GridImp_>
111 friend class OneDGridLeafIterator;
112
113 template <class GridType_>
114 friend class GridFactory;
115
116 template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
117 friend class Entity;
118
120 OneDGrid();
121
122 // **********************************************************
123 // The Interface Methods
124 // **********************************************************
125
126 public:
127
134 typedef double ctype;
135
137 typedef OneDGridFamily<dim,dimworld> GridFamily;
138
139 //Provides the standard grid types
141
143 OneDGrid(const std::vector<ctype>& coords);
144
146 OneDGrid(int numElements, const ctype& leftBoundary, const ctype& rightBoundary);
147
150
155 int maxLevel() const {return entityImps_.size()-1;}
156
158 template<int codim>
159 typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const;
160
162 template<int codim>
163 typename Traits::template Codim<codim>::LevelIterator lend (int level) const;
164
166 template<int codim, PartitionIteratorType PiType>
167 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const;
168
170 template<int codim, PartitionIteratorType PiType>
171 typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const;
172
174 template<int codim>
175 typename Traits::template Codim<codim>::LeafIterator leafbegin () const;
176
178 template<int codim>
179 typename Traits::template Codim<codim>::LeafIterator leafend () const;
180
182 template<int codim, PartitionIteratorType PiType>
183 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const;
184
186 template<int codim, PartitionIteratorType PiType>
187 typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const;
188
190 template <typename Seed>
191 static typename Traits::template Codim<Seed::codimension>::EntityPointer
192 entityPointer(const Seed& seed)
193 {
194 enum {codim = Seed::codimension};
195 return typename Traits::template Codim<codim>::EntityPointer(OneDGridEntityPointer<codim,const OneDGrid>(OneDGrid::getRealImplementation(seed).target()));
196 }
197
199 template <typename Seed>
200 static typename Traits::template Codim<Seed::codimension>::Entity
201 entity(const Seed& seed)
202 {
203 const int codim = Seed::codimension;
204 return typename Traits::template Codim<codim>::Entity(OneDGridEntity<codim,dim,const OneDGrid>(OneDGrid::getRealImplementation(seed).target()));
205 }
206
207
210 int size (int level, int codim) const {
211 if (codim<0 || codim>1)
212 DUNE_THROW(GridError, "There are no codim " << codim << " entities in a OneDGrid!");
213
214 if (codim==0)
215 return elements(level).size();
216
217 return vertices(level).size();
218 }
219
220
221
223 int size (int codim) const
224 {
225 return leafIndexSet().size(codim);
226 }
227
229 int size (int level, GeometryType type) const
230 {
231 // There is only one type for each codim
232 return size(level,1-type.dim());
233 }
234
236 int size (GeometryType type) const
237 {
238 return leafIndexSet().size(type);
239 }
240
246 size_t numBoundarySegments() const
247 {
248 return 2;
249 }
250
253 int overlapSize(int codim) const {
254 return 0;
255 }
256
259 int ghostSize(int codim) const {
260 return 0;
261 }
262
265 int overlapSize(int level, int codim) const {
266 return 0;
267 }
268
271 int ghostSize(int level, int codim) const {
272 return 0;
273 }
274
277 {
278 return idSet_;
279 }
280
283 {
284 return idSet_;
285 }
286
288 const Traits::LevelIndexSet& levelIndexSet(int level) const
289 {
290 if (! levelIndexSets_[level]) {
291 levelIndexSets_[level] =
292 new OneDGridLevelIndexSet<const OneDGrid>(*this, level);
293 levelIndexSets_[level]->update();
294 }
295
296 return * levelIndexSets_[level];
297 }
298
301 {
302 return leafIndexSet_;
303 }
304
305
313 bool mark(int refCount, const Traits::Codim<0>::Entity& e );
314
321 int getMark(const Traits::Codim<0>::Entity& e ) const;
322
324 bool preAdapt();
325
327 bool adapt();
328
330 void postAdapt();
331
332 // **********************************************************
333 // End of Interface Methods
334 // **********************************************************
335
341 COPY
342 };
343
346 refinementType_ = type;
347 }
348
354 void globalRefine(int refCount);
355
356 // dummy parallel functions
357
358 template<class DataHandle>
359 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
360 {}
361
362 template<class DataHandle>
363 void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
364 {}
365
366 const CollectiveCommunication &comm () const
367 {
368 return ccobj;
369 }
370
371
372 private:
373
375 OneDGridList<OneDEntityImp<0> >& vertices(int level) {
376 return Dune::get<0>(entityImps_[level]);
377 }
378
380 const OneDGridList<OneDEntityImp<0> >& vertices(int level) const {
381 return Dune::get<0>(entityImps_[level]);
382 }
383
385 OneDGridList<OneDEntityImp<1> >& elements(int level) {
386 return Dune::get<1>(entityImps_[level]);
387 }
388
390 const OneDGridList<OneDEntityImp<1> >& elements(int level) const {
391 return Dune::get<1>(entityImps_[level]);
392 }
393
395
397 void setIndices();
398
399 unsigned int getNextFreeId(int codim) {
400 return (codim==0) ? freeElementIdCounter_++ : freeVertexIdCounter_++;
401 }
402
404 RefinementType refinementType_;
405
406 OneDGridList<OneDEntityImp<0> >::iterator getLeftUpperVertex(const OneDEntityImp<1>* eIt);
407
408 OneDGridList<OneDEntityImp<0> >::iterator getRightUpperVertex(const OneDEntityImp<1>* eIt);
409
413 OneDGridList<OneDEntityImp<1> >::iterator getLeftNeighborWithSon(OneDGridList<OneDEntityImp<1> >::iterator eIt);
414
415 // The vertices and elements of the grid hierarchy
416 std::vector<tuple<OneDGridList<OneDEntityImp<0> >,
417 OneDGridList<OneDEntityImp<1> > > > entityImps_;
418
419 // Our set of level indices
420 mutable std::vector<OneDGridLevelIndexSet<const OneDGrid>* > levelIndexSets_;
421
422 OneDGridLeafIndexSet<const OneDGrid> leafIndexSet_;
423
424 OneDGridIdSet<const OneDGrid> idSet_;
425
426 unsigned int freeVertexIdCounter_;
427
428 unsigned int freeElementIdCounter_;
429
433 bool reversedBoundarySegmentNumbering_;
434
435 }; // end Class OneDGrid
436
437 namespace Capabilities
438 {
450 template< >
452 {
453 static const bool v = true;
454 static const unsigned int topologyId = GenericGeometry :: CubeTopology< 1 > :: type :: id ;
455 };
456
457
461 template<int cdim>
462 struct hasEntity< OneDGrid, cdim >
463 {
464 static const bool v = true;
465 };
466
470 template<>
471 struct
472#ifndef DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
473 DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.")
474#endif
476 {
477 static const bool
478#ifndef DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
479 DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.")
480#endif
481 v = false;
482 };
483
487 template<>
489 {
490 static const bool v = true;
491 };
492
496 template<>
498 {
499 static const bool v = true;
500 };
501
502 }
503
504} // namespace Dune
505
506// Include the GridFactory specialization for OneDGrid, so everybody
507// who includes the grid also gets the factory. Since OneDGrid is
508// not a template class, it needs to be a complete type before
509// GridFactory<OneDGrid> can be defined. This is why the #include-
510// directive is at _the end_ of this file.
511#include <dune/grid/onedgrid/onedgridfactory.hh>
512
513
514#endif
Wrapper class for entities.
Definition: entity.hh:62
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:321
Definition: grid.hh:1030
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:263
GridFamily::Traits::CollectiveCommunication CollectiveCommunication
A type that is a model of Dune::CollectiveCommunication. It provides a portable way for collective co...
Definition: grid.hh:545
Id Set Interface.
Definition: indexidset.hh:414
Index Set Interface base class.
Definition: indexidset.hh:76
One-dimensional adaptive grid.
Definition: onedgrid.hh:85
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first entity of given codim on level.
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end on this level
const Traits::LevelIndexSet & levelIndexSet(int level) const
Get an index set for the given level.
Definition: onedgrid.hh:288
double ctype
The type used to store coordinates.
Definition: onedgrid.hh:134
bool preAdapt()
Does nothing except return true if some element has been marked for refinement.
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
const Traits::LocalIdSet & localIdSet() const
Get the set of local ids.
Definition: onedgrid.hh:282
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition: onedgrid.hh:236
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:337
@ COPY
New level consists of the refined elements and the unrefined ones, too.
Definition: onedgrid.hh:341
@ LOCAL
New level consists only of the refined elements.
Definition: onedgrid.hh:339
size_t numBoundarySegments() const
Return the number of coarse grid boundary segments.
Definition: onedgrid.hh:246
int ghostSize(int level, int codim) const
The processor ghost overlap for parallel computing. Always zero because this is a strictly sequential...
Definition: onedgrid.hh:271
~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:345
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: onedgrid.hh:229
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: onedgrid.hh:210
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:300
int ghostSize(int codim) const
The processor ghost overlap for parallel computing. Always zero because this is a strictly sequential...
Definition: onedgrid.hh:259
const Traits::GlobalIdSet & globalIdSet() const
Get the set of global ids.
Definition: onedgrid.hh:276
static Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed)
Create an Entity from an EntitySeed.
Definition: onedgrid.hh:201
OneDGridFamily< dim, dimworld > GridFamily
GridFamily of OneDGrid.
Definition: onedgrid.hh:137
int size(int codim) const
number of leaf entities per codim in this process
Definition: onedgrid.hh:223
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
int overlapSize(int level, int codim) const
The processor overlap for parallel computing. Always zero because this is a strictly sequential grid.
Definition: onedgrid.hh:265
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first entity of given codim on leaf level.
int maxLevel() const
Return maximum level defined in this grid.
Definition: onedgrid.hh:155
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end on leaf level
int getMark(const Traits::Codim< 0 >::Entity &e) const
return current adaptation marker of given entity
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
int overlapSize(int codim) const
The processor overlap for parallel computing. Always zero because this is a strictly sequential grid.
Definition: onedgrid.hh:253
void globalRefine(int refCount)
Does one uniform refinement step.
static Traits::template Codim< Seed::codimension >::EntityPointer entityPointer(const Seed &seed)
Create an EntityPointer from an EntitySeed.
Definition: onedgrid.hh:192
Implements an utility class that provides collective communication methods for sequential programs.
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.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< ALU3dGrid< elType
YaspGrid is parallel.
Dune namespace.
Definition: alignment.hh:10
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:27
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:108
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:99
OneDGrid is not parallel.
Definition: onedgrid.hh:476
Static tag representing a codimension.
Definition: dimension.hh:22
Traits associated with a specific codim.
Definition: grid.hh:1366
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:1344
Fallback implementation of the std::tuple class.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)