CoarseningManager.h 3.97 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
// ==                                                                        ==
// ============================================================================

/** \file CoarseningManager.h */

#ifndef AMDIS_COARSENINGMANAGER_H
#define AMDIS_COARSENINGMANAGER_H

#include "Global.h"
#include "Mesh.h"
#include "ProblemStatBase.h"
28
#include "AMDiS_fwd.h"
29 30 31 32 33 34 35 36 37 38 39 40

namespace AMDiS {

  /** \ingroup Adaption
   * \brief
   * Base class of CoarseningManager1d, CoarseningManager2d, CoarseningManager3d.
   * A CoarseningManager contains all functionality to perform coarsening
   * operations on the mesh. 
   */
  class CoarseningManager
  {
  public:
41
    /// Constructs a CoarseningManager which belongs to aMesh 
42
    CoarseningManager() 
43 44 45 46
      : mesh(NULL), 
	stack(NULL), 
	doMore(0) 
    {}
47

48 49
    /// destructor
    virtual ~CoarseningManager() {}
50

51
    /// Returns the Mesh the CoarseningManager belongs to.
Thomas Witkowski's avatar
Thomas Witkowski committed
52 53 54 55
    inline Mesh* getMesh() 
    { 
      return mesh; 
    }
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

    /** \brief
     * Tries to coarsen every element of mesh at least mark times. First
     * all elements are marked for coarsening and then coarsenMesh will
     * be called. 
     */
    Flag globalCoarsen(Mesh *aMesh, int mark);
  
    /** \brief
     * Traversal routine for recursiv coarsening of a triangulation. It has
     * a default definition in CoarseningManager but it can be overriden
     * by sub classes (like in CoarseningManager1d), if another implementation
     * is needed. 
     */
    virtual Flag coarsenMesh(Mesh *aMesh);


  protected:
    /** \brief
     * If the mesh is coarsened by non recurisive traversal, this method 
     * spezifies
     * how one element of the mesh is coarsened. The method can be overriden
     * by sub classes, if used. 
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
80 81 82 83
    virtual int coarsenFunction(ElInfo *) 
    { 
      return 0; 
    }
84 85 86 87 88 89 90 91 92 93

    /** \brief
     *  Propagate coarsening information over the whole hierarchy
     *  by POSTORDER traversal of the hierarchy tree.       
     *  leaves:      'increment' coarsening mark,            
     *  inner nodes: set coarsening mark to                
     *               min(0,child[0].mark+1,child[1].mark+1)
     */
    void spreadCoarsenMark();

94
    /// Resets the element marks
95 96 97
    void cleanUpAfterCoarsen();

  protected:
98 99
    /// The Mesh this CoarseningManager belongs to.
    Mesh *mesh;
100

101
    /// Used for non recursive mesh traversal.
102 103
    TraverseStack *stack;

104
    /// Spezifies whether the coarsening operation is still in progress
105 106
    bool doMore;

107
    /// Spezifies how many DOFVectors should restricted while coarsening
108 109 110 111 112 113 114 115 116 117 118 119
    int callCoarseRestrict;

    friend class RCNeighbourList;
  };

}

#include "CoarseningManager1d.h"
#include "CoarseningManager2d.h"
#include "CoarseningManager3d.h"

#endif // AMDIS_COARSENINGMANAGER_H