Skip to content

Commit e14cb25

Browse files
authored
Merge pull request #451 from pdziekan/rigid_zero_sgs_flux
rigid bcond: add zero-sgs-flux condition
2 parents 9ae9a49 + 7d34a0a commit e14cb25

File tree

5 files changed

+148
-99
lines changed

5 files changed

+148
-99
lines changed

.travis.yml

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,41 @@ cache:
5454
- ${TRAVIS_BUILD_DIR}/deps/hdf5
5555
- /home/travis/.rvm/ # following Travis cache documentation: try to cache installed ruby on osx
5656

57-
matrix:
57+
# define the precache stage
58+
# empty phases mean that default phases (before_install, install, ...) from the test stage are used (?)
59+
# TODO: precache stage has a lot of unnecessary before_install and install code common to the (default) test stage;
60+
# add after_success, after_failure to precache, remove building of caches from the test stage, make the build error instead;
61+
62+
# YAML alias for the options common to precache jobs
63+
aliases:
64+
- &precache_default
65+
stage: precache
66+
# os: linux
67+
# dist: xenial
68+
# language: cpp
69+
# compiler: gcc
70+
install:
71+
- . ./.travis_scripts/install_common.sh
72+
script: echo "Preparing cache finished"
73+
74+
jobs:
75+
include:
76+
- <<: *precache_default
77+
env: TEST_SUITE=unit MPI=mvapich2
78+
- <<: *precache_default
79+
env: TEST_SUITE=sandbox MPI=mvapich2
80+
- <<: *precache_default
81+
env: TEST_SUITE=paper MPI=mvapich2
82+
- <<: *precache_default
83+
env: TEST_SUITE=elliptic_drop MPI=mvapich2
84+
- <<: *precache_default
85+
env: TEST_SUITE=nair_jablonowski_2008 MPI=mvapich2
86+
- <<: *precache_default
87+
env: TEST_SUITE=pbl MPI=mvapich2
88+
- <<: *precache_default
89+
env: TEST_SUITE=bconds_div MPI=mvapich2
90+
91+
# excluded jobs
5892
exclude:
5993
# MPI with clang disabled due to difficulties with building boost with clang
6094
- compiler: clang
@@ -121,7 +155,11 @@ before_install:
121155
# Seems like this is now done by Travis, but leaving it (commented out) for now
122156
#- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew cask uninstall oclint; fi
123157

124-
- sudo wget -O /usr/local/include/gnuplot-iostream.h https://raw.githubusercontent.com/dstahlke/gnuplot-iostream/master/gnuplot-iostream.h
158+
# gnuplot-iostream
159+
- git clone -n https://github.com/dstahlke/gnuplot-iostream && cd gnuplot-iostream
160+
- git checkout 8b6e30c6ea5ee4f07ccf90d858d35a10cf67a3e2 # later commits require c++17
161+
- sudo cp gnuplot-iostream.h /usr/local/include/gnuplot-iostream.h
162+
- cd ..
125163

126164
# needed to get rvm, see below
127165
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then \curl -sSL https://get.rvm.io | bash -s -- --branch stable; fi
@@ -159,7 +197,6 @@ install:
159197
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install hdf5-tools; fi
160198
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install hdf5; fi
161199

162-
# gnuplot-iostream
163200
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install gnuplot-nox; fi
164201
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install gnuplot; fi
165202

@@ -231,36 +268,4 @@ script:
231268
# testing local clang on osx
232269
- if [[ $TEST_SUITE == 'osx_local_clang' ]]; then . ./.travis_scripts/unit.sh; fi # with '.' to pass env vars
233270

234-
# define the precache stage
235-
# empty phases mean that default phases (before_install, install, ...) from the test stage are used (?)
236-
# TODO: precache stage has a lot of unnecessary before_install and install code common to the (default) test stage;
237-
# add after_success, after_failure to precache, remove building of caches from the test stage, make the build error instead;
238-
239-
# YAML alias for the options common to precache jobs
240-
job_info: &precache_default
241-
stage: precache
242-
os: linux
243-
dist: xenial
244-
language: cpp
245-
compiler: gcc
246-
install:
247-
- . ./.travis_scripts/install_common.sh
248-
script: echo "Preparing cache finished"
249-
250-
jobs:
251-
include:
252-
- <<: *precache_default
253-
env: TEST_SUITE=unit MPI=mvapich2
254-
- <<: *precache_default
255-
env: TEST_SUITE=sandbox MPI=mvapich2
256-
- <<: *precache_default
257-
env: TEST_SUITE=paper MPI=mvapich2
258-
- <<: *precache_default
259-
env: TEST_SUITE=elliptic_drop MPI=mvapich2
260-
- <<: *precache_default
261-
env: TEST_SUITE=nair_jablonowski_2008 MPI=mvapich2
262-
- <<: *precache_default
263-
env: TEST_SUITE=pbl MPI=mvapich2
264-
- <<: *precache_default
265-
env: TEST_SUITE=bconds_div MPI=mvapich2
266271

libmpdata++/bcond/gndsky_2d.hpp

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ namespace libmpdataxx
5555
}
5656
};
5757

58-
// sky
58+
// sky is the same as rigid
5959
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
60-
class bcond< real_t, halo, knd, dir, n_dims, d,
60+
class bcond< real_t, halo, knd, dir, n_dims, d,
6161
typename std::enable_if<
6262
knd == gndsky &&
6363
dir == rght &&
@@ -66,33 +66,8 @@ namespace libmpdataxx
6666
> : public bcond<real_t, halo, rigid, dir, n_dims, d>
6767
{
6868
using parent_t = bcond<real_t, halo, rigid, dir, n_dims, d>;
69-
using arr_t = blitz::Array<real_t, 2>;
7069
using parent_t::parent_t; // inheriting ctor
71-
72-
public:
73-
74-
void fill_halos_sgs_div(arr_t &a, const rng_t &j)
75-
{
76-
using namespace idxperm;
77-
a(pi<d>(this->rght_edge_sclr + h, j)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j)) - a(pi<d>(this->rght_edge_sclr - 1 - h, j));
78-
}
79-
80-
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const int offset = 0)
81-
{
82-
// fill halos for a staggered field so that it has zero value on tke sky edge
83-
// that is 0.5 * (a(sky-h) + a(sky+h)) = 0
84-
using namespace idxperm;
85-
const auto &a = av[offset + d];
86-
a(pi<d>(this->rght_edge_sclr + h, j)) = - a(pi<d>(this->rght_edge_sclr - h, j));
87-
}
88-
89-
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const real_t di)
90-
{
91-
using namespace idxperm;
92-
const auto &a = av[d];
93-
a(pi<d>(this->rght_edge_sclr + h, j)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j))
94-
- a(pi<d>(this->rght_edge_sclr - 1 - h, j));
95-
}
9670
};
71+
9772
} // namespace bcond
9873
} // namespace libmpdataxx

libmpdata++/bcond/gndsky_3d.hpp

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ namespace libmpdataxx
5656
}
5757
};
5858

59-
// sky
59+
// sky is the same as rigid
6060
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
61-
class bcond< real_t, halo, knd, dir, n_dims, d,
61+
class bcond< real_t, halo, knd, dir, n_dims, d,
6262
typename std::enable_if<
6363
knd == gndsky &&
6464
dir == rght &&
@@ -67,34 +67,8 @@ namespace libmpdataxx
6767
> : public bcond<real_t, halo, rigid, dir, n_dims, d>
6868
{
6969
using parent_t = bcond<real_t, halo, rigid, dir, n_dims, d>;
70-
using arr_t = blitz::Array<real_t, 3>;
7170
using parent_t::parent_t; // inheriting ctor
72-
73-
public:
74-
75-
void fill_halos_sgs_div(arr_t &a, const rng_t &j, const rng_t &k)
76-
{
77-
using namespace idxperm;
78-
a(pi<d>(this->rght_edge_sclr + h, j, k)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j, k))
79-
- a(pi<d>(this->rght_edge_sclr - 1 - h, j, k));
80-
}
81-
82-
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const rng_t &k, const int offset = 0)
83-
{
84-
// fill halos for a staggered field so that it has zero value on tke sky edge
85-
// that is 0.5 * (a(sky-h) + a(sky+h)) = 0
86-
using namespace idxperm;
87-
const auto &a = av[offset + d];
88-
a(pi<d>(this->rght_edge_sclr + h, j, k)) = - a(pi<d>(this->rght_edge_sclr - h, j, k));
89-
}
90-
91-
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const rng_t &k, const real_t di)
92-
{
93-
using namespace idxperm;
94-
const auto &a = av[d];
95-
a(pi<d>(this->rght_edge_sclr + h, j, k)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j, k))
96-
- a(pi<d>(this->rght_edge_sclr - 1 - h, j, k));
97-
}
9871
};
72+
9973
} // namespace bcond
10074
} // namespace libmpdataxx

libmpdata++/bcond/rigid_2d.hpp

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ namespace libmpdataxx
5757

5858
void fill_halos_vctr_alng(arrvec_t<arr_t> &av, const rng_t &j, const bool ad = false)
5959
{
60-
using namespace idxperm;
60+
using namespace idxperm;
6161
// zero velocity condition
6262
for (int i = this->left_halo_vctr.first(), n = halo; i <= this->left_halo_vctr.last() - (ad ? 1 : 0); ++i, --n)
6363
{
64-
av[d](pi<d>(i, j)) = -av[d](pi<d>(this->left_edge_sclr + n - h, j));
64+
av[d](pi<d>(i, j)) = -av[d](pi<d>(this->left_edge_sclr + n - h, j));
6565
}
6666
}
6767

@@ -74,8 +74,32 @@ namespace libmpdataxx
7474
void fill_halos_flux(arrvec_t<arr_t> &av, const rng_t &j)
7575
{
7676
using namespace idxperm;
77-
av[d](pi<d>(this->left_halo_vctr.last(), j)) = -av[d](pi<d>(this->left_edge_sclr + h, j));
77+
av[d](pi<d>(this->left_halo_vctr.last(), j)) = -av[d](pi<d>(this->left_edge_sclr + h, j));
78+
}
79+
80+
void fill_halos_sgs_div(arr_t &a, const rng_t &j)
81+
{
82+
using namespace idxperm;
83+
a(pi<d>(this->left_edge_sclr - h, j)) = 2 * a(pi<d>(this->left_edge_sclr + h, j)) - a(pi<d>(this->left_edge_sclr + 1 + h, j));
84+
}
85+
86+
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const int offset = 0)
87+
{
88+
// fill halos for a staggered field so that it has zero value on tke edge
89+
// that is 0.5 * (a(edge-h) + a(edge+h)) = 0
90+
using namespace idxperm;
91+
const auto &a = av[offset + d];
92+
a(pi<d>(this->left_edge_sclr - h, j)) = - a(pi<d>(this->left_edge_sclr + h, j));
7893
}
94+
95+
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const real_t di)
96+
{
97+
using namespace idxperm;
98+
const auto &a = av[d];
99+
a(pi<d>(this->left_edge_sclr - h, j)) = 2 * a(pi<d>(this->left_edge_sclr + h, j))
100+
- a(pi<d>(this->left_edge_sclr + 1 + h, j));
101+
}
102+
79103
};
80104

81105
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
@@ -124,11 +148,11 @@ namespace libmpdataxx
124148

125149
void fill_halos_vctr_alng(arrvec_t<arr_t> &av, const rng_t &j, const bool ad = false)
126150
{
127-
using namespace idxperm;
151+
using namespace idxperm;
128152
// zero velocity condition
129153
for (int i = this->rght_halo_vctr.first() + (ad ? 1 : 0), n = 1; i <= this->rght_halo_vctr.last(); ++i, ++n)
130154
{
131-
av[d](pi<d>(i, j)) = -av[d](pi<d>(this->rght_edge_sclr - n + h, j));
155+
av[d](pi<d>(i, j)) = -av[d](pi<d>(this->rght_edge_sclr - n + h, j));
132156
}
133157
}
134158

@@ -140,9 +164,32 @@ namespace libmpdataxx
140164

141165
void fill_halos_flux(arrvec_t<arr_t> &av, const rng_t &j)
142166
{
143-
using namespace idxperm;
167+
using namespace idxperm;
144168
// zero flux condition
145-
av[d](pi<d>(this->rght_halo_vctr.first(), j)) = -av[d](pi<d>(this->rght_edge_sclr - h, j));
169+
av[d](pi<d>(this->rght_halo_vctr.first(), j)) = -av[d](pi<d>(this->rght_edge_sclr - h, j));
170+
}
171+
172+
void fill_halos_sgs_div(arr_t &a, const rng_t &j)
173+
{
174+
using namespace idxperm;
175+
a(pi<d>(this->rght_edge_sclr + h, j)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j)) - a(pi<d>(this->rght_edge_sclr - 1 - h, j));
176+
}
177+
178+
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const int offset = 0)
179+
{
180+
// fill halos for a staggered field so that it has zero value on tke edge
181+
// that is 0.5 * (a(edge-h) + a(edge+h)) = 0
182+
using namespace idxperm;
183+
const auto &a = av[offset + d];
184+
a(pi<d>(this->rght_edge_sclr + h, j)) = - a(pi<d>(this->rght_edge_sclr - h, j));
185+
}
186+
187+
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const real_t di)
188+
{
189+
using namespace idxperm;
190+
const auto &a = av[d];
191+
a(pi<d>(this->rght_edge_sclr + h, j)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j))
192+
- a(pi<d>(this->rght_edge_sclr - 1 - h, j));
146193
}
147194
};
148195
} // namespace bcond

libmpdata++/bcond/rigid_3d.hpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ namespace libmpdataxx
7777
// zero flux condition
7878
av[d](pi<d>(this->left_halo_vctr.last(), j, k)) = -av[d](pi<d>(this->left_edge_sclr + h, j, k));
7979
}
80+
81+
void fill_halos_sgs_div(arr_t &a, const rng_t &j, const rng_t &k)
82+
{
83+
using namespace idxperm;
84+
a(pi<d>(this->left_edge_sclr - h, j, k)) = 2 * a(pi<d>(this->left_edge_sclr + h, j, k))
85+
- a(pi<d>(this->left_edge_sclr + 1 + h, j, k));
86+
}
87+
88+
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const rng_t &k, const int offset = 0)
89+
{
90+
// fill halos for a staggered field so that it has zero value on the edge
91+
// that is 0.5 * (a(edge-h) + a(edge+h)) = 0
92+
using namespace idxperm;
93+
const auto &a = av[offset + d];
94+
a(pi<d>(this->left_edge_sclr - h, j, k)) = - a(pi<d>(this->left_edge_sclr + h, j, k));
95+
}
96+
97+
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const rng_t &k, const real_t di)
98+
{
99+
using namespace idxperm;
100+
const auto &a = av[d];
101+
a(pi<d>(this->left_edge_sclr - h, j, k)) = 2 * a(pi<d>(this->left_edge_sclr + h, j, k))
102+
- a(pi<d>(this->left_edge_sclr + 1 + h, j, k));
103+
}
80104
};
81105

82106
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
@@ -146,6 +170,30 @@ namespace libmpdataxx
146170
// zero flux condition
147171
av[d](pi<d>(this->rght_halo_vctr.first(), j, k)) = -av[d](pi<d>(this->rght_edge_sclr - h, j, k));
148172
}
173+
174+
void fill_halos_sgs_div(arr_t &a, const rng_t &j, const rng_t &k)
175+
{
176+
using namespace idxperm;
177+
a(pi<d>(this->rght_edge_sclr + h, j, k)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j, k))
178+
- a(pi<d>(this->rght_edge_sclr - 1 - h, j, k));
179+
}
180+
181+
void fill_halos_sgs_vctr(arrvec_t<arr_t> &av, const arr_t &, const rng_t &j, const rng_t &k, const int offset = 0)
182+
{
183+
// fill halos for a staggered field so that it has zero value on tke edge
184+
// that is 0.5 * (a(edge-h) + a(edge+h)) = 0
185+
using namespace idxperm;
186+
const auto &a = av[offset + d];
187+
a(pi<d>(this->rght_edge_sclr + h, j, k)) = - a(pi<d>(this->rght_edge_sclr - h, j, k));
188+
}
189+
190+
void fill_halos_sgs_tnsr(arrvec_t<arr_t> &av, const arr_t &, const arr_t &, const rng_t &j, const rng_t &k, const real_t di)
191+
{
192+
using namespace idxperm;
193+
const auto &a = av[d];
194+
a(pi<d>(this->rght_edge_sclr + h, j, k)) = 2 * a(pi<d>(this->rght_edge_sclr - h, j, k))
195+
- a(pi<d>(this->rght_edge_sclr - 1 - h, j, k));
196+
}
149197
};
150198
} // namespace bcond
151199
} // namespace libmpdataxx

0 commit comments

Comments
 (0)