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 | Copyright (C) 2011-2013 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
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
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
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 // ************************************************************************* //
Foam::layerAdditionRemoval::extrusionDir
tmp< vectorField > extrusionDir() const
Calculate the offset to the next layer.
Definition: addCellLayer.C:38
Foam::layerAdditionRemoval::changeTopology
virtual bool changeTopology() const
Check for topology change.
Definition: layerAdditionRemoval.C:197
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::layerAdditionRemoval::layerAdditionRemoval
layerAdditionRemoval(const layerAdditionRemoval &)
Disallow default bitwise copy construct.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::layerAdditionRemoval::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: layerAdditionRemoval.C:434
Foam::layerAdditionRemoval::thicknessFromVolume_
const bool thicknessFromVolume_
Switch to calculate thickness as volume/area.
Definition: layerAdditionRemoval.H:69
Foam::layerAdditionRemoval
Cell layer addition mesh modifier.
Definition: layerAdditionRemoval.H:52
Foam::layerAdditionRemoval::clearAddressing
void clearAddressing() const
Clear addressing.
Definition: layerAdditionRemoval.C:107
Foam::layerAdditionRemoval::maxLayerThickness_
scalar maxLayerThickness_
Max thickness of extrusion layer. Triggers layer addition.
Definition: layerAdditionRemoval.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::layerAdditionRemoval::readOldThickness
static scalar readOldThickness(const dictionary &)
Optionally read old thickness.
Definition: layerAdditionRemoval.C:99
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition: polyTopoChanger.H:56
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:97
Foam::layerAdditionRemoval::setRefinement
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: layerAdditionRemoval.C:395
Foam::polyMeshModifier::index
label index() const
Return the index of this modifier.
Definition: polyMeshModifier.H:149
ZoneIDs.H
Foam::DynamicID< faceZoneMesh >
Foam::layerAdditionRemoval::pointsPairing
const labelList & pointsPairing() const
Return points pairing in a layer (not automatic!)
Definition: setLayerPairing.C:186
Foam::layerAdditionRemoval::~layerAdditionRemoval
virtual ~layerAdditionRemoval()
Destructor.
Definition: layerAdditionRemoval.C:189
Foam::layerAdditionRemoval::setMaxLayerThickness
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
Definition: layerAdditionRemoval.C:472
Foam::layerAdditionRemoval::removeCellLayer
void removeCellLayer(polyTopoChange &) const
Remove a layer of cells.
Definition: removeCellLayer.C:89
Foam::label
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
Foam::layerAdditionRemoval::addCellLayer
void addCellLayer(polyTopoChange &) const
Add a layer of cells.
Definition: addCellLayer.C:87
Foam::layerAdditionRemoval::facesPairing
const labelList & facesPairing() const
Return faces pairing in a layer (not automatic!)
Definition: setLayerPairing.C:198
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::layerAdditionRemoval::setMinLayerThickness
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
Definition: layerAdditionRemoval.C:459
Foam::layerAdditionRemoval::faceZoneID_
faceZoneID faceZoneID_
Master face zone ID.
Definition: layerAdditionRemoval.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::layerAdditionRemoval::maxLayerThickness
scalar maxLayerThickness() const
Return max layer thickness which triggers removal.
Definition: layerAdditionRemoval.H:205
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::layerAdditionRemoval::triggerAddition_
label triggerAddition_
Layer addition trigger time index.
Definition: layerAdditionRemoval.H:85
Foam::layerAdditionRemoval::facesPairingPtr_
labelList * facesPairingPtr_
Face pairing.
Definition: layerAdditionRemoval.H:79
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::layerAdditionRemoval::validCollapse
bool validCollapse() const
Check for valid layer.
Definition: removeCellLayer.C:39
Foam::polyMeshModifier
Virtual base class for mesh modifiers.
Definition: polyMeshModifier.H:61
Foam::layerAdditionRemoval::addDelta_
static const scalar addDelta_
Thickness insertion fraction for the pre-motion.
Definition: layerAdditionRemoval.H:136
Foam::polyMeshModifier::name
const word & name() const
Return name of this modifier.
Definition: polyMeshModifier.H:143
Foam::layerAdditionRemoval::oldLayerThickness_
scalar oldLayerThickness_
Layer thickness from previous step.
Definition: layerAdditionRemoval.H:73
Foam::layerAdditionRemoval::modifyMotionPoints
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
Definition: setLayerPairing.C:214
Foam::layerAdditionRemoval::operator=
void operator=(const layerAdditionRemoval &)
Disallow default bitwise assignment.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::layerAdditionRemoval::pointsPairingPtr_
labelList * pointsPairingPtr_
Point pairing.
Definition: layerAdditionRemoval.H:76
Foam::layerAdditionRemoval::minLayerThickness
scalar minLayerThickness() const
Return min layer thickness which triggers removal.
Definition: layerAdditionRemoval.H:196
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::layerAdditionRemoval::write
virtual void write(Ostream &) const
Write.
Definition: layerAdditionRemoval.C:485
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::layerAdditionRemoval::minLayerThickness_
scalar minLayerThickness_
Min thickness of extrusion layer. Triggers layer removal.
Definition: layerAdditionRemoval.H:62
Foam::layerAdditionRemoval::writeDict
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: layerAdditionRemoval.C:497
Foam::layerAdditionRemoval::triggerRemoval_
label triggerRemoval_
Layer removal trigger time index.
Definition: layerAdditionRemoval.H:82
Foam::layerAdditionRemoval::TypeName
TypeName("layerAdditionRemoval")
Runtime type information.
Foam::layerAdditionRemoval::setLayerPairing
bool setLayerPairing() const
Set layer pairing. Return true if a valid layer exists.
Definition: setLayerPairing.C:38
polyMeshModifier.H
Foam::layerAdditionRemoval::removeDelta_
static const scalar removeDelta_
Thickness removal fraction for the cell collapse.
Definition: layerAdditionRemoval.H:141
Foam::layerAdditionRemoval::checkDefinition
void checkDefinition()
Check validity of construction data.
Definition: layerAdditionRemoval.C:57