PoissonPatchDistMethod.C
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) 2015 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 {
37  defineTypeNameAndDebug(Poisson, 0);
38  addToRunTimeSelectionTable(patchDistMethod, Poisson, dictionary);
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  (
83  new volScalarField
84  (
85  IOobject
86  (
87  "yPsi",
88  mesh_.time().timeName(),
89  mesh_
90  ),
91  mesh_,
92  dimensionedScalar("yPsi", sqr(dimLength), 0.0),
93  y.boundaryField().types()
94  )
95  );
96  }
97 
98  volScalarField& yPsi = tyPsi_();
99 
100  solve(fvm::laplacian(yPsi) == dimensionedScalar("1", dimless, -1.0));
101 
102  volVectorField gradyPsi(fvc::grad(yPsi));
103  volScalarField magGradyPsi(mag(gradyPsi));
104 
105  y = sqrt(magSqr(gradyPsi) + 2*yPsi) - magGradyPsi;
106 
107  // Cache yPsi if the mesh is moving otherwise delete
108  if (!mesh_.changing())
109  {
110  tyPsi_.clear();
111  }
112 
113  // Only calculate n if the field is defined
114  if (notNull(n))
115  {
116  n =
117  -gradyPsi
118  /max
119  (
120  magGradyPsi,
121  dimensionedScalar("smallMagGradyPsi", dimLength, SMALL)
122  );
123  }
124 
125  return true;
126 }
127 
128 
129 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::notNull
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:46
Foam::patchDistMethods::Poisson::correct
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
Definition: PoissonPatchDistMethod.C:67
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::HashSet< label, Hash< label > >
Foam::patchDistMethods::defineTypeNameAndDebug
defineTypeNameAndDebug(advectionDiffusion, 0)
Foam::patchDistMethods::Poisson::Poisson
Poisson(const Poisson &)
Disallow default bitwise copy construct.
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::patchDistMethod
Specialisation of patchDist for wall distance calculation.
Definition: patchDistMethod.H:56
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
PoissonPatchDistMethod.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::patchDistMethods::addToRunTimeSelectionTable
addToRunTimeSelectionTable(patchDistMethod, advectionDiffusion, dictionary)
Foam::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
fvcGrad.H
Calculate the gradient of the given field.
Foam::GeometricField::null
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
Definition: GeometricFieldI.H:30
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
y
scalar y
Definition: LISASMDCalcMethod1.H:14