optMeshMovement.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 
29 Class
30  Foam::optMeshMovement
31 
32 Description
33  Abstract base class for translating an update of the design variables
34  into mesh movement
35 
36 SourceFiles
37  optMeshMovement.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef optMeshMovement_H
42 #define optMeshMovement_H
43 
44 #include "displacementMethod.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class optMeshMovement Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class optMeshMovement
56 {
57 private:
58 
59  // Private Member Functions
60 
61  //- Max allowed boundary displacement for the first optimisation cycle
62  autoPtr<scalar> maxAllowedDisplacement_;
63 
64 
65  // Private Member Functions
66 
67  //- No copy construct
68  optMeshMovement(const optMeshMovement&) = delete;
69 
70  //- No copy assignment
71  void operator=(const optMeshMovement&) = delete;
72 
73 
74 protected:
75 
76  // Protected data
77 
78  fvMesh& mesh_;
79  const dictionary& dict_;
80 
81  //- Correction of design variables
83 
84  //- IDs of patches to be moved
86 
87  //- Fall back points in case line-search is used
89 
90  //- Mesh movement engine and interface for applying mesh movement
91  //- boundary conditions
93 
94  //- Whether to write the mesh quality metrics to files each time the
95  //- mesh is updated
97 
98 
99  // Protected Member Functions
100 
101  //- Get maxAllowedDisplacement, is set
102  scalar getMaxAllowedDisplacement() const;
103 
104 
105 public:
106 
107  //- Runtime type information
108  TypeName("optMeshMovement");
109 
110 
111  // Declare run-time constructor selection table
112 
114  (
115  autoPtr,
117  dictionary,
118  (
119  fvMesh& mesh,
120  const dictionary& dict,
121  const labelList& patchIDs
122  ),
123  (
124  mesh,
125  dict,
126  patchIDs
127  )
128  );
129 
130 
131  // Constructors
132 
133  //- Construct from components
135  (
136  fvMesh& mesh,
137  const dictionary& dict,
138  const labelList& patchIDs
139  );
140 
141 
142  // Selectors
143 
145  (
146  fvMesh& mesh,
147  const dictionary& dict,
148  const labelList& patchIDs
149  );
150 
151 
152  //- Destructor
153  virtual ~optMeshMovement() = default;
154 
155 
156  // Member Functions
157 
158  //- Set design variable correction
159  void setCorrection(const scalarField& correction);
160 
161  //- Calculates mesh movemnt based on the correction of the design
162  //- variables
163  virtual void moveMesh();
164 
165  //- Return displacementMethod
167 
168  //- Return patchIDs
169  const labelList& getPatchIDs();
170 
171  //- Write mesh quality metrics
173 
174  //- Store design variables and mesh, to act as the starting point of
175  //- line search
176  virtual void storeDesignVariables();
177 
178  //- Reset to starting point of line search
179  virtual void resetDesignVariables();
180 
181  //- Compute eta value based on max displacement
182  virtual scalar computeEta(const scalarField& correction) = 0;
183 
184  //- Whether maxAllowedDisplacement has been set
185  bool maxAllowedDisplacementSet() const;
186 
187  //- Return active design variables.
188  // Implemented only for certain parametetisations
189  virtual labelList getActiveDesignVariables() const;
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
dictionary dict
declareRunTimeSelectionTable(autoPtr, optMeshMovement, dictionary,(fvMesh &mesh, const dictionary &dict, const labelList &patchIDs),(mesh, dict, patchIDs))
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
bool maxAllowedDisplacementSet() const
Whether maxAllowedDisplacement has been set.
Abstract base class for translating an update of the design variables into mesh movement.
virtual void resetDesignVariables()
Reset to starting point of line search.
vectorField pointsInit_
Fall back points in case line-search is used.
virtual labelList getActiveDesignVariables() const
Return active design variables.
virtual ~optMeshMovement()=default
Destructor.
virtual void storeDesignVariables()
Store design variables and mesh, to act as the starting point of line search.
TypeName("optMeshMovement")
Runtime type information.
static autoPtr< optMeshMovement > New(fvMesh &mesh, const dictionary &dict, const labelList &patchIDs)
virtual scalar computeEta(const scalarField &correction)=0
Compute eta value based on max displacement.
dynamicFvMesh & mesh
autoPtr< displacementMethod > & returnDisplacementMethod()
Return displacementMethod.
const dictionary & dict_
bool writeMeshQualityMetrics_
Whether to write the mesh quality metrics to files each time the mesh is updated. ...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
autoPtr< displacementMethod > displMethodPtr_
Mesh movement engine and interface for applying mesh movement boundary conditions.
virtual void moveMesh()
Calculates mesh movemnt based on the correction of the design variables.
const labelList & getPatchIDs()
Return patchIDs.
void setCorrection(const scalarField &correction)
Set design variable correction.
labelList patchIDs_
IDs of patches to be moved.
scalar getMaxAllowedDisplacement() const
Get maxAllowedDisplacement, is set.
scalarField correction_
Correction of design variables.
Namespace for OpenFOAM.
void writeMeshQualityMetrics()
Write mesh quality metrics.