RosenbrockStationary.h 5.24 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20
21
22
23
24
25
26

/** \file RosenbrockStationary.h */

#ifndef AMDIS_ROSENBROCKSTATIONARY_H
#define AMDIS_ROSENBROCKSTATIONARY_H

#include "AMDiS_fwd.h"
27
#include "ProblemStat.h"
28
#include "SystemVector.h"
29
#include "time/RosenbrockMethod.h"
30

31
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
32
33
34
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
35
36
#include "parallel/PetscProblemStat.h"
#endif
37
#endif
38

39
40
namespace AMDiS {

41
42
43
44
45
46
47
48
49
50
51
52
  struct RosenbrockBoundary 
  {
    AbstractFunction<double, WorldVector<double> > *fct;
    
    DOFVector<double> *vec;

    int row;
    
    int col;
  };


53
  class RosenbrockStationary : public ProblemStat
54
55
56
  {
  public:
    RosenbrockStationary(std::string name)
57
      : ProblemStat(name),
58
59
60
	first(true),
	minusOne(-1.0),
	tauPtr(NULL),
Thomas Witkowski's avatar
Thomas Witkowski committed
61
62
63
64
	tauGamma(NULL),
	minusTauGamma(NULL),	
	invTauGamma(NULL),
	minusInvTauGamma(NULL)
65
66
67
68
69
70
71
    {}

    DOFVector<double>* getUnVec(int i)
    {
      return unVec->getDOFVector(i);
    }

72
    DOFVector<double>* getStageSolution(int i)
73
    {
74
      return stageSolution->getDOFVector(i);
75
76
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
77
78
79
80
81
    DOFVector<double>* getTimeRhsVec(int i)
    {
      return timeRhsVec->getDOFVector(i);
    }

82
83
84
85
86
    void acceptTimestep();

    void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag,
			   bool asmMatrix, bool asmVector);

Praetorius, Simon's avatar
Praetorius, Simon committed
87
    void solve(AdaptInfo *adaptInfo, bool a = true, bool b = false);
88

89
90
91
92
93
94
    void setRosenbrockMethod(RosenbrockMethod *method)
    {
      rm = method;
      init();
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
95
96
97
98
99
100
101
102
103
    void reset()
    {
      first = true;
      stageSolution->set(0.0);
      unVec->set(0.0);
      for (int i = 0; i < rm->getStages(); i++)
	stageSolutions[i]->set(0.0);
    }

104
105
106
107
108
109
110
111
112
113
114
115
116
    void addOperator(Operator &op, int row, int col, 
		     double *factor = NULL, double *estFactor = NULL);

    void addJacobianOperator(Operator &op, int row, int col, 
			     double *factor = NULL, double *estFactor = NULL);

    void addTimeOperator(int i, int j);

    void setTau(double *ptr)
    {
      tauPtr = ptr;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
    void setTauGamma(double *ptr0, double *ptr1, double *ptr2, double *ptr3)
    {
      tauGamma = ptr0;
      minusTauGamma = ptr1;
      invTauGamma = ptr2;
      minusInvTauGamma = ptr3;
    }    

    double* getTauGamma()
    {
      return tauGamma;
    }

     double* getMinusTauGamma()
    {
      return minusTauGamma;
    }

    double* getInvTauGamma()
    {
      return invTauGamma;
    }

    double* getMinusInvTauGamma()
141
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
142
      return minusInvTauGamma;
143
144
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
145
   /// Adds a Dirichlet boundary condition, where the rhs is given by an 
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
    /// abstract function.
    void addDirichletBC(BoundaryType type, int row, int col,
			AbstractFunction<double, WorldVector<double> > *b);

    /// Adds a Dirichlet boundary condition, where the rhs is given by a DOF
    /// vector.
    void addDirichletBC(BoundaryType type, int row, int col,
			DOFVector<double> *vec)
    {
      FUNCNAME("RosenbrockStationary::addDirichletBC()");

      ERROR_EXIT("Not yet supported!\n");
    }

    /// Adds a Neumann boundary condition, where the rhs is given by an
    /// abstract function.
    void addNeumannBC(BoundaryType type, int row, int col, 
		      AbstractFunction<double, WorldVector<double> > *n)    
    {
      FUNCNAME("RosenbrockStationary::addNeumannBC()");

      ERROR_EXIT("Not yet supported!\n");    
    }

    /// Adds a Neumann boundary condition, where the rhs is given by an DOF
    /// vector.
    void addNeumannBC(BoundaryType type, int row, int col, 
		      DOFVector<double> *n)
    {
      FUNCNAME("RosenbrockStationary::addNeumannBC()");

      ERROR_EXIT("Not yet supported!\n");
    }

    /// Adds Robin boundary condition.
    void addRobinBC(BoundaryType type, int row, int col, 
		    AbstractFunction<double, WorldVector<double> > *n,
		    AbstractFunction<double, WorldVector<double> > *r)
    {
      FUNCNAME("RosenbrockStationary::addRobinBC()");

      ERROR_EXIT("Not yet supported!\n");
    }

190
#if 0
191
192
193
194
195
196
197
    /// Adds a periodic boundary condition.
    void addPeriodicBC(BoundaryType type, int row, int col)
    {
      FUNCNAME("RosenbrockStationary::addPeriodicBC()");

      ERROR_EXIT("Not yet supported!\n");
    }
198
#endif
199

200
  protected:
201
202
    void init();

203
  protected:    
204
    RosenbrockMethod *rm;
205

206
    SystemVector *stageSolution, *unVec, *timeRhsVec, *newUn, *tmp, *lowSol;
207
208
209

    std::vector<SystemVector*> stageSolutions;

210
211
212
213
    bool first;

    double minusOne;

214
215
    double *tauPtr;

Thomas Witkowski's avatar
Thomas Witkowski committed
216
    double *tauGamma, *minusTauGamma, *invTauGamma, *minusInvTauGamma;
217
218

    std::vector<RosenbrockBoundary> boundaries;
219
220
221
222
223
  };

}

#endif // AMDIS_ROSENBROCKSTATIONARY_H