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-2018 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  //- Disallow default bitwise copy construct
93 
94  //- Disallow default bitwise assignment
95  void operator=(const layerAdditionRemoval&);
96 
97  //- Check validity of construction data
98  void checkDefinition();
99 
100 
101  // Topological changes
102 
103  //- Check for valid layer
104  bool validCollapse() const;
105 
106  //- Set layer pairing. Return true if a valid layer exists
107  bool setLayerPairing() const;
108 
109  //- Return points pairing in a layer (not automatic!)
110  const labelList& pointsPairing() const;
111 
112  //- Return faces pairing in a layer (not automatic!)
113  const labelList& facesPairing() const;
114 
115  //- Calculate the offset to the next layer
116  tmp<vectorField> extrusionDir() const;
117 
118  //- Add a layer of cells
119  void addCellLayer(polyTopoChange&) const;
120 
121  //- Remove a layer of cells
122  void removeCellLayer(polyTopoChange&) const;
123 
124  //- Clear addressing
125  void clearAddressing() const;
126 
127 
128  // Helpers
129 
130  //- Optionally read old thickness
131  static scalar readOldThickness(const dictionary&);
132 
133 
134  // Static data members
135 
136  //- Thickness insertion fraction for the pre-motion
137  static const scalar addDelta_;
138 
139  //- Thickness removal fraction for the cell collapse
140  // Note: the cell will be collapsed to this relative
141  // thickness before the layer is removed.
142  static const scalar removeDelta_;
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("layerAdditionRemoval");
148 
149 
150  // Constructors
151 
152  //- Construct from components
154  (
155  const word& name,
156  const label index,
157  const polyTopoChanger& ptc,
158  const word& zoneName,
159  const scalar minThickness,
160  const scalar maxThickness,
161  const Switch thicknessFromVolume = true
162  );
163 
164  //- Construct from dictionary
166  (
167  const word& name,
168  const dictionary& dict,
169  const label index,
170  const polyTopoChanger& ptc
171  );
172 
173 
174  //- Destructor
175  virtual ~layerAdditionRemoval();
176 
177 
178  // Member Functions
179 
180  //- Check for topology change
181  virtual bool changeTopology() const;
182 
183  //- Insert the layer addition/removal instructions
184  // into the topological change
185  virtual void setRefinement(polyTopoChange&) const;
186 
187  //- Modify motion points to comply with the topological change
188  virtual void modifyMotionPoints(pointField& motionPoints) const;
189 
190  //- Force recalculation of locally stored data on topological change
191  virtual void updateMesh(const mapPolyMesh&);
192 
193 
194  // Edit
195 
196  //- Return min layer thickness which triggers removal
197  scalar minLayerThickness() const
198  {
199  return minLayerThickness_;
200  }
201 
202  //- Set min layer thickness which triggers removal
203  void setMinLayerThickness(const scalar t) const;
204 
205  //- Return max layer thickness which triggers removal
206  scalar maxLayerThickness() const
207  {
208  return maxLayerThickness_;
209  }
210 
211  //- Set max layer thickness which triggers removal
212  void setMaxLayerThickness(const scalar t) const;
213 
214 
215  //- Write
216  virtual void write(Ostream&) const;
217 
218  //- Write dictionary
219  virtual void writeDict(Ostream&) const;
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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:137
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.
Definition: Switch.H:60
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
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
Virtual base class for mesh modifiers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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.
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.