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

processorFvPatch.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 "processorFvPatch.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "transformField.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 defineTypeNameAndDebug(processorFvPatch, 0);
00039 addToRunTimeSelectionTable(fvPatch, processorFvPatch, polyPatch);
00040 
00041 
00042 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00043 
00044 void processorFvPatch::makeWeights(scalarField& w) const
00045 {
00046     if (Pstream::parRun())
00047     {
00048         // The face normals point in the opposite direction on the other side
00049         scalarField neighbFaceCentresCn
00050         (
00051             (
00052                 procPolyPatch_.neighbFaceAreas()
00053                /(mag(procPolyPatch_.neighbFaceAreas()) + VSMALL)
00054             )
00055           & (
00056               procPolyPatch_.neighbFaceCentres()
00057             - procPolyPatch_.neighbFaceCellCentres())
00058         );
00059 
00060         w = neighbFaceCentresCn/((nf()&fvPatch::delta()) + neighbFaceCentresCn);
00061     }
00062     else
00063     {
00064         w = 1.0;
00065     }
00066 }
00067 
00068 
00069 void processorFvPatch::makeDeltaCoeffs(scalarField& dc) const
00070 {
00071     if (Pstream::parRun())
00072     {
00073         dc = (1.0 - weights())/(nf() & fvPatch::delta());
00074     }
00075     else
00076     {
00077         dc = 1.0/(nf() & fvPatch::delta());
00078     }
00079 }
00080 
00081 
00082 tmp<vectorField> processorFvPatch::delta() const
00083 {
00084     if (Pstream::parRun())
00085     {
00086         // To the transformation if necessary
00087         if (parallel())
00088         {
00089             return
00090                 fvPatch::delta()
00091               - (
00092                     procPolyPatch_.neighbFaceCentres()
00093                   - procPolyPatch_.neighbFaceCellCentres()
00094                 );
00095         }
00096         else
00097         {
00098             return
00099                 fvPatch::delta()
00100               - transform
00101                 (
00102                     forwardT(),
00103                     (
00104                         procPolyPatch_.neighbFaceCentres()
00105                       - procPolyPatch_.neighbFaceCellCentres()
00106                     )
00107                 );
00108         }
00109     }
00110     else
00111     {
00112         return fvPatch::delta();
00113     }
00114 }
00115 
00116 
00117 tmp<labelField> processorFvPatch::interfaceInternalField
00118 (
00119     const unallocLabelList& internalData
00120 ) const
00121 {
00122     return patchInternalField(internalData);
00123 }
00124 
00125 
00126 void processorFvPatch::initTransfer
00127 (
00128     const Pstream::commsTypes commsType,
00129     const unallocLabelList& interfaceData
00130 ) const
00131 {
00132     send(commsType, interfaceData);
00133 }
00134 
00135 
00136 tmp<labelField> processorFvPatch::transfer
00137 (
00138     const Pstream::commsTypes commsType,
00139     const unallocLabelList&
00140 ) const
00141 {
00142     return receive<label>(commsType, this->size());
00143 }
00144 
00145 
00146 void processorFvPatch::initInternalFieldTransfer
00147 (
00148     const Pstream::commsTypes commsType,
00149     const unallocLabelList& iF
00150 ) const
00151 {
00152     send(commsType, patchInternalField(iF)());
00153 }
00154 
00155 
00156 tmp<labelField> processorFvPatch::internalFieldTransfer
00157 (
00158     const Pstream::commsTypes commsType,
00159     const unallocLabelList&
00160 ) const
00161 {
00162     return receive<label>(commsType, this->size());
00163 }
00164 
00165 
00166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00167 
00168 } // End namespace Foam
00169 
00170 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd