FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 
42 #include <OpenFOAM/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  //- Layer thickness from previous step
69  // Used to decide whether to add or remove layers
70  mutable scalar oldLayerThickness_;
71 
72  //- Point pairing
73  mutable labelList* pointsPairingPtr_;
74 
75  //- Face pairing
76  mutable labelList* facesPairingPtr_;
77 
78  //- Layer removal trigger time index
79  mutable label triggerRemoval_;
80 
81  //- Layer addition trigger time index
82  mutable label triggerAddition_;
83 
84 
85  // Private Member Functions
86 
87  //- Disallow default bitwise copy construct
89 
90  //- Disallow default bitwise assignment
91  void operator=(const layerAdditionRemoval&);
92 
93  //- Check validity of construction data
94  void checkDefinition();
95 
96 
97  // Topological changes
98 
99  //- Check for valid layer
100  bool validCollapse() const;
101 
102  //- Set layer pairing. Return true if a valid layer exists
103  bool setLayerPairing() const;
104 
105  //- Return points pairing in a layer (not automatic!)
106  const labelList& pointsPairing() const;
107 
108  //- Return faces pairing in a layer (not automatic!)
109  const labelList& facesPairing() const;
110 
111  //- Calculate the offset to the next layer
112  tmp<vectorField> extrusionDir() const;
113 
114  //- Add a layer of cells
115  void addCellLayer(polyTopoChange&) const;
116 
117  //- Remove a layer of cells
118  void removeCellLayer(polyTopoChange&) const;
119 
120  //- Clear addressing
121  void clearAddressing() const;
122 
123  // Helpers
124 
125  //- Optionally read old thickness
126  static scalar readOldThickness(const dictionary&);
127 
128 
129  // Static data members
130 
131  //- Thickness insertion fraction for the pre-motion
132  static const scalar addDelta_;
133 
134  //- Thickness removal fraction for the cell collapse
135  // Note: the cell will be collapsed to this relative
136  // thickness before the layer is removed.
137  static const scalar removeDelta_;
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("layerAdditionRemoval");
143 
144 
145  // Constructors
146 
147  //- Construct from components
149  (
150  const word& name,
151  const label index,
152  const polyTopoChanger& mme,
153  const word& zoneName,
154  const scalar minThickness,
155  const scalar maxThickness
156  );
157 
158  //- Construct from dictionary
160  (
161  const word& name,
162  const dictionary& dict,
163  const label index,
164  const polyTopoChanger& mme
165  );
166 
167 
168  // Destructor
169 
170  virtual ~layerAdditionRemoval();
171 
172 
173  // Member Functions
174 
175  //- Check for topology change
176  virtual bool changeTopology() const;
177 
178  //- Insert the layer addition/removal instructions
179  // into the topological change
180  virtual void setRefinement(polyTopoChange&) const;
181 
182  //- Modify motion points to comply with the topological change
183  virtual void modifyMotionPoints(pointField& motionPoints) const;
184 
185  //- Force recalculation of locally stored data on topological change
186  virtual void updateMesh(const mapPolyMesh&);
187 
188 
189  // Edit
190 
191  //- Return min layer thickness which triggers removal
192  scalar minLayerThickness() const
193  {
194  return minLayerThickness_;
195  }
196 
197  //- Set min layer thickness which triggers removal
198  void setMinLayerThickness(const scalar t) const;
199 
200  //- Return max layer thickness which triggers removal
201  scalar maxLayerThickness() const
202  {
203  return maxLayerThickness_;
204  }
205 
206  //- Set max layer thickness which triggers removal
207  void setMaxLayerThickness(const scalar t) const;
208 
209 
210  //- Write
211  virtual void write(Ostream&) const;
212 
213  //- Write dictionary
214  virtual void writeDict(Ostream&) const;
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************ vim: set sw=4 sts=4 et: ************************ //