CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   customizing the meanVorticity utility (https://www.cfd-online.com/Forums/openfoam-programming-development/182331-customizing-meanvorticity-utility.html)

kkpal January 6, 2017 23:43

customizing the meanVorticity utility
 
1 Attachment(s)
Hi,
I am trying to calculate the vorticity of the mean velocity fields. So far what I have done to achieve this is to save the UMean file in another time directory as U and calculate the vorticity of this U with the built-in utility 'vorticity'.
This works good but not elegant.:rolleyes:
I would like to customize a 'meanVorticity' utility that does the same thing as I have mentioned above. I anticipated that it would not be difficult since what I need to do is change the U with UMean in the original vorticity.C and then wmake.
However, it turns out that this is far more complicated than I had expected.
The meanVorticity.C file I modified is as follows:

Code:


#include "calc.H"
#include "fvc.H"

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

void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    bool writeResults = !args.optionFound("noWrite");

    IOobject UMeanheader
    (
        "UMean",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (Uheader.typeHeaderOk<volVectorField>(true))
    {
        Info<< "    Reading UMean" << endl;
        volVectorField UMean(UMeanheader, mesh);

        Info<< "    Calculating meanVorticity" << endl;
        volVectorField meanVorticity
        (
            IOobject
            (
                "meanVorticity",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            fvc::curl(UMean)
        );

        volScalarField magMeanVorticity
        (
            IOobject
            (
                "magMeanVorticity",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            mag(meanVorticity)
        );

        Info<< "meanVorticity max/min : "
            << max(magMeanVorticity).value() << " "
            << min(magMeanVorticity).value() << endl;

        if (writeResults)
        {
            meanVorticity.write();
            magMeanVorticity.write();
        }
    }
    else
    {
        Info<< "    No UMean" << endl;
    }

    Info<< "\nEnd\n" << endl;
}

And upon wmake after all the necessary modifications regarding 'file' and 'options' are finished, this piece of code gives me the following error:

Code:

meanVorticity.C:55:9: error: ‘Uheader’ was not declared in this scope
    if (Uheader.typeHeaderOk<volVectorField>(true))
        ^
meanVorticity.C:55:44: error: expected primary-expression before ‘>’ token
    if (Uheader.typeHeaderOk<volVectorField>(true))
                                            ^
make: *** [Make/linux64Gcc48DPOpt/meanVorticity.o] Error 1

It seems that something is wrong with the Uheader, and as a newbie to the programming in openfoam, I am stuck at this problem.

Could someone shed light on this problem? I attached the source code in here.

Zeppo January 7, 2017 11:45

Quote:

Originally Posted by kkpal (Post 632353)
Code:

    if (Uheader.typeHeaderOk<volVectorField>(true))

==>
Code:

    if (UMeanheader.typeHeaderOk<volVectorField>(true))

kkpal January 8, 2017 12:06

1 Attachment(s)
Quote:

Originally Posted by Zeppo (Post 632388)
==>

Code:

    if (UMeanheader.typeHeaderOk<volVectorField>(true))



Thank you for pointing this out, Zeppo. But it still does not solve this problemAttachment 53053


Sent from my iPhone using CFD Online Forum mobile app

Zeppo January 8, 2017 14:07

Code:

if (Uheader.typeHeaderOk<volVectorField>(true))
==>
Code:

if (UMeanheader.headerOk())

kkpal January 8, 2017 22:13

Quote:

Originally Posted by Zeppo (Post 632468)
Code:

if (Uheader.typeHeaderOk<volVectorField>(true))
==>
Code:

if (UMeanheader.headerOk())

This worked! Thank you so much!


All times are GMT -4. The time now is 15:29.