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 -------------------------------------------------------------------------------
11 License
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 Namespace
28  Foam::blockEdges
29 
30 Description
31  A namespace for various blockEdge types.
32 
33 Class
34  Foam::blockEdge
35 
36 Description
37  Define a curved edge that is parameterized for 0<lambda<1
38  between the start/end points.
39 
40 SourceFiles
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 
53 namespace Foam
54 {
55 
56 // Forward Declarations
57 class blockEdge;
58 Ostream& operator<<(Ostream& os, const blockEdge& e);
59 
60 /*---------------------------------------------------------------------------*\
61  Class blockEdge Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class blockEdge
65 {
66 protected:
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 
80 protected:
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
97  blockEdge
98  (
99  const pointField& points,
100  const label from,
101  const label to
102  )
103  :
104  blockEdge(points, edge(from,to))
105  {}
107 public:
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  (
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
133  blockEdge
134  (
135  const pointField& points,
136  const edge& fromTo
137  );
138 
139  //- Construct from Istream and point field.
140  blockEdge
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
152  static autoPtr<blockEdge> New
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),
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;
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 
216 
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 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
blockEdge(const pointField &points, const label from, const label to)
Construct from components.
Definition: blockEdge.H:106
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const pointField & points_
The referenced point field.
Definition: blockEdge.H:69
bool good() const noexcept
True if first/last indices are unique and non-negative.
Definition: blockEdgeI.H:24
label end() const noexcept
Index of end (last) point.
Definition: blockEdgeI.H:36
virtual ~blockEdge()=default
Destructor.
Class used for the read-construction of.
Definition: blockEdge.H:184
point linearPosition(const scalar lambda) const
The point position in the straight line.
Definition: blockEdgeI.H:81
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 dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
int compare(const blockEdge &e) const
Compare the given start/end points with this block edge.
Definition: blockEdgeI.H:69
virtual point position(const scalar lambda) const =0
The point position corresponding to the curve parameter.
const pointField & points
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:59
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
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
autoPtr< blockEdge > operator()(Istream &is) const
Definition: blockEdge.H:206
iNew(const dictionary &dict, const searchableSurfaces &geometry, const pointField &points)
Definition: blockEdge.H:194
bool valid() const noexcept
Same as good()
Definition: blockEdge.H:229
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
void write(Ostream &os, const dictionary &dict) const
Write edge with variable back-substitution.
Definition: blockEdge.C:130
declareRunTimeSelectionTable(autoPtr, blockEdge, Istream,(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &is),(dict, index, geometry, points, is))
const point & lastPoint() const
The location of the last point.
Definition: blockEdgeI.H:48
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition: blockEdge.C:63
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
virtual scalar length() const =0
The length of the curve.
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition: blockEdge.H:60
TypeName("blockEdge")
Runtime type information.
const label start_
Index of the first point.
Definition: blockEdge.H:74
label start() const noexcept
Index of start (first) point.
Definition: blockEdgeI.H:30
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const point & firstPoint() const
The location of the first point.
Definition: blockEdgeI.H:42
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const label end_
Index of the last point.
Definition: blockEdge.H:79
Namespace for OpenFOAM.