FreeFOAM The Cross-Platform CFD Toolkit
correctPhi.H
Go to the documentation of this file.
1 {
2  if (mesh.changing())
3  {
4  forAll(U.boundaryField(), patchi)
5  {
6  if (U.boundaryField()[patchi].fixesValue())
7  {
8  U.boundaryField()[patchi].initEvaluate();
9  }
10  }
11 
12  forAll(U.boundaryField(), patchi)
13  {
14  if (U.boundaryField()[patchi].fixesValue())
15  {
16  U.boundaryField()[patchi].evaluate();
17 
18  phi.boundaryField()[patchi] =
19  U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi];
20  }
21  }
22  }
23 
25  (
26  p.boundaryField().size(),
27  zeroGradientFvPatchScalarField::typeName
28  );
29 
30  for (label i=0; i<p.boundaryField().size(); i++)
31  {
32  if(p.boundaryField()[i].fixesValue())
33  {
34  pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
35  }
36  }
37 
38  volScalarField pcorr
39  (
40  IOobject
41  (
42  "pcorr",
43  runTime.timeName(),
44  mesh,
45  IOobject::NO_READ,
46  IOobject::NO_WRITE
47  ),
48  mesh,
49  dimensionedScalar("pcorr", p.dimensions(), 0.0),
51  );
52 
53  for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
54  {
55  fvScalarMatrix pcorrEqn
56  (
57  fvm::laplacian(rAU, pcorr) == fvc::div(phi)
58  );
59 
60  pcorrEqn.setReference(pRefCell, pRefValue);
61  pcorrEqn.solve();
62 
63  if (nonOrth == nNonOrthCorr)
64  {
65  phi -= pcorrEqn.flux();
66  }
67  }
68 }
69