1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "movingWallVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "fvcMeshPhi.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
43 const DimensionedField<vector, volMesh>& iF
46 fixedValueFvPatchVectorField(p, iF)
50 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
52 const movingWallVelocityFvPatchVectorField& ptf,
54 const DimensionedField<vector, volMesh>& iF,
55 const fvPatchFieldMapper& mapper
58 fixedValueFvPatchVectorField(ptf, p, iF, mapper)
62 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
65 const DimensionedField<vector, volMesh>& iF,
66 const dictionary& dict
69 fixedValueFvPatchVectorField(p, iF)
71 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
75 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
77 const movingWallVelocityFvPatchVectorField& pivpvf
80 fixedValueFvPatchVectorField(pivpvf)
84 movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
86 const movingWallVelocityFvPatchVectorField& pivpvf,
87 const DimensionedField<vector, volMesh>& iF
90 fixedValueFvPatchVectorField(pivpvf, iF)
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 void movingWallVelocityFvPatchVectorField::updateCoeffs()
103 const fvPatch& p = patch();
104 const polyPatch& pp = p.patch();
105 const fvMesh& mesh = dimensionedInternalField().mesh();
106 const pointField& oldPoints = mesh.oldPoints();
108 vectorField oldFc(pp.size());
112 oldFc[i] = pp[i].centre(oldPoints);
115 vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaT().value();
117 const volVectorField& U =
118 mesh.lookupObject<volVectorField>(dimensionedInternalField().name());
121 p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U));
123 vectorField n = p.nf();
124 const scalarField& magSf = p.magSf();
125 scalarField Un = phip/(magSf + VSMALL);
128 vectorField::operator=(Up + n*(Un - (n & Up)));
130 fixedValueFvPatchVectorField::updateCoeffs();
134 void movingWallVelocityFvPatchVectorField::write(Ostream& os) const
136 fvPatchVectorField::write(os);
137 writeEntry("value", os);
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 movingWallVelocityFvPatchVectorField
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // ************************************************************************* //