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

All cells connected via edge to cell.

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 21, 2014, 17:01
Default All cells connected via edge to cell.
  #1
New Member
 
sebastien vilfayeau
Join Date: Feb 2012
Posts: 11
Rep Power: 6
sebastien_F1 is on a distinguished road
Hi everyone,

I would like to calculate the average of neighbour cells connected by edge. I already know how to do the average of neighbour cells connected by face:

labelListList neighbour = this->mesh().cellCells();

However, I cannot find those connected by edge.

Let me know if you have any hint.
Best,
Sebastien
sebastien_F1 is offline   Reply With Quote

Old   August 21, 2014, 20:05
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 320
Rep Power: 10
kmooney is on a distinguished road
Quote:
Originally Posted by sebastien_F1 View Post
Hi everyone,

I would like to calculate the average of neighbour cells connected by edge. I already know how to do the average of neighbour cells connected by face:

labelListList neighbour = this->mesh().cellCells();

However, I cannot find those connected by edge.

Let me know if you have any hint.
Best,
Sebastien
Hi Sebastien,

You could start by taking a look at /src/OpenFOAM/lnInclude/primitiveMesh.H

There you should be able to spot a lot of useful connectivity information, including the cellCells function which you seem to have already discovered.

With a combination of edgeCells and cellEdges you should be able to assemble a data structure which suits your needs.

I hope that helps!
Cheers,
Kyle
kmooney is offline   Reply With Quote

Old   August 27, 2014, 11:22
Default
  #3
New Member
 
sebastien vilfayeau
Join Date: Feb 2012
Posts: 11
Rep Power: 6
sebastien_F1 is on a distinguished road
Hi Kyle,

Thanks for the advice. I have already explored this class. But I was wondering if someone already put all the piece together and do a smart filtering to not count for duplicate cells.

I did it. Here is my piece of code to calculate average with cells connected by edge or points.

Quote:
/****Calculate an average temperature with neighboor cells****/

avgT_ = dimensionedScalar("b",dimTemperature,0.0);

forAll(T_tilde_.internalField(),celli)
{
// Construct cellEdges
DynamicList<label> cellStorage;
//labelList neighborEdge = this->mesh().cellEdges()[celli];
labelList neighborEdge = this->mesh().cellPoints()[celli];

cellStorage.clear();

//Do quadratic insertion
forAll(neighborEdge, edgej)
{
//labelList neighborCell = this->mesh().edgeCells()[neighborEdge[edgej]];
labelList neighborCell = this->mesh().pointCells()[neighborEdge[edgej]];

forAll(neighborCell, cellj)
{
label ownCellI = neighborCell[cellj];

//Check if not already in storage
forAll(cellStorage, j)
{
if(cellStorage[j] == ownCellI)
{
ownCellI = -1;
break;
}
}
//if not, add to the storage list
if (ownCellI != -1)
{
cellStorage.append(ownCellI);
}
}
}
// Calculate the average of cells connected via edge or points
forAll(cellStorage, cellk)
{
avgT_[celli] += T_tilde_[cellStorage[cellk]];
}
avgT_[celli] /= cellStorage.size();
//Info << "Cell neighboor = " << cellStorage.size() << endl;
//Info << "Cell = " << celli << endl;
}
/************************************************** ******/
Best
Sebastien
sebastien_F1 is offline   Reply With Quote

Old   August 27, 2014, 12:27
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,713
Rep Power: 27
ngj will become famous soon enoughngj will become famous soon enough
Hi Sebastian,

A small word of warning:

Your averaging is based on the number of cells with a uniform weighting. You might want to perform a weighting by cell volumes on non-equidistant meshes.

You can also find the volume in the primitive mesh class, which Kyle pointed to.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is online now   Reply With Quote

Reply

Tags
edges, neighboring cell

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
No layers in a small gap bobburnquist OpenFOAM Native Meshers: snappyHexMesh and Others 6 August 26, 2015 09:38
Snappy creates strange cells far away from boundary vainilreb OpenFOAM Native Meshers: snappyHexMesh and Others 1 February 14, 2013 05:44
snappyHexMesh in parallel - FOAM Fatal IO Error mturcios777 OpenFOAM Running, Solving & CFD 4 August 10, 2012 19:18
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
physical boundary error!! kris CD-adapco 2 August 3, 2005 00:32


All times are GMT -4. The time now is 11:02.