movingWallVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "fvcMeshPhi.H"
31 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  fixedValueFvPatchVectorField(p, iF),
43  UName_("U")
44 {}
45 
46 
49 (
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
57  UName_(ptf.UName_)
58 {}
59 
60 
63 (
64  const fvPatch& p,
66  const dictionary& dict
67 )
68 :
69  fixedValueFvPatchVectorField(p, iF),
70  UName_(dict.lookupOrDefault<word>("U", "U"))
71 {
72  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
73 }
74 
75 
78 (
80 )
81 :
82  fixedValueFvPatchVectorField(mwvpvf),
83  UName_(mwvpvf.UName_)
84 {}
85 
86 
89 (
92 )
93 :
94  fixedValueFvPatchVectorField(mwvpvf, iF),
95  UName_(mwvpvf.UName_)
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  if (updated())
104  {
105  return;
106  }
107 
108  const fvMesh& mesh = dimensionedInternalField().mesh();
109 
110  if (mesh.moving())
111  {
112  const fvPatch& p = patch();
113  const polyPatch& pp = p.patch();
114  const pointField& oldPoints = mesh.oldPoints();
115 
116  vectorField oldFc(pp.size());
117 
118  forAll(oldFc, i)
119  {
120  oldFc[i] = pp[i].centre(oldPoints);
121  }
122 
123  const scalar deltaT = mesh.time().deltaTValue();
124 
125  const vectorField Up((pp.faceCentres() - oldFc)/deltaT);
126 
127  const volVectorField& U = db().lookupObject<volVectorField>(UName_);
128  scalarField phip
129  (
130  p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U))
131  );
132 
133  const vectorField n(p.nf());
134  const scalarField& magSf = p.magSf();
135  tmp<scalarField> Un = phip/(magSf + VSMALL);
136 
137 
138  vectorField::operator=(Up + n*(Un - (n & Up)));
139  }
140 
141  fixedValueFvPatchVectorField::updateCoeffs();
142 }
143 
144 
146 {
148  writeEntryIfDifferent<word>(os, "U", "U", UName_);
149  writeEntry("value", os);
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 namespace Foam
156 {
158  (
161  );
162 }
163 
164 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
fvcMeshPhi.H
Calculate the mesh motion flux and convert fluxes from absolute to relative and back.
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::fvc::meshPhi
tmp< surfaceScalarField > meshPhi(const volVectorField &U)
Definition: fvcMeshPhi.C:33
surfaceFields.H
Foam::surfaceFields.
movingWallVelocityFvPatchVectorField.H
U
U
Definition: pEqn.H:46
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::movingWallVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: movingWallVelocityFvPatchVectorField.C:145
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::movingWallVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: movingWallVelocityFvPatchVectorField.C:101
vectorField
volVectorField vectorField(fieldObject, mesh)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::Field::operator=
void operator=(const Field< Type > &)
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:308
Foam::movingWallVelocityFvPatchVectorField
This boundary condition provides a velocity condition for cases with moving walls....
Definition: movingWallVelocityFvPatchVectorField.H:86
Foam::movingWallVelocityFvPatchVectorField::movingWallVelocityFvPatchVectorField
movingWallVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: movingWallVelocityFvPatchVectorField.C:37
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::movingWallVelocityFvPatchVectorField::UName_
word UName_
Name of velocity field.
Definition: movingWallVelocityFvPatchVectorField.H:93