triSurfaceMeshSampledSet.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-2021 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 
27 #include "meshSearch.H"
28 #include "DynamicList.H"
29 #include "polyMesh.H"
31 #include "triSurfaceMesh.H"
32 #include "Time.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace sampledSets
39 {
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 void Foam::sampledSets::triSurfaceMeshSampledSet::calcSamples
49 (
50  DynamicList<point>& samplingPositions,
51  DynamicList<label>& samplingSegments,
52  DynamicList<label>& samplingCells,
53  DynamicList<label>& samplingFaces
54 ) const
55 {
56  forAll(points_, i)
57  {
58  const point& pt = points_[i];
59  const label celli = searchEngine().findCell(pt);
60 
61  if (celli != -1)
62  {
63  samplingPositions.append(pt);
64  samplingSegments.append(i);
65  samplingCells.append(celli);
66  samplingFaces.append(-1);
67  }
68  }
69 }
70 
71 
72 void Foam::sampledSets::triSurfaceMeshSampledSet::genSamples()
73 {
74  DynamicList<point> samplingPositions;
75  DynamicList<label> samplingSegments;
76  DynamicList<label> samplingCells;
77  DynamicList<label> samplingFaces;
78 
79  calcSamples
80  (
81  samplingPositions,
82  samplingSegments,
83  samplingCells,
84  samplingFaces
85  );
86 
87  samplingPositions.shrink();
88  samplingSegments.shrink();
89  samplingCells.shrink();
90  samplingFaces.shrink();
91 
92  setSamples
93  (
94  samplingPositions,
95  samplingSegments,
96  samplingCells,
97  samplingFaces
98  );
99 }
100 
101 
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
103 
105 (
106  const word& name,
107  const polyMesh& mesh,
108  const meshSearch& searchEngine,
109  const dictionary& dict
110 )
111 :
112  sampledSet(name, mesh, searchEngine, dict),
113  surface_(dict.lookup("surface")),
114  points_
115  (
116  mesh.time().foundObject<triSurfaceMesh>(surface_)
117  ? mesh.time().lookupObject<triSurfaceMesh>(surface_).points()
119  (
120  IOobject
121  (
122  surface_,
123  mesh.time().constant(),
124  searchableSurface::geometryDir(mesh.time()),
125  mesh.time(),
126  IOobject::MUST_READ,
127  IOobject::NO_WRITE,
128  false
129  )
130  ).points()
131  )
132 {
133  genSamples();
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
140 {}
141 
142 
143 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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:750
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:64
const meshSearch & searchEngine() const
Access the search engine.
Definition: sampledSet.H:216
Specified point samples. Optionally ordered into a continuous path. Ordering is an optimisation; it e...
Definition: points.H:107
Samples from all the points of a triSurfaceMesh. Surface files are read from constant/triSurface.
triSurfaceMeshSampledSet(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 surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals,...
A class for handling words, derived from string.
Definition: word.H:62
defineTypeNameAndDebug(arcUniform, 0)
addToRunTimeSelectionTable(sampledSet, arcUniform, word)
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
vector point
Point is a vector.
Definition: point.H:41
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict