exasim-project / FoamAdapter

GPL Adapter for the MIT licensed NeoFOAM
1 stars 0 forks source link

scalarAvection does not exit with an error if wrong executor name is chosen #22

Open happyKitesurfer opened 2 hours ago

happyKitesurfer commented 2 hours ago

I wrote in the control dict

executor LPU;

However the application does not crash as supposed in setup.cpp:

NeoFOAM::Executor createExecutor(const dictionary& dict) { auto execName = dict.get("executor");

Info << execName << nl;

if (execName == "Serial")
{
    Info << "Serial executor chosen" << nl;
    return NeoFOAM::SerialExecutor();
}
else if (execName == "CPU")
{
    Info << "CPU executor chosen" << nl;
    return NeoFOAM::CPUExecutor();
}
else if (execName == "GPU")
{
    Info << "GPU executor chosen" << nl;
    return NeoFOAM::GPUExecutor();
}
else
{
    FatalError << "Executor not recognized" << endl;
}
Info << "executor chosen" << endl;
Info << execName << nl;
return NeoFOAM::SerialExecutor();

}

It actually goes always to the end of the if else conditions

happyKitesurfer commented 2 hours ago

Even if I type

executor GPU;

in the controlDict It goes to the end of the if else conditions

happyKitesurfer commented 1 hour ago

I think dict.get("executor");

returns a word object, i.e., https://www.openfoam.com/documentation/guides/latest/api/classFoam_1_1word.html.

Maybe the == operator gets fooled :)

happyKitesurfer commented 1 hour ago

Ok the topic of comparing word with string was already discussed here:

https://www.cfd-online.com/Forums/openfoam-programming-development/168446-compare-word-variable-string.html

the solution is to convert the string to a word and compare to the dictionary entry

greole commented 1 hour ago

Thanks for reporting!

HenningScheufler commented 1 hour ago

Does this fixes the issue:

https://github.com/exasim-project/FoamAdapter/blob/fe4f53f050e31a5fd1d0a141df2fd64f316c4bca/src/setup/setup.cpp

HenningScheufler commented 54 minutes ago

Fix should be in PR #23