|
[Sponsors] |
December 11, 2012, 15:11 |
Accessing neighbor cells fields
|
#1 |
New Member
Join Date: Oct 2011
Posts: 27
Rep Power: 14 |
Hello all,
I am trying to do an average of cells neighbors. For instance, if I want to get an average of Temperature in the internal field I can easily type Code:
sum(T.internalField())/mesh.nCells() What could be the function to do it just in cell neighbors? Could it be inside geometricField.C? Thanks! António |
|
December 11, 2012, 15:37 |
|
#2 |
Member
|
I think you need to do a bit more for that:
const labelList& neighbour = mesh.cellCells()[celli] scalar sum = scalar(0); forAll(neighbour,i) { sum += T[neighbour[i]]; } sum /= neighbour.size(); And loop over all the cells with that will give you an average of cell neighbours. You can find more of functions relating to the mesh information in primitiveMesh class. Duong |
|
December 11, 2012, 15:41 |
|
#3 |
New Member
Join Date: Oct 2011
Posts: 27
Rep Power: 14 |
thanks a lot, I will give it a try!
Antonio |
|
May 13, 2015, 17:53 |
|
#4 |
New Member
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16 |
This a nice implementation, but, in parallel, it does not recognize neighbour cells if they are in subdomains different from the one of the central cell. Is there a simple implementation to address this problem?
|
|
January 20, 2018, 14:45 |
find neighbours in parallel
|
#5 |
Member
Thomas Flint
Join Date: Jan 2016
Posts: 60
Rep Power: 10 |
I think if you use field.correctBoundaryConditions(); it will work OK. Where field is the new neighbour field you assign.
This works fine for me All the best |
|
April 30, 2021, 13:55 |
|
#6 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 8 |
Hello everybody, for a new hybrid turbulence model I also need to calculate the mean of the current and neighboring cells. I am curious if there is a more efficient way doing the average instead of using a forAll loop?
|
|
May 3, 2021, 02:16 |
|
#7 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
Walk each internal face, get owner/neighbour locations and use that to add to the output (in two locations) and the neighbour count (again in two locations). After that walk the boundary faces (owner only). Finally, iterate across the boundary patches, adding in the off-processor information. Finalise your output field by preforming the averaging operation. Depending on what you need, interpolate cell vales to the faces and vol reconstruct from them could also be an interesting thing to look at. |
||
May 3, 2021, 03:14 |
|
#8 | |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 8 |
Quote:
Code:
volScalarField VTMav = fvc::surfaceSum(this->mesh().magSf() * fvc::interpolate(VTM(gradU))) / fvc::surfaceSum(this->mesh().magSf()); |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Time averaged fields on a defined time range | Yann | OpenFOAM Post-Processing | 8 | August 7, 2019 04:46 |
Accessing fields and dictionaries from within a BC implementation | alberto | OpenFOAM Running, Solving & CFD | 12 | December 6, 2011 09:30 |
Missing fields in reconstructPar | flowris | OpenFOAM | 1 | July 9, 2010 02:48 |
domainIntegrate, dieselFoam and Lagrangian Fields | mturcios777 | OpenFOAM | 0 | May 14, 2010 15:16 |
PostChannel | maka | OpenFOAM Post-Processing | 5 | July 22, 2009 09:15 |