CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istrea m&) [with Type = double]’

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2023, 01:28
Default warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istrea m&) [with Type = double]’
  #1
Ary
New Member
 
Join Date: Apr 2023
Posts: 11
Rep Power: 3
Ary is on a distinguished road
Hi

Wish you a nice day!

Sorry to bother you, this is solved.

The warning happens due to the syntax is different for the latest OpenFOAM version.

The current syntax should goes like this:

Code:
dimensionedScalar rho3("rho3",transportProperties);
lookup is not needed for reading properties from dictionary.


Question from newbe me before:
------------------------------------------------------------

There is a warning info when I try to compile a solver.

HTML Code:
readTransportProperties.H: In function ‘int main(int, char**)’:
readTransportProperties.H:18:5: warning: ‘Foam::dimensioned<Type>::dimensioned(Foam::Istream&) [with Type = double]’ is deprecated: Since 2018-11 [-Wdeprecated-declarations]
   18 |     );
      |     ^
I include the "readTranspotProperties.H" in my "createFields.H" file

Here is the "readTranspotProperties.H"

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

    dimensionedScalar rho3
    (
        transportProperties.lookup("rho3")
    );
The code is pretty simple, but warning happens.

Does anyone have an idea about how to debug the warning?

Thank you very much for your kindness and patience.

Ary

Last edited by Ary; April 12, 2023 at 05:56. Reason: SOLVED
Ary is offline   Reply With Quote

Old   April 13, 2023, 16:36
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
The dictionary "lookup" method returns a stream of tokens. If you construct from that, the constructor will use as many tokens as needed. This works fine, so you can simply ignore the compilation warnings.

However, consider the following example:
Code:
nu   nu [ 0 2 -1 0 0 0 0 ] 1e-05
enabled true;
nu0  nu0 [ 0 2 -1 0 0 0 0 ] 1e-06
At first it looks OK, but it you look closely, you'll see there is a missing ';' on the first entry. Thus it really looks like this (for the parser):
Code:
 nu   nu [ 0 2 -1 0 0 0 0 ] 1e-05  enabled true;
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06;
If you use the new syntax (specifying name and dictionary, without the lookup), you are telling the constructor that you expect the evaluation of the dictionary lookup to consume all of the tokens. The constructor can now report an IO warning or error that there are unexpected trailing tokens.
If you use the lookup syntax, you are less likely to notice your bad input. In this case, you thought you had an "enabled" entry, but it's just some trailing rubbish on the "nu" entry. Much better to have the bad input flagged immediately instead of waiting a day for the simulation to run and not even realise that the "enabled" wasn't actually seen.
olesen is offline   Reply With Quote

Old   April 23, 2023, 23:00
Default
  #3
Ary
New Member
 
Join Date: Apr 2023
Posts: 11
Rep Power: 3
Ary is on a distinguished road
Dear Olesen,

Thank you so much for the introduction.

There are so many details for me to learn.

Thank you!

Ary
Ary is offline   Reply With Quote

Reply

Tags
#openfoam #debug

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
foamToTecplot360 thomasduerr OpenFOAM Post-Processing 121 June 11, 2021 10:05
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 00:21
time step continuity problem in VAWT simulation lpz_michele OpenFOAM Running, Solving & CFD 5 February 22, 2018 19:50
rhoPimpleFoam hardship petrus OpenFOAM Running, Solving & CFD 0 October 7, 2016 02:41
[swak4Foam] installation problem with version 0.2.3 Claudio87 OpenFOAM Community Contributions 9 May 8, 2013 10:20


All times are GMT -4. The time now is 18:44.