Challenge

Project 2- Creating a custom IOObject in Visual Studio Code

code for to caclaute the P_Total perssure

functions
{
    #includeFunc streamlines
	
	// Adding Total_Pressure using codedFunctionObject
	totalPressure
    {
        //Mandatory entries
        type             coded;
        libs             ("libutilityFunctionObjects.so");
        name             pTotal;
        enabled          true;
        executeControl   timeStep;
        executeInterval  50;
        WriteControl     timeStep;
        writeInterval    50;
    
        codeWrite
        #{
            const volVectorField& U = mesh().lookupObject<volVectorField>("U");
            const volScalarField& p = mesh().lookupObject<volScalarField>("p");
     

            Info << "Creating pTotal Field" << nl << endl;

            volScalarField pTotal
            (
                IOobject
                (
                    "pTotal",
                    mesh().time().timeName(),
                    mesh(),
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),

                p + 0.5*magSqr(U)

            );
                pTotal.write();
        #};
    };	
}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.