blockEdgeI.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) 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 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 inline bool Foam::blockEdge::valid() const noexcept
32 {
33  return (start_ != end_ && start_ >= 0 && end_ >= 0);
34 }
35 
36 
37 inline Foam::label Foam::blockEdge::start() const noexcept
38 {
39  return start_;
40 }
41 
42 
43 inline Foam::label Foam::blockEdge::end() const noexcept
44 {
45  return end_;
46 }
47 
48 
50 {
51  return points_[start_];
52 }
53 
54 
56 {
57  return points_[end_];
58 }
59 
60 
61 inline int Foam::blockEdge::compare(const label start, const label end) const
62 {
63  if (start_ == start && end_ == end)
64  {
65  return 1;
66  }
67  else if (start_ == end && end_ == start)
68  {
69  return -1;
70  }
71 
72  return 0;
73 }
74 
75 
76 inline int Foam::blockEdge::compare(const blockEdge& e) const
77 {
78  return Foam::blockEdge::compare(e.start(), e.end());
79 }
80 
81 
82 inline int Foam::blockEdge::compare(const edge& e) const
83 {
84  return Foam::blockEdge::compare(e.start(), e.end());
85 }
86 
87 
89 {
90  #ifdef FULLDEBUG
91  if (lambda < -SMALL || lambda > 1 + SMALL)
92  {
94  << "Limit parameter to [0-1] range: " << lambda << nl;
95  }
96  #endif
97 
98  if (lambda < SMALL)
99  {
100  return firstPoint();
101  }
102  else if (lambda >= 1 - SMALL)
103  {
104  return lastPoint();
105  }
106 
107  return firstPoint() + lambda * (lastPoint() - firstPoint());
108 }
109 
110 
111 // ************************************************************************* //
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
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
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::linearPosition
point linearPosition(const scalar lambda) const
The point position in the straight line.
Definition: blockEdgeI.H:88
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
lambda
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
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::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::nl
constexpr char nl
Definition: Ostream.H:404
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::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11