~registry/+junk/palabos-packaging

« back to all changes in this revision

Viewing changes to tests/buildTest2

  • Committer: Anton Gladky
  • Date: 2015-03-30 15:50:46 UTC
  • Revision ID: gladky.anton@gmail.com-20150330155046-r6repoqkww82zevs
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# autopkgtest check
 
3
# (C) 2015 Anton Gladky <gladk@debian.org>
 
4
 
 
5
set -e
 
6
 
 
7
 
 
8
WORKDIR=$(mktemp -d)
 
9
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
 
10
cd $WORKDIR
 
11
mkdir src
 
12
cd src
 
13
 
 
14
cat <<EOF > CMakeLists.txt
 
15
cmake_minimum_required(VERSION 2.6)
 
16
project(Test)
 
17
find_package(Palabos REQUIRED)
 
18
include_directories(\${PALABOS_INCLUDE_DIR})
 
19
 
 
20
add_executable(demo demo.cpp)
 
21
target_link_libraries(demo \${PALABOS_LIBRARIES})
 
22
install(TARGETS demo DESTINATION bin)
 
23
 
 
24
EOF
 
25
 
 
26
cat <<EOF > demo.cpp
 
27
/* This file is part of the Palabos library.
 
28
 *
 
29
 * Copyright (C) 2011-2015 FlowKit Sarl
 
30
 * Route d'Oron 2
 
31
 * 1010 Lausanne, Switzerland
 
32
 * E-mail contact: contact@flowkit.com
 
33
 *
 
34
 * The most recent release of Palabos can be downloaded at 
 
35
 * <http://www.palabos.org/>
 
36
 *
 
37
 * The library Palabos is free software: you can redistribute it and/or
 
38
 * modify it under the terms of the GNU Affero General Public License as
 
39
 * published by the Free Software Foundation, either version 3 of the
 
40
 * License, or (at your option) any later version.
 
41
 *
 
42
 * The library is distributed in the hope that it will be useful,
 
43
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
44
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
45
 * GNU Affero General Public License for more details.
 
46
 *
 
47
 * You should have received a copy of the GNU Affero General Public License
 
48
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
49
*/
 
50
 
 
51
#include "palabos3D.h"
 
52
#include "palabos3D.hh"
 
53
#include "palabos2D.h"
 
54
#include "palabos2D.hh"
 
55
#include <iostream>
 
56
#include <fstream>
 
57
#include <iomanip>
 
58
 
 
59
using namespace plb;
 
60
using namespace plb::descriptors;
 
61
using namespace std;
 
62
 
 
63
plint nx = 40;
 
64
plint ny = 40;
 
65
plint nz = 40;
 
66
double omega = 1.;
 
67
 
 
68
Box3D domain1_3d(5,15,5,15,5,15);
 
69
Box3D domain2_3d(20,30,20,30,20,30);
 
70
 
 
71
Box2D domain1_2d(5,15,5,15);
 
72
Box2D domain2_2d(20,30,20,30);
 
73
 
 
74
 
 
75
void copyBlockLattice3D() {
 
76
    MultiBlockLattice3D<double, D3Q19Descriptor> lattice3d_1 (
 
77
            nx,ny,nz, new BGKdynamics<double,D3Q19Descriptor>(omega) );
 
78
    MultiBlockLattice3D<double, D3Q19Descriptor> lattice3d_2 (
 
79
            nx,ny,nz, new BGKdynamics<double,D3Q19Descriptor>(omega) );
 
80
 
 
81
    lattice3d_1.collideAndStream();
 
82
 
 
83
    // 1. SAME-POSITION COPIES.
 
84
    // Copy all populations and external scalars.
 
85
    copyPopulations(lattice3d_1, lattice3d_2, domain1_3d);
 
86
    // Copy all populations, external scalars, and content of dynamics objects.
 
87
    copyAll(lattice3d_1, lattice3d_2, domain1_3d);
 
88
    defineDynamics(lattice3d_1, domain1_3d,
 
89
                   new BounceBack<double,D3Q19Descriptor>(1.));
 
90
    // Copy everything, and recreate a dynamics object at the destination.
 
91
    copyRegenerate(lattice3d_1, lattice3d_2, domain1_3d);
 
92
 
 
93
    // 2. CROSS-POSITION COPIES.
 
94
    // Copy all populations and external scalars.
 
95
    copyPopulations(lattice3d_1, domain1_3d, lattice3d_2, domain2_3d);
 
96
    // Copy all populations, external scalars, and content of dynamics objects.
 
97
    copyAll(lattice3d_1, domain1_3d, lattice3d_2, domain2_3d);
 
98
    // Copy everything, and recreate a dynamics object at the destination.
 
99
    copyRegenerate(lattice3d_1, domain1_3d, lattice3d_2, domain2_3d);
 
100
 
 
101
    // 3. CREATING CLONES.
 
102
    // Create a reduced-size clone, correponding to a sub-domain of the original lattice.
 
103
    std::auto_ptr<MultiBlockLattice3D<double,D3Q19Descriptor> >
 
104
        lattice3d_3 = clone(lattice3d_1,domain1_3d);
 
105
}
 
106
 
 
107
void copyBlockLattice2D() {
 
108
    MultiBlockLattice2D<double, D2Q9Descriptor> lattice2d_1 (
 
109
            nx,ny, new BGKdynamics<double,D2Q9Descriptor>(omega) );
 
110
    MultiBlockLattice2D<double, D2Q9Descriptor> lattice2d_2 (
 
111
            nx,ny, new BGKdynamics<double,D2Q9Descriptor>(omega) );
 
112
 
 
113
    lattice2d_1.collideAndStream();
 
114
 
 
115
    // 1. SAME-POSITION COPIES.
 
116
    // Copy all populations and external scalars.
 
117
    copyPopulations(lattice2d_1, lattice2d_2, domain1_2d);
 
118
    // Copy all populations, external scalars, and content of dynamics objects.
 
119
    copyAll(lattice2d_1, lattice2d_2, domain1_2d);
 
120
    defineDynamics(lattice2d_1, domain1_2d,
 
121
                   new BounceBack<double,D2Q9Descriptor>(1.));
 
122
    // Copy everything, and recreate a dynamics object at the destination.
 
123
    copyRegenerate(lattice2d_1, lattice2d_2, domain1_2d);
 
124
 
 
125
    // 2. CROSS-POSITION COPIES.
 
126
    // Copy all populations and external scalars.
 
127
    copyPopulations(lattice2d_1, domain1_2d, lattice2d_2, domain2_2d);
 
128
    // Copy all populations, external scalars, and content of dynamics objects.
 
129
    copyAll(lattice2d_1, domain1_2d, lattice2d_2, domain2_2d);
 
130
    // Copy everything, and recreate a dynamics object at the destination.
 
131
    copyRegenerate(lattice2d_1, domain1_2d, lattice2d_2, domain2_2d);
 
132
 
 
133
    // 3. CREATING CLONES.
 
134
    // Create a reduced-size clone, correponding to a sub-domain of the original lattice.
 
135
    std::auto_ptr<MultiBlockLattice2D<double,D2Q9Descriptor> >
 
136
        lattice2d_3 = clone(lattice2d_1,domain1_2d);
 
137
}
 
138
 
 
139
void copyScalarField3D() {
 
140
    MultiScalarField3D<double> scalar3d_1(nx,ny,nz);
 
141
    MultiScalarField3D<double> scalar3d_2(nx,ny,nz);
 
142
    MultiScalarField3D<int> scalar3d_3(nx,ny,nz);
 
143
    setToConstant(scalar3d_1, scalar3d_1.getBoundingBox(), 1.);
 
144
    setToConstant(scalar3d_2, scalar3d_2.getBoundingBox(), 2.);
 
145
    setToConstant(scalar3d_3, scalar3d_3.getBoundingBox(), 3);
 
146
 
 
147
    // 1. SAME-POSITION COPIES.
 
148
    plb::copy(scalar3d_1, scalar3d_2, scalar3d_1.getBoundingBox() );
 
149
    // Copy with type conversion.
 
150
    plb::copy(scalar3d_2, scalar3d_3, scalar3d_2.getBoundingBox() );
 
151
    // 2. CROSS-POSITION COPIES.
 
152
    plb::copy(scalar3d_1, domain1_3d, scalar3d_2, domain2_3d);
 
153
    // 3. CREATING CLONES.
 
154
    std::auto_ptr<MultiScalarField3D<double> >
 
155
        scalar3d_4 = clone(scalar3d_2,domain1_3d);
 
156
}
 
157
 
 
158
void copyScalarField2D() {
 
159
    MultiScalarField2D<double> scalar2d_1(nx,ny);
 
160
    MultiScalarField2D<double> scalar2d_2(nx,ny);
 
161
    MultiScalarField2D<int> scalar2d_3(nx,ny);
 
162
    setToConstant(scalar2d_1, scalar2d_1.getBoundingBox(), 1.);
 
163
    setToConstant(scalar2d_2, scalar2d_2.getBoundingBox(), 2.);
 
164
    setToConstant(scalar2d_3, scalar2d_3.getBoundingBox(), 2);
 
165
 
 
166
    // 1. SAME-POSITION COPIES.
 
167
    plb::copy(scalar2d_1, scalar2d_2, scalar2d_1.getBoundingBox() );
 
168
    // Copy with type conversion.
 
169
    plb::copy(scalar2d_2, scalar2d_3, scalar2d_2.getBoundingBox() );
 
170
    // 2. CROSS-POSITION COPIES.
 
171
    plb::copy(scalar2d_1, domain1_2d, scalar2d_2, domain2_2d);
 
172
    // 3. CREATING CLONES.
 
173
    std::auto_ptr<MultiScalarField2D<int> >
 
174
        scalar2d_4 = clone(scalar2d_3,domain1_2d);
 
175
}
 
176
 
 
177
 
 
178
int main(int argc, char* argv[]) {
 
179
    plbInit(&argc, &argv);
 
180
 
 
181
    copyBlockLattice3D();
 
182
    copyScalarField3D();
 
183
}
 
184
 
 
185
 
 
186
EOF
 
187
 
 
188
cd ..
 
189
mkdir build
 
190
cd build
 
191
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_PREFIX=./../inst ./../src
 
192
make
 
193
make install
 
194
echo "build: OK"
 
195
[ -x demo ]
 
196
./demo
 
197
echo "run: OK"