1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "movingWallVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "fvcMeshPhi.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::movingWallVelocityFvPatchVectorField::
36 movingWallVelocityFvPatchVectorField
39 const DimensionedField<vector, volMesh>& iF
42 fixedValueFvPatchVectorField(p, iF),
47 Foam::movingWallVelocityFvPatchVectorField::
48 movingWallVelocityFvPatchVectorField
50 const movingWallVelocityFvPatchVectorField& ptf,
52 const DimensionedField<vector, volMesh>& iF,
53 const fvPatchFieldMapper& mapper
56 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
61 Foam::movingWallVelocityFvPatchVectorField::
62 movingWallVelocityFvPatchVectorField
65 const DimensionedField<vector, volMesh>& iF,
66 const dictionary& dict
69 fixedValueFvPatchVectorField(p, iF),
70 UName_(dict.lookupOrDefault<word>("U", "U"))
72 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
76 Foam::movingWallVelocityFvPatchVectorField::
77 movingWallVelocityFvPatchVectorField
79 const movingWallVelocityFvPatchVectorField& mwvpvf
82 fixedValueFvPatchVectorField(mwvpvf),
87 Foam::movingWallVelocityFvPatchVectorField::
88 movingWallVelocityFvPatchVectorField
90 const movingWallVelocityFvPatchVectorField& mwvpvf,
91 const DimensionedField<vector, volMesh>& iF
94 fixedValueFvPatchVectorField(mwvpvf, iF),
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs()
108 const fvPatch& p = patch();
109 const polyPatch& pp = p.patch();
110 const fvMesh& mesh = dimensionedInternalField().mesh();
111 const pointField& oldPoints = mesh.oldPoints();
113 vectorField oldFc(pp.size());
117 oldFc[i] = pp[i].centre(oldPoints);
120 const vectorField Up((pp.faceCentres() - oldFc)/mesh.time().deltaTValue());
122 const volVectorField& U = db().lookupObject<volVectorField>(UName_);
125 p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U))
128 const vectorField n(p.nf());
129 const scalarField& magSf = p.magSf();
130 tmp<scalarField> Un = phip/(magSf + VSMALL);
133 vectorField::operator=(Up + n*(Un - (n & Up)));
135 fixedValueFvPatchVectorField::updateCoeffs();
139 void Foam::movingWallVelocityFvPatchVectorField::write(Ostream& os) const
141 fvPatchVectorField::write(os);
142 writeEntryIfDifferent<word>(os, "U", "U", UName_);
143 writeEntry("value", os);
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 movingWallVelocityFvPatchVectorField
158 // ************************************************************************* //