rotatingPressureInletOutletVelocityFvPatchVectorField.C 4.42 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
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9
    Copyright (C) 2017-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 31 32 33 34 35

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

#include "rotatingPressureInletOutletVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "surfaceFields.H"

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

36
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
37 38
calcTangentialVelocity()
{
39
    const scalar t = this->db().time().timeOutputValue();
40 41 42
    vector om = omega_->value(t);

    vector axisHat = om/mag(om);
Henry's avatar
Henry committed
43 44 45 46
    const vectorField tangentialVelocity
    (
        (-om) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()))
    );
47

48
    const vectorField n(patch().nf());
Henry's avatar
Henry committed
49
    refValue() = tangentialVelocity - n*(n & tangentialVelocity);
50 51 52 53 54
}


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

55
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
56 57 58 59 60 61 62
rotatingPressureInletOutletVelocityFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF
)
:
    pressureInletOutletVelocityFvPatchVectorField(p, iF),
63
    omega_()
64 65 66
{}


67
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
68 69 70 71 72 73 74 75 76
rotatingPressureInletOutletVelocityFvPatchVectorField
(
    const rotatingPressureInletOutletVelocityFvPatchVectorField& ptf,
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper),
77
    omega_(ptf.omega_.clone())
Henry's avatar
Henry committed
78 79 80
{
    calcTangentialVelocity();
}
81 82


83
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
84 85 86 87 88 89 90 91
rotatingPressureInletOutletVelocityFvPatchVectorField
(
    const fvPatch& p,
    const DimensionedField<vector, volMesh>& iF,
    const dictionary& dict
)
:
    pressureInletOutletVelocityFvPatchVectorField(p, iF, dict),
Henry Weller's avatar
Henry Weller committed
92
    omega_(Function1<vector>::New("omega", dict))
Henry's avatar
Henry committed
93
{
94
    patchType() = dict.getOrDefault<word>("patchType", word::null);
Henry's avatar
Henry committed
95 96
    calcTangentialVelocity();
}
97 98


99
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
100 101
rotatingPressureInletOutletVelocityFvPatchVectorField
(
102
    const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf
103 104
)
:
105
    pressureInletOutletVelocityFvPatchVectorField(rppvf),
106
    omega_(rppvf.omega_.clone())
Henry's avatar
Henry committed
107 108 109
{
    calcTangentialVelocity();
}
110 111


112
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
113 114
rotatingPressureInletOutletVelocityFvPatchVectorField
(
115
    const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf,
116 117 118
    const DimensionedField<vector, volMesh>& iF
)
:
119
    pressureInletOutletVelocityFvPatchVectorField(rppvf, iF),
120
    omega_(rppvf.omega_.clone())
121 122
{
    calcTangentialVelocity();
123
}
124 125


Henry's avatar
Henry committed
126 127
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

128 129 130 131
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write
(
    Ostream& os
) const
132 133
{
    fvPatchVectorField::write(os);
134
    os.writeEntry("phi", phiName());
135
    omega_->writeData(os);
136 137 138 139 140 141
    writeEntry("value", os);
}


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

142 143
namespace Foam
{
144
    makePatchTypeField
145 146 147 148 149
    (
        fvPatchVectorField,
        rotatingPressureInletOutletVelocityFvPatchVectorField
    );
}
150 151

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