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-2019 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 "SubList.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace blockEdges
37 {
38  defineTypeNameAndDebug(bezier, 0);
39  addToRunTimeSelectionTable(blockEdge, bezier, Istream);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 Foam::blockEdges::bezier::bezier
47 (
48  const pointField& points,
49  const label start,
50  const label end,
51  const pointField& control
52 )
53 :
54  blockEdge(points, start, end),
55  control_(control)
56 {}
57 
58 
59 Foam::blockEdges::bezier::bezier
60 (
61  const dictionary& dict,
62  const label index,
63  const searchableSurfaces& geometry,
64  const pointField& points,
65  Istream& is
66 )
67 :
68  blockEdge(dict, index, points, is),
69  control_(appendEndPoints(points, start_, end_, pointField(is)))
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
76 {
77  pointField working(control_);
78 
79  label nWorking(working.size());
80 
81  forAll(working, workingI)
82  {
83  --nWorking;
84 
85  SubList<point>(working, nWorking) =
86  (1 - lambda)*SubList<point>(working, nWorking)
87  + lambda*SubList<point>(working, nWorking, 1);
88  }
89 
90  return working[0];
91 }
92 
93 
95 {
97  return 1.0;
98 }
99 
100 
101 // ************************************************************************* //
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:53
Foam::blockEdges::bezier::length
scalar length() const
Return the length of the curve.
Definition: bezier.C:94
Foam::blockEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start and end point.
Definition: blockEdge.H:59
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:436
Foam::blockEdges::defineTypeNameAndDebug
defineTypeNameAndDebug(arcEdge, 0)
Foam::Field< vector >
Foam::blockEdges::addToRunTimeSelectionTable
addToRunTimeSelectionTable(blockEdge, arcEdge, Istream)
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:121
lambda
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
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:75