OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

waveTransmissiveFvPatchField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "waveTransmissiveFvPatchField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "EulerDdtScheme.H"
00032 #include "CrankNicholsonDdtScheme.H"
00033 #include "backwardDdtScheme.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 template<class Type>
00043 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
00044 (
00045     const fvPatch& p,
00046     const DimensionedField<Type, volMesh>& iF
00047 )
00048 :
00049     advectiveFvPatchField<Type>(p, iF),
00050     psiName_("psi"),
00051     gamma_(0.0)
00052 {}
00053 
00054 
00055 template<class Type>
00056 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
00057 (
00058     const waveTransmissiveFvPatchField& ptf,
00059     const fvPatch& p,
00060     const DimensionedField<Type, volMesh>& iF,
00061     const fvPatchFieldMapper& mapper
00062 )
00063 :
00064     advectiveFvPatchField<Type>(ptf, p, iF, mapper),
00065     psiName_(ptf.psiName_),
00066     gamma_(ptf.gamma_)
00067 {}
00068 
00069 
00070 template<class Type>
00071 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
00072 (
00073     const fvPatch& p,
00074     const DimensionedField<Type, volMesh>& iF,
00075     const dictionary& dict
00076 )
00077 :
00078     advectiveFvPatchField<Type>(p, iF, dict),
00079     psiName_(dict.lookupOrDefault<word>("psi", "psi")),
00080     gamma_(readScalar(dict.lookup("gamma")))
00081 {}
00082 
00083 
00084 template<class Type>
00085 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
00086 (
00087     const waveTransmissiveFvPatchField& ptpsf
00088 )
00089 :
00090     advectiveFvPatchField<Type>(ptpsf),
00091     psiName_(ptpsf.psiName_),
00092     gamma_(ptpsf.gamma_)
00093 {}
00094 
00095 
00096 template<class Type>
00097 waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
00098 (
00099     const waveTransmissiveFvPatchField& ptpsf,
00100     const DimensionedField<Type, volMesh>& iF
00101 )
00102 :
00103     advectiveFvPatchField<Type>(ptpsf, iF),
00104     psiName_(ptpsf.psiName_),
00105     gamma_(ptpsf.gamma_)
00106 {}
00107 
00108 
00109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00110 
00111 template<class Type>
00112 tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
00113 {
00114     // Lookup the velocity and compressibility of the patch
00115     const fvPatchField<scalar>& psip = this->patch().lookupPatchField
00116     (
00117         psiName_,
00118         reinterpret_cast<const volScalarField*>(0),
00119         reinterpret_cast<const scalar*>(0)
00120     );
00121 
00122     const surfaceScalarField& phi =
00123         this->db().objectRegistry::lookupObject<surfaceScalarField>
00124         (this->phiName_);
00125 
00126     fvsPatchField<scalar> phip = this->patch().lookupPatchField
00127     (
00128         this->phiName_,
00129         reinterpret_cast<const surfaceScalarField*>(0),
00130         reinterpret_cast<const scalar*>(0)
00131     );
00132 
00133     if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00134     {
00135         const fvPatchScalarField& rhop = this->patch().lookupPatchField
00136         (
00137             this->rhoName_,
00138             reinterpret_cast<const volScalarField*>(0),
00139             reinterpret_cast<const scalar*>(0)
00140         );
00141 
00142         phip /= rhop;
00143     }
00144 
00145     // Calculate the speed of the field wave w
00146     // by summing the component of the velocity normal to the boundary
00147     // and the speed of sound (sqrt(gamma_/psi)).
00148     return phip/this->patch().magSf() + sqrt(gamma_/psip);
00149 }
00150 
00151 
00152 template<class Type>
00153 void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
00154 {
00155     fvPatchField<Type>::write(os);
00156 
00157     if (this->phiName_ != "phi")
00158     {
00159         os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
00160     }
00161     if (this->rhoName_ != "rho")
00162     {
00163         os.writeKeyword("rho") << this->rhoName_ << token::END_STATEMENT << nl;
00164     }
00165     if (psiName_ != "psi")
00166     {
00167         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
00168     }
00169     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
00170 
00171     if (this->lInf_ > SMALL)
00172     {
00173         os.writeKeyword("fieldInf") << this->fieldInf_
00174             << token::END_STATEMENT << nl;
00175         os.writeKeyword("lInf") << this->lInf_
00176             << token::END_STATEMENT << nl;
00177     }
00178 
00179     this->writeEntry("value", os);
00180 }
00181 
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 } // End namespace Foam
00186 
00187 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd