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

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