meshWaveFrozenPatchDistMethod.C
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 Poisson method for computing wall distance
8  Basically, we replace the original max function with the softmax
9  function to avoid discontinuity
10 
11  This file is modified from OpenFOAM's source code
12  src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C
13 
14  OpenFOAM: The Open Source CFD Toolbox
15 
16  Copyright (C): 2011-2016 OpenFOAM Foundation
17 
18  OpenFOAM License:
19 
20  OpenFOAM is free software: you can redistribute it and/or modify it
21  under the terms of the GNU General Public License as published by
22  the Free Software Foundation, either version 3 of the License, or
23  (at your option) any later version.
24 
25  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
26  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28  for more details.
29 
30  You should have received a copy of the GNU General Public License
31  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
32 
33 \*---------------------------------------------------------------------------*/
34 
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace patchDistMethods
42 {
44 addToRunTimeSelectionTable(patchDistMethod, meshWaveFrozen, dictionary);
45 }
46 }
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::patchDistMethods::meshWaveFrozen::meshWaveFrozen(
51  const dictionary& dict,
52  const fvMesh& mesh,
53  const labelHashSet& patchIDs)
54  : patchDistMethod(mesh, patchIDs),
55  correctWalls_(dict.lookupOrDefault("correctWalls", true)),
56  nUnset_(0),
57  y_(IOobject("yWallFrozen", mesh.time().timeName(), mesh),
58  mesh,
59  dimensionedScalar("yWallFrozen", dimLength, SMALL),
60  patchDistMethod::patchTypes<scalar>(mesh, patchIDs)),
61  n_(IOobject("nWallFrozen", mesh.time().timeName(), mesh),
62  mesh,
63  dimensionedVector(dimless, Zero),
64  patchDistMethod::patchTypes<vector>(mesh, patchIDs))
65 {
66 }
67 
68 Foam::patchDistMethods::meshWaveFrozen::meshWaveFrozen(
69  const fvMesh& mesh,
70  const labelHashSet& patchIDs,
71  const bool correctWalls)
72  : patchDistMethod(mesh, patchIDs),
73  correctWalls_(correctWalls),
74  nUnset_(0),
75  y_(IOobject("yWallFrozen", mesh.time().timeName(), mesh),
76  mesh,
77  dimensionedScalar("yWallFrozen", dimLength, SMALL),
78  patchDistMethod::patchTypes<scalar>(mesh, patchIDs)),
79  n_(IOobject("nWallFrozen", mesh.time().timeName(), mesh),
80  mesh,
81  dimensionedVector(dimless, Zero),
82  patchDistMethod::patchTypes<vector>(mesh, patchIDs))
83 {
84 }
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  if (isComputed_)
91  {
92  y = y_;
93  return nUnset_ > 0;
94  }
95  else
96  {
97  y = dimensionedScalar("yWall", dimLength, GREAT);
98 
99  // Calculate distance starting from patch faces
100  patchWave wave(mesh_, patchIDs_, correctWalls_);
101 
102  // Transfer cell values from wave into y
103  y.transfer(wave.distance());
104 
105  // Transfer values on patches into boundaryField of y
106  volScalarField::Boundary& ybf = y.boundaryFieldRef();
107 
108  forAll(ybf, patchi)
109  {
110  if (!isA<emptyFvPatchScalarField>(ybf[patchi]))
111  {
112  scalarField& waveFld = wave.patchDistance()[patchi];
113 
114  ybf[patchi].transfer(waveFld);
115  }
116  }
117 
118  // Transfer number of unset values
119  nUnset_ = wave.nUnset();
120 
121  y_ = y;
122 
123  isComputed_ = 1;
124 
125  return nUnset_ > 0;
126  }
127 }
128 
130  volScalarField& y,
131  volVectorField& n)
132 {
133  // NOT implemented!
134  FatalErrorIn("") << "NOT implemented" << abort(FatalError);
135  return nUnset_ > 0;
136 }
137 
138 // ************************************************************************* //
forAll
forAll(pseudoP.boundaryField(), patchI)
Definition: solvePseudoPEqn.H:10
meshWaveFrozenPatchDistMethod.H
Foam::patchDistMethods::addToRunTimeSelectionTable
addToRunTimeSelectionTable(patchDistMethod, meshWaveFrozen, dictionary)
Foam::patchDistMethods::defineTypeNameAndDebug
defineTypeNameAndDebug(meshWaveFrozen, 0)
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