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

Field Laplacian smoothing

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

Like Tree4Likes
  • 1 Post By LongGe
  • 1 Post By Tobermory
  • 2 Post By nikovasi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 12, 2023, 19:19
Question Field Laplacian smoothing
  #1
New Member
 
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4
nikovasi is on a distinguished road
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());
    }
Is there a way to perform the implement the above smoothing function in parallel?

Thanks!
nikovasi is offline   Reply With Quote

Old   September 12, 2023, 20:27
Default
  #2
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
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
nikovasi likes this.
__________________
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/
LongGe is offline   Reply With Quote

Old   September 13, 2023, 06:16
Post
  #3
New Member
 
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4
nikovasi is on a distinguished road
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.
nikovasi is offline   Reply With Quote

Old   September 13, 2023, 11:01
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 742
Rep Power: 14
Tobermory will become famous soon enough
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 ...
nikovasi likes this.
Tobermory is offline   Reply With Quote

Old   September 13, 2023, 15:29
Post
  #5
New Member
 
Nikos Vasileiadis
Join Date: May 2022
Posts: 5
Rep Power: 4
nikovasi is on a distinguished road
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;
    }
LongGe and Tobermory like this.
nikovasi is offline   Reply With Quote

Reply

Tags
parallel calculation, smoothing function

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
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


All times are GMT -4. The time now is 20:14.