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"
28 #include "meshSearch.H"
29 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  namespace sampledSets
37  {
39 
41  (
42  sampledSet,
43  triSurface,
44  word
45  );
46 
48  (
49  sampledSet,
50  triSurface,
51  word,
52  triSurfaceMesh,
53  "triSurfaceMesh"
54  );
55  }
56 }
57 
58 
59 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
60 
61 bool Foam::sampledSets::triSurface::calcSamples
62 (
63  DynamicList<point>& samplingPositions,
64  DynamicList<scalar>&,
65  DynamicList<label>& samplingSegments,
66  DynamicList<label>& samplingCells,
67  DynamicList<label>& samplingFaces
68 ) const
69 {
70  const meshSearch& searchEngine = meshSearch::New(mesh());
71 
72  forAll(points_, i)
73  {
74  const point& pt = points_[i];
75  const label celli = searchEngine.findCell(pt);
76 
77  if (celli != -1)
78  {
79  samplingPositions.append(pt);
80  samplingSegments.append(i);
81  samplingCells.append(celli);
82  samplingFaces.append(-1);
83  }
84  }
85 
86  // This set is unordered. Distances have not been created.
87  return false;
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 
94 (
95  const word& name,
96  const polyMesh& mesh,
97  const dictionary& dict
98 )
99 :
101  surface_(dict.lookup("surface")),
102  points_
103  (
104  mesh.time().foundObject<searchableSurfaces::triSurface>
105  (
106  surface_
107  )
108  ? mesh.time().lookupObject<searchableSurfaces::triSurface>
109  (
110  surface_
111  ).points()
112  : searchableSurfaces::triSurface
113  (
114  IOobject
115  (
116  surface_,
117  mesh.time().constant(),
118  searchableSurface::geometryDir(mesh.time()),
119  mesh.time(),
120  IOobject::MUST_READ,
121  IOobject::NO_WRITE,
122  false
123  )
124  ).points()
125  )
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
130 
132 {}
133 
134 
135 // ************************************************************************* //
#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
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSetI.H:36
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 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