PetscSolverNavierStokes.h 3.13 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==  http://www.amdis-fem.org                                              ==
// ==                                                                        ==
// ============================================================================
//
// 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.



/** \file PetscSolverNavierStokes.h */

#ifndef AMDIS_PETSC_SOLVER_NAVIER_STOKES_H
#define AMDIS_PETSC_SOLVER_NAVIER_STOKES_H

#include "parallel/PetscSolverGlobalMatrix.h"

namespace AMDiS {

  using namespace std;

32
  struct NavierStokesSchurData {
33
34
35
36
37
    KSP kspMass, kspLaplace;
    
    Mat matConDif;
  };

38
39
  class PetscSolverNavierStokes : public PetscSolverGlobalMatrix
  {
40
41
42
43
44
  private:
    class IdFct : public AbstractFunction<double, double>
    {
    public:
      IdFct() 
Thomas Witkowski's avatar
blub  
Thomas Witkowski committed
45
	: AbstractFunction<double, double>(1)
46
47
48
49
50
51
52
53
      {}
      
      double operator()(const double& x) const 
      {
	return x;
      }
    };

Thomas Witkowski's avatar
blub  
Thomas Witkowski committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
    class MultConstFct : public AbstractFunction<double, double>
    {
    public:
      MultConstFct(double c) 
	: AbstractFunction<double, double>(1),
	  mConst(c)
      {}
      
      double operator()(const double& x) const 
      {
	return mConst * x;
      }
    private:
      double mConst;
    };

    class Multiplier3 : public BinaryAbstractFunction<double, double, double>
    {
    public:
      Multiplier3() 
	: BinaryAbstractFunction<double, double, double >(6) 
      {}
      
      double operator()(const double& phi, const double& phase) const 
      {
   	return  phase * phi;
      }
    };


    class EinsMinus : public AbstractFunction<double, double>
    {
    public:
      EinsMinus(double d)   
	: AbstractFunction<double, double>(2),
	  c(d)
      {}
      
      double operator()(const double& x) const 
      {
	return c * std::max(1.0-x,0.000001);
      }
    private:
      double c;
    };

    struct Multiplication : public BinaryAbstractFunction<double, double, double>{
      double operator()(const double &v1, const double &v2) const{
	return v2 / v1;
      }
    };
    


108
  public:
109
    PetscSolverNavierStokes(string name);
110

111
112
113
114
115
116
    void setStokesData(double *nuPtr, double *invTauPtr, SystemVector *vec)
    {
      nu = nuPtr;
      invTau = invTauPtr;
      solution = vec;
    }
Thomas Witkowski's avatar
blub  
Thomas Witkowski committed
117
118
119
120
121
    
    void setPhase(DOFVector<double> *d)
    {
      phase = d;
    }
122

123
  protected:
124
    void initSolver(KSP &ksp);
125
126

    void initPreconditioner(PC pc);
127
128
129
130
131
132

  private:
    int pressureComponent;

    PetscSolver *massMatrixSolver, *laplaceMatrixSolver, *conDifMatrixSolver;

133
134
135
136
137
    NavierStokesSchurData matShellContext;

    double *nu, *invTau;

    SystemVector* solution;
Thomas Witkowski's avatar
blub  
Thomas Witkowski committed
138
139

    DOFVector<double>* phase;
140
141
    
    IdFct idFct;
142
143
144
145
146
  };

}

#endif