alphaEqn.H
Go to the documentation of this file.
1 {
2  word alphaScheme("div(phi,alpha)");
3  word alpharScheme("div(phirb,alpha)");
4 
5  if (MULESCorr)
6  {
7  fvScalarMatrix alpha1Eqn
8  (
9  fv::EulerDdtScheme<scalar>(mesh).fvmDdt(alpha1)
10  + fv::gaussConvectionScheme<scalar>
11  (
12  mesh,
13  phi,
14  upwind<scalar>(mesh, phi)
15  ).fvmDiv(phi, alpha1)
16  );
17 
18  solve(alpha1Eqn);
19 
20  Info<< "Phase-1 volume fraction = "
21  << alpha1.weightedAverage(mesh.Vsc()).value()
22  << " Min(" << alpha1.name() << ") = " << min(alpha1).value()
23  << " Max(" << alpha1.name() << ") = " << max(alpha1).value()
24  << endl;
25 
26  tmp<surfaceScalarField> talphaPhiUD(alpha1Eqn.flux());
27  alphaPhi = talphaPhiUD();
28 
29  if (alphaApplyPrevCorr && talphaPhiCorr0.valid())
30  {
31  Info<< "Applying the previous iteration correction flux" << endl;
32 
34  (
35  geometricOneField(),
36  alpha1,
37  alphaPhi,
38  talphaPhiCorr0.ref(),
39  UniformField<scalar>(mixture.alphaMax()),
40  zeroField()
41  );
42 
44  }
45 
46  // Cache the upwind-flux
47  talphaPhiCorr0 = talphaPhiUD;
48  }
49 
50  for (int aCorr=0; aCorr<nAlphaCorr; aCorr++)
51  {
52  tmp<surfaceScalarField> talphaPhiUn
53  (
54  fvc::flux
55  (
56  phi,
57  alpha1,
58  alphaScheme
59  )
60  + fvc::flux
61  (
62  phir,
63  alpha1,
65  )
66  );
67 
68  if (MULESCorr)
69  {
70  tmp<surfaceScalarField> talphaPhiCorr(talphaPhiUn() - alphaPhi);
71  volScalarField alpha10("alpha10", alpha1);
72 
74  (
75  geometricOneField(),
76  alpha1,
77  talphaPhiUn(),
78  talphaPhiCorr.ref(),
79  UniformField<scalar>(mixture.alphaMax()),
80  zeroField()
81  );
82 
83  // Under-relax the correction for all but the 1st corrector
84  if (aCorr == 0)
85  {
86  alphaPhi += talphaPhiCorr();
87  }
88  else
89  {
90  alpha1 = 0.5*alpha1 + 0.5*alpha10;
91  alphaPhi += 0.5*talphaPhiCorr();
92  }
93  }
94  else
95  {
96  alphaPhi = talphaPhiUn;
97 
99  (
100  geometricOneField(),
101  alpha1,
102  phi,
103  alphaPhi,
104  UniformField<scalar>(mixture.alphaMax()),
105  zeroField()
106  );
107  }
108  }
109 
111  {
113  }
114 
115  alpha2 = 1.0 - alpha1;
116 
117  Info<< "Phase-1 volume fraction = "
118  << alpha1.weightedAverage(mesh.Vsc()).value()
119  << " Min(" << alpha1.name() << ") = " << min(alpha1).value()
120  << " Max(" << alpha1.name() << ") = " << max(alpha1).value()
121  << endl;
122 }
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Foam::MULES::explicitSolve
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su)
Definition: MULESTemplates.C:41
talphaPhiCorr0
tmp< surfaceScalarField > talphaPhiCorr0
Definition: createFields.H:132
Foam::vtk::Tools::zeroField
vtkSmartPointer< vtkFloatArray > zeroField(const word &name, const label size)
Create named field initialized to zero.
Definition: foamVtkToolsTemplates.C:327
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
alpha1
const volScalarField & alpha1
Definition: setRegionFluidFields.H:8
alpharScheme
word alpharScheme("div(phirb,alpha)")
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
solve
CEqn solve()
nAlphaCorr
label nAlphaCorr(alphaControls.get< label >("nAlphaCorr"))
Foam::fvScalarMatrix
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:44
alphaPhi
surfaceScalarField alphaPhi(phi.name()+alpha1.name(), fvc::flux(phi, alpha1, alphaScheme))
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
MULESCorr
bool MULESCorr(alphaControls.getOrDefault("MULESCorr", false))
alpha2
alpha2
Definition: alphaEqn.H:9
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
phir
surfaceScalarField phir(IOobject("phir", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mixture.cAlpha() *mag(phi/mesh.magSf()) *mixture.nHatf())
alphaApplyPrevCorr
bool alphaApplyPrevCorr(alphaControls.getOrDefault("alphaApplyPrevCorr", false))
alpha10
volScalarField alpha10("alpha10", alpha1)
mixture
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n"<< endl;autoPtr< temperaturePhaseChangeTwoPhaseMixture > mixture
Definition: createFields.H:39
correct
mixture correct()