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/)
-   -   dimensionedScalar Dimension setting in lookup (https://www.cfd-online.com/Forums/openfoam-programming-development/167378-dimensionedscalar-dimension-setting-lookup.html)

13msmemusman February 29, 2016 08:51

dimensionedScalar Dimension setting in lookup
 
In creatFields.H i want to specify dimensions of a specific variable which i am getting from controlDict using lookupOrDefault. But i am unable to set proper dimensions to the variable. what i did is

dimensionedScalar heightOfOrigin
(
runTime.controlDict().lookup("heightOfOrigin"),
dimensionSet( 0, 1, 0, 0, 0, 0, 0),
);

But it gives me error.

Please help me

alexeym March 1, 2016 02:38

Hi,

Since you are constructing dimensionedScalar, use one of the constructors of the class (http://foam.sourceforge.net/docs/cpp/a00525.html) instead random attempts to guess the syntax:

Code:

dimensionedScalar heightOfOrigin
(
"heightOfOrigin",
dimLength,
readScalar(runTime.controlDict().lookup("heightOfOrigin"))
);

so in controlDict you just put "heightOfOrigin 1.0;", or you can have default value:

Code:

dimensionedScalar heightOfOrigin
(
"heightOfOrigin",
dimLength,
runTime.controlDict().lookupOrDefault<scalar>("heightOfOrigin", 0.0)
);

or you can set dimensions in controlDict like "heightOfOrigin heightOfOrigin [ m ] 1.0" and use constructor from Istream like:

Code:

dimensionedScalar heightOfOrigin(runTime.controlDict().lookup("heightOfOrigin"));

13msmemusman March 1, 2016 07:48

Sir thank you i understand now. But please guide me how you get help from sourceforge???? the link you sent.

13msmemusman March 1, 2016 07:56

I am sorry i am a new member........ Learning......

rarnaunot February 21, 2022 07:45

Error compiling lookup
 
Dear foamers,

We have a problem compiling a solver in v2006 that was previously compiled in v1806 version.

This is the problem shown:
Code:

createFields.H:247:1 warning 'Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]' is depracted (declared at 7share/apps/OpenFOAM-v2006/src/OpenFOAM/lnInclude/dimensionedType.C:305): Since 2018-11 [-Wdeprecated-declarations] );
This problem is repeated some times and it is related with this code:

Code:

IOdictionary diffusionProperties
(
        IOobject
        (
                "diffusionProperties",
                runTime.constant(),
                mesh,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE
        )
);


Info<< "Reading diffusivity DX\n" << endl;
dimensionedScalar DX
(
        diffusionProperties.lookup("DX")
);

Thanks a lot,

olesen February 21, 2022 09:17

Quote:

Originally Posted by rarnaunot (Post 822754)
Dear foamers,

We have a problem compiling a solver in v2006 that was previously compiled in v1806 version.

This is the problem shown:
Code:

createFields.H:247:1 warning 'Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]' is depracted (declared at 7share/apps/OpenFOAM-v2006/src/OpenFOAM/lnInclude/dimensionedType.C:305): Since 2018-11 [-Wdeprecated-declarations] );
This problem is repeated some times and it is related with this code:
[/CODE]


As the message states it is a deprecation, which means that it not a compilation error, but a suggestion. The message furthermore states "deprecated since 2018-11", which is a clear indication why it compiled without warnings in v1806 but now starts emitting warnings with a new version.


From the docs (https://www.openfoam.com/documentati...d.html#details) it states


Quote:


Deprecated(2018-11) Construct from Istream with given name (expects dimensions, value)
Deprecated:(2018-11) - should generally use construct from dictionary or primitiveEntry instead (additional checks on the input stream).

Which further information should we provide???

rarnaunot February 21, 2022 11:22

Thanks olesen for your quick reply. I thought it was wrong in my code so it is enough to know that it is just a suggestion.

rarnaunot


All times are GMT -4. The time now is 21:37.