1 // --------------------------------------------------------------------- 2 // 3 // Copyright (C) 1998 - 2020 by the deal.II authors 4 // 5 // This file is part of the deal.II library. 6 // 7 // The deal.II library is free software; you can use it, redistribute 8 // it, and/or modify it under the terms of the GNU Lesser General 9 // Public License as published by the Free Software Foundation; either 10 // version 2.1 of the License, or (at your option) any later version. 11 // The full text of the license can be found in the file LICENSE.md at 12 // the top level directory of deal.II. 13 // 14 // --------------------------------------------------------------------- 15 16 #ifndef dealii_tria_accessor_h 17 #define dealii_tria_accessor_h 18 19 20 #include <deal.II/base/config.h> 21 22 #include <deal.II/base/bounding_box.h> 23 #include <deal.II/base/exceptions.h> 24 #include <deal.II/base/geometry_info.h> 25 #include <deal.II/base/point.h> 26 27 #include <deal.II/grid/cell_id.h> 28 #include <deal.II/grid/reference_cell.h> 29 #include <deal.II/grid/tria_iterator_base.h> 30 #include <deal.II/grid/tria_iterator_selector.h> 31 32 #include <utility> 33 34 35 DEAL_II_NAMESPACE_OPEN 36 37 // Forward declarations 38 #ifndef DOXYGEN 39 template <int dim, int spacedim> 40 class Triangulation; 41 template <typename Accessor> 42 class TriaRawIterator; 43 template <typename Accessor> 44 class TriaIterator; 45 template <typename Accessor> 46 class TriaActiveIterator; 47 48 template <int dim, int spacedim> 49 class Manifold; 50 #endif 51 52 namespace internal 53 { 54 namespace TriangulationImplementation 55 { 56 class TriaObjects; 57 struct Implementation; 58 } // namespace TriangulationImplementation 59 60 namespace TriaAccessorImplementation 61 { 62 struct Implementation; 63 64 /** 65 * Implementation of a type with which to store the level of an accessor 66 * object. We only need it for the case that <tt>structdim == dim</tt>. 67 * Otherwise, an empty object is sufficient. 68 */ 69 template <int structdim, int dim> 70 struct PresentLevelType 71 { 72 struct type 73 { 74 /** 75 * Default constructor. 76 */ 77 type() = default; 78 79 /** 80 * Dummy constructor. Only level zero is allowed. 81 */ typePresentLevelType::type82 type(const int level) 83 { 84 Assert(level == 0, ExcInternalError()); 85 (void)level; // removes -Wunused-parameter warning in optimized mode 86 } 87 88 /** 89 * Dummy conversion operator. Returns level zero. 90 */ 91 operator int() const 92 { 93 return 0; 94 } 95 96 void 97 operator++() const 98 { 99 Assert(false, ExcInternalError()); 100 } 101 102 void 103 operator--() const 104 { 105 Assert(false, ExcInternalError()); 106 } 107 }; 108 }; 109 110 111 /** 112 * Implementation of a type with which to store the level of an accessor 113 * object. We only need it for the case that <tt>structdim == dim</tt>. 114 * Otherwise, an empty object is sufficient. 115 */ 116 template <int dim> 117 struct PresentLevelType<dim, dim> 118 { 119 using type = int; 120 }; 121 122 } // namespace TriaAccessorImplementation 123 } // namespace internal 124 template <int structdim, int dim, int spacedim> 125 class TriaAccessor; 126 template <int dim, int spacedim> 127 class TriaAccessor<0, dim, spacedim>; 128 template <int spacedim> 129 class TriaAccessor<0, 1, spacedim>; 130 131 // note: the file tria_accessor.templates.h is included at the end of 132 // this file. this includes a lot of templates. originally, this was 133 // only done in debug mode, but led to cyclic reduction problems and 134 // so is now on by default. 135 136 137 /** 138 * A namespace that contains exception classes used by the accessor classes. 139 */ 140 namespace TriaAccessorExceptions 141 { 142 /** 143 * @ingroup Exceptions 144 */ 145 DeclExceptionMsg(ExcCellNotUsed, 146 "The operation you are attempting can only be performed for " 147 "(cell, face, or edge) iterators that point to valid " 148 "objects. These objects need not necessarily be active, " 149 "i.e., have no children, but they need to be part of a " 150 "triangulation. (The objects pointed to by an iterator " 151 "may -- after coarsening -- also be objects that used " 152 "to be part of a triangulation, but are now no longer " 153 "used. Their memory location may have been retained " 154 "for re-use upon the next mesh refinement, but is " 155 "currently unused.)"); 156 /** 157 * The cell is not an 158 * @ref GlossActive "active" 159 * cell, but it already has children. Some operations, like setting 160 * refinement flags or accessing degrees of freedom are only possible on 161 * active cells. 162 * 163 * @ingroup Exceptions 164 */ 165 DeclExceptionMsg(ExcCellNotActive, 166 "The operation you are attempting can only be performed for " 167 "(cell, face, or edge) iterators that point to 'active' " 168 "objects. 'Active' objects are those that do not have " 169 "children (in the case of cells), or that are part of " 170 "an active cell (in the case of faces or edges). However, " 171 "the object on which you are trying the current " 172 "operation is not 'active' in this sense."); 173 /** 174 * Trying to access the children of a cell which is in fact active. 175 * 176 * @ingroup Exceptions 177 */ 178 DeclExceptionMsg(ExcCellHasNoChildren, 179 "The operation you are attempting can only be performed for " 180 "(cell, face, or edge) iterators that have children, " 181 "but the object on which you are trying the current " 182 "operation does not have any."); 183 /** 184 * Trying to access the parent of a cell which is in the coarsest level of 185 * the triangulation. 186 * 187 * @ingroup Exceptions 188 */ 189 DeclExceptionMsg(ExcCellHasNoParent, 190 "The operation you are attempting can only be performed for " 191 "(cell, face, or edge) iterators that have a parent object, " 192 "but the object on which you are trying the current " 193 "operation does not have one -- i.e., it is on the " 194 "coarsest level of the triangulation."); 195 /** 196 * @ingroup Exceptions 197 */ 198 DeclException1(ExcCantSetChildren, 199 int, 200 << "You can only set the child index if the cell does not " 201 << "currently have children registered; or you can clear it. " 202 << "The given index was " << arg1 203 << " (-1 means: clear children)."); 204 /** 205 * @ingroup Exceptions 206 */ 207 template <typename AccessorType> 208 DeclException1(ExcDereferenceInvalidObject, 209 AccessorType, 210 << "You tried to dereference an iterator for which this " 211 << "is not possible. More information on this iterator: " 212 << "index=" << arg1.index() << ", state=" 213 << (arg1.state() == IteratorState::valid ? 214 "valid" : 215 (arg1.state() == IteratorState::past_the_end ? 216 "past_the_end" : 217 "invalid"))); 218 /** 219 * @ingroup Exceptions 220 */ 221 DeclExceptionMsg(ExcCantCompareIterators, 222 "Iterators can only be compared if they point to the same " 223 "triangulation, or if neither of them are associated " 224 "with a triangulation."); 225 // TODO: Write documentation! 226 /** 227 * @ingroup Exceptions 228 */ 229 DeclException0(ExcNeighborIsCoarser); 230 // TODO: Write documentation! 231 /** 232 * @ingroup Exceptions 233 */ 234 DeclException0(ExcNeighborIsNotCoarser); 235 /** 236 * You are trying to access the level of a face, but faces have no inherent 237 * level. The level of a face can only be determined by the level of an 238 * adjacent face, which in turn implies that a face can have several levels. 239 * 240 * @ingroup Exceptions 241 */ 242 DeclException0(ExcFacesHaveNoLevel); 243 /** 244 * You are trying to get the periodic neighbor for a face, which does not 245 * have a periodic neighbor. For more information on this, refer to 246 * @ref GlossPeriodicConstraints "entry for periodic boundaries". 247 * @ingroup Exceptions 248 */ 249 DeclException0(ExcNoPeriodicNeighbor); 250 // TODO: Write documentation! 251 /** 252 * @ingroup Exceptions 253 */ 254 DeclException1( 255 ExcSetOnlyEvenChildren, 256 int, 257 << "You can only set the child index of an even numbered child." 258 << "The number of the child given was " << arg1 << "."); 259 } // namespace TriaAccessorExceptions 260 261 262 /** 263 * A base class for the accessor classes used by TriaRawIterator and derived 264 * classes. 265 * 266 * This class offers only the basic functionality required by the iterators 267 * (stores the necessary data members, offers comparison operators and the 268 * like), but has no functionality to actually dereference data. This is done 269 * in the derived classes. 270 * 271 * In the implementation, the behavior of this class differs between the cases 272 * where <tt>structdim==dim</tt> (cells of a mesh) and 273 * <tt>structdim<dim</tt> (faces and edges). For the latter, #present_level 274 * is always equal to zero and the constructors may not receive a positive 275 * value there. For cells, any level is possible, but only those within the 276 * range of the levels of the Triangulation are reasonable. Furthermore, the 277 * function objects() returns either the container with all cells on the same 278 * level or the container with all objects of this dimension 279 * (<tt>structdim<dim</tt>). 280 * 281 * Some internals of this class are discussed in 282 * @ref IteratorAccessorInternals. 283 * 284 * @ingroup grid 285 * @ingroup Accessors 286 */ 287 template <int structdim, int dim, int spacedim = dim> 288 class TriaAccessorBase 289 { 290 public: 291 /** 292 * Dimension of the space the object represented by this accessor lives in. 293 * For example, if this accessor represents a quad that is part of a two- 294 * dimensional surface in four-dimensional space, then this value is four. 295 */ 296 static const unsigned int space_dimension = spacedim; 297 298 /** 299 * Dimensionality of the object that the thing represented by this accessor 300 * is part of. For example, if this accessor represents a line that is part 301 * of a hexahedron, then this value will be three. 302 */ 303 static const unsigned int dimension = dim; 304 305 /** 306 * Dimensionality of the current object represented by this accessor. For 307 * example, if it is line (irrespective of whether it is part of a quad or 308 * hex, and what dimension we are in), then this value equals 1. 309 */ 310 static const unsigned int structure_dimension = structdim; 311 312 /** 313 * Copy operator. These operators are usually used in a context like 314 * <tt>iterator a,b; *a=*b;</tt>. Presumably, the intent here is to copy the 315 * object pointed to 316 * by @p b to the object pointed to by @p a. However, the result of 317 * dereferencing an iterator is not an object but an accessor; consequently, 318 * this operation is not useful for iterators on triangulations. 319 * Consequently, this operator is declared as deleted and can not be used. 320 */ 321 void 322 operator=(const TriaAccessorBase *) = delete; 323 324 protected: 325 /** 326 * Declare the data type that this accessor class expects to get passed from 327 * the iterator classes. Since the pure triangulation iterators need no 328 * additional data, this data type is @p void. 329 */ 330 using AccessorData = void; 331 332 /** 333 * Constructor. Protected, thus only callable from friend classes. 334 */ 335 TriaAccessorBase(const Triangulation<dim, spacedim> *parent = nullptr, 336 const int level = -1, 337 const int index = -1, 338 const AccessorData * = nullptr); 339 340 /** 341 * Copy constructor. Creates an object with exactly the same data. 342 */ 343 TriaAccessorBase(const TriaAccessorBase &); 344 345 /** 346 * Copy operator. Since this is only called from iterators, do not return 347 * anything, since the iterator will return itself. 348 * 349 * This method is protected, since it is only to be called from the iterator 350 * class. 351 */ 352 void 353 copy_from(const TriaAccessorBase &); 354 355 /** 356 * Copy operator. Creates an object with exactly the same data. 357 */ 358 TriaAccessorBase & 359 operator=(const TriaAccessorBase &); 360 361 /** 362 * Comparison operator for accessors. This operator is used when comparing 363 * iterators into objects of a triangulation, for example when putting 364 * them into a `std::map`. 365 * 366 * If #structure_dimension is less than #dimension, we simply compare the 367 * index of such an object because faces and edges do not have levels. If 368 * #structure_dimension equals #dimension, we compare the level first, and 369 * the index only if levels are equal. 370 */ 371 bool 372 operator<(const TriaAccessorBase &other) const; 373 374 protected: 375 /** 376 * Compare for equality. 377 */ 378 bool 379 operator==(const TriaAccessorBase &) const; 380 381 /** 382 * Compare for inequality. 383 */ 384 bool 385 operator!=(const TriaAccessorBase &) const; 386 387 /** 388 * @name Advancement of iterators 389 */ 390 /** 391 * @{ 392 */ 393 /** 394 * This operator advances the iterator to the next element. 395 * 396 * For @p dim=1 only: The next element is next on this level if there are 397 * more. If the present element is the last on this level, the first on the 398 * next level is accessed. 399 */ 400 void 401 operator++(); 402 403 /** 404 * This operator moves the iterator to the previous element. 405 * 406 * For @p dim=1 only: The previous element is previous on this level if 407 * <tt>index>0</tt>. If the present element is the first on this level, the 408 * last on the previous level is accessed. 409 */ 410 void 411 operator--(); 412 /** 413 * @} 414 */ 415 416 /** 417 * Access to the other objects of a Triangulation with same dimension. 418 */ 419 dealii::internal::TriangulationImplementation::TriaObjects & 420 objects() const; 421 422 public: 423 /** 424 * Data type to be used for passing parameters from iterators to the 425 * accessor classes in a unified way, no matter what the type of number of 426 * these parameters is. 427 */ 428 using LocalData = void *; 429 430 /** 431 * @name Iterator address and state 432 */ 433 /** 434 * @{ 435 */ 436 437 /** 438 * For cells, this function returns the level within the mesh hierarchy at 439 * which this cell is located. For all other objects, the function returns 440 * zero. 441 * 442 * @note Within a Triangulation object, cells are uniquely identified by a 443 * pair <code>(level, index)</code> where the former is the cell's 444 * refinement level and the latter is the index of the cell within this 445 * refinement level (the former being what this function returns). 446 * Consequently, there may be multiple cells on different refinement levels 447 * but with the same index within their level. Contrary to this, if the 448 * current object corresponds to a face or edge, then the object is uniquely 449 * identified solely by its index as faces and edges do not have a 450 * refinement level. For these objects, the current function always returns 451 * zero as the level. 452 */ 453 int 454 level() const; 455 456 /** 457 * Return the index of the element presently pointed to on the present 458 * level. 459 * 460 * Within a Triangulation object, cells are uniquely identified by a pair 461 * <code>(level, index)</code> where the former is the cell's refinement 462 * level and the latter is the index of the cell within this refinement 463 * level (the latter being what this function returns). Consequently, there 464 * may be multiple cells on different refinement levels but with the same 465 * index within their level. Contrary to this, if the current object 466 * corresponds to a face or edge, then the object is uniquely identified 467 * solely by its index as faces and edges do not have a refinement level. 468 * 469 * @note The indices objects returned by this function are not a contiguous 470 * set of numbers on each level: going from cell to cell, some of the 471 * indices in a level may be unused. 472 * 473 * @note If the triangulation is actually of type 474 * parallel::distributed::Triangulation then the indices are relatively only 475 * to that part of the distributed triangulation that is stored on the 476 * current processor. In other words, cells living in the partitions of the 477 * triangulation stored on different processors may have the same index even 478 * if they refer to the same cell, and the may have different indices even 479 * if they do refer to the same cell (e.g., if a cell is owned by one 480 * processor but is a ghost cell on another). 481 */ 482 int 483 index() const; 484 485 /** 486 * Return the state of the iterator. For the different states an accessor 487 * can be in, refer to the TriaRawIterator documentation. 488 */ 489 IteratorState::IteratorStates 490 state() const; 491 492 /** 493 * Return a reference to the triangulation which the object pointed to by this 494 * class belongs to. 495 */ 496 const Triangulation<dim, spacedim> & 497 get_triangulation() const; 498 499 /** 500 * @} 501 */ 502 protected: 503 /** 504 * The level if this is a cell (<tt>structdim==dim</tt>). Else, contains 505 * zero. 506 */ 507 typename dealii::internal::TriaAccessorImplementation:: 508 PresentLevelType<structdim, dim>::type present_level; 509 510 /** 511 * Used to store the index of the element presently pointed to on the level 512 * presently used. 513 */ 514 int present_index; 515 516 /** 517 * Pointer to the triangulation which we act on. 518 */ 519 const Triangulation<dim, spacedim> *tria; 520 521 private: 522 template <typename Accessor> 523 friend class TriaRawIterator; 524 template <typename Accessor> 525 friend class TriaIterator; 526 template <typename Accessor> 527 friend class TriaActiveIterator; 528 }; 529 530 531 532 /** 533 * A class that represents accessor objects to iterators that don't make sense 534 * such as quad iterators in on 1d meshes. This class can not be used to 535 * create objects (it will in fact throw an exception if this should ever be 536 * attempted but it sometimes allows code to be written in a simpler way in a 537 * dimension independent way. For example, it allows to write code that works 538 * on quad iterators that is dimension independent -- i.e., also compiles 539 * in 1d -- because quad iterators 540 * (via the current class) exist and are syntactically correct. You can not 541 * expect, however, to ever create an actual object of one of these iterators 542 * in 1d, meaning you need to expect to wrap the code block in which you use 543 * quad iterators into something like <code>if (dim@>1)</code> -- which makes 544 * eminent sense anyway. 545 * 546 * This class provides the minimal interface necessary for Accessor classes to 547 * interact with Iterator classes. However, this is only for syntactic 548 * correctness, none of the functions do anything but generate errors. 549 * 550 * @ingroup Accessors 551 */ 552 template <int structdim, int dim, int spacedim = dim> 553 class InvalidAccessor : public TriaAccessorBase<structdim, dim, spacedim> 554 { 555 public: 556 /** 557 * Propagate alias from base class to this class. 558 */ 559 using AccessorData = 560 typename TriaAccessorBase<structdim, dim, spacedim>::AccessorData; 561 562 /** 563 * Constructor. This class is used for iterators that do not make 564 * sense in a given dimension, for example quads for 1d meshes. Consequently, 565 * while the creation of such objects is syntactically valid, they make no 566 * semantic sense, and we generate an exception when such an object is 567 * actually generated. 568 */ 569 InvalidAccessor(const Triangulation<dim, spacedim> *parent = nullptr, 570 const int level = -1, 571 const int index = -1, 572 const AccessorData * local_data = nullptr); 573 574 /** 575 * Copy constructor. This class is used for iterators that do not make 576 * sense in a given dimension, for example quads for 1d meshes. Consequently, 577 * while the creation of such objects is syntactically valid, they make no 578 * semantic sense, and we generate an exception when such an object is 579 * actually generated. 580 */ 581 InvalidAccessor(const InvalidAccessor &); 582 583 /** 584 * Conversion from other accessors to the current invalid one. This of 585 * course also leads to a run-time error. 586 */ 587 template <typename OtherAccessor> 588 InvalidAccessor(const OtherAccessor &); 589 590 /** 591 * Dummy copy operation. 592 */ 593 void 594 copy_from(const InvalidAccessor &); 595 596 /** 597 * Dummy comparison operators. 598 */ 599 bool 600 operator==(const InvalidAccessor &) const; 601 bool 602 operator!=(const InvalidAccessor &) const; 603 604 /** 605 * Dummy operators to make things compile. Does nothing. 606 */ 607 void 608 operator++() const; 609 void 610 operator--() const; 611 612 /** 613 * Dummy function representing whether the accessor points to a used or an 614 * unused object. 615 */ 616 bool 617 used() const; 618 619 /** 620 * Dummy function representing whether the accessor points to an object that 621 * has children. 622 */ 623 bool 624 has_children() const; 625 626 /** 627 * Dummy function that always returns numbers::flat_manifold_id. 628 */ 629 types::manifold_id 630 manifold_id() const; 631 632 /** 633 * Dummy function that always returns numbers::invalid_unsigned_int. 634 */ 635 unsigned int 636 user_index() const; 637 638 /** 639 * Dummy function that always throws. 640 */ 641 void 642 set_user_index(const unsigned int p) const; 643 644 /** 645 * Dummy function that always throws. 646 */ 647 void 648 set_manifold_id(const types::manifold_id) const; 649 650 /** 651 * Dummy function to extract vertices. Returns the origin. 652 */ 653 Point<spacedim> & 654 vertex(const unsigned int i) const; 655 656 /** 657 * Dummy function to extract lines. Returns a default-constructed line 658 * iterator. 659 */ 660 typename dealii::internal::TriangulationImplementation:: 661 Iterators<dim, spacedim>::line_iterator 662 line(const unsigned int i) const; 663 664 /** 665 * Dummy function to extract quads. Returns a default-constructed quad 666 * iterator. 667 */ 668 typename dealii::internal::TriangulationImplementation:: 669 Iterators<dim, spacedim>::quad_iterator 670 quad(const unsigned int i) const; 671 }; 672 673 674 675 /** 676 * A class that provides access to objects in a triangulation such as its 677 * vertices, sub-objects, children, geometric information, etc. This class 678 * represents objects of dimension <code>structdim</code> (i.e. 1 for lines, 2 679 * for quads, 3 for hexes) in a triangulation of dimensionality 680 * <code>dim</code> (i.e. 1 for a triangulation of lines, 2 for a 681 * triangulation of quads, and 3 for a triangulation of hexes) that is 682 * embedded in a space of dimensionality <code>spacedim</code> (for 683 * <code>spacedim==dim</code> the triangulation represents a domain in 684 * $R^{dim}$, for <code>spacedim@>dim</code> the triangulation is of a 685 * manifold embedded in a higher dimensional space). 686 * 687 * There is a specialization of this class for the case where 688 * @p structdim equals zero, i.e., for vertices of a triangulation. 689 * 690 * @ingroup Accessors 691 */ 692 template <int structdim, int dim, int spacedim> 693 class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim> 694 { 695 public: 696 /** 697 * Propagate alias from base class to this class. 698 */ 699 using AccessorData = 700 typename TriaAccessorBase<structdim, dim, spacedim>::AccessorData; 701 702 /** 703 * Constructor. 704 */ 705 TriaAccessor(const Triangulation<dim, spacedim> *parent = nullptr, 706 const int level = -1, 707 const int index = -1, 708 const AccessorData * local_data = nullptr); 709 710 /** 711 * Conversion constructor. This constructor exists to make certain 712 * constructs simpler to write in dimension independent code. For example, 713 * it allows assigning a face iterator to a line iterator, an operation that 714 * is useful in 2d but doesn't make any sense in 3d. The constructor here 715 * exists for the purpose of making the code conform to C++ but it will 716 * unconditionally abort; in other words, assigning a face iterator to a 717 * line iterator is better put into an if-statement that checks that the 718 * dimension is two, and assign to a quad iterator in 3d (an operator that, 719 * without this constructor would be illegal if we happen to compile for 720 * 2d). 721 */ 722 template <int structdim2, int dim2, int spacedim2> 723 TriaAccessor(const InvalidAccessor<structdim2, dim2, spacedim2> &); 724 725 /** 726 * Another conversion operator between objects that don't make sense, just 727 * like the previous one. 728 */ 729 template <int structdim2, int dim2, int spacedim2> 730 TriaAccessor(const TriaAccessor<structdim2, dim2, spacedim2> &); 731 732 /** 733 * Copy operator. These operators are usually used in a context like 734 * <tt>iterator a,b; *a=*b;</tt>. Presumably, the intent here is to copy the 735 * object pointed to 736 * by @p b to the object pointed to by @p a. However, the result of 737 * dereferencing an iterator is not an object but an accessor; consequently, 738 * this operation is not useful for iterators on triangulations. 739 * Consequently, this operator is declared as deleted and can not be used. 740 */ 741 void 742 operator=(const TriaAccessor &) = delete; 743 744 /** 745 * Test for the element being used or not. The return value is @p true for 746 * all iterators that are either normal iterators or active iterators, only 747 * raw iterators can return @p false. Since raw iterators are only used in 748 * the interiors of the library, you will not usually need this function. 749 */ 750 bool 751 used() const; 752 753 /** 754 * @name Accessing sub-objects 755 */ 756 /** 757 * @{ 758 */ 759 760 /** 761 * Pointer to the @p ith vertex bounding this object. Throw an exception if 762 * <code>dim=1</code>. 763 */ 764 TriaIterator<TriaAccessor<0, dim, spacedim>> 765 vertex_iterator(const unsigned int i) const; 766 767 /** 768 * Return the global index of i-th vertex of the current object. The 769 * convention regarding the numbering of vertices is laid down in the 770 * documentation of the GeometryInfo class. 771 * 772 * Note that the returned value is only the index of the geometrical vertex. 773 * It has nothing to do with possible degrees of freedom associated with it. 774 * For this, see the @p DoFAccessor::vertex_dof_index functions. 775 * 776 * @note Despite the name, the index returned here is only global in the 777 * sense that it is specific to a particular Triangulation object or, in the 778 * case the triangulation is actually of type 779 * parallel::distributed::Triangulation, specific to that part of the 780 * distributed triangulation stored on the current processor. 781 */ 782 unsigned int 783 vertex_index(const unsigned int i) const; 784 785 /** 786 * Return a reference to the @p ith vertex. The reference is not const, 787 * i.e., it is possible to call this function on the left hand side of an 788 * assignment, thereby moving the vertex of a cell within the triangulation. 789 * Of course, doing so requires that you ensure that the new location of the 790 * vertex remains useful -- for example, avoiding inverted or otherwise 791 * distorted (see also 792 * @ref GlossDistorted "this glossary entry"). 793 * 794 * @note When a cell is refined, its children inherit the position of the 795 * vertex positions of those vertices they share with the mother cell (plus 796 * the locations of the new vertices on edges, faces, and cell interiors 797 * that are created for the new child cells). If the vertex of a cell is 798 * moved, this implies that its children will also use these new locations. 799 * On the other hand, imagine a 2d situation where you have one cell that is 800 * refined (with four children) and then you move the central vertex 801 * connecting all four children. If you coarsen these four children again to 802 * the mother cell, then the location of the moved vertex is lost and if, in 803 * a later step, you refine the mother cell again, the then again new vertex 804 * will be placed again at the same position as the first time around -- 805 * i.e., not at the location you had previously moved it to. 806 * 807 * @note The behavior described above is relevant if you have a 808 * parallel::distributed::Triangulation object. There, refining a mesh 809 * always involves a re-partitioning. In other words, vertices of locally 810 * owned cells (see 811 * @ref GlossLocallyOwnedCell "this glossary entry") 812 * that you may have moved to a different location on one processor may be 813 * moved to a different processor upon mesh refinement (even if these 814 * particular cells were not refined) which will re-create their position 815 * based on the position of the coarse cells they previously had, not based 816 * on the position these vertices had on the processor that previously owned 817 * them. In other words, in parallel computations, you will probably have to 818 * move nodes explicitly after every mesh refinement because vertex 819 * positions may or may not be preserved across the re-partitioning that 820 * accompanies mesh refinement. 821 */ 822 Point<spacedim> & 823 vertex(const unsigned int i) const; 824 825 /** 826 * Pointer to the @p ith line bounding this object. 827 */ 828 typename dealii::internal::TriangulationImplementation:: 829 Iterators<dim, spacedim>::line_iterator 830 line(const unsigned int i) const; 831 832 /** 833 * Line index of the @p ith line bounding this object. 834 * 835 * Implemented only for <tt>structdim>1</tt>, otherwise an exception 836 * generated. 837 */ 838 unsigned int 839 line_index(const unsigned int i) const; 840 841 /** 842 * Pointer to the @p ith quad bounding this object. 843 */ 844 typename dealii::internal::TriangulationImplementation:: 845 Iterators<dim, spacedim>::quad_iterator 846 quad(const unsigned int i) const; 847 848 /** 849 * Quad index of the @p ith quad bounding this object. 850 * 851 * Implemented only for <tt>structdim>2</tt>, otherwise an exception 852 * generated. 853 */ 854 unsigned int 855 quad_index(const unsigned int i) const; 856 /** 857 * @} 858 */ 859 860 /** 861 * @name Orientation of sub-objects 862 */ 863 /** 864 * @{ 865 */ 866 867 /** 868 * Return whether the face with index @p face has its normal pointing in the 869 * standard direction (@p true) or whether it is the opposite (@p false). 870 * Which is the standard direction is documented with the GeometryInfo 871 * class. In 1d and 2d, this is always @p true, but in 3d it may be 872 * different, see the respective discussion in the documentation of the 873 * GeometryInfo class. 874 * 875 * This function is really only for internal use in the library unless you 876 * absolutely know what this is all about. 877 */ 878 bool 879 face_orientation(const unsigned int face) const; 880 881 /** 882 * Return whether the face with index @p face is rotated by 180 degrees (@p 883 * true) or not (@p false). In 1d and 2d, this is always @p false, but in 884 * 3d it may be different, see the respective discussion in the 885 * documentation of the GeometryInfo class. 886 * 887 * This function is really only for internal use in the library unless you 888 * absolutely know what this is all about. 889 */ 890 bool 891 face_flip(const unsigned int face) const; 892 893 /** 894 * Return whether the face with index @p face is rotated by 90 degrees (@p 895 * true) or not (@p false). In 1d and 2d, this is always @p false, but in 896 * 3d it may be different, see the respective discussion in the 897 * documentation of the GeometryInfo class. 898 * 899 * This function is really only for internal use in the library unless you 900 * absolutely know what this is all about. 901 */ 902 bool 903 face_rotation(const unsigned int face) const; 904 905 /** 906 * Return whether the line with index @p line is oriented in standard 907 * direction. @p true indicates, that the line is oriented from vertex 0 to 908 * vertex 1, whereas it is the other way around otherwise. In 1d and 2d, 909 * this is always @p true, but in 3d it may be different, see the respective 910 * discussion in the documentation of the GeometryInfo class. 911 * 912 * This function is really only for internal use in the library unless you 913 * absolutely know what this is all about. 914 */ 915 bool 916 line_orientation(const unsigned int line) const; 917 /** 918 * @} 919 */ 920 921 /** 922 * @name Accessing children 923 */ 924 /** 925 * @{ 926 */ 927 928 /** 929 * Test whether the object has children. 930 */ 931 bool 932 has_children() const; 933 934 /** 935 * Return the number of immediate children of this object. The number of 936 * children of an unrefined cell is zero. 937 */ 938 unsigned int 939 n_children() const; 940 941 /** 942 * Compute and return the number of active descendants of this objects. For 943 * example, if all of the eight children of a hex are further refined 944 * isotropically exactly once, the returned number will be 64, not 80. 945 * 946 * If the present cell is not refined, one is returned. 947 * 948 * If one considers a triangulation as a forest where the root of each tree 949 * are the coarse mesh cells and nodes have descendants (the children of a 950 * cell), then this function returns the number of terminal nodes in the 951 * sub-tree originating from the current object; consequently, if the 952 * current object is not further refined, the answer is one. 953 */ 954 unsigned int 955 number_of_children() const; 956 957 /** 958 * Return the number of times that this object is refined. Note that not all 959 * its children are refined that often (which is why we prepend @p max_), 960 * the returned number is rather the maximum number of refinement in any 961 * branch of children of this object. 962 * 963 * For example, if this object is refined, and one of its children is 964 * refined exactly one more time, then <tt>max_refinement_depth</tt> should 965 * return 2. 966 * 967 * If this object is not refined (i.e. it is active), then the return value 968 * is zero. 969 */ 970 unsigned int 971 max_refinement_depth() const; 972 973 /** 974 * Return an iterator to the @p ith child. 975 */ 976 TriaIterator<TriaAccessor<structdim, dim, spacedim>> 977 child(const unsigned int i) const; 978 979 /** 980 * Return the child number of @p child on the current cell. This is the 981 * inverse function of TriaAccessor::child(). 982 */ 983 unsigned int 984 child_iterator_to_index( 985 const TriaIterator<TriaAccessor<structdim, dim, spacedim>> &child) const; 986 987 /** 988 * Return an iterator to that object that is identical to the ith child for 989 * isotropic refinement. If the current object is refined isotropically, 990 * then the returned object is the ith child. If the current object is 991 * refined anisotropically, the returned child may in fact be a grandchild 992 * of the object, or may not exist at all (in which case an exception is 993 * generated). 994 */ 995 TriaIterator<TriaAccessor<structdim, dim, spacedim>> 996 isotropic_child(const unsigned int i) const; 997 998 /** 999 * Return the RefinementCase of this cell. 1000 */ 1001 RefinementCase<structdim> 1002 refinement_case() const; 1003 1004 /** 1005 * Index of the @p ith child. The level of the child is one higher than that 1006 * of the present cell, if the children of a cell are accessed. The children 1007 * of faces have no level. If the child does not exist, -1 is returned. 1008 */ 1009 int 1010 child_index(const unsigned int i) const; 1011 1012 /** 1013 * Index of the @p ith isotropic child. See the isotropic_child() function 1014 * for a definition of this concept. If the child does not exist, -1 is 1015 * returned. 1016 */ 1017 int 1018 isotropic_child_index(const unsigned int i) const; 1019 /** 1020 * @} 1021 */ 1022 1023 /** 1024 * @name Dealing with boundary indicators 1025 */ 1026 /** 1027 * @{ 1028 */ 1029 1030 /** 1031 * Return the boundary indicator of this object. 1032 * 1033 * If the return value is the special value 1034 * numbers::internal_face_boundary_id, then this object is in the interior 1035 * of the domain. 1036 * 1037 * @see 1038 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 1039 */ 1040 types::boundary_id 1041 boundary_id() const; 1042 1043 /** 1044 * Set the boundary indicator of the current object. The same applies as for 1045 * the boundary_id() function. 1046 * 1047 * This function only sets the boundary object of the current object itself, 1048 * not the indicators of the ones that bound it. For example, in 3d, if this 1049 * function is called on a face, then the boundary indicator of the 4 edges 1050 * that bound the face remain unchanged. If you want to set the boundary 1051 * indicators of face and edges at the same time, use the 1052 * set_all_boundary_ids() function. You can see the result of not using the 1053 * correct function in the results section of step-49. 1054 * 1055 * @warning You should never set the boundary indicator of an interior face 1056 * (a face not at the boundary of the domain), or set the boundary 1057 * indicator of an exterior face to numbers::internal_face_boundary_id (this 1058 * value is reserved for another purpose). Algorithms may not work or 1059 * produce very confusing results if boundary cells have a boundary 1060 * indicator of numbers::internal_face_boundary_id or if interior cells have 1061 * boundary indicators other than numbers::internal_face_boundary_id. 1062 * Unfortunately, the current object has no means of finding out whether it 1063 * really is at the boundary of the domain and so cannot determine whether 1064 * the value you are trying to set makes sense under the current 1065 * circumstances. 1066 * 1067 * @ingroup boundary 1068 * 1069 * @see 1070 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 1071 */ 1072 void 1073 set_boundary_id(const types::boundary_id) const; 1074 1075 /** 1076 * Do as set_boundary_id() but also set the boundary indicators of the 1077 * objects that bound the current object. For example, in 3d, if 1078 * set_boundary_id() is called on a face, then the boundary indicator of the 1079 * 4 edges that bound the face remain unchanged. In contrast, if you call 1080 * the current function, the boundary indicators of face and edges are all 1081 * set to the given value. 1082 * 1083 * This function is useful if you set boundary indicators of faces in 3d (in 1084 * 2d, the function does the same as set_boundary_id()) and you do so 1085 * because you want a curved boundary object to represent the part of the 1086 * boundary that corresponds to the current face. In that case, the 1087 * Triangulation class needs to figure out where to put new vertices upon 1088 * mesh refinement, and higher order Mapping objects also need to figure out 1089 * where new interpolation points for a curved boundary approximation should 1090 * be. In either case, the two classes first determine where interpolation 1091 * points on the edges of a boundary face should be, asking the boundary 1092 * object, before asking the boundary object for the interpolation points 1093 * corresponding to the interior of the boundary face. For this to work 1094 * properly, it is not sufficient to have set the boundary indicator for the 1095 * face alone, but you also need to set the boundary indicators of the edges 1096 * that bound the face. This function does all of this at once. You can see 1097 * the result of not using the correct function in the results section of 1098 * step-49. 1099 * 1100 * @ingroup boundary 1101 * 1102 * @see 1103 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 1104 */ 1105 void 1106 set_all_boundary_ids(const types::boundary_id) const; 1107 1108 /** 1109 * Return whether this object is at the boundary. Obviously, the use of this 1110 * function is only possible for <tt>dim@>structdim</tt>; however, for 1111 * <tt>dim==structdim</tt>, an object is a cell and the CellAccessor class 1112 * offers another possibility to determine whether a cell is at the boundary 1113 * or not. 1114 */ 1115 bool 1116 at_boundary() const; 1117 1118 /** 1119 * Return a constant reference to the manifold object used for this object. 1120 * 1121 * As explained in the 1122 * @ref manifold 1123 * module, the process involved in finding the appropriate manifold 1124 * description involves querying both the manifold or boundary 1125 * indicators. See there for more information. 1126 */ 1127 const Manifold<dim, spacedim> & 1128 get_manifold() const; 1129 1130 /** 1131 * @} 1132 */ 1133 1134 /** 1135 * @name Dealing with manifold indicators 1136 */ 1137 /** 1138 * @{ 1139 */ 1140 1141 /** 1142 * Return the manifold indicator of this object. 1143 * 1144 * If the return value is the special value numbers::flat_manifold_id, then 1145 * this object is associated with a standard Cartesian Manifold Description. 1146 * 1147 * @see 1148 * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" 1149 */ 1150 types::manifold_id 1151 manifold_id() const; 1152 1153 /** 1154 * Set the manifold indicator. The same applies as for the 1155 * <tt>manifold_id()</tt> function. 1156 * 1157 * Note that it only sets the manifold object of the current object itself, 1158 * not the indicators of the ones that bound it, nor of its children. For 1159 * example, in 3d, if this function is called on a face, then the manifold 1160 * indicator of the 4 edges that bound the face remain unchanged. If you 1161 * want to set the manifold indicators of face, edges and all children at 1162 * the same time, use the set_all_manifold_ids() function. 1163 * 1164 * 1165 * @ingroup manifold 1166 * 1167 * @see 1168 * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" 1169 */ 1170 void 1171 set_manifold_id(const types::manifold_id) const; 1172 1173 /** 1174 * Do as set_manifold_id() but also set the manifold indicators of the 1175 * objects that bound the current object. For example, in 3d, if 1176 * set_manifold_id() is called on a face, then the manifold indicator of the 1177 * 4 edges that bound the face remain unchanged. On the other hand, the 1178 * manifold indicators of face and edges are all set at the same time using 1179 * the current function. 1180 * 1181 * @ingroup manifold 1182 * 1183 * @see 1184 * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" 1185 */ 1186 void 1187 set_all_manifold_ids(const types::manifold_id) const; 1188 1189 /** 1190 * @} 1191 */ 1192 1193 1194 /** 1195 * @name User data 1196 */ 1197 /** 1198 * @{ 1199 */ 1200 /** 1201 * Read the user flag. See 1202 * @ref GlossUserFlags 1203 * for more information. 1204 */ 1205 bool 1206 user_flag_set() const; 1207 1208 /** 1209 * Set the user flag. See 1210 * @ref GlossUserFlags 1211 * for more information. 1212 */ 1213 void 1214 set_user_flag() const; 1215 1216 /** 1217 * Clear the user flag. See 1218 * @ref GlossUserFlags 1219 * for more information. 1220 */ 1221 void 1222 clear_user_flag() const; 1223 1224 /** 1225 * Set the user flag for this and all descendants. See 1226 * @ref GlossUserFlags 1227 * for more information. 1228 */ 1229 void 1230 recursively_set_user_flag() const; 1231 1232 /** 1233 * Clear the user flag for this and all descendants. See 1234 * @ref GlossUserFlags 1235 * for more information. 1236 */ 1237 void 1238 recursively_clear_user_flag() const; 1239 1240 /** 1241 * Reset the user data to zero, independent if pointer or index. See 1242 * @ref GlossUserData 1243 * for more information. 1244 */ 1245 void 1246 clear_user_data() const; 1247 1248 /** 1249 * Set the user pointer to @p p. 1250 * 1251 * @note User pointers and user indices are mutually exclusive. Therefore, 1252 * you can only use one of them, unless you call 1253 * Triangulation::clear_user_data() in between. 1254 * 1255 * See 1256 * @ref GlossUserData 1257 * for more information. 1258 */ 1259 void 1260 set_user_pointer(void *p) const; 1261 1262 /** 1263 * Reset the user pointer to a @p nullptr pointer. See 1264 * @ref GlossUserData 1265 * for more information. 1266 */ 1267 void 1268 clear_user_pointer() const; 1269 1270 /** 1271 * Access the value of the user pointer. It is in the responsibility of the 1272 * user to make sure that the pointer points to something useful. You should 1273 * use the new style cast operator to maintain a minimum of type safety, 1274 * e.g. 1275 * 1276 * @note User pointers and user indices are mutually exclusive. Therefore, 1277 * you can only use one of them, unless you call 1278 * Triangulation::clear_user_data() in between. <tt>A 1279 * *a=static_cast<A*>(cell->user_pointer());</tt>. 1280 * 1281 * See 1282 * @ref GlossUserData 1283 * for more information. 1284 */ 1285 void * 1286 user_pointer() const; 1287 1288 /** 1289 * Set the user pointer of this object and all its children to the given 1290 * value. This is useful for example if all cells of a certain subdomain, or 1291 * all faces of a certain part of the boundary should have user pointers 1292 * pointing to objects describing this part of the domain or boundary. 1293 * 1294 * Note that the user pointer is not inherited under mesh refinement, so 1295 * after mesh refinement there might be cells or faces that don't have user 1296 * pointers pointing to the describing object. In this case, simply loop 1297 * over all the elements of the coarsest level that has this information, 1298 * and use this function to recursively set the user pointer of all finer 1299 * levels of the triangulation. 1300 * 1301 * @note User pointers and user indices are mutually exclusive. Therefore, 1302 * you can only use one of them, unless you call 1303 * Triangulation::clear_user_data() in between. 1304 * 1305 * See 1306 * @ref GlossUserData 1307 * for more information. 1308 */ 1309 void 1310 recursively_set_user_pointer(void *p) const; 1311 1312 /** 1313 * Clear the user pointer of this object and all of its descendants. The 1314 * same holds as said for the recursively_set_user_pointer() function. See 1315 * @ref GlossUserData 1316 * for more information. 1317 */ 1318 void 1319 recursively_clear_user_pointer() const; 1320 1321 /** 1322 * Set the user index to @p p. 1323 * 1324 * @note User pointers and user indices are mutually exclusive. Therefore, 1325 * you can only use one of them, unless you call 1326 * Triangulation::clear_user_data() in between. See 1327 * @ref GlossUserData 1328 * for more information. 1329 */ 1330 void 1331 set_user_index(const unsigned int p) const; 1332 1333 /** 1334 * Reset the user index to 0. See 1335 * @ref GlossUserData 1336 * for more information. 1337 */ 1338 void 1339 clear_user_index() const; 1340 1341 /** 1342 * Access the value of the user index. 1343 * 1344 * @note User pointers and user indices are mutually exclusive. Therefore, 1345 * you can only use one of them, unless you call 1346 * Triangulation::clear_user_data() in between. 1347 * 1348 * See 1349 * @ref GlossUserData 1350 * for more information. 1351 */ 1352 unsigned int 1353 user_index() const; 1354 1355 /** 1356 * Set the user index of this object and all its children. 1357 * 1358 * Note that the user index is not inherited under mesh refinement, so after 1359 * mesh refinement there might be cells or faces that don't have the 1360 * expected user indices. In this case, simply loop over all the elements of 1361 * the coarsest level that has this information, and use this function to 1362 * recursively set the user index of all finer levels of the triangulation. 1363 * 1364 * @note User pointers and user indices are mutually exclusive. Therefore, 1365 * you can only use one of them, unless you call 1366 * Triangulation::clear_user_data() in between. 1367 * 1368 * See 1369 * @ref GlossUserData 1370 * for more information. 1371 */ 1372 void 1373 recursively_set_user_index(const unsigned int p) const; 1374 1375 /** 1376 * Clear the user index of this object and all of its descendants. The same 1377 * holds as said for the recursively_set_user_index() function. 1378 * 1379 * See 1380 * @ref GlossUserData 1381 * for more information. 1382 */ 1383 void 1384 recursively_clear_user_index() const; 1385 /** 1386 * @} 1387 */ 1388 1389 /** 1390 * @name Geometric information about an object 1391 */ 1392 /** 1393 * @{ 1394 */ 1395 1396 /** 1397 * Diameter of the object. 1398 * 1399 * The diameter of an object is computed to be the largest diagonal. This is 1400 * not necessarily the true diameter for objects that may use higher order 1401 * mappings, but completely sufficient for most computations. 1402 */ 1403 double 1404 diameter() const; 1405 1406 /** 1407 * Return a pair of Point and double corresponding to the center and 1408 * the radius of a reasonably small enclosing ball of the object. 1409 * 1410 * The function implements Ritter's O(n) algorithm to get a reasonably 1411 * small enclosing ball around the vertices of the object. 1412 * The initial guess for the enclosing ball is taken to be the ball 1413 * which contains the largest diagonal of the object as its diameter. 1414 * Starting from such an initial guess, the algorithm tests whether all 1415 * the vertices of the object (except the vertices of the largest diagonal) 1416 * are geometrically within the ball. 1417 * If any vertex (v) is found to be geometrically outside the ball, 1418 * a new iterate of the ball is constructed by shifting its center and 1419 * increasing the radius so as to geometrically enclose both the previous 1420 * ball and the vertex (v). The algorithm terminates when all the vertices 1421 * are geometrically inside the ball. 1422 * 1423 * If a vertex (v) is geometrically inside a particular iterate of the ball, 1424 * then it will continue to be so in the subsequent iterates of 1425 * the ball (this is true \a by \a construction). 1426 * 1427 * @note This function assumes d-linear mapping from the reference cell. 1428 * 1429 * <a href="http://geomalgorithms.com/a08-_containers.html">see this</a> and 1430 * [Ritter 1990] 1431 */ 1432 std::pair<Point<spacedim>, double> 1433 enclosing_ball() const; 1434 1435 /** 1436 * Return the smallest bounding box that encloses the object. 1437 * 1438 * Notice that this method is not aware of any mapping you may be using to 1439 * do your computations. If you are using a mapping object that modifies the 1440 * position of the vertices, like MappingQEulerian, or MappingFEField, then 1441 * you should call the function Mapping::get_bounding_box() instead. 1442 */ 1443 BoundingBox<spacedim> 1444 bounding_box() const; 1445 1446 /** 1447 * Length of an object in the direction of the given axis, specified in the 1448 * local coordinate system. See the documentation of GeometryInfo for the 1449 * meaning and enumeration of the local axes. 1450 * 1451 * Note that the "length" of an object can be interpreted in a variety of 1452 * ways. Here, we choose it as the maximal length of any of the edges of the 1453 * object that are parallel to the chosen axis on the reference cell. 1454 */ 1455 double 1456 extent_in_direction(const unsigned int axis) const; 1457 1458 /** 1459 * Return the minimal distance between any two vertices. 1460 */ 1461 double 1462 minimum_vertex_distance() const; 1463 1464 /** 1465 * Return a point belonging to the Manifold<dim,spacedim> where this object 1466 * lives, given its parametric coordinates on the reference @p structdim 1467 * cell. This function queries the underlying manifold object, and can be 1468 * used to obtain the exact geometrical location of arbitrary points on this 1469 * object. 1470 * 1471 * Notice that the argument @p coordinates are the coordinates on the 1472 * <em>reference cell</em>, given in reference coordinates. In other words, 1473 * the argument provides a weighting between the different vertices. For 1474 * example, for lines, calling this function with argument Point<1>(.5), is 1475 * equivalent to asking the line for its center. 1476 */ 1477 Point<spacedim> 1478 intermediate_point(const Point<structdim> &coordinates) const; 1479 1480 /** 1481 * This function computes a fast approximate transformation from the real to 1482 * the unit cell by inversion of an affine approximation of the $d$-linear 1483 * function from the reference $d$-dimensional cell. 1484 * 1485 * The affine approximation of the unit to real cell mapping is found by a 1486 * least squares fit of an affine function to the $2^d$ vertices of the 1487 * present object. For any valid mesh cell whose geometry is not degenerate, 1488 * this operation results in a unique affine mapping. Thus, this function 1489 * will return a finite result for all given input points, even in cases 1490 * where the actual transformation by an actual bi-/trilinear or higher 1491 * order mapping might be singular. Besides only approximating the mapping 1492 * from the vertex points, this function also ignores the attached manifold 1493 * descriptions. The result is only exact in case the transformation from 1494 * the unit to the real cell is indeed affine, such as in one dimension or 1495 * for Cartesian and affine (parallelogram) meshes in 2D/3D. 1496 * 1497 * For exact transformations to the unit cell, use 1498 * Mapping::transform_real_to_unit_cell(). 1499 * 1500 * @note If dim<spacedim we first project p onto the plane. 1501 */ 1502 Point<structdim> 1503 real_to_unit_cell_affine_approximation(const Point<spacedim> &point) const; 1504 1505 /** 1506 * Center of the object. The center of an object is defined to be the 1507 * average of the locations of the vertices, which is also where a $Q_1$ 1508 * mapping would map the center of the reference cell. However, you can also 1509 * ask this function to instead return the average of the vertices as 1510 * computed by the underlying Manifold object associated with the current 1511 * object, by setting to true the optional parameter @p respect_manifold. 1512 * Manifolds would then typically pull back the coordinates of the vertices 1513 * to a reference domain (not necessarily the reference cell), compute the 1514 * average there, and then push forward the coordinates of the averaged 1515 * point to the physical space again; the resulting point is guaranteed to 1516 * lie within the manifold, even if the manifold is curved. 1517 * 1518 * When the object uses a different manifold description as its surrounding, 1519 * like when part of the bounding objects of this TriaAccessor use a 1520 * non-flat manifold description but the object itself is flat, the result 1521 * given by the TriaAccessor::center() function may not be accurate enough, 1522 * even when parameter @p respect_manifold is set to true. If you find this 1523 * to be case, than you can further refine the computation of the center by 1524 * setting to true the second additional parameter @p 1525 * interpolate_from_surrounding. This computes the location of the center by 1526 * a so-called transfinite interpolation from the center of all the bounding 1527 * objects. For a 2D object, it puts a weight of <code>1/2</code> on each of 1528 * the four surrounding lines and a weight <code>-1/4</code> on the four 1529 * vertices. This corresponds to a linear interpolation between the 1530 * descriptions of the four faces, subtracting the contribution of the 1531 * vertices that is added twice when coming through both lines adjacent to 1532 * the vertex. In 3D, the weights for faces are <code>1/2</code>, the 1533 * weights for lines are <code>-1/4</code>, and the weights for vertices are 1534 * <code>1/8</code>. For further information, also confer to the 1535 * TransfiniteInterpolationManifold class that is able to not only apply 1536 * this beneficial description to a single cell but all children of a coarse 1537 * cell. 1538 */ 1539 Point<spacedim> 1540 center(const bool respect_manifold = false, 1541 const bool interpolate_from_surrounding = false) const; 1542 1543 /** 1544 * Return the barycenter (also called centroid) 1545 * of the object. The barycenter for an object $K$ 1546 * of dimension $d$ in $D$ space dimensions is given by the $D$-dimensional 1547 * vector $\mathbf x_K$ defined by 1548 * @f[ 1549 * \mathbf x_K = \frac{1}{|K|} \int_K \mathbf x \; \textrm{d}x 1550 * @f] 1551 * where the measure of the object is given by 1552 * @f[ 1553 * |K| = \int_K \mathbf 1 \; \textrm{d}x. 1554 * @f] 1555 * This function assumes that $K$ is mapped by a $d$-linear function from 1556 * the reference $d$-dimensional cell. Then the integrals above can be 1557 * pulled back to the reference cell and evaluated exactly (if through 1558 * lengthy and, compared to the center() function, expensive computations). 1559 */ 1560 Point<spacedim> 1561 barycenter() const; 1562 1563 /** 1564 * Compute the dim-dimensional measure of the object. For a dim-dimensional 1565 * cell in dim-dimensional space, this equals its volume. On the other hand, 1566 * for a 2d cell in 3d space, or if the current object pointed to is a 2d 1567 * face of a 3d cell in 3d space, then the function computes the area the 1568 * object occupies. For a one-dimensional object, return its length. 1569 * 1570 * The function only computes the measure of cells, faces or edges assumed 1571 * to be represented by (bi-/tri-)linear mappings. In other words, it only 1572 * takes into account the locations of the vertices that bound the current 1573 * object but not how the interior of the object may actually be mapped. In 1574 * most simple cases, this is exactly what you want. However, for objects 1575 * that are not "straight", e.g. 2d cells embedded in 3d space as part of a 1576 * triangulation of a curved domain, two-dimensional faces of 3d cells that 1577 * are not just parallelograms, or for faces that are at the boundary of a 1578 * domain that is not just bounded by straight line segments or planes, this 1579 * function only computes the dim-dimensional measure of a (bi-/tri-)linear 1580 * interpolation of the "real" object as defined by the manifold or boundary 1581 * object describing the real geometry of the object in question. If you 1582 * want to consider the "real" geometry, you will need to compute the 1583 * measure by integrating a function equal to one over the object, which 1584 * after applying quadrature equals the summing the JxW values returned by 1585 * the FEValues or FEFaceValues object you will want to use for the 1586 * integral. 1587 */ 1588 double 1589 measure() const; 1590 1591 /** 1592 * Return true if the current object is a translation of the given argument. 1593 * 1594 * @note For the purpose of a triangulation, cells, faces, etc are only 1595 * characterized by their vertices. The current function therefore only 1596 * compares the locations of vertices. For many practical applications, 1597 * however, it is not only the vertices that determine whether one cell is a 1598 * translation of another, but also how the cell is mapped from the 1599 * reference cell to its location in real space. For example, if we are 1600 * using higher order mappings, then not only do the vertices have to be 1601 * translations of each other, but also the points along edges. In these 1602 * questions, therefore, it would be appropriate to ask the mapping, not the 1603 * current function, whether two objects are translations of each other. 1604 */ 1605 bool 1606 is_translation_of( 1607 const TriaIterator<TriaAccessor<structdim, dim, spacedim>> &o) const; 1608 1609 /** 1610 * Reference cell type of the current object. 1611 */ 1612 ReferenceCell::Type 1613 reference_cell_type() const; 1614 1615 /** 1616 * Number of vertices. 1617 */ 1618 unsigned int 1619 n_vertices() const; 1620 1621 /** 1622 * Number of lines. 1623 */ 1624 unsigned int 1625 n_lines() const; 1626 1627 /** 1628 * Number of faces. 1629 * 1630 * @note Only implemented for cells (dim==spacedim). 1631 */ 1632 unsigned int 1633 n_faces() const; 1634 1635 /** 1636 * Return an object that can be thought of as an array containing all indices 1637 * from zero to n_vertices(). 1638 */ 1639 std_cxx20::ranges::iota_view<unsigned int, unsigned int> 1640 vertex_indices() const; 1641 1642 /** 1643 * Return an object that can be thought of as an array containing all indices 1644 * from zero to n_lines(). 1645 */ 1646 std_cxx20::ranges::iota_view<unsigned int, unsigned int> 1647 line_indices() const; 1648 1649 /** 1650 * Return an object that can be thought of as an array containing all indices 1651 * from zero to n_faces(). 1652 * 1653 * @note Only implemented for cells (dim==spacedim). 1654 */ 1655 std_cxx20::ranges::iota_view<unsigned int, unsigned int> 1656 face_indices() const; 1657 1658 /** 1659 * @} 1660 */ 1661 1662 protected: 1663 /** 1664 * Return additional information related to the current geometric entity 1665 * type. 1666 */ 1667 inline const ReferenceCell::internal::Info::Base & 1668 reference_cell_info() const; 1669 1670 private: 1671 /** 1672 * Like set_boundary_id but without checking for internal faces or invalid 1673 * ids. 1674 */ 1675 void 1676 set_boundary_id_internal(const types::boundary_id id) const; 1677 1678 /** 1679 * Set the indices of those objects that bound the current 1680 * object. For example, if the current object represents a cell, 1681 * then the argument denotes the indices of the faces that bound the 1682 * cell. If the current object represents a line, the argument 1683 * denotes the indices of the vertices that bound it. And so on. 1684 */ 1685 void 1686 set_bounding_object_indices( 1687 const std::initializer_list<int> &new_indices) const; 1688 1689 /** 1690 * The same as above but for `unsigned int`. 1691 */ 1692 void 1693 set_bounding_object_indices( 1694 const std::initializer_list<unsigned int> &new_indices) const; 1695 1696 /** 1697 * Set the flag indicating, what <code>line_orientation()</code> will 1698 * return. 1699 * 1700 * It is only possible to set the line_orientation of faces in 3d (i.e. 1701 * <code>structdim==2 && dim==3</code>). 1702 */ 1703 void 1704 set_line_orientation(const unsigned int line, const bool orientation) const; 1705 1706 /** 1707 * Set whether the quad with index @p face has its normal pointing in the 1708 * standard direction (@p true) or whether it is the opposite (@p false). 1709 * Which is the standard direction is documented with the GeometryInfo 1710 * class. 1711 * 1712 * This function is only for internal use in the library. Setting this flag 1713 * to any other value than the one that the triangulation has already set is 1714 * bound to bring you disaster. 1715 */ 1716 void 1717 set_face_orientation(const unsigned int face, const bool orientation) const; 1718 1719 /** 1720 * Set the flag indicating, what <code>face_flip()</code> will return. 1721 * 1722 * It is only possible to set the face_orientation of cells in 3d (i.e. 1723 * <code>structdim==3 && dim==3</code>). 1724 */ 1725 void 1726 set_face_flip(const unsigned int face, const bool flip) const; 1727 1728 /** 1729 * Set the flag indicating, what <code>face_rotation()</code> will return. 1730 * 1731 * It is only possible to set the face_orientation of cells in 3d (i.e. 1732 * <code>structdim==3 && dim==3</code>). 1733 */ 1734 void 1735 set_face_rotation(const unsigned int face, const bool rotation) const; 1736 1737 /** 1738 * Set the @p used flag. Only for internal use in the library. 1739 */ 1740 void 1741 set_used_flag() const; 1742 1743 /** 1744 * Clear the @p used flag. Only for internal use in the library. 1745 */ 1746 void 1747 clear_used_flag() const; 1748 1749 /** 1750 * Set the @p RefinementCase<dim> this TriaObject is refined with. Not 1751 * defined for <tt>structdim=1</tt> as lines are always refined resulting in 1752 * 2 children lines (isotropic refinement). 1753 * 1754 * You should know quite exactly what you are doing if you touch this 1755 * function. It is exclusively for internal use in the library. 1756 */ 1757 void 1758 set_refinement_case(const RefinementCase<structdim> &ref_case) const; 1759 1760 /** 1761 * Clear the RefinementCase<dim> of this TriaObject, i.e. reset it to 1762 * RefinementCase<dim>::no_refinement. 1763 * 1764 * You should know quite exactly what you are doing if you touch this 1765 * function. It is exclusively for internal use in the library. 1766 */ 1767 void 1768 clear_refinement_case() const; 1769 1770 /** 1771 * Set the index of the ith child. Since the children come at least in 1772 * pairs, we need to store the index of only every second child, i.e. of the 1773 * even numbered children. Make sure, that the index of child i=0 is set 1774 * first. Calling this function for odd numbered children is not allowed. 1775 */ 1776 void 1777 set_children(const unsigned int i, const int index) const; 1778 1779 /** 1780 * Clear the child field, i.e. set it to a value which indicates that this 1781 * cell has no children. 1782 */ 1783 void 1784 clear_children() const; 1785 1786 private: 1787 template <int, int> 1788 friend class Triangulation; 1789 1790 friend struct dealii::internal::TriangulationImplementation::Implementation; 1791 friend struct dealii::internal::TriaAccessorImplementation::Implementation; 1792 }; 1793 1794 1795 1796 /** 1797 * This class is a specialization of <code>TriaAccessor<structdim, dim, 1798 * spacedim></code> 1799 * for the case that @p structdim is zero. This 1800 * class represents vertices in a triangulation of dimensionality 1801 * <code>dim</code> (i.e. 1 for a triangulation of lines, 2 for a 1802 * triangulation of quads, and 3 for a triangulation of hexes) that is 1803 * embedded in a space of dimensionality <code>spacedim</code> (for 1804 * <code>spacedim==dim</code> the triangulation represents a domain in 1805 * ${\mathbb R}^\text{dim}$, for <code>spacedim@>dim</code> the triangulation 1806 * is of a manifold embedded in a higher dimensional space). 1807 * 1808 * There is a further specialization of this class for the case that 1809 * @p dim equals one, i.e., for vertices of a one-dimensional triangulation, 1810 * since in that case vertices are also faces. 1811 * 1812 * @ingroup Accessors 1813 */ 1814 template <int dim, int spacedim> 1815 class TriaAccessor<0, dim, spacedim> 1816 { 1817 public: 1818 /** 1819 * Dimension of the space the object represented by this accessor lives in. 1820 * For example, if this accessor represents a quad that is part of a two- 1821 * dimensional surface in four-dimensional space, then this value is four. 1822 */ 1823 static const unsigned int space_dimension = spacedim; 1824 1825 /** 1826 * Dimensionality of the object that the thing represented by this accessor 1827 * is part of. For example, if this accessor represents a line that is part 1828 * of a hexahedron, then this value will be three. 1829 */ 1830 static const unsigned int dimension = dim; 1831 1832 /** 1833 * Dimensionality of the current object represented by this accessor. For 1834 * example, if it is line (irrespective of whether it is part of a quad or 1835 * hex, and what dimension we are in), then this value equals 1. 1836 */ 1837 static const unsigned int structure_dimension = 0; 1838 1839 /** 1840 * Pointer to internal data. 1841 */ 1842 using AccessorData = void; 1843 1844 /** 1845 * Constructor. The second argument is the global index of the vertex we 1846 * point to. 1847 */ 1848 TriaAccessor(const Triangulation<dim, spacedim> *tria, 1849 const unsigned int vertex_index); 1850 1851 /** 1852 * Constructor. This constructor exists in order to maintain interface 1853 * compatibility with the other accessor classes. @p index can be used to 1854 * set the global index of the vertex we point to. 1855 */ 1856 TriaAccessor(const Triangulation<dim, spacedim> *tria = nullptr, 1857 const int level = 0, 1858 const int index = 0, 1859 const AccessorData * = nullptr); 1860 1861 /** 1862 * Constructor. Should never be called and thus produces an error. 1863 */ 1864 template <int structdim2, int dim2, int spacedim2> 1865 TriaAccessor(const TriaAccessor<structdim2, dim2, spacedim2> &); 1866 1867 /** 1868 * Constructor. Should never be called and thus produces an error. 1869 */ 1870 template <int structdim2, int dim2, int spacedim2> 1871 TriaAccessor(const InvalidAccessor<structdim2, dim2, spacedim2> &); 1872 1873 /** 1874 * Return the state of the iterator. 1875 */ 1876 IteratorState::IteratorStates 1877 state() const; 1878 1879 /** 1880 * Level of this object. Vertices have no level, so this function always 1881 * returns zero. 1882 */ 1883 static int 1884 level(); 1885 1886 /** 1887 * Index of this object. Returns the global index of the vertex this object 1888 * points to. 1889 */ 1890 int 1891 index() const; 1892 1893 /** 1894 * Return a reference to the triangulation which the object pointed to by this 1895 * class belongs to. 1896 */ 1897 const Triangulation<dim, spacedim> & 1898 get_triangulation() const; 1899 1900 /** 1901 * @name Advancement of iterators 1902 */ 1903 /** 1904 * @{ 1905 */ 1906 /** 1907 * This operator advances the iterator to the next element. 1908 */ 1909 void 1910 operator++(); 1911 1912 /** 1913 * This operator moves the iterator to the previous element. 1914 */ 1915 void 1916 operator--(); 1917 /** 1918 * Compare for equality. 1919 */ 1920 bool 1921 operator==(const TriaAccessor &) const; 1922 1923 /** 1924 * Compare for inequality. 1925 */ 1926 bool 1927 operator!=(const TriaAccessor &) const; 1928 1929 /** 1930 * @} 1931 */ 1932 1933 1934 /** 1935 * @name Accessing sub-objects 1936 */ 1937 /** 1938 * @{ 1939 */ 1940 1941 /** 1942 * Return the global index of i-th vertex of the current object. If @p i is 1943 * zero, this returns the index of the current point to which this object 1944 * refers. Otherwise, it throws an exception. 1945 * 1946 * Note that the returned value is only the index of the geometrical vertex. 1947 * It has nothing to do with possible degrees of freedom associated with it. 1948 * For this, see the @p DoFAccessor::vertex_dof_index functions. 1949 * 1950 * @note Despite the name, the index returned here is only global in the 1951 * sense that it is specific to a particular Triangulation object or, in the 1952 * case the triangulation is actually of type 1953 * parallel::distributed::Triangulation, specific to that part of the 1954 * distributed triangulation stored on the current processor. 1955 */ 1956 unsigned int 1957 vertex_index(const unsigned int i = 0) const; 1958 1959 /** 1960 * Return a reference to the @p ith vertex. If i is zero, this returns a 1961 * reference to the current point to which this object refers. Otherwise, it 1962 * throws an exception. 1963 */ 1964 Point<spacedim> & 1965 vertex(const unsigned int i = 0) const; 1966 1967 /** 1968 * Pointer to the @p ith line bounding this object. Will point to an invalid 1969 * object. 1970 */ 1971 typename dealii::internal::TriangulationImplementation:: 1972 Iterators<dim, spacedim>::line_iterator static line(const unsigned int); 1973 1974 /** 1975 * Line index of the @p ith line bounding this object. Throws an exception. 1976 */ 1977 static unsigned int 1978 line_index(const unsigned int i); 1979 1980 /** 1981 * Pointer to the @p ith quad bounding this object. 1982 */ 1983 static typename dealii::internal::TriangulationImplementation:: 1984 Iterators<dim, spacedim>::quad_iterator 1985 quad(const unsigned int i); 1986 1987 /** 1988 * Quad index of the @p ith quad bounding this object. Throws an exception. 1989 */ 1990 static unsigned int 1991 quad_index(const unsigned int i); 1992 1993 /** 1994 * @} 1995 */ 1996 1997 1998 /** 1999 * @name Geometric information about an object 2000 */ 2001 /** 2002 * @{ 2003 */ 2004 2005 /** 2006 * Diameter of the object. This function always returns zero. 2007 */ 2008 double 2009 diameter() const; 2010 2011 /** 2012 * Length of an object in the direction of the given axis, specified in the 2013 * local coordinate system. See the documentation of GeometryInfo for the 2014 * meaning and enumeration of the local axes. 2015 * 2016 * This function always returns zero. 2017 */ 2018 double 2019 extent_in_direction(const unsigned int axis) const; 2020 2021 /** 2022 * Return the center of this object, which of course coincides with the 2023 * location of the vertex this object refers to. The parameters @p 2024 * respect_manifold and @p interpolate_from_surrounding are not used. They 2025 * are there to provide the same interface as 2026 * <code>TriaAccessor<structdim,dim,spacedim></code>. 2027 */ 2028 Point<spacedim> 2029 center(const bool respect_manifold = false, 2030 const bool interpolate_from_surrounding = false) const; 2031 2032 /** 2033 * Compute the dim-dimensional measure of the object. For a dim-dimensional 2034 * cell in dim-dimensional space, this equals its volume. On the other hand, 2035 * for a 2d cell in 3d space, or if the current object pointed to is a 2d 2036 * face of a 3d cell in 3d space, then the function computes the area the 2037 * object occupies. For a one-dimensional object, return its length. For a 2038 * zero-dimensional object, return zero. 2039 */ 2040 double 2041 measure() const; 2042 /** 2043 * @} 2044 */ 2045 2046 /** 2047 * @name Orientation of sub-objects 2048 */ 2049 /** 2050 * @{ 2051 */ 2052 2053 /** 2054 * @brief Always return false 2055 */ 2056 static bool 2057 face_orientation(const unsigned int face); 2058 2059 /** 2060 * @brief Always return false 2061 */ 2062 static bool 2063 face_flip(const unsigned int face); 2064 2065 /** 2066 * @brief Always return false 2067 */ 2068 static bool 2069 face_rotation(const unsigned int face); 2070 2071 /** 2072 * @brief Always return false 2073 */ 2074 static bool 2075 line_orientation(const unsigned int line); 2076 2077 /** 2078 * @} 2079 */ 2080 2081 /** 2082 * @name Accessing children 2083 */ 2084 /** 2085 * @{ 2086 */ 2087 2088 /** 2089 * Test whether the object has children. Always false. 2090 */ 2091 static bool 2092 has_children(); 2093 2094 /** 2095 * Return the number of immediate children of this object. This is always 2096 * zero. 2097 */ 2098 static unsigned int 2099 n_children(); 2100 2101 /** 2102 * Compute and return the number of active descendants of this objects. 2103 * Always zero. 2104 */ 2105 static unsigned int 2106 number_of_children(); 2107 2108 /** 2109 * Return the number of times that this object is refined. Always 0. 2110 */ 2111 static unsigned int 2112 max_refinement_depth(); 2113 2114 /** 2115 * @brief Return an invalid unsigned integer. 2116 */ 2117 static unsigned int 2118 child_iterator_to_index(const TriaIterator<TriaAccessor<0, dim, spacedim>> &); 2119 2120 /** 2121 * @brief Return an invalid object. 2122 */ 2123 static TriaIterator<TriaAccessor<0, dim, spacedim>> 2124 child(const unsigned int); 2125 2126 /** 2127 * @brief Return an invalid object. 2128 */ 2129 static TriaIterator<TriaAccessor<0, dim, spacedim>> 2130 isotropic_child(const unsigned int); 2131 2132 /** 2133 * Always return no refinement. 2134 */ 2135 static RefinementCase<0> 2136 refinement_case(); 2137 2138 /** 2139 * @brief Returns -1 2140 */ 2141 static int 2142 child_index(const unsigned int i); 2143 2144 /** 2145 * @brief Returns -1 2146 */ 2147 static int 2148 isotropic_child_index(const unsigned int i); 2149 /** 2150 * @} 2151 */ 2152 2153 /** 2154 * Return whether the vertex pointed to here is used. 2155 */ 2156 bool 2157 used() const; 2158 2159 protected: 2160 /** 2161 * Copy operator. Since this is only called from iterators, do not return 2162 * anything, since the iterator will return itself. 2163 * 2164 * This method is protected, since it is only to be called from the iterator 2165 * class. 2166 */ 2167 void 2168 copy_from(const TriaAccessor &); 2169 2170 /** 2171 * Comparison operator for accessors. This operator is used when comparing 2172 * iterators into objects of a triangulation, for example when putting 2173 * them into a `std::map`. 2174 * 2175 * This operator simply compares the global index of the vertex the 2176 * current object points to. 2177 */ 2178 bool 2179 operator<(const TriaAccessor &other) const; 2180 2181 /** 2182 * Pointer to the triangulation we operate on. 2183 */ 2184 const Triangulation<dim, spacedim> *tria; 2185 2186 /** 2187 * The global vertex index of the vertex this object corresponds to. 2188 */ 2189 unsigned int global_vertex_index; 2190 2191 private: 2192 template <typename Accessor> 2193 friend class TriaRawIterator; 2194 template <typename Accessor> 2195 friend class TriaIterator; 2196 template <typename Accessor> 2197 friend class TriaActiveIterator; 2198 }; 2199 2200 2201 2202 /** 2203 * This class is a specialization of <code>TriaAccessor<structdim, dim, 2204 * spacedim></code> 2205 * for the case that @p structdim is zero and @p dim is one. This 2206 * class represents vertices in a one-dimensional triangulation that is 2207 * embedded in a space of dimensionality <code>spacedim</code> (for 2208 * <code>spacedim==dim==1</code> the triangulation represents a domain in 2209 * ${\mathbb R}^\text{dim}$, for <code>spacedim@>dim==1</code> the triangulation 2210 * is of a manifold embedded in a higher dimensional space). 2211 * 2212 * The current specialization of the TriaAccessor<0,dim,spacedim> class 2213 * for vertices of a one-dimensional triangulation exists 2214 * since in the @p dim == 1 case vertices are also faces. 2215 * 2216 * @ingroup Accessors 2217 */ 2218 template <int spacedim> 2219 class TriaAccessor<0, 1, spacedim> 2220 { 2221 public: 2222 /** 2223 * Dimension of the space the object represented by this accessor lives in. 2224 * For example, if this accessor represents a quad that is part of a two- 2225 * dimensional surface in four-dimensional space, then this value is four. 2226 */ 2227 static const unsigned int space_dimension = spacedim; 2228 2229 /** 2230 * Dimensionality of the object that the thing represented by this accessor 2231 * is part of. For example, if this accessor represents a line that is part 2232 * of a hexahedron, then this value will be three. 2233 */ 2234 static const unsigned int dimension = 1; 2235 2236 /** 2237 * Dimensionality of the current object represented by this accessor. For 2238 * example, if it is line (irrespective of whether it is part of a quad or 2239 * hex, and what dimension we are in), then this value equals 1. 2240 */ 2241 static const unsigned int structure_dimension = 0; 2242 2243 /** 2244 * Pointer to internal data. 2245 */ 2246 using AccessorData = void; 2247 2248 /** 2249 * Whether the vertex represented here is at the left end of the domain, the 2250 * right end, or in the interior. 2251 */ 2252 enum VertexKind 2253 { 2254 /** 2255 * Left vertex. 2256 */ 2257 left_vertex, 2258 /** 2259 * Interior vertex. 2260 */ 2261 interior_vertex, 2262 /** 2263 * Right vertex. 2264 */ 2265 right_vertex 2266 }; 2267 2268 /** 2269 * Constructor. 2270 * 2271 * Since there is no mapping from vertices to cells, an accessor object for 2272 * a point has no way to figure out whether it is at the boundary of the 2273 * domain or not. Consequently, the second argument must be passed by the 2274 * object that generates this accessor -- e.g. a 1d cell that can figure out 2275 * whether its left or right vertex are at the boundary. 2276 * 2277 * The third argument is the global index of the vertex we point to. 2278 */ 2279 TriaAccessor(const Triangulation<1, spacedim> *tria, 2280 const VertexKind vertex_kind, 2281 const unsigned int vertex_index); 2282 2283 /** 2284 * Constructor. This constructor exists in order to maintain interface 2285 * compatibility with the other accessor classes. However, it doesn't do 2286 * anything useful here and so may not actually be called. 2287 */ 2288 TriaAccessor(const Triangulation<1, spacedim> *tria = nullptr, 2289 const int = 0, 2290 const int = 0, 2291 const AccessorData * = nullptr); 2292 2293 /** 2294 * Constructor. Should never be called and thus produces an error. 2295 */ 2296 template <int structdim2, int dim2, int spacedim2> 2297 TriaAccessor(const TriaAccessor<structdim2, dim2, spacedim2> &); 2298 2299 /** 2300 * Constructor. Should never be called and thus produces an error. 2301 */ 2302 template <int structdim2, int dim2, int spacedim2> 2303 TriaAccessor(const InvalidAccessor<structdim2, dim2, spacedim2> &); 2304 2305 /** 2306 * Copy operator. Since this is only called from iterators, do not return 2307 * anything, since the iterator will return itself. 2308 */ 2309 void 2310 copy_from(const TriaAccessor &); 2311 2312 /** 2313 * Return the state of the iterator. Since an iterator to points can not be 2314 * incremented or decremented, its state remains constant, and in particular 2315 * equal to IteratorState::valid. 2316 */ 2317 static IteratorState::IteratorStates 2318 state(); 2319 2320 /** 2321 * Level of this object. Vertices have no level, so this function always 2322 * returns zero. 2323 */ 2324 static int 2325 level(); 2326 2327 /** 2328 * Index of this object. Returns the global index of the vertex this object 2329 * points to. 2330 */ 2331 int 2332 index() const; 2333 2334 /** 2335 * Return a reference to the triangulation which the object pointed to by this 2336 * class belongs to. 2337 */ 2338 const Triangulation<1, spacedim> & 2339 get_triangulation() const; 2340 2341 /** 2342 * @name Advancement of iterators 2343 */ 2344 /** 2345 * @{ 2346 */ 2347 /** 2348 * This operator advances the iterator to the next element. For points, this 2349 * operation is not defined, so you can't iterate over point iterators. 2350 */ 2351 void 2352 operator++() const; 2353 2354 /** 2355 * This operator moves the iterator to the previous element. For points, 2356 * this operation is not defined, so you can't iterate over point iterators. 2357 */ 2358 void 2359 operator--() const; 2360 /** 2361 * Compare for equality. 2362 */ 2363 bool 2364 operator==(const TriaAccessor &) const; 2365 2366 /** 2367 * Compare for inequality. 2368 */ 2369 bool 2370 operator!=(const TriaAccessor &) const; 2371 2372 /** 2373 * Comparison operator for accessors. This operator is used when comparing 2374 * iterators into objects of a triangulation, for example when putting 2375 * them into a `std::map`. 2376 * 2377 * This operator simply compares the global index of the vertex the 2378 * current object points to. 2379 */ 2380 bool 2381 operator<(const TriaAccessor &other) const; 2382 2383 /** 2384 * @} 2385 */ 2386 2387 /** 2388 * @name Accessing sub-objects 2389 */ 2390 /** 2391 * @{ 2392 */ 2393 2394 /** 2395 * Return the global index of i-th vertex of the current object. If i is 2396 * zero, this returns the index of the current point to which this object 2397 * refers. Otherwise, it throws an exception. 2398 * 2399 * Note that the returned value is only the index of the geometrical vertex. 2400 * It has nothing to do with possible degrees of freedom associated with it. 2401 * For this, see the @p DoFAccessor::vertex_dof_index functions. 2402 * 2403 * @note Despite the name, the index returned here is only global in the 2404 * sense that it is specific to a particular Triangulation object or, in the 2405 * case the triangulation is actually of type 2406 * parallel::distributed::Triangulation, specific to that part of the 2407 * distributed triangulation stored on the current processor. 2408 */ 2409 unsigned int 2410 vertex_index(const unsigned int i = 0) const; 2411 2412 /** 2413 * Return a reference to the @p ith vertex. If i is zero, this returns a 2414 * reference to the current point to which this object refers. Otherwise, it 2415 * throws an exception. 2416 */ 2417 Point<spacedim> & 2418 vertex(const unsigned int i = 0) const; 2419 2420 /** 2421 * Return the center of this object, which of course coincides with the 2422 * location of the vertex this object refers to. 2423 */ 2424 Point<spacedim> 2425 center() const; 2426 2427 /** 2428 * Pointer to the @p ith line bounding this object. Will point to an invalid 2429 * object. 2430 */ 2431 typename dealii::internal::TriangulationImplementation:: 2432 Iterators<1, spacedim>::line_iterator static line(const unsigned int); 2433 2434 /** 2435 * Line index of the @p ith line bounding this object. 2436 * 2437 * Implemented only for <tt>structdim>1</tt>, otherwise an exception 2438 * generated. 2439 */ 2440 static unsigned int 2441 line_index(const unsigned int i); 2442 2443 /** 2444 * Pointer to the @p ith quad bounding this object. 2445 */ 2446 static typename dealii::internal::TriangulationImplementation:: 2447 Iterators<1, spacedim>::quad_iterator 2448 quad(const unsigned int i); 2449 2450 /** 2451 * Quad index of the @p ith quad bounding this object. 2452 * 2453 * Implemented only for <tt>structdim>2</tt>, otherwise an exception 2454 * generated. 2455 */ 2456 static unsigned int 2457 quad_index(const unsigned int i); 2458 2459 /** 2460 * @} 2461 */ 2462 2463 2464 /** 2465 * Return whether this point is at the boundary of the one-dimensional 2466 * triangulation we deal with here. 2467 */ 2468 bool 2469 at_boundary() const; 2470 2471 /** 2472 * Return the boundary indicator of this object. The convention for one 2473 * dimensional triangulations is that left end vertices (of each line 2474 * segment from which the triangulation may be constructed) have boundary 2475 * indicator zero, and right end vertices have boundary indicator one, 2476 * unless explicitly set differently. 2477 * 2478 * If the return value is the special value 2479 * numbers::internal_face_boundary_id, then this object is in the interior 2480 * of the domain. 2481 * 2482 * @see 2483 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 2484 */ 2485 types::boundary_id 2486 boundary_id() const; 2487 2488 /** 2489 * Return a constant reference to the manifold object used for this object. 2490 */ 2491 const Manifold<1, spacedim> & 2492 get_manifold() const; 2493 2494 /** 2495 * Return the manifold indicator of this object. 2496 * 2497 * @see 2498 * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" 2499 */ 2500 types::manifold_id 2501 manifold_id() const; 2502 2503 2504 /** 2505 * @name Orientation of sub-objects 2506 */ 2507 /** 2508 * @{ 2509 */ 2510 2511 /** 2512 * @brief Always return false 2513 */ 2514 static bool 2515 face_orientation(const unsigned int face); 2516 2517 /** 2518 * @brief Always return false 2519 */ 2520 static bool 2521 face_flip(const unsigned int face); 2522 2523 /** 2524 * @brief Always return false 2525 */ 2526 static bool 2527 face_rotation(const unsigned int face); 2528 2529 /** 2530 * @brief Always return false 2531 */ 2532 static bool 2533 line_orientation(const unsigned int line); 2534 2535 /** 2536 * @} 2537 */ 2538 2539 /** 2540 * @name Accessing children 2541 */ 2542 /** 2543 * @{ 2544 */ 2545 2546 /** 2547 * Test whether the object has children. Always false. 2548 */ 2549 static bool 2550 has_children(); 2551 2552 /** 2553 * Return the number of immediate children of this object.This is always 2554 * zero in dimension 0. 2555 */ 2556 static unsigned int 2557 n_children(); 2558 2559 /** 2560 * Compute and return the number of active descendants of this objects. 2561 * Always zero. 2562 */ 2563 static unsigned int 2564 number_of_children(); 2565 2566 /** 2567 * Return the number of times that this object is refined. Always 0. 2568 */ 2569 static unsigned int 2570 max_refinement_depth(); 2571 2572 /** 2573 * @brief Return an invalid unsigned integer. 2574 */ 2575 static unsigned int 2576 child_iterator_to_index(const TriaIterator<TriaAccessor<0, 1, spacedim>> &); 2577 2578 /** 2579 * @brief Return an invalid object 2580 */ 2581 static TriaIterator<TriaAccessor<0, 1, spacedim>> 2582 child(const unsigned int); 2583 2584 /** 2585 * @brief Return an invalid object 2586 */ 2587 static TriaIterator<TriaAccessor<0, 1, spacedim>> 2588 isotropic_child(const unsigned int); 2589 2590 /** 2591 * Always return no refinement. 2592 */ 2593 static RefinementCase<0> 2594 refinement_case(); 2595 2596 /** 2597 * @brief Returns -1 2598 */ 2599 static int 2600 child_index(const unsigned int i); 2601 2602 /** 2603 * @brief Returns -1 2604 */ 2605 static int 2606 isotropic_child_index(const unsigned int i); 2607 /** 2608 * @} 2609 */ 2610 2611 /** 2612 * @name Dealing with boundary indicators 2613 */ 2614 /** 2615 * @{ 2616 */ 2617 2618 /** 2619 * Set the boundary indicator. The same applies as for the 2620 * <tt>boundary_id()</tt> function. 2621 * 2622 * @warning You should never set the boundary indicator of an interior face 2623 * (a face not at the boundary of the domain), or set the boundary 2624 * indicator of an exterior face to numbers::internal_face_boundary_id (this 2625 * value is reserved for another purpose). Algorithms may not work or 2626 * produce very confusing results if boundary cells have a boundary 2627 * indicator of numbers::internal_face_boundary_id or if interior cells have 2628 * boundary indicators other than numbers::internal_face_boundary_id. 2629 * Unfortunately, the current object has no means of finding out whether it 2630 * really is at the boundary of the domain and so cannot determine whether 2631 * the value you are trying to set makes sense under the current 2632 * circumstances. 2633 * 2634 * @ingroup boundary 2635 * 2636 * @see 2637 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 2638 */ 2639 void 2640 set_boundary_id(const types::boundary_id); 2641 2642 /** 2643 * Set the manifold indicator of this vertex. This does nothing so far since 2644 * manifolds are only used to refine and map objects, but vertices are not 2645 * refined and the mapping is trivial. This function is here only to allow 2646 * dimension independent programming. 2647 */ 2648 void 2649 set_manifold_id(const types::manifold_id); 2650 2651 /** 2652 * Set the boundary indicator of this object and all of its lower- 2653 * dimensional sub-objects. Since this object only represents a single 2654 * vertex, there are no lower-dimensional object and this function is 2655 * equivalent to calling set_boundary_id() with the same argument. 2656 * 2657 * @ingroup boundary 2658 * 2659 * @see 2660 * @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" 2661 */ 2662 void 2663 set_all_boundary_ids(const types::boundary_id); 2664 2665 /** 2666 * Set the manifold indicator of this object and all of its lower- 2667 * dimensional sub-objects. Since this object only represents a single 2668 * vertex, there are no lower-dimensional object and this function is 2669 * equivalent to calling set_manifold_id() with the same argument. 2670 * 2671 * @ingroup manifold 2672 * 2673 * @see 2674 * @ref GlossManifoldIndicator "Glossary entry on manifold indicators" 2675 */ 2676 void 2677 set_all_manifold_ids(const types::manifold_id); 2678 /** 2679 * @} 2680 */ 2681 2682 /** 2683 * Return whether the vertex pointed to here is used. 2684 */ 2685 bool 2686 used() const; 2687 2688 /** 2689 * Reference cell type of the current object. 2690 */ 2691 ReferenceCell::Type 2692 reference_cell_type() const; 2693 2694 /** 2695 * Number of vertices. 2696 */ 2697 unsigned int 2698 n_vertices() const; 2699 2700 /** 2701 * Number of lines. 2702 */ 2703 unsigned int 2704 n_lines() const; 2705 2706 /** 2707 * Return an object that can be thought of as an array containing all indices 2708 * from zero to n_vertices(). 2709 */ 2710 std_cxx20::ranges::iota_view<unsigned int, unsigned int> 2711 vertex_indices() const; 2712 2713 /** 2714 * Return an object that can be thought of as an array containing all indices 2715 * from zero to n_lines(). 2716 */ 2717 std_cxx20::ranges::iota_view<unsigned int, unsigned int> 2718 line_indices() const; 2719 2720 protected: 2721 /** 2722 * Pointer to the triangulation we operate on. 2723 */ 2724 const Triangulation<1, spacedim> *tria; 2725 2726 /** 2727 * Whether this is a left end, right end, or interior vertex. This 2728 * information is provided by the cell at the time of creation. 2729 */ 2730 VertexKind vertex_kind; 2731 2732 /** 2733 * The global vertex index of the vertex this object corresponds to. 2734 */ 2735 unsigned int global_vertex_index; 2736 }; 2737 2738 2739 2740 /** 2741 * This class allows access to a cell: a line in one dimension, a quad in two 2742 * dimension, etc. 2743 * 2744 * The following refers to any dimension: 2745 * 2746 * This class allows access to a <tt>cell</tt>, which is a line in 1D and a 2747 * quad in 2D. Cells have more functionality than lines or quads by 2748 * themselves, for example they can be flagged for refinement, they have 2749 * neighbors, they have the possibility to check whether they are at the 2750 * boundary etc. This class offers access to all this data. 2751 * 2752 * @ingroup grid 2753 * @ingroup Accessors 2754 */ 2755 template <int dim, int spacedim = dim> 2756 class CellAccessor : public TriaAccessor<dim, dim, spacedim> 2757 { 2758 public: 2759 /** 2760 * Propagate the AccessorData type into the present class. 2761 */ 2762 using AccessorData = typename TriaAccessor<dim, dim, spacedim>::AccessorData; 2763 2764 /** 2765 * Define the type of the container this is part of. 2766 */ 2767 using Container = Triangulation<dim, spacedim>; 2768 2769 /** 2770 * @name Constructors 2771 */ 2772 /** 2773 * @{ 2774 */ 2775 2776 /** 2777 * Constructor. 2778 */ 2779 CellAccessor(const Triangulation<dim, spacedim> *parent = nullptr, 2780 const int level = -1, 2781 const int index = -1, 2782 const AccessorData * local_data = nullptr); 2783 2784 /** 2785 * Copy constructor. 2786 */ 2787 CellAccessor(const TriaAccessor<dim, dim, spacedim> &cell_accessor); 2788 2789 /** 2790 * Conversion constructor. This constructor exists to make certain 2791 * constructs simpler to write in dimension independent code. For example, 2792 * it allows assigning a face iterator to a line iterator, an operation that 2793 * is useful in 2d but doesn't make any sense in 3d. The constructor here 2794 * exists for the purpose of making the code conform to C++ but it will 2795 * unconditionally abort; in other words, assigning a face iterator to a 2796 * line iterator is better put into an if-statement that checks that the 2797 * dimension is two, and assign to a quad iterator in 3d (an operator that, 2798 * without this constructor would be illegal if we happen to compile for 2799 * 2d). 2800 */ 2801 template <int structdim2, int dim2, int spacedim2> 2802 CellAccessor(const InvalidAccessor<structdim2, dim2, spacedim2> &); 2803 2804 /** 2805 * Another conversion operator between objects that don't make sense, just 2806 * like the previous one. 2807 */ 2808 template <int structdim2, int dim2, int spacedim2> 2809 CellAccessor(const TriaAccessor<structdim2, dim2, spacedim2> &); 2810 2811 /** 2812 * Copy operator. These operators are usually used in a context like 2813 * <tt>iterator a,b; *a=*b;</tt>. Presumably, the intent here is to copy the 2814 * object pointed to 2815 * by @p b to the object pointed to by @p a. However, the result of 2816 * dereferencing an iterator is not an object but an accessor; consequently, 2817 * this operation is not useful for iterators on triangulations. 2818 * Consequently, this operator is declared as deleted and can not be used. 2819 */ 2820 void 2821 operator=(const CellAccessor<dim, spacedim> &) = delete; 2822 2823 /** 2824 * @} 2825 */ 2826 2827 /** 2828 * @name Accessing sub-objects and neighbors 2829 */ 2830 /** 2831 * @{ 2832 */ 2833 2834 /** 2835 * Return a pointer to the @p ith child. Overloaded version which returns a 2836 * more reasonable iterator class. 2837 */ 2838 TriaIterator<CellAccessor<dim, spacedim>> 2839 child(const unsigned int i) const; 2840 2841 /** 2842 * Return an iterator to the @p ith face of this cell. 2843 */ 2844 TriaIterator<TriaAccessor<dim - 1, dim, spacedim>> 2845 face(const unsigned int i) const; 2846 2847 /** 2848 * Return the face number of @p face on the current cell. This is the 2849 * inverse function of TriaAccessor::face(). 2850 */ 2851 unsigned int 2852 face_iterator_to_index( 2853 const TriaIterator<TriaAccessor<dim - 1, dim, spacedim>> &face) const; 2854 2855 /** 2856 * Return an array of iterators to all faces of this cell. 2857 */ 2858 boost::container::small_vector< 2859 TriaIterator<TriaAccessor<dim - 1, dim, spacedim>>, 2860 GeometryInfo<dim>::faces_per_cell> 2861 face_iterators() const; 2862 2863 /** 2864 * Return the (global) index of the @p ith face of this cell. 2865 * 2866 * @note Despite the name, the index returned here is only global in the 2867 * sense that it is specific to a particular Triangulation object or, in the 2868 * case the triangulation is actually of type 2869 * parallel::distributed::Triangulation, specific to that part of the 2870 * distributed triangulation stored on the current processor. 2871 */ 2872 unsigned int 2873 face_index(const unsigned int i) const; 2874 2875 /** 2876 * Return an iterator to that cell that neighbors the present cell on the 2877 * given face and subface number. 2878 * 2879 * To succeed, the present cell must not be further refined, and the 2880 * neighbor on the given face must be further refined exactly once; the 2881 * returned cell is then a child of that neighbor. 2882 * 2883 * The function may not be called in 1d, since there we have no subfaces. 2884 * The implementation of this function is rather straightforward in 2d, by 2885 * first determining which face of the neighbor cell the present cell is 2886 * bordering on (this is what the @p neighbor_of_neighbor function does), 2887 * and then asking @p GeometryInfo::child_cell_on_subface for the index of 2888 * the child. 2889 * 2890 * However, the situation is more complicated in 3d, since there faces may 2891 * have more than one orientation, and we have to use @p face_orientation, 2892 * @p face_flip and @p face_rotation for both this and the neighbor cell to 2893 * figure out which cell we want to have. 2894 * 2895 * This can lead to surprising results: if we are sitting on a cell and are 2896 * asking for a cell behind subface <tt>sf</tt>, then this means that we are 2897 * considering the subface for the face in the natural direction for the 2898 * present cell. However, if the face as seen from this cell has 2899 * <tt>face_orientation()==false</tt>, then the child of the face that 2900 * separates the present cell from the neighboring cell's child is not 2901 * necessarily the @p sf-th child of the face of this cell. This is so 2902 * because the @p subface_no on a cell corresponds to the subface with 2903 * respect to the intrinsic ordering of the present cell, whereas children 2904 * of face iterators are computed with respect to the intrinsic ordering of 2905 * faces; these two orderings are only identical if the face orientation is 2906 * @p true, and reversed otherwise. 2907 * 2908 * Similarly, effects of <tt>face_flip()==true</tt> and 2909 * <tt>face_rotation()==true()</tt>, both of which indicate a non-standard 2910 * face have to be considered. 2911 * 2912 * Fortunately, this is only very rarely of concern, since usually one 2913 * simply wishes to loop over all finer neighbors at a given face of an 2914 * active cell. Only in the process of refinement of a Triangulation we want 2915 * to set neighbor information for both our child cells and the neighbor's 2916 * children. Since we can respect orientation of faces from our current cell 2917 * in that case, we do NOT respect face_orientation, face_flip and 2918 * face_rotation of the present cell within this function, i.e. the returned 2919 * neighbor's child is behind subface @p subface concerning the intrinsic 2920 * ordering of the given face. 2921 */ 2922 TriaIterator<CellAccessor<dim, spacedim>> 2923 neighbor_child_on_subface(const unsigned int face_no, 2924 const unsigned int subface_no) const; 2925 2926 /** 2927 * Return an iterator to the neighboring cell on the other side of the face 2928 * with number @p face_no. If the neighbor does not exist, 2929 * i.e., if the face with number @p face_no of the current object is at the boundary, then 2930 * an invalid iterator is returned. 2931 * 2932 * Consequently, the index @p face_no must be less than n_faces(). 2933 * 2934 * The neighbor of a cell has at most the same level as this cell. For 2935 * example, consider the following situation: 2936 * @image html limit_level_difference_at_vertices.png "" 2937 * Here, if you are on the top right cell and you ask for its left neighbor 2938 * (which is, according to the conventions spelled out in the GeometryInfo 2939 * class, its <i>zeroth</i> neighbor), then you will get the mother cell of 2940 * the four small cells at the top left. In other words, the cell you get as 2941 * neighbor has the same refinement level as the one you're on right now 2942 * (the top right one) and it may have children. 2943 * 2944 * On the other hand, if you were at the top right cell of the four small 2945 * cells at the top left, and you asked for the right neighbor (which is 2946 * associated with index <code>face_no=1</code>), then you would get the large 2947 * cell at the top right which in this case has a lower refinement level and 2948 * no children of its own. 2949 */ 2950 TriaIterator<CellAccessor<dim, spacedim>> 2951 neighbor(const unsigned int face_no) const; 2952 2953 /** 2954 * Return the cell index of the neighboring cell on the other side of the face 2955 * with index @p face_no. If the neighbor does not exist, this function returns -1. 2956 * 2957 * This function is equivalent to <tt>cell->neighbor(face_no)->index()</tt>. 2958 * See neighbor() for more details. 2959 */ 2960 int 2961 neighbor_index(const unsigned int face_no) const; 2962 2963 /** 2964 * Return the level of the neighboring cell on the other side of the face with 2965 * number @p face_no. If the neighbor does not exist, this function returns -1. 2966 * 2967 * This function is equivalent to `cell->neighbor(face_no)->level()`. 2968 * See neighbor() for more details. 2969 */ 2970 int 2971 neighbor_level(const unsigned int face_no) const; 2972 2973 /** 2974 * Return the how-many'th neighbor this cell is of 2975 * <tt>cell->neighbor(face_no)</tt>, i.e. return @p other_face_no such that 2976 * <tt>cell->neighbor(face_no)->neighbor(other_face_no)==cell</tt>. This 2977 * function is the right one if you want to know how to get back from a 2978 * neighbor to the present cell. 2979 * 2980 * Note that this operation is only useful if the neighbor is not coarser 2981 * than the present cell. If the neighbor is coarser this function throws an 2982 * exception. Use the @p neighbor_of_coarser_neighbor function in that case. 2983 */ 2984 unsigned int 2985 neighbor_of_neighbor(const unsigned int face_no) const; 2986 2987 /** 2988 * Return, whether the neighbor is coarser then the present cell. This is 2989 * important in case of anisotropic refinement where this information does 2990 * not depend on the levels of the cells. 2991 * 2992 * Note, that in an anisotropic setting, a cell can only be coarser than 2993 * another one at a given face, not on a general basis. The face of the 2994 * finer cell is contained in the corresponding face of the coarser cell, 2995 * the finer face is either a child or a grandchild of the coarser face. 2996 */ 2997 bool 2998 neighbor_is_coarser(const unsigned int face_no) const; 2999 3000 /** 3001 * This function is a generalization of the @p neighbor_of_neighbor function 3002 * for the case of a coarser neighbor. It returns a pair of numbers, face_no 3003 * and subface_no, with the following property, if the neighbor is not 3004 * refined: <tt>cell->neighbor(neighbor)->neighbor_child_on_subface(face_no, 3005 * subface_no)==cell</tt>. In 3D, a coarser neighbor can still be refined. 3006 * In that case subface_no denotes the child index of the neighbors face 3007 * that relates to our face: 3008 * <tt>cell->neighbor(neighbor)->face(face_no)->child(subface_no)==cell->face(neighbor)</tt>. 3009 * This case in 3d and how it can happen is discussed in the introduction of 3010 * the step-30 tutorial program. 3011 * 3012 * This function is impossible for <tt>dim==1</tt>. 3013 */ 3014 std::pair<unsigned int, unsigned int> 3015 neighbor_of_coarser_neighbor(const unsigned int neighbor) const; 3016 3017 /** 3018 * This function is a generalization of the @p neighbor_of_neighbor and the 3019 * @p neighbor_of_coarser_neighbor functions. It checks whether the neighbor 3020 * is coarser or not and calls the respective function. In both cases, only 3021 * the face_no is returned. 3022 */ 3023 unsigned int 3024 neighbor_face_no(const unsigned int neighbor) const; 3025 3026 /** 3027 * Compatibility interface with DoFCellAccessor. Always returns @p false. 3028 */ 3029 static bool 3030 is_level_cell(); 3031 3032 /** 3033 * @} 3034 */ 3035 /** 3036 * @name Dealing with periodic neighbors 3037 */ 3038 /** 3039 * @{ 3040 */ 3041 /** 3042 * If the cell has a periodic neighbor at its @c ith face, this function 3043 * returns true, otherwise, the returned value is false. 3044 */ 3045 bool 3046 has_periodic_neighbor(const unsigned int i) const; 3047 3048 /** 3049 * For a cell with its @c ith face at a periodic boundary, 3050 * see 3051 * @ref GlossPeriodicConstraints "the entry for periodic boundaries", 3052 * this function returns an iterator to the cell on the other side 3053 * of the periodic boundary. If there is no periodic boundary at the @c ith 3054 * face, an exception will be thrown. 3055 * In order to avoid running into an exception, check the result of 3056 * has_periodic_neighbor() for the @c ith face prior to using this function. 3057 * The behavior of periodic_neighbor() is similar to neighbor(), in 3058 * the sense that the returned cell has at most the same level of refinement 3059 * as the current cell. On distributed meshes, by calling 3060 * Triangulation::add_periodicity(), 3061 * we can make sure that the element on the other side of the periodic 3062 * boundary exists in this rank as a ghost cell or a locally owned cell. 3063 */ 3064 TriaIterator<CellAccessor<dim, spacedim>> 3065 periodic_neighbor(const unsigned int i) const; 3066 3067 /** 3068 * For a cell whose @c ith face is not at a boundary, this function returns 3069 * the same result as neighbor(). If the @c ith face is at a periodic boundary 3070 * this function returns the same result as periodic_neighbor(). If neither of 3071 * the aforementioned conditions are met, i.e. the @c ith face is on a 3072 * nonperiodic boundary, an exception will be thrown. 3073 */ 3074 TriaIterator<CellAccessor<dim, spacedim>> 3075 neighbor_or_periodic_neighbor(const unsigned int i) const; 3076 3077 /** 3078 * Return an iterator to the periodic neighbor of the cell at a given 3079 * face and subface number. The general guidelines for using this function 3080 * is similar to the function neighbor_child_on_subface(). The 3081 * implementation of this function is consistent with 3082 * periodic_neighbor_of_coarser_periodic_neighbor(). For instance, 3083 * assume that we are sitting on a cell named @c cell1, whose neighbor behind 3084 * the @c ith face is one level coarser. Let us name this coarser neighbor 3085 * @c cell2. Then, by calling 3086 * periodic_neighbor_of_coarser_periodic_neighbor(), from @c cell1, we get 3087 * a @c face_num and a @c subface_num. Now, if we call 3088 * periodic_neighbor_child_on_subface() from cell2, with the above face_num 3089 * and subface_num, we get an iterator to @c cell1. 3090 */ 3091 TriaIterator<CellAccessor<dim, spacedim>> 3092 periodic_neighbor_child_on_subface(const unsigned int face_no, 3093 const unsigned int subface_no) const; 3094 3095 /** 3096 * This function is a generalization of 3097 * periodic_neighbor_of_periodic_neighbor() 3098 * for those cells which have a coarser periodic neighbor. The returned 3099 * pair of numbers can be used in periodic_neighbor_child_on_subface() 3100 * to get back to the current cell. In other words, the following 3101 * assertion should be true, for a cell with coarser periodic neighbor: 3102 * cell->periodic_neighbor(i)->periodic_neighbor_child_on_subface(face_no, 3103 * subface_no)==cell 3104 */ 3105 std::pair<unsigned int, unsigned int> 3106 periodic_neighbor_of_coarser_periodic_neighbor(const unsigned face_no) const; 3107 3108 /** 3109 * This function returns the index of the periodic neighbor at the 3110 * @c ith face of the current cell. If there is no periodic neighbor 3111 * at the given face, the returned value is -1. 3112 */ 3113 int 3114 periodic_neighbor_index(const unsigned int i) const; 3115 3116 /** 3117 * This function returns the level of the periodic neighbor at the 3118 * @c ith face of the current cell. If there is no periodic neighbor 3119 * at the given face, the returned value is -1. 3120 */ 3121 int 3122 periodic_neighbor_level(const unsigned int i) const; 3123 3124 /** 3125 * For a cell with a periodic neighbor at its @c ith face, this function 3126 * returns the face number of that periodic neighbor such that the 3127 * current cell is the periodic neighbor of that neighbor. In other words 3128 * the following assertion holds for those cells which have a periodic 3129 * neighbor with the same or a higher level of refinement as the current 3130 * cell: 3131 * @c {cell->periodic_neighbor(i)-> 3132 * periodic_neighbor(cell->periodic_neighbor_of_periodic_neighbor(i))==cell} 3133 * For the cells with a coarser periodic neighbor, one should use 3134 * periodic_neighbor_of_coarser_periodic_neighbor() and 3135 * periodic_neighbor_child_on_subface() 3136 * to get back to the current cell. 3137 */ 3138 unsigned int 3139 periodic_neighbor_of_periodic_neighbor(const unsigned int i) const; 3140 3141 /** 3142 * If a cell has a periodic neighbor at its @c ith face, this function 3143 * returns the face number of the periodic neighbor, which is connected 3144 * to the @c ith face of this cell. 3145 */ 3146 unsigned int 3147 periodic_neighbor_face_no(const unsigned int i) const; 3148 3149 /** 3150 * This function returns true if the element on the other side of the 3151 * periodic boundary is coarser and returns false otherwise. The 3152 * implementation allows this function to work in the case of 3153 * anisotropic refinement. 3154 */ 3155 bool 3156 periodic_neighbor_is_coarser(const unsigned int i) const; 3157 3158 /** 3159 * @} 3160 */ 3161 3162 /** 3163 * @name Dealing with boundary indicators 3164 */ 3165 /** 3166 * @{ 3167 */ 3168 3169 /** 3170 * Return whether the @p ith vertex or face (depending on the dimension) is 3171 * part of the boundary. This is true, if the @p ith neighbor does not 3172 * exist. 3173 */ 3174 bool 3175 at_boundary(const unsigned int i) const; 3176 3177 /** 3178 * Return whether the cell is at the boundary. Being at the boundary is 3179 * defined by one face being on the boundary. Note that this does not catch 3180 * cases where only one vertex of a quad or of a hex is at the boundary, or 3181 * where only one line of a hex is at the boundary while the interiors of 3182 * all faces are in the interior of the domain. For the latter case, the @p 3183 * has_boundary_lines function is the right one to ask. 3184 */ 3185 bool 3186 at_boundary() const; 3187 3188 /** 3189 * This is a slight variation to the @p at_boundary function: for 1 and 2 3190 * dimensions, it is equivalent, for three dimensions it returns whether at 3191 * least one of the 12 lines of the hexahedron is at a boundary. This, of 3192 * course, includes the case where a whole face is at the boundary, but also 3193 * some other cases. 3194 */ 3195 bool 3196 has_boundary_lines() const; 3197 /** 3198 * @} 3199 */ 3200 3201 /** 3202 * @name Dealing with refinement indicators 3203 */ 3204 /** 3205 * @{ 3206 */ 3207 3208 /** 3209 * Return the @p RefinementCase<dim> this cell was flagged to be refined 3210 * with. The return value of this function can be compared to a bool to 3211 * check if this cell is flagged for any kind of refinement. For example, if 3212 * you have previously called cell->set_refine_flag() for a cell, then you 3213 * will enter the 'if' block in the following snippet: 3214 * 3215 * @code 3216 * if (cell->refine_flag_set()) 3217 * { 3218 * // yes, this cell is marked for refinement. 3219 * } 3220 * @endcode 3221 */ 3222 RefinementCase<dim> 3223 refine_flag_set() const; 3224 3225 /** 3226 * Flag the cell pointed to for refinement. This function is only allowed 3227 * for active cells. Keeping the default value for @p ref_case will mark 3228 * this cell for isotropic refinement. 3229 * 3230 * If you choose anisotropic refinement, for example by passing as argument 3231 * one of the flags RefinementCase::cut_x, RefinementCase::cut_y, 3232 * RefinementCase::cut_z, or a combination of these, then keep in mind 3233 * that refining in x-, y-, or z-direction happens with regard to the 3234 * <em>local</em> coordinate system of the cell. In other words, these 3235 * flags determine which edges and faces of the cell will be cut into new 3236 * edges and faces. On the other hand, this process is independent of 3237 * how the cell is oriented within the <em>global</em> coordinate system, 3238 * and you should not assume any particular orientation of the cell's 3239 * local coordinate system within the global coordinate system of the 3240 * space it lives in. 3241 */ 3242 void 3243 set_refine_flag(const RefinementCase<dim> ref_case = 3244 RefinementCase<dim>::isotropic_refinement) const; 3245 3246 /** 3247 * Clear the refinement flag. 3248 */ 3249 void 3250 clear_refine_flag() const; 3251 3252 /** 3253 * Modify the refinement flag of the cell to ensure (at least) the given 3254 * refinement case @p face_refinement_case at face <tt>face_no</tt>, taking 3255 * into account orientation, flip and rotation of the face. Return, whether 3256 * the refinement flag had to be modified. This function is only allowed for 3257 * active cells. 3258 */ 3259 bool 3260 flag_for_face_refinement( 3261 const unsigned int face_no, 3262 const RefinementCase<dim - 1> &face_refinement_case = 3263 RefinementCase<dim - 1>::isotropic_refinement) const; 3264 3265 /** 3266 * Modify the refinement flag of the cell to ensure that line 3267 * <tt>face_no</tt> will be refined. Return, whether the refinement flag had 3268 * to be modified. This function is only allowed for active cells. 3269 */ 3270 bool 3271 flag_for_line_refinement(const unsigned int line_no) const; 3272 3273 /** 3274 * Return the SubfaceCase of face <tt>face_no</tt>. Note that this is not 3275 * identical to asking <tt>cell->face(face_no)->refinement_case()</tt> since 3276 * the latter returns a RefinementCase<dim-1> and thus only considers one 3277 * (anisotropic) refinement, whereas this function considers the complete 3278 * refinement situation including possible refinement of the face's 3279 * children. This function may only be called for active cells in 2d and 3d. 3280 */ 3281 dealii::internal::SubfaceCase<dim> 3282 subface_case(const unsigned int face_no) const; 3283 3284 /** 3285 * Return whether the coarsen flag is set or not. 3286 */ 3287 bool 3288 coarsen_flag_set() const; 3289 3290 /** 3291 * Flag the cell pointed to for coarsening. This function is only allowed 3292 * for active cells. 3293 */ 3294 void 3295 set_coarsen_flag() const; 3296 3297 /** 3298 * Clear the coarsen flag. 3299 */ 3300 void 3301 clear_coarsen_flag() const; 3302 /** 3303 * @} 3304 */ 3305 3306 /** 3307 * @name Dealing with material indicators 3308 */ 3309 /** 3310 * @{ 3311 */ 3312 3313 /** 3314 * Return the material id of this cell. 3315 * 3316 * For a typical use of this function, see the 3317 * @ref step_28 "step-28" 3318 * tutorial program. 3319 * 3320 * See the 3321 * @ref GlossMaterialId "glossary" 3322 * for more information. 3323 */ 3324 types::material_id 3325 material_id() const; 3326 3327 /** 3328 * Set the material id of this cell. 3329 * 3330 * For a typical use of this function, see the 3331 * @ref step_28 "step-28" 3332 * tutorial program. 3333 * 3334 * See the 3335 * @ref GlossMaterialId "glossary" 3336 * for more information. 3337 */ 3338 void 3339 set_material_id(const types::material_id new_material_id) const; 3340 3341 /** 3342 * Set the material id of this cell and all its children (and grand- 3343 * children, and so on) to the given value. 3344 * 3345 * See the 3346 * @ref GlossMaterialId "glossary" 3347 * for more information. 3348 */ 3349 void 3350 recursively_set_material_id(const types::material_id new_material_id) const; 3351 /** 3352 * @} 3353 */ 3354 3355 /** 3356 * @name Dealing with subdomain indicators 3357 */ 3358 /** 3359 * @{ 3360 */ 3361 3362 /** 3363 * Return the subdomain id of this cell. 3364 * 3365 * See the 3366 * @ref GlossSubdomainId "glossary" 3367 * for more information. 3368 * 3369 * @note The subdomain of a cell is a property only defined for active 3370 * cells, i.e., cells that are not further refined. Consequently, you can 3371 * only call this function if the cell it refers to has no children. For 3372 * multigrid methods in parallel, it is also important to know which 3373 * processor owns non-active cells, and for this you can call 3374 * level_subdomain_id(). 3375 */ 3376 types::subdomain_id 3377 subdomain_id() const; 3378 3379 /** 3380 * Set the subdomain id of this cell. 3381 * 3382 * See the 3383 * @ref GlossSubdomainId "glossary" 3384 * for more information. This function should not be called if you use a 3385 * parallel::distributed::Triangulation object. 3386 * 3387 * @note The subdomain of a cell is a property only defined for active 3388 * cells, i.e., cells that are not further refined. Consequently, you can 3389 * only call this function if the cell it refers to has no children. For 3390 * multigrid methods in parallel, it is also important to know which 3391 * processor owns non-active cells, and for this you can call 3392 * level_subdomain_id(). 3393 */ 3394 void 3395 set_subdomain_id(const types::subdomain_id new_subdomain_id) const; 3396 3397 /** 3398 * Get the level subdomain id of this cell. This is used for parallel 3399 * multigrid where not only the global mesh (consisting of the active cells) 3400 * is partitioned among processors, but also the individual levels of the 3401 * hierarchy of recursively refined cells that make up the mesh. In 3402 * other words, the level subdomain id is a property that is also defined 3403 * for non-active cells if a multigrid hierarchy is used. 3404 */ 3405 types::subdomain_id 3406 level_subdomain_id() const; 3407 3408 /** 3409 * Set the level subdomain id of this cell. This is used for parallel 3410 * multigrid. 3411 */ 3412 void 3413 set_level_subdomain_id( 3414 const types::subdomain_id new_level_subdomain_id) const; 3415 3416 3417 /** 3418 * Set the subdomain id of this cell (if it is active) or all its terminal 3419 * children (and grand-children, and so on, as long as they have no children 3420 * of their own) to the given value. Since the subdomain id is a concept 3421 * that is only defined for cells that are active (i.e., have no children of 3422 * their own), this function only sets the subdomain ids for all children 3423 * and grand children of this cell that are actually active, skipping 3424 * intermediate child cells. 3425 * 3426 * See the 3427 * @ref GlossSubdomainId "glossary" 3428 * for more information. This function should not be called if you use a 3429 * parallel::distributed::Triangulation object since there the subdomain id 3430 * is implicitly defined by which processor you're on. 3431 */ 3432 void 3433 recursively_set_subdomain_id( 3434 const types::subdomain_id new_subdomain_id) const; 3435 /** 3436 * @} 3437 */ 3438 3439 /** 3440 * @name Dealing with codim 1 cell orientation 3441 */ 3442 /** 3443 * @{ 3444 */ 3445 3446 /** 3447 * Return the orientation of this cell. 3448 * 3449 * For the meaning of this flag, see 3450 * @ref GlossDirectionFlag. 3451 */ 3452 bool 3453 direction_flag() const; 3454 3455 /** 3456 * Return the how many-th active cell the current cell is (assuming the 3457 * current cell is indeed active). This is useful, for example, if you are 3458 * accessing the elements of a vector with as many entries as there are 3459 * active cells. Such vectors are used for estimating the error on each cell 3460 * of a triangulation, for specifying refinement criteria passed to the 3461 * functions in GridRefinement, and for generating cell-wise output. 3462 * 3463 * The function throws an exception if the current cell is not active. 3464 * 3465 * @note If the triangulation this function is called on is of type 3466 * parallel::distributed::Triangulation, then active cells may be locally 3467 * owned, ghost cells, or artificial (see 3468 * @ref GlossLocallyOwnedCell, 3469 * @ref GlossGhostCell, 3470 * and 3471 * @ref GlossArtificialCell). 3472 * This function counts over all of them, including ghost and artificial 3473 * active cells. This implies that the index returned by this function 3474 * uniquely identifies a cell within the triangulation on a single 3475 * processor, but does not uniquely identify the cell among the (parts of 3476 * the) triangulation that is shared among processors. If you would like to 3477 * identify active cells across processors, you need to consider the CellId 3478 * of a cell returned by CellAccessor::id(). 3479 */ 3480 unsigned int 3481 active_cell_index() const; 3482 3483 /** 3484 * Return the index of the parent of this cell within the level of the 3485 * triangulation to which the parent cell belongs. The level of the parent 3486 * is of course one lower than that of the present cell. If the parent does 3487 * not exist (i.e., if the object is at the coarsest level of the mesh 3488 * hierarchy), an exception is generated. 3489 */ 3490 int 3491 parent_index() const; 3492 3493 /** 3494 * Return an iterator to the parent. If the parent does not exist (i.e., if 3495 * the object is at the coarsest level of the mesh hierarchy), an exception 3496 * is generated. 3497 */ 3498 TriaIterator<CellAccessor<dim, spacedim>> 3499 parent() const; 3500 3501 /** 3502 * @} 3503 */ 3504 3505 /** 3506 * @name Other functions 3507 */ 3508 /** 3509 * @{ 3510 */ 3511 3512 /** 3513 * Test that the cell has no children (this is the criterion for whether a 3514 * cell is called "active"). 3515 * 3516 * See the 3517 * @ref GlossActive "glossary" 3518 * for more information. 3519 * 3520 * @deprecated This function is deprecated. Use the is_active() 3521 * function instead, which satisfies the naming scheme of other 3522 * functions inquiring about yes/no properties of cells (e.g., 3523 * is_ghost(), is_locally_owned(), etc.). 3524 */ 3525 DEAL_II_DEPRECATED 3526 bool 3527 active() const; 3528 3529 /** 3530 * Test that the cell has no children (this is the criterion for whether a 3531 * cell is called "active"). 3532 * 3533 * See the 3534 * @ref GlossActive "glossary" 3535 * for more information. 3536 */ 3537 bool 3538 is_active() const; 3539 3540 /** 3541 * Return whether this cell is owned by the current processor or is owned by 3542 * another processor. The function always returns true if applied to an 3543 * object of type dealii::Triangulation, but may yield false if the 3544 * triangulation is of type parallel::distributed::Triangulation. 3545 * 3546 * See the 3547 * @ref GlossGhostCell "glossary" 3548 * and the 3549 * @ref distributed 3550 * module for more information. 3551 * 3552 * @post The returned value is equal to <code>!is_ghost() && 3553 * !is_artificial()</code>. 3554 * 3555 * @note Whether a cell is a ghost cell, artificial, or is locally owned or 3556 * is a property that only pertains to cells that are active. Consequently, 3557 * you can only call this function if the cell it refers to has no children. 3558 */ 3559 bool 3560 is_locally_owned() const; 3561 3562 /** 3563 * Return true if either the Triangulation is not distributed or if 3564 * level_subdomain_id() is equal to the id of the current processor. 3565 */ 3566 bool 3567 is_locally_owned_on_level() const; 3568 3569 /** 3570 * Return whether this cell exists in the global mesh but (i) is owned by 3571 * another processor, i.e. has a subdomain_id different from the one the 3572 * current processor owns and (ii) is adjacent to a cell owned by the 3573 * current processor. 3574 * 3575 * This function only makes sense if the triangulation used is of kind 3576 * parallel::distributed::Triangulation. In all other cases, the returned 3577 * value is always false. 3578 * 3579 * See the 3580 * @ref GlossGhostCell "glossary" 3581 * and the 3582 * @ref distributed 3583 * module for more information. 3584 * 3585 * @post The returned value is equal to <code>!is_locally_owned() && 3586 * !is_artificial()</code>. 3587 * 3588 * @note Whether a cell is a ghost cell, artificial, or is locally owned or 3589 * is a property that only pertains to cells that are active. Consequently, 3590 * you can only call this function if the cell it refers to has no children. 3591 */ 3592 bool 3593 is_ghost() const; 3594 3595 /** 3596 * Return whether this cell is artificial, i.e. it isn't one of the cells 3597 * owned by the current processor, and it also doesn't border on one. As a 3598 * consequence, it exists in the mesh to ensure that each processor has all 3599 * coarse mesh cells and that the 2:1 ratio of neighboring cells is 3600 * maintained, but it is not one of the cells we should work on on the 3601 * current processor. In particular, there is no guarantee that this cell 3602 * isn't, in fact, further refined on one of the other processors. 3603 * 3604 * This function only makes sense if the triangulation used is of kind 3605 * parallel::distributed::Triangulation. In all other cases, the returned 3606 * value is always false. 3607 * 3608 * See the 3609 * @ref GlossArtificialCell "glossary" 3610 * and the 3611 * @ref distributed 3612 * module for more information. 3613 * 3614 * @post The returned value is equal to <code>!is_ghost() && 3615 * !is_locally_owned()</code>. 3616 * 3617 * @note Whether a cell is a ghost cell, artificial, or is locally owned is 3618 * a property that only pertains to cells that are active. Consequently, you 3619 * can only call this function if the cell it refers to has no children. 3620 */ 3621 bool 3622 is_artificial() const; 3623 3624 /** 3625 * Test whether the point @p p is inside this cell. Points on the boundary 3626 * are counted as being inside the cell. 3627 * 3628 * Note that this function assumes that the mapping between unit cell and 3629 * real cell is (bi-, tri-)linear, i.e. that faces in 2d and edges in 3d are 3630 * straight lines. If you have higher order transformations, results may be 3631 * different as to whether a point is in- or outside the cell in real space. 3632 * 3633 * In case of codim>0, the point is first projected to the manifold where 3634 * the cell is embedded and then check if this projection is inside the 3635 * cell. 3636 */ 3637 bool 3638 point_inside(const Point<spacedim> &p) const; 3639 3640 /** 3641 * Set the neighbor @p i of this cell to the cell pointed to by @p pointer. 3642 * 3643 * This function shouldn't really be public (but needs to for various 3644 * reasons in order not to make a long list of functions friends): it 3645 * modifies internal data structures and may leave things. Do not use it 3646 * from application codes. 3647 */ 3648 void 3649 set_neighbor(const unsigned int i, 3650 const TriaIterator<CellAccessor<dim, spacedim>> &pointer) const; 3651 3652 /** 3653 * Return a unique ID for the current cell. This ID is constructed from the 3654 * path in the hierarchy from the coarse father cell and works correctly in 3655 * parallel computations using objects of type 3656 * parallel::distributed::Triangulation. This function is therefore useful 3657 * in providing a unique identifier for cells (active or not) that also 3658 * works for parallel triangulations. See the documentation of the CellId 3659 * class for more information. 3660 * 3661 * @note This operation takes O(level) time to compute. In most practical 3662 * cases, the number of levels of a triangulation will depend 3663 * logarithmically on the number of cells in the triangulation. 3664 */ 3665 CellId 3666 id() const; 3667 3668 /** 3669 * @} 3670 */ 3671 3672 3673 /** 3674 * @ingroup Exceptions 3675 */ 3676 DeclException0(ExcRefineCellNotActive); 3677 /** 3678 * @ingroup Exceptions 3679 */ 3680 DeclException0(ExcCellFlaggedForRefinement); 3681 /** 3682 * @ingroup Exceptions 3683 */ 3684 DeclException0(ExcCellFlaggedForCoarsening); 3685 3686 protected: 3687 /** 3688 * This function assumes that the neighbor is not coarser than the current 3689 * cell. In this case it returns the neighbor_of_neighbor() value. If, 3690 * however, the neighbor is coarser this function returns an 3691 * <code>invalid_unsigned_int</code>. 3692 * 3693 * This function is not for public use. Use the function 3694 * neighbor_of_neighbor() instead which throws an exception if called for a 3695 * coarser neighbor. If neighbor is indeed coarser (you get to know this by 3696 * e.g. the neighbor_is_coarser() function) then the 3697 * neighbor_of_coarser_neighbor() function should be call. If you'd like to 3698 * know only the <code>face_no</code> which is required to get back from the 3699 * neighbor to the present cell then simply use the neighbor_face_no() 3700 * function which can be used for coarser as well as non-coarser neighbors. 3701 */ 3702 unsigned int 3703 neighbor_of_neighbor_internal(const unsigned int neighbor) const; 3704 3705 /** 3706 * As for any codim>0 we can use a similar code and c++ does not allow 3707 * partial templates. we use this auxiliary function that is then called 3708 * from point_inside. 3709 */ 3710 template <int dim_, int spacedim_> 3711 bool 3712 point_inside_codim(const Point<spacedim_> &p) const; 3713 3714 3715 3716 private: 3717 /** 3718 * Set the active cell index of a cell. This is done at the end of 3719 * refinement. 3720 */ 3721 void 3722 set_active_cell_index(const unsigned int active_cell_index); 3723 3724 /** 3725 * Set the parent of a cell. 3726 */ 3727 void 3728 set_parent(const unsigned int parent_index); 3729 3730 /** 3731 * Set the orientation of this cell. 3732 * 3733 * For the meaning of this flag, see 3734 * @ref GlossDirectionFlag. 3735 */ 3736 void 3737 set_direction_flag(const bool new_direction_flag) const; 3738 3739 template <int, int> 3740 friend class Triangulation; 3741 3742 friend struct dealii::internal::TriangulationImplementation::Implementation; 3743 }; 3744 3745 3746 3747 /* ----- declaration of explicit specializations and general templates ----- */ 3748 3749 3750 template <int structdim, int dim, int spacedim> 3751 template <typename OtherAccessor> 3752 InvalidAccessor<structdim, dim, spacedim>::InvalidAccessor( 3753 const OtherAccessor &) 3754 { 3755 Assert(false, 3756 ExcMessage("You are attempting an illegal conversion between " 3757 "iterator/accessor types. The constructor you call " 3758 "only exists to make certain template constructs " 3759 "easier to write as dimension independent code but " 3760 "the conversion is not valid in the current context.")); 3761 } 3762 3763 3764 3765 template <int structdim, int dim, int spacedim> 3766 template <int structdim2, int dim2, int spacedim2> 3767 TriaAccessor<structdim, dim, spacedim>::TriaAccessor( 3768 const InvalidAccessor<structdim2, dim2, spacedim2> &) 3769 { 3770 Assert(false, 3771 ExcMessage("You are attempting an illegal conversion between " 3772 "iterator/accessor types. The constructor you call " 3773 "only exists to make certain template constructs " 3774 "easier to write as dimension independent code but " 3775 "the conversion is not valid in the current context.")); 3776 } 3777 3778 3779 3780 template <int dim, int spacedim> 3781 template <int structdim2, int dim2, int spacedim2> 3782 CellAccessor<dim, spacedim>::CellAccessor( 3783 const InvalidAccessor<structdim2, dim2, spacedim2> &) 3784 { 3785 Assert(false, 3786 ExcMessage("You are attempting an illegal conversion between " 3787 "iterator/accessor types. The constructor you call " 3788 "only exists to make certain template constructs " 3789 "easier to write as dimension independent code but " 3790 "the conversion is not valid in the current context.")); 3791 } 3792 3793 3794 3795 template <int structdim, int dim, int spacedim> 3796 template <int structdim2, int dim2, int spacedim2> 3797 TriaAccessor<structdim, dim, spacedim>::TriaAccessor( 3798 const TriaAccessor<structdim2, dim2, spacedim2> &) 3799 { 3800 Assert(false, 3801 ExcMessage("You are attempting an illegal conversion between " 3802 "iterator/accessor types. The constructor you call " 3803 "only exists to make certain template constructs " 3804 "easier to write as dimension independent code but " 3805 "the conversion is not valid in the current context.")); 3806 } 3807 3808 3809 3810 template <int dim, int spacedim> 3811 template <int structdim2, int dim2, int spacedim2> 3812 CellAccessor<dim, spacedim>::CellAccessor( 3813 const TriaAccessor<structdim2, dim2, spacedim2> &) 3814 { 3815 Assert(false, 3816 ExcMessage("You are attempting an illegal conversion between " 3817 "iterator/accessor types. The constructor you call " 3818 "only exists to make certain template constructs " 3819 "easier to write as dimension independent code but " 3820 "the conversion is not valid in the current context.")); 3821 } 3822 3823 3824 #ifndef DOXYGEN 3825 3826 template <> 3827 bool 3828 CellAccessor<1, 1>::point_inside(const Point<1> &) const; 3829 template <> 3830 bool 3831 CellAccessor<2, 2>::point_inside(const Point<2> &) const; 3832 template <> 3833 bool 3834 CellAccessor<3, 3>::point_inside(const Point<3> &) const; 3835 template <> 3836 bool 3837 CellAccessor<1, 2>::point_inside(const Point<2> &) const; 3838 template <> 3839 bool 3840 CellAccessor<1, 3>::point_inside(const Point<3> &) const; 3841 template <> 3842 bool 3843 CellAccessor<2, 3>::point_inside(const Point<3> &) const; 3844 // ------------------------------------------------------------------- 3845 3846 template <> 3847 void 3848 TriaAccessor<3, 3, 3>::set_all_manifold_ids(const types::manifold_id) const; 3849 3850 #endif // DOXYGEN 3851 3852 DEAL_II_NAMESPACE_CLOSE 3853 3854 // include more templates in debug and optimized mode 3855 #include "tria_accessor.templates.h" 3856 3857 #endif 3858