dgConservationLawShallowWater2d.h 7.49 KB
Newer Older
lambrechts's avatar
lambrechts committed
1
2
3
4
5
6
7
8
#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"

void roeSolver(double uL, double uR, double vL, double vR, double HL, double HR,
9
               double &uStar, double &vStar, double &HStar, double &AStar, double g,
lambrechts's avatar
lambrechts committed
10
11
12
13
14
15
16
               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 clipToPhysics;
  class maxConvectiveSpeed;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
17
18
19
20
  void gradPsiTerm(functorCache &cache,fullMatrix<double> &val) const;
  void source(functorCache &cache,fullMatrix<double> &val) const;
  void diffusiveFlux(functorCache &cache,fullMatrix<double> &val) const;
  void diffusivity(functorCache &cache,fullMatrix<double> &val) const;
bertrand's avatar
bertrand committed
21
  void riemann(functorCache &cache,fullMatrix<double> &val) const;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
22
  void dgConservationLawShallowWater2dWallExtValue(functorCache &cache,fullMatrix<double> &val, double slip_factor) const;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
23
  void dgConservationLawShallowWater2dWallExtValueGrad(functorCache &cache,fullMatrix<double> &val) const;
lambrechts's avatar
lambrechts committed
24
  
Valentin Vallaeys's avatar
Valentin Vallaeys committed
25
  //class boundaryWall;
lambrechts's avatar
lambrechts committed
26
  class boundaryForcedDischarge;
27
  //class boundaryCouplingSW1D;
lambrechts's avatar
lambrechts committed
28
29
30
31
32
  
  bool _linear, _constantJac;
  bool _useMovingBathWD;
  double _alphaMovingBathWD;
  double _upwindFactorRiemann;
33
  bool _laxFriedrichs;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
34
  bool _nudgingVelIsTransport;
35
  double _density;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
36
  bool _from3D, _linearSolverFrom3D;
lambrechts's avatar
lambrechts committed
37
  
38
  const functor *_bathymetry, *_bathymetryGradient;
39
  const functor *_hydro, *_hydroGradient;
40
  const functor *_originalBathymetry, *_originalBathymetryGradient;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
41
42
  const functor *_linearDissipation, *_quadraticDissipation, *_source, *_windStress, *_coriolisFactor, *_g, *_atmPress;
  const functor *_rhoSurf, *_rhoSurfGrad;
43
  const functor *_movingBathFactor, *_movingBathFactorGradient;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
44
  const functor *_fzero, *_fzerov, *_nu, *_diffusiveFlux, *_diffusion, *_ipTerm;
45
  const functor *_nudgingCoeff, *_nudgingVel;
Valentin Vallaeys's avatar
Valentin Vallaeys committed
46
47
48
49
50
51
  const functor *_etaOld;
//  const functor *_sourceTerm, *_sourceTermLin, *_gradPsiTerm, *_gradPsiTermLin,
//    *_riemannTerm, *_riemannTermLin, *_maxSpeed, *_maxSpeedFilt;
  const functor *_sourceTerm, *_gradPsiTerm, *_riemannTerm, *_maxSpeed;
  //imexMode _imexMode;
  //bool _linearIMEX, _constantJacIMEX, _linearFilter;
lambrechts's avatar
lambrechts committed
52
53
54
55
56
57
58
59
60
61
62
 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;}
Valentin Vallaeys's avatar
Valentin Vallaeys committed
63
64
65
66
67
68
69
70
71
  inline bool getIsLinear(){return _linear;}
  /**if this flag is true, 2D equations of SLIM3D are solved: only coriolis, gradEta, rhoSurf(Grad) (no adv, no diff !).
   * only for mode-splitting in 3D */
  inline void setFrom3D(bool f) {_from3D = f;}
  /**if this flag is true, div(H*u) is approximated by div((h+eta_old)*u).
   * option useful for mode-splitting in 3D, to fasten the code */
  inline void setLinearSolverFrom3D(bool f) {_linearSolverFrom3D = f; _linear = f; _constantJac = f;}
  //virtual void setImexMode(imexMode mode);
  //void setLinearFilterMode(bool set);
72
  inline void setLaxFriedrichs(bool flag) { _laxFriedrichs = flag;}
Valentin Vallaeys's avatar
Valentin Vallaeys committed
73
74
  virtual bool isLinear() const {return _linear;}// {return (_linear || _linearIMEX);}
  virtual bool isConstantJac() const {return _constantJac;} // {return (_constantJac || _constantJacIMEX);}
75
  void setDensity(double density) {_density = density;}
lambrechts's avatar
lambrechts committed
76
  /**set the function to evaluate the coriolis factor \f{eqnarray*} \frac{du}{dt} &= &-f v \\ \frac{dv}{dt} &=& f u\f} */
77
  inline void setCoriolisFactor(const functor *coriolisFactor) { _coriolisFactor = coriolisFactor;}
David Vincent's avatar
David Vincent committed
78
79
  /*set the gravity as a functor */
  inline void setGravity(const functor *gravityF) { _g = gravityF;}
lambrechts's avatar
lambrechts committed
80
  /**set the function to evaluate the linear dissipation \f{eqnarray*}\frac{du}{dt} &=& -\gamma u\\ \frac {dv}{dt} &=& -\gamma v \f}*/
81
  inline void setLinearDissipation(const functor *linearDissipation) { _linearDissipation = linearDissipation;}
lambrechts's avatar
lambrechts committed
82
  /**set the function to evaluate the quadratic dissipation \f{eqnarray*}\frac{du}{dt} &=& -c_d u||u||\\ \frac{dv}{dt}&= &-c_d v \f}*/
83
  inline void setQuadraticDissipation(const functor *quadraticDissipation) { _quadraticDissipation = quadraticDissipation;}
lambrechts's avatar
lambrechts committed
84
  /**set the function to evaluate the source term \f{eqnarray*}\frac{du}{dt} &=& s(0)\\ \frac{dv}{dt} &=& s(1)\f} */
85
  inline void setSource(const functor *source) { _source = source;}
86
87
  /**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
88
  /**set the function to evaluate the bathymetry h (H = h+eta) */
Valentin Vallaeys's avatar
Valentin Vallaeys committed
89
  inline void setBathymetry(const functor *bathymetry) { _bathymetry= bathymetry; }
lambrechts's avatar
lambrechts committed
90
  /**set the function to evaluate the gradient of the bathymetry: grad(h) */
91
  inline void setBathymetryGradient(functor *bathymetryGradient) { _bathymetryGradient = bathymetryGradient;}
lambrechts's avatar
lambrechts committed
92
  /**set the function to evaluate the diffusion term */
93
  inline void setDiffusivity(const functor *nuFunction) { _nu = nuFunction;}
94
95
96
  /**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
97
98
99
100
  void setNudgingVelocity(const functor *nudgingVel, bool transport=false){
    _nudgingVel = nudgingVel;
    _nudgingVelIsTransport = transport;
  }
lambrechts's avatar
lambrechts committed
101
  /**use the moving bath WD (Karna et al, 2011) and define the bathymetry and the moving bathymetry */
102
  void setMovingBathWettingDrying(const functor *hydro, const functor *hydroGradient, double alphaMovingBathWD);
lambrechts's avatar
lambrechts committed
103
104
105
106
  /** a factor to smooth the if in Hv term in the roe riemann solver */
  inline void setUpwindFactorRiemann(double upwindFactorRiemann) {
    _upwindFactorRiemann=upwindFactorRiemann;
  }
Valentin Vallaeys's avatar
Valentin Vallaeys committed
107
  /** Functions for 3D external mode*/
Valentin Vallaeys's avatar
Valentin Vallaeys committed
108
109
110
111
112
  inline void setRhoSurf(const functor *f) { _rhoSurf = f;}
  inline void setRhoSurfGrad(const functor *f) { _rhoSurfGrad = f;}
  inline void setEtaOld(const functor *f) { _etaOld = f;}
  /**set the function to evaluate the atmospheric pressure */
  inline void setAtmPress(const functor *f) { _atmPress = f;}
lambrechts's avatar
lambrechts committed
113
  
114
  inline const functor *getDepth() {
lambrechts's avatar
lambrechts committed
115
116
    return functionSumNew(_bathymetry,functionExtractCompNew(function::getSolution(),0));
  }
117
  inline const functor *getBathymetry() {
118
    return _bathymetry;
lambrechts's avatar
lambrechts committed
119
  }
120
121
122
  inline const functor *getBathymetryGradient() {
    return _bathymetryGradient;
  }
123
  inline const functor *getElevation() {
lambrechts's avatar
lambrechts committed
124
125
    return functionExtractCompNew(function::getSolution(),0);
  }
126
  inline const functor *getVelocity() {
lambrechts's avatar
lambrechts committed
127
128
129
130
131
132
133
134
    std::vector<int> comp;
    comp.push_back(1), comp.push_back(2);
    return functionExtractCompNew(function::getSolution(),comp);
  }
  
  // Boundary conditions
  
  /**slip wall boundary */
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
135
  dgBoundaryCondition *newBoundaryWall(double slip_factor = 0);
136
  dgBoundaryCondition *newForcedDischarge(dgDofContainer *solution, const functor *discharge, std::string tag);
137
  //dgBoundaryCondition *newBoundaryCouplingSW1D(const functor *solExtF);
lambrechts's avatar
lambrechts committed
138
};
139
140
141
142
143
/*==============================================================================
 * IP Term
 *============================================================================*/

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