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

[Technical] How to identify cell neighbours

Register Blogs Community New Posts Updated Threads Search

Like Tree30Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 11, 2010, 23:02
Default
  #21
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Quote:
Originally Posted by yashar.afarin View Post
Hi Su

how I could export my data so that I could specify and link for each point(cell centre) , the position(x,y,z) and velocity(u,v,w) variables of that point as a same file?
// include the head file
#include"OFstream.H"

//declare a object and out the variable you want. file.dat is the name of the //file you need.

OFstream os("file.dat");

forAll(mesh.C(), i)
{
os<<mesh.C()[i] <<" " <<u[i]<<endl;
}
songwukong and SH_Zhong like this.
su_junwei is offline   Reply With Quote

Old   January 17, 2011, 05:10
Default
  #22
Member
 
Yashar Afarin
Join Date: May 2010
Location: Toronto- Canada
Posts: 40
Rep Power: 16
yashar.afarin is on a distinguished road
Send a message via Skype™ to yashar.afarin
Hi SU

thank you very much for all of your helps.
I would appreciate if you could answer my question.
I have calculated Umean by introducing a function at system/controlDict of my case and I can see its contour with paraFoam.
how I could export it (UMean) to a .dat file, similar to my last question about U ?
yashar.afarin is offline   Reply With Quote

Old   January 17, 2011, 05:56
Default
  #23
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Quote:
Originally Posted by yashar.afarin View Post
Hi SU

thank you very much for all of your helps.
I would appreciate if you could answer my question.
I have calculated Umean by introducing a function at system/controlDict of my case and I can see its contour with paraFoam.
how I could export it (UMean) to a .dat file, similar to my last question about U ?
You don't have to process UMean. It should be in the time dir in your case.
su_junwei is offline   Reply With Quote

Old   January 17, 2011, 07:02
Default
  #24
Member
 
Yashar Afarin
Join Date: May 2010
Location: Toronto- Canada
Posts: 40
Rep Power: 16
yashar.afarin is on a distinguished road
Send a message via Skype™ to yashar.afarin
Quote:
Originally Posted by su_junwei View Post
You don't have to process UMean. It should be in the time dir in your case.
yes, it's there but I want to export it to a file.dat. according to your reply I export U of each point but I don't know how I could do that again for UMean?
I would appreciate if you could help me.
yashar.afarin is offline   Reply With Quote

Old   January 17, 2011, 07:55
Default
  #25
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Quote:
Originally Posted by yashar.afarin View Post
yes, it's there but I want to export it to a file.dat. according to your reply I export U of each point but I don't know how I could do that again for UMean?
I would appreciate if you could help me.
Just copy the internalField to a seperate file name *.dat

If you want to do it using a program, Just write a small tool for post processing. Read the file and write the internalField to a file

OFstream os("file.dat");

forAll(UMean.C(), i)
{
os<<mesh.C()[i] <<" " <<UMean[i]<<endl;
}
songwukong likes this.
su_junwei is offline   Reply With Quote

Old   January 17, 2011, 08:35
Default
  #26
Member
 
Yashar Afarin
Join Date: May 2010
Location: Toronto- Canada
Posts: 40
Rep Power: 16
yashar.afarin is on a distinguished road
Send a message via Skype™ to yashar.afarin
Quote:
Originally Posted by su_junwei View Post
Just copy the internalField to a seperate file name *.dat

If you want to do it using a program, Just write a small tool for post processing. Read the file and write the internalField to a file

OFstream os("file.dat");

forAll(UMean.C(), i)
{
os<<mesh.C()[i] <<" " <<UMean[i]<<endl;
}
thank you very much for your reply.
I wrote the code that you sent for me in applications/solvers/incompressible/pisoFoam/pisoFoam.C
but when I compiled it, an error would be reported:
write.H:55: error: ‘UMean’ was not declared in this scope

I cant understand what is the problem, plz give me help!

Last edited by yashar.afarin; January 17, 2011 at 09:41.
yashar.afarin is offline   Reply With Quote

Old   January 17, 2011, 10:43
Default
  #27
Member
 
Yashar Afarin
Join Date: May 2010
Location: Toronto- Canada
Posts: 40
Rep Power: 16
yashar.afarin is on a distinguished road
Send a message via Skype™ to yashar.afarin
I am sorry. that was my silly reply. I know what you mean now. thanks for your reply.
yashar.afarin is offline   Reply With Quote

Old   February 22, 2011, 14:53
Default problems with mesh.cellCells()
  #28
New Member
 
Rudi T.
Join Date: Feb 2011
Location: Munich, Bavaria
Posts: 3
Rep Power: 15
daZigeiner is on a distinguished road
Quote:
Originally Posted by su_junwei View Post
Hi Khaled

mesh.cellCells()[cellI] gives the neighbours of cell cellI

su junwei
Hi Su

I'm just working on a possibility to refine locally on a selection of the mesh (blockMesh with refinementIterator). Since I have higher refinement levels I need to lay some buffer-layers around the selection. For this purpose I use the cellCells() function in multiple iterations.

My problem is that cellCells() does not recognize all neighbours of already refined cells (The refinement history I have implemented works fine and has no bugs) .

I'll give a little example:

- 8 cells (= refinement level 3) on the west side of a simple refined cell (= 2 cells f.e. cell A and B).
- this should give cell A as eastern neighbour for four of the tripple refined cells and cell B for the other four cells
- instead of this cellCells returns only cell A as eastern neighbour for all eight cells!!

And now the really big problem:

This bug is not reproduceable, since the correct recognition of all neighbours works fine in the mesh of forwardStep (tutorials/compressible/rhoCentralFo...), but not in the mesh of counterFlow2D (tutorials/combustion/reactingFoam...)
daZigeiner is offline   Reply With Quote

Old   May 22, 2011, 20:22
Default
  #29
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Quote:
Originally Posted by su_junwei View Post
// include the head file
#include"OFstream.H"

//declare a object and out the variable you want. file.dat is the name of the //file you need.

OFstream os("file.dat");

forAll(mesh.C(), i)
{
os<<mesh.C()[i] <<" " <<u[i]<<endl;
}
Hi Su,
Is it possible describe it more for me?
Where should be written this code and how should it be compiled?
maysmech is offline   Reply With Quote

Old   May 22, 2011, 22:38
Default
  #30
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
just write it in the time cycle. os declaration can be written in creatFields. H

You can write it like the following code

if(runTime.outputTime()) //only write at outputTime point
{
forAll(mesh.C(), i)
{
os<<mesh.C()[i] <<" " <<u[i]<<endl;
}
}
songwukong likes this.
su_junwei is offline   Reply With Quote

Old   January 7, 2012, 18:24
Default
  #31
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 16
robingilbert is on a distinguished road
Quote:
Originally Posted by kathrin_kissling View Post
Hi Pascal,

alternatively you can use

label labelOfClosestCell mesh.findCell(c y z);


Best Kathrin
Kathrin,

I am getting the following error when I use this:

Code:
transientSimpleFoam.C: In function ‘int main(int, char**)’:
transientSimpleFoam.C:123: error: expected initializer before ‘mesh’
transientSimpleFoam.C:124: error: ‘labelOfClosestCell’ was not declared in this scope
Any ideas why this is happening?

Thank you.
robingilbert is offline   Reply With Quote

Old   January 8, 2012, 12:08
Default
  #32
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
I think something is wrong with my formatting:
const point& location = (x,y,z); //your coordinates
label labelOfClosestCell=mesh.findCell(location);

Can you post your code?

Thanks!

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   January 8, 2012, 15:52
Default
  #33
Member
 
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 16
robingilbert is on a distinguished road
Kathrin,

Thanks for your reply. It was indeed the problem with the way I specified my location. I got it working.
Thank you.
robingilbert is offline   Reply With Quote

Old   May 23, 2012, 07:18
Default
  #34
Member
 
Kim Yusik
Join Date: Dec 2009
Posts: 39
Rep Power: 16
impecca is on a distinguished road
Hi, Junwei

I am trying to access the neighbour cells with parallel computing but it seems the cell which is placed adjacent to the interface between sub-domains does not recognize all neighbour cells.
I followed the same as you mentioned which is briefly (I am using OF-2.1.x),

mesh.cellCells()[cellI]

So I am wondering that you have a similar experience and is there any possible solution on this?

I also posted the question on this issue but I haven't got respose so far.

http://www.cfd-online.com/Forums/ope...computing.html


Thanks in advance.
Yusik
impecca is offline   Reply With Quote

Old   August 14, 2012, 10:56
Default
  #35
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15
mathslw is on a distinguished road
Quote:
Originally Posted by su_junwei View Post
Hi Pascal
you can use the following code

meshSearch ms(mesh);
label nearestCellIndex = ms.findNearestCell(p);

p is your point for searching nearest cell. nearestCellIndex is the cell index that you want.
Don't forget to include "meshSearch.H"

Junwei
Hi Junwei,

Could the p be a face in the internal field. If it could be, how can I define it?
Many thanks!

Wei
mathslw is offline   Reply With Quote

Old   October 2, 2012, 12:39
Default X, Y and Z of each cell
  #36
Member
 
,...
Join Date: Apr 2011
Posts: 92
Rep Power: 14
hawkeye321 is an unknown quantity at this point
hey, does anyone know how can I get the x, y and z of each cell?
hawkeye321 is offline   Reply With Quote

Old   September 23, 2013, 20:44
Default
  #37
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15
mathslw is on a distinguished road
Hi Junwei

As I see, the cellCells gives the list of index, my question is how could distinguish them?
thanks

Wei

Quote:
Originally Posted by su_junwei View Post
Hi Khaled

mesh.cellCells()[cellI] gives the neighbours of cell cellI

su junwei
mathslw is offline   Reply With Quote

Old   September 25, 2013, 02:31
Default
  #38
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 20
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
The return value is a list of index of neighbor cells. cells can be distinguished from another from cell index, cell center, etc.
su_junwei is offline   Reply With Quote

Old   May 5, 2014, 15:38
Default
  #39
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13
CHARLES is on a distinguished road
I'm confused about how to access a specific cell using cellCells. For example, how can I use cellCells to access the NORTH cell of each cell in my domain?

Here's an example of what I would like to do... I know that the code may not compile, I'm just trying to explain what I'm doing.

Code:
V=value; //V is a boundary field ('value' is calculated and varies across the domain)

forAll(U, celli)
{
U[celli]=V[celli];
U[NORTH of celli] = U[celli];
}
CHARLES is offline   Reply With Quote

Old   December 19, 2014, 01:58
Default
  #40
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15
babakflame is on a distinguished road
Quote:
Originally Posted by su_junwei View Post
Hi Pascal
you can use the following code

meshSearch ms(mesh);
label nearestCellIndex = ms.findNearestCell(p);

p is your point for searching nearest cell. nearestCellIndex is the cell index that you want.
Don't forget to include "meshSearch.H"

Junwei

Greeting Su

Is it possible to detail your hint more clearly?
I guess that the meshSearch.H should be added to the main code for instance reactingFoam.C . But what about

Code:
meshSearch ms(mesh); 
    label nearestCellIndex = ms.findNearestCell(p);
Where should I add these lines?

Thanks for your hints.


Best,
Bobi
babakflame 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
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
Determining cell neighbours on unstructured grid orxan.shibli Main CFD Forum 4 September 25, 2011 05:29
Help Me, what's the Cell Above any given cell in 3D. gomane8 Main CFD Forum 3 September 11, 2011 21:29
neighbours of a cell Asghari FLUENT 17 October 7, 2010 17:41
neighbours of a cell Asghari FLUENT 0 July 9, 2006 13:28


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