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

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