Loading...
Searching...
No Matches
levelSetDesignVariables.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) 2022-2023 PCOpt/NTUA
9 Copyright (C) 2022-2023 FOSS GP
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::levelSetDesignVariables
29
30Description
31 Signed distance field design variables for level-set based topology
32 optimization (topO).
33
34 A great reference for various aspects of level-set-based topO can be found
35 in
36
37 Reference:
38 \verbatim
39 van Dijk, N.P., Maute, K., Langelaar, M., & & van Keulen, F. (2013).
40 Level-set methods for structural topology optimization: a review.
41 Structural and Multidisciplinary Optimization, 48, 437–472.
42 https://doi.org/10.1007/s00158-013-0912-y
43 \endverbatim
44
45 The implemented approach borrows from the references therein, but does not
46 follow any of them exactly. The underlying field of the design variables
47 is not the level-set field but affects the latter through:
48 a) a regularisation approach similar to that used in porosity-based topO
49 (see the regularisation class and references therein) and
50 b) a re-initialisation strategy. Since solving a modified Hamilton-Jacobi
51 equation poses a number of numerical challenges, the signed distance field
52 is obtained by identifying the zero level-set contour using the
53 cutFaceIso, cutCellIso infrastructure (see references therein for the
54 methodology) and using these "cut-faces" as seeds for meshWave.
55
56SourceFiles
57 levelSetDesignVariables.C
58
59\*---------------------------------------------------------------------------*/
60
61#ifndef levelSetDesignVariables_H
62#define levelSetDesignVariables_H
63
64#include "topOVariablesBase.H"
65#include "designVariables.H"
67#include "regularisationPDE.H"
69#include "adjointSensitivity.H"
70
71// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72
73namespace Foam
74{
76/*---------------------------------------------------------------------------*\
77 Class levelSetDesignVariables Declaration
78\*---------------------------------------------------------------------------*/
79
80class levelSetDesignVariables
81:
82 public topOVariablesBase,
83 public designVariables
84{
85protected:
86
87 // Protected Data Members
88
89 //- The regularisation radius
91
92 //- Regularisation mechanism
94
95 //- The regularised field
98 //- The signed distances field
100
101 //- Function to transorm signed distances to the indicator field beta_
103
104 //- The indicator field
106
107 //- Fix aTilda values in fixed{Zero}PorousZones and IOcells
108 bool fixATildaValues_;
109
110 //- Write all fields related to the distance calculation (debugging)
113 //- Mesh faces acting as the source of MeshWave
115
116 //- Seed distances to MeshWave and cell distances
117 // The data carried by each wallPoints corresponds to the origin
118 // mesh face ID
121
123 // Protected Member Functions
124
125 //- Read the design variables field
126 void readField();
128 //- Apply fixed values in certain zones
130
131 //- Determine which design variables are active
132 void setActiveDesignVariables(bool activeIO = false);
133
134 //- Make aTilda a signed distance field based on the zero iso-surface
135 //- of the current aTilda field
137
138 //- Update the beta field
139 void updateBeta();
140
141
142private:
143
144 // Private Member Functions
145
146 //- No copy construct
147 levelSetDesignVariables(const levelSetDesignVariables&) = delete;
148
149 //- No copy assignment
150 void operator=(const levelSetDesignVariables&) = delete;
151
152
153public:
154
155 //- Runtime type information
156 TypeName("levelSet");
157
158
159 // Constructors
160
161 //- Construct from dictionary
162 levelSetDesignVariables
163 (
164 fvMesh& mesh,
165 const dictionary& dict
166 );
167
168
169 // Selectors
170
171 //- Return a reference to the selected turbulence model
173 (
174 fvMesh& mesh,
175 const dictionary& dict
176 );
177
178
179 //- Destructor
180 virtual ~levelSetDesignVariables() = default;
181
182
183 // Member Functions
184
185 //- Const reference to the beta field
186 virtual const volScalarField& beta() const;
187
188 //- Update design variables based on a given correction
189 virtual void update(scalarField& correction);
190
191 //- Compute eta if not set in the first step
192 virtual scalar computeEta(scalarField& correction);
193
194 //- Whether to use global sum when computing matrix-vector products
195 //- in update methods
196 virtual bool globalSum() const;
197
198 //- Add contributions from the adjoint to the regularization PDE,
199 //- the derivative of the interpolation function and the mesh volume
200 //- to the final sensitivities
202 (
203 adjointSensitivity& adjointSens
204 );
205
206 //- Write useful quantities to files
207 virtual void writeDesignVars();
208
209 //- The writeData function required by the regIOobject write operation
210 virtual bool writeData(Ostream&) const;
211};
212
213
214// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215
216} // End namespace Foam
217
218// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219
220#endif
221
222// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Abstract base class for adjoint-based sensitivities.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
void applyFixedPorosityValues()
Apply fixed values in certain zones.
autoPtr< regularisationRadius > radius_
The regularisation radius.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
void updateBeta()
Update the beta field.
virtual tmp< scalarField > assembleSensitivities(adjointSensitivity &adjointSens)
Add contributions from the adjoint to the regularization PDE, the derivative of the interpolation fun...
List< wallPointData< label > > changedFacesInfo_
Seed distances to MeshWave and cell distances.
TypeName("levelSet")
Runtime type information.
bool fixATildaValues_
Fix aTilda values in fixed{Zero}PorousZones and IOcells.
void setActiveDesignVariables(bool activeIO=false)
Determine which design variables are active.
volScalarField beta_
The indicator field.
List< wallPointData< label > > allCellInfo_
autoPtr< topOInterpolationFunction > interpolation_
Function to transorm signed distances to the indicator field beta_.
void readField()
Read the design variables field.
virtual bool globalSum() const
Whether to use global sum when computing matrix-vector products in update methods.
void updateSignedDistances()
Make aTilda a signed distance field based on the zero iso-surface of the current aTilda field.
autoPtr< regularisationPDE > regularisation_
Regularisation mechanism.
virtual const volScalarField & beta() const
Const reference to the beta field.
virtual ~levelSetDesignVariables()=default
Destructor.
labelList changedFaces_
Mesh faces acting as the source of MeshWave.
static autoPtr< levelSetDesignVariables > New(fvMesh &mesh, const dictionary &dict)
Return a reference to the selected turbulence model.
bool writeAllDistanceFields_
Write all fields related to the distance calculation (debugging).
virtual scalar computeEta(scalarField &correction)
Compute eta if not set in the first step.
volScalarField aTilda_
The regularised field.
volScalarField signedDistances_
The signed distances field.
virtual void writeDesignVars()
Write useful quantities to files.
A class for managing temporary objects.
Definition tmp.H:75
mesh update()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68