CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to find the cell distance from a patch in openfoam?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Zhiheng Wang

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 23, 2017, 10:26
Default How to find the cell distance from a patch in openfoam?
  #1
Member
 
Phanindra
Join Date: Jan 2013
Posts: 39
Rep Power: 13
phani45 is on a distinguished road
Hi foamers,
can any one of tell me how can we find the distance between an internal cell from an inlet in openfoam
I need to use it as part of my code not as post processing
Regards,
Phanindra
phani45 is offline   Reply With Quote

Old   September 23, 2017, 17:06
Default
  #2
Member
 
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10
Zhiheng Wang is on a distinguished road
label patchID = mesh.boundaryMesh().findPatchID("name of your patch");
labelList InternalFieldNextToPatch = mesh.boundaryMesh()[patchID].faceCells(); //// Gives List of cell IDs label next to patch//////

DynamicList<vector> Distance(0); /// distace betwen face center of patch and cell center of cell next to patch

if ( InternalFieldNextToPatch.size() == mesh.boundaryMesh()[patchID].size() )
// check weather patch size and list of cell ids is same or not/// this code may or may not work after usting refinemesh /////
{
forAll(InternalFieldNextToPatch, I)
{
Distance.append(mesh.C()[InternalFieldNextToPatch[I]] - mesh.Cf().boundaryField()[patchID][I]
}
}
save in some distance.H n include or you can also use

OR use

scalarField Dis = 1.0/mesh.deltaCoeffs().boundaryField()[patchID];

If you are using 4.z, plus or 5.x version at place of boundaryField() use boundaryFieldRef() I hope I did not do any typing mistake in code
Kummi likes this.
Zhiheng Wang is offline   Reply With Quote

Old   September 24, 2017, 07:00
Default Thank you Wang
  #3
Member
 
Phanindra
Join Date: Jan 2013
Posts: 39
Rep Power: 13
phani45 is on a distinguished road
Does the procedure works even for the internal cells and boundary patch distance?
phani45 is offline   Reply With Quote

Old   September 25, 2017, 02:57
Default
  #4
Member
 
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10
Zhiheng Wang is on a distinguished road
Quote:
Originally Posted by phani45 View Post
Does the procedure works even for the internal cells and boundary patch distance?
Yes mesh.deltaCoeffs()[patchID] will give inverse of distance between boundary face n cell center. If you want
Distance between two internal Fields use [cellIDs] if you do not know cellIDs use the code I wrote.
Zhiheng Wang is offline   Reply With Quote

Old   September 25, 2017, 08:00
Default Hi
  #5
Member
 
Phanindra
Join Date: Jan 2013
Posts: 39
Rep Power: 13
phani45 is on a distinguished road
Thanks . I will give it a try
phani45 is offline   Reply With Quote

Reply


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
Find distance from a cell to a Boundary patch oehmu OpenFOAM Programming & Development 1 March 22, 2016 23:47
interFoam running blowing up sandy13 OpenFOAM Running, Solving & CFD 2 May 5, 2015 07:16
createPatch Segmentation Fault (CORE DUMPED) sam.ho OpenFOAM Pre-Processing 2 April 21, 2014 02:01
How to find the flux through each cell in a each boundary patch? Hale OpenFOAM Pre-Processing 0 September 13, 2013 08:52
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 02:34


All times are GMT -4. The time now is 15:27.