|
[Sponsors] |
Locate a cell with a specific wall Distance value |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 28, 2013, 10:26 |
Locate a cell with a specific field value
|
#1 |
Senior Member
M. Montero
Join Date: Mar 2009
Location: Madrid
Posts: 155
Rep Power: 17 |
Hi all,
My intention is know where is the cell with the lowest distance to the wall without using paraFoam. It would give me an indication about where is the problem in the mesh and where I have to change the mesh. Code:
Info<< "Calculating wall distance using wallDist function\n" << endl; wallDist y(mesh, true); Info<< "Writing wall distance to field zDistance" << endl; zDistance.internalField()= y; Info << " Minimum z Distance"<< min(zDistance) << endl; zDistance.write(); Info << "location"<< mesh.findCell(zDistance=??)<< endl; Please, could someone help me. Thanks. Last edited by be_inspired; May 28, 2013 at 11:32. |
|
May 28, 2013, 14:57 |
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi Marcelino,
As far as I know, you have to do a search for the cell in question. The brute-force solution is simply to do the following (note, just written out, it might be adjusted for compilation): Code:
label cellIndex = 0; forAll( mesh.C(), celli ) { if ( y[celli] < y[cellIndex] ) cellIndex = celli; } Info << "The cell index with smallest distance:" << tab << cellIndex << endl; Code:
label cellIndex = 0; forAll( y.boundaryField(), patchi ) { const labelList & faceCells = mesh.boundaryMesh()[patchi].patch().faceCells(); // Something like this, but might not compile. forAll( faceCells, celli ) { if ( y[faceCells[celli]] < y[cellIndex] ) cellIndex = faceCells[celli]; } } Info << "The cell index with smallest distance:" << tab << cellIndex << endl; Niels |
|
May 29, 2013, 06:43 |
|
#3 |
Senior Member
M. Montero
Join Date: Mar 2009
Location: Madrid
Posts: 155
Rep Power: 17 |
Hi Niels,
Thank you very much.I have chosen the second option and works great in a mesh of 20 millions of elements. The only point is that, al least for OF2.1.1, I had to delete a patch() word in one of your code lines. I post the last version here if someone needs the tool or has to modify it for other purposes. Thanks a lot Marcelino Code:
int main( int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" Info<< "Calculating wall distance using wallDist function\n" << endl; wallDist y(mesh, true); y.write(); Info<< "Analyzing minimum cell Distance" << endl; label cellIndex=0; forAll ( y.boundaryField(),patchi) { const labelList & faceCells = mesh.boundaryMesh()[patchi].faceCells(); forAll (faceCells, celli) { if ( y[faceCells[celli]] < y[cellIndex] ) cellIndex = faceCells[celli]; } } Info << "The cell index with smallest distance:" << tab << cellIndex << endl; Info << "Minimum wall distance" << tab << y[cellIndex] << endl; Info << "Location of the cell with minimum wall distance (X Y Z)" << mesh.C()[cellIndex] << endl; return 0; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Natural convection in a closed domain STILL NEEDING help! | Yr0gErG | FLUENT | 4 | December 2, 2019 01:04 |
problem with cyclicAMI and wall distance | Maff | OpenFOAM Bugs | 5 | August 14, 2014 15:41 |
wall layer distance in ICEM HEXA | F.K. | CFX | 0 | November 3, 2004 04:48 |
Multicomponent fluid | Andrea | CFX | 2 | October 11, 2004 06:12 |
distance from the wall to the first grid point | Wenqing Zhang | CFX | 0 | August 9, 2004 11:08 |