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 "waveTransmissiveFvPatchField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
43 const DimensionedField<Type, volMesh>& iF
46 advectiveFvPatchField<Type>(p, iF),
54 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
57 const DimensionedField<Type, volMesh>& iF,
58 const dictionary& dict
61 advectiveFvPatchField<Type>(p, iF, dict),
62 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
63 UName_(dict.lookupOrDefault<word>("U", "U")),
64 gamma_(readScalar(dict.lookup("gamma")))
69 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
71 const waveTransmissiveFvPatchField& ptf,
73 const DimensionedField<Type, volMesh>& iF,
74 const fvPatchFieldMapper& mapper
77 advectiveFvPatchField<Type>(ptf, p, iF, mapper),
78 psiName_(ptf.psiName_),
85 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
87 const waveTransmissiveFvPatchField& ptpsf
90 advectiveFvPatchField<Type>(ptpsf),
91 psiName_(ptpsf.psiName_),
98 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
100 const waveTransmissiveFvPatchField& ptpsf,
101 const DimensionedField<Type, volMesh>& iF
104 advectiveFvPatchField<Type>(ptpsf, iF),
105 psiName_(ptpsf.psiName_),
106 UName_(ptpsf.UName_),
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
116 // Lookup the velocity and compressibility of the patch
117 const fvPatchField<scalar>& psip = this->patch().lookupPatchField
120 reinterpret_cast<const volScalarField*>(0),
121 reinterpret_cast<const scalar*>(0)
124 const surfaceScalarField& phi =
125 this->db().objectRegistry::lookupObject<surfaceScalarField>
128 fvsPatchField<scalar> phip = this->patch().lookupPatchField
131 reinterpret_cast<const surfaceScalarField*>(0),
132 reinterpret_cast<const scalar*>(0)
135 if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
137 const fvPatchScalarField& rhop = this->patch().lookupPatchField
140 reinterpret_cast<const volScalarField*>(0),
141 reinterpret_cast<const scalar*>(0)
147 // Calculate the speed of the field wave w
148 // by summing the component of the velocity normal to the boundary
149 // and the speed of sound (sqrt(gamma_/psi)).
150 return phip/this->patch().magSf() + sqrt(gamma_/psip);
155 tmp<scalarField> waveTransmissiveFvPatchField<Type>::supercritical() const
157 // Lookup the velocity and compressibility of the patch
158 const fvPatchField<scalar>& psip = this->patch().lookupPatchField
161 reinterpret_cast<const volScalarField*>(NULL),
162 reinterpret_cast<const scalar*>(NULL)
165 const fvPatchVectorField& U =
166 this->patch().lookupPatchField
169 reinterpret_cast<const volVectorField*>(NULL),
170 reinterpret_cast<const vector*>(NULL)
173 // Calculate the speed of the field wave w
174 // by summing the component of the velocity normal to the boundary
175 // and the speed of sound (sqrt(gamma_/psi)).
178 mag(U.patchInternalField() & this->patch().Sf())/this->patch().magSf()
185 void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
187 advectiveFvPatchField<Type>::write(os);
188 if (this->phiName_ != "phi")
190 os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
192 if (this->rhoName_ != "rho")
194 os.writeKeyword("rho") << this->rhoName_ << token::END_STATEMENT << nl;
196 if (this->UName_ != "U")
198 os.writeKeyword("U") << this->UName_ << token::END_STATEMENT << nl;
200 if (psiName_ != "psi")
202 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
205 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
207 if (this->lInf_ > SMALL)
209 os.writeKeyword("fieldInf") << this->fieldInf_
210 << token::END_STATEMENT << nl;
211 os.writeKeyword("lInf") << this->lInf_
212 << token::END_STATEMENT << nl;
215 this->writeEntry("value", os);
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 } // End namespace Foam
223 // ************************************************************************* //