Loading...
Searching...
No Matches
marchingCells.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) 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
27Class
28 marchingCells
29
30Description
31 Marches cells from given seed patches, faceZones or the boundary faces of
32 cellZones, towards the interior of the mesh, with a given step at a time.
33 Used in topology optimisation, to gradually activate the design variables,
34 in an attempt to prevent the optimiser from acting too agressively in the
35 first optimisation cycles. Use meshWave to do the marching.
36
37SourceFiles
38 marchingCells.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef marchingCells_H
43#define marchingCells_H
44
45#include "fvMesh.H"
46#include "wallPointData.H"
47#include "FaceCellWave.H"
48
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
55/*---------------------------------------------------------------------------*\
56 Class marchingCells Declaration
57\*---------------------------------------------------------------------------*/
58
59class marchingCells
60{
62protected:
63
64 // Protected data
65
66 const fvMesh& mesh_;
67
68 //- Patches used as seeds in the marching algorithm
70
71 //- Cell zones, the boundary faces of which are used as seeds in the
72 //- marching algorithm
74
75 //- Face zones used as seeds in the marching algorithm.
78 //- Marching step
79 label marchingStep_;
80
81 //- Whether each cell is curently active or not
83
84 //- Should this cell remain incative
86
87 //- Which are the active cells
89
90 //- Which are the added cells
93 //- Has the initial seeding been conducted
94 bool initialised_;
95
96 //- Iterations conducted thus far
97 label nIters_;
98
99 //- Information for all faces
101
102 //- Information for all cells
104
105 //- Engine propagating the active cells.
106 // Uses infrastructure from FaceCellWave, to easily handle parallel
107 // interfaces
109
110
111 // Protected Member Functions
113 //- Initialise the active cells from the seeding patches
114 void initialise();
115
116 //- Append cell to seed cells
117 void appendSeedCell(const label cellID);
118
119 // Updates the isActiveCells_ list and gathers newlyAddedCells
120 void march
121 (
122 label nVisited,
123 const label cI,
124 labelList& newlyAddedCells
125 );
126
127
128private:
129
130 // Private Member Functions
131
132 //- No copy construct
133 marchingCells(const marchingCells&) = delete;
134
135 //- No copy assignment
136 void operator=(const marchingCells&) = delete;
137
138
139public:
140
141 //- Runtime type information
142 TypeName("marchingCells");
143
144
145 // Constructors
146
147 //- Construct from components
148 marchingCells
149 (
150 const fvMesh& mesh,
151 const dictionary& dict
152 );
153
154
155 //- Destructor
156 virtual ~marchingCells() = default;
157
158
159 // Member Functions
160
161 // Access
162
163 //- Get the active cells
164 inline const labelList& getActiveCells() const
165 {
166 return activeCells_;
167 }
168
169 //- Number of newly added cells in the last iteration
170 inline label numberOfAddedCells() const
171 {
172 return addedCells_.size();
173 }
175
176 // Edit
177
178 //- Update active cells
179 void update(const label iters = 1);
180
181 //- Set marching step
182 inline void setMarchingStep(const label step)
183 {
184 marchingStep_ = step;
185 }
186
187 //- Add fixed cells through cellZone IDs
188 void addFixedCells
189 (
191 const labelList& fixedCellZoneIDs
192 );
193
194 //- Add fixed cells
195 void addFixedCells(const labelList& fixedCellIDs);
196};
197
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace Foam
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205#endif
206
207// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Wave propagation of information through grid. Every iteration information goes through one layer of c...
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
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
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
FaceCellWave< wallPointData< bool > > meshWave_
Engine propagating the active cells.
List< wallPointData< bool > > allFaceInfo_
Information for all faces.
virtual ~marchingCells()=default
Destructor.
void appendSeedCell(const label cellID)
Append cell to seed cells.
List< wallPointData< bool > > allCellInfo_
Information for all cells.
void initialise()
Initialise the active cells from the seeding patches.
labelList addedCells_
Which are the added cells.
const fvMesh & mesh_
void setMarchingStep(const label step)
Set marching step.
bool initialised_
Has the initial seeding been conducted.
label nIters_
Iterations conducted thus far.
label numberOfAddedCells() const
Number of newly added cells in the last iteration.
boolList isFixedCell_
Should this cell remain incative.
label marchingStep_
Marching step.
const labelList & getActiveCells() const
Get the active cells.
boolList isActiveCell_
Whether each cell is curently active or not.
void addFixedCells(const cellZoneMesh &cellZoneMesh, const labelList &fixedCellZoneIDs)
Add fixed cells through cellZone IDs.
labelList seedFaceZoneIDs_
Face zones used as seeds in the marching algorithm.
DynamicList< label > activeCells_
Which are the active cells.
TypeName("marchingCells")
Runtime type information.
labelHashSet seedPatches_
Patches used as seeds in the marching algorithm.
void march(label nVisited, const label cI, labelList &newlyAddedCells)
labelList seedCellZoneIDs_
Cell zones, the boundary faces of which are used as seeds in the marching algorithm.
mesh update()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
List< bool > boolList
A List of bools.
Definition List.H:60
loopControl iters(runTime, aMesh.solutionDict(), "solution")
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68