Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Mesh.h 26.1 KB
Newer Older
1 2 3 4 5 6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9 10 11
// ==  Institut für Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12 13 14 15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// ==                                                                        ==
// ============================================================================

/** \file Mesh.h */

/** \defgroup Triangulation Triangulation module
 * @{ <img src="triangulation.png"> @}
 *
 * Example:
 *
 * @{ <img src="hierarchicalMesh.png"> @}
 *
 * \brief
 * Contains all triangulation classes.
 */

#ifndef AMDIS_MESH_H
#define AMDIS_MESH_H

Thomas Witkowski's avatar
Thomas Witkowski committed
36 37 38 39
#include <deque>
#include <set>
#include <stdio.h>
#include "AMDiS_fwd.h"
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include "DOFAdmin.h"
#include "Line.h"
#include "Triangle.h"
#include "Tetrahedron.h"
#include "Element.h"
#include "ElInfo.h"
#include "FixVec.h"
#include "Serializable.h"
#include "BoundaryCondition.h"

namespace AMDiS {

  /** \ingroup Triangulation 
   * \brief
   * A Mesh holds all information about a triangulation. 
   */
  class Mesh : public Serializable
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
59
    /// Creates a mesh with the given name of dimension dim
Thomas Witkowski's avatar
Thomas Witkowski committed
60
    Mesh(std::string name, int dim);
61

Thomas Witkowski's avatar
Thomas Witkowski committed
62
    /// Destructor
63 64
    virtual ~Mesh();

Thomas Witkowski's avatar
Thomas Witkowski committed
65
    /// Reads macro triangulation.
66 67
    void initialize();

Thomas Witkowski's avatar
Thomas Witkowski committed
68
    /// Assignment operator
69 70 71 72 73 74 75 76
    Mesh& operator=(const Mesh&);

    /** \name getting methods
     * \{
     */

    /** \brief
     * Returns geometric information about this mesh. With GeoIndex p it is 
Backofen, Rainer's avatar
Backofen, Rainer committed
77
     * specified which information is requested.
78
     */
79 80
    inline int getGeo(GeoIndex p) const 
    { 
81
      return Global::getGeo(p, dim); 
82
    }
83

Thomas Witkowski's avatar
Thomas Witkowski committed
84
    /// Returns \ref name of the mesh
Thomas Witkowski's avatar
Thomas Witkowski committed
85
    inline std::string getName() const 
86
    { 
87
      return name; 
88
    }
89

Thomas Witkowski's avatar
Thomas Witkowski committed
90
    /// Returns \ref dim of the mesh
91
    inline int getDim() const
92
    { 
93
      return dim; 
94
    }
95

96 97
    /// Returns \ref nDofEl of the mesh
    inline const int getNumberOfAllDofs() const 
98
    { 
99
      return nDofEl; 
100
    }
101

Thomas Witkowski's avatar
Thomas Witkowski committed
102
    /// Returns \ref nNodeEl of the mesh
103 104
    inline const int getNumberOfNodes() const 
    { 
105
      return nNodeEl; 
106
    }
107

Thomas Witkowski's avatar
Thomas Witkowski committed
108
    /// Returns \ref nVertices of the mesh
109 110
    inline const int getNumberOfVertices() const 
    { 
111
      return nVertices; 
112
    }
113

Thomas Witkowski's avatar
Thomas Witkowski committed
114
    /// Returns \ref nEdges of the mesh 
115 116
    inline const int getNumberOfEdges() const 
    { 
117
      return nEdges; 
118
    }
119

Thomas Witkowski's avatar
Thomas Witkowski committed
120
    /// Returns \ref nFaces of the mesh 
121 122
    inline const int getNumberOfFaces() const 
    { 
123
      return nFaces; 
124
    }
125

Thomas Witkowski's avatar
Thomas Witkowski committed
126
    /// Returns \ref nLeaves of the mesh 
127 128
    inline const int getNumberOfLeaves() const 
    { 
129
      return nLeaves; 
130
    }
131

Thomas Witkowski's avatar
Thomas Witkowski committed
132
    /// Returns \ref nElements of the mesh
133 134
    inline const int getNumberOfElements() const 
    { 
135
      return nElements; 
136
    }
137

Thomas Witkowski's avatar
Thomas Witkowski committed
138
    /// Returns \ref maxEdgeNeigh of the mesh
139 140
    inline const int getMaxEdgeNeigh() const 
    { 
141
      return maxEdgeNeigh; 
142
    }
143

Thomas Witkowski's avatar
Thomas Witkowski committed
144
    /// Returns \ref parametric of the mesh
145 146
    inline Parametric *getParametric() const 
    { 
147
      return parametric; 
148
    }
149

Thomas Witkowski's avatar
Thomas Witkowski committed
150
    /// Returns \ref diam of the mesh
151 152
    inline const WorldVector<double>& getDiameter() const 
    { 
153
      return diam; 
154
    }
155

156 157
    /// Returns nDof[i] of the mesh
    inline const int getNumberOfDofs(int i) const 
158
    { 
159
      return nDof[i]; 
160
    }
161

Thomas Witkowski's avatar
Thomas Witkowski committed
162
    /// Returns \ref elementPrototype of the mesh
163 164
    inline Element* getElementPrototype() 
    { 
165
      return elementPrototype; 
166
    }
167

Thomas Witkowski's avatar
Thomas Witkowski committed
168
    /// Returns \ref leafDataPrototype of the mesh
169 170
    inline ElementData* getElementDataPrototype() 
    { 
171
      return elementDataPrototype; 
172
    }
173

Thomas Witkowski's avatar
Thomas Witkowski committed
174
    /// Returns node[i] of the mesh 
175 176
    inline int getNode(int i) const 
    { 
177
      return node[i]; 
178
    }
179 180 181 182 183 184 185

    /** \brief
     * Allocates the number of DOFs needed at position and registers the DOFs
     * at the DOFAdmins. The number of needed DOFs is the sum over the needed
     * DOFs of all DOFAdmin objects belonging to this mesh. 
     * The return value is a pointer to the first allocated DOF. 
     */
186
    DegreeOfFreedom *getDof(GeoIndex position);
187

Thomas Witkowski's avatar
Thomas Witkowski committed
188
    /// Returns *(\ref admin[i]) of the mesh
189
    inline const DOFAdmin& getDofAdmin(int i) const 
190
    {
191
      return *(admin[i]);
192
    }
193 194

    /** \brief
195
     * Creates a DOFAdmin with name lname. nDof specifies how many DOFs 
196 197 198
     * are needed at the different positions (see \ref DOFAdmin::nrDOF).
     * A pointer to the created DOFAdmin is returned.
     */
199
    const DOFAdmin* createDOFAdmin(std::string lname, DimVec<int> nDof);
200 201 202 203 204

    /** \brief
     * Returns the size of \ref admin which is the number of the DOFAdmins
     * belonging to this mesh
     */
205 206
    const int getNumberOfDOFAdmin() const 
    {
207
      return admin.size();
208
    }
209 210 211 212 213

    /** \brief
     * Returns the size of \ref macroElements which is the number of
     * of macro elements of this mesh
     */
214 215
    const int getNumberOfMacros() const 
    {
216
      return macroElements.size();
217
    }
218

Thomas Witkowski's avatar
Thomas Witkowski committed
219
    /// Returns a DOFAdmin which at least manages vertex DOFs
220 221
    const DOFAdmin* getVertexAdmin() const;

Thomas Witkowski's avatar
Thomas Witkowski committed
222
    /// Allocates a array of DOF pointers. The array holds one pointer for each node.
Thomas Witkowski's avatar
Thomas Witkowski committed
223
    DegreeOfFreedom **createDofPtrs();
224

Thomas Witkowski's avatar
Thomas Witkowski committed
225
    /// Returns \ref preserveCoarseDOFs of the mesh
226 227
    inline bool queryCoarseDOFs() const 
    { 
228
      return preserveCoarseDOFs;
229
    }
230

Thomas Witkowski's avatar
Thomas Witkowski committed
231
    /// Returns an iterator to the begin of \ref macroElements
232 233
    inline std::deque<MacroElement*>::iterator firstMacroElement() 
    {
234
      return macroElements.begin();
235
    }
236

Thomas Witkowski's avatar
Thomas Witkowski committed
237
    /// Returns macroElements[i].
238 239
    inline MacroElement *getMacroElement(int i) 
    { 
240
      return macroElements[i]; 
241
    }
242

Thomas Witkowski's avatar
Thomas Witkowski committed
243
    /// Returns an iterator to the end of \ref macroElements
244 245
    inline std::deque<MacroElement*>::iterator endOfMacroElements() 
    {
246
      return macroElements.end();
247
    }
248

249 250 251 252 253 254
    /// Returns \ref macroElements, the list of all macro elements in the mesh.
    std::deque<MacroElement*>& getMacroElements()
    {
      return macroElements;
    }

255 256 257 258 259 260
    /** \} */

    /** \name setting methods
     * \{
     */

Thomas Witkowski's avatar
Thomas Witkowski committed
261
    /// Sets \ref name of the mesh
Thomas Witkowski's avatar
Thomas Witkowski committed
262
    inline void setName(std::string aName) 
263
    { 
264
      name = aName;
265
    }
266

Thomas Witkowski's avatar
Thomas Witkowski committed
267
    /// Sets \ref nVertices of the mesh
268 269
    inline void setNumberOfVertices(int n) 
    { 
270
      nVertices = n; 
271
    }
272

Thomas Witkowski's avatar
Thomas Witkowski committed
273
    /// Sets \ref nFaces of the mesh
274 275
    inline void setNumberOfFaces(int n) 
    { 
276
      nFaces = n; 
277
    }
278

Thomas Witkowski's avatar
Thomas Witkowski committed
279
    /// Increments \ref nVertices by inc
280 281
    inline void incrementNumberOfVertices(int inc) 
    { 
282
      nVertices += inc; 
283
    }
284
 
Thomas Witkowski's avatar
Thomas Witkowski committed
285
    /// Sets \ref nEdges of the mesh
286 287
    inline void setNumberOfEdges(int n) 
    { 
288
      nEdges = n; 
289
    }
290

Thomas Witkowski's avatar
Thomas Witkowski committed
291
    /// Increments \ref nEdges by inc
292 293
    inline void incrementNumberOfEdges(int inc) 
    { 
294
      nEdges += inc; 
295
    }
296

Thomas Witkowski's avatar
Thomas Witkowski committed
297
    /// Increments \ref nFaces by inc
298 299
    inline void incrementNumberOfFaces(int inc) 
    { 
300
      nFaces += inc; 
301
    }
302

Thomas Witkowski's avatar
Thomas Witkowski committed
303
    /// Sets \ref nLeaves of the mesh
304 305
    inline void setNumberOfLeaves(int n) 
    { 
306
      nLeaves = n; 
307
    }
308

Thomas Witkowski's avatar
Thomas Witkowski committed
309
    /// Increments \ref nLeaves by inc
310 311
    inline void incrementNumberOfLeaves(int inc) 
    { 
312
      nLeaves += inc; 
313
    }
314

Thomas Witkowski's avatar
Thomas Witkowski committed
315
    /// Sets \ref nElements of the mesh
316 317
    inline void setNumberOfElements(int n) 
    { 
318
      nElements = n; 
319
    }
320

Thomas Witkowski's avatar
Thomas Witkowski committed
321
    /// Increments \ref nElements by inc
322 323
    inline void incrementNumberOfElements(int inc) 
    { 
324
      nElements += inc; 
325
    }
326

Thomas Witkowski's avatar
Thomas Witkowski committed
327
    /// Sets *\ref diam to w
328 329
    void setDiameter(const WorldVector<double>& w);

Thomas Witkowski's avatar
Thomas Witkowski committed
330
    /// Sets (*\ref diam)[i] to d
331 332
    void setDiameter(int i, double d);

Thomas Witkowski's avatar
Thomas Witkowski committed
333
    /// Sets \ref preserveCoarseDOFs = true
334 335
    inline void retainCoarseDOFs() 
    {
336
      preserveCoarseDOFs = true;
337
    }
338

Thomas Witkowski's avatar
Thomas Witkowski committed
339
    /// Sets \ref preserveCoarseDOFs = b
340 341
    inline void setPreserveCoarseDOFs(bool b) 
    {
342
      preserveCoarseDOFs = b;
343
    }
344

Thomas Witkowski's avatar
Thomas Witkowski committed
345
    /// Sets \ref preserveCoarseDOFs = false
346 347
    inline void noCoarseDOFs() 
    {
348
      preserveCoarseDOFs = false;
349
    }
350

Thomas Witkowski's avatar
Thomas Witkowski committed
351
    /// Sets \ref elementPrototype of the mesh
352 353
    inline void setElementPrototype(Element* prototype) 
    {
354
      elementPrototype = prototype;
355 356
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
357
    /// Sets \ref elementDataPrototype of the mesh
358 359
    inline void setElementDataPrototype(ElementData* prototype) 
    {
360
      elementDataPrototype = prototype;
361
    }
362

Thomas Witkowski's avatar
Thomas Witkowski committed
363
    ///
364 365
    inline void setParametric(Parametric *param) 
    {
366
      parametric = param;
367
    }
368

Thomas Witkowski's avatar
Thomas Witkowski committed
369
    ///
370 371
    inline void setMaxEdgeNeigh(int m) 
    { 
372
      maxEdgeNeigh = m; 
373
    }
374 375 376
  
    /** \} */

Thomas Witkowski's avatar
Thomas Witkowski committed
377
    /// Creates a new Element by cloning \ref elementPrototype
378 379
    Element* createNewElement(Element *parent = NULL);

Thomas Witkowski's avatar
Thomas Witkowski committed
380
    /// Creates a new ElInfo dependent of \ref dim of the mesh
381 382
    ElInfo* createNewElInfo();

Thomas Witkowski's avatar
Thomas Witkowski committed
383
    /// Frees DOFs at the given position pointed by dof 
384
    void freeDof(DegreeOfFreedom* dof, GeoIndex position);
385

Thomas Witkowski's avatar
Thomas Witkowski committed
386
    /// Frees memory for the given element el
387 388
    void freeElement(Element* el);

Thomas Witkowski's avatar
Thomas Witkowski committed
389
    /// Performs DOF compression for all DOFAdmins (see \ref DOFAdmin::compress)
390 391
    void dofCompress();

Thomas Witkowski's avatar
Thomas Witkowski committed
392
    /// Adds a DOFAdmin to the mesh
393
    virtual void addDOFAdmin(DOFAdmin *admin);
394

395 396 397
    /// Recalculates the number of leave elements.
    void updateNumberOfLeaves();

Thomas Witkowski's avatar
Thomas Witkowski committed
398
    /// Clears \ref macroElements
399 400
    inline void clearMacroElements() 
    { 
401
      macroElements.clear();
402
    }
403
  
Thomas Witkowski's avatar
Thomas Witkowski committed
404
    /// Adds a macro element to the mesh
405 406
    void addMacroElement(MacroElement* me);

407
    /* \brief
408 409 410
     * Removes a set of macro elements from the mesh. This works only for the case, 
     * that there are no global or local refinements, i.e., all macro elements have 
     * no children.
411
     */
412
    void removeMacroElements(std::set<MacroElement*>& macros,
Thomas Witkowski's avatar
Thomas Witkowski committed
413
			     const FiniteElemSpace* feSpace);
414

Thomas Witkowski's avatar
Thomas Witkowski committed
415
    /// Frees the array of DOF pointers (see \ref createDofPtrs)
416
    void freeDofPtrs(DegreeOfFreedom **ptrs);
417

Thomas Witkowski's avatar
Thomas Witkowski committed
418
    /// Used by \ref findElementAtPoint. 
419 420 421
    bool findElInfoAtPoint(const WorldVector<double>& xy,
			   ElInfo *el_info,
			   DimVec<double>& bary,
422
			   const MacroElement *start_mel,
423 424
			   const WorldVector<double> *xy0,
			   double *sp);
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460

    /** \brief
     * Access to an element at world coordinates xy. Some applications need the 
     * access to elements at a special location in world coordinates. Examples 
     * are characteristic methods for convection problems, or the implementation
     * of a special right hand side like point evaluations or curve integrals.
     * For such purposes, a routine is available which returns an element pointer
     * and corresponding barycentric coordinates.
     *
     * \param xy world coordinates of point
     * \param elp return address for a pointer to the element at xy
     * \param pary returns barycentric coordinates of xy
     * \param start_mel initial guess for the macro element containing xy or NULL
     * \param xy0 start point from a characteristic method, see below, or NULL
     * \param sp return address for relative distance to domain boundary in a 
     *        characteristic method, see below, or NULL
     * \return true is xy is inside the domain , false otherwise
     * 
     * For a characteristic method, where \f$ xy = xy_0 - V\tau \f$, it may be 
     * convenient to know the point on the domain's boundary which lies on the 
     * line segment between the old point xy0 and the new point xy, in case that 
     * xy is outside the domain. Such information is returned when xy0 and a 
     * pointer sp!=NULL are supplied: *sp is set to the value s such that 
     * \f$ xy_0 +s (xy -xy_0) \in \partial Domain \f$, and the element and local 
     * coordinates corresponding to that boundary point will be returned via elp 
     * and bary.
     *
     * The implementation of findElementAtPoint() is based on the transformation 
     * from world to local coordinates, available via the routine worldToCoord(),
     * At the moment, findElementAtPoint() works correctly only for domains with 
     * non-curved boundary. This is due to the fact that the implementation first
     * looks for the macro-element containing xy and then finds its path through 
     * the corresponding element tree based on the macro barycentric coordinates.
     * For non-convex domains, it is possible that in some cases a point inside
     * the domain is considered as external.
     */
461 462 463
    bool findElementAtPoint(const WorldVector<double>& xy,
			    Element **elp, 
			    DimVec<double>& bary,
464
			    const MacroElement *start_mel,
465 466
			    const WorldVector<double> *xy0,
			    double *sp);
467

468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
    /** \brief
     * Returns for a given dof its world coordinates in this mesh. Because we do
     * not have any direct connection between dofs and coordinates, this function
     * has to search for the element in this mesh, that contains the dof. Than the
     * coordinates can be computed. Therefore, this function is very costly and
     * should be used for debugging purpose only.
     *
     * @param[in]    dof       A pointer to the dof we have to search for.
     * @param[in]    feSpace   The fe space to be used for the search.
     * @param[out]   coords    World vector that stores the coordinates of the dof.
     *
     * The function returns true, if the dof was found, otherwise false.
     */
    bool getDofIndexCoords(const DegreeOfFreedom* dof, 
			   const FiniteElemSpace* feSpace,
483 484 485 486
			   WorldVector<double>& coords)
    {
      return getDofIndexCoords(*dof, feSpace, coords);
    }
487

488 489 490 491 492

    /** \brief
     * This function is equal to \ref getDofIndexCoords as defined above, but takes
     * a DOF index instead of a DOF pointer.
     */
493 494 495
    bool getDofIndexCoords(DegreeOfFreedom dof, 
			   const FiniteElemSpace* feSpace,
			   WorldVector<double>& coords);
496

497 498 499 500 501 502 503 504 505 506 507
    /** \brief
     * Traverse the whole mesh and stores to each DOF of the given finite element space
     * the coordinates in a given DOFVector. Works in the same way as the function
     * \ref getDofIndexCoords defined above.
     *
     * @param[in]   feSpace   The fe soace to be used for the search.
     * @param[out]  coords    DOF vector that stores the coordinates to each dof.
     */
    void getDofIndexCoords(const FiniteElemSpace* feSpace,
			   DOFVector<WorldVector<double> >& coords);

Thomas Witkowski's avatar
Thomas Witkowski committed
508
    /// Returns FILL_ANY_?D
509 510
    inline static const Flag& getFillAnyFlag(int dim) 
    {
511
      switch (dim) {
512 513 514 515 516 517 518 519 520 521 522 523 524
      case 1:
	return FILL_ANY_1D;
	break;
      case 2:
	return FILL_ANY_2D;
	break;
      case 3:
	return FILL_ANY_3D;
	break;
      default:
	ERROR_EXIT("invalid dim\n");
	return FILL_ANY_1D;
      }
525
    }
526

Thomas Witkowski's avatar
Thomas Witkowski committed
527
    /// Serialize the mesh to a file.
528
    void serialize(std::ostream &out);
529

Thomas Witkowski's avatar
Thomas Witkowski committed
530
    /// Deserialize a mesh from a file.
531
    void deserialize(std::istream &in);
532

Thomas Witkowski's avatar
Thomas Witkowski committed
533
    /// Returns \ref elementIndex and increments it by 1.
534 535
    inline int getNextElementIndex() 
    { 
536
      return elementIndex++; 
537
    }
538

Thomas Witkowski's avatar
Thomas Witkowski committed
539
    /// Returns \ref initialized.
540 541
    inline bool isInitialized() 
    {
542 543
      return initialized; 
    }
544
  
Thomas Witkowski's avatar
Thomas Witkowski committed
545
    ///
546 547
    inline std::map<BoundaryType, VertexVector*>& getPeriodicAssociations() 
    {
548
      return periodicAssociations;
549
    }
550

551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
    /// Returns the periodic association for a specific boundary type.
    inline VertexVector& getPeriodicAssociations(BoundaryType b)
    {
      FUNCNAME("Mesh::getPeriodicAssociations()");

      TEST_EXIT_DBG(periodicAssociations.count(b) == 1)
	("There are no periodic assoications for boundary type %d!\n", b);

      return (*(periodicAssociations[b]));
    }

    
    /// Returns whether the given boundary type is periodic, i.e., if there is
    /// a periodic association for this boundary type.
    inline bool isPeriodicAssociation(BoundaryType b)
    {
      return (periodicAssociations.count(b) == 1 ? true : false);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
570
    ///
571 572
    bool associated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
573
    ///
574 575
    bool indirectlyAssociated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
576
    /// Returns \macroFileInfo
577 578
    inline MacroInfo* getMacroFileInfo() 
    { 
579
      return macroFileInfo;
580
    }
581

582 583 584 585 586 587 588 589 590 591 592 593
    /// Increment the value of mesh change index, see \ref changeIndex.
    inline void incChangeIndex()
    {
      changeIndex++;
    }

    /// Returns the mesh change index, see \ref changeIndex.
    inline long getChangeIndex()
    {
      return changeIndex;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
594
    ///
595 596
    void clearMacroFileInfo();

597 598 599 600 601 602 603
    /** \brief
     * Traverse this mesh to compute the number of non zero elements the assembled 
     * matrix will have in each row.
     */
    void computeMatrixFillin(const FiniteElemSpace *feSpace,
			     std::vector<int> &nnzInRow, int &overall, int &average);

Thomas Witkowski's avatar
Thomas Witkowski committed
604
    ///
605 606
    int calcMemoryUsage();

607 608 609
    ///
    void deleteMeshStructure();

610
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
611
    ///
612 613
    static const Flag FILL_NOTHING;

Thomas Witkowski's avatar
Thomas Witkowski committed
614
    ///
615
    static const Flag FILL_COORDS; 
616

Thomas Witkowski's avatar
Thomas Witkowski committed
617
    ///
618
    static const Flag FILL_BOUND; 
619

Thomas Witkowski's avatar
Thomas Witkowski committed
620
    ///
621
    static const Flag FILL_NEIGH; 
622

Thomas Witkowski's avatar
Thomas Witkowski committed
623
    ///
624
    static const Flag FILL_OPP_COORDS; 
625

Thomas Witkowski's avatar
Thomas Witkowski committed
626
    ///
627 628
    static const Flag FILL_ORIENTATION; 

Thomas Witkowski's avatar
Thomas Witkowski committed
629
    ///
630
    static const Flag FILL_ADD_ALL; 
631
  
Thomas Witkowski's avatar
Thomas Witkowski committed
632
    ///
633
    static const Flag FILL_ANY_1D; 
634

Thomas Witkowski's avatar
Thomas Witkowski committed
635
    ///
636
    static const Flag FILL_ANY_2D; 
637

Thomas Witkowski's avatar
Thomas Witkowski committed
638
    ///
639
    static const Flag FILL_ANY_3D; 
640

Thomas Witkowski's avatar
Thomas Witkowski committed
641
    ///
642
    static const Flag FILL_DET;
643

Thomas Witkowski's avatar
Thomas Witkowski committed
644
    ///
645 646 647 648 649 650
    static const Flag FILL_GRD_LAMBDA;

    //**************************************************************************
    //  flags for Mesh traversal                                                
    //**************************************************************************

Thomas Witkowski's avatar
Thomas Witkowski committed
651
    ///
652 653
    static const Flag CALL_EVERY_EL_PREORDER;      

Thomas Witkowski's avatar
Thomas Witkowski committed
654
    ///
655 656
    static const Flag CALL_EVERY_EL_INORDER;     

Thomas Witkowski's avatar
Thomas Witkowski committed
657
    ///
658 659
    static const Flag CALL_EVERY_EL_POSTORDER;    

Thomas Witkowski's avatar
Thomas Witkowski committed
660
    ///
661 662
    static const Flag CALL_LEAF_EL;   

Thomas Witkowski's avatar
Thomas Witkowski committed
663
    ///
664 665
    static const Flag CALL_LEAF_EL_LEVEL;  

Thomas Witkowski's avatar
Thomas Witkowski committed
666
    ///
667 668
    static const Flag CALL_EL_LEVEL; 

Thomas Witkowski's avatar
Thomas Witkowski committed
669
    ///
670 671
    static const Flag CALL_MG_LEVEL;

672 673 674
    /// If set, left and right children are swapped in traverse.
    static const Flag CALL_REVERSE_MODE;

675
  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
676
    ///
677
    bool findElementAtPointRecursive(ElInfo *elinfo,
678
				     const DimVec<double>& lambda,
679
				     int outside,
680 681
				     ElInfo *final_el_info);

682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    /** \brief
     * This functions is called in parallel computations by the function \ref
     * Mesh::initialize(). It checks that the macro file has enough macro elements
     * for the number of used processors and that all macro elements are of type 0.
     * If this is not the case, that macro mesh is globally refined in an
     * apropriate way and is written to a new macro file.
     *
     * The function returns true, if a new macro and parallel file were created for
     * the current parallel usage. In this case, a new macro file with the same name
     * plus ".tmp", and if required, a new periodic file with the same name plus
     * ".tmp" are created.
     *
     * \param[in]  macroFilename      Name of the macro mesh file.
     * \param[in]  periodicFilename   If periodic boundaries are used, name of the
     *                                periodicity file. Otherwise, the string must
     *                                be empty.
     * \param[in]  check              If the mesh should be checked to be a correct
     *                                AMDiS macro mesh, the value must be 1 and 0
     *                                otherwise.
     */
    bool checkParallelMacroFile(std::string macroFilename, 
				std::string periodicFilename,
				int check);
#endif

708
  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
709
    /// maximal number of DOFs at one position
710 711
    static const int MAX_DOF;

Thomas Witkowski's avatar
Thomas Witkowski committed
712
    /// Name of this Mesh
713
    std::string name;
714

Thomas Witkowski's avatar
Thomas Witkowski committed
715
    /// Dimension of this Mesh. Doesn't have to be equal to dimension of world.
716 717
    int dim;

Thomas Witkowski's avatar
Thomas Witkowski committed
718
    /// Number of vertices in this Mesh
719 720
    int nVertices;

Thomas Witkowski's avatar
Thomas Witkowski committed
721
    /// Number of Edges in this Mesh
722 723
    int nEdges;

Thomas Witkowski's avatar
Thomas Witkowski committed
724
    /// Number of leaf elements in this Mesh
725 726
    int nLeaves;

Thomas Witkowski's avatar
Thomas Witkowski committed
727
    /// Total number of elements in this Mesh
728 729
    int nElements;

Thomas Witkowski's avatar
Thomas Witkowski committed
730
    /// Number of faces in this Mesh
731 732 733 734 735 736 737 738 739
    int nFaces;

    /** \brief
     * Maximal number of elements that share one edge; used to allocate memory 
     * to store pointers to the neighbour at the refinement/coarsening edge 
     * (only 3d);
     */
    int maxEdgeNeigh;

Thomas Witkowski's avatar
Thomas Witkowski committed
740
    /// Diameter of the mesh in the DIM_OF_WORLD directions
741 742 743 744 745 746 747 748 749 750
    WorldVector<double> diam;

    /** \brief
     * Is pointer to NULL if mesh contains no parametric elements else pointer 
     * to a Parametric object containing coefficients of the parameterization 
     * and related information
     */
    Parametric *parametric;

    /** \brief
751 752 753 754 755 756 757
     * When an element is refined, not all dofs of the coarse element must be 
     * part of the new elements. An example are centered dofs when using higher
     * lagrange basis functions. The midpoint dof of the parents element is not
     * a dof of the both children elements. Therefore, the dof can be deleted. In
     * some situation, e.g., when using multigrid techniques, it can be necessary to
     * store this coarse dofs. Then this variable must be set to true. If false, the
     * not required coarse dofs will be deleted.
758 759 760
     */
    bool preserveCoarseDOFs;

Thomas Witkowski's avatar
Thomas Witkowski committed
761
    /// Number of all DOFs on a single element
762
    int nDofEl;
763 764 765 766 767

    /** \brief
     * Number of DOFs at the different positions VERTEX, EDGE, (FACE,) CENTER on
     * an element:
     *
768
     * - nDof[VERTEX]: number of DOFs at a vertex (>= 1)
769
     *
770
     * - nDof[EDGE]: number of DOFs at an edge; if no DOFs are associated to
771 772
     *   edges, then this value is 0
     *
773
     * - nDof[FACE]: number of DOFs at a face; if no DOFs are associated to
774 775
     *   faces, then this value is 0 (only 3d)
     *
776
     * - nDof[CENTER]: number of DOFs at the barycenter; if no DOFs are 
777 778
     *   associated to the barycenter, then this value is 0
     */
779
    DimVec<int> nDof;
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804

    /** \brief
     * Number of nodes on a single element where DOFs are located; needed for 
     * the (de-) allocation of the dof-vector on the element (\ref Element::dof);
     */
    int nNodeEl;

    /** \brief
     * Gives the index of the first node at vertex, edge, face (only 3d), and 
     * barycenter:
     *
     * - node[VERTEX]: has always value 0; dof[0],...,dof[N_VERTICES-1] are 
     *   always DOFs at the vertices;
     *
     * - node[EDGE]: dof[node[EDGE]],..., dof[node[EDGE]+N_EDGES-1] are the DOFs
     *   at the N_EDGES edges, if DOFs are located at edges;
     *
     * - node[FACE]: dof[node[FACE]],..., dof[node[FACE]+N_FACES-1] are the DOFs
     *   at the N_FACES faces, if DOFs are located at faces (only 3d);
     *
     * - node[CENTER]: dof[node[CENTER]] are the DOFs at the barycenter, if DOFs
     *   are located at the barycenter;
     */
    DimVec<int> node;

Thomas Witkowski's avatar
Thomas Witkowski committed
805
    /// List of all DOFAdmins
806
    std::vector<DOFAdmin*> admin;
807

Thomas Witkowski's avatar
Thomas Witkowski committed
808
    /// List of all MacroElements of this Mesh
809
    std::deque<MacroElement*> macroElements;
Peter Gottschling's avatar