|
[Sponsors] |
August 21, 2018, 03:17 |
how to use grad P at boundary faces
|
#1 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
Hi Foamers
I have a very simple problem. I want to access grad P at boundary faces. Code: Info<< fvc::grad(pf) << endl; Output: dimensions [0 1 -2 0 0 0 0]; internalField nonuniform List<vector> 4((1.92787 -1.80556 0) (1.92787 1.80538 0) (5.53881 -1.80556 0) (5.53881 1.80538 0)); boundaryField { movingWall { type extrapolatedCalculated; value nonuniform List<vector> 2((5.53881 0 0) (5.53881 0 0)); } fixedWalls { type extrapolatedCalculated; value nonuniform List<vector> 6((0 -1.80556 0) (0 -1.80556 0) (0 1.80538 0) (0 1.80538 0) (1.92787 0 0) (1.92787 0 0)); } frontAndback { type empty; } } So I can access grad(P) of interior faces like: Code: forAll(fluidRegions[0].owner(), faceI) { Info<< fvc::grad(pf)()[faceI] <<endl; } Output: (1.92787 -1.80556 0) (1.92787 1.80538 0) (5.53881 -1.80556 0) (5.53881 1.80538 0) Similarly I want to write a face loop for all the boundary faces and want to print grad(P). How can I do that? |
|
August 21, 2018, 18:01 |
|
#2 |
New Member
Join Date: Nov 2016
Posts: 15
Rep Power: 10 |
The shitty solution would be to get the patchID for every patch:
Code:
label patchLabel1 = mesh.boundaryMesh().findPatchID("boundary1") label patchLabel2 = mesh.boundaryMesh().findPatchID("boundary2") Code:
forAll (U.boundaryField()[patchLabel1], faceI) { // code } forAll (U.boundaryField()[patchLabel2], faceI) { // code } |
|
August 23, 2018, 02:35 |
|
#3 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
Hey Thanks for Reply
I get how to write the boundary face loop. But I still didn't get how to get grad(p) at boundary. I try using Info<< fvc::grad(pf).boundaryField()[faceI] <<endl; But it gives error like boundaryField is not defined in this class. However when I simply give command like Info<< fvc::grad(pf) <<endl; Then it give output as dimensions [0 1 -2 0 0 0 0]; internalField nonuniform List<vector> 4((1.92787 -1.80556 0) (1.92787 1.80538 0) (5.53881 -1.80556 0) (5.53881 1.80538 0)); boundaryField { movingWall { type extrapolatedCalculated; value nonuniform List<vector> 2((5.53881 0 0) (5.53881 0 0)); } fixedWalls { type extrapolatedCalculated; value nonuniform List<vector> 6((0 -1.80556 0) (0 -1.80556 0) (0 1.80538 0) (0 1.80538 0) (1.92787 0 0) (1.92787 0 0)); } frontAndback { type empty; } } This means the boundary field information is stored in grad(P). However I dont know how to use it. Can you help me with that? |
|
August 23, 2018, 04:50 |
|
#4 |
New Member
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12 |
Hey,
If you need grad(p) on the patch, something like this should work (I didn't test it, sorry): Code:
// Find your patch label patchID = mesh.boundaryMesh().findPatchID("yourPatch"); if(patchID == -1) { FatalError << "patch not found!" << exit(FatalError); } // Print p gradient on the patch forAll(p.boundaryFieldRef()[patchID], faceI) { Info<<p.boundaryFieldRef()[patchID].snGrad()()[faceI]<<endl; } Artem |
|
August 23, 2018, 05:04 |
|
#5 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
.snGrad() gives you the surface normal gradient, which is not equal to the gradient. The surface normal gradient at the boundary is defined as the difference between the cell center value and the boundary face center value divided by the distance between the cell center and the face center. It is described in the programmer guide.
|
|
August 25, 2018, 02:45 |
|
#6 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
With lot of try and error I found this solution,
Code: Info<< fvc::grad(pf)().boundaryField()[0] << endl; Output: type extrapolatedCalculated; value nonuniform List<vector> 2((5.53881 0 0) (5.53881 0 0)); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
Foam::error::PrintStack | almir | OpenFOAM Running, Solving & CFD | 92 | May 21, 2024 08:56 |
[snappyHexMesh] sHM layer process keeps getting killed | MBttR | OpenFOAM Meshing & Mesh Conversion | 4 | August 15, 2016 04:21 |
[OpenFOAM.org] OF2.3.1 + OS13.2 - Trying to use the dummy Pstream library | aylalisa | OpenFOAM Installation | 23 | June 15, 2015 15:49 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 18:11 |