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

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