Loading...
Searching...
No Matches
NURBS3DVolumeCylindrical.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) 2007-2023 PCOpt/NTUA
9 Copyright (C) 2013-2023 FOSS GP
10 Copyright (C) 2019 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
32#include "pointMesh.H"
33#include "pointPatchField.H"
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
40
43 (
47 );
48}
49
50
51// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
52
54(
55 const vector& localSystemCoordinates
56) const
57{
58 vector cartesianCoors
59 (
60 localSystemCoordinates.x()*cos(localSystemCoordinates.y()),
61 localSystemCoordinates.x()*sin(localSystemCoordinates.y()),
62 localSystemCoordinates.z()
63 );
64 cartesianCoors += origin_;
65
66 return cartesianCoors;
67}
68
69
71(
72 label globalPointIndex
73)
74{
75 const vector& localCoors = localSystemCoordinates_[globalPointIndex];
76 tensor transformTensor
77 (
78 cos(localCoors.y()), -localCoors.x()*sin(localCoors.y()), 0,
79 sin(localCoors.y()), localCoors.x()*cos(localCoors.y()), 0,
80 0, 0, 1
81 );
82
83 return transformTensor;
84}
85
86
88(
89 const vectorField& cartesianPoints
90)
91{
92 forAll(cartesianPoints, pI)
93 {
94 const vector point(cartesianPoints[pI] - origin_);
95 vector cylindricalCoors(Zero);
96
97 const scalar R(Foam::sqrt(sqr(point.x()) + sqr(point.y())));
98 const scalar theta(atan2(point.y(), point.x()));
99 cylindricalCoors.x() = R;
100 cylindricalCoors.y() = theta;
101 cylindricalCoors.z() = cartesianPoints[pI].z();
102 localSystemCoordinates_[pI] = cylindricalCoors;
103 }
104
105 pointVectorField cylindricalCoors
106 (
107 IOobject
108 (
109 "cylindricalCoors" + name_,
110 mesh_.time().timeName(),
111 mesh_,
114 ),
115 pointMesh::New(mesh_),
117 );
118 cylindricalCoors.primitiveFieldRef() = localSystemCoordinates_;
119 cylindricalCoors.write();
120}
121
122
123// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
124
125Foam::NURBS3DVolumeCylindrical::NURBS3DVolumeCylindrical
126(
127 const dictionary& dict,
128 const fvMesh& mesh,
129 bool computeParamCoors
130)
131:
132 NURBS3DVolume(dict, mesh, computeParamCoors),
133 origin_(dict.get<vector>("origin"))
134{
136 writeCps("cpsBsplines" + mesh_.time().timeName());
137 if (computeParamCoors)
138 {
141 }
142}
143
144
145// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
Calculation of adjoint based sensitivities at wall faces.
void updateLocalCoordinateSystem(const vectorField &cartesianPoints)
Update coordinates in the local system based on the cartesian points.
vector transformPointToCartesian(const vector &localCoordinates) const
Transform a point from its coordinate system to a cartesian system.
tensor transformationTensorDxDb(label globalPointIndex)
Transformation tensor for dxdb, from local coordinate system to cartesian.
NURBS3DVolume morpher. Includes support functions for gradient computations Base class providing supp...
const fvMesh & mesh_
vectorField localSystemCoordinates_
Coordinates in the local system for which CPs are defined.
const pointVectorField & getParametricCoordinates()
Get parametric coordinates.
void writeCps(const fileName &="cpsFile", const bool transform=true) const
Write control points on a cartesian coordinates system for visualization.
NURBS3DVolume(const dictionary &dict, const fvMesh &mesh, bool computeParamCoors=true)
Construct from dictionary.
const dictionary & dict() const
Get dictionary.
const fvMesh & mesh() const
Get mesh.
void determineActiveDesignVariablesAndPoints()
Create lists with active design variables and control points.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition Time.C:714
static const Form zero
const Cmpt & x() const noexcept
Access to the vector x component.
Definition Vector.H:135
const Cmpt & z() const noexcept
Access to the vector z component.
Definition Vector.H:145
const Cmpt & y() const noexcept
Access to the vector y component.
Definition Vector.H:140
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const Time & time() const
Return the top-level database.
Definition fvMesh.H:360
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sin(const dimensionedScalar &ds)
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Tensor< scalar > tensor
Definition symmTensor.H:57
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
Vector< scalar > vector
Definition vector.H:57
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299