optMeshMovementBezier.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-2019 PCOpt/NTUA
9 Copyright (C) 2013-2019 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
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
39 (
43 );
44}
45
46
47// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
48
50(
51 const scalarField& correction
52)
53{
54 // Re-initialize movement to zero
56
57 // Compute boundary mesh movement using derivatives of the control points
58 // and parameterization information
59 const label nBezier = Bezier_.nBezier();
60 const boolList& confineXmovement = Bezier_.confineXmovement();
61 const boolList& confineYmovement = Bezier_.confineYmovement();
62 const boolList& confineZmovement = Bezier_.confineZmovement();
63 vectorField actualMovement(nBezier, Zero);
64 for (label iCP = 0; iCP < nBezier; iCP++)
65 {
66 // Confine x movement
67 if (!confineXmovement[iCP])
68 {
69 actualMovement[iCP].x() = correction[iCP];
70 }
71 // Confine y movement
72 if (!confineYmovement[iCP])
73 {
74 actualMovement[iCP].y() = correction[iCP + nBezier];
75 }
76 // Confine z movement
77 if (!confineZmovement[iCP])
78 {
79 actualMovement[iCP].z() = correction[iCP + 2*nBezier];
80 }
81 dx_ += Bezier_.dxidXj()[iCP] & actualMovement[iCP];
82 }
83
84 // Add to cumulative control point change (wrong in the first optimisation
85 // cycle if initial eta not set)
86 cumulativeChange_ += actualMovement;
87 Info<< "Cumulative control point change " << cumulativeChange_ << endl;
88}
89
90
91// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92
94(
95 fvMesh& mesh,
96 const dictionary& dict,
97 const labelList& patchIDs
98)
99:
100 optMeshMovement(mesh, dict, patchIDs),
101 Bezier_(mesh, mesh.lookupObject<IOdictionary>("optimisationDict")),
102 dx_
103 (
105 (
106 "dx",
107 mesh_.time().timeName(),
108 mesh_,
109 IOobject::NO_READ,
110 IOobject::NO_WRITE,
111 false
112 ),
115 ),
116 cumulativeChange_(Bezier_.nBezier(), Zero)
117{}
118
119
120// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121
123{
124 // Update the boundary movement
125 computeBoundaryMovement(correction_);
126
127 // Set boundary movement of motion solver
128 displMethodPtr_->setMotionField(dx_);
129
130 // Move the mesh and check quality
132}
133
134
135Foam::scalar
137{
138 // Set unscaled correction
139 computeBoundaryMovement(correction);
140
141 // Get maximum boundary movement
142 const scalar maxDisplacement = gMax(mag(dx_.primitiveField()));
143
144 // Compute eta value
145 Info<< "maxAllowedDisplacement/maxDisplacement \t"
146 << getMaxAllowedDisplacement() << "/" << maxDisplacement << endl;
147 const scalar eta = getMaxAllowedDisplacement()/maxDisplacement;
148 Info<< "Setting eta value to " << eta << endl;
149
150 return eta;
151}
152
153
155{
156 return Bezier_.getActiveDesignVariables();
157}
158
159
160// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label nBezier() const
Number of Bezier control points.
Definition: Bezier.C:127
const boolList & confineZmovement() const
Confine z movement.
Definition: Bezier.C:151
const boolList & confineYmovement() const
Confine y movement.
Definition: Bezier.C:145
const boolList & confineXmovement() const
Confine x movement.
Definition: Bezier.C:139
PtrList< pointTensorField > & dxidXj()
dx/db tensor for all control points
Definition: Bezier.C:133
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Converts NURBS control points update to actual mesh movement.
void moveMesh()
Calculates surface mesh movement.
virtual labelList getActiveDesignVariables() const
Return active design variables.
void computeBoundaryMovement(const scalarField &correction)
vectorField cumulativeChange_
Cumulative change of control points.
pointVectorField dx_
Boundary movement due to change of NURBS control points.
Bezier Bezier_
Parameterization based on NURBS curves.
virtual scalar computeEta(const scalarField &correction)
Compute eta value based on max displacement.
Abstract base class for translating an update of the design variables into mesh movement.
virtual void moveMesh()
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
word timeName
Definition: getTimeIndex.H:3
Namespace for OpenFOAM.
const dimensionSet dimless
Dimensionless.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Type gMax(const FieldField< Field, Type > &f)
dictionary dict
A non-counting (dummy) refCount.
Definition: refCount.H:59