|
[Sponsors] |
May 25, 2018, 11:23 |
False warning: unused variable
|
#1 |
New Member
Mohamed Elshahat Ouda
Join Date: May 2010
Posts: 29
Rep Power: 16 |
Dear All;
I have weird problem when I try to compile my solver. I have a some variables defined in creatFields.H, for example: Code:
//Dispersed phase diameter const dimensionedScalar& dd(mixture.dd()); //Turbulent Schmidt number const dimensionedScalar& Sct(mixture.Sct()); The problem is that when I try to compile the code it gives me the following warning: Code:
./createFields.H: In function ‘int main(int, char**)’: ./createFields.H:140:26: warning: unused variable ‘dd’ [-Wunused-variable] const dimensionedScalar& dd(mixture.dd()); ^ ./createFields.H:143:26: warning: unused variable ‘Sct’ [-Wunused-variable] const dimensionedScalar& Sct(mixture.Sct()); Code:
‘Sct’ was not declared in this scope ‘dd’ was not declared in this scope I just wonder why does this problem appear? and which variables should be declared in createFields.H and which should be declared directly in the solver source file? Best regards |
|
May 30, 2018, 03:58 |
|
#2 |
Member
Join Date: Oct 2015
Location: Finland
Posts: 39
Rep Power: 11 |
Hey,
I think it looks like you declare a reference but does not initialize it in your createFields. I tested it like following with dummy variables and no warning messages: In createFields.H: Code:
const scalarField& Sct = mesh.V(); const scalarField& vols = mesh.V(); Code:
#include "createFields.H" scalarField test = vols + Sct; Code:
//Dispersed phase diameter const dimensionedScalar& dd = mixture.dd(); //Turbulent Schmidt number const dimensionedScalar& Sct = mixture.Sct(); Bulut |
|
February 5, 2021, 08:48 |
|
#3 |
Member
K
Join Date: Jul 2017
Posts: 97
Rep Power: 9 |
Did you find any solution to your problem ? I do have the same issue:
a warning about an unused variable. But I am 100% it is used. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 08:31 |
Cells with t below lower limit | Purushothama | Siemens | 2 | May 31, 2010 22:58 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |
Gentoo Compilation woes on AMD64 with fluentMeshToFoamL | connclark | OpenFOAM Installation | 8 | February 29, 2008 15:18 |