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