layerAdditionRemoval.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) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
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  Foam::layerAdditionRemoval
29 
30 Description
31  Cell layer addition mesh modifier
32 
33 SourceFiles
34  layerAdditionRemoval.C
35  addCellLayer.C
36  removeCellLayer.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef layerAdditionRemoval_H
41 #define layerAdditionRemoval_H
42 
43 #include "polyMeshModifier.H"
44 #include "primitiveFacePatch.H"
45 #include "ZoneIDs.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class layerAdditionRemoval Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public polyMeshModifier
59 {
60  // Private Data
61 
62  //- Master face zone ID
63  faceZoneID faceZoneID_;
64 
65  //- Min thickness of extrusion layer. Triggers layer removal
66  mutable scalar minLayerThickness_;
67 
68  //- Max thickness of extrusion layer. Triggers layer addition
69  mutable scalar maxLayerThickness_;
70 
71  //- Switch to calculate thickness as volume/area
72  // If false, thickness calculated from edges
73  const bool thicknessFromVolume_;
74 
75  //- Layer thickness from previous step
76  // Used to decide whether to add or remove layers
77  mutable scalar oldLayerThickness_;
78 
79  //- Point pairing
80  mutable unique_ptr<labelList> pointsPairingPtr_;
81 
82  //- Face pairing
83  mutable unique_ptr<labelList> facesPairingPtr_;
84 
85  //- Layer removal trigger time index
86  mutable label triggerRemoval_;
87 
88  //- Layer addition trigger time index
89  mutable label triggerAddition_;
90 
91 
92  // Private Member Functions
93 
94  //- No copy construct
96 
97  //- No copy assignment
98  void operator=(const layerAdditionRemoval&) = delete;
99 
100  //- Check validity of construction data
101  void checkDefinition();
102 
103 
104  // Topological Changes
105 
106  //- Check for valid layer
107  bool validCollapse() const;
108 
109  //- Set layer pairing. Return true if a valid layer exists
110  bool setLayerPairing() const;
111 
112  //- Return points pairing in a layer (not automatic!)
113  const labelList& pointsPairing() const;
114 
115  //- Return faces pairing in a layer (not automatic!)
116  const labelList& facesPairing() const;
117 
118  //- Calculate the offset to the next layer
119  tmp<vectorField> extrusionDir() const;
120 
121  //- Add a layer of cells
122  void addCellLayer(polyTopoChange&) const;
123 
124  //- Remove a layer of cells
125  void removeCellLayer(polyTopoChange&) const;
126 
127  //- Clear addressing
128  void clearAddressing() const;
129 
130 
131  // Static Data Members
132 
133  //- Thickness insertion fraction for the pre-motion
134  static const scalar addDelta_;
135 
136  //- Thickness removal fraction for the cell collapse
137  // Note: the cell will be collapsed to this relative
138  // thickness before the layer is removed.
139  static const scalar removeDelta_;
140 
141 public:
142 
143  //- Runtime type information
144  TypeName("layerAdditionRemoval");
145 
146 
147  // Constructors
148 
149  //- Construct from components
151  (
152  const word& name,
153  const label index,
154  const polyTopoChanger& ptc,
155  const word& zoneName,
156  const scalar minThickness,
157  const scalar maxThickness,
158  const bool thicknessFromVolume = true
159  );
160 
161  //- Construct from dictionary
163  (
164  const word& name,
165  const dictionary& dict,
166  const label index,
167  const polyTopoChanger& ptc
168  );
169 
170 
171  //- Destructor
172  virtual ~layerAdditionRemoval() = default;
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 updateMesh(const mapPolyMesh&);
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 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
Foam::layerAdditionRemoval::changeTopology
virtual bool changeTopology() const
Check for topology change.
Definition: layerAdditionRemoval.C:158
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::layerAdditionRemoval::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: layerAdditionRemoval.C:395
Foam::layerAdditionRemoval
Cell layer addition mesh modifier.
Definition: layerAdditionRemoval.H:55
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition: polyTopoChanger.H:62
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:99
Foam::layerAdditionRemoval::setRefinement
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: layerAdditionRemoval.C:356
primitiveFacePatch.H
Foam::polyMeshModifier::index
label index() const
Return the index of this modifier.
Definition: polyMeshModifier.H:156
ZoneIDs.H
Foam::DynamicID< faceZoneMesh >
Foam::layerAdditionRemoval::setMaxLayerThickness
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
Definition: layerAdditionRemoval.C:433
Foam::Field< vector >
Foam::layerAdditionRemoval::setMinLayerThickness
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
Definition: layerAdditionRemoval.C:420
Foam::layerAdditionRemoval::~layerAdditionRemoval
virtual ~layerAdditionRemoval()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::layerAdditionRemoval::maxLayerThickness
scalar maxLayerThickness() const
Return max layer thickness which triggers removal.
Definition: layerAdditionRemoval.H:202
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyMeshModifier
Virtual base class for mesh modifiers.
Definition: polyMeshModifier.H:68
Foam::polyMeshModifier::name
const word & name() const
Return name of this modifier.
Definition: polyMeshModifier.H:150
Foam::layerAdditionRemoval::modifyMotionPoints
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
Definition: setLayerPairing.C:216
Foam::List< label >
Foam::layerAdditionRemoval::minLayerThickness
scalar minLayerThickness() const
Return min layer thickness which triggers removal.
Definition: layerAdditionRemoval.H:193
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::layerAdditionRemoval::write
virtual void write(Ostream &) const
Write.
Definition: layerAdditionRemoval.C:446
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::layerAdditionRemoval::writeDict
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: layerAdditionRemoval.C:458
Foam::layerAdditionRemoval::TypeName
TypeName("layerAdditionRemoval")
Runtime type information.
polyMeshModifier.H