From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 24 Jun 2019 14:43:36 +0200 Subject: Initialize at openlb-1-3 --- src/particles/particle3D.h | 407 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 407 insertions(+) create mode 100644 src/particles/particle3D.h (limited to 'src/particles/particle3D.h') diff --git a/src/particles/particle3D.h b/src/particles/particle3D.h new file mode 100644 index 0000000..a9af64a --- /dev/null +++ b/src/particles/particle3D.h @@ -0,0 +1,407 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2016 Thomas Henn, Mathias J. Krause + * E-mail contact: info@openlb.net + * The most recent release of OpenLB can be downloaded at + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef PARTICLE_3D_H +#define PARTICLE_3D_H + +#include +#include +#include +#include +#include +#include + +namespace olb { + +template +class Particle3D { +public: + Particle3D(); + Particle3D(std::vector pos, T mas = 1., T rad = 1., int id = 0); + Particle3D(std::vector pos, std::vector vel, + T mas = 1., T rad = 1., int id = 0); + Particle3D(const Particle3D& p); + + inline void setPos(std::vector pos) { + _pos = pos; + } + inline void setStoredPos(std::vector pos) { + _storePos = pos; + } + inline std::vector& getStoredPos() { + return _storePos; + } + inline std::vector& getPos() { + return _pos; + } + inline const std::vector& getPos() const { + return _pos; + } + inline void setVel(std::vector vel) { + _vel = vel; + } + inline void setStoredVel(std::vector vel) { + _storeVel = vel; + } + inline std::vector& getStoredVel() { + return _storeVel; + } + inline int getID() { + return _id; + } + inline void setID(int id) { + _id = id; + } + inline std::vector& getVel() { + return _vel; + } + inline const std::vector& getVel() const { + return _vel; + } + + inline void addForce(std::vector& frc); + + inline void setForce(std::vector& frc); + inline void resetForce(); + inline std::vector& getForce() { + return _force; + } + inline const std::vector& getForce() const { + return _force; + } + + inline void setStoreForce(std::vector& storeForce); + inline void resetStoreForce(); + inline std::vector& getStoreForce() + { + return _storeForce; + } + inline const std::vector& getStoreForce() const { + return _storeForce; + } + + // RK4 +// inline void setPos(std::vector pos, int i) { +// _positions[i] = pos; +// } +// inline std::vector& getPos(int i) { +// return _positions[i]; +// } +// inline const std::vector& getPos(int i) const { +// return _positions[i]; +// } +// inline void setVel(std::vector vel, int i) { +// _velocities[i] = vel; +// } +// inline std::vector& getVel(int i) { +// return _velocities[i]; +// } +// inline const std::vector& getVel(int i) const { +// return _velocities[i]; +// } +// inline void setForce(std::vector force, int i) { +// _forces[i] = force; +// } +// inline std::vector& getForce(int i) { +// return _forces[i]; +// } +// inline const std::vector& getForce(int i) const { +// return _forces[i]; +// } + +// write particle properties into serial + void serialize(T serial[]); + // write data into particle properties + void unserialize(T*); + void print(); + void printDeep(std::string message); + + inline const T& getMass() { + return _mas; + } + + inline const T& getInvMass() { + return _invMas; + } + + inline const T& getMass() const { + return _mas; + } + inline void setMass(T m) { + _mas = m; + _invMas = 1. / _mas; + } + inline const T& getRad() { + return _rad; + } + inline const T& getRad() const { + return _rad; + } + inline void setRad(T r) { + _rad = r; + } + inline const int& getCuboid() { + return _cuboid; + } + inline void setCuboid(int c) { + _cuboid = c; + } + inline const bool& getActive() { + return _active; + } + inline const bool& getActive() const { + return _active; + } + inline void setActive(bool act) { + _active = act; + if (!act) { + _vel[0] = 0; + _vel[1] = 0; + _vel[2] = 0; + } + } + + // static const int serialPartSize = 14; // pos, vel, force, mas, rad, cuboid, id, active + static const int serialPartSize = 17; // pos, vel, force, mas, rad, cuboid, id, active, storeForce + // static const int serialPartSize = 23; // pos, vel, force, mas, rad, cuboid, id, active, storeForce, storePos, storeVel + + std::vector > _verletList; + +protected: + std::vector _pos; + std::vector _vel; + std::vector _force; + T _invMas; + T _mas; + T _rad; + ///globIC + int _cuboid; + int _id; + bool _active; + std::vector _storePos; + std::vector _storeVel; + std::vector _storeForce; + // RK4 +// std::vector > _positions; +// std::vector > _velocities; +// std::vector > _forces; + +}; + +/* + * Electric Particles + */ +template +class ElParticle3D: public Particle3D { +public: + ElParticle3D(); + ElParticle3D(std::vector pos, T mas = 1., T rad = 1., T charge = 1.); + ElParticle3D(std::vector pos, std::vector vel, + T mas = 1., T rad = 1., T charge = 1.); + ElParticle3D(const ElParticle3D& p); + virtual ~ElParticle3D() { + } + ; + virtual void serialize(T serial[]); + virtual void unserialize(T*); + static const int serialPartSize = 10; + T _charge; +}; + +/* + * Particles for Agglomeration + */ + +template +class AggParticle3D: public Particle3D { +public: + AggParticle3D(); + AggParticle3D(std::vector pos, T mas = 1., T rad = 1.); + AggParticle3D(std::vector pos, std::vector vel, T mas = 1., T rad = 1.); + AggParticle3D(const Particle3D& p); + + inline void setMass(T mas) { + this->_mas = mas; + } + inline void setRad(T rad) { + this->_rad = rad; + } + inline const bool& getAggl() { + return _aggl; + } + inline const bool& getAggl() const { + return _aggl; + } + inline void setAggl(bool aggl) { + _aggl = aggl; + if (aggl) { + this->setActive(false); + } + } + + static const int serialPartSize = 14; + void serialize(T serial[]); + void unserialize(T*); + +private: + bool _aggl; +}; + +/* + * Rotating Particles + */ +template +class RotatingParticle3D: public Particle3D { +public: + RotatingParticle3D(); + RotatingParticle3D(std::vector pos, T mas = 1., T rad = 1.); + RotatingParticle3D(std::vector pos, std::vector vel, T mas = 1., T rad = 1.); + RotatingParticle3D(const RotatingParticle3D& p); + + static const int serialPartSize = 19; + void serialize(T serial[]); + void unserialize(T*); + + inline std::vector& getAVel() { + return _aVel; + } + inline const std::vector& getAVel() const { + return _aVel; + } + inline std::vector& getTorque() { + return _torque; + } + inline const std::vector& getTorque() const { + return _torque; + } +private: + std::vector _aVel; + std::vector _torque; +}; + +// NEW +/* + * Particles for magnetic force + */ + +template +class MagneticParticle3D: public Particle3D { +private: + std::vector _dMoment; + std::vector _aVel; + std::vector _torque; + T _magnetisation; + + // _sActivity values range from 1 to 3 + // Gives information about the poisiton of the particle in the simulation area + // One collision model: + // 1: Particle is not deposited + // 2: Not in use + // 3: Particle is deposited on mag. wire. + // Multiple collision models: + // 1: Particle is in sufficiently large distance to the inhom. mag. field of the wire + // Particle collsions are managed by a collision model function + // 2: Particle is within the inhom. mag. field of the wire + // Particle collsions are managed by a mechanic contact force + // The sActivity change (1 --> 2) is done in explicitEuler() + // 3: Particle is deposited on mag. wire. + // Particle collsions are managed by a mechanic contact force + int _sActivity; + + // Assigns an agglomerate to the particle + typename std::deque*>>::iterator _aggloItr; + // Assigns the particle position in an Agglomerate to a Particle + // typename std::list*>::iterator _aggloItrPos; + +public: + + MagneticParticle3D(); + MagneticParticle3D(std::vector pos, T mas = 1., T rad = 1., int id = 0); + MagneticParticle3D(std::vector pos, std::vector vel, T mas = 1., T rad = + 1., int id = 0); + MagneticParticle3D(const MagneticParticle3D& p); + MagneticParticle3D(std::vector pos, std::vector vel, T mas, T rad, int id, + std::vector dMoment, std::vector aVel, std::vector torque, T magnetisation); + MagneticParticle3D(std::vector pos, std::vector vel, T mas, T rad, int id, + std::vector dMoment, std::vector aVel, std::vector torque, T magnetisation, int sActivity); + + static const int serialPartSize = 28; + void serialize(T serial[]); + void unserialize(T*); + + // Set torque zero + inline void resetTorque(); + + // Set and get orientation of magnetic dipolemoment + inline void setMoment(std::vector moment); + inline std::vector& getMoment() { + return _dMoment; + } + inline const std::vector& getMoment() const { + return _dMoment; + } + + // Set and get angular velocity + inline void setAVel(std::vector aVel); + inline std::vector& getAVel() { + return _aVel; + } + inline const std::vector& getAVel() const { + return _aVel; + } + + // Set and get torque + inline void setTorque(std::vector torque); + inline std::vector& getTorque() { + return _torque; + } + inline const std::vector& getTorque() const { + return _torque; + } + + // Set and get magnetisation + inline void setMagnetisation(T magnetisation); + inline T& getMagnetisation() { + return _magnetisation; + + } + inline const T& getMagnetisation() const { + return _magnetisation; + } + + // Set and get sActivity + inline void setSActivity(int sActivity); + inline int& getSActivity() { + return _sActivity; + } + + // Set and get aggloItr + inline void setAggloItr(typename std::deque*>>::iterator aggloItr); + inline typename std::deque*>>::iterator& getAggloItr() { + return _aggloItr; + } + +}; +} +#endif /* PARTICLE_3D_H */ + -- cgit v1.2.3