Mesh.h 22.8 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
    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
    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.
     */
90
91
    inline int getGeo(GeoIndex p) const 
    { 
92
      return Global::getGeo(p, dim); 
93
    }
94

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

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

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

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

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

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

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
143
    /// Returns \ref nElements of the mesh
144
145
    inline const int getNumberOfElements() const 
    { 
146
      return nElements; 
147
    }
148

Thomas Witkowski's avatar
Thomas Witkowski committed
149
    /// Returns \ref maxEdgeNeigh of the mesh
150
151
    inline const int getMaxEdgeNeigh() const 
    { 
152
      return maxEdgeNeigh; 
153
    }
154

Thomas Witkowski's avatar
Thomas Witkowski committed
155
    /// Returns \ref parametric of the mesh
156
157
    inline Parametric *getParametric() const 
    { 
158
      return parametric; 
159
    }
160

Thomas Witkowski's avatar
Thomas Witkowski committed
161
    /// Returns \ref diam of the mesh
162
163
    inline const WorldVector<double>& getDiameter() const 
    { 
164
      return diam; 
165
    }
166

Thomas Witkowski's avatar
Thomas Witkowski committed
167
    /// Returns nDOF[i] of the mesh
168
169
    inline const int getNumberOfDOFs(int i) const 
    { 
170
      return nDOF[i]; 
171
    }
172

Thomas Witkowski's avatar
Thomas Witkowski committed
173
    /// Returns \ref elementPrototype of the mesh
174
175
    inline Element* getElementPrototype() 
    { 
176
      return elementPrototype; 
177
    }
178

Thomas Witkowski's avatar
Thomas Witkowski committed
179
    /// Returns \ref leafDataPrototype of the mesh
180
181
    inline ElementData* getElementDataPrototype() 
    { 
182
      return elementDataPrototype; 
183
    }
184

Thomas Witkowski's avatar
Thomas Witkowski committed
185
    /// Returns node[i] of the mesh 
186
187
    inline int getNode(int i) const 
    { 
188
      return node[i]; 
189
    }
190
191
192
193
194
195
196
197
198

    /** \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
199
    /// Returns *(\ref admin[i]) of the mesh
200
201
    inline const DOFAdmin& getDOFAdmin(int i) const 
    {
202
      return *(admin[i]);
203
    }
204
205
206
207
208
209

    /** \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.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
210
    const DOFAdmin* createDOFAdmin(std::string lname, DimVec<int> nDOF);
211
212
213
214
215

    /** \brief
     * Returns the size of \ref admin which is the number of the DOFAdmins
     * belonging to this mesh
     */
216
217
    const int getNumberOfDOFAdmin() const 
    {
218
      return admin.size();
219
    }
220
221
222
223
224

    /** \brief
     * Returns the size of \ref macroElements which is the number of
     * of macro elements of this mesh
     */
225
226
    const int getNumberOfMacros() const 
    {
227
      return macroElements.size();
228
    }
229

Thomas Witkowski's avatar
Thomas Witkowski committed
230
    /// Returns a DOFAdmin which at least manages vertex DOFs
231
232
    const DOFAdmin* getVertexAdmin() const;

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

Thomas Witkowski's avatar
Thomas Witkowski committed
236
    /// Returns \ref preserveCoarseDOFs of the mesh
237
238
    inline bool queryCoarseDOFs() const 
    { 
239
      return preserveCoarseDOFs;
240
    }
241

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

Thomas Witkowski's avatar
Thomas Witkowski committed
248
    /// Returns macroElements[i].
249
250
    inline MacroElement *getMacroElement(int i) 
    { 
251
      return macroElements[i]; 
252
    }
253

Thomas Witkowski's avatar
Thomas Witkowski committed
254
    /// Returns an iterator to the end of \ref macroElements
255
256
    inline std::deque<MacroElement*>::iterator endOfMacroElements() 
    {
257
      return macroElements.end();
258
    }
259
260
261
262
263
264
265

    /** \} */

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

Thomas Witkowski's avatar
Thomas Witkowski committed
266
    /// Sets \ref name of the mesh
Thomas Witkowski's avatar
Thomas Witkowski committed
267
    inline void setName(std::string aName) 
268
    { 
269
      name = aName;
270
    }
271

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

Thomas Witkowski's avatar
Thomas Witkowski committed
278
    /// Sets \ref nFaces of the mesh
279
280
    inline void setNumberOfFaces(int n) 
    { 
281
      nFaces = n; 
282
    }
283

Thomas Witkowski's avatar
Thomas Witkowski committed
284
    /// Increments \ref nVertices by inc
285
286
    inline void incrementNumberOfVertices(int inc) 
    { 
287
      nVertices += inc; 
288
    }
289
 
Thomas Witkowski's avatar
Thomas Witkowski committed
290
    /// Sets \ref nEdges of the mesh
291
292
    inline void setNumberOfEdges(int n) 
    { 
293
      nEdges = n; 
294
    }
295

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

Thomas Witkowski's avatar
Thomas Witkowski committed
302
    /// Increments \ref nFaces by inc
303
304
    inline void incrementNumberOfFaces(int inc) 
    { 
305
      nFaces += inc; 
306
    }
307

Thomas Witkowski's avatar
Thomas Witkowski committed
308
    /// Sets \ref nLeaves of the mesh
309
310
    inline void setNumberOfLeaves(int n) 
    { 
311
      nLeaves = n; 
312
    }
313

Thomas Witkowski's avatar
Thomas Witkowski committed
314
    /// Increments \ref nLeaves by inc
315
316
    inline void incrementNumberOfLeaves(int inc) 
    { 
317
      nLeaves += inc; 
318
    }
319

Thomas Witkowski's avatar
Thomas Witkowski committed
320
    /// Sets \ref nElements of the mesh
321
322
    inline void setNumberOfElements(int n) 
    { 
323
      nElements = n; 
324
    }
325

Thomas Witkowski's avatar
Thomas Witkowski committed
326
    /// Increments \ref nElements by inc
327
328
    inline void incrementNumberOfElements(int inc) 
    { 
329
      nElements += inc; 
330
    }
331

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

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

Thomas Witkowski's avatar
Thomas Witkowski committed
338
    /// Sets \ref preserveCoarseDOFs = true
339
340
    inline void retainCoarseDOFs() 
    {
341
      preserveCoarseDOFs = true;
342
    }
343

Thomas Witkowski's avatar
Thomas Witkowski committed
344
    /// Sets \ref preserveCoarseDOFs = b
345
346
    inline void setPreserveCoarseDOFs(bool b) 
    {
347
      preserveCoarseDOFs = b;
348
    }
349

Thomas Witkowski's avatar
Thomas Witkowski committed
350
    /// Sets \ref preserveCoarseDOFs = false
351
352
    inline void noCoarseDOFs() 
    {
353
      preserveCoarseDOFs = false;
354
    }
355

Thomas Witkowski's avatar
Thomas Witkowski committed
356
    /// Sets \ref elementPrototype of the mesh
357
358
    inline void setElementPrototype(Element* prototype) 
    {
359
      elementPrototype = prototype;
360
361
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
362
    /// Sets \ref elementDataPrototype of the mesh
363
364
    inline void setElementDataPrototype(ElementData* prototype) 
    {
365
      elementDataPrototype = prototype;
366
    }
367

Thomas Witkowski's avatar
Thomas Witkowski committed
368
    ///
369
370
    inline void setParametric(Parametric *param) 
    {
371
      parametric = param;
372
    }
373

Thomas Witkowski's avatar
Thomas Witkowski committed
374
    ///
375
376
    inline void setMaxEdgeNeigh(int m) 
    { 
377
      maxEdgeNeigh = m; 
378
    }
379
380
381
  
    /** \} */

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

Thomas Witkowski's avatar
Thomas Witkowski committed
385
    /// Creates a new ElInfo dependent of \ref dim of the mesh
386
387
    ElInfo* createNewElInfo();

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

Thomas Witkowski's avatar
Thomas Witkowski committed
391
    /// Frees memory for the given element el
392
393
    void freeElement(Element* el);

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

Thomas Witkowski's avatar
Thomas Witkowski committed
397
    /// Adds a DOFAdmin to the mesh
398
    virtual void addDOFAdmin(DOFAdmin *admin);
399

400
401
402
    /// Recalculates the number of leave elements.
    void updateNumberOfLeaves();

Thomas Witkowski's avatar
Thomas Witkowski committed
403
    /// Clears \ref macroElements
404
405
    inline void clearMacroElements() 
    { 
406
      macroElements.clear();
407
    }
408
  
Thomas Witkowski's avatar
Thomas Witkowski committed
409
    /// Adds a macro element to the mesh
410
411
    void addMacroElement(MacroElement* me);

412
    /* \brief
413
414
415
     * 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.
416
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
417
418
    void removeMacroElements(std::vector<MacroElement*>& macros,
			     const FiniteElemSpace* feSpace);
419

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

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

    /** \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.
     */
466
467
468
    bool findElementAtPoint(const WorldVector<double>& xy,
			    Element **elp, 
			    DimVec<double>& bary,
469
			    const MacroElement *start_mel,
470
471
			    const WorldVector<double> *xy0,
			    double *sp);
472

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
    /** \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,
			   WorldVector<double>& coords);

490
491
492
    bool getDofIndexCoords(DegreeOfFreedom dof, 
			   const FiniteElemSpace* feSpace,
			   WorldVector<double>& coords);
493

Thomas Witkowski's avatar
Thomas Witkowski committed
494
    /// Returns FILL_ANY_?D
495
496
    inline static const Flag& getFillAnyFlag(int dim) 
    {
497
      switch (dim) {
498
499
500
501
502
503
504
505
506
507
508
509
510
      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;
      }
511
    }
512

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

Thomas Witkowski's avatar
Thomas Witkowski committed
516
    /// Deserialize a mesh from a file.
517
    void deserialize(std::istream &in);
518

Thomas Witkowski's avatar
Thomas Witkowski committed
519
    /// Returns \ref elementIndex and increments it by 1.
520
521
    inline int getNextElementIndex() 
    { 
522
      return elementIndex++; 
523
    }
524

Thomas Witkowski's avatar
Thomas Witkowski committed
525
    /// Returns \ref initialized.
526
527
    inline bool isInitialized() 
    {
528
529
      return initialized; 
    }
530
  
Thomas Witkowski's avatar
Thomas Witkowski committed
531
    ///
532
533
    inline std::map<BoundaryType, VertexVector*>& getPeriodicAssociations() 
    {
534
      return periodicAssociations;
535
    }
536

Thomas Witkowski's avatar
Thomas Witkowski committed
537
    ///
538
539
    bool associated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
540
    ///
541
542
    bool indirectlyAssociated(DegreeOfFreedom dof1, DegreeOfFreedom dof2);

Thomas Witkowski's avatar
Thomas Witkowski committed
543
    /// Returns \macroFileInfo
544
545
    inline MacroInfo* getMacroFileInfo() 
    { 
546
      return macroFileInfo;
547
    }
548

Thomas Witkowski's avatar
Thomas Witkowski committed
549
    ///
550
551
    void clearMacroFileInfo();

552
553
554
555
556
557
558
    /** \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
559
    ///
560
561
    int calcMemoryUsage();

562
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
563
    ///
564
565
    static const Flag FILL_NOTHING;

Thomas Witkowski's avatar
Thomas Witkowski committed
566
    ///
567
    static const Flag FILL_COORDS; 
568

Thomas Witkowski's avatar
Thomas Witkowski committed
569
    ///
570
    static const Flag FILL_BOUND; 
571

Thomas Witkowski's avatar
Thomas Witkowski committed
572
    ///
573
    static const Flag FILL_NEIGH; 
574

Thomas Witkowski's avatar
Thomas Witkowski committed
575
    ///
576
    static const Flag FILL_OPP_COORDS; 
577

Thomas Witkowski's avatar
Thomas Witkowski committed
578
    ///
579
580
    static const Flag FILL_ORIENTATION; 

Thomas Witkowski's avatar
Thomas Witkowski committed
581
    ///
582
    static const Flag FILL_ADD_ALL; 
583
  
Thomas Witkowski's avatar
Thomas Witkowski committed
584
    ///
585
    static const Flag FILL_ANY_1D; 
586

Thomas Witkowski's avatar
Thomas Witkowski committed
587
    ///
588
    static const Flag FILL_ANY_2D; 
589

Thomas Witkowski's avatar
Thomas Witkowski committed
590
    ///
591
    static const Flag FILL_ANY_3D; 
592

Thomas Witkowski's avatar
Thomas Witkowski committed
593
    ///
594
    static const Flag FILL_DET;
595

Thomas Witkowski's avatar
Thomas Witkowski committed
596
    ///
597
598
599
600
601
602
    static const Flag FILL_GRD_LAMBDA;

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

Thomas Witkowski's avatar
Thomas Witkowski committed
603
    ///
604
605
    static const Flag CALL_EVERY_EL_PREORDER;      

Thomas Witkowski's avatar
Thomas Witkowski committed
606
    ///
607
608
    static const Flag CALL_EVERY_EL_INORDER;     

Thomas Witkowski's avatar
Thomas Witkowski committed
609
    ///
610
611
    static const Flag CALL_EVERY_EL_POSTORDER;    

Thomas Witkowski's avatar
Thomas Witkowski committed
612
    ///
613
614
    static const Flag CALL_LEAF_EL;   

Thomas Witkowski's avatar
Thomas Witkowski committed
615
    ///
616
617
    static const Flag CALL_LEAF_EL_LEVEL;  

Thomas Witkowski's avatar
Thomas Witkowski committed
618
    ///
619
620
    static const Flag CALL_EL_LEVEL; 

Thomas Witkowski's avatar
Thomas Witkowski committed
621
    ///
622
623
624
    static const Flag CALL_MG_LEVEL;

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
625
    ///
626
    bool findElementAtPointRecursive(ElInfo *elinfo,
627
				     const DimVec<double>& lambda,
628
				     int outside,
629
630
631
				     ElInfo *final_el_info);

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
632
    /// maximal number of DOFs at one position
633
634
    static const int MAX_DOF;

Thomas Witkowski's avatar
Thomas Witkowski committed
635
    /// Name of this Mesh
636
    std::string name;
637

Thomas Witkowski's avatar
Thomas Witkowski committed
638
    /// Dimension of this Mesh. Doesn't have to be equal to dimension of world.
639
640
    int dim;

Thomas Witkowski's avatar
Thomas Witkowski committed
641
    /// Number of vertices in this Mesh
642
643
    int nVertices;

Thomas Witkowski's avatar
Thomas Witkowski committed
644
    /// Number of Edges in this Mesh
645
646
    int nEdges;

Thomas Witkowski's avatar
Thomas Witkowski committed
647
    /// Number of leaf elements in this Mesh
648
649
    int nLeaves;

Thomas Witkowski's avatar
Thomas Witkowski committed
650
    /// Total number of elements in this Mesh
651
652
    int nElements;

Thomas Witkowski's avatar
Thomas Witkowski committed
653
    /// Number of faces in this Mesh
654
655
656
657
658
659
660
661
662
    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
663
    /// Diameter of the mesh in the DIM_OF_WORLD directions
664
665
666
667
668
669
670
671
672
673
    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
674
675
676
677
678
679
680
     * 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.
681
682
683
     */
    bool preserveCoarseDOFs;

Thomas Witkowski's avatar
Thomas Witkowski committed
684
    /// Number of all DOFs on a single element
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
    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
728
    /// List of all DOFAdmins
729
    std::vector<DOFAdmin*> admin;
730

Thomas Witkowski's avatar
Thomas Witkowski committed
731
    /// List of all MacroElements of this Mesh
732
    std::deque<MacroElement*> macroElements;
733

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

Thomas Witkowski's avatar
Thomas Witkowski committed
737
    /// Needed during DOF compression (\ref DOFAdmin::compress).
738
739
    static DOFAdmin *compressAdmin;

Thomas Witkowski's avatar
Thomas Witkowski committed
740
    /// Used by check functions
741
    static std::vector<DegreeOfFreedom> dof_used;
742

743
744
745
746
747
748
749
750
751
752
753
    /** \brief
     * This map is used for serialization and deserialization of mesh elements. 
     * During the serialization process, all elements are visited and their dof indices
     * are written to the file. If a dof index at a position, i.e. vertex, line or face,
     * was written to file, the combination of dof index and position is inserted to
     * this map. That ensures that the same dof at the same position, but being part of
     * another element, is not written twice to the file. 
     * When a state should be deserialized, the information can be used to construct
     * exactly the same dof structure.
     */
    static std::map<std::pair<DegreeOfFreedom, int>, DegreeOfFreedom*> serializedDOFs;
754
755
756
757
758
759
760
761
762

    /** \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
763
    /// Prototype for leaf data. Used for creation of new leaf data while refinement.
764
765
    ElementData* elementDataPrototype;

Thomas Witkowski's avatar
Thomas Witkowski committed
766
    /// Used for enumeration of all mesh elements
767
768
    int elementIndex;

Thomas Witkowski's avatar
Thomas Witkowski committed
769
    /// True if the mesh is already initialized, false otherwise.
770
771
    bool initialized;

Thomas Witkowski's avatar
Thomas Witkowski committed
772
    /// Map of managed periodic vertex associations.
773
    std::map<BoundaryType, VertexVector*> periodicAssociations;
774
775
776
777
778

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

  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
782
    /// for findElement-Fcts
783
    DimVec<double> final_lambda;
784
785

    /** \brief
786
787
     * Temporary variables that are used in functions \ref fineElInfoatPoint and
     * \ref fineElementAtPointRecursive.
788
     */
789
    const WorldVector<double> *g_xy0, *g_xy;
790
791

    /** \brief
792
793
     * Temporary variable that is used in functions \ref fineElInfoatPoint and
     * \ref fineElementAtPointRecursive.
794
795
     */    
    double *g_sp;
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
   
    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