Loading...
Searching...
No Matches
midPointAndFaceSet.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-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "midPointAndFaceSet.H"
29#include "polyMesh.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
39}
40
41
42// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43
44void Foam::midPointAndFaceSet::genSamples()
45{
46 // Generate midpoints and add to face points
47
48 List<point> mpfSamplePoints(3*size());
49 labelList mpfSampleCells(3*size());
50 labelList mpfSampleFaces(3*size());
51 labelList mpfSampleSegments(3*size());
52 scalarList mpfSampleCurveDist(3*size());
53
54 label mpfSamplei = 0;
55 label samplei = 0;
56
57 while (size() > 0)
58 {
59 // Add first face
60 mpfSamplePoints[mpfSamplei] = points()[samplei];
61 mpfSampleCells[mpfSamplei] = cells_[samplei];
62 mpfSampleFaces[mpfSamplei] = faces_[samplei];
63 mpfSampleSegments[mpfSamplei] = segments_[samplei];
64 mpfSampleCurveDist[mpfSamplei] = distance_[samplei];
65 ++mpfSamplei;
66
67 while
68 (
69 (samplei < size() - 1)
70 && (segments_[samplei] == segments_[samplei+1])
71 )
72 {
73 point midPoint(0.5*(points()[samplei] + points()[samplei+1]));
74 label cellm = pointInCell(midPoint, samplei);
75
76 if (cellm != -1)
77 {
78 mpfSamplePoints[mpfSamplei] = midPoint;
79 mpfSampleCells[mpfSamplei] = cellm;
80 mpfSampleFaces[mpfSamplei] = -1;
81 mpfSampleSegments[mpfSamplei] = segments_[samplei];
82 mpfSampleCurveDist[mpfSamplei] =
83 mag(mpfSamplePoints[mpfSamplei] - start());
84
85 ++mpfSamplei;
86 }
87
88 // Add second face
89 mpfSamplePoints[mpfSamplei] = operator[](samplei+1);
90 mpfSampleCells[mpfSamplei] = cells_[samplei+1];
91 mpfSampleFaces[mpfSamplei] = faces_[samplei+1];
92 mpfSampleSegments[mpfSamplei] = segments_[samplei+1];
93 mpfSampleCurveDist[mpfSamplei] =
94 mag(mpfSamplePoints[mpfSamplei] - start());
95
96 ++mpfSamplei;
97
98 ++samplei;
99 }
100
101 if (samplei == size() - 1)
102 {
103 break;
104 }
105 ++samplei;
106 }
107
108 mpfSamplePoints.setSize(mpfSamplei);
109 mpfSampleCells.setSize(mpfSamplei);
110 mpfSampleFaces.setSize(mpfSamplei);
111 mpfSampleSegments.setSize(mpfSamplei);
112 mpfSampleCurveDist.setSize(mpfSamplei);
113
114 // Move into *this
116 (
117 std::move(mpfSamplePoints),
118 std::move(mpfSampleCells),
119 std::move(mpfSampleFaces),
120 std::move(mpfSampleSegments),
121 std::move(mpfSampleCurveDist)
122 );
123
124 if (debug)
125 {
127 }
128}
129
130
131// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
132
134(
135 const word& name,
136 const polyMesh& mesh,
137 const meshSearch& searchEngine,
138 const word& axis,
139 const point& start,
140 const point& end
141)
144{
145 genSamples();
146}
147
148
150(
151 const word& name,
152 const polyMesh& mesh,
153 const meshSearch& searchEngine,
154 const dictionary& dict
155)
156:
157 faceOnlySet(name, mesh, searchEngine, dict)
158{
159 genSamples();
160}
161
162
163// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label size() const noexcept
Definition UList.H:706
vector & operator[](const label i)
scalarList distance_
Cumulative distance for "distance" write specifier.
Definition coordSet.H:89
const word & axis() const
The sort axis name.
Definition coordSet.H:160
const pointField & points() const noexcept
Return the points.
Definition coordSet.H:168
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Sample on faces along a specified path.
Definition faceOnlySet.H:85
const point & start() const
const point & end() const
faceOnlySet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const point &start, const point &end)
Construct from components.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition meshSearch.H:57
midPointAndFaceSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const point &start, const point &end)
Construct from components.
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
labelList faces_
Face numbers (-1 if not known).
Definition sampledSet.H:113
const meshSearch & searchEngine() const noexcept
Definition sampledSet.H:378
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingDistance)
Set sample data. Copy list contents.
Definition sampledSet.C:363
label pointInCell(const point &p, const label samplei) const
Return the cell in which the point on the sample line.
Definition sampledSet.C:80
labelList segments_
Segment numbers.
Definition sampledSet.H:103
labelList cells_
Cell numbers.
Definition sampledSet.H:108
const polyMesh & mesh() const noexcept
Definition sampledSet.H:373
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 OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
Definition point.H:37
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
runTime write()
dictionary dict