layerAdditionRemoval.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::layerAdditionRemoval
26 
27 Description
28  Cell layer addition mesh modifier
29 
30 SourceFiles
31  layerAdditionRemoval.C
32  addCellLayer.C
33  removeCellLayer.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef layerAdditionRemoval_H
38 #define layerAdditionRemoval_H
39 
40 #include "polyMeshModifier.H"
41 #include "primitiveFacePatch.H"
42 #include "ZoneIDs.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class layerAdditionRemoval Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public polyMeshModifier
56 {
57  // Private Data
58 
59  //- Master face zone ID
60  faceZoneID faceZoneID_;
61 
62  //- Min thickness of extrusion layer. Triggers layer removal
63  mutable scalar minLayerThickness_;
64 
65  //- Max thickness of extrusion layer. Triggers layer addition
66  mutable scalar maxLayerThickness_;
67 
68  //- Switch to calculate thickness as volume/area
69  // If false, thickness calculated from edges
70  const bool thicknessFromVolume_;
71 
72  //- Layer thickness from previous step
73  // Used to decide whether to add or remove layers
74  mutable scalar oldLayerThickness_;
75 
76  //- Point pairing
77  mutable labelList* pointsPairingPtr_;
78 
79  //- Face pairing
80  mutable labelList* facesPairingPtr_;
81 
82  //- Layer removal trigger time index
83  mutable label triggerRemoval_;
84 
85  //- Layer addition trigger time index
86  mutable label triggerAddition_;
87 
88 
89  // Private Member Functions
90 
91  //- Check validity of construction data
92  void checkDefinition();
93 
94 
95  // Topological changes
96 
97  //- Check for valid layer
98  bool validCollapse() const;
99 
100  //- Set layer pairing. Return true if a valid layer exists
101  bool setLayerPairing() const;
102 
103  //- Return points pairing in a layer (not automatic!)
104  const labelList& pointsPairing() const;
105 
106  //- Return faces pairing in a layer (not automatic!)
107  const labelList& facesPairing() const;
108 
109  //- Calculate the offset to the next layer
110  tmp<vectorField> extrusionDir() const;
111 
112  //- Add a layer of cells
113  void addCellLayer(polyTopoChange&) const;
114 
115  //- Remove a layer of cells
116  void removeCellLayer(polyTopoChange&) const;
117 
118  //- Clear addressing
119  void clearAddressing() const;
120 
121 
122  // Helpers
123 
124  //- Optionally read old thickness
125  static scalar readOldThickness(const dictionary&);
126 
127 
128  // Static Data Members
129 
130  //- Thickness insertion fraction for the pre-motion
131  static const scalar addDelta_;
132 
133  //- Thickness removal fraction for the cell collapse
134  // Note: the cell will be collapsed to this relative
135  // thickness before the layer is removed.
136  static const scalar removeDelta_;
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("layerAdditionRemoval");
142 
143 
144  // Constructors
145 
146  //- Construct from components
148  (
149  const word& name,
150  const label index,
151  const polyTopoChanger& ptc,
152  const word& zoneName,
153  const scalar minThickness,
154  const scalar maxThickness,
155  const Switch thicknessFromVolume = true
156  );
157 
158  //- Construct from dictionary
160  (
161  const word& name,
162  const dictionary& dict,
163  const label index,
164  const polyTopoChanger& ptc
165  );
166 
167  //- Disallow default bitwise copy construction
169 
170 
171  //- Destructor
172  virtual ~layerAdditionRemoval();
173 
174 
175  // Member Functions
176 
177  //- Check for topology change
178  virtual bool changeTopology() const;
179 
180  //- Insert the layer addition/removal instructions
181  // into the topological change
182  virtual void setRefinement(polyTopoChange&) const;
183 
184  //- Modify motion points to comply with the topological change
185  virtual void modifyMotionPoints(pointField& motionPoints) const;
186 
187  //- Force recalculation of locally stored data on topological change
188  virtual void topoChange(const polyTopoChangeMap&);
189 
190 
191  // Edit
192 
193  //- Return min layer thickness which triggers removal
194  scalar minLayerThickness() const
195  {
196  return minLayerThickness_;
197  }
198 
199  //- Set min layer thickness which triggers removal
200  void setMinLayerThickness(const scalar t) const;
201 
202  //- Return max layer thickness which triggers removal
203  scalar maxLayerThickness() const
204  {
205  return maxLayerThickness_;
206  }
207 
208  //- Set max layer thickness which triggers removal
209  void setMaxLayerThickness(const scalar t) const;
210 
211 
212  //- Write
213  virtual void write(Ostream&) const;
214 
215  //- Write dictionary
216  virtual void writeDict(Ostream&) const;
217 
218 
219  // Member Operators
220 
221  //- Disallow default bitwise assignment
222  void operator=(const layerAdditionRemoval&) = delete;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
dictionary dict
virtual void write(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
virtual bool changeTopology() const
Check for topology change.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
layerAdditionRemoval(const word &name, const label index, const polyTopoChanger &ptc, const word &zoneName, const scalar minThickness, const scalar maxThickness, const Switch thicknessFromVolume=true)
Construct from components.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
virtual ~layerAdditionRemoval()
Destructor.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Virtual base class for mesh modifiers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
TypeName("layerAdditionRemoval")
Runtime type information.
scalar maxLayerThickness() const
Return max layer thickness which triggers removal.
virtual void writeDict(Ostream &) const
Write dictionary.
Cell layer addition mesh modifier.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const word & name() const
Return name of this modifier.
void operator=(const layerAdditionRemoval &)=delete
Disallow default bitwise assignment.
scalar minLayerThickness() const
Return min layer thickness which triggers removal.
label index() const
Return the index of this modifier.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.