OpenLB 1.7
Loading...
Searching...
No Matches
magneticForceForMagP3D.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Marie-Luise Maier, Mathias J. Krause, Sascha Janz
3 * E-mail contact: info@openlb.net
4 * The most recent release of OpenLB can be downloaded at
5 * <http://www.openlb.net/>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23/* Alberto Di Renzo, Francesco Paolo Di Maio:
24 * "Comparison of contact-force models for the simulation of collisions in
25 * DEM-based granular ow codes",
26 * Chemical Engineering Science 59 (2004) 525 - 541
27 */
28
29#ifndef MagneticForceForMagP3D_HH
30#define MagneticForceForMagP3D_HH
31
32#include "utilities/omath.h"
33#include <vector>
35
36#ifndef M_PI
37#define M_PI 3.14159265358979323846
38#endif
39
40namespace olb {
41
42template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
44 AnalyticalF<3,T, T>& getMagForce, AnalyticalF<3,T, T>& getMagField, T scale) :
45 Force3D<T, PARTICLETYPE>(), _getMagForce(getMagForce), _getMagField(getMagField), _scale(scale)
46{ }
47
48template<typename T, template<typename U> class PARTICLETYPE, typename DESCRIPTOR>
50 typename std::deque<PARTICLETYPE<T> >::iterator p, int pInt,
52{
53
54 T m_p = p->getMagnetisation();
55 T mu_0 = 4 * 3.14159265e-7;
56 T mu_i = 4. / 3.*M_PI * util::pow(p->getRad(), 3) * m_p; // norm mag. dipole moment
57
58 T pos[3] = { T(), T(), T() };
59 pos[0] = p->getPos()[0];
60 pos[1] = p->getPos()[1];
61 pos[2] = p->getPos()[2];
62
63 T forceHelp[3] = { T(), T(), T() };
64 _getMagForce(forceHelp, pos);
65 T fieldHelp[3] = { T(), T(), T() };
66 _getMagField(fieldHelp, pos);
67
68 Vector<T, 3> dMom(p->getMoment()); // orientation vector mag. dipole moment
69 dMom *= mu_i; // vector mag. dipole moment
70
71 Vector<T, 3> fieldVec(fieldHelp); // H-Field
72 Vector<T, 3> trq = crossProduct3D(dMom, fieldVec); // T = mu_0 mu x H
73 trq *= mu_0;
74
75 p->getTorque()[0] += trq[0];
76 p->getTorque()[1] += trq[1];
77 p->getTorque()[2] += trq[2];
78 p->getForce()[0] += forceHelp[0] * _scale;
79 p->getForce()[1] += forceHelp[1] * _scale;
80 p->getForce()[2] += forceHelp[2] * _scale;
81
82}
83
84}
85#endif
#define M_PI
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Prototype for all particle forces.
Definition force3D.h:43
MagneticForceForMagP3D(AnalyticalF< 3, T, T > &getMagForce, AnalyticalF< 3, T, T > &getMagField, T scale=T(1.))
void applyForce(typename std::deque< PARTICLETYPE< T > >::iterator p, int pInt, ParticleSystem3D< T, PARTICLETYPE > &psSys) override
Plain old scalar vector.
Definition vector.h:47
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
Top level namespace for all of OpenLB.
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:224