Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 413
    • Issues 413
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1356
Closed
Open
Issue created Jul 04, 2019 by Admin@OpenFOAM-adminMaintainer

pressure functionObject in v1906 does not calculate total pressure coefficient (fix attached)

In v1906, the pressure function object uses a new "mode" specification. The documentation is not up yet, but from the source code it looks like the options are: static, total, isentropic, staticCoeff, totalCoeff.

The block of code below correctly handles the difference between static and total pressure, and when I calculate these, the values are correct.

However, when the mode is totalCoeff or staticCoeff, the output of both is the same: staticCoeff (i.e., the default in the switch below). I think the switch needs some kind of "startswith" logic.

To fix this, I have replaced this switch case with an if statement similar to the one used for the coeff logic and resultName logic. After compiling and running, I am getting proper values for totalCoeff. I've attached the modified file.

pressure.C

Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::calcPressure
(
    const volScalarField& p,
    const tmp<volScalarField>& tp
) const
{
    switch (mode_)
    {
        case TOTAL:
        {
            return
                tp
              + dimensionedScalar("pRef", dimPressure, pRef_)
              + rhoScale(p, 0.5*magSqr(lookupObject<volVectorField>(UName_)));
        }
        case ISENTROPIC:
        {
            const basicThermo* thermoPtr =
                p.mesh().lookupObjectPtr<basicThermo>(basicThermo::dictName);

            if (!thermoPtr)
            {
                FatalErrorInFunction
                    << "Isentropic pressure calculation requires a "
                    << "thermodynamics package"
                    << exit(FatalError);
            }

            const volScalarField gamma(thermoPtr->gamma());
            const volScalarField Mb
            (
                mag(lookupObject<volVectorField>(UName_))
               /sqrt(gamma*tp.ref()/thermoPtr->rho())
            );

            return tp()*(pow(1 + (gamma - 1)/2*sqr(Mb), gamma/(gamma - 1)));
        }
        default:
        {
            return
                tp
              + dimensionedScalar("pRef", dimPressure, pRef_);
        }
    }
}

## Reattaching the author to the issue ticket: @aerogt3 ##

Edited Dec 11, 2019 by Kutalmış Berçin
Assignee
Assign to
Time tracking