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

processorPointPatchField.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 "processorPointPatchField.H"
00027 #include <OpenFOAM/transformField.H>
00028 #include <OpenFOAM/processorPolyPatch.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 processorPointPatchField<Type>::processorPointPatchField
00039 (
00040     const pointPatch& p,
00041     const DimensionedField<Type, pointMesh>& iF
00042 )
00043 :
00044     coupledPointPatchField<Type>(p, iF),
00045     procPatch_(refCast<const processorPointPatch>(p))
00046 {}
00047 
00048 
00049 template<class Type>
00050 processorPointPatchField<Type>::processorPointPatchField
00051 (
00052     const pointPatch& p,
00053     const DimensionedField<Type, pointMesh>& iF,
00054     const dictionary& dict
00055 )
00056 :
00057     coupledPointPatchField<Type>(p, iF, dict),
00058     procPatch_(refCast<const processorPointPatch>(p))
00059 {}
00060 
00061 
00062 template<class Type>
00063 processorPointPatchField<Type>::processorPointPatchField
00064 (
00065     const processorPointPatchField<Type>& ptf,
00066     const pointPatch& p,
00067     const DimensionedField<Type, pointMesh>& iF,
00068     const pointPatchFieldMapper& mapper
00069 )
00070 :
00071     coupledPointPatchField<Type>(ptf, p, iF, mapper),
00072     procPatch_(refCast<const processorPointPatch>(ptf.patch()))
00073 {}
00074 
00075 
00076 template<class Type>
00077 processorPointPatchField<Type>::processorPointPatchField
00078 (
00079     const processorPointPatchField<Type>& ptf,
00080     const DimensionedField<Type, pointMesh>& iF
00081 )
00082 :
00083     coupledPointPatchField<Type>(ptf, iF),
00084     procPatch_(refCast<const processorPointPatch>(ptf.patch()))
00085 {}
00086 
00087 
00088 // * * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //
00089 
00090 template<class Type>
00091 processorPointPatchField<Type>::~processorPointPatchField()
00092 {}
00093 
00094 
00095 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00096 
00097 template<class Type>
00098 void processorPointPatchField<Type>::initSwapAdd(Field<Type>& pField) const
00099 {
00100     if (Pstream::parRun())
00101     {
00102         // Get internal field into my point order
00103         Field<Type> pf(this->patchInternalField(pField));
00104 
00105         OPstream::write
00106         (
00107             Pstream::blocking,
00108             procPatch_.neighbProcNo(),
00109             reinterpret_cast<const char*>(pf.begin()),
00110             pf.byteSize()
00111         );
00112     }
00113 }
00114 
00115 
00116 template<class Type>
00117 void processorPointPatchField<Type>::swapAdd(Field<Type>& pField) const
00118 {
00119     if (Pstream::parRun())
00120     {
00121         Field<Type> pnf(this->size());
00122 
00123         IPstream::read
00124         (
00125             Pstream::blocking,
00126             procPatch_.neighbProcNo(),
00127             reinterpret_cast<char*>(pnf.begin()),
00128             pnf.byteSize()
00129         );
00130 
00131         if (doTransform())
00132         {
00133             const processorPolyPatch& ppp = procPatch_.procPolyPatch();
00134             const tensorField& forwardT = ppp.forwardT();
00135 
00136             if (forwardT.size() == 1)
00137             {
00138                 transform(pnf, forwardT[0], pnf);
00139             }
00140             else
00141             {
00142                 const labelList& nonGlobalPatchPoints =
00143                     procPatch_.nonGlobalPatchPoints();
00144                 const labelListList& pointFaces = ppp.pointFaces();
00145 
00146                 forAll(nonGlobalPatchPoints, pfi)
00147                 {
00148                     pnf[pfi] = transform
00149                     (
00150                         forwardT[pointFaces[nonGlobalPatchPoints[pfi]][0]],
00151                         pnf[pfi]
00152                     );
00153                 }
00154             }
00155         }
00156 
00157         this->addToInternalField(pField, pnf);
00158     }
00159 }
00160 
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 } // End namespace Foam
00165 
00166 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines