triSurfaceSampledSet.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-2025 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 "triSurfaceSampledSet.H"
27 #include "meshSearch.H"
28 #include "polyMesh.H"
30 #include "Time.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  namespace sampledSets
38  {
40 
42  (
43  sampledSet,
44  triSurface,
45  word
46  );
47 
49  (
50  sampledSet,
51  triSurface,
52  word,
53  triSurfaceMesh,
54  "triSurfaceMesh"
55  );
56  }
57 }
58 
59 
60 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
61 
62 void Foam::sampledSets::triSurface::calcSamples
63 (
64  DynamicList<point>& samplingPositions,
65  DynamicList<label>& samplingSegments,
66  DynamicList<label>& samplingCells,
67  DynamicList<label>& samplingFaces
68 ) const
69 {
70  forAll(points_, i)
71  {
72  const point& pt = points_[i];
73  const label celli = searchEngine().findCell(pt);
74 
75  if (celli != -1)
76  {
77  samplingPositions.append(pt);
78  samplingSegments.append(i);
79  samplingCells.append(celli);
80  samplingFaces.append(-1);
81  }
82  }
83 }
84 
85 
86 void Foam::sampledSets::triSurface::genSamples()
87 {
88  DynamicList<point> samplingPositions;
89  DynamicList<label> samplingSegments;
90  DynamicList<label> samplingCells;
91  DynamicList<label> samplingFaces;
92 
93  calcSamples
94  (
95  samplingPositions,
96  samplingSegments,
97  samplingCells,
98  samplingFaces
99  );
100 
101  samplingPositions.shrink();
102  samplingSegments.shrink();
103  samplingCells.shrink();
104  samplingFaces.shrink();
105 
106  setSamples
107  (
108  samplingPositions,
109  samplingSegments,
110  samplingCells,
111  samplingFaces
112  );
113 }
114 
115 
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
117 
119 (
120  const word& name,
121  const polyMesh& mesh,
122  const meshSearch& searchEngine,
123  const dictionary& dict
124 )
125 :
126  sampledSet(name, mesh, searchEngine, dict),
127  surface_(dict.lookup("surface")),
128  points_
129  (
130  mesh.time().foundObject<searchableSurfaces::triSurface>
131  (
132  surface_
133  )
134  ? mesh.time().lookupObject<searchableSurfaces::triSurface>
135  (
136  surface_
137  ).points()
138  : searchableSurfaces::triSurface
139  (
140  IOobject
141  (
142  surface_,
143  mesh.time().constant(),
144  searchableSurface::geometryDir(mesh.time()),
145  mesh.time(),
146  IOobject::MUST_READ,
147  IOobject::NO_WRITE,
148  false
149  )
150  ).points()
151  )
152 {
153  genSamples();
154 }
155 
156 
157 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 
160 {}
161 
162 
163 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:58
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
Definition: meshSearch.C:749
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:67
const meshSearch & searchEngine() const
Access the search engine.
Definition: sampledSet.H:222
Specified point samples. Optionally ordered into a continuous path. Ordering is an optimisation; it e...
Definition: points.H:106
Samples from all the points of a triSurface. Surface files are read from constant/triSurface.
triSurface(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
Set of sets to sample. Call sampledSets.write() to sample&write files.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(arcUniform, 0)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
addBackwardCompatibleToRunTimeSelectionTable(sampledSet, triSurface, word, triSurfaceMesh, "triSurfaceMesh")
Namespace for OpenFOAM.
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
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict