dgConservationLawShallowWater2d.h 5.43 KB
Newer Older
lambrechts's avatar
lambrechts committed
1
2
3
4
5
6
7
8
9
#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,
10
               double &uStar, double &vStar, double &HStar, double &AStar, double g,
lambrechts's avatar
lambrechts committed
11
12
13
14
15
16
17
18
19
20
21
22
23
               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;
bertrand's avatar
bertrand committed
24
  void riemann(functorCache &cache,fullMatrix<double> &val) const;
lambrechts's avatar
lambrechts committed
25
26
27
28
29
30
31
32
33
34
  
  class boundaryWall;
  class boundaryForcedDischarge;
  class boundaryCouplingSW1D;
  
  bool _linear, _constantJac;
  bool _useMovingBathWD;
  double _alphaMovingBathWD;
  double _upwindFactorRiemann;
  double _R;
35
  double _g;
lambrechts's avatar
lambrechts committed
36
  
37
38
39
40
41
  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
42

43
  const functor *_sourceTerm, *_sourceTermLin, *_gradPsiTerm, *_gradPsiTermLin,
lambrechts's avatar
lambrechts committed
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;}
64
  void setGravity(double g) {_g = g;}
lambrechts's avatar
lambrechts committed
65
  inline double getRadius() {return _R;}
66
  void setCoordinatesFunction(functor *xyz);
lambrechts's avatar
lambrechts committed
67
68
  
  /**set the function to evaluate the coriolis factor \f{eqnarray*} \frac{du}{dt} &= &-f v \\ \frac{dv}{dt} &=& f u\f} */
69
  inline void setCoriolisFactor(const functor *coriolisFactor) { _coriolisFactor = coriolisFactor;}
lambrechts's avatar
lambrechts committed
70
  /**set the function to evaluate the linear dissipation \f{eqnarray*}\frac{du}{dt} &=& -\gamma u\\ \frac {dv}{dt} &=& -\gamma v \f}*/
71
  inline void setLinearDissipation(const functor *linearDissipation) { _linearDissipation = linearDissipation;}
lambrechts's avatar
lambrechts committed
72
  /**set the function to evaluate the quadratic dissipation \f{eqnarray*}\frac{du}{dt} &=& -c_d u||u||\\ \frac{dv}{dt}&= &-c_d v \f}*/
73
  inline void setQuadraticDissipation(const functor *quadraticDissipation) { _quadraticDissipation = quadraticDissipation;}
lambrechts's avatar
lambrechts committed
74
  /**set the function to evaluate the source term \f{eqnarray*}\frac{du}{dt} &=& s(0)\\ \frac{dv}{dt} &=& s(1)\f} */
75
  inline void setSource(const functor *source) { _source = source;}
lambrechts's avatar
lambrechts committed
76
  /**set the function to evaluate the bathymetry h (H = h+eta) */
77
  inline void setBathymetry(functor *bathymetry) { _bathymetry= bathymetry; }
lambrechts's avatar
lambrechts committed
78
  /**set the function to evaluate the gradient of the bathymetry: grad(h) */
79
  inline void setBathymetryGradient(functor *bathymetryGradient) { _bathymetryGradient = bathymetryGradient;}
lambrechts's avatar
lambrechts committed
80
  /**set the function to evaluate the diffusion term */
81
  inline void setDiffusivity(const functor *nuFunction) { _nu = nuFunction;}
amodave's avatar
amodave committed
82
  /**set an absorbing layer. Param: TAG, AbsCoef, ExtFields */
83
  void setAbsLayer(const std::string, const functor *, const functor *);
lambrechts's avatar
lambrechts committed
84
85
86
87
88
89
90
91
92
93
94
95
  /**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;
  }
  
96
  inline const functor *getDepth() {
lambrechts's avatar
lambrechts committed
97
98
    return functionSumNew(_bathymetry,functionExtractCompNew(function::getSolution(),0));
  }
99
  inline const functor *getBathymetry() {
lambrechts's avatar
lambrechts committed
100
101
102
103
104
    if(_useMovingBathWD)
      return new movingBath(_originalBathymetry,_alphaMovingBathWD);
    else
      return _bathymetry;
  }
105
  inline const functor *getElevation() {
lambrechts's avatar
lambrechts committed
106
107
    return functionExtractCompNew(function::getSolution(),0);
  }
108
  inline const functor *getVelocity() {
lambrechts's avatar
lambrechts committed
109
110
111
112
113
114
115
116
    std::vector<int> comp;
    comp.push_back(1), comp.push_back(2);
    return functionExtractCompNew(function::getSolution(),comp);
  }
  
  // Boundary conditions
  
  /**slip wall boundary */
117
  dgBoundaryCondition *newBoundaryWall(bool slip = false);
118
119
  dgBoundaryCondition *newForcedDischarge(dgDofContainer *solution, const functor *discharge, std::string tag);
  dgBoundaryCondition *newBoundaryCouplingSW1D(const functor *solExtF);
lambrechts's avatar
lambrechts committed
120
121
};
#endif