dynLagrangian.C 4.58 KB
Newer Older
sergio's avatar
sergio committed
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
sergio's avatar
sergio committed
6
7
8
9
10
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

11
12
13
14
    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.
sergio's avatar
sergio committed
15
16
17
18
19
20
21

    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
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
sergio's avatar
sergio committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

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

#include "dynLagrangian.H"
#include "addToRunTimeSelectionTable.H"

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

namespace Foam
{
namespace incompressible
{
namespace LESModels
{

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(dynLagrangian, 0);
addToRunTimeSelectionTable(LESModel, dynLagrangian, dictionary);

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

void dynLagrangian::updateSubGridScaleFields
(
    const tmp<volTensorField>& gradU
)
{
50
    nuSgs_ = (flm_/fmm_)*sqr(delta())*mag(dev(symm(gradU)));
sergio's avatar
sergio committed
51
52
53
54
55
56
57
58
59
60
    nuSgs_.correctBoundaryConditions();
}


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

dynLagrangian::dynLagrangian
(
    const volVectorField& U,
    const surfaceScalarField& phi,
61
    transportModel& transport,
62
63
    const word& turbulenceModelName,
    const word& modelName
sergio's avatar
sergio committed
64
65
)
:
66
    LESModel(modelName, U, phi, transport, turbulenceModelName),
sergio's avatar
sergio committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
    GenEddyVisc(U, phi, transport),

    flm_
    (
        IOobject
        (
            "flm",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_
    ),
    fmm_
    (
        IOobject
        (
            "fmm",
            runTime_.timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_
    ),
    theta_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "theta",
            coeffDict_,
            1.5
        )
    ),
    simpleFilter_(U.mesh()),
    filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
    filter_(filterPtr_()),
    flm0_("flm0", flm_.dimensions(), 0.0),
    fmm0_("fmm0", fmm_.dimensions(), VSMALL)
{
    updateSubGridScaleFields(fvc::grad(U));

    printCoeffs();
}


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

void dynLagrangian::correct(const tmp<volTensorField>& gradU)
{
    LESModel::correct(gradU);

120
    volSymmTensorField S(dev(symm(gradU())));
sergio's avatar
sergio committed
121

122
    volScalarField magS(mag(S));
sergio's avatar
sergio committed
123

124
    volVectorField Uf(filter_(U()));
sergio's avatar
sergio committed
125

126
    volSymmTensorField Sf(dev(symm(fvc::grad(Uf))));
sergio's avatar
sergio committed
127

128
    volScalarField magSf(mag(Sf));
sergio's avatar
sergio committed
129

130
    volSymmTensorField L(dev(filter_(sqr(U())) - (sqr(filter_(U())))));
sergio's avatar
sergio committed
131

132
    volSymmTensorField M(2.0*sqr(delta())*(filter_(magS*S) - 4.0*magSf*Sf));
sergio's avatar
sergio committed
133

134
135
136
137
    volScalarField invT
    (
        (1.0/(theta_.value()*delta()))*pow(flm_*fmm_, 1.0/8.0)
    );
sergio's avatar
sergio committed
138

139
    volScalarField LM(L && M);
sergio's avatar
sergio committed
140
141
142

    fvScalarMatrix flmEqn
    (
143
144
145
146
147
        fvm::ddt(flm_)
      + fvm::div(phi(), flm_)
     ==
        invT*LM
      - fvm::Sp(invT, flm_)
sergio's avatar
sergio committed
148
149
150
151
152
153
154
    );

    flmEqn.relax();
    flmEqn.solve();

    bound(flm_, flm0_);

155
    volScalarField MM(M && M);
sergio's avatar
sergio committed
156
157
158

    fvScalarMatrix fmmEqn
    (
159
160
161
162
163
        fvm::ddt(fmm_)
      + fvm::div(phi(), fmm_)
     ==
        invT*MM
      - fvm::Sp(invT, fmm_)
sergio's avatar
sergio committed
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
    );

    fmmEqn.relax();
    fmmEqn.solve();

    bound(fmm_, fmm0_);

    updateSubGridScaleFields(gradU);
}


bool dynLagrangian::read()
{
    if (GenEddyVisc::read())
    {
        filter_.read(coeffDict());
        theta_.readIfPresent(coeffDict());

        return true;
    }
    else
    {
        return false;
    }
}


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

} // End namespace LESModels
} // End namespace incompressible
} // End namespace Foam

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