FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

cyclicFvPatchField.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <finiteVolume/cyclicFvPatchField.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 template<class Type>
00036 cyclicFvPatchField<Type>::cyclicFvPatchField
00037 (
00038     const fvPatch& p,
00039     const DimensionedField<Type, volMesh>& iF
00040 )
00041 :
00042     coupledFvPatchField<Type>(p, iF),
00043     cyclicPatch_(refCast<const cyclicFvPatch>(p))
00044 {}
00045 
00046 
00047 template<class Type>
00048 cyclicFvPatchField<Type>::cyclicFvPatchField
00049 (
00050     const cyclicFvPatchField<Type>& ptf,
00051     const fvPatch& p,
00052     const DimensionedField<Type, volMesh>& iF,
00053     const fvPatchFieldMapper& mapper
00054 )
00055 :
00056     coupledFvPatchField<Type>(ptf, p, iF, mapper),
00057     cyclicPatch_(refCast<const cyclicFvPatch>(p))
00058 {
00059     if (!isType<cyclicFvPatch>(this->patch()))
00060     {
00061         FatalErrorIn
00062         (
00063             "cyclicFvPatchField<Type>::cyclicFvPatchField\n"
00064             "(\n"
00065             "    const cyclicFvPatchField<Type>& ptf,\n"
00066             "    const fvPatch& p,\n"
00067             "    const DimensionedField<Type, volMesh>& iF,\n"
00068             "    const fvPatchFieldMapper& mapper\n"
00069             ")\n"
00070         )   << "\n    patch type '" << p.type()
00071             << "' not constraint type '" << typeName << "'"
00072             << "\n    for patch " << p.name()
00073             << " of field " << this->dimensionedInternalField().name()
00074             << " in file " << this->dimensionedInternalField().objectPath()
00075             << exit(FatalIOError);
00076     }
00077 }
00078 
00079 
00080 template<class Type>
00081 cyclicFvPatchField<Type>::cyclicFvPatchField
00082 (
00083     const fvPatch& p,
00084     const DimensionedField<Type, volMesh>& iF,
00085     const dictionary& dict
00086 )
00087 :
00088     coupledFvPatchField<Type>(p, iF, dict),
00089     cyclicPatch_(refCast<const cyclicFvPatch>(p))
00090 {
00091     if (!isType<cyclicFvPatch>(p))
00092     {
00093         FatalIOErrorIn
00094         (
00095             "cyclicFvPatchField<Type>::cyclicFvPatchField\n"
00096             "(\n"
00097             "    const fvPatch& p,\n"
00098             "    const Field<Type>& field,\n"
00099             "    const dictionary& dict\n"
00100             ")\n",
00101             dict
00102         )   << "\n    patch type '" << p.type()
00103             << "' not constraint type '" << typeName << "'"
00104             << "\n    for patch " << p.name()
00105             << " of field " << this->dimensionedInternalField().name()
00106             << " in file " << this->dimensionedInternalField().objectPath()
00107             << exit(FatalIOError);
00108     }
00109 
00110     this->evaluate(Pstream::blocking);
00111 }
00112 
00113 
00114 template<class Type>
00115 cyclicFvPatchField<Type>::cyclicFvPatchField
00116 (
00117     const cyclicFvPatchField<Type>& ptf
00118 )
00119 :
00120     cyclicLduInterfaceField(),
00121     coupledFvPatchField<Type>(ptf),
00122     cyclicPatch_(ptf.cyclicPatch_)
00123 {}
00124 
00125 
00126 template<class Type>
00127 cyclicFvPatchField<Type>::cyclicFvPatchField
00128 (
00129     const cyclicFvPatchField<Type>& ptf,
00130     const DimensionedField<Type, volMesh>& iF
00131 )
00132 :
00133     coupledFvPatchField<Type>(ptf, iF),
00134     cyclicPatch_(ptf.cyclicPatch_)
00135 {}
00136 
00137 
00138 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00139 
00140 template<class Type>
00141 tmp<Field<Type> > cyclicFvPatchField<Type>::patchNeighbourField() const
00142 {
00143     const Field<Type>& iField = this->internalField();
00144     const unallocLabelList& faceCells = cyclicPatch_.faceCells();
00145 
00146     tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
00147     Field<Type>& pnf = tpnf();
00148 
00149     label sizeby2 = this->size()/2;
00150 
00151     if (doTransform())
00152     {
00153         for (label facei=0; facei<sizeby2; facei++)
00154         {
00155             pnf[facei] = transform
00156             (
00157                 forwardT()[0], iField[faceCells[facei + sizeby2]]
00158             );
00159 
00160             pnf[facei + sizeby2] = transform
00161             (
00162                 reverseT()[0], iField[faceCells[facei]]
00163             );
00164         }
00165     }
00166     else
00167     {
00168         for (label facei=0; facei<sizeby2; facei++)
00169         {
00170             pnf[facei] = iField[faceCells[facei + sizeby2]];
00171             pnf[facei + sizeby2] = iField[faceCells[facei]];
00172         }
00173     }
00174 
00175     return tpnf;
00176 }
00177 
00178 
00179 template<class Type>
00180 void cyclicFvPatchField<Type>::updateInterfaceMatrix
00181 (
00182     const scalarField& psiInternal,
00183     scalarField& result,
00184     const lduMatrix&,
00185     const scalarField& coeffs,
00186     const direction cmpt,
00187     const Pstream::commsTypes
00188 ) const
00189 {
00190     scalarField pnf(this->size());
00191 
00192     label sizeby2 = this->size()/2;
00193     const unallocLabelList& faceCells = cyclicPatch_.faceCells();
00194 
00195     for (label facei=0; facei<sizeby2; facei++)
00196     {
00197         pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
00198         pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
00199     }
00200 
00201     // Transform according to the transformation tensors
00202     transformCoupleField(pnf, cmpt);
00203 
00204     // Multiply the field by coefficients and add into the result
00205     forAll(faceCells, elemI)
00206     {
00207         result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
00208     }
00209 }
00210 
00211 
00212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00213 
00214 } // End namespace Foam
00215 
00216 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines