|
[Sponsors] |
September 12, 2023, 19:19 |
Field Laplacian smoothing
|
#1 |
New Member
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4 |
Hello everyone,
I'm trying to write a Laplacian smoothing function that takes a noisy volScalarField f0 and returns a smoothed field f. The following simple code snippet works fine in serial execution. However, it doesn't work as intended in parallel for cells that are adjacent to a processor patch. This is due to the fact that, when looking for the cells j adjacent to cell i, only the cells that belong to the same processor are found. Thus there is a clear "discontinuity" across processor boundaries. Code:
forAll(mesh.cells(), i) { f[i] = f0[i]; forAll(mesh.cellCells()[i],j) { const label k = mesh.cellCells()[i][j]; f[i] += f0[k]; } f[i] /= (1.0+mesh.cellCells()[i].size()); } Thanks! |
|
September 12, 2023, 20:27 |
|
#2 |
Member
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14 |
Hello nikovasi
Does "fvc::smooth" not achieve your goal? It may not be "Laplacian smoothing", but it can smooth volScalarField, etc. see: OpenFOAM-11/src/finiteVolume/finiteVolume/fvc/fvcSmooth/fvcSmooth.H
__________________
Our Work: https://www.idaj.co.jp/product/ennovacfd/openfoam_gui/ Powered by Ennova : https://ennova-cfd.com/ Ennova's Channel Partners : http://www.wolfdynamics.com/ |
|
September 13, 2023, 06:16 |
|
#3 |
New Member
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4 |
Hello LongGe and thanks for your reply.
I have tried to solve my problem with the "fvc::smooth" function. However, "fvc::smooth" takes the smallest field value (which is left unchanged) and propagates it through the domain based on the user defined maximum ratio. This leads to problems when there are large differences between adjacent cells, where "fvc::smooth" propagates the smallest filed value too far. That's why I came up with the idea of Laplacian smoothing. So that small field values increase and large field values decrease based on their adjacent field values. Maybe running my Laplacian smoothing and then fvc::smooth to smooth out any differences across processor boundaries could be a possible solution. |
|
September 13, 2023, 11:01 |
|
#4 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14 |
Nikos - you could try reverse engineer fvSmooth, and see how it manages to address all of the cells, and not just the processor's set. It might be a deep dive into the coding though ...
|
|
September 13, 2023, 15:29 |
|
#5 |
New Member
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4 |
Hello everyone,
I stumbled across the following post which seems to give some possible solutions for smoothing a field over the whole domain. Conservatively Smoothing a Source Term For reference I wrote the following code snippet which seems to work in both serial and parallel. The smoothingPasses variable is used to determine the degree of smoothing, with higher smoothing passes leading to a more smoothed out field. Code:
label smoothingPasses = 5; for (label pass=1; pass<=smoothingPasses; pass++) { f = fvc::average(fvc::interpolate(f0)); f.correctBoundaryConditions(); f0 = f; } |
|
Tags |
parallel calculation, smoothing function |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error: "Source airToporous defined for field h but never used" | Utkan | OpenFOAM Running, Solving & CFD | 2 | April 6, 2022 09:23 |
overPimpleDyMFoam rotating airfoil startup problems | jantheron | OpenFOAM Running, Solving & CFD | 1 | May 20, 2020 05:55 |
potential flows, helmholtz decomposition and other stuffs | pigna | Main CFD Forum | 1 | October 26, 2017 09:34 |
Access to field which is evaluated at the moment | Tobi | OpenFOAM Programming & Development | 6 | April 19, 2017 14:09 |
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL | AndoniBM | OpenFOAM Running, Solving & CFD | 2 | March 25, 2015 19:44 |