optMeshMovementVolumetricBSplines.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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
29 
32 
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(optMeshMovementVolumetricBSplines, 0);
40  (
41  optMeshMovement,
42  optMeshMovementVolumetricBSplines,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
51 (
52  const scalarField& correction
53 )
54 {
55  const label nControlPoints(correction.size()/3);
56  vectorField cpMovement(nControlPoints, Zero);
57 
58  for (label iCP = 0; iCP < nControlPoints; ++iCP)
59  {
60  cpMovement[iCP].x() = correction[3*iCP];
61  cpMovement[iCP].y() = correction[3*iCP + 1];
62  cpMovement[iCP].z() = correction[3*iCP + 2];
63  }
64  displMethodPtr_->boundControlField(cpMovement);
65 
66  return cpMovement;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
72 Foam::optMeshMovementVolumetricBSplines::optMeshMovementVolumetricBSplines
73 (
74  fvMesh& mesh,
75  const dictionary& dict,
76  const labelList& patchIDs
77 )
78 :
79  optMeshMovement(mesh, dict, patchIDs),
80  volBSplinesBase_
81  (
83  ),
84  cpsInit_(volBSplinesBase_.getNumberOfBoxes())
85 {
86  PtrList<NURBS3DVolume>& boxes = volBSplinesBase_.boxesRef();
87 
88  forAll(boxes, boxI)
89  {
90  cpsInit_[boxI].setSize
91  (
92  boxes[boxI].getControlPoints().size()
93  );
94  cpsInit_[boxI] = boxes[boxI].getControlPoints();
95  }
96 }
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  // Get controlPoint movement from correction
105 
106  // Set movement of the B-Splines control points
107  displMethodPtr_->setControlField(cpMovement);
108 
109  // Move the mesh and check quality
111 }
112 
113 
115 {
117  const PtrList<NURBS3DVolume>& boxes = volBSplinesBase_.boxes();
118  forAll(boxes, boxI)
119  {
120  cpsInit_[boxI] = boxes[boxI].getControlPoints();
121  }
122 }
123 
124 
126 {
127  // Reset mesh points
129 
130  DebugInfo
131  << "optMeshMovementVolumetricBSplines:: resetting control points"
132  << endl;
133 
134  PtrList<NURBS3DVolume>& boxes = volBSplinesBase_.boxesRef();
135  forAll(boxes, boxI)
136  {
137  boxes[boxI].setControlPoints(cpsInit_[boxI]);
138  }
139 }
140 
141 
143 (
144  const scalarField& correction
145 )
146 {
147  const vectorField cpMovement(controlPointMovement(correction));
148  const scalar maxDisplacement
149  (
150  volBSplinesBase_.computeMaxBoundaryDisplacement
151  (
152  cpMovement,
153  patchIDs_
154  )
155  );
156 
157  Info<< "maxAllowedDisplacement/maxDisplacement of boundary\t"
158  << getMaxAllowedDisplacement() << "/" << maxDisplacement << endl;
159  scalar eta = getMaxAllowedDisplacement() / maxDisplacement;
160  Info<< "Setting eta value to " << eta << endl;
161 
162  return eta;
163 }
164 
165 
168 {
169  return volBSplinesBase_.getActiveDesignVariables();
170 }
171 
172 
173 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::optMeshMovement::displMethodPtr_
autoPtr< displacementMethod > displMethodPtr_
Definition: optMeshMovement.H:91
Foam::optMeshMovementVolumetricBSplines::computeEta
virtual scalar computeEta(const scalarField &correction)
Compute eta value based on max displacement.
Definition: optMeshMovementVolumetricBSplines.C:143
Foam::optMeshMovementVolumetricBSplines::resetDesignVariables
virtual void resetDesignVariables()
Reset to starting point of line search.
Definition: optMeshMovementVolumetricBSplines.C:125
Foam::volBSplinesBase
Class constructing a number of volumetric B-Splines boxes, read from dynamicMeshDict....
Definition: volBSplinesBase.H:59
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::optMeshMovement::storeDesignVariables
virtual void storeDesignVariables()
Definition: optMeshMovement.C:182
Foam::optMeshMovementVolumetricBSplines::storeDesignVariables
virtual void storeDesignVariables()
Definition: optMeshMovementVolumetricBSplines.C:114
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
optMeshMovementVolumetricBSplines.H
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
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
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::optMeshMovementVolumetricBSplines::controlPointMovement
vectorField controlPointMovement(const scalarField &correction)
Definition: optMeshMovementVolumetricBSplines.C:51
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::optMeshMovement::moveMesh
virtual void moveMesh()
Definition: optMeshMovement.C:128
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::optMeshMovementVolumetricBSplines::getActiveDesignVariables
virtual labelList getActiveDesignVariables() const
Return active design variables.
Definition: optMeshMovementVolumetricBSplines.C:167
Foam::List< label >
Foam::optMeshMovement::correction_
scalarField correction_
Correction of design variables.
Definition: optMeshMovement.H:81
Foam::optMeshMovement
Abstract base class for translating an update of the design variables into mesh movement.
Definition: optMeshMovement.H:54
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::optMeshMovement::resetDesignVariables
virtual void resetDesignVariables()
Reset to starting point of line search.
Definition: optMeshMovement.C:188
Foam::optMeshMovementVolumetricBSplines::moveMesh
void moveMesh()
Calculates surface mesh movement.
Definition: optMeshMovementVolumetricBSplines.C:101