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 blockEdge_H
46#define blockEdge_H
47
48#include "searchableSurfaces.H"
49#include "edge.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57class blockEdge;
58Ostream& operator<<(Ostream& os, const blockEdge& e);
59
60/*---------------------------------------------------------------------------*\
61 Class blockEdge Declaration
62\*---------------------------------------------------------------------------*/
64class blockEdge
65{
66protected:
67
68 // Protected Data
69
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
79
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
115 (
116 autoPtr,
117 blockEdge,
118 Istream,
119 (
120 const dictionary& dict,
121 const label index,
122 const searchableSurfaces& geometry,
123 const pointField& points,
124 Istream& is
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:
172 iNew
173 (
174 const dictionary& dict,
175 const searchableSurfaces& geometry,
176 const pointField& points
177 )
178 :
179 dict_(dict),
180 geometry_(geometry),
181 points_(points),
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 valid() const noexcept;
200
201 //- Index of start (first) point
202 inline label start() const noexcept;
203
204 //- Index of end (last) point
205 inline label end() const noexcept;
206
207 //- The location of the first point
208 inline const point& firstPoint() const;
209
210 //- The location of the last point
211 inline const point& lastPoint() const;
212
213
214 //- Compare the given start/end points with this block edge
215 // Return:
216 // - 0: different
217 // - +1: identical
218 // - -1: same edge, but different orientation
219 inline int compare(const blockEdge& e) const;
220
221 //- Compare the given start/end points with this block edge
222 // Return:
223 // - 0: different
224 // - +1: identical
225 // - -1: same edge, but different orientation
226 inline int compare(const edge& e) const;
227
228 //- Compare the given start/end points with this block edge
229 // Return:
230 // - 0: different
231 // - +1: identical
232 // - -1: same edge, but different orientation
233 inline int compare(const label start, const label end) const;
234
235
236 //- The point position in the straight line
237 // 0 <= lambda <= 1
238 inline point linearPosition(const scalar lambda) const;
239
240 //- The point position corresponding to the curve parameter
241 // 0 <= lambda <= 1
242 virtual point position(const scalar lambda) const = 0;
243
244 //- The point positions corresponding to the curve parameters
245 // 0 <= lambda <= 1
246 virtual tmp<pointField> position(const scalarList& lambdas) const;
247
248 //- The length of the curve
249 virtual scalar length() const = 0;
250
251 //- Write edge with variable back-substitution
252 void write(Ostream& os, const dictionary& dict) const;
253
254
255 // Ostream Operator
257 friend Ostream& operator<<(Ostream& os, const blockEdge& e);
258};
259
260
261// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262
263} // End namespace Foam
264
265// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267#include "blockEdgeI.H"
268
269// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271#endif
272
273// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Class used for the read-construction of.
Definition: blockEdge.H:163
autoPtr< blockEdge > operator()(Istream &is) const
Definition: blockEdge.H:184
iNew(const dictionary &dict, const searchableSurfaces &geometry, const pointField &points)
Definition: blockEdge.H:172
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition: blockEdge.H:64
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:70
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition: blockEdge.C:70
point linearPosition(const scalar lambda) const
The point position in the straight line.
Definition: blockEdgeI.H:88
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:78
const point & lastPoint() const
The location of the last point.
Definition: blockEdgeI.H:55
virtual ~blockEdge()=default
Destructor.
bool valid() const noexcept
True if first/last indices are unique and non-negative.
Definition: blockEdgeI.H:31
const label end_
Index of the last point.
Definition: blockEdge.H:76
static pointField appendEndPoints(const pointField &p, const label from, const label to, const pointField &intermediate)
Definition: blockEdge.C:110
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:43
label start() const noexcept
Index of start (first) point.
Definition: blockEdgeI.H:37
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:73
int compare(const blockEdge &e) const
Compare the given start/end points with this block edge.
Definition: blockEdgeI.H:76
const point & firstPoint() const
The location of the first point.
Definition: blockEdgeI.H:49
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
A class for managing temporary objects.
Definition: tmp.H:65
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)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
volScalarField & e
Definition: createFields.H:11
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73