Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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\*---------------------------------------------------------------------------*/
28
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38 (
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
68 activeDesignVariables_ = marchCells_.getActiveCells();
69}
70
71
72// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73
74Foam::dynamicTopODesignVariables::dynamicTopODesignVariables
75(
76 fvMesh& mesh,
78)
79:
80 dynamicTopODesignVariables(mesh, dict, mesh.nCells())
81{}
82
83
84Foam::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)
107}
108
109
110// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
111
114 marchCells_.update();
115 activeDesignVariables_ = marchCells_.getActiveCells();
117}
118
119
121{
122 os.writeEntry("evolvedCount", evolvedCount_);
124}
125
126
127// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
void size(const label n)
Definition UList.H:118
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
Abstract base class for defining design variables.
labelList activeDesignVariables_
Which of the design variables will be updated.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Design variables for topology optimisation problems. Active design variables are added gradually,...
virtual void evolveNumber()
Update the active design variables.
label evolvedCount_
Number of times the design variables have evolved.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
virtual void setActiveDesignVariables(const label fluidID=0, const bool activeIO=false)
Set active design variables.
marchingCells marchCells_
Mechanism for gradually activating design variables.
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:85
localIOdictionary is derived from IOdictionary but excludes parallel master reading.
void addFixedCells(const cellZoneMesh &cellZoneMesh, const labelList &fixedCellZoneIDs)
Add fixed cells through cellZone IDs.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition polyMesh.H:679
Design variables for porosity-based topology optimisation (topO) problems.
virtual bool writeData(Ostream &) const
The writeData function required by the regIOobject write operation.
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
const labelList & fixedPorousZoneIDs() const
Cell zone IDs with fixed porosity values.
Definition topOZones.H:169
const cellZone & IOCells() const
Cells next to IO boundaries.
Definition topOZones.H:201
const labelList & fixedZeroPorousZoneIDs() const
Cell zone IDs with fixed zero porosity values.
Definition topOZones.H:185
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
dictionary dict