controlPointsDefinition.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) 2020 PCOpt/NTUA
9 Copyright (C) 2020 FOSS GP
10 Copyright (C) 2021 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
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\*---------------------------------------------------------------------------*/
29
33
34
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
41}
42
43
44// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
45
47(
48 const vector& geometryMin,
49 const vector& geometryMax
50)
51{
52 const dictionary& dict = box_.dict();
53 // Translation vector
54 vector position(dict.get<vector>("translation"));
55
56 // Rotation vector
57 vector rotation(dict.get<vector>("rotation"));
58 const scalar deg2rad(constant::mathematical::pi/180.0);
59 rotation *= deg2rad;
60
61 // Scaling
62 vector scale(dict.get<vector>("scale"));
63
64 // Scale box
65 cps_ = cmptMultiply(cps_, scale);
66
67 // Rotation matrices
69 (
70 1, 0 , 0,
71 0, ::cos(rotation.x()), -::sin(rotation.x()),
72 0, ::sin(rotation.x()), ::cos(rotation.x())
73 );
75 (
76 ::cos(rotation.y()), 0, ::sin(rotation.y()),
77 0 , 1, 0,
78 -::sin(rotation.y()), 0, ::cos(rotation.y())
79 );
81 (
82 ::cos(rotation.z()), -::sin(rotation.z()), 0,
83 ::sin(rotation.z()), ::cos(rotation.z()), 0,
84 0, 0 , 1
85 );
86
87 // Comined rotation matrix
88 tensor R = (Rz & Rx) & Ry;
89
90 // Rotate cps
91 cps_ = R & cps_;
92
93 // Translate cps
94 cps_ += position;
95}
96
97
98// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
99
101(
102 NURBS3DVolume& box
103)
104:
105 box_(box),
106 cps_(box.getControlPoints())
107{}
108
109
110// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
111
113(
114 NURBS3DVolume& box
115)
116{
117 const dictionary& dict = box.dict();
118 const word type(dict.get<word>("controlPointsDefinition"));
119
120 Info<< "controlPointsDefinition type : " << type << endl;
121
122 auto* ctorPtr = dictionaryConstructorTable(type);
123
124 if (!ctorPtr)
125 {
127 (
128 dict,
129 "controlPointsDefinition",
130 type,
131 *dictionaryConstructorTablePtr_
132 ) << exit(FatalIOError);
133 }
134
135 return autoPtr<controlPointsDefinition>(ctorPtr(box));
136}
137
138
139// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
Macros for easy insertion into run-time selection tables.
NURBS3DVolume morpher. Includes support functions for gradient computations Base class providing supp...
Definition: NURBS3DVolume.H:76
const dictionary & dict() const
Get dictionary.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Abstract base for selecting how to construct the control points of a volumetric B-Splines morpher.
void transformControlPoints(const vector &geometryMin, const vector &geometryMax)
vectorField & cps_
The volumetric B-Splines control points.
NURBS3DVolume & box_
The volumetric B-Splines box.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
constexpr scalar pi(M_PI)
Namespace for OpenFOAM.
tensor Rx(const scalar omega)
Rotational transformation tensor about the x-axis by omega radians.
Definition: transform.H:85
tensor Ry(const scalar omega)
Rotational transformation tensor about the y-axis by omega radians.
Definition: transform.H:99
dimensionedScalar sin(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
tensor Rz(const scalar omega)
Rotational transformation tensor about the z-axis by omega radians.
Definition: transform.H:113
IOerror FatalIOError
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dimensionedScalar cos(const dimensionedScalar &ds)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict