inverseFaceDistanceDiffusivity.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) 2011-2016 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 
28 #include "HashSet.H"
29 #include "wallPoint.H"
30 #include "MeshWave.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(inverseFaceDistanceDiffusivity, 0);
37 
39  (
40  motionDiffusivity,
41  inverseFaceDistanceDiffusivity,
42  Istream
43  );
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 Foam::inverseFaceDistanceDiffusivity::inverseFaceDistanceDiffusivity
50 (
51  const fvMesh& mesh,
52  Istream& mdData
53 )
54 :
55  uniformDiffusivity(mesh, mdData),
56  patchNames_(mdData)
57 {
58  correct();
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63 
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 {
72  const polyBoundaryMesh& bdry = mesh().boundaryMesh();
73 
74  labelHashSet patchSet(bdry.size());
75 
76  label nPatchFaces = 0;
77 
78  forAll(patchNames_, i)
79  {
80  const label pID = bdry.findPatchID(patchNames_[i]);
81 
82  if (pID > -1)
83  {
84  patchSet.insert(pID);
85  nPatchFaces += bdry[pID].size();
86  }
87  }
88 
89  List<wallPoint> faceDist(nPatchFaces);
90  labelList changedFaces(nPatchFaces);
91 
92  nPatchFaces = 0;
93 
94  forAllConstIter(labelHashSet, patchSet, iter)
95  {
96  const polyPatch& patch = bdry[iter.key()];
97 
98  const vectorField::subField fc(patch.faceCentres());
99 
100  forAll(fc, patchFacei)
101  {
102  changedFaces[nPatchFaces] = patch.start() + patchFacei;
103 
104  faceDist[nPatchFaces] = wallPoint(fc[patchFacei], 0);
105 
106  nPatchFaces++;
107  }
108  }
109  faceDist.setSize(nPatchFaces);
110  changedFaces.setSize(nPatchFaces);
111 
112  MeshWave<wallPoint> waveInfo
113  (
114  mesh(),
115  changedFaces,
116  faceDist,
117  mesh().globalData().nTotalCells()+1 // max iterations
118  );
119 
120  const List<wallPoint>& faceInfo = waveInfo.allFaceInfo();
121  const List<wallPoint>& cellInfo = waveInfo.allCellInfo();
122 
123  for (label facei=0; facei<mesh().nInternalFaces(); facei++)
124  {
125  scalar dist = faceInfo[facei].distSqr();
126 
127  faceDiffusivity_[facei] = 1.0/sqrt(dist);
128  }
129 
130  surfaceScalarField::Boundary& faceDiffusivityBf =
131  faceDiffusivity_.boundaryFieldRef();
132 
133  forAll(faceDiffusivityBf, patchi)
134  {
135  fvsPatchScalarField& bfld = faceDiffusivityBf[patchi];
136 
137  const labelUList& faceCells = bfld.patch().faceCells();
138 
139  if (patchSet.found(patchi))
140  {
141  forAll(bfld, i)
142  {
143  scalar dist = cellInfo[faceCells[i]].distSqr();
144  bfld[i] = 1.0/sqrt(dist);
145  }
146  }
147  else
148  {
149  const label start = bfld.patch().start();
150 
151  forAll(bfld, i)
152  {
153  scalar dist = faceInfo[start+i].distSqr();
154  bfld[i] = 1.0/sqrt(dist);
155  }
156  }
157  }
158 }
159 
160 
161 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:424
Uniform uniform finite volume mesh motion diffusivity.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
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:60
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)
label findPatchID(const word &patchName) const
Find patch index given a name.
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:61
Macros for easy insertion into run-time selection tables.
const List< Type > & allFaceInfo() const
Get allFaceInfo.
Definition: MeshWave.H:119
dynamicFvMesh & mesh
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:93
FaceCellWave plus data.
Definition: MeshWave.H:56
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
virtual void correct()
Correct the motion diffusivity.
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:61
Foam::polyBoundaryMesh.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
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/ubuntu/OpenFOAM-5.0/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:72
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:125
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
label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:155
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:300
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
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:284