1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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"
31 #include "EulerDdtScheme.H"
32 #include "CrankNicholsonDdtScheme.H"
33 #include "backwardDdtScheme.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
46 const DimensionedField<Type, volMesh>& iF
49 advectiveFvPatchField<Type>(p, iF),
56 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
58 const waveTransmissiveFvPatchField& ptf,
60 const DimensionedField<Type, volMesh>& iF,
61 const fvPatchFieldMapper& mapper
64 advectiveFvPatchField<Type>(ptf, p, iF, mapper),
65 psiName_(ptf.psiName_),
71 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
74 const DimensionedField<Type, volMesh>& iF,
75 const dictionary& dict
78 advectiveFvPatchField<Type>(p, iF, dict),
79 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
80 gamma_(readScalar(dict.lookup("gamma")))
85 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
87 const waveTransmissiveFvPatchField& ptpsf
90 advectiveFvPatchField<Type>(ptpsf),
91 psiName_(ptpsf.psiName_),
97 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
99 const waveTransmissiveFvPatchField& ptpsf,
100 const DimensionedField<Type, volMesh>& iF
103 advectiveFvPatchField<Type>(ptpsf, iF),
104 psiName_(ptpsf.psiName_),
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
114 // Lookup the velocity and compressibility of the patch
115 const fvPatchField<scalar>& psip = this->patch().lookupPatchField
118 reinterpret_cast<const volScalarField*>(0),
119 reinterpret_cast<const scalar*>(0)
122 const surfaceScalarField& phi =
123 this->db().objectRegistry::lookupObject<surfaceScalarField>
126 fvsPatchField<scalar> phip = this->patch().lookupPatchField
129 reinterpret_cast<const surfaceScalarField*>(0),
130 reinterpret_cast<const scalar*>(0)
133 if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
135 const fvPatchScalarField& rhop = this->patch().lookupPatchField
138 reinterpret_cast<const volScalarField*>(0),
139 reinterpret_cast<const scalar*>(0)
145 // Calculate the speed of the field wave w
146 // by summing the component of the velocity normal to the boundary
147 // and the speed of sound (sqrt(gamma_/psi)).
148 return phip/this->patch().magSf() + sqrt(gamma_/psip);
153 void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
155 fvPatchField<Type>::write(os);
157 if (this->phiName_ != "phi")
159 os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
161 if (this->rhoName_ != "rho")
163 os.writeKeyword("rho") << this->rhoName_ << token::END_STATEMENT << nl;
165 if (psiName_ != "psi")
167 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
169 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
171 if (this->lInf_ > SMALL)
173 os.writeKeyword("fieldInf") << this->fieldInf_
174 << token::END_STATEMENT << nl;
175 os.writeKeyword("lInf") << this->lInf_
176 << token::END_STATEMENT << nl;
179 this->writeEntry("value", os);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //