Skip to content

Commit 33f9a7f

Browse files
authored
Merge pull request #457 from pdziekan/avg_edge_sclr
bcond: Avg edge sclr
2 parents 990778f + fba22e3 commit 33f9a7f

File tree

13 files changed

+303
-88
lines changed

13 files changed

+303
-88
lines changed

.travis.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ env:
4848
# - TEST_SUITE=UWLCM MPI=mvapich2
4949

5050
cache:
51+
packages: true
52+
pip: true
5153
directories:
5254
- ${TRAVIS_BUILD_DIR}/deps/mvapich2-2.3b
5355
- ${TRAVIS_BUILD_DIR}/deps/boost
@@ -63,12 +65,8 @@ cache:
6365
aliases:
6466
- &precache_default
6567
stage: precache
66-
# os: linux
67-
# dist: xenial
68-
# language: cpp
69-
# compiler: gcc
7068
install:
71-
- . ./.travis_scripts/install_common.sh
69+
- . ./.travis_scripts/deps_install/install_common.sh
7270
script: echo "Preparing cache finished"
7371

7472
jobs:
@@ -140,20 +138,7 @@ before_install:
140138
- if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then export COMPILER=clang++; fi
141139
- if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'g++' ]]; then export COMPILER=g++; fi
142140
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then export COMPILER=clang++; fi # only clang on osx
143-
144-
# to avoid python lib/interpreter mismatch; https://github.com/travis-ci/travis-ci/issues/5326
145-
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g"); fi
146-
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty main universe multiverse"; fi
147-
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get update; fi
148141
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then export apt_get_install="apt-get install --no-install-recommends -t xenial -y"; fi
149-
# - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update; fi
150-
151-
# - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew tap homebrew/science; fi
152-
# - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then rvm get stable; fi #see https://github.com/travis-ci/travis-ci/issues/6307
153-
154-
# Workaround for upgrading gcc, see https://github.com/travis-ci/travis-ci/issues/8826
155-
# Seems like this is now done by Travis, but leaving it (commented out) for now
156-
#- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew cask uninstall oclint; fi
157142

158143
# gnuplot-iostream
159144
- git clone -n https://github.com/dstahlke/gnuplot-iostream && cd gnuplot-iostream
@@ -183,18 +168,13 @@ before_install:
183168
# testing Python 3 on Linux
184169
- export PY3DEB=""
185170
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then PY3DEB=3; fi
186-
# - PY3DEB=3 # had problems with building h5py using python3-pip
187-
# - if [[ $PY3DEB != '' ]]; then sudo apt-get install python3-dev; fi
188171

189172
# upgrade pip
190-
#- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo pip install --upgrade pip; fi
191173
- sudo pip$PY3DEB install --upgrade pip
192174

193175
install:
194-
- . ./.travis_scripts/install_common.sh
176+
- . ./.travis_scripts/deps_install/install_common.sh
195177

196-
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" libpango-1.0-0 libpangocairo-1.0-0 libhdf5-dev; fi
197-
# - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install hdf5-tools; fi
198178
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install hdf5; fi
199179

200180
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install gnuplot-nox; fi

.travis_scripts/UWLCM.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ cd libmpdata++/build
1111
sudo make install
1212
cd ../..
1313

14-
# making Python 2 back the default if needed - TODO: support Python3 in libcloudph++
15-
if [[ $PY3DEB != '' ]]; then sudo update-alternatives --remove python /usr/bin/python3; fi
16-
if [[ $PY3DEB != '' ]]; then sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 10; fi
17-
18-
# libcloudph++'s dependencies
19-
#if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install libboost-python1.55-dev python-numpy; fi
20-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install python-numpy; fi
21-
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install boost-python; fi
22-
23-
# odeint
24-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then git clone --depth=1 https://github.com/boostorg/odeint.git; fi # get boost odeint > 1.58
25-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo rm -f /usr/include/boost/numeric/odeint.hpp; fi
26-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo rm -rf /usr/include/boost/numeric/odeint; fi
27-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo ln -s `pwd`/odeint/include/boost/numeric/odeint.hpp /usr/include/boost/numeric/odeint.hpp; fi
28-
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo ln -s `pwd`/odeint/include/boost/numeric/odeint /usr/include/boost/numeric/; fi
29-
3014
# newest thrust
3115
git clone --depth=1 git://github.com/thrust/thrust.git;
3216
sudo ln -s `pwd`/thrust/thrust /usr/local/include/thrust;

.travis_scripts/install_common.sh renamed to .travis_scripts/deps_install/install_common.sh

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ if [[ $TRAVIS_OS_NAME == 'linux' && $COMPILER == 'g++' ]]; then export CXX=g
1818
# downloads and setups local clang on osx
1919
if [[ $TEST_SUITE == 'osx_local_clang' ]]; then . ./.travis_scripts/setup_local_clang.sh; fi
2020

21-
#<<<<<<< HEAD
22-
# add a definition -DBOOST_HAS_INT128=1 to clang calls on linux to avoid errors with boost.atomic (https://svn.boost.org/trac/boost/ticket/9610)
23-
# if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then mkdir /tmp/bin; fi
24-
# if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then printf "#!/bin/sh\nexec /usr/bin/clang++ -DBOOST_HAS_INT128=1 \"\$@\"" > /tmp/bin/clang++; fi
25-
# if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then chmod +x /tmp/bin/clang++; fi
26-
# if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then sudo ln -sf /tmp/bin/clang++ /usr/bin/clang++; fi
27-
# put /usr/bin first to use clang++-3.5 instead of the default 3.4
28-
#if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then export PATH=/usr/bin:$PATH; fi
29-
3021
if [[ $TRAVIS_OS_NAME == 'linux' && $CXX == 'clang++' ]]; then export CXXFLAGS="-DBOOST_HAS_INT128=1 ${CXXFLAGS}"; fi
3122

3223
# cmake
@@ -61,47 +52,45 @@ if [[ $MPI == 'openmpi' ]]; then sudo $apt_get_install openmpi-bin libopenmpi-d
6152
if [[ $MPI != 'none' ]]; then export CXX=${DEPS_DIR}/mvapich2-2.3b/bin/mpic++ ; fi # full path, since libtool in hdf5 installation does not understand PATH set above (?)
6253
if [[ $MPI != 'none' ]]; then export CC=${DEPS_DIR}/mvapich2-2.3b/bin/mpicc ; fi
6354

64-
# boost
65-
#if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo $apt_get_install libboost-thread1.55-dev libboost-timer1.55-dev libboost-iostreams1.55-dev libboost-filesystem1.55-dev; fi
66-
#if [[ $TRAVIS_OS_NAME == 'linux' && $MPI != 'none' ]]; then sudo $apt_get_install libboost-mpi1.55-dev; fi
67-
#if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew reinstall boost --c++11; fi # ...what takes too long :(
68-
69-
# no MPI get boost from the repository
70-
if [[ $TRAVIS_OS_NAME == 'linux' && $MPI == 'none' ]]; then sudo $apt_get_install boost1.61; fi
55+
# no MPI
56+
if [[ $TRAVIS_OS_NAME == 'linux' && $MPI == 'none' ]]; then
57+
sudo $apt_get_install boost1.61
58+
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python3.so # different naming conventions for boost python with python 3
59+
fi
7160

7261
# for MPI we need boost>=1.59 with mpi support, boost installation based on https://github.com/boostorg/compute/blob/master/.travis.yml
73-
if [[ $TRAVIS_OS_NAME == 'linux' && $MPI != 'none' ]]; then
74-
ls -A ${DEPS_DIR}/boost
75-
if [[ -z "$(ls -A ${DEPS_DIR}/boost)" ]]; then
76-
wget http://sourceforge.net/projects/boost/files/boost/1.65.1/boost_1_65_1.tar.gz
77-
tar xf boost_1_65_1.tar.gz
78-
cd boost_1_65_1
79-
# configure and install
80-
if [[ $COMPILER == 'g++' ]]; then echo "using gcc : 6.2 : g++-6 ;" > $HOME/user-config.jam; fi
81-
if [[ $COMPILER == 'clang++' ]]; then echo "using clang : 5.0 : clang++-5.0 ;" > $HOME/user-config.jam; fi
82-
echo "using mpi : $CC ;" >> $HOME/user-config.jam
83-
cat $HOME/user-config.jam
84-
if [[ $COMPILER == 'g++' ]]; then
85-
./bootstrap.sh --prefix=${DEPS_DIR}/boost/ --with-libraries=serialization,mpi,thread,date_time,system,iostreams,timer,filesystem
86-
./b2 -d0 install
87-
fi
88-
if [[ $COMPILER == 'clang++' ]]; then
89-
#clang installation taken from https://gist.github.com/jimporter/10442880
90-
./bootstrap.sh --prefix=${DEPS_DIR}/boost/ --with-libraries=serialization,mpi,thread,date_time,system,iostreams,timer,filesystem --with-toolset=clang
91-
./b2 clean
92-
./b2 toolset=clang cxxflags="-std=c++14 -stdlib=libc++" linkflags="-stdlib=libc++" --prefix=${DEPS_DIR}/boost/ -j 4 stage release
93-
./b2 install toolset=clang cxxflags="-std=c++14 -stdlib=libc++" linkflags="-stdlib=libc++" --prefix=${DEPS_DIR}/boost/
94-
fi
95-
cd ..
96-
else
97-
echo "Using cached boost."
62+
if [[ $TRAVIS_OS_NAME == 'linux' && $MPI != 'none' ]]; then
63+
ls -A ${DEPS_DIR}/boost
64+
if [[ -z "$(ls -A ${DEPS_DIR}/boost)" ]]; then
65+
wget http://sourceforge.net/projects/boost/files/boost/1.65.1/boost_1_65_1.tar.gz
66+
tar xf boost_1_65_1.tar.gz
67+
cd boost_1_65_1
68+
# configure and install
69+
if [[ $COMPILER == 'g++' ]]; then echo "using gcc : 6.2 : g++-6 ;" > $HOME/user-config.jam; fi
70+
if [[ $COMPILER == 'clang++' ]]; then echo "using clang : 5.0 : clang++-5.0 ;" > $HOME/user-config.jam; fi
71+
echo "using mpi : $CC ;" >> $HOME/user-config.jam
72+
cat $HOME/user-config.jam
73+
if [[ $COMPILER == 'g++' ]]; then
74+
./bootstrap.sh --prefix=${DEPS_DIR}/boost/ --with-libraries=serialization,mpi,thread,date_time,system,iostreams,timer,filesystem
75+
./b2 -d0 install
76+
fi
77+
if [[ $COMPILER == 'clang++' ]]; then
78+
#clang installation taken from https://gist.github.com/jimporter/10442880
79+
./bootstrap.sh --prefix=${DEPS_DIR}/boost/ --with-libraries=serialization,mpi,thread,date_time,system,iostreams,timer,filesystem --with-toolset=clang
80+
./b2 clean
81+
./b2 toolset=clang cxxflags="-std=c++14 -stdlib=libc++" linkflags="-stdlib=libc++" --prefix=${DEPS_DIR}/boost/ -j 4 stage release
82+
./b2 install toolset=clang cxxflags="-std=c++14 -stdlib=libc++" linkflags="-stdlib=libc++" --prefix=${DEPS_DIR}/boost/
9883
fi
99-
export BOOST_ROOT=${DEPS_DIR}/boost
100-
export LD_LIBRARY_PATH=${DEPS_DIR}/boost/lib:${LD_LIBRARY_PATH}
101-
export LD_RUN_PATH=${DEPS_DIR}/boost/lib:${LD_RUN_PATH}
102-
export LIBRARY_PATH=${DEPS_DIR}/boost/lib:${LIBRARY_PATH}
103-
export CPATH=${DEPS_DIR}/boost/include:${CPATH}
84+
cd ..
85+
else
86+
echo "Using cached boost."
10487
fi
88+
export BOOST_ROOT=${DEPS_DIR}/boost
89+
export LD_LIBRARY_PATH=${DEPS_DIR}/boost/lib:${LD_LIBRARY_PATH}
90+
export LD_RUN_PATH=${DEPS_DIR}/boost/lib:${LD_RUN_PATH}
91+
export LIBRARY_PATH=${DEPS_DIR}/boost/lib:${LIBRARY_PATH}
92+
export CPATH=${DEPS_DIR}/boost/include:${CPATH}
93+
fi
10594

10695
# blitz
10796
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install blitz; fi

libmpdata++/bcond/cyclic_1d.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ namespace libmpdataxx
4040
{
4141
fill_halos_vctr_alng(av, ad);
4242
}
43+
44+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a)
45+
{
46+
assert(halo>=1);
47+
48+
a(this->left_halo_sclr.last()) = a(this->rght_edge_sclr);
49+
}
50+
51+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a)
52+
{
53+
assert(halo>=1);
54+
55+
a(this->left_edge_sclr) = ( a(this->left_edge_sclr) + a(this->left_halo_sclr.last()) ) / real_t(2);
56+
}
4357
};
4458

4559
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int dim>
@@ -71,6 +85,20 @@ namespace libmpdataxx
7185
{
7286
fill_halos_vctr_alng(av, ad);
7387
}
88+
89+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a)
90+
{
91+
assert(halo>=1);
92+
93+
a(this->rght_halo_sclr.first()) = a(this->left_edge_sclr);
94+
}
95+
96+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a)
97+
{
98+
assert(halo>=1);
99+
100+
a(this->rght_edge_sclr) = ( a(this->rght_edge_sclr) + a(this->rght_halo_sclr.first()) ) / real_t(2);
101+
}
74102
};
75103
} // namespace bcond
76104
} // namespace libmpdataxx

libmpdata++/bcond/cyclic_2d.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ namespace libmpdataxx
7878
{
7979
fill_halos_vctr_nrml(a, j);
8080
}
81+
82+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a, const rng_t &j)
83+
{
84+
using namespace idxperm;
85+
assert(halo>=1);
86+
87+
a(pi<d>(this->left_halo_sclr.last(), j)) = a(pi<d>(this->rght_edge_sclr, j));
88+
}
89+
90+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a, const rng_t &j)
91+
{
92+
using namespace idxperm;
93+
assert(halo>=1);
94+
95+
a(pi<d>(this->left_edge_sclr, j)) = ( a(pi<d>(this->left_edge_sclr, j)) + a(pi<d>(this->left_halo_sclr.last(), j)) ) / real_t(2);
96+
}
8197
};
8298

8399
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
@@ -147,6 +163,22 @@ namespace libmpdataxx
147163
{
148164
fill_halos_vctr_nrml(a, j);
149165
}
166+
167+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a, const rng_t &j)
168+
{
169+
using namespace idxperm;
170+
assert(halo>=1);
171+
172+
a(pi<d>(this->rght_halo_sclr.first(), j)) = a(pi<d>(this->left_edge_sclr, j));
173+
}
174+
175+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a, const rng_t &j)
176+
{
177+
using namespace idxperm;
178+
assert(halo>=1);
179+
180+
a(pi<d>(this->rght_edge_sclr, j)) = ( a(pi<d>(this->rght_edge_sclr, j)) + a(pi<d>(this->rght_halo_sclr.first(), j)) ) / real_t(2);
181+
}
150182
};
151183
} // namespace bcond
152184
} // namespace libmpdataxx

libmpdata++/bcond/cyclic_3d.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ namespace libmpdataxx
7878
{
7979
fill_halos_vctr_nrml(a, j, k);
8080
}
81+
82+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a, const rng_t &j, const rng_t &k)
83+
{
84+
using namespace idxperm;
85+
assert(halo>=1);
86+
87+
a(pi<d>(this->left_halo_sclr.last(), j, k)) = a(pi<d>(this->rght_edge_sclr, j, k));
88+
}
89+
90+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a, const rng_t &j, const rng_t &k)
91+
{
92+
using namespace idxperm;
93+
assert(halo>=1);
94+
95+
a(pi<d>(this->left_edge_sclr, j, k)) = ( a(pi<d>(this->left_edge_sclr, j, k)) + a(pi<d>(this->left_halo_sclr.last(), j, k)) ) / real_t(2);
96+
}
8197
};
8298

8399
template <typename real_t, int halo, bcond_e knd, drctn_e dir, int n_dims, int d>
@@ -147,6 +163,22 @@ namespace libmpdataxx
147163
{
148164
fill_halos_vctr_nrml(a, j, k);
149165
}
166+
167+
void copy_edge_sclr_to_halo1_cyclic(arr_t &a, const rng_t &j, const rng_t &k)
168+
{
169+
using namespace idxperm;
170+
assert(halo>=1);
171+
172+
a(pi<d>(this->rght_halo_sclr.first(), j, k)) = a(pi<d>(this->left_edge_sclr, j, k));
173+
}
174+
175+
void avg_edge_and_halo1_sclr_cyclic(arr_t &a, const rng_t &j, const rng_t &k)
176+
{
177+
using namespace idxperm;
178+
assert(halo>=1);
179+
180+
a(pi<d>(this->rght_edge_sclr, j, k)) = ( a(pi<d>(this->rght_edge_sclr, j, k)) + a(pi<d>(this->rght_halo_sclr.first(), j, k)) ) / real_t(2);
181+
}
150182
};
151183
} // namespace bcond
152184
} // namespace libmpdataxx

libmpdata++/bcond/detail/bcond_common.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ namespace libmpdataxx
5656
virtual void fill_halos_vctr_alng_cyclic(arrvec_t<blitz::Array<real_t, 1>> &, const bool ad = false)
5757
{};
5858

59+
virtual void copy_edge_sclr_to_halo1_cyclic(arr_1d_t &)
60+
{};
61+
62+
virtual void avg_edge_and_halo1_sclr_cyclic(arr_1d_t &)
63+
{};
64+
5965
// 2D
6066
virtual void fill_halos_sclr(arr_2d_t &, const rng_t &, const bool deriv = false)
6167
{
@@ -111,6 +117,12 @@ namespace libmpdataxx
111117
virtual void fill_halos_flux(arrvec_t<blitz::Array<real_t, 2>> &, const rng_t &)
112118
{};
113119

120+
virtual void copy_edge_sclr_to_halo1_cyclic(arr_2d_t &, const rng_t &)
121+
{};
122+
123+
virtual void avg_edge_and_halo1_sclr_cyclic(arr_2d_t &, const rng_t &)
124+
{};
125+
114126
// 3D
115127
virtual void fill_halos_sclr(arr_3d_t &, const rng_t &, const rng_t &, const bool deriv = false)
116128
{
@@ -175,6 +187,12 @@ namespace libmpdataxx
175187
virtual void fill_halos_flux(arrvec_t<blitz::Array<real_t, 3>> &, const rng_t &, const rng_t &)
176188
{};
177189

190+
virtual void copy_edge_sclr_to_halo1_cyclic(arr_3d_t &, const rng_t &, const rng_t &)
191+
{};
192+
193+
virtual void avg_edge_and_halo1_sclr_cyclic(arr_3d_t &, const rng_t &, const rng_t &)
194+
{};
195+
178196
protected:
179197
// sclr
180198
int

0 commit comments

Comments
 (0)