inversePointDistanceDiffusivity.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "HashSet.H"
32 #include "pointEdgePoint.H"
33 #include "PointEdgeWave.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
40 
42  (
43  motionDiffusivity,
44  inversePointDistanceDiffusivity,
45  Istream
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 Foam::inversePointDistanceDiffusivity::inversePointDistanceDiffusivity
53 (
54  const fvMesh& mesh,
55  Istream& mdData
56 )
57 :
58  uniformDiffusivity(mesh, mdData),
59  patchNames_(mdData)
60 {
61  correct();
62 }
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 {
69  const polyBoundaryMesh& bdry = mesh().boundaryMesh();
70 
71  labelHashSet patchSet(bdry.patchSet(patchNames_));
72 
73  label nPatchEdges = 0;
74 
75  for (const label patchi : patchSet)
76  {
77  nPatchEdges += bdry[patchi].nEdges();
78  }
79 
80  // Distance to wall on points and edges.
81  List<pointEdgePoint> pointWallDist(mesh().nPoints());
82  List<pointEdgePoint> edgeWallDist(mesh().nEdges());
83 
84  int dummyTrackData = 0;
85 
86 
87  {
88  // Seeds
89  List<pointEdgePoint> seedInfo(nPatchEdges);
90  labelList seedPoints(nPatchEdges);
91 
92  nPatchEdges = 0;
93 
94  for (const label patchi : patchSet)
95  {
96  const polyPatch& patch = bdry[patchi];
97 
98  const labelList& meshPoints = patch.meshPoints();
99 
100  for (const label pointi : meshPoints)
101  {
102  if (!pointWallDist[pointi].valid(dummyTrackData))
103  {
104  // Not yet seeded
105  seedInfo[nPatchEdges] = pointEdgePoint
106  (
107  mesh().points()[pointi],
108  0.0
109  );
110  seedPoints[nPatchEdges] = pointi;
111  pointWallDist[pointi] = seedInfo[nPatchEdges];
112 
113  nPatchEdges++;
114  }
115  }
116  }
117  seedInfo.setSize(nPatchEdges);
118  seedPoints.setSize(nPatchEdges);
119 
120  // Do calculations
121  PointEdgeWave<pointEdgePoint> waveInfo
122  (
123  mesh(),
124  seedPoints,
125  seedInfo,
126 
127  pointWallDist,
128  edgeWallDist,
129  mesh().globalData().nTotalPoints(),// max iterations
130  dummyTrackData
131  );
132  }
133 
134 
135  for (label facei=0; facei<mesh().nInternalFaces(); ++facei)
136  {
137  const face& f = mesh().faces()[facei];
138 
139  scalar dist = 0;
140 
141  forAll(f, fp)
142  {
143  dist += sqrt(pointWallDist[f[fp]].distSqr());
144  }
145  dist /= f.size();
146 
147  faceDiffusivity_[facei] = 1.0/dist;
148  }
149 
150 
151  surfaceScalarField::Boundary& faceDiffusivityBf =
153 
154  forAll(faceDiffusivityBf, patchi)
155  {
156  fvsPatchScalarField& bfld = faceDiffusivityBf[patchi];
157 
158  if (patchSet.found(patchi))
159  {
160  const labelUList& faceCells = bfld.patch().faceCells();
161 
162  forAll(bfld, i)
163  {
164  const cell& ownFaces = mesh().cells()[faceCells[i]];
165 
166  labelHashSet cPoints(4*ownFaces.size());
167 
168  scalar dist = 0;
169 
170  forAll(ownFaces, ownFacei)
171  {
172  const face& f = mesh().faces()[ownFaces[ownFacei]];
173 
174  forAll(f, fp)
175  {
176  if (cPoints.insert(f[fp]))
177  {
178  dist += sqrt(pointWallDist[f[fp]].distSqr());
179  }
180  }
181  }
182  dist /= cPoints.size();
183 
184  bfld[i] = 1.0/dist;
185  }
186  }
187  else
188  {
189  const label start = bfld.patch().start();
190 
191  forAll(bfld, i)
192  {
193  const face& f = mesh().faces()[start+i];
194 
195  scalar dist = 0;
196 
197  forAll(f, fp)
198  {
199  dist += sqrt(pointWallDist[f[fp]].distSqr());
200  }
201  dist /= f.size();
202 
203  bfld[i] = 1.0/dist;
204  }
205  }
206  }
207 }
208 
209 
210 // ************************************************************************* //
fvsPatchField< scalar > fvsPatchScalarField
Uniform uniform finite volume mesh motion diffusivity.
labelHashSet patchSet(const UList< wordRe > &select, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual void correct()
Correct the motion diffusivity.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const cellList & cells() const
GeometricBoundaryField< scalar, fvsPatchField, surfaceMesh > Boundary
Type of boundary fields.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
dynamicFvMesh & mesh
const pointField & points
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
label nPoints
label nInternalFaces() const noexcept
Number of internal faces.
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1103
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2312/OpenFOAM-v2312/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:63
defineTypeNameAndDebug(combustionModel, 0)
labelList f(nPoints)
const fvMesh & mesh() const
Return reference to the mesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const std::string patch
OpenFOAM patch number as a std::string.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
List< label > labelList
A List of labels.
Definition: List.H:62
surfaceScalarField faceDiffusivity_
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)