forked from PrincetonUniversity/athena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09.shallow_water.patch
80 lines (75 loc) · 3.36 KB
/
09.shallow_water.patch
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
diff --git a/src/hydro/srcterms/hydro_srcterms.cpp b/src/hydro/srcterms/hydro_srcterms.cpp
index 7212f434..f69b30f7 100644
--- a/src/hydro/srcterms/hydro_srcterms.cpp
+++ b/src/hydro/srcterms/hydro_srcterms.cpp
@@ -106,6 +106,10 @@ HydroSourceTerms::HydroSourceTerms(Hydro *phyd, ParameterInput *pin) {
if (SELF_GRAVITY_ENABLED) hydro_sourceterms_defined = true;
+ multi_layer_coupling_ = pin->GetOrAddBoolean("hydro",
+ "multi_layer_coupling", false);
+ if (multi_layer_coupling_) hydro_sourceterms_defined = true;
+
UserSourceTerm = phyd->pmy_block->pmy_mesh->UserSourceTerm_;
if (UserSourceTerm != nullptr) hydro_sourceterms_defined = true;
}
@@ -145,6 +149,8 @@ void HydroSourceTerms::AddSourceTerms(const Real time, const Real dt,
RotatingSystemSourceTerms(dt, flux, prim, cons);
// MyNewSourceTerms()
+ if (multi_layer_coupling_)
+ MultiLayerCoupling(dt, flux, prim, cons);
// user-defined source terms
if (UserSourceTerm != nullptr) {
diff --git a/src/hydro/srcterms/hydro_srcterms.hpp b/src/hydro/srcterms/hydro_srcterms.hpp
index caa39eab..39647484 100644
--- a/src/hydro/srcterms/hydro_srcterms.hpp
+++ b/src/hydro/srcterms/hydro_srcterms.hpp
@@ -62,6 +62,9 @@ class HydroSourceTerms {
void EnrollSrcTermFunction(SrcTermFunc my_func);
SrcTermFunc UserSourceTerm;
+ void MultiLayerCoupling(const Real dt,const AthenaArray<Real> *flx,
+ const AthenaArray<Real> &prim, AthenaArray<Real> &cons);
+
private:
Hydro *pmy_hydro_; // ptr to Hydro containing this HydroSourceTerms
Real gm_; // GM for point mass MUST BE LOCATED AT ORIGIN
@@ -70,5 +73,6 @@ class HydroSourceTerms {
int ShBoxCoord_; // ShearCoordinate type: 1=xy (default), 2=xz
bool flag_point_mass_; // flag for calling PointMass function
int flag_shearing_source_; // 1=orbital advection, 2=shearing box, 3=rotating system
+ bool multi_layer_coupling_; // flag for activate multi-layer coupling
};
#endif // HYDRO_SRCTERMS_HYDRO_SRCTERMS_HPP_
diff --git a/src/hydro/srcterms/multi_layer_coupling.cpp b/src/hydro/srcterms/multi_layer_coupling.cpp
new file mode 100644
index 00000000..28d7d336
--- /dev/null
+++ b/src/hydro/srcterms/multi_layer_coupling.cpp
@@ -0,0 +1,29 @@
+#include "../../athena.hpp"
+#include "../../mesh/mesh.hpp"
+#include "../../coordinates/coordinates.hpp"
+#include "../hydro.hpp"
+#include "hydro_srcterms.hpp"
+
+void HydroSourceTerms::MultiLayerCoupling(const Real dt,const AthenaArray<Real> *flx,
+ const AthenaArray<Real> &prim, AthenaArray<Real> &cons)
+{
+ MeshBlock *pmb = pmy_hydro_->pmy_block;
+ Coordinates *pcoord = pmb->pcoord;
+
+ for (int k = pmb->ks; k <= pmb->ke; ++k)
+ for (int j = pmb->js; j <= pmb->je; ++j) {
+ int i1 = pmb->is, i2 = pmb->is+1;
+ Real delta = pcoord->dx1f(i2)/pcoord->dx1f(i1);
+ cons(IM2,k,j,i1) += - dt*delta*prim(IDN,k,j,i1)*
+ (prim(IDN,k,j+1,i2) - prim(IDN,k,j-1,i2))/(pcoord->x2v(j+1) - pcoord->x2v(j-1));
+ cons(IM3,k,j,i1) += - dt*delta*prim(IDN,k,j,i1)*
+ (prim(IDN,k+1,j,i2) - prim(IDN,k-1,j,i2))/(pcoord->x3v(k+1) - pcoord->x3v(k-1));
+
+ cons(IM2,k,j,i2) += - dt*prim(IDN,k,j,i2)*
+ (prim(IDN,k,j+1,i1) - prim(IDN,k,j-1,i1))/(pcoord->x2v(j+1) - pcoord->x2v(j-1));
+ cons(IM3,k,j,i2) += - dt*prim(IDN,k,j,i2)*
+ (prim(IDN,k+1,j,i1) - prim(IDN,k-1,j,i1))/(pcoord->x3v(k+1) - pcoord->x3v(k-1));
+ }
+
+ return;
+}