how to call 'p' as pressure into my code from OpenFOAM?
Hello all,
I am written a new wall function in OpenFOAM and I am trying to compile it. I am getting the error saying Code:
error: ‘p’ was not declared in this scope I saw the channelFoam and pisoFoam codes where the variable 'p' was used as pressure in the code. I want to do just the same in my code. Any help will be appreciated. Thank you! A.T.M |
Hi ATM,
Inside the wall functions you do not have direct access to the pressure, since it is not part of the construction. You do, however, have access to the database structure, so you can obtain a constant reference to the pressure in the following way: Code:
const volScalarField & p = this->db().lookupObject<volScalarField>("p"); Niels |
Hi ATM,
Good. I will try to answer your questions below: 1. Please provide me/us with some compilation errors, as the error could be due to a multiple number of things. 2. It does not seem as you have written the correct lines in your Make/files script, since it tells you that it outputs the library to a default name, namely libNULL.so. Please post the Make/files file here. 3. Your simulation does not recognise the new library, because the solver has not been linked to it during compilation. You can do a runTime-linking adding the following line to the controlDict: Code:
libs ( "<myLibraryName>" ); Kind regards, Niels |
Hi Niels,
This is the code I inserted (NewWallFunctionFvPatchScalarField.C:138:48 in the error message) Code:
const scalarField GradP(Foam::fvc::grad(pr)); of the pressure in the whole field. Here is the error msg I get - Its a dropbox link to a text file. http://db.tt/TSnCRvcS And this is my Make/file Code:
Basically, I just used the nuSgsUSpaldingWallFunction code as a template, and edited it to the new function, so as to be consistent. Thank you very much for your help again. Regards, A.T.M |
Hi ATM,
With respect to the pressure, then the gradient of a volScalarField is a vectorField, so the following should compile: Code:
volVectorField gradP = Foam::fvc::grad( pr )(); Secondly, as you are compiling a library and not a solver/utility, the line in your Make/files should read the following: Code:
LIB = $(FOAM_USER_LIBBIN)/libNewWallFunction |
Quote:
Meanwhile, I have been trying my code with the fix you suggested for grad(p). I am having some additional problems, but I will try my best and figure it out before I post it here for you. Thank you very much for your help so far !! |
OK, good luck - I will keep my eyes on the thread :)
/ Niels |
Hi ATM,
did you manage to get the streamwise pressure gradient to work properly? I'm dealing with a similar problem at the moment, and I tried the solution as destribed above with Code:
volVectorField gradient = Foam::fvc::grad(pressure)(); However, in parallel the simulation crashes as soon as the volVectorField for the gradient definition is included in the code. It even does not matter if I really use the gradient later on, just the definition itself seems to be critical. It seems to me this is some kind of MPI and/or memory allocation problem... Did you experience the same issue when testing your wall function and do you have an idea how to solve this? Thanks! Nils |
Where to add this in case one wants to write out the pressure gradient during runtime?
Is something like probe for p/U possible for the pressure gradient by adding locations in controldict? Thanks |
All times are GMT -4. The time now is 07:50. |