cloudSet.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cloudSet.H"
27 #include "sampledSet.H"
28 #include "meshSearch.H"
29 #include "DynamicList.H"
30 #include "polyMesh.H"
32 #include "word.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(cloudSet, 0);
39  addToRunTimeSelectionTable(sampledSet, cloudSet, word);
40 }
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
46 (
47  DynamicList<point>& samplingPts,
48  DynamicList<label>& samplingCells,
49  DynamicList<label>& samplingFaces,
50  DynamicList<label>& samplingSegments,
51  DynamicList<scalar>& samplingCurveDist
52 ) const
53 {
54  const meshSearch& queryMesh = searchEngine();
55 
56  forAll(sampleCoords_, sampleI)
57  {
58  label cellI = queryMesh.findCell(sampleCoords_[sampleI]);
59 
60  if (cellI != -1)
61  {
62  samplingPts.append(sampleCoords_[sampleI]);
63  samplingCells.append(cellI);
64  samplingFaces.append(-1);
65  samplingSegments.append(0);
66  samplingCurveDist.append(1.0 * sampleI);
67  }
68  }
69 }
70 
71 
73 {
74  // Storage for sample points
75  DynamicList<point> samplingPts;
76  DynamicList<label> samplingCells;
77  DynamicList<label> samplingFaces;
78  DynamicList<label> samplingSegments;
79  DynamicList<scalar> samplingCurveDist;
80 
82  (
83  samplingPts,
84  samplingCells,
85  samplingFaces,
86  samplingSegments,
87  samplingCurveDist
88  );
89 
90  samplingPts.shrink();
91  samplingCells.shrink();
92  samplingFaces.shrink();
93  samplingSegments.shrink();
94  samplingCurveDist.shrink();
95 
97  (
98  samplingPts,
99  samplingCells,
100  samplingFaces,
101  samplingSegments,
102  samplingCurveDist
103  );
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
108 
110 (
111  const word& name,
112  const polyMesh& mesh,
113  const meshSearch& searchEngine,
114  const word& axis,
115  const List<point>& sampleCoords
116 )
117 :
118  sampledSet(name, mesh, searchEngine, axis),
119  sampleCoords_(sampleCoords)
120 {
121  genSamples();
122 
123  if (debug)
124  {
125  write(Info);
126  }
127 }
128 
129 
131 (
132  const word& name,
133  const polyMesh& mesh,
134  const meshSearch& searchEngine,
135  const dictionary& dict
136 )
137 :
138  sampledSet(name, mesh, searchEngine, dict),
139  sampleCoords_(dict.lookup("points"))
140 {
141  genSamples();
142 
143  if (debug)
144  {
145  write(Info);
146  }
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
151 
153 {}
154 
155 
156 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
Foam::cloudSet::~cloudSet
virtual ~cloudSet()
Destructor.
Definition: cloudSet.C:152
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::meshSearch
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:57
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
sampledSet.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
Foam::DynamicList::shrink
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Definition: DynamicListI.H:258
Foam::cloudSet::cloudSet
cloudSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const List< point > &sampleCoords)
Construct from components.
Definition: cloudSet.C:110
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
meshSearch.H
Foam::sampledSet::setSamples
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingCurveDist)
Sets sample data.
Definition: sampledSet.C:351
Foam::cloudSet::genSamples
void genSamples()
Uses calcSamples to obtain samples. Copies them into *this.
Definition: cloudSet.C:72
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::meshSearch::findCell
label findCell(const point &location, const label seedCellI=-1, const bool useTreeSearch=true) const
Find cell containing location.
Definition: meshSearch.C:788
DynamicList.H
word.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::cloudSet::calcSamples
void calcSamples(DynamicList< point > &samplingPts, DynamicList< label > &samplingCells, DynamicList< label > &samplingFaces, DynamicList< label > &samplingSegments, DynamicList< scalar > &samplingCurveDist) const
Samples all points in sampleCoords.
Definition: cloudSet.C:46
write
Tcoeff write()
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
cloudSet.H