wallDist.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) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2016 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::wallDist
29 
30 Description
31  Interface to run-time selectable methods to calculate the distance-to-wall
32  and normal-to-wall fields.
33 
34  Example of the wallDist specification in fvSchemes:
35  \verbatim
36  wallDist
37  {
38  method meshWave;
39 
40  // Optional entry enabling the calculation
41  // of the normal-to-wall field
42  nRequired false;
43 
44  // Optional entry delaying wall distance update to every n steps
45  // Default is 1 (update every step)
46  updateInterval 5;
47  }
48  \endverbatim
49 
50 See also
51  Foam::patchDistMethod::meshWave
52  Foam::patchDistMethod::Poisson
53  Foam::patchDistMethod::advectionDiffusion
54 
55 SourceFiles
56  wallDist.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef Foam_wallDist_H
61 #define Foam_wallDist_H
62 
63 #include "MeshObject.H"
64 #include "patchDistMethod.H"
65 #include "volFields.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class wallDist Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class wallDist
77 :
78  public MeshObject<fvMesh, UpdateableMeshObject, wallDist>
79 {
80  // Private Typedefs
81 
82  typedef MeshObject
83  <
84  fvMesh,
86  wallDist
88 
89 
90  // Private Data
91 
92  //- Set of patch IDs
93  const labelHashSet patchIDs_;
94 
95  //- Name for the patch set, e.g. "wall"
96  const word patchTypeName_;
97 
98  //- Construction dictionary
99  const dictionary dict_;
100 
101  //- Run-time selected method to generate the distance-to-wall field
102  mutable autoPtr<patchDistMethod> pdm_;
103 
104  //- Distance-to-wall field
105  mutable volScalarField y_;
106 
107  //- Normal-to-wall field
108  mutable tmp<volVectorField> n_;
109 
110  //- Update wall distance every updateInterval_ steps
111  const label updateInterval_;
112 
113  //- Flag to indicate if the distance-to-wall field is required
114  mutable bool nRequired_;
115 
116  //- Flag to indicate whether the wall distance requires updating
117  bool requireUpdate_;
118 
119 
120  // Private Member Functions
121 
122  //- Construct the normal-to-wall field as required
123  void constructn() const;
124 
125  //- No copy construct
126  wallDist(const wallDist&) = delete;
127 
128  //- No copy assignment
129  void operator=(const wallDist&) = delete;
130 
131 
132 public:
133 
134  // Declare name of the class and its debug switch
135  ClassName("wallDist");
136 
137 
138  // Constructors
139 
140  //- Construct from mesh, patch IDs and optional patch type name
141  wallDist
142  (
143  const fvMesh& mesh,
144  const labelHashSet& patchIDs,
145  const word& patchTypeName = "patch"
146  );
147 
148  //- Construct from mesh, patch IDs, default patch distance method
149  // and optional patch type name
150  wallDist
151  (
152  const fvMesh& mesh,
153  const word& defaultPatchDistMethod,
154  const labelHashSet& patchIDs,
155  const word& patchTypeName = "patch"
156  );
157 
158  //- Construct from mesh and optional patch type name
159  wallDist
160  (
161  const fvMesh& mesh,
162  const word& patchTypeName = "wall"
163  );
164 
165 
166  //- Destructor
167  virtual ~wallDist();
168 
169 
170  // Static Member Functions
171 
172  //- Trigger update of y-field for the "wallDist" MeshObject on the
173  //- given mesh. A no-op if the wallDist is not found.
174  static bool try_movePoints(const fvMesh& mesh);
175 
176 
177  // Member Functions
178 
179  //- Return the patchIDs
180  const labelHashSet& patchIDs() const noexcept
181  {
182  return patchIDs_;
183  }
184 
185  //- Return reference to cached distance-to-wall field
186  const volScalarField& y() const noexcept
187  {
188  return y_;
189  }
190 
191  //- Return reference to cached normal-to-wall field
192  const volVectorField& n() const;
193 
194  //- Update the y-field when the mesh moves
195  virtual bool movePoints();
196 
197  //- Update the y-field when the mesh changes
198  virtual void updateMesh(const mapPolyMesh&);
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
const volVectorField & n() const
Return reference to cached normal-to-wall field.
Definition: wallDist.C:168
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~wallDist()
Destructor.
Definition: wallDist.C:146
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
ClassName("wallDist")
const fvMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:255
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void updateMesh(const mapPolyMesh &)
Update the y-field when the mesh changes.
Definition: wallDist.C:217
virtual bool movePoints()
Update the y-field when the mesh moves.
Definition: wallDist.C:186
const volScalarField & y() const noexcept
Return reference to cached distance-to-wall field.
Definition: wallDist.H:220
const labelHashSet & patchIDs() const noexcept
Return the patchIDs.
Definition: wallDist.H:212
const direction noexcept
Definition: Scalar.H:258
static bool try_movePoints(const fvMesh &mesh)
Trigger update of y-field for the "wallDist" MeshObject on the given mesh. A no-op if the wallDist is...
Definition: wallDist.C:152
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Interface to run-time selectable methods to calculate the distance-to-wall and normal-to-wall fields...
Definition: wallDist.H:71
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
UpdateableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:352