commit e593fef659bcd71028e0e66a70510de2c34888e2
Author: Henry <Henry>
Date: Thu Feb 19 19:05:17 2015 +0000
potentialFoam: Added new method to estimate the static pressure field from the velocity
Uses a form of the Euler equation in which only variation along the streamlines is considered
commit cdadf4865de4808d6fe5c2a7eb5f5deaefe83b66
Author: Henry <Henry>
Date: Sat Feb 14 11:03:37 2015 +0000
potentialFoam: Solve for velocity potential named Phi rather than using the pressure field for this purpose
The Phi field is read if available otherwise created automatically with
boundary conditions obtained automatically from the pressure field if
available (with optional name) otherwise inferred from the velocity
field. Phi Laplacian scheme and solver specification are required. See
tutorials for examples.
98 lines
2.1 KiB
C
98 lines
2.1 KiB
C
Info<< "Reading velocity field U\n" << endl;
|
|
volVectorField U
|
|
(
|
|
IOobject
|
|
(
|
|
"U",
|
|
runTime.timeName(),
|
|
mesh,
|
|
IOobject::MUST_READ,
|
|
IOobject::AUTO_WRITE
|
|
),
|
|
mesh
|
|
);
|
|
|
|
U = dimensionedVector("0", U.dimensions(), vector::zero);
|
|
|
|
surfaceScalarField phi
|
|
(
|
|
IOobject
|
|
(
|
|
"phi",
|
|
runTime.timeName(),
|
|
mesh,
|
|
IOobject::NO_READ,
|
|
IOobject::AUTO_WRITE
|
|
),
|
|
fvc::interpolate(U) & mesh.Sf()
|
|
);
|
|
|
|
if (args.optionFound("initialiseUBCs"))
|
|
{
|
|
U.correctBoundaryConditions();
|
|
phi = fvc::interpolate(U) & mesh.Sf();
|
|
}
|
|
|
|
|
|
// Default name for the pressure field
|
|
word pName("p");
|
|
|
|
// Update name of the pressure field from the command-line option
|
|
args.optionReadIfPresent("pName", pName);
|
|
|
|
// Infer the pressure BCs from the velocity BCs
|
|
wordList pBCTypes
|
|
(
|
|
U.boundaryField().size(),
|
|
fixedValueFvPatchScalarField::typeName
|
|
);
|
|
|
|
forAll(U.boundaryField(), patchi)
|
|
{
|
|
if (U.boundaryField()[patchi].fixesValue())
|
|
{
|
|
pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName;
|
|
}
|
|
}
|
|
|
|
Info<< "Constructing pressure field " << pName << nl << endl;
|
|
volScalarField p
|
|
(
|
|
IOobject
|
|
(
|
|
pName,
|
|
runTime.timeName(),
|
|
mesh,
|
|
IOobject::READ_IF_PRESENT,
|
|
IOobject::NO_WRITE
|
|
),
|
|
mesh,
|
|
dimensionedScalar(pName, sqr(dimVelocity), 0),
|
|
pBCTypes
|
|
);
|
|
|
|
Info<< "Constructing velocity potential field Phi\n" << endl;
|
|
volScalarField Phi
|
|
(
|
|
IOobject
|
|
(
|
|
"Phi",
|
|
runTime.timeName(),
|
|
mesh,
|
|
IOobject::READ_IF_PRESENT,
|
|
IOobject::NO_WRITE
|
|
),
|
|
mesh,
|
|
dimensionedScalar("Phi", dimLength*dimVelocity, 0),
|
|
p.boundaryField().types()
|
|
);
|
|
|
|
label PhiRefCell = 0;
|
|
scalar PhiRefValue = 0;
|
|
setRefCell
|
|
(
|
|
Phi,
|
|
potentialFlow,
|
|
PhiRefCell,
|
|
PhiRefValue
|
|
);
|