maxwellSlipUFvPatchVectorField.C 7.02 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2015 OpenFOAM Foundation
9
    Copyright (C) 2020 OpenCFD Ltd.
10
11
12
13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14
15
16
17
    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.
18
19
20
21
22
23
24

    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
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26
27
28
29
30

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

#include "maxwellSlipUFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
31
#include "mathematicalConstants.H"
32
33
#include "fvPatchFieldMapper.H"
#include "volFields.H"
34
#include "fvcGrad.H"
35
36
37

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

andy's avatar
andy committed
38
Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
39
40
41
42
43
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
44
    partialSlipFvPatchVectorField(p, iF),
andy's avatar
andy committed
45
46
47
48
49
    TName_("T"),
    rhoName_("rho"),
    psiName_("thermo:psi"),
    muName_("thermo:mu"),
    tauMCName_("tauMC"),
50
    accommodationCoeff_(1.0),
51
    Uwall_(p.size(), Zero),
52
53
54
55
56
    thermalCreep_(true),
    curvature_(true)
{}


andy's avatar
andy committed
57
Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
58
(
andy's avatar
andy committed
59
    const maxwellSlipUFvPatchVectorField& mspvf,
60
61
62
63
64
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
65
    partialSlipFvPatchVectorField(mspvf, p, iF, mapper),
andy's avatar
andy committed
66
67
68
69
70
71
72
73
74
    TName_(mspvf.TName_),
    rhoName_(mspvf.rhoName_),
    psiName_(mspvf.psiName_),
    muName_(mspvf.muName_),
    tauMCName_(mspvf.tauMCName_),
    accommodationCoeff_(mspvf.accommodationCoeff_),
    Uwall_(mspvf.Uwall_),
    thermalCreep_(mspvf.thermalCreep_),
    curvature_(mspvf.curvature_)
75
76
77
{}


andy's avatar
andy committed
78
Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
79
80
81
82
83
84
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
85
    partialSlipFvPatchVectorField(p, iF),
86
87
88
89
90
    TName_(dict.getOrDefault<word>("T", "T")),
    rhoName_(dict.getOrDefault<word>("rho", "rho")),
    psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
    muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
    tauMCName_(dict.getOrDefault<word>("tauMC", "tauMC")),
91
    accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
92
    Uwall_("Uwall", dict, p.size()),
93
94
    thermalCreep_(dict.getOrDefault("thermalCreep", true)),
    curvature_(dict.getOrDefault("curvature", true))
95
96
97
98
{
    if
    (
        mag(accommodationCoeff_) < SMALL
99
     || mag(accommodationCoeff_) > 2.0
100
101
    )
    {
102
103
        FatalIOErrorInFunction(dict)
            << "unphysical accommodationCoeff_ specified"
104
            << "(0 < accommodationCoeff_ <= 1)" << endl
105
            << exit(FatalIOError);
106
107
108
109
110
111
112
113
    }

    if (dict.found("value"))
    {
        fvPatchField<vector>::operator=
        (
            vectorField("value", dict, p.size())
        );
114

115
116
117
        if (dict.found("refValue") && dict.found("valueFraction"))
        {
            this->refValue() = vectorField("refValue", dict, p.size());
andy's avatar
andy committed
118
            this->valueFraction() =
119
120
121
122
123
                scalarField("valueFraction", dict, p.size());
        }
        else
        {
            this->refValue() = *this;
124
            this->valueFraction() = scalar(1);
125
        }
126
127
128
129
    }
}


andy's avatar
andy committed
130
Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
131
(
andy's avatar
andy committed
132
    const maxwellSlipUFvPatchVectorField& mspvf,
133
134
135
    const DimensionedField<vector, volMesh>& iF
)
:
136
    partialSlipFvPatchVectorField(mspvf, iF),
andy's avatar
andy committed
137
138
139
140
141
142
143
144
145
    TName_(mspvf.TName_),
    rhoName_(mspvf.rhoName_),
    psiName_(mspvf.psiName_),
    muName_(mspvf.muName_),
    tauMCName_(mspvf.tauMCName_),
    accommodationCoeff_(mspvf.accommodationCoeff_),
    Uwall_(mspvf.Uwall_),
    thermalCreep_(mspvf.thermalCreep_),
    curvature_(mspvf.curvature_)
146
147
148
149
150
{}


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

andy's avatar
andy committed
151
void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
152
153
154
155
156
157
158
{
    if (updated())
    {
        return;
    }

    const fvPatchScalarField& pmu =
andy's avatar
andy committed
159
        patch().lookupPatchField<volScalarField, scalar>(muName_);
160
    const fvPatchScalarField& prho =
andy's avatar
andy committed
161
        patch().lookupPatchField<volScalarField, scalar>(rhoName_);
162
    const fvPatchField<scalar>& ppsi =
andy's avatar
andy committed
163
        patch().lookupPatchField<volScalarField, scalar>(psiName_);
164

165
166
167
168
169
    Field<scalar> C1
    (
        sqrt(ppsi*constant::mathematical::piByTwo)
      * (2.0 - accommodationCoeff_)/accommodationCoeff_
    );
170

171
    Field<scalar> pnu(pmu/prho);
172
173
174
175
    valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));

    refValue() = Uwall_;

176
    if (thermalCreep_)
177
    {
mattijs's avatar
mattijs committed
178
        const volScalarField& vsfT =
andy's avatar
andy committed
179
            this->db().objectRegistry::lookupObject<volScalarField>(TName_);
180
181
        label patchi = this->patch().index();
        const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
182
183
        Field<vector> gradpT(fvc::grad(vsfT)().boundaryField()[patchi]);
        vectorField n(patch().nf());
184
185
186
187

        refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
    }

188
    if (curvature_)
189
190
    {
        const fvPatchTensorField& ptauMC =
andy's avatar
andy committed
191
            patch().lookupPatchField<volTensorField, tensor>(tauMCName_);
192
        vectorField n(patch().nf());
193
194
195
196

        refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
    }

197
    partialSlipFvPatchVectorField::updateCoeffs();
198
199
200
}


andy's avatar
andy committed
201
void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
202
203
{
    fvPatchVectorField::write(os);
204
205
206
207
208
209
210
    os.writeEntryIfDifferent<word>("T", "T", TName_);
    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
    os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
    os.writeEntryIfDifferent<word>("tauMC", "tauMC", tauMCName_);

    os.writeEntry("accommodationCoeff", accommodationCoeff_);
211
    Uwall_.writeEntry("Uwall", os);
212
213
    os.writeEntry("thermalCreep", thermalCreep_);
    os.writeEntry("curvature", curvature_);
214

215
216
    refValue().writeEntry("refValue", os);
    valueFraction().writeEntry("valueFraction", os);
217
218
219
220
221
222
223

    writeEntry("value", os);
}


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

andy's avatar
andy committed
224
225
226
227
228
229
230
231
namespace Foam
{
    makePatchTypeField
    (
        fvPatchVectorField,
        maxwellSlipUFvPatchVectorField
    );
}
232
233

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