OpenLB 1.7
Loading...
Searching...
No Matches
rotatingParticle3D.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 ROTATING_PARTICLE_3D_HH
25#define ROTATING_PARTICLE_3D_HH
26
27#include <string>
28#include <iostream>
29#include <set>
30#include <vector>
31#include <list>
32#include <deque>
33
34#include "rotatingParticle3D.h"
35
36namespace olb {
37
38
39template<typename T>
41 : Particle3D<T>::Particle3D(), _aVel(3, T()), _torque(3, T())
42{ }
43
44template<typename T>
45RotatingParticle3D<T>::RotatingParticle3D(std::vector<T> pos, T mas, T rad)
46 : Particle3D<T>::Particle3D(pos, mas, rad), _aVel(3, T()), _torque(3, T())
47{ }
48
49template<typename T>
51 : Particle3D<T>::Particle3D(p), _aVel(p.getAVel()), _torque(p._torque)
52{ }
53
54template<typename T>
55RotatingParticle3D<T>::RotatingParticle3D(std::vector<T> pos, std::vector<T> vel, T mas,
56 T rad)
57 : Particle3D<T>::Particle3D(pos, vel, mas, rad), _aVel(3, T()), _torque(3, T())
58{ }
59
60template<typename T>
61inline std::vector<T>& RotatingParticle3D<T>::getAVel()
62{
63 return _aVel;
64}
65
66template<typename T>
67inline const std::vector<T>& RotatingParticle3D<T>::getAVel() const
68{
69 return _aVel;
70}
71
72template<typename T>
73inline std::vector<T>& RotatingParticle3D<T>::getTorque()
74{
75 return _torque;
76}
77
78template<typename T>
79inline const std::vector<T>& RotatingParticle3D<T>::getTorque() const
80{
81 return _torque;
82}
83
84template<typename T>
86{
87 for (int i = 0; i < 3; i++) {
88 serial[i] = this->_pos[i];
89 serial[i + 3] = this->_vel[i];
90 serial[i + 6] = this->_force[i];
91 }
92 serial[9] = this->_mas;
93 serial[10] = this->_rad;
94 serial[11] = this->_cuboid;
95 serial[12] = (double) this->_active;
96 serial[13] = (double) _aVel[0];
97 serial[14] = (double) _aVel[1];
98 serial[15] = (double) _aVel[2];
99 serial[16] = (double) _torque[0];
100 serial[17] = (double) _torque[1];
101 serial[18] = (double) _torque[2];
102}
103
104template<typename T>
106{
107 for (int i = 0; i < 3; i++) {
108 this->_pos[i] = data[i];
109 this->_vel[i] = data[i + 3];
110 this->_force[i] = data[i + 6];
111 }
112 this->_mas = data[9];
113 this->_rad = data[10];
114 this->_cuboid = int(data[11]);
115 this->_active = (bool) data[12];
116 _aVel[0] = (bool) data[13];
117 _aVel[1] = (bool) data[14];
118 _aVel[2] = (bool) data[15];
119 _torque[0] = (bool) data[16];
120 _torque[1] = (bool) data[17];
121 _torque[2] = (bool) data[18];
122}
123
124
126
127template<typename T>
131
132template<typename T>
134{
135 _pSys->computeForce();
136 _pSys->explicitEuler(dT, scale);
137 _pSys->integrateTorque(dT);
138}
139
140
141}
142
143#endif
std::vector< T > & getAVel()
std::vector< T > & getTorque()
SimulateParticles(ParticleSystem3D< T, PARTICLETYPE > *ps)
void simulate(T dT, bool scale=false)
Top level namespace for all of OpenLB.