NonInertialFrameForce.C 5.34 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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 3 of the License, or
    (at your option) any later version.

    OpenFOAM 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 OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "NonInertialFrameForce.H"
#include "uniformDimensionedFields.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
    CloudType& owner,
    const fvMesh& mesh,
andy's avatar
andy committed
36
    const dictionary& dict
37
38
)
:
andy's avatar
andy committed
39
    ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
40
41
42
43
44
45
46
47
    WName_
    (
        this->coeffs().template lookupOrDefault<word>
        (
            "linearAccelerationName",
            "linearAcceleration"
        )
    ),
Henry Weller's avatar
Henry Weller committed
48
    W_(Zero),
49
    omegaName_
50
51
52
    (
        this->coeffs().template lookupOrDefault<word>
        (
53
54
            "angularVelocityName",
            "angularVelocity"
55
56
        )
    ),
Henry Weller's avatar
Henry Weller committed
57
    omega_(Zero),
58
59
60
61
62
63
64
65
    omegaDotName_
    (
        this->coeffs().template lookupOrDefault<word>
        (
            "angularAccelerationName",
            "angularAcceleration"
        )
    ),
Henry Weller's avatar
Henry Weller committed
66
    omegaDot_(Zero),
67
    centreOfRotationName_
68
69
70
    (
        this->coeffs().template lookupOrDefault<word>
        (
71
72
            "centreOfRotationName",
            "centreOfRotation"
73
74
        )
    ),
Henry Weller's avatar
Henry Weller committed
75
    centreOfRotation_(Zero)
76
77
78
79
80
81
82
83
84
85
86
87
{}


template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::NonInertialFrameForce
(
    const NonInertialFrameForce& niff
)
:
    ParticleForce<CloudType>(niff),
    WName_(niff.WName_),
    W_(niff.W_),
88
89
    omegaName_(niff.omegaName_),
    omega_(niff.omega_),
90
91
    omegaDotName_(niff.omegaDotName_),
    omegaDot_(niff.omegaDot_),
92
93
    centreOfRotationName_(niff.centreOfRotationName_),
    centreOfRotation_(niff.centreOfRotation_)
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{}


// * * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //

template<class CloudType>
Foam::NonInertialFrameForce<CloudType>::~NonInertialFrameForce()
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class CloudType>
void Foam::NonInertialFrameForce<CloudType>::cacheFields(const bool store)
{
Henry Weller's avatar
Henry Weller committed
109
110
111
112
    W_ = Zero;
    omega_ = Zero;
    omegaDot_ = Zero;
    centreOfRotation_ = Zero;
113
114
115
116
117

    if (store)
    {
        if
        (
118
119
120
121
            this->mesh().template foundObject<uniformDimensionedVectorField>
            (
                WName_
            )
122
123
        )
        {
124
            const uniformDimensionedVectorField& W = this->mesh().template
125
                lookupObject<uniformDimensionedVectorField>(WName_);
126

127
128
            W_ = W.value();
        }
129

130
131
132
        if
        (
            this->mesh().template foundObject<uniformDimensionedVectorField>
133
            (
134
                omegaName_
135
            )
136
137
        )
        {
138
            const uniformDimensionedVectorField& omega = this->mesh().template
139
                lookupObject<uniformDimensionedVectorField>(omegaName_);
140

141
            omega_ = omega.value();
142
143
144
145
        }

        if
        (
146
147
148
149
            this->mesh().template foundObject<uniformDimensionedVectorField>
            (
                omegaDotName_
            )
150
151
        )
        {
152
153
            const uniformDimensionedVectorField& omegaDot =
                this->mesh().template
154
                lookupObject<uniformDimensionedVectorField>(omegaDotName_);
155

156
            omegaDot_ = omegaDot.value();
157
        }
158
159
160
161

        if
        (
            this->mesh().template foundObject<uniformDimensionedVectorField>
162
            (
163
164
165
166
                centreOfRotationName_
            )
        )
        {
167
            const uniformDimensionedVectorField& centreOfRotation =
graham's avatar
graham committed
168
                this->mesh().template
169
170
171
172
173
                lookupObject<uniformDimensionedVectorField>
                (
                    centreOfRotationName_
                );

graham's avatar
graham committed
174
            centreOfRotation_ = centreOfRotation.value();
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
        }
    }
}


template<class CloudType>
Foam::forceSuSp Foam::NonInertialFrameForce<CloudType>::calcNonCoupled
(
    const typename CloudType::parcelType& p,
    const scalar dt,
    const scalar mass,
    const scalar Re,
    const scalar muc
) const
{
Henry Weller's avatar
Henry Weller committed
190
    forceSuSp value(Zero, 0.0);
191

graham's avatar
graham committed
192
    const vector r = p.position() - centreOfRotation_;
193

194
195
196
197
198
199
200
201
    value.Su() =
        mass
       *(
           -W_
          + (r ^ omegaDot_)
          + 2.0*(p.U() ^ omega_)
          + (omega_ ^ (r ^ omega_))
        );
202
203
204
205
206
207

    return value;
}


// ************************************************************************* //