ResidualEstimator.h 4.29 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
36
37
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file ResidualEstimator.h */

/** \defgroup Estimator Estimator module
 * @{ <img src="estimator.png"> @}
 */

#ifndef AMDIS_RESIDUALESTIMATOR_H
#define AMDIS_RESIDUALESTIMATOR_H

#include "Estimator.h"
#include "FixVec.h"

namespace AMDiS {

  /** \brief
   * Returns residual square at quadrature point. Not Member of
   * Estimator to avoid multiple instantiation.
   */
Thomas Witkowski's avatar
Thomas Witkowski committed
38
39
40
  void r(const ElInfo *elInfo,
	 int nPoints,
	 const double *uhIq,
41
42
	 const WorldVector<double> *grdUhIq,
	 const WorldMatrix<double> *D2UhIq,
Thomas Witkowski's avatar
Thomas Witkowski committed
43
	 const double *uhOldIq,
44
45
46
47
48
49
50
	 const WorldVector<double> *grdUhOldIq,
	 const WorldMatrix<double> *D2UhOldIq,
	 DOFMatrix *A, 
	 DOFVector<double> *fh,
	 Quadrature *quad,
	 double *result);
 
51
52
53
  /// Returns pow(det,2.0/dim). Not Member of Estimator to avoid multiple instantiation.
  inline double h2_from_det(double det, int dim) 
  {
54
    return pow(det, 2.0 / dim);
Thomas Witkowski's avatar
Thomas Witkowski committed
55
  }
56
57
58
59
60
61
62
63
64
65

  /**
   * \ingroup Estimator
   * 
   * \brief
   * Estimator for scalar problems.
   */
  class ResidualEstimator : public Estimator
  {
  public:
66
    /// Creator class used in the OEMSolverMap.
67
68
69
    class Creator : public EstimatorCreator
    {
    public:
Thomas Witkowski's avatar
Thomas Witkowski committed
70
      Creator() : EstimatorCreator() {}
71

Thomas Witkowski's avatar
Thomas Witkowski committed
72
      virtual ~Creator() {}
73

74
75
76
      /// Returns a new ODirSolver object.
      Estimator* create() 
      { 
Thomas Witkowski's avatar
Thomas Witkowski committed
77
	return new ResidualEstimator(name, row);
Thomas Witkowski's avatar
Thomas Witkowski committed
78
      }
79
80
    };
  
81
    /// Constructor.
82
    ResidualEstimator(std::string name, int r);
83
84
85
86
87
88
89
90

    virtual void init(double timestep);

    virtual void estimateElement(ElInfo *elInfo);

    virtual void exit(bool output = true);

  protected:
91
    /// Constant in front of element residual
92
93
    double C0;
 
94
    /// Constant in front of edge/face residual
95
96
    double C1;

97
    /// Not used! Was thought to be the constant in front of coarsening term.
98
99
    double C2;

100
    /// Constant in front of the time
101
102
    double C3;

Thomas Witkowski's avatar
Thomas Witkowski committed
103
104
    /// Number of systems, e.g., number of variables in the equation.
    int nSystems;
105

Thomas Witkowski's avatar
Thomas Witkowski committed
106
107
    /// Number of quadrature points.
    int nPoints;
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

    int dim;

    int degree;

    Quadrature *quad;

    FastQuadrature **quadFast;

    const BasisFunction **basFcts;

    double **uhEl;

    double **uhOldEl;

123
124
    double **uhNeigh;

125
126
127
128
    double *uhQP;

    double *uhOldQP;

129
    /// Stores the element residual computed at the quadrature points of the element.
130
    double *riq;
131
132
133
134

    WorldVector<double> *grdUh_qp;

    WorldMatrix<double> *D2uhqp; 
135
136
137

    ElInfo *neighInfo;

138
    Quadrature *surfaceQuad;
139

140
    int nPointsSurface;
141

142
    Vector<WorldVector<double> > grdUhEl;
143

144
    Vector<WorldVector<double> > grdUhNeigh;
145

146
    Vector<WorldVector<double> > jump;
147

148
    Vector<WorldVector<double> > localJump;
149

150
    WorldVector<int> faceIndEl;
151
    
152
    WorldVector<int> faceIndNeigh;
153

154
    DimVec<WorldVector<double> > *lambdaNeigh;
155

156
    DimVec<double> *lambda;
157

158
159
    /// Maximal number of neighbours an element may have in the used dimension.
    int nNeighbours;
160
161
162
163
  };
}

#endif // AMDIS_RESIDUALESTIMATOR_H