lineCellFace.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 "lineCellFace.H"
27 #include "meshSearch.H"
28 #include "DynamicList.H"
29 #include "polyMesh.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace sampledSets
37 {
38  defineTypeNameAndDebug(lineCellFace, 0);
39  addToRunTimeSelectionTable(sampledSet, lineCellFace, word);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 void Foam::sampledSets::lineCellFace::calcSamples
47 (
48  DynamicList<point>& samplingPts,
49  DynamicList<label>& samplingCells,
50  DynamicList<label>& samplingFaces,
51  DynamicList<label>& samplingSegments,
52  DynamicList<scalar>& samplingCurveDist
53 ) const
54 {
55  // Run the algorithm from lineFaceSet to get all the face intersections
56  DynamicList<point> facePts;
57  DynamicList<label> faceCells;
58  DynamicList<label> faceFaces;
59  DynamicList<label> faceSegments;
60  DynamicList<scalar> faceCurveDist;
61  lineFace::calcSamples
62  (
63  mesh(),
64  searchEngine(),
65  start_,
66  end_,
67  facePts,
68  faceCells,
69  faceFaces,
70  faceSegments,
71  faceCurveDist
72  );
73 
74  // If there are no intersections then quit
75  if (!facePts.size())
76  {
77  return;
78  }
79 
80  // Append all the face intersections to the set, additionally adding mid
81  // points when the segment is the same
82  samplingPts.append(facePts[0]);
83  samplingCells.append(faceCells[0]);
84  samplingFaces.append(faceFaces[0]);
85  samplingSegments.append(faceSegments[0]);
86  samplingCurveDist.append(faceCurveDist[0]);
87 
88  for (label facei = 1; facei < facePts.size(); ++ facei)
89  {
91  (
92  mesh(),
93  samplingPts.last(),
94  samplingFaces.last(),
95  samplingSegments.last(),
96  samplingCurveDist.last(),
97  facePts[facei],
98  faceFaces[facei],
99  faceSegments[facei],
100  samplingPts,
101  samplingCells,
102  samplingFaces,
103  samplingSegments,
104  samplingCurveDist
105  );
106 
107  samplingPts.append(facePts[facei]);
108  samplingCells.append(faceCells[facei]);
109  samplingFaces.append(faceFaces[facei]);
110  samplingSegments.append(faceSegments[facei]);
111  samplingCurveDist.append(faceCurveDist[facei]);
112  }
113 }
114 
115 
116 void Foam::sampledSets::lineCellFace::genSamples()
117 {
118  DynamicList<point> samplingPts;
119  DynamicList<label> samplingCells;
120  DynamicList<label> samplingFaces;
121  DynamicList<label> samplingSegments;
122  DynamicList<scalar> samplingCurveDist;
123 
124  calcSamples
125  (
126  samplingPts,
127  samplingCells,
128  samplingFaces,
129  samplingSegments,
130  samplingCurveDist
131  );
132 
133  samplingPts.shrink();
134  samplingCells.shrink();
135  samplingFaces.shrink();
136  samplingSegments.shrink();
137  samplingCurveDist.shrink();
138 
139  setSamples
140  (
141  samplingPts,
142  samplingCells,
143  samplingFaces,
144  samplingSegments,
145  samplingCurveDist
146  );
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
151 
153 (
154  const word& name,
155  const polyMesh& mesh,
156  const meshSearch& searchEngine,
157  const dictionary& dict
158 )
159 :
160  sampledSet(name, mesh, searchEngine, dict),
161  start_(dict.lookup("start")),
162  end_(dict.lookup("end"))
163 {
164  genSamples();
165 
166  if (debug)
167  {
168  write(Info);
169  }
170 }
171 
172 
174 (
175  const word& name,
176  const polyMesh& mesh,
177  const meshSearch& searchEngine,
178  const word& axis,
179  const point& start,
180  const point& end
181 )
182 :
183  sampledSet(name, mesh, searchEngine, axis),
184  start_(start),
185  end_(end)
186 {
187  genSamples();
188 
189  if (debug)
190  {
191  write(Info);
192  }
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
197 
199 {}
200 
201 
202 // ************************************************************************* //
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
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:156
virtual ~lineCellFace()
Destructor.
Definition: lineCellFace.C:198
Macros for easy insertion into run-time selection tables.
dynamicFvMesh & mesh
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:61
lineCellFace(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
Definition: lineCellFace.C:153
A class for handling words, derived from string.
Definition: word.H:59
static void calcMidPointSample(const polyMesh &mesh, const point &prevPt, const label prevFace, const label prevSegment, const scalar prevCurveDist, const point &nextPt, const label nextFace, const label nextSegment, DynamicList< point > &samplingPts, DynamicList< label > &samplingCells, DynamicList< label > &samplingFaces, DynamicList< label > &samplingSegments, DynamicList< scalar > &samplingCurveDist)
Calculate the next mid point sample.
Definition: lineCell.C:47
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
virtual bool write()
Sample and write.
Definition: sampledSets.C:228
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
defineTypeNameAndDebug(arcUniform, 0)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844