PoissonPatchDistMethod.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "PoissonPatchDistMethod.H"
27 #include "fvcGrad.H"
28 #include "fvmLaplacian.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace patchDistMethods
36 {
39 }
40 }
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const dictionary& dict,
47  const fvMesh& mesh,
48  const labelHashSet& patchIDs
49 )
50 :
51  patchDistMethod(mesh, patchIDs)
52 {}
53 
54 
56 (
57  const fvMesh& mesh,
58  const labelHashSet& patchIDs
59 )
60 :
61  patchDistMethod(mesh, patchIDs)
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 {
69  return correct(y, const_cast<volVectorField&>(volVectorField::null()));
70 }
71 
72 
74 (
77 )
78 {
79  if (!tyPsi_.valid())
80  {
81  tyPsi_ = tmp<volScalarField>
82  (
84  (
85  "yPsi",
86  mesh_,
88  y.boundaryFieldRef().types()
89  )
90  );
91  }
92  volScalarField& yPsi = tyPsi_.ref();
93 
95 
96  volVectorField gradyPsi(fvc::grad(yPsi));
97  volScalarField magGradyPsi(mag(gradyPsi));
98 
99  y = sqrt(magSqr(gradyPsi) + 2*yPsi) - magGradyPsi;
100 
101  // Cache yPsi if the mesh is moving otherwise delete
102  if (!mesh_.changing())
103  {
104  tyPsi_.clear();
105  }
106 
107  // Only calculate n if the field is defined
108  if (notNull(n))
109  {
110  n =
111  -gradyPsi
112  /max
113  (
114  magGradyPsi,
116  );
117  }
118 
119  return true;
120 }
121 
122 
123 // ************************************************************************* //
scalar y
label n
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:125
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Specialisation of patchDist for wall distance calculation.
Calculation of approximate distance to nearest patch for all cells and boundary by solving Poisson's ...
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
Poisson(const dictionary &dict, const fvMesh &mesh, const labelHashSet &patchIDs)
Construct from coefficients dictionary, mesh.
A class for managing temporary objects.
Definition: tmp.H:55
Calculate the gradient of the given field.
Calculate the matrix for the laplacian of the field.
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp, const SuType &Su)
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
defineTypeNameAndDebug(advectionDiffusion, 0)
addToRunTimeSelectionTable(patchDistMethod, advectionDiffusion, dictionary)
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimless
const dimensionSet dimLength
dimensionedScalar sqrt(const dimensionedScalar &ds)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:64
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
dictionary dict