|
[Sponsors] |
how to call 'p' as pressure into my code from OpenFOAM? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 16, 2013, 08:45 |
how to call 'p' as pressure into my code from OpenFOAM?
|
#1 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
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 |
|
February 16, 2013, 09:05 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
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 |
|
February 18, 2013, 01:42 |
|
#3 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Niels,
Thank you very much for your reply - It works now. I have just one more question. Forgive me if it is very basic; its just that OpenFOAM's level of C++ takes some time to get used to, and I am fairly new to this game I have included 'p' into my code as you said, but I tried taking a gradient of 'p' and it gave me compile errors. I tried grad(p) and also Foam::fvc::grad(p) Neither of which work. All I want to do is Is there an elegant way to do this? I want only the streamwise (x) pressure gradient, instead of the gradient in all directions. Finally, omitting the gradient term, my code compiles saying 'libNULL.so' is up to date. But when I run a test case with my new wall function included in the 0/nuSgs file, it aborts Code:
Unknown patchField type NewWallFunction for patch type wall Valid patchField types are : 69 ( advective atmBoundaryLayerInletEpsilon buoyantPressure .... .... nuSgsUSpaldingWallFunction nutLowReWallFunction nutTabulatedWallFunction nutURoughWallFunction nutUSpaldingWallFunction ... ... Can you please give me some ideas as to what I am doing wrong here? How do I integrate my New wall function into OpenFOAM like the existing ones?? Thanks for your time and help. Regards, A.T.M |
|
February 18, 2013, 05:18 |
|
#4 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
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 |
|
February 18, 2013, 05:45 |
|
#5 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
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:
NewWallFunctionFvPatchScalarField.C EXE = $(FOAM_USER_LIBBIN)/NewWallFunction 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 |
|
February 18, 2013, 05:54 |
|
#6 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
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 |
|
February 18, 2013, 06:20 |
|
#7 | |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
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 !! |
||
February 18, 2013, 06:28 |
|
#8 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
OK, good luck - I will keep my eyes on the thread
/ Niels |
|
January 13, 2014, 12:04 |
|
#9 |
New Member
Join Date: Aug 2009
Location: Stuttgart, Germany
Posts: 20
Rep Power: 17 |
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 |
|
March 25, 2016, 18:13 |
|
#10 |
Member
SM
Join Date: Dec 2010
Posts: 97
Rep Power: 15 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Pressure Inlet" Boundary Setup | Wijaya | FLUENT | 15 | May 18, 2016 11:08 |
Pressure Rise Error | emueller | CFX | 0 | May 5, 2009 12:08 |
Does star cd takes reference pressure? | monica | Siemens | 1 | April 19, 2007 12:26 |
Gas pressure question | Dan Moskal | Main CFD Forum | 0 | October 24, 2002 23:02 |
2D CFD code using SIMPLE algorithm | bfan | Main CFD Forum | 3 | June 22, 2002 23:01 |