OpenLB 1.7
Loading...
Searching...
No Matches
magneticParticle3D.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 MAGNETIC_PARTICLE_3D_HH
25#define MAGNETIC_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 "magneticParticle3D.h"
35
36namespace olb {
37
38
40
41template<typename T>
43 : Particle3D<T>::Particle3D(), _dMoment(3, T()), _aVel(3, T()), _torque(3, T()), _magnetisation(T())
44{ }
45
46template<typename T>
48 : Particle3D<T>::Particle3D(p), _dMoment(p._dMoment), _aVel(p._aVel), _torque(p._torque), _magnetisation(p._magnetisation), _sActivity(p._sActivity)
49{ }
50
51template<typename T>
52MagneticParticle3D<T>::MagneticParticle3D(std::vector<T> pos, std::vector<T> vel, T mas,
53 T rad, int id, T masAdd)
54 : Particle3D<T>::Particle3D(pos, vel, mas, rad), _dMoment(3, T()), _aVel(3, T()), _torque(3, T()), _magnetisation(T())
55{ }
56
57template<typename T>
58MagneticParticle3D<T>::MagneticParticle3D(std::vector<T> pos, std::vector<T> vel, T mas, T rad, int id,
59 std::vector<T> dMoment, std::vector<T> aVel, std::vector<T> torque, T magnetisation)
60 : Particle3D<T>::Particle3D(pos, vel, mas, rad, id),
61 _dMoment(dMoment), _aVel(aVel), _torque(torque), _magnetisation(magnetisation)
62{ }
63
64template<typename T>
65MagneticParticle3D<T>::MagneticParticle3D(std::vector<T> pos, std::vector<T> vel, T mas, T rad, int id,
66 std::vector<T> dMoment, std::vector<T> aVel, std::vector<T> torque, T magnetisation, int sActivity)
67 : Particle3D<T>::Particle3D(pos, vel, mas, rad, id),
68 _dMoment(dMoment), _aVel(aVel), _torque(torque), _magnetisation(magnetisation), _sActivity(sActivity)
69{ }
70
71template<typename T>
73{
74 for (int i = 0; i < 3; i++) {
75 _torque[i] = 0.;
76 }
77}
78
79template<typename T>
80inline std::vector<T>& MagneticParticle3D<T>::getMoment()
81{
82 return _dMoment;
83}
84
85template<typename T>
86inline const std::vector<T>& MagneticParticle3D<T>::getMoment() const
87{
88 return _dMoment;
89}
90
91template<typename T>
92inline void MagneticParticle3D<T>::setMoment(std::vector<T> moment)
93{
94 _dMoment = moment;
95}
96
97template<typename T>
98inline void MagneticParticle3D<T>::setAVel(std::vector<T> aVel)
99{
100 _aVel = aVel;
101}
102
103template<typename T>
104inline std::vector<T>& MagneticParticle3D<T>::getAVel()
105{
106 return _aVel;
107}
108
109template<typename T>
110inline const std::vector<T>& MagneticParticle3D<T>::getAVel() const
111{
112 return _aVel;
113}
114
115template<typename T>
116inline void MagneticParticle3D<T>::setTorque(std::vector<T> torque)
117{
118 _torque = torque;
119}
120
121template<typename T>
122inline void MagneticParticle3D<T>::setMagnetisation(T magnetisation)
123{
124 _magnetisation = magnetisation;
125 //std::cout<< "Setting magnetisation: "<< _magnetisation << std::endl;
126}
127
128template<typename T>
129inline void MagneticParticle3D<T>::setSActivity(int sActivity)
130{
131 _sActivity = sActivity;
132}
133
134template<typename T>
135inline typename std::deque<std::list<MagneticParticle3D<T>*>>::iterator& MagneticParticle3D<T>::getAggloItr()
136{
137 return _aggloItr;
138}
139
140template<typename T>
141inline void MagneticParticle3D<T>::setAggloItr(typename std::deque<std::list<MagneticParticle3D<T>*>>::iterator aggloItr)
142{
143 _aggloItr = aggloItr;
144}
145
146template<typename T>
147inline std::vector<T>& MagneticParticle3D<T>::getTorque()
148{
149 return _torque;
150}
151
152template<typename T>
153inline const std::vector<T>& MagneticParticle3D<T>::getTorque() const
154{
155 return _torque;
156}
157
158template<typename T>
160{
161 return _magnetisation;
162}
163
164template<typename T>
166{
167 return _magnetisation;
168}
169
170template<typename T>
175
176template<typename T>
178{
179 for (int i = 0; i < 3; i++) {
180 serial[i] = this->_pos[i];
181 serial[i + 3] = this->_vel[i];
182 serial[i + 6] = this->_force[i];
183 }
184 serial[9] = this->_mas;
185 serial[10] = this->_rad;
186 serial[11] = (double) this->_cuboid;
187 serial[12] = (double) this->_active;
188 serial[13] = (double) this->_id;
189 for (int i = 0; i < 3; i++) {
190 serial[i + 14] = this->_storeForce[i];
191 serial[i + 17] = _dMoment[i];
192 serial[i + 20] = _aVel[i];
193 serial[i + 23] = _torque[i];
194 }
195 serial[26] = _magnetisation;
196 serial[27] = (double) _sActivity;
197}
198
199template<typename T>
201{
202 for (int i = 0; i < 3; i++) {
203 this->_pos[i] = data[i];
204 this->_vel[i] = data[i + 3];
205 this->_force[i] = data[i + 6];
206 }
207 this->_mas = data[9];
208 this->_rad = data[10];
209 this->_cuboid = (int) data[11];
210 this->_active = (bool) data[12];
211 this->_id = (int) data[13];
212 for (int i = 0; i < 3; i++) {
213 this->_storeForce[i] = data[i + 14];
214 _dMoment[i] = data[i + 17];
215 _aVel[i] = data[i + 20];
216 _torque[i] = data[i + 23];
217 }
218 _magnetisation = data[26];
219 _sActivity = (int) data[27];
220}
221
222
224
225template<typename T>
229
230template<typename T>
232{
233 _pSys->resetMag();
234 _pSys->computeForce();
235 _pSys->explicitEuler(dT, scale);
236 _pSys->integrateTorqueMag(dT);
237
238#ifdef CollisionModels
239 _pSys->partialElasticImpact(0.67);
240#endif
241}
242
243template<typename T>
247 int material, int subSteps, bool scale )
248{
249 for (int iSubStep=1; iSubStep<=subSteps; iSubStep++) {
250 if (! _pSys->executeForwardCoupling(forwardCoupling) ) {
251 std::cout << " on substep " << iSubStep << std::endl;
253 }
254 _pSys->computeForce();
255 _pSys->explicitEuler(dT/(T)(subSteps), scale);
256 //_pSys->rungeKutta4(dT/(T)(subSteps));
257 }
258 _pSys->executeBackwardCoupling(backCoupling, material);
259}
260
261template<typename T>
265 int material, int subSteps, bool scale )
266{
267 for (int iSubStep=1; iSubStep<=subSteps; iSubStep++) {
268 if (! _pSys->executeForwardCoupling(forwardCoupling) ) {
269 std::cout << " on substep " << iSubStep << std::endl;
271 }
272 _pSys->computeForce();
273 _pSys->explicitEuler(dT/(T)(subSteps), scale);
274 //_pSys->rungeKutta4(dT/(T)(subSteps));
275 _pSys->executeBackwardCoupling(backCoupling, material, subSteps);
276 }
277}
278
279template<typename T>
280inline void SimulateParticles<T,MagneticParticle3D>::simulate(T dT, std::set<int> sActivityOfParticle, bool scale)
281{
282 _pSys->resetMag(sActivityOfParticle);
283 _pSys->computeForce(sActivityOfParticle);
284 _pSys->explicitEuler(dT, sActivityOfParticle, scale);
285 _pSys->integrateTorqueMag(dT, sActivityOfParticle);
286
287#ifdef CollisionModels
288 _pSys->partialElasticImpact(0.67);
289#endif
290
291#ifdef CollisionModelsCombindedWithMechContactForce
292 _pSys->partialElasticImpactForCombinationWithMechContactForce(0.67);
293#endif
294}
295
296
297}
298
299#endif
Abstact base class for BaseBackCouplingModel.
Abstact base class for all the forward-coupling models Its raison d'etre consists of not being temple...
std::vector< T > & getTorque()
void setSActivity(int sActivity)
void setTorque(std::vector< T > torque)
std::deque< std::list< MagneticParticle3D< T > * > >::iterator & getAggloItr()
void setMagnetisation(T magnetisation)
std::vector< T > & getAVel()
std::vector< T > & getMoment()
void setAggloItr(typename std::deque< std::list< MagneticParticle3D< T > * > >::iterator aggloItr)
void setMoment(std::vector< T > moment)
void setAVel(std::vector< T > aVel)
void simulateWithTwoWayCoupling_Mathias(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps=1, bool scale=false)
SimulateParticles(ParticleSystem3D< T, PARTICLETYPE > *ps)
void simulateWithTwoWayCoupling_Davide(T dT, ForwardCouplingModel< T, PARTICLETYPE > &forwardCoupling, BackCouplingModel< T, PARTICLETYPE > &backCoupling, int material, int subSteps=1, bool scale=false)
void simulate(T dT, bool scale=false)
void exit(int exitcode)
Definition singleton.h:165
Top level namespace for all of OpenLB.