Loading...
Searching...
No Matches
triSurfaceMeshPointSet.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "meshSearch.H"
31#include "DynamicList.H"
32#include "polyMesh.H"
35#include "Time.H"
36
37// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38
39namespace Foam
40{
43}
44
45
46// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47
48void Foam::triSurfaceMeshPointSet::calcSamples
49(
50 DynamicList<point>& samplingPts,
51 DynamicList<label>& samplingCells,
52 DynamicList<label>& samplingFaces,
53 DynamicList<label>& samplingSegments,
54 DynamicList<scalar>& samplingCurveDist
55) const
56{
57 forAll(sampleCoords_, sampleI)
58 {
59 label celli = searchEngine().findCell(sampleCoords_[sampleI]);
60
61 if (celli != -1)
62 {
63 samplingPts.append(sampleCoords_[sampleI]);
64 samplingCells.append(celli);
65 samplingFaces.append(-1);
66 samplingSegments.append(0);
67 samplingCurveDist.append(1.0 * sampleI);
68 }
69 }
70}
71
72
73void Foam::triSurfaceMeshPointSet::genSamples()
74{
75 // Storage for sample points
76 DynamicList<point> samplingPts;
77 DynamicList<label> samplingCells;
78 DynamicList<label> samplingFaces;
79 DynamicList<label> samplingSegments;
80 DynamicList<scalar> samplingCurveDist;
81
82 calcSamples
83 (
84 samplingPts,
85 samplingCells,
86 samplingFaces,
87 samplingSegments,
88 samplingCurveDist
89 );
90
91 samplingPts.shrink();
92 samplingCells.shrink();
93 samplingFaces.shrink();
94 samplingSegments.shrink();
95 samplingCurveDist.shrink();
96
97 // Move into *this
98 setSamples
99 (
100 std::move(samplingPts),
101 std::move(samplingCells),
102 std::move(samplingFaces),
103 std::move(samplingSegments),
104 std::move(samplingCurveDist)
105 );
106
107 if (debug)
108 {
110 }
111}
112
113
114// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
115
117(
118 const word& name,
119 const polyMesh& mesh,
120 const meshSearch& searchEngine,
121 const dictionary& dict
122)
123:
124 sampledSet(name, mesh, searchEngine, dict),
125 surfaceName_(dict.get<word>("surface"))
126{
127 // Get or load surface
128
129 const auto* surfPtr =
130 mesh.time().cfindObject<triSurfaceMesh>(surfaceName_);
131
132 if (surfPtr)
133 {
134 // Note: should use localPoints() instead of points() but assume
135 // trisurface is compact.
136 sampleCoords_ = surfPtr->points();
137 }
138 else
139 {
140 sampleCoords_ = triSurface
141 (
142 IOobject
143 (
144 surfaceName_,
145 mesh.time().constant(), // instance
146 "triSurface", // local
147 mesh.time(),
151 ),
153 ).points();
154 }
156 genSamples();
157}
158
159
160// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161
163(
164 const List<point>& pts
165) const
166{
167 if (pts.size())
168 {
169 // Use first samplePt as starting point
170 return pts.first();
171 }
172
173 return Zero;
174}
175
176
177// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
const Field< point_type > & points() const noexcept
Return reference to global points.
bool get(const label i) const
Definition UList.H:868
const word & name() const noexcept
The coord-set name.
Definition coordSet.H:152
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition meshSearch.H:57
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
Definition meshSearch.C:759
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition sampledSet.H:82
const meshSearch & searchEngine() const noexcept
Definition sampledSet.H:378
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const coordSet::coordFormat axisType)
Construct from components.
Definition sampledSet.C:405
const polyMesh & mesh() const noexcept
Definition sampledSet.H:373
A sampleSet from all points of a triSurfaceMesh.
virtual point getRefPoint(const List< point > &pts) const
Get reference point.
triSurfaceMeshPointSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
Triangulated surface description with patch information.
Definition triSurface.H:74
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
auto & name
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
runTime write()
dictionary dict
const pointField & pts
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299