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

Search adjacent cells and assign

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 31, 2020, 03:49
Default Search adjacent cells and assign
  #1
New Member
 
Join Date: Mar 2020
Posts: 20
Rep Power: 3
loving_cfd is on a distinguished road
Hello, my dears.

I want to loop over all the cell in the computational domain, search the four or eight neighbor cells and assign at each timestep.

It can be implemented in Fluent via the macros of c_face_loop and C_F0.

How about on OpenFOAM?
loving_cfd is offline   Reply With Quote

Old   March 31, 2020, 12:06
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 486
Rep Power: 11
clapointe is on a distinguished road
Neighbour cells can be accessed via cellCells(). So off the top of my head it would be something like :

Code:
forAll(mesh.C(), celli) //outer, all cell loop
{
    label curCell = mesh.C()[celli];

    labelList curNeiCells = mesh.cellCells()[curCell];

    forAll(curNeiCells, cellj) //inner, neighbor cell loop
    {
         do something here...
    }
}
There might be a more elegant way to do it, but looping is pretty straightforward. Of course, the first loop doesn't have to be all cells if you already have a list of cells in mind.

Caelan
clapointe is offline   Reply With Quote

Old   April 14, 2020, 04:21
Default reply to Caelan
  #3
New Member
 
Join Date: Mar 2020
Posts: 20
Rep Power: 3
loving_cfd is on a distinguished road
Dear Caelan,

Appreciate for your relpy!

Your reply help me learn more on OpenFOAM.

I will try the method on my program and share the result with you.

Best wishes!
loving_cfd is offline   Reply With Quote

Reply

Tags
cell, openfoam, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mass source term to boundary cells adjacent to a wall Kimia Fluent UDF and Scheme Programming 7 November 15, 2020 10:53
decomposePar: how to distribute cells unevenly? floquation OpenFOAM Pre-Processing 4 February 25, 2017 04:15
How to assign different values for every cells in a part of the domain clktp OpenFOAM Pre-Processing 0 April 1, 2016 11:45
assign values to selected cells zxj160 OpenFOAM Pre-Processing 4 June 29, 2012 12:17
How to Reference an Adjacent Cell in a UDF ? jeff8541 FLUENT 0 March 8, 2011 10:33


All times are GMT -4. The time now is 23:26.