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

'error: "variable" was not declared in this scope'

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 2, 2018, 16:43
Default 'error: "variable" was not declared in this scope'
  #1
New Member
 
Join Date: Sep 2016
Posts: 7
Rep Power: 7
dbarre5 is on a distinguished road
Hello all,

I am new to and still learning OpenFOAM as well as C++.

I am coming across an issue where when compiling it is telling me that my variables are not being declared. Even though they definitely are... well at least they seemingly are to me, based on other languages I've coded in.

An example of this:
Code:
#include "setRootCase.H"
#include "createTime.H"
#include "createMeshes.H"
will result in the error: ‘adjustTimeStep’ was not declared in this scope

adjustTimeStep is declared in setRootCase.H. This issue can be resolved by taking everything in the header file and just pasting it in the main C file.

Code:
const bool adjustTimeStep =
    runTime.controlDict().lookupOrDefault("adjustTimeStep", false);

scalar maxCo =
    runTime.controlDict().lookupOrDefault<scalar>("maxCo", 1.0);

scalar maxDeltaT =
    runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT);	
#include "CourantNo.H"
#include "setDeltaT.H"
Well, that works but still, all of my scalarFields, vectorFields, etc are having the same issue. (And yes, I should have all of the correct files in my Make folder)

Is there something I am missing about programming in openFOAM or c++ where my variables are only declared temporarily but then forgotten?

Any help is appreciated, as I have searched the forums and google but haven't found anything (maybe as to not using the right keywords as I'm not exactly sure what the issue is).
dbarre5 is offline   Reply With Quote

Old   July 3, 2018, 12:27
Default
  #2
New Member
 
Join Date: Sep 2016
Posts: 7
Rep Power: 7
dbarre5 is on a distinguished road
I have found a similar issue with some additional information that may be related to mine.

https://www.linuxquestions.org/quest...enfoam-940604/

at this rate I think I can figure out what is going wrong as it seems like some sort of basic issue. Maybe not being declared in the correct scope. I will update after I solve the issue (hopefully at least)
dbarre5 is offline   Reply With Quote

Old   June 9, 2021, 21:35
Default
  #3
New Member
 
Robert Crane
Join Date: Jul 2020
Posts: 8
Rep Power: 3
rcrane22 is on a distinguished road
Did you ever make any progress on this? Im struggling with a similar issue. In this case modifying chtMultiRegionSimpleFoam
rcrane22 is offline   Reply With Quote

Reply

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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 07:43
error compiling modified applications yvyan OpenFOAM Programming & Development 21 March 1, 2016 04:53
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 12:34
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 05:07


All times are GMT -4. The time now is 04:41.