Loading...
Searching...
No Matches
topOVariablesBase.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-2023 PCOpt/NTUA
9 Copyright (C) 2013-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
27
28Class
29 Foam::topOVariablesBase
30
31Description
32 Base class for all design variables related to topology optimisation (topO).
33 Provides the lookup functionality necessary for all fvOptions associated
34 with topO and access to topOZones.
35
36SourceFiles
37 topOVariablesBase.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef topOVariablesBase_H
42#define topOVariablesBase_H
43
44#include "localIOdictionary.H"
45#include "topOZones.H"
47#include "FaceCellWave.H"
48#include "wallPointData.H"
49#include "cutFaceIso.H"
50#include "cutCellIso.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
57/*---------------------------------------------------------------------------*\
58 Class topOVariablesBase Declaration
59\*---------------------------------------------------------------------------*/
60
61class topOVariablesBase
62:
64{
65protected:
66
67 // Protected data
69 //- Cell zones useful for defining the constant and changing parts
70 //- of the domain in topO
72
73 //- Folder name holding the zero level-set iso-surface
75
76 //- Map between iso-surface and mesh faces (internal and boundary)
79 //- Per cutting face, the changed faces owned by it
80 //labelListList changedFacesPerCuttingFace_;
81
82 //- Iso-surface points
84
85 //- Iso-surface faces
87
88
89 // Protected Member Functions
90
91 //- Based on the current pseudo-distance field y, identity the zero
92 //- level-set iso-surface, write it to files for post-processing and
93 //- set the seeds for the distance calculation from this iso-surface
95 (
96 const volScalarField& y,
97 labelList& changedFaces,
98 List<wallPointData<label>>& changedFacesInfo
99 ) const;
100
101 //- Construct facesFaces for a given boundary face
102 DynamicList<label> faceFaces(const label facei) const;
103
104 //- Check whether the cutFace intersects the boundary of the initial
105 //- domain and add fluid part of the intersected face to the isoline
107 (
108 const label facei,
109 const cutFaceIso& cutFace,
110 DynamicList<vector>& isoSurfPts,
111 DynamicList<face>& isoSurfFaces,
113 List<DynamicList<label>>& cuttingFacesPerMeshFace
114 ) const;
115
117 (
118 const label pointID,
119 const vector& pointi,
120 const DynamicList<label>& cuttingFaces,
121 const DynamicList<point>& isoSurfPts,
122 const DynamicList<face>& isoSurfFaces,
123 labelList& uniquePointIDs
124 ) const;
125
126 //- Add the cutting face to the zero level-set iso-surface
128 (
129 const DynamicList<point>& facePoints,
130 const label nSerialPatches,
131 const DynamicList<label>& cellCutFaces,
132 const List<DynamicList<label>>& cuttingFacesPerMeshFace,
133 DynamicList<vector>& isoSurfPts,
134 DynamicList<face>& isoSurfFaces,
136 ) const;
137
138 //- Check whether the boundary faces of the initial domain belong
139 //- to the fluid part and add them to the surface describing the
140 //- fluid domain.
141 // Used only to close the output surface, does not set distance seeds
143 (
144 const pointScalarField& pointY,
145 const Map<label>& addedFaces,
146 const scalar isoValue,
147 DynamicList<vector>& isoSurfPts,
148 DynamicList<face>& isoSurfFaces,
150 label& nChangedFaces,
151 labelList& changedFaces,
152 List<wallPointData<label>>& changedFacesInfo,
153 labelList& changedFaceToCutFace,
154 List<DynamicList<label>>& cuttingFacesPerMeshFace
155 );
156
157 //- Write the surface describing the fluid domain to stl and vtp files
159 (
160 const pointField& pts,
161 const faceList& faces,
162 const labelList& zoneIds,
163 const label nSerialPatches
164 ) const;
165
166
167private:
168
169 // Private Member Functions
170
171 //- Disallow default bitwise copy construct
172 topOVariablesBase(const topOVariablesBase&) = delete;
173
174 //- Disallow default bitwise assignment
175 void operator=(const topOVariablesBase&) = delete;
176
177
178public:
179
180 //- Runtime type information
181 TypeName("topOVariablesBase");
182
183 // Constructors
184
185 //- Construct from dictionary
186 topOVariablesBase
187 (
188 fvMesh& mesh,
189 const dictionary& dict
190 );
191
192
193 //- Destructor
194 virtual ~topOVariablesBase() = default;
195
196
197 // Member Functions
198
199 //- Get topOZones
200 inline const topOZones& getTopOZones() const
201 {
202 return zones_;
203 }
204
205 //- Get betaMax value
206 inline scalar getBetaMax() const
207 {
208 return zones_.getBetaMax();
209 }
210
211 //inline const labelListList& changedFacesPerCuttingFace() const
212 //{
213 // return changedFacesPerCuttingFace_;
214 //}
215
216 inline const pointField& surfacePoints() const
217 {
218 return surfPoints_;
219 }
220
221 inline const faceList& surfaceFaces() const
222 {
223 return surfFaces_;
224 }
226 //- Get field used for physical interpolations
227 virtual const volScalarField& beta() const = 0;
228
229 //- Populate source terms for the flow equations
230 virtual void sourceTerm
231 (
233 const topOInterpolationFunction& interpolationFunc,
234 const scalar betaMax,
235 const word& interpolationFieldName = "beta"
236 ) const;
237
238 //- Post-processing sensitivities due to interpolations based on
239 //- the indicator fields
240 virtual void sourceTermSensitivities
242 scalarField& sens,
243 const topOInterpolationFunction& interpolationFunc,
244 const scalar betaMax,
245 const word& designVariablesName,
246 const word& interpolationFieldName = "beta"
247 ) const;
248
249 //- Write the fluid-solid interface to files.
250 // The interface is computed as an isoValue contour of the indicator
251 // field
252 // - 0 distance contour for levelSet or
253 // - 0.5 beta contour for porosity-based topO.
254 // For levelSet topO, the process of identifying the contour sets also
255 // the seeds for computing the distance field in the entire domain
257 (
258 const volScalarField& indicator,
259 const scalar isoValue,
260 labelList& changedFaces,
261 List<wallPointData<label>>& changedFacesInfo
262 );
263};
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268} // End namespace Foam
269
270// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271
272#endif
273
274// ************************************************************************* //
scalar y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
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
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
Base class for selecting the betaMax value, i.e. the value multiplying the Brinkman penalisation term...
Definition betaMax.H:50
Class for cutting a face, faceI, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition cutFaceIso.H:67
Base class for cutting a face, faceI, of an fvMesh, mesh_, at its intersections.
Definition cutFace.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
localIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
void writeFluidSolidInterface(const volScalarField &indicator, const scalar isoValue, labelList &changedFaces, List< wallPointData< label > > &changedFacesInfo)
Write the fluid-solid interface to files.
void setCutInterfaceFaces(const volScalarField &y, labelList &changedFaces, List< wallPointData< label > > &changedFacesInfo) const
Based on the current pseudo-distance field y, identity the zero level-set iso-surface,...
TypeName("topOVariablesBase")
Runtime type information.
virtual void sourceTerm(DimensionedField< scalar, volMesh > &field, const topOInterpolationFunction &interpolationFunc, const scalar betaMax, const word &interpolationFieldName="beta") const
Populate source terms for the flow equations.
Map< label > meshFaceToChangedFace_
Map between iso-surface and mesh faces (internal and boundary).
virtual ~topOVariablesBase()=default
Destructor.
scalar getBetaMax() const
Get betaMax value.
bool addCutBoundaryFaceToIsoline(const label facei, const cutFaceIso &cutFace, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs, List< DynamicList< label > > &cuttingFacesPerMeshFace) const
Check whether the cutFace intersects the boundary of the initial domain and add fluid part of the int...
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
virtual void sourceTermSensitivities(scalarField &sens, const topOInterpolationFunction &interpolationFunc, const scalar betaMax, const word &designVariablesName, const word &interpolationFieldName="beta") const
Post-processing sensitivities due to interpolations based on the indicator fields.
const topOZones & getTopOZones() const
Get topOZones.
fileName isoSurfFolder_
Folder name holding the zero level-set iso-surface.
DynamicList< label > faceFaces(const label facei) const
Construct facesFaces for a given boundary face.
void addBoundaryFacesToIsoline(const pointScalarField &pointY, const Map< label > &addedFaces, const scalar isoValue, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs, label &nChangedFaces, labelList &changedFaces, List< wallPointData< label > > &changedFacesInfo, labelList &changedFaceToCutFace, List< DynamicList< label > > &cuttingFacesPerMeshFace)
Check whether the boundary faces of the initial domain belong to the fluid part and add them to the s...
const pointField & surfacePoints() const
virtual const volScalarField & beta() const =0
Get field used for physical interpolations.
void writeSurfaceFiles(const pointField &pts, const faceList &faces, const labelList &zoneIds, const label nSerialPatches) const
Write the surface describing the fluid domain to stl and vtp files.
pointField surfPoints_
Per cutting face, the changed faces owned by it.
const faceList & surfaceFaces() const
bool addCuttingFaceToIsoline(const DynamicList< point > &facePoints, const label nSerialPatches, const DynamicList< label > &cellCutFaces, const List< DynamicList< label > > &cuttingFacesPerMeshFace, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs) const
Add the cutting face to the zero level-set iso-surface.
faceList surfFaces_
Iso-surface faces.
bool isDuplicatePoint(const label pointID, const vector &pointi, const DynamicList< label > &cuttingFaces, const DynamicList< point > &isoSurfPts, const DynamicList< face > &isoSurfFaces, labelList &uniquePointIDs) const
Holds information (coordinate and normal) regarding nearest wall point.
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
dynamicFvMesh & mesh
const labelIOList & zoneIDs
Definition correctPhi.H:59
Namespace for OpenFOAM.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
dictionary dict
const pointField & pts
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68