bezier.C
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) 2015-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "bezier.H"
29 #include "polyLine.H"
30 #include "SubList.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace blockEdges
38 {
39  defineTypeNameAndDebug(bezier, 0);
40  addToRunTimeSelectionTable(blockEdge, bezier, Istream);
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 Foam::blockEdges::bezier::bezier
48 (
49  const pointField& points,
50  const edge& fromTo,
51  const pointField& control
52 )
53 :
54  blockEdge(points, fromTo),
55  control_(control)
56 {}
57 
58 
59 Foam::blockEdges::bezier::bezier
60 (
61  const pointField& points,
62  const label from,
63  const label to,
64  const pointField& control
65 )
66 :
67  bezier(points, edge(from, to), control)
68 {}
69 
70 
71 Foam::blockEdges::bezier::bezier
72 (
73  const dictionary& dict,
74  const label index,
75  const searchableSurfaces&,
76  const pointField& points,
77  Istream& is
78 )
79 :
80  blockEdge(dict, index, points, is),
81  control_
82  (
83  polyLine::concat(firstPoint(), pointField(is), lastPoint())
84  )
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91 {
92  pointField working(control_);
93 
94  label nWorking(working.size());
95 
96  forAll(working, workingI)
97  {
98  --nWorking;
99 
100  SubList<point>(working, nWorking) =
101  (1 - lambda)*SubList<point>(working, nWorking)
102  + lambda*SubList<point>(working, nWorking, 1);
103  }
104 
105  return working[0];
106 }
107 
108 
110 {
112  return 1;
113 }
114 
115 
116 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
SubList.H
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
polyLine.H
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::blockEdges::bezier::length
scalar length() const
Return the length of the curve.
Definition: bezier.C:109
Foam::blockEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
Definition: blockEdge.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
bezier.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::blockEdges::defineTypeNameAndDebug
defineTypeNameAndDebug(arcEdge, 0)
Foam::Field< vector >
Foam::blockEdges::addToRunTimeSelectionTable
addToRunTimeSelectionTable(blockEdge, arcEdge, Istream)
Foam::blockEdges::bezier
Nth order bezier curve edge. Only interior control points should be specified. The outer points are t...
Definition: bezier.H:61
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
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)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Vector< scalar >
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::blockEdges::bezier::position
point position(const scalar lambda) const
Return the point position corresponding to the curve parameter.
Definition: bezier.C:90