OpenLB 1.7
Loading...
Searching...
No Matches
periodicBoundary3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2014 Thomas Henn, Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#ifndef PERIODICBOUNDARY3D_H_
25#define PERIODICBOUNDARY3D_H_
26
27#include <math.h>
28#include <vector>
29
30namespace olb {
31
32template<typename T, template<typename U> class PARTICLETYPE>
33class ParticleSystem3D;
34
35/*
36 * Particle boundary based on a cube around the area with material number 1.
37 * Only applicable to rectangles since if a particle leaves the area with
38 * material number 1 it is moved to the opposing side of the area by
39 * newPosition = oldPosition +/- extend(MaterialNumber=1).
40 **/
41
42template<typename T, template<typename U> class PARTICLETYPE>
43class PeriodicBoundary3D : public Boundary3D<T, PARTICLETYPE> {
44public:
46 bool y, bool z);
48 virtual ~PeriodicBoundary3D() { };
49 virtual void applyBoundary(typename std::deque<PARTICLETYPE<T> >::iterator& p, ParticleSystem3D<T, PARTICLETYPE>& psSys);
52 unsigned int* getJumper();
53private:
54 //cube extents with origin (0,0,0)
55 std::vector<T> _minPhys, _maxPhys, _extend;
56 bool _x, _y, _z;
57 unsigned int _jumper[6];
58 CuboidGeometry3D<T>& _cuboidGeometry;
59 T _overlap;
60};
61
62template<typename T, template<typename U> class PARTICLETYPE>
64 SuperGeometry<T,3> sg, bool x, bool y, bool z) : Boundary3D<T, PARTICLETYPE>(),
65 _minPhys(3, T()), _maxPhys(3, T()), _extend(3, T()),
66 _x(x),
67 _y(y),
68 _z(z), _cuboidGeometry(sg.getCuboidGeometry())
69{
70 _minPhys = sg.getStatistics().getMinPhysR(1);
71 _maxPhys = sg.getStatistics().getMaxPhysR(1);
72 _extend[0] = _maxPhys[0] - _minPhys[0];
73 _extend[1] = _maxPhys[1] - _minPhys[1];
74 _extend[2] = _maxPhys[2] - _minPhys[2];
75 for (int i=0; i<6; ++i) {
76 _jumper[i] = 0;
77 }
78 _overlap = sg.getOverlap();
79}
80
81template<typename T, template<typename U> class PARTICLETYPE>
83 typename std::deque<PARTICLETYPE<T> >::iterator& p,
85{
86 if (_x) {
87 if (p->getPos()[0] > _maxPhys[0]) {
88 p->getPos()[0] -= _extend[0];
89 ++_jumper[0];
90 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
91 p->setCuboid(C);
92 }
93 else if (p->getPos()[0] < _minPhys[0]) {
94 p->getPos()[0] += _extend[0];
95 ++_jumper[1];
96 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
97 p->setCuboid(C);
98 }
99 }
100 if (_y) {
101 if (p->getPos()[1] > _maxPhys[1]) {
102 p->getPos()[1] -= _extend[1];
103 ++_jumper[2];
104 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
105 p->setCuboid(C);
106 }
107 else if (p->getPos()[1] < _minPhys[1]) {
108 p->getPos()[1] += _extend[1];
109 ++_jumper[3];
110 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
111 p->setCuboid(C);
112 }
113 }
114 if (_z) {
115 if (p->getPos()[2] > _maxPhys[2]) {
116 p->getPos()[2] -= _extend[2];
117 ++_jumper[4];
118 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
119 p->setCuboid(C);
120 }
121 else if (p->getPos()[2] < _minPhys[2]) {
122 p->getPos()[2] += _extend[2];
123 ++_jumper[5];
124 int C = this->_cuboidGeometry.get_iC(p->getPos()[0], p->getPos()[1], p->getPos()[2], _overlap);
125 p->setCuboid(C);
126 }
127 }
128}
129
130template<typename T, template<typename U> class PARTICLETYPE>
132{
133 return _jumper;
134}
135
136
137}
138
139#endif
Prototype for all particle boundaries.
Definition boundary3D.h:43
A cuboid geometry represents a voxel mesh.
PeriodicBoundary3D(PeriodicBoundary3D< T, PARTICLETYPE > &f)
unsigned int * getJumper()
Returns number of particles that moved through the periodic boundary Order: x+, x-,...
virtual void applyBoundary(typename std::deque< PARTICLETYPE< T > >::iterator &p, ParticleSystem3D< T, PARTICLETYPE > &psSys)
PeriodicBoundary3D(SuperGeometry< T, 3 > sg, bool x, bool y, bool z)
Representation of a statistic for a parallel 2D geometry.
SuperGeometryStatistics< T, D > & getStatistics()
Returns the statistics object.
int getOverlap()
Read and write access to the overlap.
Top level namespace for all of OpenLB.