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(),
27  zeroGradientFvPatchScalarField::typeName
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.append(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 }
nZones
label nZones
Definition: interpolatedFaces.H:24
rAUf
dimensionedScalar rAUf("rAUf", dimTime, 1.0)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
runTime
engineTime & runTime
Definition: createEngineTime.H:13
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::labelIOList
IOList< label > labelIOList
Label container classes.
Definition: labelIOList.H:44
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
zoneIDs
const labelIOList & zoneIDs
Definition: correctPhi.H:59
pcorr
volScalarField pcorr(IOobject("pcorr", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(p.dimensions(), Zero), pcorrTypes)
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
pimple
pimpleControl & pimple
Definition: setRegionFluidFields.H:56
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::fvScalarMatrix
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:44
pcorrTypes
wordList pcorrTypes(p.boundaryField().size(), zeroGradientFvPatchScalarField::typeName)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
U
U
Definition: pEqn.H:72
overlap
const cellCellStencilObject & overlap
Definition: correctPhi.H:57
cellTypes
const labelList & cellTypes
Definition: correctPhi.H:58
Foam::fac::laplacian
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:47
forAll
forAll(p.boundaryField(), patchi)
Definition: correctPhi.H:36
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592