View Issue Details

IDProjectCategoryView StatusLast Update
0001227OpenFOAMBugpublic2015-10-03 17:51
Reporterjacob Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSUbuntuOS Version12.04
Summary0001227: "ptot" utility does not support -region
DescriptionThe utility "ptot" cannot be used with multi-region mesh since it does not support the "-region" switch.
TagsNo tags attached.

Relationships

related to 0001861 resolvedhenry applications/utilities/postProcessing: Adding "-region" option to wallGradU, temporalInterpolate and pPrime2 

Activities

wyldckat

2015-09-27 21:34

updater  

ptot.C (4,061 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Application
    ptot

Description
    For each time: calculate the total pressure.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
    timeSelector::addOptions();
    #include "addRegionOption.H"

    #include "setRootCase.H"
    #include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);

    #include "createNamedMesh.H"

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << endl;

        IOobject pheader
        (
            "p",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        IOobject Uheader
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );


        // Check p and U exist
        if (pheader.headerOk() && Uheader.headerOk())
        {
            mesh.readUpdate();

            Info<< "    Reading p" << endl;
            volScalarField p(pheader, mesh);

            Info<< "    Reading U" << endl;
            volVectorField U(Uheader, mesh);

            Info<< "    Calculating ptot" << endl;
            if (p.dimensions() == dimensionSet(0, 2, -2, 0, 0))
            {
                volScalarField ptot
                (
                    IOobject
                    (
                        "ptot",
                        runTime.timeName(),
                        mesh,
                        IOobject::NO_READ
                    ),
                    p + 0.5*magSqr(U)
                );
                ptot.write();
            }
            else
            {
                IOobject rhoheader
                (
                    "rho",
                    runTime.timeName(),
                    mesh,
                    IOobject::MUST_READ
                );

                // Check rho exists
                if (rhoheader.headerOk())
                {
                    Info<< "    Reading rho" << endl;
                    volScalarField rho(rhoheader, mesh);

                    volScalarField ptot
                    (
                        IOobject
                        (
                            "ptot",
                            runTime.timeName(),
                            mesh,
                            IOobject::NO_READ
                        ),
                        p + 0.5*rho*magSqr(U)
                    );
                    ptot.write();
                }
                else
                {
                    Info<< "    No rho" << endl;
                }
            }
        }
        else
        {
            Info<< "    No p or U" << endl;
        }

        Info<< endl;
    }

    return 0;
}


// ************************************************************************* //
ptot.C (4,061 bytes)   

wyldckat

2015-09-27 21:37

updater   ~0005375

Last edited: 2015-09-27 22:00

@Henry: Attached is the "ptot.C" file for the folder "applications/utilities/postProcessing/miscellaneous/ptot". It's based on OpenFOAM-dev, but it can also be added to 2.4.x as-is.

There are more utilities in the "postProcessing" folder that can get this update. I'll open up a new task when I have tested them.

henry

2015-09-28 15:36

manager   ~0005376

@Bruno: Thanks for the updated file.
Resolved in OpenFOAM-dev: commit d917833d41fba7b2d40404ab3e708f23692a7f31

Issue History

Date Modified Username Field Change
2014-03-17 07:15 jacob New Issue
2015-09-27 21:34 wyldckat File Added: ptot.C
2015-09-27 21:34 wyldckat Assigned To => henry
2015-09-27 21:34 wyldckat Status new => assigned
2015-09-27 21:37 wyldckat Note Added: 0005375
2015-09-27 22:00 wyldckat Note Edited: 0005375
2015-09-28 15:36 henry Note Added: 0005376
2015-09-28 15:36 henry Status assigned => resolved
2015-09-28 15:36 henry Resolution open => fixed
2015-10-03 17:51 wyldckat Relationship added related to 0001861