CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Error when <dictionary>.lookup("variable"). OpenFOAM 1.6-ext (https://www.cfd-online.com/Forums/openfoam-programming-development/163742-error-when-dictionary-lookup-variable-openfoam-1-6-ext.html)

Malthe Eisum December 5, 2015 06:41

Error when <dictionary>.lookup("variable"). OpenFOAM 1.6-ext
 
I'm making my owen solver from icoFoam, where I add a body force B = U0m*(2*pi/period)*cos((2*pi/period)*t).
Where the period and free stream velocity (U0m) is to be loaded fra a dictionary. I think I have figured out the syntax from looking in "createFields.H" to keep it simple I started with the assumption that the variables was gonna be placed in "transportProperties".

Code:

IOdictionary transportProperties
(
    IOobject
    (
        "transportProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    )
);

scalar period(transportProperties.lookup("period"));
scalar U0m(transportProperties.lookup("U0m"));

added the last two lines, but when I try to make the solver i get the following error:
Code:

createFields.H: In function 'int main(int, char**)':
createFields.H:20: error: cannot convert 'Foam::ITstream' to 'Foam::scalar'
createFields.H:21: error: cannot convert 'Foam::ITstream' to 'Foam::scalar' in initialization

Additional questions
  1. What is good practice, shall I add min variables (period,U0m) in the transportPorperties or make an additional dictionary?
  2. I need the variables to be of class scalar, what is the syntax in the dictionary? is it as that of an dimensionedScalar omitting the dimension array:
    Code:

    period    period 9.72;

Malthe Eisum December 5, 2015 06:59

Found my own answer
 
Have spend 48 hours searching for an answer for my problems and the 15 min after posting my thread I find my own answer.

http://www.cfd-online.com/Forums/ope...nt-solver.html


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