initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / waveTransmissive / waveTransmissiveFvPatchField.C
blobd59ade959f30318135c6fd4f9175b7f36bc9b21c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 template<class Type>
43 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
45     const fvPatch& p,
46     const DimensionedField<Type, volMesh>& iF
49     advectiveFvPatchField<Type>(p, iF),
50     psiName_("psi"),
51     gamma_(0.0)
55 template<class Type>
56 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
58     const waveTransmissiveFvPatchField& ptf,
59     const fvPatch& p,
60     const DimensionedField<Type, volMesh>& iF,
61     const fvPatchFieldMapper& mapper
64     advectiveFvPatchField<Type>(ptf, p, iF, mapper),
65     psiName_(ptf.psiName_),
66     gamma_(ptf.gamma_)
70 template<class Type>
71 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
73     const fvPatch& p,
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")))
84 template<class Type>
85 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
87     const waveTransmissiveFvPatchField& ptpsf
90     advectiveFvPatchField<Type>(ptpsf),
91     psiName_(ptpsf.psiName_),
92     gamma_(ptpsf.gamma_)
96 template<class Type>
97 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
99     const waveTransmissiveFvPatchField& ptpsf,
100     const DimensionedField<Type, volMesh>& iF
103     advectiveFvPatchField<Type>(ptpsf, iF),
104     psiName_(ptpsf.psiName_),
105     gamma_(ptpsf.gamma_)
109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
111 template<class Type>
112 tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
114     // Lookup the velocity and compressibility of the patch
115     const fvPatchField<scalar>& psip = this->patch().lookupPatchField
116     (
117         psiName_,
118         reinterpret_cast<const volScalarField*>(0),
119         reinterpret_cast<const scalar*>(0)
120     );
122     const surfaceScalarField& phi =
123         this->db().objectRegistry::lookupObject<surfaceScalarField>
124         (this->phiName_);
126     fvsPatchField<scalar> phip = this->patch().lookupPatchField
127     (
128         this->phiName_,
129         reinterpret_cast<const surfaceScalarField*>(0),
130         reinterpret_cast<const scalar*>(0)
131     );
133     if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
134     {
135         const fvPatchScalarField& rhop = this->patch().lookupPatchField
136         (
137             this->rhoName_,
138             reinterpret_cast<const volScalarField*>(0),
139             reinterpret_cast<const scalar*>(0)
140         );
142         phip /= rhop;
143     }
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);
152 template<class Type>
153 void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
155     fvPatchField<Type>::write(os);
157     if (this->phiName_ != "phi")
158     {
159         os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
160     }
161     if (this->rhoName_ != "rho")
162     {
163         os.writeKeyword("rho") << this->rhoName_ << token::END_STATEMENT << nl;
164     }
165     if (psiName_ != "psi")
166     {
167         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
168     }
169     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
171     if (this->lInf_ > SMALL)
172     {
173         os.writeKeyword("fieldInf") << this->fieldInf_
174             << token::END_STATEMENT << nl;
175         os.writeKeyword("lInf") << this->lInf_
176             << token::END_STATEMENT << nl;
177     }
179     this->writeEntry("value", os);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //