Challenge

Week 5 Challenge- Creating a test case in OpenFOAM

Code:

#include "fvCFD.H"

int main(int argc, char *argv[]) 
{
    Foam::argList::noBanner();
    Foam::argList args(argc, argv);

    // Assuming the user runs the code in the case directory
    Foam::Time runTime
    (
        Foam::Time::controlDictName,
        args.rootPath(),
        args.caseName()
    );

    IOdictionary ioDictObj
    (
        IOobject
        (
            "thermalProperties",
            "constant",
            runTime,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    scalar nu = readScalar( ioDictObj.lookup("nu") );
    scalar T = readScalar( ioDictObj.lookup("T") );


    // Print the retrieved values to the console
    Info<<nu<<"\n";
    Info<<T<<"\n";

    return 0;
}

Modified transportProperties to thermalProperties file:

T variable is added and value 300 is assigned

Output:

The output gives values of nu and T

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.