CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   application help (http://www.cfd-online.com/Forums/openfoam-programming-development/117809-application-help.html)

albertofast May 15, 2013 10:57

application help
 
Dear users, I'm using openfoam 2.1 and I need to create a post-processing application to get this filed:

acoSor=rho*fvc::div(fvc::div(U*U))

This field can be used as a source term for a FW-H acoustic solver. I already tried to modify other utilities (for example the one for vorticity) and get it done, but I always get errors.

this is my code actually

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 Uheader
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (Uheader.headerOk())
    {
        Info<< "    Reading U" << endl;
        volVectorField U(Uheader, mesh);

        Info<< "    Calculating vorticity" << endl;
        volScalarField acoSor
        (
            IOobject
            (
                "acoSor",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            rho*fvc::div(fvc::div(U*U))
        );
        Info<< "    Calculating acoSor" << endl;

        if (writeResults)
        {
            acoSor.write();
        }
    }
    else
    {
        Info<< "    No U" << endl;
    }

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

Can you help me please? Thank you very much!

ngj May 15, 2013 11:33

Hi Edoardo,

I cannot see that you have defined the rho variable? This for one will give you compilation errors.

Kind regards

Niels


All times are GMT -4. The time now is 08:05.