Canoe
Comprehensive Atmosphere N' Ocean Engine
apply_boundary_condition.cpp
Go to the documentation of this file.
1 // athena
2 #include <athena/coordinates/coordinates.hpp>
3 #include <athena/hydro/hydro.hpp>
4 #include <athena/mesh/mesh.hpp>
5 // canoe
6 #include "decomposition.hpp"
7 
9  AthenaArray<Real> &psf, int kl, int ku,
10  int jl, int ju) {
11  MeshBlock *pmb = pmy_block_;
12  Coordinates *pco = pmb->pcoord;
13  Real grav = -pmb->phydro->hsrc.GetG1(); // positive downward pointing
14  int is = pmb->is, ie = pmb->ie;
15 
16  if (pmb->pbval->block_bcs[inner_x1] == BoundaryFlag::reflect) {
17  for (int k = kl; k <= ku; ++k)
18  for (int j = jl; j <= ju; ++j)
19  for (int i = 1; i <= NGHOST; ++i) {
20  psf(k, j, is - i) = psf(k, j, is + i);
21  w(IPR, k, j, is - i) = w(IPR, k, j, is + i - 1);
22  w(IDN, k, j, is - i) = -w(IDN, k, j, is + i - 1);
23  }
24  } else if (pmb->pbval->block_bcs[inner_x1] == BoundaryFlag::outflow) {
25  for (int k = kl; k <= ku; ++k)
26  for (int j = jl; j <= ju; ++j)
27  for (int i = 1; i <= NGHOST; ++i) {
28  psf(k, j, is - i) = psf(k, j, is - i + 1) +
29  grav * w(IDN, k, j, is - i) * pco->dx1f(is - i);
30  w(IPR, k, j, is - i) = w(IPR, k, j, is);
31  w(IDN, k, j, is - i) = 0.;
32  }
33  }
34 
35  if (pmb->pbval->block_bcs[outer_x1] == BoundaryFlag::reflect) {
36  for (int k = kl; k <= ku; ++k)
37  for (int j = jl; j <= ju; ++j)
38  for (int i = 1; i <= NGHOST; ++i) {
39  psf(k, j, ie + i + 1) = psf(k, j, ie - i);
40  w(IPR, k, j, ie + i) = w(IPR, k, j, ie - i + 1);
41  w(IDN, k, j, ie + i) = -w(IDN, k, j, ie - i + 1);
42  }
43  } else if (pmb->pbval->block_bcs[outer_x1] == BoundaryFlag::outflow) {
44  for (int k = kl; k <= ku; ++k)
45  for (int j = jl; j <= ju; ++j)
46  for (int i = 1; i <= NGHOST; ++i) {
47  psf(k, j, ie + i + 1) = psf(k, j, ie + i) - grav *
48  w(IDN, k, j, ie + i) *
49  pco->dx1f(ie + i);
50  w(IPR, k, j, ie + i) = w(IPR, k, j, ie);
51  w(IDN, k, j, ie + i) = 0.;
52  }
53  }
54 }
55 
56 /*void Decomposition::UpdateBoundaryCondition(AthenaArray<Real> &w,
57  AthenaArray<Real> const& psf, int kl, int ku, int jl, int ju)
58 {
59  MeshBlock *pmb = pmy_hydro->pmy_block;
60  Coordinates *pco = pmb->pcoord;
61  Real grav = -pmy_hydro->hsrc.GetG1(); // positive downward pointing
62 
63  if (pmb->pbval->block_bcs[inner_x1] == BoundaryFlag::reflect) {
64  for (int k = kl; k <= ku; ++k)
65  for (int j = jl; j <= ju; ++j)
66  for (int i = 1; i <= NGHOST; ++i) {
67  w(IPR,k,j,is-i) = w(IPR,k,j,is+i-1);
68  w(IDN,k,j,is-i) = w(IDN,k,j,is+i-1);
69  }
70  } else if (pmb->pbval->block_bcs[inner_x1] == BoundaryFlag::outflow) {
71  for (int k = kl; k <= ku; ++k)
72  for (int j = jl; j <= ju; ++j)
73  for (int i = 1; i <= NGHOST; ++i) {
74  Real psv = (psf_(k,j,i) -
75 psf_(k,j,i+1))/log(psf_(k,j,i)/psf_(k,j,i+1)); w(IPR,k,j,is-i) += psv;
76  w(IDN,k,j,is-i) = (psf_(k,j,is-i) -
77 psf_(k,j,is-i+1))/(pco->dx1f(is-i)*grav);
78  }
79  }
80 
81  if (pmb->pbval->block_bcs[outer_x1] == BoundaryFlag::reflect) {
82  for (int k = kl; k <= ku; ++k)
83  for (int j = jl; j <= ju; ++j)
84  for (int i = 1; i <= NGHOST; ++i) {
85  w(IPR,k,j,ie+i) = w(IPR,k,j,ie-i+1);
86  w(IDN,k,j,ie+i) = w(IDN,k,j,ie-i+1);
87  }
88  } else if (pmb->pbval->block_bcs[outer_x1] == BoundaryFlag::outflow) {
89  for (int k = kl; k <= ku; ++k)
90  for (int j = jl; j <= ju; ++j)
91  for (int i = 1; i <= NGHOST; ++i) {
92  Real psv = (psf_(k,j,ie+i) -
93 psf_(k,j,ie+i+1))/log(psf_(k,j,ie+i)/psf_(k,j,ie+i+1)); w(IPR,k,j,ie+i) += psv;
94  w(IDN,k,j,ie+i) = (psf_(k,j,ie+i) -
95 psf_(k,j,ie+i+1))/(pco->dx1f(ie+i)*grav);
96  }
97  }
98 }*/
MeshBlock * pmy_block_
void ApplyHydroBoundary(AthenaArray< Real > &w, AthenaArray< Real > &psf, int kl, int ku, int jl, int ju)