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

Getting node of a position

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By l_r_mcglashan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 2, 2013, 15:39
Default Getting node of a position
  #1
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
How do you find the grid point that is near a location?
The purpose is to calculate space correlation of a turbulence field which means:

Code:
R(r)=<u(x)u(x+r)>/<u(x)^2>
anishtain4 is offline   Reply With Quote

Old   March 2, 2013, 23:28
Default The most easiest way
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
I think the most easiest way to do your job is the following:

Code:
    vector pos(0.0,0.0,0.0); //Change the position as you like
    scalar limitLeng = 0.1;  //Change the value as you like

    const cellList& Cells = mesh.cells();
    const pointField& Points = mesh.points();

    forAll(Cells, cellI)
    {
        if(mag(mesh.C()[cellI] - pos) < limitLeng)
        {
            forAll(mesh.cellPoints()[cellI], pointi)
            {
                //You can access labels of cell vertices
                label pointI = mesh.cellPoints()[cellI][pointi];
                scalar r = mag(pos - Points[pointI]);

                //your stuff
            }
        }
    }
Please post the codes, if there are more efficient ways.

Hope that helps,
Fumiya
fumiya is offline   Reply With Quote

Old   March 3, 2013, 07:37
Default
  #3
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
The above code is unreliable, as the answer will be dependent on limitLeng. You are also not considering the situation where the nearest point to the location you are looking up may not be a part of the cell that it is inside of, although that will depend on how your mesh was constructed.

primitiveMesh has a findCell function. Use that instead.

If you want something more efficient then meshSearch uses an octree method for faster lookup. It doesn't work in parallel though so the location you lookup must be within the local mesh.
anishtain4 and fumiya like this.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan 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
mpirun, best parameters pablodecastillo Hardware 18 November 10, 2016 12:36
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 09:46
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 01:29
License server not visible from master node Charles FLUENT 0 October 30, 2007 17:48
Combustion Convergence problems Art Stretton Phoenics 5 April 2, 2002 05:59


All times are GMT -4. The time now is 18:46.