nearWallDistNoSearch.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) 2011-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 "nearWallDistNoSearch.H"
27 #include "fvMesh.H"
28 #include "wallFvPatch.H"
29 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 void Foam::nearWallDistNoSearch::doAll()
34 {
35  const volVectorField& cellCentres = mesh_.C();
36  const fvPatchList& patches = mesh_.boundary();
37 
38  forAll(patches, patchi)
39  {
40  fvPatchScalarField& ypatch = operator[](patchi);
41 
42  if (isA<wallFvPatch>(patches[patchi]))
43  {
44  const labelUList& faceCells = patches[patchi].faceCells();
45 
46  const fvPatchVectorField& patchCentres
47  = cellCentres.boundaryField()[patchi];
48 
49  const fvsPatchVectorField& Apatch
50  = mesh_.Sf().boundaryField()[patchi];
51 
52  const fvsPatchScalarField& magApatch
53  = mesh_.magSf().boundaryField()[patchi];
54 
55  forAll(patchCentres, facei)
56  {
57  ypatch[facei] =
58  (
59  Apatch[facei] &
60  (
61  patchCentres[facei]
62  - cellCentres[faceCells[facei]]
63  )
64  )/magApatch[facei];
65  }
66  }
67  else
68  {
69  ypatch = 0.0;
70  }
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 :
79  volScalarField::Boundary
80  (
81  mesh.boundary(),
82  mesh.V(), // Dummy internal field
83  calculatedFvPatchScalarField::typeName
84  ),
85  mesh_(mesh)
86 {
87  doAll();
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 {
101  if (mesh_.changing())
102  {
103  // Update size of Boundary
104  forAll(mesh_.boundary(), patchi)
105  {
106  operator[](patchi).setSize(mesh_.boundary()[patchi].size());
107  }
108  }
109 
110  doAll();
111 }
112 
113 
114 // ************************************************************************* //
Foam::surfaceFields.
fvsPatchField< vector > fvsPatchVectorField
fvsPatchField< scalar > fvsPatchScalarField
bool changing() const
Is mesh changing (topology changing and/or moving)
Definition: polyMesh.H:540
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const surfaceVectorField & Sf() const
Return cell face area vectors.
fvPatchField< vector > fvPatchVectorField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
UList< label > labelUList
Definition: UList.H:65
dynamicFvMesh & mesh
fvPatchField< scalar > fvPatchScalarField
virtual void correct()
Correct for mesh geom/topo changes.
faceListList boundary(nPatches)
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
nearWallDistNoSearch(const fvMesh &mesh)
Construct from components.
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:45
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual ~nearWallDistNoSearch()
Destructor.
const volVectorField & C() const
Return cell centres as volVectorField.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:540