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

cyclicPointPatchField.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 "cyclicPointPatchField.H"
00028 #include "Swap.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 cyclicPointPatchField<Type>::cyclicPointPatchField
00039 (
00040     const pointPatch& p,
00041     const DimensionedField<Type, pointMesh>& iF
00042 )
00043 :
00044     coupledPointPatchField<Type>(p, iF),
00045     cyclicPatch_(refCast<const cyclicPointPatch>(p))
00046 {}
00047 
00048 
00049 template<class Type>
00050 cyclicPointPatchField<Type>::cyclicPointPatchField
00051 (
00052     const pointPatch& p,
00053     const DimensionedField<Type, pointMesh>& iF,
00054     const dictionary& dict
00055 )
00056 :
00057     coupledPointPatchField<Type>(p, iF, dict),
00058     cyclicPatch_(refCast<const cyclicPointPatch>(p))
00059 {
00060     if (!isType<cyclicPointPatch>(p))
00061     {
00062         FatalIOErrorIn
00063         (
00064             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
00065             "(\n"
00066             "    const pointPatch& p,\n"
00067             "    const Field<Type>& field,\n"
00068             "    const dictionary& dict\n"
00069             ")\n",
00070             dict
00071         )   << "patch " << this->patch().index() << " not cyclic type. "
00072             << "Patch type = " << p.type()
00073             << exit(FatalIOError);
00074     }
00075 }
00076 
00077 
00078 template<class Type>
00079 cyclicPointPatchField<Type>::cyclicPointPatchField
00080 (
00081     const cyclicPointPatchField<Type>& ptf,
00082     const pointPatch& p,
00083     const DimensionedField<Type, pointMesh>& iF,
00084     const pointPatchFieldMapper& mapper
00085 )
00086 :
00087     coupledPointPatchField<Type>(ptf, p, iF, mapper),
00088     cyclicPatch_(refCast<const cyclicPointPatch>(p))
00089 {
00090     if (!isType<cyclicPointPatch>(this->patch()))
00091     {
00092         FatalErrorIn
00093         (
00094             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
00095             "(\n"
00096             "    const cyclicPointPatchField<Type>& ptf,\n"
00097             "    const pointPatch& p,\n"
00098             "    const DimensionedField<Type, pointMesh>& iF,\n"
00099             "    const pointPatchFieldMapper& mapper\n"
00100             ")\n"
00101         )   << "Field type does not correspond to patch type for patch "
00102             << this->patch().index() << "." << endl
00103             << "Field type: " << typeName << endl
00104             << "Patch type: " << this->patch().type()
00105             << exit(FatalError);
00106     }
00107 }
00108 
00109 
00110 template<class Type>
00111 cyclicPointPatchField<Type>::cyclicPointPatchField
00112 (
00113     const cyclicPointPatchField<Type>& ptf,
00114     const DimensionedField<Type, pointMesh>& iF
00115 )
00116 :
00117     coupledPointPatchField<Type>(ptf, iF),
00118     cyclicPatch_(ptf.cyclicPatch_)
00119 {}
00120 
00121 
00122 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00123 
00124 template<class Type>
00125 void cyclicPointPatchField<Type>::swapAdd(Field<Type>& pField) const
00126 {
00127     Field<Type> pf(this->patchInternalField(pField));
00128 
00129     const edgeList& pairs = cyclicPatch_.transformPairs();
00130 
00131     if (doTransform())
00132     {
00133         forAll(pairs, pairi)
00134         {
00135             Type tmp = pf[pairs[pairi][0]];
00136             pf[pairs[pairi][0]] = transform(forwardT()[0], pf[pairs[pairi][1]]);
00137             pf[pairs[pairi][1]] = transform(reverseT()[0], tmp);
00138         }
00139     }
00140     else
00141     {
00142         forAll(pairs, pairi)
00143         {
00144             Swap(pf[pairs[pairi][0]], pf[pairs[pairi][1]]);
00145         }
00146     }
00147 
00148     addToInternalField(pField, pf);
00149 }
00150 
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 } // End namespace Foam
00155 
00156 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd