|
[Sponsors] |
September 17, 2022, 04:44 |
Variable decleration problem
|
#1 |
Member
Refik
Join Date: Dec 2014
Location: Turkey
Posts: 53
Rep Power: 11 |
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 12:58. |
|
September 22, 2022, 04:25 |
|
#2 |
Member
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4 |
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, 14:43 |
|
#3 |
Member
Refik
Join Date: Dec 2014
Location: Turkey
Posts: 53
Rep Power: 11 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem diverges when exhaust valve opens | swerner0711 | AVL FIRE | 0 | September 21, 2018 07:14 |
[swak4Foam] Variable T_inf for convection problem in a pipe using groovyBC | Mojtaba.a | OpenFOAM Community Contributions | 4 | September 4, 2013 19:10 |
Problem with variable in expression CFX-Pre | TallesC | CFX | 4 | March 7, 2013 17:32 |
A realy easy variable - problem | wernsen | OpenFOAM Programming & Development | 3 | January 7, 2013 13:25 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 20:09 |