Loading...
Searching...
No Matches
blockEdge.H
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) 2019-2021 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
27Namespace
28 Foam::blockEdges
29
30Description
31 A namespace for various blockEdge types.
32
33Class
34 Foam::blockEdge
35
36Description
37 Define a curved edge that is parameterized for 0<lambda<1
38 between the start/end points.
39
40SourceFiles
41 blockEdge.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_blockEdge_H
46#define Foam_blockEdge_H
47
48#include "searchableSurfaces.H"
49#include "edge.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57class blockEdge;
59
60/*---------------------------------------------------------------------------*\
61 Class blockEdge Declaration
62\*---------------------------------------------------------------------------*/
63
64class blockEdge
65{
66protected:
67
68 // Protected Data
70 //- The referenced point field
71 const pointField& points_;
72
73 //- Index of the first point
74 const label start_;
75
76 //- Index of the last point
77 const label end_;
78
80protected:
81
82 // Protected Member Functions
83
84 //- Return a complete point field by appending the start/end points
85 //- to the given list
86 // \deprecated(2020-10) use polyLine::concat
88 (
89 const pointField& p,
90 const label from,
91 const label to,
92 const pointField& intermediate
93 );
94
95 //- Construct from components
96 // \deprecated(2021-11) use constructor with edge
98 (
99 const pointField& points,
100 const label from,
101 const label to
102 )
103 :
104 blockEdge(points, edge(from,to))
105 {}
106
107public:
108
109 //- Runtime type information
110 TypeName("blockEdge");
111
112 // Declare run-time constructor selection tables
113
115 (
116 autoPtr,
117 blockEdge,
118 Istream,
119 (
121 const label index,
122 const searchableSurfaces& geometry,
123 const pointField& points,
125 ),
126 (dict, index, geometry, points, is)
127 );
128
129
130 // Constructors
131
132 //- Construct from components
134 (
135 const pointField& points,
136 const edge& fromTo
137 );
138
139 //- Construct from Istream and point field.
141 (
142 const dictionary& dict,
143 const label index,
144 const pointField& points,
145 Istream& is
146 );
147
148 //- Clone function
149 virtual autoPtr<blockEdge> clone() const;
150
151 //- New function which constructs and returns pointer to a blockEdge
153 (
154 const dictionary& dict,
155 const label index,
156 const searchableSurfaces& geometry,
157 const pointField& points,
158 Istream& is
159 );
160
161 //- Class used for the read-construction of
162 // PtrLists of blockEdge
163 class iNew
164 {
165 const dictionary& dict_;
166 const searchableSurfaces& geometry_;
167 const pointField& points_;
168 mutable label index_;
169
170 public:
171
172 iNew
173 (
174 const dictionary& dict,
175 const searchableSurfaces& geometry,
176 const pointField& points
177 )
178 :
179 dict_(dict),
180 geometry_(geometry),
182 index_(0)
183 {}
186 {
187 return blockEdge::New(dict_, index_++, geometry_, points_, is);
188 }
189 };
190
191
192 //- Destructor
193 virtual ~blockEdge() = default;
194
195
196 // Member Functions
197
198 //- True if first/last indices are unique and non-negative.
199 inline bool good() const noexcept;
200
201 //- Same as good()
202 bool valid() const noexcept { return good(); }
203
204 //- Index of start (first) point
205 inline label start() const noexcept;
207 //- Index of end (last) point
208 inline label end() const noexcept;
209
210 //- The location of the first point
211 inline const point& firstPoint() const;
212
213 //- The location of the last point
214 inline const point& lastPoint() const;
215
217 //- Compare the given start/end points with this block edge
218 // Return:
219 // - 0: different
220 // - +1: identical
221 // - -1: same edge, but different orientation
222 inline int compare(const blockEdge& e) const;
223
224 //- Compare the given start/end points with this block edge
225 // Return:
226 // - 0: different
227 // - +1: identical
228 // - -1: same edge, but different orientation
229 inline int compare(const edge& e) const;
230
231 //- Compare the given start/end points with this block edge
232 // Return:
233 // - 0: different
234 // - +1: identical
235 // - -1: same edge, but different orientation
236 inline int compare(const label start, const label end) const;
237
238
239 //- The point position in the straight line
240 // 0 <= lambda <= 1
241 inline point linearPosition(const scalar lambda) const;
242
243 //- The point position corresponding to the curve parameter
244 // 0 <= lambda <= 1
245 virtual point position(const scalar lambda) const = 0;
246
247 //- The point positions corresponding to the curve parameters
248 // 0 <= lambda <= 1
249 virtual tmp<pointField> position(const scalarList& lambdas) const;
250
251 //- The length of the curve
252 virtual scalar length() const = 0;
253
254 //- Write edge with variable back-substitution
255 void write(Ostream& os, const dictionary& dict) const;
256
257
258 // Ostream Operator
259
260 friend Ostream& operator<<(Ostream& os, const blockEdge& e);
261};
262
263
264// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265
266} // End namespace Foam
267
268// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269
270#include "blockEdgeI.H"
271
272// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273
274#endif
275
276// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Class used for the read-construction of.
Definition blockEdge.H:185
autoPtr< blockEdge > operator()(Istream &is) const
Definition blockEdge.H:206
iNew(const dictionary &dict, const searchableSurfaces &geometry, const pointField &points)
Definition blockEdge.H:194
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition blockEdge.H:61
virtual scalar length() const =0
The length of the curve.
TypeName("blockEdge")
Runtime type information.
const pointField & points_
The referenced point field.
Definition blockEdge.H:69
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition blockEdge.C:63
blockEdge(const pointField &points, const label from, const label to)
Construct from components.
Definition blockEdge.H:106
point linearPosition(const scalar lambda) const
The point position in the straight line.
Definition blockEdgeI.H:81
bool good() const noexcept
True if first/last indices are unique and non-negative.
Definition blockEdgeI.H:24
static autoPtr< blockEdge > New(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &is)
New function which constructs and returns pointer to a blockEdge.
Definition blockEdge.C:71
const point & lastPoint() const
The location of the last point.
Definition blockEdgeI.H:48
virtual ~blockEdge()=default
Destructor.
bool valid() const noexcept
Same as good().
Definition blockEdge.H:229
const label end_
Index of the last point.
Definition blockEdge.H:79
static pointField appendEndPoints(const pointField &p, const label from, const label to, const pointField &intermediate)
Return a complete point field by appending the start/end points to the given list.
Definition blockEdge.C:103
declareRunTimeSelectionTable(autoPtr, blockEdge, Istream,(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &is),(dict, index, geometry, points, is))
label end() const noexcept
Index of end (last) point.
Definition blockEdgeI.H:36
label start() const noexcept
Index of start (first) point.
Definition blockEdgeI.H:30
virtual point position(const scalar lambda) const =0
The point position corresponding to the curve parameter.
const label start_
Index of the first point.
Definition blockEdge.H:74
int compare(const blockEdge &e) const
Compare the given start/end points with this block edge.
Definition blockEdgeI.H:69
void write(Ostream &os, const dictionary &dict) const
Write edge with variable back-substitution.
Definition blockEdge.C:130
const point & firstPoint() const
The location of the first point.
Definition blockEdgeI.H:42
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
volScalarField & e
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68