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

fvPatch.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 "fvPatch.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvBoundaryMesh.H>
00029 #include <finiteVolume/fvMesh.H>
00030 #include <OpenFOAM/primitiveMesh.H>
00031 #include <finiteVolume/volFields.H>
00032 #include <finiteVolume/surfaceFields.H>
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 defineTypeNameAndDebug(fvPatch, 0);
00042 defineRunTimeSelectionTable(fvPatch, polyPatch);
00043 addToRunTimeSelectionTable(fvPatch, fvPatch, polyPatch);
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm)
00049 :
00050     polyPatch_(p),
00051     boundaryMesh_(bm)
00052 {}
00053 
00054 
00055 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00056 
00057 fvPatch::~fvPatch()
00058 {}
00059 
00060 
00061 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00062 
00063 bool fvPatch::constraintType(const word& pt)
00064 {
00065     return fvPatchField<scalar>::patchConstructorTablePtr_->found(pt);
00066 }
00067 
00068 
00069 wordList fvPatch::constraintTypes()
00070 {
00071     wordList cTypes(polyPatchConstructorTablePtr_->size());
00072 
00073     label i = 0;
00074 
00075     for
00076     (
00077         polyPatchConstructorTable::iterator cstrIter =
00078             polyPatchConstructorTablePtr_->begin();
00079         cstrIter != polyPatchConstructorTablePtr_->end();
00080         ++cstrIter
00081     )
00082     {
00083         if (constraintType(cstrIter.key()))
00084         {
00085             cTypes[i++] = cstrIter.key();
00086         }
00087     }
00088 
00089     cTypes.setSize(i);
00090 
00091     return cTypes;
00092 }
00093 
00094 
00095 const unallocLabelList& fvPatch::faceCells() const
00096 {
00097     return polyPatch_.faceCells();
00098 }
00099 
00100 
00101 const vectorField& fvPatch::Cf() const
00102 {
00103     return boundaryMesh().mesh().Cf().boundaryField()[index()];
00104 }
00105 
00106 
00107 tmp<vectorField> fvPatch::Cn() const
00108 {
00109     tmp<vectorField> tcc(new vectorField(size()));
00110     vectorField& cc = tcc();
00111 
00112     const unallocLabelList& faceCells = this->faceCells();
00113 
00114     // get reference to global cell centres
00115     const vectorField& gcc = boundaryMesh().mesh().cellCentres();
00116 
00117     forAll (faceCells, faceI)
00118     {
00119         cc[faceI] = gcc[faceCells[faceI]];
00120     }
00121 
00122     return tcc;
00123 }
00124 
00125 
00126 tmp<vectorField> fvPatch::nf() const
00127 {
00128     return Sf()/magSf();
00129 }
00130 
00131 
00132 const vectorField& fvPatch::Sf() const
00133 {
00134     return boundaryMesh().mesh().Sf().boundaryField()[index()];
00135 }
00136 
00137 
00138 const scalarField& fvPatch::magSf() const
00139 {
00140     return boundaryMesh().mesh().magSf().boundaryField()[index()];
00141 }
00142 
00143 
00144 tmp<vectorField> fvPatch::delta() const
00145 {
00146     return Cf() - Cn();
00147 }
00148 
00149 
00150 void fvPatch::makeWeights(scalarField& w) const
00151 {
00152     w = 1.0;
00153 }
00154 
00155 
00156 void fvPatch::makeDeltaCoeffs(scalarField& dc) const
00157 {
00158     dc = 1.0/(nf() & delta());
00159 }
00160 
00161 
00162 void fvPatch::initMovePoints()
00163 {}
00164 
00165 
00166 void fvPatch::movePoints()
00167 {}
00168 
00169 
00170 const scalarField& fvPatch::deltaCoeffs() const
00171 {
00172     return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()];
00173 }
00174 
00175 
00176 const scalarField& fvPatch::weights() const
00177 {
00178     return boundaryMesh().mesh().weights().boundaryField()[index()];
00179 }
00180 
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 } // End namespace Foam
00185 
00186 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines