dynamicTopODesignVariables.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) 2020-2023 PCOpt/NTUA
9  Copyright (C) 2020-2023 FOSS GP
10 -------------------------------------------------------------------------------
11 License
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 \*---------------------------------------------------------------------------*/
28 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(dynamicTopODesignVariables, 0);
38  (
39  designVariables,
40  dynamicTopODesignVariables,
41  designVariables
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
47 
49 (
50  const label fluidID,
51  const bool activeIO
52 )
53 {
54  cellZoneMesh& cellZones = mesh_.cellZones();
57  if (!activeIO)
58  {
60  }
61 
62  // Evolve the active design variables as many times as the passed
63  // optimisation cycles - 1 (the last evolution corresponds to the design
64  // variables of the next optimisation cycle).
65  // Ensure at least one evolution, to kick-start the optimisation
69 }
70 
71 
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 
74 Foam::dynamicTopODesignVariables::dynamicTopODesignVariables
75 (
76  fvMesh& mesh,
77  const dictionary& dict
78 )
79 :
81 {}
82 
83 
84 Foam::dynamicTopODesignVariables::dynamicTopODesignVariables
85 (
86  fvMesh& mesh,
87  const dictionary& dict,
88  const label size
89 )
90 :
92  marchCells_(mesh, dict.subDict("marchingCoeffs")),
93  evolvedCount_(localIOdictionary::getOrDefault<label>("evolvedCount", 0))
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
98 
101 (
102  fvMesh& mesh,
103  const dictionary& dict
104 )
105 {
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
111 
113 {
114  marchCells_.update();
115  activeDesignVariables_ = marchCells_.getActiveCells();
116  ++evolvedCount_;
117 }
118 
119 
121 {
122  os.writeEntry("evolvedCount", evolvedCount_);
124 }
125 
126 
127 // ************************************************************************* //
labelList activeDesignVariables_
Which of the design variables will be updated.
virtual void evolveNumber()
Update the active design variables.
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void setActiveDesignVariables(const label fluidID=0, const bool activeIO=false)
Set active design variables.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
Design variables for porosity-based topology optimisation (topO) problems.
const cellZone & IOCells() const
Cells next to IO boundaries.
Definition: topOZones.H:201
Macros for easy insertion into run-time selection tables.
localIOdictionary is derived from IOdictionary but excludes parallel master reading.
dynamicFvMesh & mesh
const labelList & getActiveCells() const
Get the active cells.
marchingCells marchCells_
Mechanism for gradually activating design variables.
const labelList & fixedZeroPorousZoneIDs() const
Cell zone IDs with fixed zero porosity values.
Definition: topOZones.H:185
void addFixedCells(const cellZoneMesh &cellZoneMesh, const labelList &fixedCellZoneIDs)
Add fixed cells through cellZone IDs.
void update(const label iters=1)
Update active cells.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
label evolvedCount_
Number of times the design variables have evolved.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static autoPtr< dynamicTopODesignVariables > New(fvMesh &mesh, const dictionary &dict)
Construct and return the selected design variables.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:678
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Design variables for topology optimisation problems. Active design variables are added gradually...
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
const labelList & fixedPorousZoneIDs() const
Cell zone IDs with fixed porosity values.
Definition: topOZones.H:169
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)