3
# (C) 2015 Anton Gladky <gladk@debian.org>
9
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
14
cat <<EOF > CMakeLists.txt
15
cmake_minimum_required(VERSION 2.6)
17
find_package(Palabos REQUIRED)
18
include_directories(\${PALABOS_INCLUDE_DIR})
20
add_executable(demo demo.cpp)
21
target_link_libraries(demo \${PALABOS_LIBRARIES})
22
install(TARGETS demo DESTINATION bin)
27
/* This file is part of the Palabos library.
29
* Copyright (C) 2011-2015 FlowKit Sarl
31
* 1010 Lausanne, Switzerland
32
* E-mail contact: contact@flowkit.com
34
* The most recent release of Palabos can be downloaded at
35
* <http://www.palabos.org/>
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.
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.
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/>.
51
#include "palabos3D.h"
52
#include "palabos3D.hh"
53
#include "palabos2D.h"
54
#include "palabos2D.hh"
60
using namespace plb::descriptors;
68
Box3D domain1_3d(5,15,5,15,5,15);
69
Box3D domain2_3d(20,30,20,30,20,30);
71
Box2D domain1_2d(5,15,5,15);
72
Box2D domain2_2d(20,30,20,30);
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) );
81
lattice3d_1.collideAndStream();
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);
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);
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);
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) );
113
lattice2d_1.collideAndStream();
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);
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);
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);
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);
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);
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);
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);
178
int main(int argc, char* argv[]) {
179
plbInit(&argc, &argv);
181
copyBlockLattice3D();
191
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_PREFIX=./../inst ./../src