31 fvSource_(const_cast<volVectorField&>(
32 mesh_.thisDb().lookupObject<volVectorField>(
"fvSource"))),
33 fvSourceEnergy_(const_cast<volScalarField&>(
34 mesh_.thisDb().lookupObject<volScalarField>(
"fvSourceEnergy"))),
35 thermo_(const_cast<fluidThermo&>(
36 mesh_.thisDb().lookupObject<fluidThermo>(
"thermophysicalProperties"))),
38 rho_(const_cast<volScalarField&>(
39 mesh_.thisDb().lookupObject<volScalarField>(
"rho"))),
40 alphat_(const_cast<volScalarField&>(
41 mesh_.thisDb().lookupObject<volScalarField>(
"alphat"))),
42 psi_(const_cast<volScalarField&>(
43 mesh_.thisDb().lookupObject<volScalarField>(
"thermo:psi"))),
44 dpdt_(const_cast<volScalarField&>(
45 mesh_.thisDb().lookupObject<volScalarField>(
"dpdt"))),
46 K_(const_cast<volScalarField&>(
47 mesh_.thisDb().lookupObject<volScalarField>(
"K"))),
50 pimple_(const_cast<fvMesh&>(
mesh))
55 if (
allOptions.subDict(
"fvSource").toc().size() != 0)
61 const IOdictionary& thermoDict =
mesh.thisDb().lookupObject<IOdictionary>(
"thermophysicalProperties");
62 dictionary mixSubDict = thermoDict.subDict(
"mixture");
63 dictionary specieSubDict = mixSubDict.subDict(
"specie");
64 molWeight_ = specieSubDict.getScalar(
"molWeight");
65 dictionary thermodynamicsSubDict = mixSubDict.subDict(
"thermodynamics");
66 Cp_ = thermodynamicsSubDict.getScalar(
"Cp");
71 Info <<
"Cp " <<
Cp_ << endl;
106 label isPC = options.getLabel(
"isPC");
108 word divUScheme =
"div(phi,U)";
109 word divHEScheme =
"div(phi,e)";
111 if (
he_.name() ==
"h")
113 divHEScheme =
"div(phi,h)";
118 divUScheme =
"div(pc)";
119 divHEScheme =
"div(pc)";
133 tmp<fvVectorMatrix>
tUEqn(
135 + fvm::div(
phi_,
U_, divUScheme)
149 K_ = 0.5 * magSqr(
U_);
154 + fvm::div(
phi_,
he_, divHEScheme)
159 fvc::absolute(
phi_ / fvc::interpolate(
rho_),
U_),
173 volScalarField
rAU(1.0 /
UEqn.A());
174 surfaceScalarField
rhorAUf(
"rhorAUf", fvc::interpolate(
rho_ *
rAU));
179 autoPtr<volVectorField>
HbyAPtr =
nullptr;
187 HbyAPtr.reset(
new volVectorField(
"HbyA",
U_));
194 surfaceScalarField
phiHbyA(
"phiHbyA", fvc::interpolate(
rho_) * fvc::flux(
HbyA));
231 scalar RR = Foam::constant::thermodynamic::RR;
237 dimensionSet(0, 2, -2, -1, 0, 0, 0),
243 psi_.oldTime() = 1.0 /
T_.oldTime() / R;
244 psi_.oldTime().oldTime() = 1.0 /
T_.oldTime().oldTime() / R;
249 rho_.oldTime() =
psi_.oldTime() *
p_.oldTime();
250 rho_.oldTime().oldTime() =
psi_.oldTime().oldTime() *
p_.oldTime().oldTime();
262 dimensionedScalar Cp(
264 dimensionSet(0, 2, -2, -1, 0, 0, 0),
277 if (
he_.name() ==
"e")
280 he_.oldTime() = Cp *
T_.oldTime() -
T_.oldTime() * R;
281 he_.oldTime().oldTime() = Cp *
T_.oldTime().oldTime() -
T_.oldTime().oldTime() * R;
286 he_.oldTime() = Cp *
T_.oldTime();
287 he_.oldTime().oldTime() = Cp *
T_.oldTime().oldTime();
289 he_.correctBoundaryConditions();
291 K_ = 0.5 * magSqr(
U_);
292 K_.oldTime() = 0.5 * magSqr(
U_.oldTime());
293 K_.oldTime().oldTime() = 0.5 * magSqr(
U_.oldTime().oldTime());
307 U_.correctBoundaryConditions();
308 p_.correctBoundaryConditions();
309 T_.correctBoundaryConditions();
319 const labelUList& owner =
mesh_.owner();
320 const labelUList& neighbour =
mesh_.neighbour();
338 + fvm::div(
phi_,
U_,
"div(pc)")
345 scalar UScaling = 1.0;
346 if (normStateDict.found(
"U"))
348 UScaling = normStateDict.getScalar(
"U");
350 scalar UResScaling = 1.0;
355 if (normResDict.found(
"URes"))
357 UResScaling =
mesh_.V()[cellI];
359 for (label i = 0; i < 3; i++)
362 PetscInt colI = rowI;
363 scalarField
D =
UEqn.D();
364 scalar val1 =
D[cellI] * UScaling / UResScaling;
366 MatSetValues(PCMat, 1, &rowI, 1, &colI, &val, INSERT_VALUES);
373 label ownerCellI = owner[faceI];
374 label neighbourCellI = neighbour[faceI];
376 if (normResDict.found(
"URes"))
378 UResScaling =
mesh_.V()[neighbourCellI];
381 for (label i = 0; i < 3; i++)
385 scalar val1 =
UEqn.lower()[faceI] * UScaling / UResScaling;
387 MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
394 label ownerCellI = owner[faceI];
395 label neighbourCellI = neighbour[faceI];
397 if (normResDict.found(
"URes"))
399 UResScaling =
mesh_.V()[ownerCellI];
402 for (label i = 0; i < 3; i++)
406 scalar val1 =
UEqn.upper()[faceI] * UScaling / UResScaling;
408 MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
498 volScalarField
rAU(1.0 /
UEqn.A());
499 surfaceScalarField
rhorAUf(
"rhorAUf", fvc::interpolate(
rho_ *
rAU));
504 autoPtr<volVectorField>
HbyAPtr =
nullptr;
512 HbyAPtr.reset(
new volVectorField(
"HbyA",
U_));
517 surfaceScalarField
phiHbyA(
"phiHbyA", fvc::interpolate(
rho_) * fvc::flux(
HbyA));
526 scalar pScaling = 1.0;
527 if (normStateDict.found(
"p"))
529 pScaling = normStateDict.getScalar(
"p");
531 scalar pResScaling = 1.0;
535 if (normResDict.found(
"pRes"))
537 pResScaling =
mesh_.V()[cellI];
541 PetscInt colI = rowI;
542 scalarField
D = pEqn.D();
543 scalar val1 =
D[cellI] * pScaling / pResScaling;
545 MatSetValues(PCMat, 1, &rowI, 1, &colI, &val, INSERT_VALUES);
551 label ownerCellI = owner[faceI];
552 label neighbourCellI = neighbour[faceI];
554 if (normResDict.found(
"pRes"))
556 pResScaling =
mesh_.V()[neighbourCellI];
561 scalar val1 = pEqn.lower()[faceI] * pScaling / pResScaling;
563 MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);
569 label ownerCellI = owner[faceI];
570 label neighbourCellI = neighbour[faceI];
572 if (normResDict.found(
"pRes"))
574 pResScaling =
mesh_.V()[ownerCellI];
579 scalar val1 = pEqn.upper()[faceI] * pScaling / pResScaling;
581 MatSetValues(PCMat, 1, &colI, 1, &rowI, &val, INSERT_VALUES);