/usr/include/dune/grid/onedgrid.hh is in libdune-grid-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | #ifndef DUNE_ONE_D_GRID_HH
#define DUNE_ONE_D_GRID_HH
#include <vector>
#include <list>
#include <dune/common/misc.hh>
#include <dune/common/collectivecommunication.hh>
#include <dune/common/tuples.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/common/grid.hh>
#include <dune/grid/common/gridfactory.hh>
#include <dune/geometry/genericgeometry/topologytypes.hh>
/** \file
* \brief The OneDGrid class
*/
#include "onedgrid/onedgridlist.hh"
#include "onedgrid/nulliteratorfactory.hh"
#include "onedgrid/onedgridentity.hh"
#include "onedgrid/onedgridentitypointer.hh"
#include "onedgrid/onedgridentityseed.hh"
#include "onedgrid/onedgridgeometry.hh"
#include "onedgrid/onedgridintersections.hh"
#include "onedgrid/onedgridintersectioniterators.hh"
#include "onedgrid/onedgridleveliterator.hh"
#include "onedgrid/onedgridleafiterator.hh"
#include "onedgrid/onedgridhieriterator.hh"
#include "onedgrid/onedgridindexsets.hh"
namespace Dune {
class OneDGrid;
template<int dim, int dimw>
struct OneDGridFamily
{
typedef GridTraits<dim,dimw,Dune::OneDGrid,
OneDGridGeometry,
OneDGridEntity,
OneDGridEntityPointer,
OneDGridLevelIterator,
OneDGridLeafIntersection,
OneDGridLevelIntersection,
OneDGridLeafIntersectionIterator,
OneDGridLevelIntersectionIterator,
OneDGridHierarchicIterator,
OneDGridLeafIterator,
OneDGridLevelIndexSet<const OneDGrid>,
OneDGridLeafIndexSet<const OneDGrid>,
OneDGridIdSet<const OneDGrid>,
unsigned int,
OneDGridIdSet<const OneDGrid>,
unsigned int,
CollectiveCommunication<Dune::OneDGrid>,
DefaultLevelGridViewTraits,
DefaultLeafGridViewTraits,
OneDGridEntitySeed>
Traits;
};
//**********************************************************************
//
// --OneDGrid
//
//**********************************************************************
/**
\brief One-dimensional adaptive grid
[<em> provides \ref Dune::Grid </em>]
\ingroup GridImplementations
This implementation of the grid interface provides one-dimensional
grids only. The OneDGrid can be nonuniform
and provides local mesh refinement and coarsening.
*/
class OneDGrid : public GridDefaultImplementation <1, 1,double,OneDGridFamily<1,1> >
{
// Grid and world dimension are hardwired in this grid
enum {dim = 1};
enum {dimworld = 1};
template <int, class >
friend class OneDGridEntityPointer;
template <int , PartitionIteratorType, class >
friend class OneDGridLevelIterator;
friend class OneDGridHierarchicIterator<const OneDGrid>;
template <int codim_, int dim_, class GridImp_>
friend class OneDGridEntity;
friend class OneDGridHierarchicIterator<OneDGrid>;
friend class OneDGridLeafIntersection<const OneDGrid>;
friend class OneDGridLevelIntersection<const OneDGrid>;
friend class OneDGridLeafIntersectionIterator<const OneDGrid>;
friend class OneDGridLevelIntersectionIterator<const OneDGrid>;
friend class OneDGridLevelIndexSet<const OneDGrid>;
friend class OneDGridLeafIndexSet<const OneDGrid>;
friend class OneDGridIdSet<const OneDGrid>;
template <int codim_, PartitionIteratorType PiType_, class GridImp_>
friend class OneDGridLeafIterator;
template <class GridType_>
friend class GridFactory;
template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
friend class Entity;
/** \brief Default constructor for the GridFactory */
OneDGrid();
// **********************************************************
// The Interface Methods
// **********************************************************
public:
/** \brief The type used to store coordinates
If you ever want OneDGrid to use a different type for coordinates,
you need to change this type and the third template argument of
the base class.
*/
typedef double ctype;
/** \brief GridFamily of OneDGrid */
typedef OneDGridFamily<dim,dimworld> GridFamily;
//Provides the standard grid types
typedef OneDGridFamily<dim,dimworld>::Traits Traits;
/** \brief Constructor with an explicit set of coordinates */
OneDGrid(const std::vector<ctype>& coords);
/** \brief Constructor for a uniform grid */
OneDGrid(int numElements, const ctype& leftBoundary, const ctype& rightBoundary);
//! Destructor
~OneDGrid();
/** \brief Return maximum level defined in this grid.
Levels are numbered 0 ... maxlevel with 0 the coarsest level.
*/
int maxLevel() const {return entityImps_.size()-1;}
//! Iterator to first entity of given codim on level
template<int codim>
typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const;
//! one past the end on this level
template<int codim>
typename Traits::template Codim<codim>::LevelIterator lend (int level) const;
//! Iterator to first entity of given codim on level
template<int codim, PartitionIteratorType PiType>
typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const;
//! one past the end on this level
template<int codim, PartitionIteratorType PiType>
typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const;
//! Iterator to first entity of given codim on leaf level
template<int codim>
typename Traits::template Codim<codim>::LeafIterator leafbegin () const;
//! one past the end on leaf level
template<int codim>
typename Traits::template Codim<codim>::LeafIterator leafend () const;
//! Iterator to first entity of given codim on level
template<int codim, PartitionIteratorType PiType>
typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const;
//! one past the end on this level
template<int codim, PartitionIteratorType PiType>
typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const;
/** \brief Create an EntityPointer from an EntitySeed */
template <int codim>
static typename Traits::template Codim<codim>::EntityPointer
entityPointer(const OneDGridEntitySeed<codim, const OneDGrid>& seed)
{
return typename Traits::template Codim<codim>::EntityPointer(seed.target());
}
/** \brief Number of grid entities per level and codim
*/
int size (int level, int codim) const {
if (codim<0 || codim>1)
DUNE_THROW(GridError, "There are no codim " << codim << " entities in a OneDGrid!");
if (codim==0)
return elements(level).size();
return vertices(level).size();
}
//! number of leaf entities per codim in this process
int size (int codim) const
{
return leafIndexSet().size(codim);
}
//! number of entities per level and geometry type in this process
int size (int level, GeometryType type) const
{
// There is only one type for each codim
return size(level,1-type.dim());
}
//! number of leaf entities per geometry type in this process
int size (GeometryType type) const
{
return leafIndexSet().size(type);
}
/** \brief Return the number of coarse grid boundary segments.
For this grid implementation, the return value is always 2, because only connected domains
are supported, and then the coarse grid boundary consists of two points.
*/
size_t numBoundarySegments() const
{
return 2;
}
/** \brief The processor overlap for parallel computing. Always zero because
this is a strictly sequential grid */
int overlapSize(int codim) const {
return 0;
}
/** \brief The processor ghost overlap for parallel computing. Always zero because
this is a strictly sequential grid */
int ghostSize(int codim) const {
return 0;
}
/** \brief The processor overlap for parallel computing. Always zero because
this is a strictly sequential grid */
int overlapSize(int level, int codim) const {
return 0;
}
/** \brief The processor ghost overlap for parallel computing. Always zero because
this is a strictly sequential grid */
int ghostSize(int level, int codim) const {
return 0;
}
/** \brief Get the set of global ids */
const Traits::GlobalIdSet& globalIdSet() const
{
return idSet_;
}
/** \brief Get the set of local ids */
const Traits::LocalIdSet& localIdSet() const
{
return idSet_;
}
/** \brief Get an index set for the given level */
const Traits::LevelIndexSet& levelIndexSet(int level) const
{
if (! levelIndexSets_[level]) {
levelIndexSets_[level] =
new OneDGridLevelIndexSet<const OneDGrid>(*this, level);
levelIndexSets_[level]->update();
}
return * levelIndexSets_[level];
}
/** \brief Get an index set for the leaf level */
const Traits::LeafIndexSet& leafIndexSet() const
{
return leafIndexSet_;
}
/** \brief Mark entity for refinement
*
* \param refCount if >0 mark for refinement, if <0 mark for coarsening
* \param e Entity to the entity you want to mark
*
* \return True, if marking was successfull
*/
bool mark(int refCount, const Traits::Codim<0>::Entity& e );
/** \brief return current adaptation marker of given entity
\param e Entity to the entity you want to mark
\return int current adaptation marker of entity pointer e
*/
int getMark(const Traits::Codim<0>::Entity& e ) const;
//! Does nothing except return true if some element has been marked for refinement
bool preAdapt();
//! Triggers the grid refinement process
bool adapt();
/** \brief Adaptation post-processing: Reset all adaptation state flags */
void postAdapt();
// **********************************************************
// End of Interface Methods
// **********************************************************
/** \brief The different forms of grid refinement supported by OneDGrid */
enum RefinementType {
/** \brief New level consists only of the refined elements */
LOCAL,
/** \brief New level consists of the refined elements and the unrefined ones, too */
COPY};
/** \brief Sets the type of grid refinement */
void setRefinementType(RefinementType type) {
refinementType_ = type;
}
/** \brief Does one uniform refinement step
*
* \param refCount I don't know what this is good for. It doesn't
* actually do anything.
*/
void globalRefine(int refCount);
// dummy parallel functions
template<class DataHandle>
void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
{
}
template<class DataHandle>
void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
{
}
const CollectiveCommunication &comm () const
{
return ccobj;
}
private:
/** \brief Get vertex lists directly -- makes the code more readable */
OneDGridList<OneDEntityImp<0> >& vertices(int level) {
return Dune::get<0>(entityImps_[level]);
}
/** \brief Get vertex lists directly -- makes the code more readable */
const OneDGridList<OneDEntityImp<0> >& vertices(int level) const {
return Dune::get<0>(entityImps_[level]);
}
/** \brief Get element lists directly -- makes the code more readable */
OneDGridList<OneDEntityImp<1> >& elements(int level) {
return Dune::get<1>(entityImps_[level]);
}
/** \brief Get element lists directly -- makes the code more readable */
const OneDGridList<OneDEntityImp<1> >& elements(int level) const {
return Dune::get<1>(entityImps_[level]);
}
CollectiveCommunication ccobj;
/** \brief Update all indices and ids */
void setIndices();
unsigned int getNextFreeId(int codim) {
return (codim==0) ? freeElementIdCounter_++ : freeVertexIdCounter_++;
}
//! The type of grid refinement currently in use
RefinementType refinementType_;
OneDGridList<OneDEntityImp<0> >::iterator getLeftUpperVertex(const OneDEntityImp<1>* eIt);
OneDGridList<OneDEntityImp<0> >::iterator getRightUpperVertex(const OneDEntityImp<1>* eIt);
/** \brief Returns an iterator to the first element on the left of
the input element which has sons.
*/
OneDGridList<OneDEntityImp<1> >::iterator getLeftNeighborWithSon(OneDGridList<OneDEntityImp<1> >::iterator eIt);
// The vertices and elements of the grid hierarchy
std::vector<tuple<OneDGridList<OneDEntityImp<0> >,
OneDGridList<OneDEntityImp<1> > > > entityImps_;
// Our set of level indices
mutable std::vector<OneDGridLevelIndexSet<const OneDGrid>* > levelIndexSets_;
OneDGridLeafIndexSet<const OneDGrid> leafIndexSet_;
OneDGridIdSet<const OneDGrid> idSet_;
unsigned int freeVertexIdCounter_;
unsigned int freeElementIdCounter_;
/** Since a OneDGrid is one-dimensional and connected, there can only be two possible numberings
of the boundary segments. Either the left one is '0' and the right one is '1' or the reverse.
This flag stores which is the case. */
bool reversedBoundarySegmentNumbering_;
}; // end Class OneDGrid
namespace Capabilities
{
/** \struct hasBackupRestoreFacilities
\ingroup OneDGrid
*/
/** \struct IsUnstructured
\ingroup OneDGrid
*/
/** \brief OneDGrid has only one geometry type for codim 0 entities
\ingroup OneDGrid
*/
template< >
struct hasSingleGeometryType< OneDGrid >
{
static const bool v = true;
static const unsigned int topologyId = GenericGeometry :: CubeTopology< 1 > :: type :: id ;
};
/** \brief OneDGrid has entities for all codimension
\ingroup OneDGrid
*/
template<int cdim>
struct hasEntity< OneDGrid, cdim >
{
static const bool v = true;
};
/** \brief OneDGrid is not parallel
\ingroup OneDGrid
*/
template<>
struct isParallel< OneDGrid >
{
static const bool v = false;
};
/** \brief OneDGrid is levelwise conforming
\ingroup OneDGrid
*/
template<>
struct isLevelwiseConforming< OneDGrid >
{
static const bool v = true;
};
/** \brief OneDGrid is leafwise conforming
\ingroup OneDGrid
*/
template<>
struct isLeafwiseConforming< OneDGrid >
{
static const bool v = true;
};
}
} // namespace Dune
// Include the GridFactory specialization for OneDGrid, so everybody
// who includes the grid also gets the factory. Since OneDGrid is
// not a template class, it needs to be a complete type before
// GridFactory<OneDGrid> can be defined. This is why the #include-
// directive is at _the end_ of this file.
#include <dune/grid/onedgrid/onedgridfactory.hh>
#endif
|