-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUEqn.H
69 lines (53 loc) · 1.78 KB
/
UEqn.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Construct the Momentum equation
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(U)
+ turbulence->divDevSigma(U)
==
fvModels.source(U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn.relax();
// Include the porous media resistance and solve the momentum equation
// either implicit in the tensorial resistance or transport using by
// including the spherical part of the resistance in the momentum diagonal
tmp<volScalarField> trAU;
tmp<volTensorField> trTU;
if (pressureImplicitPorosity)
{
tmp<volTensorField> tTU = tensor(I)*UEqn.A();
//pZones.addResistance(UEqn, tTU.ref());
volTensorField & AU = tTU.ref();
AU = AU + mu*D + (rho*mag(U))*F/2.0;
AU.correctBoundaryConditions();
trTU = inv(tTU());
trTU.ref().rename("rAU");
fvConstraints.constrain(UEqn);
volVectorField gradp(fvc::grad(p));
for (int UCorr=0; UCorr<nUCorr; UCorr++)
{
U = trTU() & (UEqn.H() - gradp);
}
U.correctBoundaryConditions();
fvConstraints.constrain(U);
}
else
{
Info << "Explicit" << endl;
//pZones.addResistance(UEqn);
//const volVectorField& U = UEqn.psi();
const scalarField& V = mesh.V();
scalarField& Udiag = UEqn.diag();
vectorField& Usource = UEqn.source();
const tensorField Cd = mu*D + (rho*mag(U))*F/2.0;
const scalarField isoCd = tr(Cd);
Udiag += V*isoCd;
Usource -= V*((Cd - I*isoCd) & U);
fvConstraints.constrain(UEqn);
solve(UEqn == -fvc::grad(p));
fvConstraints.constrain(U);
trAU = 1.0/UEqn.A();
trAU.ref().rename("rAU");
}