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

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