meshWaveFrozenPatchDistMethod.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6  Description:
7  A modified version of meshWave wall distance method
8  Basically, we compute the wall distance only once and save it to y_.
9  When the mesh is deformed during optimization, we will NOT update y_.
10  The reason we do this is that the meshWave fuction is not AD in
11  parallel so it will impact the adjoint derivative. Also, not updating
12  the wall distance during optimization has little impact on CFD
13 
14  This file is modified from OpenFOAM's source code
15  src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H
16 
17  OpenFOAM: The Open Source CFD Toolbox
18 
19  Copyright (C): 2011-2016 OpenFOAM Foundation
20 
21  OpenFOAM License:
22 
23  OpenFOAM is free software: you can redistribute it and/or modify it
24  under the terms of the GNU General Public License as published by
25  the Free Software Foundation, either version 3 of the License, or
26  (at your option) any later version.
27 
28  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
29  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
31  for more details.
32 
33  You should have received a copy of the GNU General Public License
34  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef meshWaveFrozenPatchDistMethod_H
39 #define meshWaveFrozenPatchDistMethod_H
40 
41 #include "patchDistMethod.H"
42 #include "fvMesh.H"
43 #include "volFields.H"
44 #include "patchWave.H"
45 #include "patchDataWave.H"
46 #include "wallPointData.H"
47 #include "emptyFvPatchFields.H"
48 #include "addToRunTimeSelectionTable.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 namespace patchDistMethods
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class meshWaveFrozen Declaration
59 \*---------------------------------------------------------------------------*/
60 
62  : public patchDistMethod
63 {
64  // Private Member Data
65 
66  //- Do accurate distance calculation for near-wall cells.
67  const bool correctWalls_;
68 
69  //- Number of unset cells and faces.
70  mutable label nUnset_;
71 
73  mutable volScalarField y_;
74 
76  mutable volVectorField n_;
77 
79  mutable label isComputed_ = 0;
80 
81  // Private Member Functions
82 
83  //- No copy construct
84  meshWaveFrozen(const meshWaveFrozen&) = delete;
85 
86  //- No copy assignment
87  void operator=(const meshWaveFrozen&) = delete;
88 
89 public:
90  //- Runtime type information
91  TypeName("meshWaveFrozen");
92 
93  // Constructors
94 
95  //- Construct from coefficients dictionary, mesh
96  // and fixed-value patch set
98  const dictionary& dict,
99  const fvMesh& mesh,
100  const labelHashSet& patchIDs);
101 
102  //- Construct from mesh, fixed-value patch set and flag specifying
103  // whether or not to correct wall.
104  // Calculate for all cells. correctWalls : correct wall (face&point)
105  // cells for correct distance, searching neighbours.
107  const fvMesh& mesh,
108  const labelHashSet& patchIDs,
109  const bool correctWalls = true);
110 
111  // Member Functions
112 
113  label nUnset() const
114  {
115  return nUnset_;
116  }
117 
118  //- Correct the given distance-to-patch field
119  virtual bool correct(volScalarField& y);
120 
121  //- Correct the given distance-to-patch and normal-to-patch fields
122  virtual bool correct(volScalarField& y, volVectorField& n);
123 };
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace patchDistMethods
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Foam::patchDistMethods::meshWaveFrozen::nUnset
label nUnset() const
Definition: meshWaveFrozenPatchDistMethod.H:113
Foam::patchDistMethods::meshWaveFrozen::TypeName
TypeName("meshWaveFrozen")
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::patchDistMethods::meshWaveFrozen
Definition: meshWaveFrozenPatchDistMethod.H:61
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::patchDistMethods::meshWaveFrozen::correct
virtual bool correct(volScalarField &y)
Definition: meshWaveFrozenPatchDistMethod.C:88