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 blockEdge_H
46 #define 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
98  (
99  const pointField& points,
100  const label from,
101  const label to
102  )
103  :
104  blockEdge(points, edge(from,to))
105  {}
106 
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 
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  {}
184 
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
256 
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 // ************************************************************************* //
Foam::blockEdge::TypeName
TypeName("blockEdge")
Runtime type information.
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::blockEdge::iNew::iNew
iNew(const dictionary &dict, const searchableSurfaces &geometry, const pointField &points)
Definition: blockEdge.H:172
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::blockEdge::New
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
Foam::blockEdge::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, blockEdge, Istream,(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &is),(dict, index, geometry, points, is))
Foam::blockEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition: blockEdge.H:63
Foam::blockEdge::lastPoint
const point & lastPoint() const
The location of the last point.
Definition: blockEdgeI.H:55
Foam::blockEdge::blockEdge
blockEdge(const pointField &points, const label from, const label to)
Construct from components.
Definition: blockEdge.H:97
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
searchableSurfaces.H
Foam::blockEdge::~blockEdge
virtual ~blockEdge()=default
Destructor.
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::blockEdge::points_
const pointField & points_
The referenced point field.
Definition: blockEdge.H:70
Foam::blockEdge::linearPosition
point linearPosition(const scalar lambda) const
The point position in the straight line.
Definition: blockEdgeI.H:88
Foam::blockEdge::iNew::operator()
autoPtr< blockEdge > operator()(Istream &is) const
Definition: blockEdge.H:184
Foam::blockEdge::length
virtual scalar length() const =0
The length of the curve.
Foam::blockEdge::end
label end() const noexcept
Index of end (last) point.
Definition: blockEdgeI.H:43
Foam::blockEdge::start_
const label start_
Index of the first point.
Definition: blockEdge.H:73
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
lambda
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
os
OBJstream os(runTime.globalPath()/outputName)
Foam::blockEdge::position
virtual point position(const scalar lambda) const =0
The point position corresponding to the curve parameter.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::blockEdge::appendEndPoints
static pointField appendEndPoints(const pointField &p, const label from, const label to, const pointField &intermediate)
Definition: blockEdge.C:110
edge.H
Foam::blockEdge::end_
const label end_
Index of the last point.
Definition: blockEdge.H:76
Foam::blockEdge::start
label start() const noexcept
Index of start (first) point.
Definition: blockEdgeI.H:37
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::blockEdge::compare
int compare(const blockEdge &e) const
Compare the given start/end points with this block edge.
Definition: blockEdgeI.H:76
Foam::blockEdge::firstPoint
const point & firstPoint() const
The location of the first point.
Definition: blockEdgeI.H:49
Foam::blockEdge::iNew
Class used for the read-construction of.
Definition: blockEdge.H:162
Foam::Vector< scalar >
Foam::blockEdge::valid
bool valid() const noexcept
True if first/last indices are unique and non-negative.
Definition: blockEdgeI.H:31
Foam::List< scalar >
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::blockEdge::clone
virtual autoPtr< blockEdge > clone() const
Clone function.
Definition: blockEdge.C:70
Foam::blockEdge::write
void write(Ostream &os, const dictionary &dict) const
Write edge with variable back-substitution.
Definition: blockEdge.C:137
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56