OpenLB 1.7
Loading...
Searching...
No Matches
latticeFrameChangeF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2013, 2015 Gilles Zahnd, Mathias J. Krause
4 * Marie-Luise Maier
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef LATTICE_FRAME_CHANGE_F_3D_HH
26#define LATTICE_FRAME_CHANGE_F_3D_HH
27
28#include<cmath>
29
32#include "core/superLattice.h"
33#include "dynamics/lbm.h" // for computation of lattice rho and velocity
34#include "utilities/vectorHelpers.h" // for normalize
36
37namespace olb {
38
39
40template <typename T, typename DESCRIPTOR>
42(SuperLattice<T,DESCRIPTOR>& sLattice_, SuperGeometry<T,3>& superGeometry_,
43 const UnitConverter<T,DESCRIPTOR>& converter_, std::vector<T> axisPoint_,
44 std::vector<T> axisDirection_, T w_, bool centrifugeForceOn_,
45 bool coriolisForceOn_)
46 : SuperLatticeF3D<T,DESCRIPTOR>(sLattice_,3), sg(superGeometry_),
47 converter(converter_), axisPoint(axisPoint_), axisDirection(axisDirection_),
48 w(w_), centrifugeForceOn(centrifugeForceOn_), coriolisForceOn(coriolisForceOn_),
49 velocity(sLattice_,converter_), rho(sLattice_)
50{
51 this->getName() = "rotatingForce";
52}
53
54
55template <typename T, typename DESCRIPTOR>
57{
58 std::vector<T> F_centri(3,0);
59 std::vector<T> F_coriolis(3,0);
60
61 if ( this->_sLattice.getLoadBalancer().rank(x[0]) == singleton::mpi().getRank() ) {
62 // local coords are given, fetch local cell and compute value(s)
63 std::vector<T> physR(3,T());
64 this->sg.getCuboidGeometry().getPhysR(&(physR[0]),&(x[0]));
65
66 T scalar = (physR[0]-axisPoint[0])*axisDirection[0]
67 +(physR[1]-axisPoint[1])*axisDirection[1]
68 +(physR[2]-axisPoint[2])*axisDirection[2];
69
70 if (centrifugeForceOn) {
71 F_centri[0] = w*w*(physR[0]-axisPoint[0]-scalar*axisDirection[0]);
72 F_centri[1] = w*w*(physR[1]-axisPoint[1]-scalar*axisDirection[1]);
73 F_centri[2] = w*w*(physR[2]-axisPoint[2]-scalar*axisDirection[2]);
74 }
75 if (coriolisForceOn) {
76 T _vel[3];
77 (velocity)(_vel,x);
78 F_coriolis[0] = -2*w*(axisDirection[1]*_vel[2]-axisDirection[2]*_vel[1]);
79 F_coriolis[1] = -2*w*(axisDirection[2]*_vel[0]-axisDirection[0]*_vel[2]);
80 F_coriolis[2] = -2*w*(axisDirection[0]*_vel[1]-axisDirection[1]*_vel[0]);
81 }
82 // return latticeForce
83 output[0] = (F_coriolis[0]+F_centri[0]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
84 output[1] = (F_coriolis[1]+F_centri[1]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
85 output[2] = (F_coriolis[2]+F_centri[2]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
86 }
87 return true;
88}
89
90
91template <typename T, typename DESCRIPTOR>
93(SuperLattice<T,DESCRIPTOR>& sLattice_, SuperGeometry<T,3>& superGeometry_,
94 const UnitConverter<T,DESCRIPTOR>& converter_, std::vector<T> axisPoint_,
95 std::vector<T> axisDirection_, T amplitude_, T frequency_)
96 : SuperLatticeF3D<T,DESCRIPTOR>(sLattice_,3), sg(superGeometry_),
97 converter(converter_), axisPoint(axisPoint_), axisDirection(axisDirection_),
98 amplitude(amplitude_), resonanceFrequency(2.*4.*util::atan(1.0)*frequency_), w(0.0), dwdt(0.0),
99 velocity(sLattice_,converter_)
100{
101 this->getName() = "harmonicOscillatingrotatingForce";
102}
103
104template <typename T, typename DESCRIPTOR>
106{
107 w = resonanceFrequency * amplitude * util::cos(resonanceFrequency*converter.getPhysTime(iT));
108 dwdt = -resonanceFrequency * resonanceFrequency * amplitude * util::sin(resonanceFrequency*converter.getPhysTime(iT));
109}
110
111
112template <typename T, typename DESCRIPTOR>
114{
115
116
117 std::vector<T> F_centri(3,0);
118 std::vector<T> F_coriolis(3,0);
119 std::vector<T> F_euler(3,0);
120
121 if ( this->_sLattice.getLoadBalancer().rank(x[0]) == singleton::mpi().getRank() ) {
122 // local coords are given, fetch local cell and compute value(s)
123 std::vector<T> physR(3,T());
124 this->sg.getCuboidGeometry().getPhysR(&(physR[0]),&(x[0]));
125
126 T scalar = (physR[0]-axisPoint[0])*axisDirection[0]
127 +(physR[1]-axisPoint[1])*axisDirection[1]
128 +(physR[2]-axisPoint[2])*axisDirection[2];
129
130 T r[3];
131 r[0] = physR[0]-axisPoint[0]-scalar*axisDirection[0];
132 r[1] = physR[1]-axisPoint[1]-scalar*axisDirection[1];
133 r[2] = physR[2]-axisPoint[2]-scalar*axisDirection[2];
134
135 F_centri[0] = w*w*(r[0]);
136 F_centri[1] = w*w*(r[1]);
137 F_centri[2] = w*w*(r[2]);
138
139 T _vel[3];
140 (velocity)(_vel,x);
141 F_coriolis[0] = -2*w*(axisDirection[1]*_vel[2]-axisDirection[2]*_vel[1]);
142 F_coriolis[1] = -2*w*(axisDirection[2]*_vel[0]-axisDirection[0]*_vel[2]);
143 F_coriolis[2] = -2*w*(axisDirection[0]*_vel[1]-axisDirection[1]*_vel[0]);
144
145 F_euler[0] = -dwdt*(axisDirection[1]*r[2]-axisDirection[2]*r[1]);
146 F_euler[1] = -dwdt*(axisDirection[2]*r[0]-axisDirection[0]*r[2]);
147 F_euler[2] = -dwdt*(axisDirection[0]*r[1]-axisDirection[1]*r[0]);
148
149
150 // return latticeForce
151 output[0] = (F_coriolis[0]+F_centri[0]+F_euler[0]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
152 output[1] = (F_coriolis[1]+F_centri[1]+F_euler[1]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
153 output[2] = (F_coriolis[2]+F_centri[2]+F_euler[2]) * converter.getConversionFactorTime() / converter.getConversionFactorVelocity();
154 }
155 return true;
156}
157
158
159} // end namespace olb
160
161#endif
std::string & getName()
read and write access to name
Definition genericF.hh:51
HarmonicOscillatingRotatingForceField3D(SuperLattice< T, DESCRIPTOR > &sLattice_, SuperGeometry< T, 3 > &superGeometry_, const UnitConverter< T, DESCRIPTOR > &converter_, std::vector< T > axisPoint_, std::vector< T > axisDirection_, T amplitude_, T frequency_)
bool operator()(T output[], const int x[]) override
RotatingForceField3D(SuperLattice< T, DESCRIPTOR > &sLattice_, SuperGeometry< T, 3 > &superGeometry_, const UnitConverter< T, DESCRIPTOR > &converter_, std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, bool centrifugeForceOn_=true, bool coriolisForceOn_=true)
bool operator()(T output[], const int x[]) override
Representation of a statistic for a parallel 2D geometry.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
Super class maintaining block lattices for a cuboid decomposition.
Conversion between physical and lattice units, as well as discretization.
int getRank() const
Returns the process ID.
This file contains two different classes of functors, in the FIRST part.
MpiManager & mpi()
ADf< T, DIM > sin(const ADf< T, DIM > &a)
Definition aDiff.h:569
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Definition aDiff.h:578
Top level namespace for all of OpenLB.
Representation of a parallel 2D geometry – header file.