dgConservationLawShallowWater2d.h 5.3 KB
Newer Older
lambrechts's avatar
lambrechts committed
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
#ifndef _DG_CONSERVATION_LAW_SHALLOW_WATER_2D_
#define _DG_CONSERVATION_LAW_SHALLOW_WATER_2D_
#include "dgConservationLawFunction.h"
#include "functionGeneric.h"
#include "function.h"
#include "dgDofContainer.h"
#include "slimMovingBathWettingDrying.h"

void roeSolver(double uL, double uR, double vL, double vR, double HL, double HR,
               double &uStar, double &vStar, double &HStar, double &AStar,
               double mbFactL=1.0, double mbFactR=1.0 , double upwindFact=-1.0);

/**The non-conservative shallow water conservation law. (eta, u, v) */
class dgConservationLawShallowWater2d : public dgConservationLawFunction {
  
  //class massFactor;
  class clipToPhysics;
  class maxDiffusiveSpeed;
  class maxConvectiveSpeed;
  class gradPsiTerm;
  class source;
  class diffusiveFlux;
  class diffusivity;
  class riemann;
  
  class boundaryWall;
  class boundaryForcedDischarge;
  class boundaryCouplingSW1D;
  
  bool _linear, _constantJac;
  bool _useMovingBathWD;
  double _alphaMovingBathWD;
  double _upwindFactorRiemann;
  double _R;
  
36
37
38
39
40
  const functor *_bathymetry, *_bathymetryGradient;
  const functor *_originalBathymetry, *_originalBathymetryGradient;
  const functor *_linearDissipation, *_quadraticDissipation, *_source, *_coriolisFactor, *_coordinatesF;
  const functor *_movingBathFactor, *_movingBathFactorGradient;
  const functor *_fzero, *_fzerov, *_nu, *_diffusiveFlux, *_diffusion, *_ipTerm, *_xyz;
lambrechts's avatar
lambrechts committed
41

42
  const functor *_sourceTerm, *_sourceTermLin, *_gradPsiTerm, *_gradPsiTermLin,
lambrechts's avatar
lambrechts committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    *_riemannTerm, *_riemannTermLin, *_maxSpeed, *_maxSpeedFilt;
  imexMode _imexMode;
  bool _linearIMEX, _constantJacIMEX, _linearFilter;
 public:
  
  std::map<int, bool> dryFlag;
  
  dgConservationLawShallowWater2d();
  ~dgConservationLawShallowWater2d();
  void setup();
  
  /**if this flag is true, a linear version of the equations are solved.
   * no quadratic dissipation, no advection, no non-linear free surface term in mass conservation */
  inline void setIsLinear(bool linear) {_linear = linear; _constantJac = linear;}
  virtual void setImexMode(imexMode mode);
  void setLinearFilterMode(bool set);
  virtual bool isLinear() const {return (_linear || _linearIMEX);}
  virtual bool isConstantJac() const {return (_constantJac || _constantJacIMEX);}
  /**if this flag is true, a spherical version of the equations are solved*/
  inline void setIsSpherical(double R) {_R = R;}
  inline double getRadius() {return _R;}
64
  void setCoordinatesFunction(functor *xyz);
lambrechts's avatar
lambrechts committed
65
66
  
  /**set the function to evaluate the coriolis factor \f{eqnarray*} \frac{du}{dt} &= &-f v \\ \frac{dv}{dt} &=& f u\f} */
67
  inline void setCoriolisFactor(const functor *coriolisFactor) { _coriolisFactor = coriolisFactor;}
lambrechts's avatar
lambrechts committed
68
  /**set the function to evaluate the linear dissipation \f{eqnarray*}\frac{du}{dt} &=& -\gamma u\\ \frac {dv}{dt} &=& -\gamma v \f}*/
69
  inline void setLinearDissipation(const functor *linearDissipation) { _linearDissipation = linearDissipation;}
lambrechts's avatar
lambrechts committed
70
  /**set the function to evaluate the quadratic dissipation \f{eqnarray*}\frac{du}{dt} &=& -c_d u||u||\\ \frac{dv}{dt}&= &-c_d v \f}*/
71
  inline void setQuadraticDissipation(const functor *quadraticDissipation) { _quadraticDissipation = quadraticDissipation;}
lambrechts's avatar
lambrechts committed
72
  /**set the function to evaluate the source term \f{eqnarray*}\frac{du}{dt} &=& s(0)\\ \frac{dv}{dt} &=& s(1)\f} */
73
  inline void setSource(const functor *source) { _source = source;}
lambrechts's avatar
lambrechts committed
74
  /**set the function to evaluate the bathymetry h (H = h+eta) */
75
  inline void setBathymetry(functor *bathymetry) { _bathymetry= bathymetry; }
lambrechts's avatar
lambrechts committed
76
  /**set the function to evaluate the gradient of the bathymetry: grad(h) */
77
  inline void setBathymetryGradient(functor *bathymetryGradient) { _bathymetryGradient = bathymetryGradient;}
lambrechts's avatar
lambrechts committed
78
  /**set the function to evaluate the diffusion term */
79
  inline void setDiffusivity(const functor *nuFunction) { _nu = nuFunction;}
amodave's avatar
amodave committed
80
  /**set an absorbing layer. Param: TAG, AbsCoef, ExtFields */
81
  void setAbsLayer(const std::string, const functor *, const functor *);
lambrechts's avatar
lambrechts committed
82
83
84
85
86
87
88
89
90
91
92
93
  /**use the moving bath WD (Karna et al, 2011) and define the bathymetry and the moving bathymetry */
  inline void setMovingBathWettingDrying(double alphaMovingBathWD) {
    _useMovingBathWD = true;
    _alphaMovingBathWD = alphaMovingBathWD;
    _originalBathymetry = _bathymetry;
    _originalBathymetryGradient= _bathymetryGradient;
  }
  /** a factor to smooth the if in Hv term in the roe riemann solver */
  inline void setUpwindFactorRiemann(double upwindFactorRiemann) {
    _upwindFactorRiemann=upwindFactorRiemann;
  }
  
94
  inline const functor *getDepth() {
lambrechts's avatar
lambrechts committed
95
96
    return functionSumNew(_bathymetry,functionExtractCompNew(function::getSolution(),0));
  }
97
  inline const functor *getBathymetry() {
lambrechts's avatar
lambrechts committed
98
99
100
101
102
    if(_useMovingBathWD)
      return new movingBath(_originalBathymetry,_alphaMovingBathWD);
    else
      return _bathymetry;
  }
103
  inline const functor *getElevation() {
lambrechts's avatar
lambrechts committed
104
105
    return functionExtractCompNew(function::getSolution(),0);
  }
106
  inline const functor *getVelocity() {
lambrechts's avatar
lambrechts committed
107
108
109
110
111
112
113
114
115
    std::vector<int> comp;
    comp.push_back(1), comp.push_back(2);
    return functionExtractCompNew(function::getSolution(),comp);
  }
  
  // Boundary conditions
  
  /**slip wall boundary */
  dgBoundaryCondition *newBoundaryWall();
116
117
  dgBoundaryCondition *newForcedDischarge(dgDofContainer *solution, const functor *discharge, std::string tag);
  dgBoundaryCondition *newBoundaryCouplingSW1D(const functor *solExtF);
lambrechts's avatar
lambrechts committed
118
119
};
#endif