OpenLB 1.7
Loading...
Searching...
No Matches
particleDynamicsUtilities.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Nicolas Hafen, Mathias J. Krause
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_DYNAMICS_UTILITIES_H
25#define PARTICLE_DYNAMICS_UTILITIES_H
26
27#include <cassert>
28
29namespace olb {
30
31namespace particles {
32
33//Forward declaration of particle
34template <typename T, typename DESCRIPTOR> class Particle;
35
36namespace dynamics {
37
38//TODO: should be moved to more accessible location
39template<typename T, typename PARTICLETYPE>
41{
42 using namespace descriptors;
43 auto rotationMatrix = util::calculateRotationMatrix<T,PARTICLETYPE::d>(
44 particle.template getField<SURFACE,ANGLE>() );
45 if constexpr ( PARTICLETYPE::template providesNested<SURFACE,ROT_MATRIX>() ) {
46 particle.template setField<SURFACE,ROT_MATRIX>( rotationMatrix );
47 } else {
48 std::cerr << "ERROR: The field ROT_MATRIX must be provided." << std::endl;
49 }
50}
51
52
54
55//TODO: Check whether any are actually used anymore after particle dynamics adaption
56
57//TODO: Check, whether obsolet with new doAtParticleWallContact
58template<typename T, typename PARTICLETYPE, typename F>
63 F boundTreatment )
64{
65 using namespace particles::access;
66 auto radius = getRadius<T,PARTICLETYPE>( particle );
67 auto position = getPosition<T,PARTICLETYPE>( particle );
68 for (int iDim=0; iDim<PARTICLETYPE::d; ++iDim) {
69 T distToLowerBound = (position[iDim] - radius) - domainMin[iDim];
70 T distToUpperBound = domainMax[iDim] - (position[iDim] + radius);
72 if ( distToLowerBound <= 0. ) {
73 normal[iDim] = 1.;
74 boundTreatment(iDim, normal, distToLowerBound);
75 }
76 if ( distToUpperBound <= 0. ) {
77 normal[iDim] = -1.;
78 boundTreatment(iDim, normal, distToUpperBound);
79 }
80 }
81}
82
83template<typename T, typename PARTICLETYPE>
85 Vector<T,PARTICLETYPE::d> positionPre, int iDir )
86{
87 using namespace descriptors;
88 const unsigned D = PARTICLETYPE::d;
89 Vector<T,D> position( particle.template getField<GENERAL,POSITION>() );
90 Vector<T,D> velocity( particle.template getField<MOBILITY,VELOCITY>() );
91 position[iDir] = positionPre[iDir];
92 velocity[iDir] = 0.;
93 particle.template setField<GENERAL,POSITION>( position );
94 particle.template setField<MOBILITY,VELOCITY>( velocity );
95}
96
97template<typename T, typename PARTICLETYPE>
99 Vector<T,PARTICLETYPE::d> positionPre,
102{
103 using namespace descriptors;
104 const unsigned D = PARTICLETYPE::d;
106 particle.template setField<GENERAL,POSITION>( positionPre );
107 particle.template setField<MOBILITY,VELOCITY>( Vector<T,D>(0.) );
108 if constexpr ( PARTICLETYPE::template providesNested<SURFACE,ANGLE>() ) {
109 particle.template setField<SURFACE,ANGLE>( anglePre );
110 particle.template setField<MOBILITY,ANG_VELOCITY>( Vector<T,Drot>(0.) );
111 }
112}
113
114//TODO: remove in favour of ParametersD
115template<typename T, typename PARTICLETYPE>
128
129template<typename T, typename PARTICLETYPE>
149
150template <typename T, typename PARTICLETYPE>
151using DynState = std::conditional_t<
152 PARTICLETYPE::template providesNested<descriptors::SURFACE,descriptors::ANGLE>(),
155>;
156
157} //namespace dynamics
158
159} //namespace particles
160
161} //namespace olb
162
163#endif
Plain old scalar vector.
Definition vector.h:47
void resetMovement(Particle< T, PARTICLETYPE > &particle, Vector< T, PARTICLETYPE::d > positionPre, Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation > anglePre=Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation >(0.))
std::conditional_t< PARTICLETYPE::template providesNested< descriptors::SURFACE, descriptors::ANGLE >(), ParticleDynamicStateAngle< T, PARTICLETYPE >, ParticleDynamicStateNoAngle< T, PARTICLETYPE > > DynState
void resetDirection(Particle< T, PARTICLETYPE > &particle, Vector< T, PARTICLETYPE::d > positionPre, int iDir)
void updateRotationMatrix(Particle< T, PARTICLETYPE > &particle)
void doAtCubicBoundPenetration(Particle< T, PARTICLETYPE > &particle, Vector< T, PARTICLETYPE::d > domainMin, Vector< T, PARTICLETYPE::d > domainMax, F boundTreatment)
Helper functions.
Top level namespace for all of OpenLB.
Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation > angle
ParticleDynamicStateAngle(Vector< T, PARTICLETYPE::d > position, Vector< T, utilities::dimensions::convert< PARTICLETYPE::d >::rotation > angle)
ParticleDynamicStateAngle(Vector< T, PARTICLETYPE::d > position)
ParticleDynamicStateNoAngle(Vector< T, PARTICLETYPE::d > position)
Converts dimensions by deriving from given cartesian dimension D.