OpenFOAM® offers a standard way to access user-specified constant data by means of dictionaries. However, dictionaries are by default read during the start-up phase of the main code. If a boundary condition requires to access the same information, the value can be looked up from the internal database used by OpenFOAM to store objects. The procedure is quite simple, and I show an example below, in a general case. Let’s assume our solver uses the “transportProperties” dictionary, which contains a subdictionary, called “mySubDict”. This sub-dictionary contains a dimensioned scalar, named “myScalar”. In the BC, you can recover “myScalar” as follows:
// Extract the dictionary from the database const dictionary& transportProperties = db().lookupObject<IOdictionary> ( "transportProperties" ); // Exctract subdictionary from the main dictionary dictionary mySubDict ( transportProperties.subDict("mySubDict") ); // Extracting scalar value dimensionedScalar myScalar(mySubDict.lookup("myScalar"));
At this point “myScalar” is accessible from inside the code of the boundary condition.
This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.