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-2016 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 
45 void Foam::cloudSet::calcSamples
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 
72 void Foam::cloudSet::genSamples()
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 
81  calcSamples
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 
96  setSamples
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 // ************************************************************************* //
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
Macros for easy insertion into run-time selection tables.
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
A class for handling words, derived from string.
Definition: word.H:59
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
virtual ~cloudSet()
Destructor.
Definition: cloudSet.C:152
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
cloudSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const List< point > &sampleCoords)
Construct from components.
Definition: cloudSet.C:110
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576