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

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