RosenbrockStationary.h 4.65 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
  {
  public:
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    class IdFunc : public AbstractFunction<double, double>
    {
    public:
      IdFunc()
	: AbstractFunction<double, double>(1)
      {}
      
      double operator()(const double& u) const 
      {
	return u;
      }
    };


70
    RosenbrockStationary(std::string name)
71
      : ProblemStat(name),
72
73
74
75
	first(true),
	minusOne(-1.0),
	tauPtr(NULL),
	tauGamma(NULL)
76
77
78
79
80
81
82
    {}

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

83
    DOFVector<double>* getStageSolution(int i)
84
    {
85
      return stageSolution->getDOFVector(i);
86
87
88
89
90
91
92
    }

    void acceptTimestep();

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

93
    void solve(AdaptInfo *adaptInfo, bool, bool);
94

95
96
97
98
99
100
    void setRosenbrockMethod(RosenbrockMethod *method)
    {
      rm = method;
      init();
    }

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    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;
    }

    void setTauGamma(double *ptr)
    {
      tauGamma = ptr;
    }

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    /// Adds a Dirichlet boundary condition, where the rhs is given by an 
    /// 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");
    }

164
#if 0
165
166
167
168
169
170
171
    /// Adds a periodic boundary condition.
    void addPeriodicBC(BoundaryType type, int row, int col)
    {
      FUNCNAME("RosenbrockStationary::addPeriodicBC()");

      ERROR_EXIT("Not yet supported!\n");
    }
172
#endif
173

174
  protected:
175
176
    void init();

177
  protected:    
178
    RosenbrockMethod *rm;
179

180
    SystemVector *stageSolution, *unVec, *timeRhsVec, *newUn, *tmp, *lowSol;
181
182
183

    std::vector<SystemVector*> stageSolutions;

184
185
186
187
    bool first;

    double minusOne;

188
189
    double *tauPtr;

190
    double *tauGamma;
191
192

    std::vector<RosenbrockBoundary> boundaries;
193
194
195
196
197
  };

}

#endif // AMDIS_ROSENBROCKSTATIONARY_H