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 
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 // ************************************************************************* //
Foam::optMeshMovement::displMethodPtr_
autoPtr< displacementMethod > displMethodPtr_
Definition: optMeshMovement.H:91
Foam::optMeshMovement::patchIDs_
labelList patchIDs_
IDs of patches to be moved.
Definition: optMeshMovement.H:84
Foam::optMeshMovement::getActiveDesignVariables
virtual labelList getActiveDesignVariables() const
Return active design variables.
Definition: optMeshMovement.C:201
Foam::optMeshMovement::getPatchIDs
const labelList & getPatchIDs()
Return patchIDs.
Definition: optMeshMovement.C:148
Foam::optMeshMovement::New
static autoPtr< optMeshMovement > New(fvMesh &mesh, const dictionary &dict, const labelList &patchIDs)
Definition: optMeshMovement.C:93
Foam::optMeshMovement::computeEta
virtual scalar computeEta(const scalarField &correction)=0
Compute eta value based on max displacement.
Foam::optMeshMovement::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, optMeshMovement, dictionary,(fvMesh &mesh, const dictionary &dict, const labelList &patchIDs),(mesh, dict, patchIDs))
Foam::optMeshMovement::storeDesignVariables
virtual void storeDesignVariables()
Definition: optMeshMovement.C:182
Foam::optMeshMovement::TypeName
TypeName("optMeshMovement")
Runtime type information.
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Foam::optMeshMovement::maxAllowedDisplacementSet
bool maxAllowedDisplacementSet() const
Whether maxAllowedDisplacement has been set.
Definition: optMeshMovement.C:195
Foam::optMeshMovement::returnDisplacementMethod
autoPtr< displacementMethod > & returnDisplacementMethod()
Return displacementMethod.
Definition: optMeshMovement.C:142
Foam::optMeshMovement::dict_
const dictionary & dict_
Definition: optMeshMovement.H:78
Foam::Field< scalar >
Foam::optMeshMovement::~optMeshMovement
virtual ~optMeshMovement()=default
Destructor.
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
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::optMeshMovement::writeMeshQualityMetrics_
bool writeMeshQualityMetrics_
Definition: optMeshMovement.H:95
Foam::autoPtr< scalar >
displacementMethod.H
Foam::optMeshMovement::moveMesh
virtual void moveMesh()
Definition: optMeshMovement.C:128
Foam::List< label >
Foam::optMeshMovement::setCorrection
void setCorrection(const scalarField &correction)
Set design variable correction.
Definition: optMeshMovement.C:122
Foam::optMeshMovement::getMaxAllowedDisplacement
scalar getMaxAllowedDisplacement() const
Get maxAllowedDisplacement, is set.
Definition: optMeshMovement.C:45
Foam::optMeshMovement::correction_
scalarField correction_
Correction of design variables.
Definition: optMeshMovement.H:81
Foam::optMeshMovement::writeMeshQualityMetrics
void writeMeshQualityMetrics()
Write mesh quality metrics.
Definition: optMeshMovement.C:154
Foam::optMeshMovement
Abstract base class for translating an update of the design variables into mesh movement.
Definition: optMeshMovement.H:54
Foam::optMeshMovement::resetDesignVariables
virtual void resetDesignVariables()
Reset to starting point of line search.
Definition: optMeshMovement.C:188
Foam::optMeshMovement::mesh_
fvMesh & mesh_
Definition: optMeshMovement.H:77
Foam::optMeshMovement::pointsInit_
vectorField pointsInit_
Fall back points in case line-search is used.
Definition: optMeshMovement.H:87