NURBSbasis.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) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 Class
29  Foam::NURBSbasis
30 
31 Description
32  NURBSbasis function. Used to construct NURBS curves, surfaces and volumes
33 
34 SourceFiles
35  NURBSbasis.C
36  NURBSbasisTemplates.C
37  NURBSbasisI.H
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef NURBSbasis_H
42 #define NURBSbasis_H
43 
44 #include "dictionary.H"
45 #include "scalarField.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class NURBSbasis Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class NURBSbasis
57 {
58  // Private data
59 
60  //- Number of control points
61  label nCPs_;
62 
63  //- Basis order
64  label basisDegree_;
65 
66  //- Knot values
67  scalarField knots_;
68 
69 
70  // Private Member Functions
71 
72  //- Compute knots
73  void computeKnots();
74 
75 
76 public:
77 
78  //- Runtime type information
79  TypeName("NURBbasis");
80 
81  // Constructors
82 
83  //- Construct from number of control points, knot vector and basis order
85  (
86  const label nCPs,
87  const label degree,
88  const scalarField& knots
89  );
90 
91  //- Construct from number of control points and basis order
92  // Assumes uniform knot vector
94  (
95  const label nCPs,
96  const label degree
97  );
98 
99  //- Construct from dictionary
100  // Assumes uniform knot vector
101  NURBSbasis
102  (
103  const dictionary& dict
104  );
105 
106  //- Construct as copy
107  NURBSbasis(const NURBSbasis&);
108 
109 
110  //- Destructor
111  virtual ~NURBSbasis() = default;
112 
113 
114  // Member Functions
115 
116  //- Basis value
117  scalar basisValue
118  (
119  const label iCP,
120  const label degree,
121  const scalar u
122  ) const;
123 
124  //- Basis derivative w.r.t u
125  scalar basisDerivativeU
126  (
127  const label iCP,
128  const label degree,
129  const scalar u
130  ) const;
131 
132  //- Basis second derivative w.r.t u
133  scalar basisDerivativeUU
134  (
135  const label iCP,
136  const label degree,
137  const scalar u
138  ) const;
139 
140  //- Checks to see if given u is affected by given CP.
141  bool checkRange
142  (
143  const scalar u,
144  const label CPI,
145  const label degree
146  ) const;
147 
148  //- Adds the new knot's u value, increments the nCPs and returns 'k',
149  //- the index of the newly inserted uValue.
150  // uBar should be pre-bounded between 0,1.
151  label insertKnot
152  (
153  const scalar uBar
154  );
155 
156  inline const scalarField& knots() const;
157 
158  inline const label& degree() const;
159 
160  inline const label& nCPs() const;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #include "NURBSbasisI.H"
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
Foam::NURBSbasis::basisDerivativeU
scalar basisDerivativeU(const label iCP, const label degree, const scalar u) const
Basis derivative w.r.t u.
Definition: NURBSbasis.C:190
scalarField.H
Foam::NURBSbasis::basisValue
scalar basisValue(const label iCP, const label degree, const scalar u) const
Basis value.
Definition: NURBSbasis.C:140
Foam::NURBSbasis
NURBSbasis function. Used to construct NURBS curves, surfaces and volumes.
Definition: NURBSbasis.H:55
Foam::NURBSbasis::insertKnot
label insertKnot(const scalar uBar)
Definition: NURBSbasis.C:298
Foam::NURBSbasis::degree
const label & degree() const
Definition: NURBSbasisI.H:40
Foam::NURBSbasis::basisDerivativeUU
scalar basisDerivativeUU(const label iCP, const label degree, const scalar u) const
Basis second derivative w.r.t u.
Definition: NURBSbasis.C:231
Foam::Field< scalar >
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
Foam::NURBSbasis::nCPs
const label & nCPs() const
Definition: NURBSbasisI.H:46
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::NURBSbasis::~NURBSbasis
virtual ~NURBSbasis()=default
Destructor.
NURBSbasisI.H
Foam::NURBSbasis::knots
const scalarField & knots() const
Definition: NURBSbasisI.H:34
dictionary.H
Foam::NURBSbasis::NURBSbasis
NURBSbasis(const label nCPs, const label degree, const scalarField &knots)
Construct from number of control points, knot vector and basis order.
Definition: NURBSbasis.C:84
Foam::NURBSbasis::checkRange
bool checkRange(const scalar u, const label CPI, const label degree) const
Checks to see if given u is affected by given CP.
Definition: NURBSbasis.C:273
Foam::NURBSbasis::TypeName
TypeName("NURBbasis")
Runtime type information.