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

Cell minimum side length

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

Like Tree2Likes
  • 1 Post By ngj
  • 1 Post By mturcios777

Reply
 
LinkBack Thread Tools Display Modes
Old   December 7, 2013, 10:23
Default Cell minimum side length
  #1
New Member
 
M. Sabouri
Join Date: Nov 2011
Posts: 22
Rep Power: 5
Moslem is on a distinguished road
Dear Foamers,
Does anybody know a simple way to determine the minimum edge length for a single cell an for the whole mesh?
Thanks.
Moslem is offline   Reply With Quote

Old   December 7, 2013, 11:53
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,608
Rep Power: 25
ngj will become famous soon enoughngj will become famous soon enough
Hello,

Yes, you can do something along these lines:

Code:
// Get needed reference to the mesh
const edgeList& edges = mesh.edges();
const pointField& pp = mesh.points();
const labelListList& cEdges = mesh.cellEdges();

// Make a list with all the edge lenghts
scalarField eLengths(edges.size(), 0.0);

forAll (edges, edgei)
{
    eLengths[edgei] = edges[edgei].mag(pp);
}

// Find the minimum edge length in the whole mesh
scalar minLength = Foam::min(eLengths);

// Find the minimum per cell
scalarField minLengthCells(cEdges.size(), GREAT);

forAll (cEdges, celli)
{
     const labelList& ce = cEdges[celli];

     forAll (ce, edgei)
     {
         minLengthCells[celli] = Foam::min(minLengthCells[celli], eLengths[ce[edgei]]);
     }
}
That is it.

Kind regards,

Niels

P.S. Please note that I have not tried to compile it, so there might be minor blops, but the overall idea gives the requested result.
mm.abdollahzadeh likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   December 7, 2013, 12:31
Default
  #3
New Member
 
M. Sabouri
Join Date: Nov 2011
Posts: 22
Rep Power: 5
Moslem is on a distinguished road
Thank you Niels!
I will try it.
Moslem
Moslem is offline   Reply With Quote

Old   February 23, 2015, 06:30
Default
  #4
Member
 
Naresh Yathuru
Join Date: Feb 2015
Posts: 54
Rep Power: 2
Naresh yathuru is on a distinguished road
hi excuse me for restarting the thread after a long time. i m new to openfoam can some one tell me where to type this above code? i mean in which directory? or in controldict?

Thanks
Naresh yathuru is offline   Reply With Quote

Old   February 23, 2015, 14:16
Default
  #5
New Member
 
M. Sabouri
Join Date: Nov 2011
Posts: 22
Rep Power: 5
Moslem is on a distinguished road
It must be added to a source code.
Moslem is offline   Reply With Quote

Old   February 23, 2015, 14:41
Default
  #6
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
This code would need to be implemented in a utility or solver, then compiled and run on the desired case. You will need to add some kind of output capability for your results, either as a logFile or some kind of field.
Moslem likes this.
mturcios777 is offline   Reply With Quote

Reply

Tags
mesh and grid

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Reynolds Number laliong Main CFD Forum 11 March 19, 2015 12:42
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
code for designing a minimum length shock free nozzle staleyjj1981 Main CFD Forum 0 December 4, 2009 16:53
Turbulence length scale and integral length scale rizhang CFX 1 September 10, 2009 06:38
How to find the length of cell zhou1 FLUENT 0 October 26, 2003 13:42


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