correctPhi.H
Go to the documentation of this file.
1 if (mesh.changing())
2 {
3  volVectorField::Boundary& bfld = U.boundaryFieldRef();
4  forAll(bfld, patchi)
5  {
6  if (bfld[patchi].fixesValue())
7  {
8  bfld[patchi].initEvaluate();
9  }
10  }
11 
12  surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef();
13  forAll(bfld, patchi)
14  {
15  if (bfld[patchi].fixesValue())
16  {
17  bfld[patchi].evaluate();
18 
19  phiBfld[patchi] = bfld[patchi] & mesh.Sf().boundaryField()[patchi];
20  }
21  }
22 }
23  // Initialize BCs list for pcorr to zero-gradient
25  (
26  p.boundaryField().size(),
28  );
29 
30  // Set BCs of pcorr to fixed-value for patches at which p is fixed
31  forAll(p.boundaryField(), patchi)
32  {
33  if (p.boundaryField()[patchi].fixesValue())
34  {
35  pcorrTypes[patchi] = fixedValueFvPatchScalarField::typeName;
36  }
37  }
38 
40  (
41  IOobject
42  (
43  "pcorr",
44  runTime.timeName(),
45  mesh,
46  IOobject::NO_READ,
47  IOobject::NO_WRITE
48  ),
49  mesh,
50  dimensionedScalar(p.dimensions(), Zero),
52  );
53 
54 {
55  dimensionedScalar rAUf("rAUf", dimTime, 1.0);
56 
57  const cellCellStencilObject& overlap = Stencil::New(mesh);
58  const labelList& cellTypes = overlap.cellTypes();
59  const labelIOList& zoneIDs = overlap.zoneID();
60 
61  while (pimple.correctNonOrthogonal())
62  {
63  label nZones = gMax(zoneIDs)+1;
64 
65  //label refCellI2 = -1;
66  labelList refCells(nZones, -1);
67  labelList refZones(nZones, -1);
68 
69  forAll(zoneIDs, cellI)
70  {
71  label zoneId = zoneIDs[cellI];
72  if
73  (
74  refCells[zoneId] == -1
75  && cellTypes[cellI] == cellCellStencil::CALCULATED
76  && refZones[zoneId] == -1
77  )
78  {
79  refCells[zoneId] = cellI;
80  refZones[zoneId] = zoneId;
81  }
82  }
83 
84  fvScalarMatrix pcorrEqn
85  (
87  );
88 
89 
90  // Only set reference for cells that are CALCULATED
91  {
92  DynamicList<label> validCells(refCells.size());
93  forAll(refCells, zoneId)
94  {
95  if (refCells[zoneId] != -1)
96  {
97  validCells.push_back(refCells[zoneId]);
98  }
99  }
100 
101  pcorrEqn.setReferences
102  (
103  validCells,
104  scalar(0),
105  true
106  );
107  }
108 
109  const dictionary& d = mesh.solver
110  (
111  pcorr.select
112  (
113  pimple.finalInnerIter()
114  )
115  );
116  //Bypass virtual layer
117  mesh.fvMesh::solve(pcorrEqn, d);
118 
119  if (pimple.finalNonOrthogonalIter())
120  {
121  phi -= pcorrEqn.flux();
122  }
123  }
124 }
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:37
const labelIOList & zoneIDs
Definition: correctPhi.H:59
volScalarField pcorr(IOobject("pcorr", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(p.dimensions(), Zero), pcorrTypes)
wordList pcorrTypes(p.boundaryField().size(), fvPatchFieldBase::zeroGradientType())
const word zeroGradientType
A zeroGradient patch field type.
const labelList & cellTypes
Definition: correctPhi.H:58
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:43
engineTime & runTime
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
forAll(p.boundaryField(), patchi)
Definition: correctPhi.H:36
dimensionedScalar rAUf("rAUf", dimTime, 1.0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
IOList< label > labelIOList
IO for a List of label.
Definition: labelIOList.H:32
dynamicFvMesh & mesh
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:40
const cellCellStencilObject & overlap
Definition: correctPhi.H:57
Type gMax(const FieldField< Field, Type > &f)
pimpleControl & pimple
List< word > wordList
List of word.
Definition: fileName.H:59
U
Definition: pEqn.H:72
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
List< label > labelList
A List of labels.
Definition: List.H:62
volScalarField & p
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127