OpenFOAM logo
Open Source CFD Toolkit

wallPointDataI.H

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-2005 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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00035 
00036 
00037 // Update this with w2 if w2 nearer to pt.
00038 template <class Type>
00039 inline bool wallPointData<Type>::update
00040 (
00041     const point& pt,
00042     const wallPointData<Type>& w2,
00043     const scalar tol
00044 )
00045 {
00046     scalar dist2 = magSqr(pt - w2.origin());
00047 
00048     if (!valid())
00049     {
00050         // current not yet set so use any value
00051         distSqr() = dist2;
00052         origin() = w2.origin();
00053         data_ = w2.data();
00054 
00055         return true;
00056     }        
00057 
00058     scalar diff = distSqr() - dist2;
00059 
00060     if (diff < 0)
00061     {
00062         // already nearer to pt
00063         return false;
00064     }
00065 
00066     if ((diff < SMALL) || ((distSqr() > SMALL) && (diff/distSqr() < tol)))
00067     {
00068         // don't propagate small changes
00069         return false;
00070     }
00071     else
00072     {
00073         // update with new values
00074         distSqr() = dist2;
00075         origin() = w2.origin();
00076         data_ = w2.data();
00077 
00078         return true;
00079     }
00080 }
00081     
00082 
00083 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00084 
00085 // Null constructor
00086 template <class Type>
00087 inline wallPointData<Type>::wallPointData()
00088 :
00089     wallPoint(),
00090     data_()
00091 {}
00092 
00093 
00094 // Construct from components
00095 template <class Type>
00096 inline wallPointData<Type>::wallPointData
00097 (
00098     const point& origin,
00099     const Type& data,
00100     const scalar distSqr
00101 )
00102 :
00103     wallPoint(origin, distSqr),
00104     data_(data)
00105 {}
00106 
00107 
00108 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00109 
00110 template <class Type>
00111 inline const Type& wallPointData<Type>::data() const
00112 {
00113     return data_;
00114 }
00115 
00116 
00117 template <class Type>
00118 inline Type& wallPointData<Type>::data()
00119 {
00120     return data_;
00121 }
00122 
00123 
00124 // Update this with w2 if w2 nearer to pt.
00125 template <class Type>
00126 inline bool wallPointData<Type>::updateCell
00127 (
00128     const polyMesh& mesh,
00129     const label thisCellI,
00130     const label,
00131     const wallPointData<Type>& neighbourWallInfo,
00132     const scalar tol
00133 )
00134 {
00135     const vectorField& cellCentres = mesh.primitiveMesh::cellCentres();
00136 
00137     return update
00138     (
00139         cellCentres[thisCellI],
00140         neighbourWallInfo,
00141         tol
00142     );
00143 }    
00144 
00145 
00146 // Update this with w2 if w2 nearer to pt.
00147 template <class Type>
00148 inline bool wallPointData<Type>::updateFace
00149 (
00150     const polyMesh& mesh,
00151     const label thisFaceI,
00152     const label,
00153     const wallPointData<Type>& neighbourWallInfo,
00154     const scalar tol
00155 )
00156 {
00157     const vectorField& faceCentres = mesh.faceCentres();
00158 
00159     return update
00160     (
00161         faceCentres[thisFaceI],
00162         neighbourWallInfo,
00163         tol
00164     );
00165 }    
00166 
00167 
00168 // Update this with w2 if w2 nearer to pt.
00169 template <class Type>
00170 inline bool wallPointData<Type>::updateFace
00171 (
00172     const polyMesh& mesh,
00173     const label thisFaceI,
00174     const wallPointData<Type>& neighbourWallInfo,
00175     const scalar tol
00176 )
00177 {
00178     const vectorField& faceCentres = mesh.faceCentres();
00179 
00180     return update
00181     (
00182         faceCentres[thisFaceI],
00183         neighbourWallInfo,
00184         tol
00185     );
00186 }    
00187 
00188 
00189 // ************************************************************************* //
00190 
00191 } // End namespace Foam
00192 
00193 // ************************************************************************* //
For further information go to www.openfoam.org