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

cloudSet.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 "cloudSet.H"
00027 #include <sampling/sampledSet.H>
00028 #include <meshTools/meshSearch.H>
00029 #include <OpenFOAM/DynamicList.H>
00030 #include <OpenFOAM/polyMesh.H>
00031 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00032 #include <OpenFOAM/word.H>
00033 
00034 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038     defineTypeNameAndDebug(cloudSet, 0);
00039     addToRunTimeSelectionTable(sampledSet, cloudSet, word);
00040 }
00041 
00042 
00043 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00044 
00045 void Foam::cloudSet::calcSamples
00046 (
00047     DynamicList<point>& samplingPts,
00048     DynamicList<label>& samplingCells,
00049     DynamicList<label>& samplingFaces,
00050     DynamicList<label>& samplingSegments,
00051     DynamicList<scalar>& samplingCurveDist
00052 ) const
00053 {
00054     forAll(sampleCoords_, sampleI)
00055     {
00056         label cellI = searchEngine().findCell(sampleCoords_[sampleI]);
00057 
00058         if (cellI != -1)
00059         {
00060             samplingPts.append(sampleCoords_[sampleI]);
00061             samplingCells.append(cellI);
00062             samplingFaces.append(-1);
00063             samplingSegments.append(0);
00064             samplingCurveDist.append(1.0 * sampleI);
00065         }
00066     }
00067 }
00068 
00069 
00070 void Foam::cloudSet::genSamples()
00071 {
00072     // Storage for sample points
00073     DynamicList<point> samplingPts;
00074     DynamicList<label> samplingCells;
00075     DynamicList<label> samplingFaces;
00076     DynamicList<label> samplingSegments;
00077     DynamicList<scalar> samplingCurveDist;
00078 
00079     calcSamples
00080     (
00081         samplingPts,
00082         samplingCells,
00083         samplingFaces,
00084         samplingSegments,
00085         samplingCurveDist
00086     );
00087 
00088     samplingPts.shrink();
00089     samplingCells.shrink();
00090     samplingFaces.shrink();
00091     samplingSegments.shrink();
00092     samplingCurveDist.shrink();
00093 
00094     setSamples
00095     (
00096         samplingPts,
00097         samplingCells,
00098         samplingFaces,
00099         samplingSegments,
00100         samplingCurveDist
00101     );
00102 }
00103 
00104 
00105 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00106 
00107 Foam::cloudSet::cloudSet
00108 (
00109     const word& name,
00110     const polyMesh& mesh,
00111     meshSearch& searchEngine,
00112     const word& axis,
00113     const List<point>& sampleCoords
00114 )
00115 :
00116     sampledSet(name, mesh, searchEngine, axis),
00117     sampleCoords_(sampleCoords)
00118 {
00119     genSamples();
00120 
00121     if (debug)
00122     {
00123         write(Info);
00124     }
00125 }
00126 
00127 
00128 Foam::cloudSet::cloudSet
00129 (
00130     const word& name,
00131     const polyMesh& mesh,
00132     meshSearch& searchEngine,
00133     const dictionary& dict
00134 )
00135 :
00136     sampledSet(name, mesh, searchEngine, dict),
00137     sampleCoords_(dict.lookup("points"))
00138 {
00139     genSamples();
00140 
00141     if (debug)
00142     {
00143         write(Info);
00144     }
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00149 
00150 Foam::cloudSet::~cloudSet()
00151 {}
00152 
00153 
00154 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00155 
00156 Foam::point Foam::cloudSet::getRefPoint(const List<point>& pts) const
00157 {
00158     if (pts.size())
00159     {
00160         // Use first samplePt as starting point
00161         return pts[0];
00162     }
00163     else
00164     {
00165         return vector::zero;
00166     }
00167 }
00168 
00169 
00170 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines