inversePointDistanceDiffusivity.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 "pointEdgePoint.H"
30 #include "PointEdgeWave.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
38 
40  (
41  motionDiffusivity,
42  inversePointDistanceDiffusivity,
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 Functions * * * * * * * * * * * * * //
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  const labelHashSet patchSet(bdry.patchSet(patchNames_));
94 
95  label nPatchEdges = 0;
96 
97  forAllConstIter(labelHashSet, patchSet, iter)
98  {
99  nPatchEdges += bdry[iter.key()].nEdges();
100  }
101 
102  // Distance to wall on points and edges.
103  List<pointEdgePoint> pointWallDist(mesh().nPoints());
104  List<pointEdgePoint> edgeWallDist(mesh().nEdges());
105 
106  int dummyTrackData = 0;
107 
108 
109  {
110  // Seeds
111  List<pointEdgePoint> seedInfo(nPatchEdges);
112  labelList seedPoints(nPatchEdges);
113 
114  nPatchEdges = 0;
115 
116  forAllConstIter(labelHashSet, patchSet, iter)
117  {
118  const polyPatch& patch = bdry[iter.key()];
119 
120  const labelList& meshPoints = patch.meshPoints();
121 
122  forAll(meshPoints, i)
123  {
124  const label pointi = meshPoints[i];
125 
126  if (!pointWallDist[pointi].valid(dummyTrackData))
127  {
128  // Not yet seeded
129  seedInfo[nPatchEdges] = pointEdgePoint
130  (
131  mesh().points()[pointi],
132  0.0
133  );
134  seedPoints[nPatchEdges] = pointi;
135  pointWallDist[pointi] = seedInfo[nPatchEdges];
136 
137  nPatchEdges++;
138  }
139  }
140  }
141  seedInfo.setSize(nPatchEdges);
142  seedPoints.setSize(nPatchEdges);
143 
144  // Do calculations
146  (
147  mesh(),
148  seedPoints,
149  seedInfo,
150 
151  pointWallDist,
152  edgeWallDist,
153  mesh().globalData().nTotalPoints(),// max iterations
154  dummyTrackData
155  );
156  }
157 
158 
159  for (label facei=0; facei<mesh().nInternalFaces(); facei++)
160  {
161  const face& f = mesh().faces()[facei];
162 
163  scalar dist = 0;
164 
165  forAll(f, fp)
166  {
167  dist += sqrt(pointWallDist[f[fp]].distSqr());
168  }
169  dist /= f.size();
170 
171  faceDiffusivity[facei] = 1.0/dist;
172  }
173 
174 
175  surfaceScalarField::Boundary& faceDiffusivityBf =
176  faceDiffusivity.boundaryFieldRef();
177 
178  forAll(faceDiffusivityBf, patchi)
179  {
180  fvsPatchScalarField& bfld = faceDiffusivityBf[patchi];
181 
182  if (patchSet.found(patchi))
183  {
184  const labelUList& faceCells = bfld.patch().faceCells();
185 
186  forAll(bfld, i)
187  {
188  const cell& ownFaces = mesh().cells()[faceCells[i]];
189 
190  labelHashSet cPoints(4*ownFaces.size());
191 
192  scalar dist = 0;
193 
194  forAll(ownFaces, ownFacei)
195  {
196  const face& f = mesh().faces()[ownFaces[ownFacei]];
197 
198  forAll(f, fp)
199  {
200  if (cPoints.insert(f[fp]))
201  {
202  dist += sqrt(pointWallDist[f[fp]].distSqr());
203  }
204  }
205  }
206  dist /= cPoints.size();
207 
208  bfld[i] = 1.0/dist;
209  }
210  }
211  else
212  {
213  const label start = bfld.patch().start();
214 
215  forAll(bfld, i)
216  {
217  const face& f = mesh().faces()[start+i];
218 
219  scalar dist = 0;
220 
221  forAll(f, fp)
222  {
223  dist += sqrt(pointWallDist[f[fp]].distSqr());
224  }
225  dist /= f.size();
226 
227  bfld[i] = 1.0/dist;
228  }
229  }
230  }
231 
232  return tfaceDiffusivity;
233 }
234 
235 
236 // ************************************************************************* //
Foam::surfaceFields.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:434
#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
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
dimensionedScalar sqrt(const dimensionedScalar &ds)
const cellList & cells() const
const dimensionSet dimless
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
Macros for easy insertion into run-time selection tables.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
dynamicFvMesh & mesh
const pointField & points
label nPoints
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:99
word timeName
Definition: getTimeIndex.H:3
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1156
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
virtual tmp< surfaceScalarField > operator()() const
Return diffusivity field.
Foam::polyBoundaryMesh.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Abstract base class for cell-centre mesh motion diffusivity.
defineTypeNameAndDebug(combustionModel, 0)
labelList f(nPoints)
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.
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
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
inversePointDistanceDiffusivity(const fvMesh &mesh, Istream &mdData)
Construct for the given fvMesh and data Istream.
Wave propagation of information through grid. Every iteration information goes through one layer of e...
Definition: PointEdgeWave.H:85
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.