2016-03-18 11:44:28 +00:00
|
|
|
{
|
2017-01-09 18:46:51 +00:00
|
|
|
// Update boundary velocity for consistency with the flux
|
|
|
|
mrfZones.correctBoundaryVelocity(U);
|
|
|
|
|
2015-04-27 14:34:02 +00:00
|
|
|
// Momentum equation
|
2016-03-18 11:44:28 +00:00
|
|
|
fvVectorMatrix UEqn
|
2015-04-27 14:34:02 +00:00
|
|
|
(
|
2016-03-18 11:44:28 +00:00
|
|
|
fvm::div(phi, U)
|
2016-06-06 13:59:41 +00:00
|
|
|
+ turbulence->divDevReff()
|
2015-04-27 14:34:02 +00:00
|
|
|
);
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
// Add MRF and porous sources implicitly. HJ, 18/Nov/2017
|
2016-03-18 11:44:28 +00:00
|
|
|
tmp<volTensorField> tTU;
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
if (addMRF || addPorosity)
|
2016-03-18 11:44:28 +00:00
|
|
|
{
|
|
|
|
tTU = tmp<volTensorField>
|
|
|
|
(
|
|
|
|
new volTensorField
|
|
|
|
(
|
|
|
|
IOobject
|
|
|
|
(
|
|
|
|
"TU",
|
|
|
|
runTime.timeName(),
|
|
|
|
mesh,
|
|
|
|
IOobject::NO_READ,
|
|
|
|
IOobject::NO_WRITE
|
|
|
|
),
|
|
|
|
mesh,
|
|
|
|
dimensionedTensor("zero", dimless/dimTime, tensor::zero)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
volTensorField& TU = tTU();
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
// Add implicit MRF source as a Hodge dual of the rotational velocity
|
|
|
|
TU += *mrfZones.omega();
|
|
|
|
|
|
|
|
// Add implicit resistance
|
2016-03-18 11:44:28 +00:00
|
|
|
pZones.addResistance(UEqn, TU);
|
|
|
|
|
|
|
|
trTU = inv(TU + tensor(I)*UEqn.A());
|
|
|
|
trTU().rename("rAU");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trAU = 1.0/UEqn.A();
|
|
|
|
trAU().rename("rAU");
|
|
|
|
}
|
|
|
|
|
2017-02-06 11:45:17 +00:00
|
|
|
// Under-relax momentum. Note this will destroy the H and A
|
2016-03-18 11:44:28 +00:00
|
|
|
UEqn.relax();
|
|
|
|
|
|
|
|
// Insert momentum equation
|
|
|
|
UpEqn.insertEquation(0, UEqn);
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
if (addMRF || addPorosity)
|
2016-03-18 11:44:28 +00:00
|
|
|
{
|
|
|
|
// Manually over-ride the 3x3 block to handle the off-diagonal
|
|
|
|
// part of the Ap coefficient
|
|
|
|
const tensorField& TUIn = tTU().internalField();
|
|
|
|
|
|
|
|
CoeffField<vector4>::squareTypeField& DD = UpEqn.diag().asSquare();
|
|
|
|
|
|
|
|
const scalarField& V = mesh.V().field();
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
// Note: insertion should only happen in MRF and porous cell zones
|
2016-03-18 11:44:28 +00:00
|
|
|
// HJ, 14/Mar/2016
|
2017-01-09 18:46:51 +00:00
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
// Warning. Possible problem with a zone which is both MRF and porous
|
|
|
|
// The solution is to do the loop below everywhere
|
|
|
|
// Currently only inserting zones for efficiency. HJ, 18/Nov/2017
|
2017-01-09 18:46:51 +00:00
|
|
|
register label cellI;
|
|
|
|
|
2017-11-18 12:21:56 +00:00
|
|
|
forAll (mrfZones, mrfZoneI)
|
|
|
|
{
|
|
|
|
const labelList& curZoneCells = mrfZones[mrfZoneI].zone();
|
|
|
|
|
|
|
|
// Loop over all cells in the zone
|
|
|
|
forAll (curZoneCells, zcI)
|
|
|
|
{
|
|
|
|
cellI = curZoneCells[zcI];
|
|
|
|
|
|
|
|
const scalar& cellV = V[cellI];
|
|
|
|
|
|
|
|
const tensor& cellTU = TUIn[cellI];
|
|
|
|
|
|
|
|
CoeffField<vector4>::squareType& cellDD = DD[cellI];
|
|
|
|
|
|
|
|
cellDD(0, 0) += cellV*cellTU.xx();
|
|
|
|
cellDD(0, 1) += cellV*cellTU.xy();
|
|
|
|
cellDD(0, 2) += cellV*cellTU.xz();
|
|
|
|
|
|
|
|
cellDD(1, 0) += cellV*cellTU.yx();
|
|
|
|
cellDD(1, 1) += cellV*cellTU.yy();
|
|
|
|
cellDD(2, 2) += cellV*cellTU.yz();
|
|
|
|
|
|
|
|
cellDD(2, 0) += cellV*cellTU.zx();
|
|
|
|
cellDD(2, 1) += cellV*cellTU.zy();
|
|
|
|
cellDD(2, 2) += cellV*cellTU.zz();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
forAll (pZones, pZoneI)
|
2016-03-18 11:44:28 +00:00
|
|
|
{
|
2017-01-09 18:46:51 +00:00
|
|
|
const labelList& curZoneCells = pZones[pZoneI].zone();
|
|
|
|
|
|
|
|
// Loop over all cells in the zone
|
|
|
|
forAll (curZoneCells, zcI)
|
|
|
|
{
|
|
|
|
cellI = curZoneCells[zcI];
|
|
|
|
|
|
|
|
const scalar& cellV = V[cellI];
|
2016-03-18 11:44:28 +00:00
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
const tensor& cellTU = TUIn[cellI];
|
2016-03-18 11:44:28 +00:00
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
CoeffField<vector4>::squareType& cellDD = DD[cellI];
|
2016-03-18 11:44:28 +00:00
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
cellDD(0, 0) += cellV*cellTU.xx();
|
|
|
|
cellDD(0, 1) += cellV*cellTU.xy();
|
|
|
|
cellDD(0, 2) += cellV*cellTU.xz();
|
2015-04-27 14:34:02 +00:00
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
cellDD(1, 0) += cellV*cellTU.yx();
|
|
|
|
cellDD(1, 1) += cellV*cellTU.yy();
|
|
|
|
cellDD(2, 2) += cellV*cellTU.yz();
|
2015-04-27 14:34:02 +00:00
|
|
|
|
2017-01-09 18:46:51 +00:00
|
|
|
cellDD(2, 0) += cellV*cellTU.zx();
|
|
|
|
cellDD(2, 1) += cellV*cellTU.zy();
|
|
|
|
cellDD(2, 2) += cellV*cellTU.zz();
|
|
|
|
}
|
2016-03-18 11:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|