Referencing variable from different code
Hello, I am modifying scalartransportFoam to make some multiple scalar properties I need. I first modified to create scalar named 'zeta', by modifying PDE from scalarTransport.c and changing name of scalar from 's' to 'zeta'. Then, i made another code which is also modified version of scalarTransport.c, which uses 'zeta' scalar for transport equation.
So, I tried to make the code gets data of 'zeta' as it does to rho and phi, so I wrote the line 'zetaName_ = dict.lookupOrDefault<word>("zeta", "zeta");' and 'mesh_.lookupObject<volScalarField>(zetaName_);' each below the part they reference rho and phi. However it seems like the code doesn't compile well. Below is the error code Code:
avgageTransport.C: In member function ‘virtual bool Foam::functionObjects::avgageTransport::read(const Foam::dictionary&)’: What may have caused the problem? Do these lookupOrDefault and lookupObject functions work different to rho/phi and zeta? I am not sure about how OF saves and load variable data |
Quote:
|
Do I have to externally declare the 'zetaName_'?
I thought the dict.lookupOrDefault is the function that creates the variable, since the function was doing the same job for rho and phi on original code, and they didn't have declared themselves before the 'rhoName_ = dict.lookupOrDefault<word>("rho", "rho");" stuffs... I am confused how the rhoName_ and phiName_ managed to compile without error but zetaName didn't. Also, how does this function actually work? It seems like it searches for field named "zeta" from the dictionary, and uses the latter "zeta", i have no idea what actually means by the way. Since zeta is also created from my another code which is modification of scalartransport, I'm not sure if it is actually stored in the so called 'dict', since I don't know how they do input on to the dictionary. Sorry for my low understanding in OF structure since I've just started OF programming... |
Lots to unpack here!
Quote:
Quote:
Code:
const volScalarField& rho = Quote:
Quote:
Code:
rhoName_ = dict.lookupOrDefault<word>("rho", "rho"); Quote:
1. brush up on your C++ programming skills 2. make extensive use of the Doxygen pages (eg https://cpp.openfoam.org/v8/scalarTr...8H_source.html) 3. Start to get your head around how OpenFOAM does things ... classes, dictionaries etc. 4. Google lots, to find helpful resources - there's plenty of training material, MSc theses etc. out there 5. try to work out the answers as much as you can, yourself - you'll learn enormously that way; come back to the forum when you get stuck Good luck! |
Oh god you are my livesaver! I had a bit experience on C, but never worked on such large software, so I've never thought of seeking variables in header file before.
Thank you very much. Now I got another clue about how OF works. Also, thanks for the last tip! |
All times are GMT -4. The time now is 15:03. |