inverseFaceDistanceDiffusivity.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-2019 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 
27 #include "surfaceFields.H"
28 #include "HashSet.H"
29 #include "wallPoint.H"
30 #include "MeshWave.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(inverseFaceDistanceDiffusivity, 0);
38 
40  (
41  motionDiffusivity,
42  inverseFaceDistanceDiffusivity,
43  Istream
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const fvMesh& mesh,
53  Istream& mdData
54 )
55 :
56  motionDiffusivity(mesh),
57  patchNames_(mdData)
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
68 
71 {
72  tmp<surfaceScalarField> tfaceDiffusivity
73  (
75  (
76  IOobject
77  (
78  "faceDiffusivity",
79  mesh().time().timeName(),
80  mesh(),
83  ),
84  mesh(),
86  )
87  );
88 
89  surfaceScalarField& faceDiffusivity = tfaceDiffusivity.ref();
90 
91  const polyBoundaryMesh& bdry = mesh().boundaryMesh();
92 
93  labelHashSet patchSet(bdry.size());
94 
95  label nPatchFaces = 0;
96 
97  forAll(patchNames_, i)
98  {
99  const label pID = bdry.findPatchID(patchNames_[i]);
100 
101  if (pID > -1)
102  {
103  patchSet.insert(pID);
104  nPatchFaces += bdry[pID].size();
105  }
106  }
107 
108  List<wallPoint> faceDist(nPatchFaces);
109  labelList changedFaces(nPatchFaces);
110 
111  nPatchFaces = 0;
112 
113  forAllConstIter(labelHashSet, patchSet, iter)
114  {
115  const polyPatch& patch = bdry[iter.key()];
116 
117  const vectorField::subField fc(patch.faceCentres());
118 
119  forAll(fc, patchFacei)
120  {
121  changedFaces[nPatchFaces] = patch.start() + patchFacei;
122 
123  faceDist[nPatchFaces] = wallPoint(fc[patchFacei], 0);
124 
125  nPatchFaces++;
126  }
127  }
128  faceDist.setSize(nPatchFaces);
129  changedFaces.setSize(nPatchFaces);
130 
131  MeshWave<wallPoint> waveInfo
132  (
133  mesh(),
134  changedFaces,
135  faceDist,
136  mesh().globalData().nTotalCells()+1 // max iterations
137  );
138 
139  const List<wallPoint>& faceInfo = waveInfo.allFaceInfo();
140  const List<wallPoint>& cellInfo = waveInfo.allCellInfo();
141 
142  for (label facei=0; facei<mesh().nInternalFaces(); facei++)
143  {
144  const scalar dist = faceInfo[facei].distSqr();
145 
146  faceDiffusivity[facei] = 1.0/sqrt(dist);
147  }
148 
149  surfaceScalarField::Boundary& faceDiffusivityBf =
150  faceDiffusivity.boundaryFieldRef();
151 
152  forAll(faceDiffusivityBf, patchi)
153  {
154  fvsPatchScalarField& bfld = faceDiffusivityBf[patchi];
155 
156  const labelUList& faceCells = bfld.patch().faceCells();
157 
158  if (patchSet.found(patchi))
159  {
160  forAll(bfld, i)
161  {
162  const scalar dist = cellInfo[faceCells[i]].distSqr();
163  bfld[i] = 1.0/sqrt(dist);
164  }
165  }
166  else
167  {
168  const label start = bfld.patch().start();
169 
170  forAll(bfld, i)
171  {
172  const scalar dist = faceInfo[start+i].distSqr();
173  bfld[i] = 1.0/sqrt(dist);
174  }
175  }
176  }
177 
178  return tfaceDiffusivity;
179 }
180 
181 
182 // ************************************************************************* //
Foam::surfaceFields.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:434
inverseFaceDistanceDiffusivity(const fvMesh &mesh, Istream &mdData)
Construct for the given fvMesh and data Istream.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:150
label nInternalFaces() const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual tmp< surfaceScalarField > operator()() const
Return diffusivity field.
label findPatchID(const word &patchName) const
Find patch index given a name.
const dimensionSet dimless
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
Definition: cellInfo.H:63
Pre-declare related SubField type.
Definition: Field.H:60
Macros for easy insertion into run-time selection tables.
const List< Type > & allFaceInfo() const
Get allFaceInfo.
Definition: MeshWave.H:116
dynamicFvMesh & mesh
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:99
FaceCellWave plus data.
Definition: MeshWave.H:56
word timeName
Definition: getTimeIndex.H:3
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyBoundaryMesh.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Abstract base class for cell-centre mesh motion diffusivity.
defineTypeNameAndDebug(combustionModel, 0)
Holds information regarding nearest wall point. Used in wall distance calculation.
Definition: wallPoint.H:63
const List< Type > & allCellInfo() const
Get allCellInfo.
Definition: MeshWave.H:122
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
const fvPatch & patch() const
Return patch.
void setSize(const label)
Reset size of List.
Definition: List.C:281
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:309
A class for managing temporary objects.
Definition: PtrList.H:53
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Namespace for OpenFOAM.
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:297