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 -------------------------------------------------------------------------------
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 Class
28  marchingCells
29 
30 Description
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 
37 SourceFiles
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 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class marchingCells Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class marchingCells
60 {
61 
62 protected:
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.
77 
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
92 
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 
128 private:
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 
139 public:
140 
141  //- Runtime type information
142  TypeName("marchingCells");
143 
144 
145  // Constructors
146 
147  //- Construct from components
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  }
174 
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  (
190  const cellZoneMesh& cellZoneMesh,
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 // ************************************************************************* //
dictionary dict
const fvMesh & mesh_
Definition: marchingCells.H:61
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
labelList addedCells_
Which are the added cells.
FaceCellWave< wallPointData< bool > > meshWave_
Engine propagating the active cells.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
Definition: FaceCellWave.H:206
label marchingStep_
Marching step.
Definition: marchingCells.H:82
void setMarchingStep(const label step)
Set marching step.
labelHashSet seedPatches_
Patches used as seeds in the marching algorithm.
Definition: marchingCells.H:66
dynamicFvMesh & mesh
DynamicList< label > activeCells_
Which are the active cells.
Definition: marchingCells.H:97
labelList seedFaceZoneIDs_
Face zones used as seeds in the marching algorithm.
Definition: marchingCells.H:77
const labelList & getActiveCells() const
Get the active cells.
void addFixedCells(const cellZoneMesh &cellZoneMesh, const labelList &fixedCellZoneIDs)
Add fixed cells through cellZone IDs.
List< wallPointData< bool > > allCellInfo_
Information for all cells.
void update(const label iters=1)
Update active cells.
boolList isActiveCell_
Whether each cell is curently active or not.
Definition: marchingCells.H:87
label numberOfAddedCells() const
Number of newly added cells in the last iteration.
bool initialised_
Has the initial seeding been conducted.
List< wallPointData< bool > > allFaceInfo_
Information for all faces.
virtual ~marchingCells()=default
Destructor.
void appendSeedCell(const label cellID)
Append cell to seed cells.
Definition: marchingCells.C:99
label nIters_
Iterations conducted thus far.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
loopControl iters(runTime, aMesh.solutionDict(), "solution")
void initialise()
Initialise the active cells from the seeding patches.
Definition: marchingCells.C:36
TypeName("marchingCells")
Runtime type information.
void march(label nVisited, const label cI, labelList &newlyAddedCells)
List< label > labelList
A List of labels.
Definition: List.H:62
boolList isFixedCell_
Should this cell remain incative.
Definition: marchingCells.H:92
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
Namespace for OpenFOAM.
labelList seedCellZoneIDs_
Cell zones, the boundary faces of which are used as seeds in the marching algorithm.
Definition: marchingCells.H:72