# Variable decleration problem

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

 September 17, 2022, 05:44 Variable decleration problem #1 Member   Refik Join Date: Dec 2014 Location: Turkey Posts: 53 Rep Power: 9 Hello Everyone, I am trying to implement a new solver based on reactingFoam. Currently i am on very early stages and try to implement necessery codes step by step. My first attempt was to create a scalar that will be read from a dictionary i created. Below code is written in a file named "readThickenedFlameProperties.H" and this header is in the same directory as "reactingFoam.C" and "createFields.H". IOdictionary thickenedFlameProperties ( IOobject ( "thickenedFlameProperties", runTime.constant(), runTime, IOobject::MUST_READ, IOobject::NO_WRITE ) ); // Define a scalar for thickening factor scalar TF = readScalar(thickenedFlameProperties.lookup("thicke ningFactor")); scalar yfSt = readScalar(thickenedFlameProperties.lookup("fuelSt oicRatio")); I also created the thickened flame properties file in the tutorial case and compilation works up to this point. ("readThickenedFlameProperties.H" is reactingFoam.C right before "createFields.H") But when i try to create a scalar field inside the "createFields.H" with the scalar i read from my dictionary, i get an decleration error during compilation. Piece of code in createFields.H is: volScalarField& yf = composition.Y("CH4"); volScalarField c("c", 1 - yf / yfSt); and also in reactingFoam.C int main(int argc, char *argv[]) { .. .. .. .. #include "readThickenedFlameProperties.H" #include "createFields.H" .. .. } The error i get is: In file included from /usr/lib/openfoam/openfoam2112/src/OpenFOAM/lnInclude/postProcess.H:147:0, from myReactingFoam.C:57: ./createFields.H: In function ‘int main(int, char**)’: ./createFields.H:104:32: error: ‘yfSt’ was not declared in this scope volScalarField c("c", 1 - yf / yfSt); ^~~~ I know yfSt is defined prior to volScalarField c but it seems there is a problem in communication which is weird. Do you have any suggestions as to how to overcome this problem ? I know i could place readThickenedFlameProperties.H inside createFields.H but i want to code them seperately for later usage and extended code. Best regards. Refik Last edited by rewol; September 17, 2022 at 13:58.

 September 22, 2022, 05:25 #2 Member   Join Date: Jan 2022 Location: Germany Posts: 49 Rep Power: 2 Without seeing the whole Code of "readThickenedFlameProperties.H", its hard to guess where your error is. According to the errror message I would guess that you defined your variables in "readThickenedFlameProperties.H" under a different scope. Because of the different scope the program is not able to find your variables defined earlier. Maybe you have to get your variable via the scope resolution operator (:. Take a look on your code and look if you have declared for example a block scope in your "readThickenedFlameProperties.H" file or something else.

 October 2, 2022, 15:43 #3 Member   Refik Join Date: Dec 2014 Location: Turkey Posts: 53 Rep Power: 9 Hello, I overcame this problem by moving my new solver folder to user solver folder inside applications. Though I did not understand why it worked.