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 | Copyright (C) 2015 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "bezier.H"
27 #include "SubList.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(bezier, 0);
35  addToRunTimeSelectionTable(curvedEdge, bezier, Istream);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const pointField& ps,
44  const label start,
45  const label end,
46  const pointField& control
47 )
48 :
49  curvedEdge(ps, start, end),
50  control_(control)
51 {}
52 
53 
55 :
56  curvedEdge(ps, is),
57  control_(appendEndPoints(ps, start_, end_, pointField(is)))
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  pointField working(control_);
72 
73  label nWorking(working.size());
74 
75  forAll(working, workingI)
76  {
77  -- nWorking;
78 
79  SubList<point>(working, nWorking).assign
80  (
81  (1 - lambda)*SubList<point>(working, nWorking)
82  + lambda*SubList<point>(working, nWorking, 1)
83  );
84  }
85 
86  return working[0];
87 }
88 
89 
90 Foam::scalar Foam::bezier::length() const
91 {
93  return 1.0;
94 }
95 
96 
97 // ************************************************************************* //
SubList.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::bezier::position
point position(const scalar lambda) const
Return the point position corresponding to the curve parameter.
Definition: bezier.C:69
bezier.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::bezier::length
scalar length() const
Return the length of the curve.
Definition: bezier.C:90
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::UList::assign
void assign(const UList< T > &)
Assign elements to those from UList.
Definition: UList.C:37
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::bezier::~bezier
virtual ~bezier()
Destructor.
Definition: bezier.C:63
Foam::Vector< scalar >
Foam::bezier::bezier
bezier(const bezier &)
Disallow default bitwise copy construct.
Foam::curvedEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start and end point.
Definition: curvedEdge.H:53
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
lambda
dimensionedScalar lambda(laminarTransport.lookup("lambda"))