Skip to content

Commit

Permalink
Merge pull request #424 from mwarusz/impl_tht_abs_fix
Browse files Browse the repository at this point in the history
fix trapezoidal integration of theta absorber in implicit boussinesq solver
  • Loading branch information
mwarusz authored Nov 6, 2018
2 parents 88e6583 + dd61503 commit ec5c801
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 15 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ addons:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0

osx_image: xcode8

before_install:
# define a compiler variable for use in if statements
- if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then export COMPILER=clang++; fi
Expand All @@ -48,6 +46,12 @@ before_install:
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get update; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then export apt_get_install="apt-get install --no-install-recommends -t trusty -y"; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update; fi

# Workaround for upgrading gcc, see https://github.com/travis-ci/travis-ci/issues/8826
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew cask uninstall oclint; fi

# https://github.com/travis-ci/travis-ci/issues/10165
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then rvm get stable; fi

# fixing broken OSX gzip tools
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then export PATH=/usr/local/bin:$PATH; fi # so that brew-installed ones are first
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/UWLCM.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex

# install libmpata++
cd libmpdata++/build
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/elliptic_drop.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
# installing
cd libmpdata++/build
sudo make install
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/nair_jablonowski_2008.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
cd tests/nair_jablonowski_2008
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/paper.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
cd tests/paper_2015_GMD
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/pbl.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
cd tests/sandbox
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/sandbox.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
cd tests/sandbox
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion .travis_scripts/unit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
set -e
set -ex
cd tests/unit
mkdir build
cd build
Expand Down
13 changes: 8 additions & 5 deletions libmpdata++/solvers/detail/boussinesq_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ namespace libmpdataxx
}
case (1):
{
rhs.at(ix::tht)(ijk) += (this->hflux_frc(ijk) - this->tht_abs(ijk) * tht(ijk))
/ (1 + 0.5 * this->dt * this->tht_abs(ijk));
rhs.at(ix::tht)(ijk) += this->hflux_frc(ijk);

rhs.at(ix_w)(ijk) += this->g * (tht(ijk) + 0.5 * this->dt * rhs.at(ix::tht)(ijk)) / this->Tht_ref;
rhs.at(ix_w)(ijk) += this->g * (tht(ijk) + 0.5 * this->dt * rhs.at(ix::tht)(ijk))
/ (this->Tht_ref * (1 + 0.5 * this->dt * this->tht_abs(ijk)));
break;
}
}
Expand All @@ -116,8 +116,11 @@ namespace libmpdataxx
parent_t::vip_rhs_impl_fnlz();

const auto &w = this->vips()[ct_params_t::n_dims - 1];
this->state(ix::tht)(this->ijk) += - 0.5 * this->dt * w(this->ijk) * this->dtht_e(this->ijk);
this->rhs.at(ix::tht)(this->ijk) += -w(this->ijk) * this->dtht_e(this->ijk);
this->state(ix::tht)(this->ijk) = ( this->state(ix::tht)(this->ijk)
- 0.5 * this->dt * w(this->ijk) * this->dtht_e(this->ijk))
/ (1 + 0.5 * this->dt * this->tht_abs(this->ijk));
this->rhs.at(ix::tht)(this->ijk) += -w(this->ijk) * this->dtht_e(this->ijk)
-this->tht_abs(this->ijk) * this->state(ix::tht)(this->ijk);
}

public:
Expand Down
10 changes: 10 additions & 0 deletions libmpdata++/solvers/detail/solver_3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ namespace libmpdataxx
if (!cyclic)
{
for (auto &bc : this->bcs[1]) bc->fill_halos_vctr_nrml(arrvec[0], range_ijk[2]^ext^1, range_ijk[0]^ext^h);

// without this barrier, there is a race condition when some threads handle subdomains
// with one gridpoint width, the problem manifests itself, for example, in pbl test
// TODO: figure out the exact cause and try to avoid this barrier, what about 2D,
// what about atypical boundary condition choices -- rigid/cyclic/rigid etc
if (parent_t::div3_mpdata)
{
this->mem->barrier();
}

for (auto &bc : this->bcs[2]) bc->fill_halos_vctr_nrml(arrvec[0], range_ijk_0__ext_h, range_ijk[1]^ext^1);

for (auto &bc : this->bcs[0]) bc->fill_halos_vctr_nrml(arrvec[1], range_ijk[1]^ext^h, range_ijk[2]^ext^1);
Expand Down
2 changes: 1 addition & 1 deletion tests/sandbox/pbl/budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
outname = dirname[4:]
outfile = open('budget_' + outname + '.txt', 'w')
for lev_d in zip(Z, hflux, tke_t, dssp, inb):
outfile.write('{:6.2f} {:10.3e} {:10.3e} {:10.3e} {:10.1e}\n'.format(*lev_d))
outfile.write('{:6.2f} {:10.1e} {:10.1e} {:10.1e} {:10.1e}\n'.format(*lev_d))

fig, axarr = plt.subplots(1, 1, figsize= (10, 6))
axarr.plot(hflux, Z, 'k-', lw = 1, label = 'B')
Expand Down
Binary file modified tests/sandbox/pbl/refdata/budget_pbl_iles_travis.txt.gz
Binary file not shown.
Binary file modified tests/sandbox/pbl/refdata/budget_pbl_smg_travis.txt.gz
Binary file not shown.
Binary file not shown.
Binary file modified tests/sandbox/pbl/refdata/out_pbl_smg_travis/timestep0000000600.h5
Binary file not shown.
Binary file modified tests/sandbox/pbl/refdata/profiles_pbl_iles_travis.txt.gz
Binary file not shown.
Binary file modified tests/sandbox/pbl/refdata/profiles_pbl_smg_travis.txt.gz
Binary file not shown.

0 comments on commit ec5c801

Please sign in to comment.