Mesh.h 21.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \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
60
    Mesh(const 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
    Mesh& operator=(const Mesh&);

    /** \name static methods used while mesh traversal 
     * \{
     */

Thomas Witkowski's avatar
Thomas Witkowski committed
75
    /// Used while dof compress
76
77
    static int newDOFFct1(ElInfo* e);

Thomas Witkowski's avatar
Thomas Witkowski committed
78
    /// Used while dof compress
79
80
81
82
83
84
85
86
87
88
89
90
91
    static int newDOFFct2(ElInfo* e);
    /** \} */

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

    /** \brief
     * Returns geometric information about this mesh. With GeoIndex p it is 
     * specifiedm which information is requested.
     */
    inline int getGeo(GeoIndex p) const { 
      return Global::getGeo(p, dim); 
92
    }
93

Thomas Witkowski's avatar
Thomas Witkowski committed
94
    /// Returns \ref name of the mesh
95
    inline const std::string& getName() const { 
96
      return name; 
97
    }
98

Thomas Witkowski's avatar
Thomas Witkowski committed
99
    /// Returns \ref dim of the mesh
100
101
    inline int getDim() const { 
      return dim; 
102
    }
103

Thomas Witkowski's avatar
Thomas Witkowski committed
104
    /// Returns \ref nDOFEl of the mesh
105
106
    inline const int getNumberOfAllDOFs() const { 
      return nDOFEl; 
107
    }
108

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
119
    /// Returns \ref nEdges of the mesh 
120
121
    inline const int getNumberOfEdges() const { 
      return nEdges; 
122
    }
123

Thomas Witkowski's avatar
Thomas Witkowski committed
124
    /// Returns \ref nFaces of the mesh 
125
126
    inline const int getNumberOfFaces() const { 
      return nFaces; 
127
    }
128

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

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

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

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
154
    /// Returns nDOF[i] of the mesh
155
156
    inline const int getNumberOfDOFs(int i) const { 
      return nDOF[i]; 
157
    }
158

Thomas Witkowski's avatar
Thomas Witkowski committed
159
    /// Returns \ref elementPrototype of the mesh
160
161
    inline Element* getElementPrototype() { 
      return elementPrototype; 
162
    }
163

Thomas Witkowski's avatar
Thomas Witkowski committed
164
    /// Returns \ref leafDataPrototype of the mesh
165
166
    inline ElementData* getElementDataPrototype() { 
      return elementDataPrototype; 
167
    }
168

Thomas Witkowski's avatar
Thomas Witkowski committed
169
    /// Returns node[i] of the mesh 
170
171
    inline int getNode(int i) const { 
      return node[i]; 
172
    }
173
174
175
176
177
178
179
180
181

    /** \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. 
     */
    DegreeOfFreedom *getDOF(GeoIndex position);

Thomas Witkowski's avatar
Thomas Witkowski committed
182
    /// Returns *(\ref admin[i]) of the mesh
183
184
    inline const DOFAdmin& getDOFAdmin(int i) const {
      return *(admin[i]);
185
    }
186
187
188
189
190
191

    /** \brief
     * Creates a DOFAdmin with name lname. nDOF specifies how many DOFs 
     * are needed at the different positions (see \ref DOFAdmin::nrDOF).
     * A pointer to the created DOFAdmin is returned.
     */
192
    const DOFAdmin* createDOFAdmin(const std::string& lname, DimVec<int> nDOF);
193
194
195
196
197

    /** \brief
     * Returns the size of \ref admin which is the number of the DOFAdmins
     * belonging to this mesh
     */
198
199
    const int getNumberOfDOFAdmin() const {
      return admin.size();
200
    }
201
202
203
204
205

    /** \brief
     * Returns the size of \ref macroElements which is the number of
     * of macro elements of this mesh
     */
206
207
    const int getNumberOfMacros() const {
      return macroElements.size();
208
    }
209

Thomas Witkowski's avatar
Thomas Witkowski committed
210
    /// Returns a DOFAdmin which at least manages vertex DOFs
211
212
    const DOFAdmin* getVertexAdmin() const;

Thomas Witkowski's avatar
Thomas Witkowski committed
213
    /// Allocates a array of DOF pointers. The array holds one pointer for each node.
214
    DegreeOfFreedom **createDOFPtrs();
215

Thomas Witkowski's avatar
Thomas Witkowski committed
216
    /// Returns \ref preserveCoarseDOFs of the mesh
217
218
    inline bool queryCoarseDOFs() const { 
      return preserveCoarseDOFs;
219
    }
220

Thomas Witkowski's avatar
Thomas Witkowski committed
221
    /// Returns an iterator to the begin of \ref macroElements
222
    inline std::deque<MacroElement*>::iterator firstMacroElement() {
223
      return macroElements.begin();
224
    }
225

Thomas Witkowski's avatar
Thomas Witkowski committed
226
    /// Returns macroElements[i].
227
228
    inline MacroElement *getMacroElement(int i) { 
      return macroElements[i]; 
229
    }
230

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

    /** \} */

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

Thomas Witkowski's avatar
Thomas Witkowski committed
242
    /// Sets \ref name of the mesh
243
    inline void setName(const std::string& aName) { 
244
      name = aName;
245
    }
246

Thomas Witkowski's avatar
Thomas Witkowski committed
247
    /// Sets \ref nVertices of the mesh
248
249
    inline void setNumberOfVertices(int n) { 
      nVertices = n; 
250
    }
251

Thomas Witkowski's avatar
Thomas Witkowski committed
252
    /// Sets \ref nFaces of the mesh
253
254
    inline void setNumberOfFaces(int n) { 
      nFaces = n; 
255
    }
256

Thomas Witkowski's avatar
Thomas Witkowski committed
257
    /// Increments \ref nVertices by inc
258
259
    inline void incrementNumberOfVertices(int inc) { 
      nVertices += inc; 
260
    }
261
 
Thomas Witkowski's avatar
Thomas Witkowski committed
262
    /// Sets \ref nEdges of the mesh
263
264
    inline void setNumberOfEdges(int n) { 
      nEdges = n; 
265
    }
266

Thomas Witkowski's avatar
Thomas Witkowski committed
267
    /// Increments \ref nEdges by inc
268
269
    inline void incrementNumberOfEdges(int inc) { 
      nEdges += inc; 
270
    }
271

Thomas Witkowski's avatar
Thomas Witkowski committed
272
    /// Increments \ref nFaces by inc
273
274
    inline void incrementNumberOfFaces(int inc) { 
      nFaces += inc; 
275
    }
276

Thomas Witkowski's avatar
Thomas Witkowski committed
277
    /// Sets \ref nLeaves of the mesh
278
279
    inline void setNumberOfLeaves(int n) { 
      nLeaves = n; 
280
    }
281

Thomas Witkowski's avatar
Thomas Witkowski committed
282
    /// Increments \ref nLeaves by inc
283
284
    inline void incrementNumberOfLeaves(int inc) { 
      nLeaves += inc; 
285
    }
286

Thomas Witkowski's avatar
Thomas Witkowski committed
287
    /// Sets \ref nElements of the mesh
288
289
    inline void setNumberOfElements(int n) { 
      nElements = n; 
290
    }
291

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

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
303
    /// Sets \ref preserveCoarseDOFs = true
304
305
    inline void retainCoarseDOFs() {
      preserveCoarseDOFs = true;
306
    }
307

Thomas Witkowski's avatar
Thomas Witkowski committed
308
    /// Sets \ref preserveCoarseDOFs = b
309
310
    inline void setPreserveCoarseDOFs(bool b) {
      preserveCoarseDOFs = b;
311
    }
312

Thomas Witkowski's avatar
Thomas Witkowski committed
313
    /// Sets \ref preserveCoarseDOFs = false
314
315
    inline void noCoarseDOFs() {
      preserveCoarseDOFs = false;
316
    }
317

Thomas Witkowski's avatar
Thomas Witkowski committed
318
    /// Sets \ref elementPrototype of the mesh
319
320
    inline void setElementPrototype(Element* prototype) {
      elementPrototype = prototype;
321
322
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
323
    /// Sets \ref elementDataPrototype of the mesh
324
325
    inline void setElementDataPrototype(ElementData* prototype) {
      elementDataPrototype = prototype;
326
    }
327

Thomas Witkowski's avatar
Thomas Witkowski committed
328
    ///
329
330
    inline void setParametric(Parametric *param) {
      parametric = param;
331
    }
332

Thomas Witkowski's avatar
Thomas Witkowski committed
333
    ///
334
335
    inline void setMaxEdgeNeigh(int m) { 
      maxEdgeNeigh = m; 
336
    }
337
338
339
  
    /** \} */

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

Thomas Witkowski's avatar
Thomas Witkowski committed
343
    /// Creates a new ElInfo dependent of \ref dim of the mesh
344
345
    ElInfo* createNewElInfo();

Thomas Witkowski's avatar
Thomas Witkowski committed
346
    /// Frees DOFs at the given position pointed by dof 
347
348
    void freeDOF(DegreeOfFreedom* dof, GeoIndex position);

Thomas Witkowski's avatar
Thomas Witkowski committed
349
    /// Frees memory for the given element el
350
351
    void freeElement(Element* el);

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

Thomas Witkowski's avatar
Thomas Witkowski committed
355
    /// Adds a DOFAdmin to the mesh
356
    virtual void addDOFAdmin(DOFAdmin *admin);
357

358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    /** \brief
     * Traverses the mesh. The argument level specifies the element level if 
     * CALL_EL_LEVEL or CALL_LEAF_EL_LEVEL, or the multigrid level if 
     * CALL_MG_LEVEL is set. Otherwise this variable is ignored. By the argument
     * fillFlag the elements to be traversed and data to be filled into ElInfo is
     * selected, using bitwise or of one CALL_... flag and several FILL_... 
     * flags. The argument elFct is a pointer to a function which is called on 
     * every element selected by the CALL_... part of fillFlag.
     * It is possible to use the recursive mesh traversal recursively, by calling
     * traverse() from elFct.
     */
    int traverse(int level, 
		 const Flag fillFlag,
		 int (*elFct)(ElInfo*));

373
374
375
    /// Recalculates the number of leave elements.
    void updateNumberOfLeaves();

Thomas Witkowski's avatar
Thomas Witkowski committed
376
    /// Clears \ref macroElements
377
378
    inline void clearMacroElements() { 
      macroElements.clear();
379
    }
380
  
Thomas Witkowski's avatar
Thomas Witkowski committed
381
    /// Adds a macro element to the mesh
382
383
    void addMacroElement(MacroElement* me);

384
    /* \brief
385
386
387
     * 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.
388
     */
389
    void removeMacroElements(std::vector<MacroElement*>& macros);
390

Thomas Witkowski's avatar
Thomas Witkowski committed
391
    /// Frees the array of DOF pointers (see \ref createDOFPtrs)
392
393
    void freeDOFPtrs(DegreeOfFreedom **ptrs);

Thomas Witkowski's avatar
Thomas Witkowski committed
394
    /// Used by \ref findElementAtPoint. 
395
396
397
    bool findElInfoAtPoint(const WorldVector<double>& xy,
			   ElInfo *el_info,
			   DimVec<double>& bary,
398
			   const MacroElement *start_mel,
399
400
			   const WorldVector<double> *xy0,
			   double *sp);
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436

    /** \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.
     */
437
438
439
    bool findElementAtPoint(const WorldVector<double>& xy,
			    Element **elp, 
			    DimVec<double>& bary,
440
			    const MacroElement *start_mel,
441
442
			    const WorldVector<double> *xy0,
			    double *sp);
443
444


Thomas Witkowski's avatar
Thomas Witkowski committed
445
    /// Returns FILL_ANY_?D
446
    inline static const Flag& getFillAnyFlag(int dim) {
447
      switch (dim) {
448
449
450
451
452
453
454
455
456
457
458
459
460
      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;
      }
461
    }
462

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

Thomas Witkowski's avatar
Thomas Witkowski committed
466
    /// Deserialize a mesh from a file.
467
    void deserialize(std::istream &in);
468

Thomas Witkowski's avatar
Thomas Witkowski committed
469
    /// Returns \ref elementIndex and increments it by 1.
470
471
    inline int getNextElementIndex() { 
      return elementIndex++; 
472
    }
473

Thomas Witkowski's avatar
Thomas Witkowski committed
474
    /// Returns \ref initialized.
475
476
477
    inline bool isInitialized() {
      return initialized; 
    }
478
  
Thomas Witkowski's avatar
Thomas Witkowski committed
479
    ///
480
    inline std::map<BoundaryType, VertexVector*>& getPeriodicAssociations() {
481
      return periodicAssociations;
482
    }
483

Thomas Witkowski's avatar
Thomas Witkowski committed
484
    ///
485
486
    bool associated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
487
    ///
488
489
    bool indirectlyAssociated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
490
    /// Returns \macroFileInfo
491
    inline MacroInfo* getMacroFileInfo() { 
492
      return macroFileInfo;
493
    }
494

Thomas Witkowski's avatar
Thomas Witkowski committed
495
    ///
496
497
    void clearMacroFileInfo();

Thomas Witkowski's avatar
Thomas Witkowski committed
498
    ///
499
500
    int calcMemoryUsage();

501
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
502
    ///
503
504
    static const Flag FILL_NOTHING;

Thomas Witkowski's avatar
Thomas Witkowski committed
505
    ///
506
    static const Flag FILL_COORDS; 
507

Thomas Witkowski's avatar
Thomas Witkowski committed
508
    ///
509
    static const Flag FILL_BOUND; 
510

Thomas Witkowski's avatar
Thomas Witkowski committed
511
    ///
512
    static const Flag FILL_NEIGH; 
513

Thomas Witkowski's avatar
Thomas Witkowski committed
514
    ///
515
    static const Flag FILL_OPP_COORDS; 
516

Thomas Witkowski's avatar
Thomas Witkowski committed
517
    ///
518
519
    static const Flag FILL_ORIENTATION; 

Thomas Witkowski's avatar
Thomas Witkowski committed
520
    ///
521
    static const Flag FILL_ADD_ALL; 
522
  
Thomas Witkowski's avatar
Thomas Witkowski committed
523
    ///
524
    static const Flag FILL_ANY_1D; 
525

Thomas Witkowski's avatar
Thomas Witkowski committed
526
    ///
527
    static const Flag FILL_ANY_2D; 
528

Thomas Witkowski's avatar
Thomas Witkowski committed
529
    ///
530
    static const Flag FILL_ANY_3D; 
531

Thomas Witkowski's avatar
Thomas Witkowski committed
532
    ///
533
    static const Flag FILL_DET;
534

Thomas Witkowski's avatar
Thomas Witkowski committed
535
    ///
536
537
538
539
540
541
    static const Flag FILL_GRD_LAMBDA;

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

Thomas Witkowski's avatar
Thomas Witkowski committed
542
    ///
543
544
    static const Flag CALL_EVERY_EL_PREORDER;      

Thomas Witkowski's avatar
Thomas Witkowski committed
545
    ///
546
547
    static const Flag CALL_EVERY_EL_INORDER;     

Thomas Witkowski's avatar
Thomas Witkowski committed
548
    ///
549
550
    static const Flag CALL_EVERY_EL_POSTORDER;    

Thomas Witkowski's avatar
Thomas Witkowski committed
551
    ///
552
553
    static const Flag CALL_LEAF_EL;   

Thomas Witkowski's avatar
Thomas Witkowski committed
554
    ///
555
556
    static const Flag CALL_LEAF_EL_LEVEL;  

Thomas Witkowski's avatar
Thomas Witkowski committed
557
    ///
558
559
    static const Flag CALL_EL_LEVEL; 

Thomas Witkowski's avatar
Thomas Witkowski committed
560
    ///
561
562
563
    static const Flag CALL_MG_LEVEL;

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
564
    ///
565
    bool findElementAtPointRecursive(ElInfo *elinfo,
566
				     const DimVec<double>& lambda,
567
				     int outside,
568
569
570
				     ElInfo *final_el_info);

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
571
    /// maximal number of DOFs at one position
572
573
    static const int MAX_DOF;

Thomas Witkowski's avatar
Thomas Witkowski committed
574
    /// Name of this Mesh
575
    std::string name;
576

Thomas Witkowski's avatar
Thomas Witkowski committed
577
    /// Dimension of this Mesh. Doesn't have to be equal to dimension of world.
578
579
    int dim;

Thomas Witkowski's avatar
Thomas Witkowski committed
580
    /// Number of vertices in this Mesh
581
582
    int nVertices;

Thomas Witkowski's avatar
Thomas Witkowski committed
583
    /// Number of Edges in this Mesh
584
585
    int nEdges;

Thomas Witkowski's avatar
Thomas Witkowski committed
586
    /// Number of leaf elements in this Mesh
587
588
    int nLeaves;

Thomas Witkowski's avatar
Thomas Witkowski committed
589
    /// Total number of elements in this Mesh
590
591
    int nElements;

Thomas Witkowski's avatar
Thomas Witkowski committed
592
    /// Number of faces in this Mesh
593
594
595
596
597
598
599
600
601
    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
602
    /// Diameter of the mesh in the DIM_OF_WORLD directions
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
    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
     * If the value is non zero then preserve all DOFs on all levels (can
     * be used for multigrid, e.g.); otherwise all DOFs on the parent that are 
     * not handed over to a child are removed during refinement and added again 
     * on the parent during coarsening.
     */
    bool preserveCoarseDOFs;

Thomas Witkowski's avatar
Thomas Witkowski committed
620
    /// Number of all DOFs on a single element
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
    int nDOFEl;

    /** \brief
     * Number of DOFs at the different positions VERTEX, EDGE, (FACE,) CENTER on
     * an element:
     *
     * - nDOF[VERTEX]: number of DOFs at a vertex (>= 1)
     *
     * - nDOF[EDGE]: number of DOFs at an edge; if no DOFs are associated to
     *   edges, then this value is 0
     *
     * - nDOF[FACE]: number of DOFs at a face; if no DOFs are associated to
     *   faces, then this value is 0 (only 3d)
     *
     * - nDOF[CENTER]: number of DOFs at the barycenter; if no DOFs are 
     *   associated to the barycenter, then this value is 0
     */
    DimVec<int> nDOF;

    /** \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
664
    /// List of all DOFAdmins
665
    std::vector<DOFAdmin*> admin;
666

Thomas Witkowski's avatar
Thomas Witkowski committed
667
    /// List of all MacroElements of this Mesh
668
    std::deque<MacroElement*> macroElements;
669

Thomas Witkowski's avatar
Thomas Witkowski committed
670
    /// Needed during DOF compression (\ref DOFAdmin::compress).
671
    std::vector<DegreeOfFreedom> newDOF;
672

Thomas Witkowski's avatar
Thomas Witkowski committed
673
    /// Needed during DOF compression (\ref DOFAdmin::compress).
674
675
676
677
678
679
680
681
682
    static DOFAdmin *compressAdmin;

    /** \brief
     * Used for recursive mesh traversal. Static pointer to the mesh
     * that should be traversed. This allows access to the mesh even
     * from the static traverse routines
     */
    static Mesh* traversePtr;

Thomas Witkowski's avatar
Thomas Witkowski committed
683
    /// Used by check functions
684
    static std::vector<DegreeOfFreedom> dof_used;
685

Thomas Witkowski's avatar
Thomas Witkowski committed
686
    ///
687
    static std::map<DegreeOfFreedom, DegreeOfFreedom*> serializedDOFs;
688
689
690
691
692
693
694
695
696

    /** \brief
     * Used while mesh refinement. To create new elements 
     * elementPrototype->clone() is called, which returns a Element of the
     * same type as elementPrototype. So e.g. Elements of the different
     * dimensions can be created in a uniform way. 
     */
    Element* elementPrototype;

Thomas Witkowski's avatar
Thomas Witkowski committed
697
    /// Prototype for leaf data. Used for creation of new leaf data while refinement.
698
699
    ElementData* elementDataPrototype;

Thomas Witkowski's avatar
Thomas Witkowski committed
700
    /// Used for enumeration of all mesh elements
701
702
    int elementIndex;

Thomas Witkowski's avatar
Thomas Witkowski committed
703
    /// True if the mesh is already initialized, false otherwise.
704
705
    bool initialized;

Thomas Witkowski's avatar
Thomas Witkowski committed
706
    /// Map of managed periodic vertex associations.
707
    std::map<BoundaryType, VertexVector*> periodicAssociations;
708
709
710
711
712

    /** \brief
     * If the mesh has been created by reading a macro file, here 
     * the information are stored about the content of the file.
     */
713
    MacroInfo *macroFileInfo;
714
715

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
716
    /// for findElement-Fcts
717
    DimVec<double> final_lambda;
718
719

    /** \brief
720
721
     * Temporary variables that are used in functions \ref fineElInfoatPoint and
     * \ref fineElementAtPointRecursive.
722
     */
723
    const WorldVector<double> *g_xy0, *g_xy;
724
725

    /** \brief
726
727
     * Temporary variable that is used in functions \ref fineElInfoatPoint and
     * \ref fineElementAtPointRecursive.
728
729
     */    
    double *g_sp;
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
   
    friend class MacroInfo;
    friend class MacroReader;
    friend class MacroWriter;
    friend class MacroElement;
    friend class Element;
    friend void Element::newDOFFct1(const DOFAdmin*);
    friend void Element::newDOFFct2(const DOFAdmin*);
  };

}

#endif  // AMDIS_MESH_H