CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Boundary condition. How to get the normal gradient of the patchField U

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

Like Tree2Likes
  • 1 Post By Sylv
  • 1 Post By schröder

LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2015, 07:57
Default Boundary condition. How to get the normal gradient of the patchField U
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 13
Sylv is on a distinguished road
Dear Foam,

I have a home-made solver, which has the volVectorField named Vs aside the classic U and p field. In a custom inlet boundary condition of U (named "customBC"), I need to access Vs, which is quite easy with a lookupObject. I also need the normal gradient of Vs on my inlet BC. I have implemented several possibilities, which work fine, but they are either costly or not flexible.

  1. First possibility: get snGard(Vs) in the BC and extract the right patchField from snGard(Vs) with such code:
    // in the custom boundary condition of U
    const volVectorField& Vs = this->db().lookupObject<volVectorField>("Vs");
    const surfaceVectorField snGradVs = fvc::snGrad(Vs);
    const label& patchIndex(this->patch().index());
    const vectorField& patchSnGradVs = snGradVs.boundaryField()[patchIndex];
    This works well, but if I have N "customBC", snGrad(Vs) is calculated N time, which is costly. It is also not very efficient to calculate snGrad on the entire field and keeping only the patch field...
  2. Second possibility: calculate snGrad(Vs) in the solver directly. The calculation is done only one, even with multiple "customBC". But it is not very flexible. If I don't need "customBC", snGradVs is calculated for nothing...
Is there a why to calculate the snGrad of a boundary field more efficiently?

ancolli likes this.
Sylv is offline   Reply With Quote

Old   April 21, 2015, 08:29
New Member
Martin S.
Join Date: Apr 2015
Posts: 9
Rep Power: 11
schröder is on a distinguished road
From a boundary field you have access to the face value ("psif"), the value at the cell center ("psic") and the delta coeffient ("delta"), which is 1/(distance from center to face).
From these values you can calculate the normal gradient sngrad=delta*(psif-psic).

I don't remember the functions to access psif,psic and delta, but you'll find them if you browse the fvPatchField documentation.

fly_light likes this.
schröder is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
fixed gradient of boundary condition in Openfoam nwpukaka OpenFOAM 1 February 20, 2014 03:36
conjugate boundary condition Daniel_Khazaei OpenFOAM Programming & Development 0 December 31, 2013 13:11
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
temperature normal gradient on a boundary Sandrine Main CFD Forum 2 June 10, 2009 16:34
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 15:55

All times are GMT -4. The time now is 06:44.