dgConservationLawShallowWater2d.h 6.1 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
  
  class boundaryWall;
  class boundaryForcedDischarge;
28
  //class boundaryCouplingSW1D;
lambrechts's avatar
lambrechts committed
29
30
31
32
33
  
  bool _linear, _constantJac;
  bool _useMovingBathWD;
  double _alphaMovingBathWD;
  double _upwindFactorRiemann;
34
  bool _laxFriedrichs;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
35
  bool _nudgingVelIsTransport;
lambrechts's avatar
lambrechts committed
36
  double _R;
37
  double _g;
38
  double _density;
lambrechts's avatar
lambrechts committed
39
  
40
41
  const functor *_bathymetry, *_bathymetryGradient;
  const functor *_originalBathymetry, *_originalBathymetryGradient;
42
  const functor *_linearDissipation, *_quadraticDissipation, *_source, *_windStress, *_coriolisFactor, *_coordinatesF;
43
44
  const functor *_movingBathFactor, *_movingBathFactorGradient;
  const functor *_fzero, *_fzerov, *_nu, *_diffusiveFlux, *_diffusion, *_ipTerm, *_xyz;
45
  const functor *_nudgingCoeff, *_nudgingVel;
46
  const functor *_sourceTerm, *_sourceTermLin, *_gradPsiTerm, *_gradPsiTermLin,
lambrechts's avatar
lambrechts committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    *_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);
63
  inline void setLaxFriedrichs(bool flag) { _laxFriedrichs = flag;}
lambrechts's avatar
lambrechts committed
64
65
66
67
  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;}
68
  void setGravity(double g) {_g = g;}
69
  void setDensity(double density) {_density = density;}
lambrechts's avatar
lambrechts committed
70
  inline double getRadius() {return _R;}
71
  void setCoordinatesFunction(functor *xyz);
lambrechts's avatar
lambrechts committed
72
73
  
  /**set the function to evaluate the coriolis factor \f{eqnarray*} \frac{du}{dt} &= &-f v \\ \frac{dv}{dt} &=& f u\f} */
74
  inline void setCoriolisFactor(const functor *coriolisFactor) { _coriolisFactor = coriolisFactor;}
lambrechts's avatar
lambrechts committed
75
  /**set the function to evaluate the linear dissipation \f{eqnarray*}\frac{du}{dt} &=& -\gamma u\\ \frac {dv}{dt} &=& -\gamma v \f}*/
76
  inline void setLinearDissipation(const functor *linearDissipation) { _linearDissipation = linearDissipation;}
lambrechts's avatar
lambrechts committed
77
  /**set the function to evaluate the quadratic dissipation \f{eqnarray*}\frac{du}{dt} &=& -c_d u||u||\\ \frac{dv}{dt}&= &-c_d v \f}*/
78
  inline void setQuadraticDissipation(const functor *quadraticDissipation) { _quadraticDissipation = quadraticDissipation;}
lambrechts's avatar
lambrechts committed
79
  /**set the function to evaluate the source term \f{eqnarray*}\frac{du}{dt} &=& s(0)\\ \frac{dv}{dt} &=& s(1)\f} */
80
  inline void setSource(const functor *source) { _source = source;}
81
82
  /**set the function to evaluate the wind induced surface stress term \f{eqnarray*}\frac{du}{dt} &=& s(0)\\ \frac{dv}{dt} &=& s(1)\f} */
  inline void setWindStress(const functor *windStress) { _windStress = windStress;}
lambrechts's avatar
lambrechts committed
83
  /**set the function to evaluate the bathymetry h (H = h+eta) */
84
  inline void setBathymetry(functor *bathymetry) { _bathymetry= bathymetry; }
lambrechts's avatar
lambrechts committed
85
  /**set the function to evaluate the gradient of the bathymetry: grad(h) */
86
  inline void setBathymetryGradient(functor *bathymetryGradient) { _bathymetryGradient = bathymetryGradient;}
lambrechts's avatar
lambrechts committed
87
  /**set the function to evaluate the diffusion term */
88
  inline void setDiffusivity(const functor *nuFunction) { _nu = nuFunction;}
89
90
91
  /**set the coefficient of the nudging layer. */
  void setNudgingCoefficient(const functor *coeff){_nudgingCoeff = coeff;}
  /**set the reference velocity for the nudging layer. */
Valentin Vallaeys's avatar
Valentin Vallaeys committed
92
93
94
95
  void setNudgingVelocity(const functor *nudgingVel, bool transport=false){
    _nudgingVel = nudgingVel;
    _nudgingVelIsTransport = transport;
  }
lambrechts's avatar
lambrechts committed
96
  /**use the moving bath WD (Karna et al, 2011) and define the bathymetry and the moving bathymetry */
97
  void setMovingBathWettingDrying(double alphaMovingBathWD);
lambrechts's avatar
lambrechts committed
98
99
100
101
102
  /** a factor to smooth the if in Hv term in the roe riemann solver */
  inline void setUpwindFactorRiemann(double upwindFactorRiemann) {
    _upwindFactorRiemann=upwindFactorRiemann;
  }
  
103
  inline const functor *getDepth() {
lambrechts's avatar
lambrechts committed
104
105
    return functionSumNew(_bathymetry,functionExtractCompNew(function::getSolution(),0));
  }
106
  inline const functor *getBathymetry() {
107
    return _bathymetry;
lambrechts's avatar
lambrechts committed
108
  }
109
  inline const functor *getElevation() {
lambrechts's avatar
lambrechts committed
110
111
    return functionExtractCompNew(function::getSolution(),0);
  }
112
  inline const functor *getVelocity() {
lambrechts's avatar
lambrechts committed
113
114
115
116
117
118
119
120
    std::vector<int> comp;
    comp.push_back(1), comp.push_back(2);
    return functionExtractCompNew(function::getSolution(),comp);
  }
  
  // Boundary conditions
  
  /**slip wall boundary */
121
  dgBoundaryCondition *newBoundaryWall(bool slip = false);
122
  dgBoundaryCondition *newForcedDischarge(dgDofContainer *solution, const functor *discharge, std::string tag);
123
  //dgBoundaryCondition *newBoundaryCouplingSW1D(const functor *solExtF);
lambrechts's avatar
lambrechts committed
124
};
125
126
127
128
129
/*==============================================================================
 * IP Term
 *============================================================================*/

functor *dgNewIpTermIsotropicOnSphere (int nbFields, const functor *diffusiveFlux, const functor *diffusivity);
lambrechts's avatar
lambrechts committed
130
#endif