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

jumpCyclicFvPatchField.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 "jumpCyclicFvPatchField.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 jumpCyclicFvPatchField<Type>::jumpCyclicFvPatchField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<Type, volMesh>& iF
00041 )
00042 :
00043     cyclicFvPatchField<Type>(p, iF)
00044 {}
00045 
00046 
00047 template<class Type>
00048 jumpCyclicFvPatchField<Type>::jumpCyclicFvPatchField
00049 (
00050     const jumpCyclicFvPatchField<Type>& ptf,
00051     const fvPatch& p,
00052     const DimensionedField<Type, volMesh>& iF,
00053     const fvPatchFieldMapper& mapper
00054 )
00055 :
00056     cyclicFvPatchField<Type>(ptf, p, iF, mapper)
00057 {}
00058 
00059 
00060 template<class Type>
00061 jumpCyclicFvPatchField<Type>::jumpCyclicFvPatchField
00062 (
00063     const fvPatch& p,
00064     const DimensionedField<Type, volMesh>& iF,
00065     const dictionary& dict
00066 )
00067 :
00068     cyclicFvPatchField<Type>(p, iF, dict)
00069 {
00070     // Call this evaluation in derived classes
00071     //this->evaluate(Pstream::blocking);
00072 }
00073 
00074 
00075 template<class Type>
00076 jumpCyclicFvPatchField<Type>::jumpCyclicFvPatchField
00077 (
00078     const jumpCyclicFvPatchField<Type>& ptf
00079 )
00080 :
00081     cyclicLduInterfaceField(),
00082     cyclicFvPatchField<Type>(ptf)
00083 {}
00084 
00085 
00086 template<class Type>
00087 jumpCyclicFvPatchField<Type>::jumpCyclicFvPatchField
00088 (
00089     const jumpCyclicFvPatchField<Type>& ptf,
00090     const DimensionedField<Type, volMesh>& iF
00091 )
00092 :
00093     cyclicFvPatchField<Type>(ptf, iF)
00094 {}
00095 
00096 
00097 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00098 
00099 template<class Type>
00100 tmp<Field<Type> > jumpCyclicFvPatchField<Type>::patchNeighbourField() const
00101 {
00102     const Field<Type>& iField = this->internalField();
00103     const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
00104 
00105     tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
00106     Field<Type>& pnf = tpnf();
00107 
00108     tmp<Field<scalar> > tjf = jump();
00109     const Field<scalar>& jf = tjf();
00110 
00111     label sizeby2 = this->size()/2;
00112 
00113     if (this->doTransform())
00114     {
00115         for (label facei=0; facei<sizeby2; facei++)
00116         {
00117             pnf[facei] = transform
00118             (
00119                 this->forwardT()[0], iField[faceCells[facei + sizeby2]]
00120             ) - jf[facei];
00121 
00122             pnf[facei + sizeby2] = transform
00123             (
00124                 this->reverseT()[0], iField[faceCells[facei]] + jf[facei]
00125             );
00126         }
00127     }
00128     else
00129     {
00130         for (label facei=0; facei<sizeby2; facei++)
00131         {
00132             pnf[facei] = iField[faceCells[facei + sizeby2]] - jf[facei];
00133             pnf[facei + sizeby2] = iField[faceCells[facei]] + jf[facei];
00134         }
00135     }
00136 
00137     return tpnf;
00138 }
00139 
00140 
00141 template<class Type>
00142 void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix
00143 (
00144     const scalarField& psiInternal,
00145     scalarField& result,
00146     const lduMatrix&,
00147     const scalarField& coeffs,
00148     const direction cmpt,
00149     const Pstream::commsTypes
00150 ) const
00151 {
00152     scalarField pnf(this->size());
00153 
00154     label sizeby2 = this->size()/2;
00155     const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
00156 
00157     if (long(&psiInternal) == long(&this->internalField()))
00158     {
00159         tmp<Field<scalar> > tjf = jump();
00160         const Field<scalar>& jf = tjf();
00161 
00162         for (label facei=0; facei<sizeby2; facei++)
00163         {
00164             pnf[facei] = psiInternal[faceCells[facei + sizeby2]] - jf[facei];
00165             pnf[facei + sizeby2] = psiInternal[faceCells[facei]] + jf[facei];
00166         }
00167     }
00168     else
00169     {
00170         for (label facei=0; facei<sizeby2; facei++)
00171         {
00172             pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
00173             pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
00174         }
00175     }
00176 
00177     // Transform according to the transformation tensors
00178     this->transformCoupleField(pnf, cmpt);
00179 
00180     // Multiply the field by coefficients and add into the result
00181     forAll(faceCells, elemI)
00182     {
00183         result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
00184     }
00185 }
00186 
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 } // End namespace Foam
00191 
00192 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd