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

dynamicRefineFvMesh - Protect cells from refinement (boundary)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 3, 2021, 18:04
Default dynamicRefineFvMesh - Protect cells from refinement (boundary)
  #1
Member
 
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 57
Rep Power: 11
jairoandres is on a distinguished road
Hello Forum

In my AMR case, I want to protect wall-cells from refinement. This basically because the y+ size is well defined there and because of other reasons (I have found issues in OpenFOAM 2012 and older versions when tracking a particle with a containing near-wall cell which is being refined / unrefined).

The protection of wall boundaries has to be done in dynamicRefineFvMesh.C, however, it has given me issues as mesh() is not defined there.

I can assign a SMALL value to the field used for refinement criteria in near-wall cells (already implemented in other thread), but dynamicRefineFvMesh does at least 1-buffer cell refinement, therefore, in many cases, the wall-cells get refined. I don't honestly want to remove the 1-buffer refinement as it would bring many issues. A possible solution would be extending this set value to neighbour cells, but it would hamper the solution accuracy in some regions, so protecting the cells seems a better solution.

I've tried something like this (among many other things) :

forAll(cells(), celli)
{
const cell& cFaces = cells()[celli];

// if (cFaces.nFaces() - cFaces.nInternalFaces() > 0)
if (cFaces.nFaces() - cFaces.nInternalFaces() > 0)
{
protectedCell_.set(celli);
}


}

but, of course, it does not work as nInternalFaces() is not defined for cells() (as nFaces is). I am running out of ideas. I would be very happy to receive feedback on this.

Naturally, using topoSet to selected all boundaryCells and then saving those to a protectedCells file does not work as the cell-protection decision is performed each refining step inside dynamicRefineFvMesh

Thank you for your support
jairoandres is offline   Reply With Quote

Old   March 3, 2021, 19:25
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
What if you looped over patches and checked if they're walls? Something like :

Code:
    //Protect walls
    const fvMesh& mesh(*this);
    const fvPatchList& patches = mesh.boundary();
    forAll(patches, patchi)
    {
        if(isA<wallFvPatch>(patches[patchi]))
        {
            labelList faceCells = patches[patchi].faceCells();

            forAll(patches[patchi], facei)
            {
                label celli = faceCells[facei];
                protectedCell_.set(celli);
            }
        }
    }
Tested the above (make sure to include wallFvPatch.H) with the dam break tutorial and wall cells were not refined.

Caelan
__________________
Public git repository : https://github.com/clapointe2011/public
clapointe is offline   Reply With Quote

Old   March 3, 2021, 21:31
Default
  #3
Member
 
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 57
Rep Power: 11
jairoandres is on a distinguished road
Dear Caelan, thank you very much, it worked just fine!. I was looking at the code because I expected OF to write the protected cells, but anyway, it does not matter. I owe you part of the last objective of my PhD thesis .

I remember I tried something similar to what you posted, but my mistake was not defining the fvMesh& using "(*this)".

I suppose it is possible to include below "if(isA<wallFvPatch>(patches[patchi]))", a specific walll patch name (for example walls1, or walls2?), right?

By the way, nice github contributions.

Best regards from Bogota,

J.A. Gutiérrez.

Quote:
Originally Posted by clapointe View Post
What if you looped over patches and checked if they're walls? Something like :

Code:
    //Protect walls
    const fvMesh& mesh(*this);
    const fvPatchList& patches = mesh.boundary();
    forAll(patches, patchi)
    {
        if(isA<wallFvPatch>(patches[patchi]))
        {
            labelList faceCells = patches[patchi].faceCells();

            forAll(patches[patchi], facei)
            {
                label celli = faceCells[facei];
                protectedCell_.set(celli);
            }
        }
    }
Tested the above (make sure to include wallFvPatch.H) with the dam break tutorial and wall cells were not refined.

Caelan
jairoandres is offline   Reply With Quote

Old   March 3, 2021, 21:51
Default
  #4
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
I'm sure there's a nicer way to do it, but a quick hard code would be something like :

Code:
if (patches[patchi].name() == "wall1")
Given that the above comparison is hard coded, you could probably grab a list of patch names from dynamicMeshDict instead... if you went that route, you could do something like :

Code:
    //Protect some walls
    const fvMesh& mesh(*this);
    forAll(patchList, namei)
    {
        label patchLabel = mesh.boundaryMesh().findPatchID(patchList[namei]);
        const fvPatch& patch = mesh.boundary()[patchLabel];
                           
        forAll(patch,facei)
	{
            label celli = patch.faceCells()[facei];
	    protectedCell_.set(celli);
	}
    }
Note that I've not tested the above code (and pieced it together from various snippets) -- you'd also need to create the wordList "patchList" somewhere. Good luck with the rest of your thesis!

Caelan
__________________
Public git repository : https://github.com/clapointe2011/public
clapointe is offline   Reply With Quote

Old   March 6, 2021, 12:57
Default
  #5
Member
 
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 57
Rep Power: 11
jairoandres is on a distinguished road
Thank you again, I'm going to test it soon and let you know how it works.
jairoandres is offline   Reply With Quote

Old   November 8, 2022, 13:56
Default
  #6
New Member
 
Benedetto Di Paolo
Join Date: Feb 2016
Location: Santander (Spain)
Posts: 4
Rep Power: 10
benedip is on a distinguished road
Hi,

I guess this only works for the first cell at the wall, right? I mean, it prevent just the first cell layer not to be refined right? Not the entire boundary layer mesh. The loop is done over the cells adjacent to the wall if I'm not wrong

Can you just confirm if so?
Regards
Benedetto
benedip is offline   Reply With Quote

Old   November 8, 2022, 14:48
Default
  #7
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
One could use the wall distance field ( see the spalart allmaras model how to create it https://www.openfoam.com/documentati...s.html#details ) the shield the cells from refinement. Maybe this helps

Best

Michael
mAlletto is offline   Reply With Quote

Reply


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
[snappyHexMesh] SnappyHexMesh running killed! Mark JIN OpenFOAM Meshing & Mesh Conversion 7 June 14, 2022 01:37
[snappyHexMesh] snappyHexMesh stuck when snap is turned on yukuns OpenFOAM Meshing & Mesh Conversion 3 February 2, 2021 13:05
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops avinashjagdale OpenFOAM Meshing & Mesh Conversion 53 March 8, 2019 09:42
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 09:38
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 04:05


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