OpenLB 1.7
Loading...
Searching...
No Matches
particleOperations3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016 Thomas Henn, Davide Dapelo
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 PARTICLE_OPERATIONS_3D_HH
25#define PARTICLE_OPERATIONS_3D_HH
26
27#include <string>
28#include <iostream>
29#include <set>
30#include <vector>
31#include <list>
32#include <deque>
33
34namespace olb {
35
36template<typename T, template<typename U> class PARTICLETYPE>
38 : _dT(dT),
39 _randomNormal( 0, util::sqrt(2.*diffusivity*dT) )
40{ }
41
42template<typename T, template<typename U> class PARTICLETYPE>
43void RandomWalkOperation3D<T,PARTICLETYPE>::applyParticleOperation ( typename std::deque<PARTICLETYPE<T> >::iterator p,
45{
46 T posOldArray[] { p->getPos()[0], p->getPos()[1], p->getPos()[2] };
47 T posIncrementArray[] {0., 0., 0.};
48 _randomNormal(posIncrementArray, posOldArray);
49 std::vector<T> posNew { posOldArray[0]+posIncrementArray[0], posOldArray[1]+posIncrementArray[1], posOldArray[2]+posIncrementArray[2] };
50 p->setPos(posNew);
51 p->setVel({ (posNew[0]-posOldArray[0])/_dT, (posNew[1]-posOldArray[1])/_dT, (posNew[2]-posOldArray[2])/_dT });
52}
53
54
55template<typename T, template<typename U> class PARTICLETYPE>
57 : _dT(dT),
58 _randomNormal( 0, util::sqrt(2.*diffusivity*dT), n )
59{ }
60
61template<typename T, template<typename U> class PARTICLETYPE>
62void RandomTruncatedWalkOperation3D<T,PARTICLETYPE>::applyParticleOperation ( typename std::deque<PARTICLETYPE<T> >::iterator p,
64{
65 T posOldArray[] { p->getPos()[0], p->getPos()[1], p->getPos()[2] };
66 T posIncrementArray0[] {0., 0., 0.};
67 T posIncrementArray1[] {0., 0., 0.};
68 T posIncrementArray2[] {0., 0., 0.};
69 _randomNormal(posIncrementArray0, posOldArray);
70 _randomNormal(posIncrementArray1, posOldArray);
71 _randomNormal(posIncrementArray2, posOldArray);
72 std::vector<T> posNew { posOldArray[0]+posIncrementArray0[0], posOldArray[1]+posIncrementArray1[0], posOldArray[2]+posIncrementArray2[0] };
73 p->setPos(posNew);
74 p->setVel({ (posNew[0]-posOldArray[0])/_dT, (posNew[1]-posOldArray[1])/_dT, (posNew[2]-posOldArray[2])/_dT });
75}
76
77
78template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
81 : _dT(converter.getPhysDeltaT()),
82 _getVel(sLattice, converter)
83{ }
84
85template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
86void PassiveAdvectionOperation3D<T,PARTICLETYPE,DESCRIPTOR>::applyParticleOperation ( typename std::deque<PARTICLETYPE<T> >::iterator p,
88{
89 T fluidVel[] {0., 0., 0.};
90 _getVel(fluidVel, &p->getPos()[0], p->getCuboid());
91
92 T oldPos[] {p->getPos()[0], p->getPos()[1], p->getPos()[2]};
93 p->setPos({ oldPos[0]+fluidVel[0]*_dT, oldPos[1]+fluidVel[1]*_dT, oldPos[2]+fluidVel[2]*_dT });
94 std::vector<T> oldVel { p->getVel() };
95 p->setVel({ oldVel[0]+fluidVel[0], oldVel[1]+fluidVel[1], oldVel[2]+fluidVel[2] });
96}
97
98}
99
100
101
102#endif
virtual void applyParticleOperation(typename std::deque< PARTICLETYPE< T > >::iterator p, ParticleSystem3D< T, PARTICLETYPE > &pSys) override
PassiveAdvectionOperation3D(SuperLattice< T, DESCRIPTOR > &sLattice, UnitConverter< T, DESCRIPTOR > &converter)
virtual void applyParticleOperation(typename std::deque< PARTICLETYPE< T > >::iterator p, ParticleSystem3D< T, PARTICLETYPE > &pSys) override
RandomTruncatedWalkOperation3D(T dT, T diffusivity, T n)
virtual void applyParticleOperation(typename std::deque< PARTICLETYPE< T > >::iterator p, ParticleSystem3D< T, PARTICLETYPE > &pSys) override
RandomWalkOperation3D(T dT, T diffusivity)
Super class maintaining block lattices for a cuboid decomposition.
Conversion between physical and lattice units, as well as discretization.
Top level namespace for all of OpenLB.