|
[Sponsors] |
dynamicRefineFvMesh - Protect cells from refinement (boundary) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 3, 2021, 19:04 |
dynamicRefineFvMesh - Protect cells from refinement (boundary)
|
#1 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
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 |
|
March 3, 2021, 20:25 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
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); } } } Caelan
__________________
Public git repository : https://github.com/clapointe2011/public |
|
March 3, 2021, 22:31 |
|
#3 | |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
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:
|
||
March 3, 2021, 22:51 |
|
#4 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
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") 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); } } Caelan
__________________
Public git repository : https://github.com/clapointe2011/public |
|
March 6, 2021, 13:57 |
|
#5 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 11 |
Thank you again, I'm going to test it soon and let you know how it works.
|
|
November 8, 2022, 14:56 |
|
#6 |
New Member
Benedetto Di Paolo
Join Date: Feb 2016
Location: Santander (Spain)
Posts: 4
Rep Power: 10 |
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 |
|
November 8, 2022, 15:48 |
|
#7 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] SnappyHexMesh running killed! | Mark JIN | OpenFOAM Meshing & Mesh Conversion | 7 | June 14, 2022 02:37 |
[snappyHexMesh] snappyHexMesh stuck when snap is turned on | yukuns | OpenFOAM Meshing & Mesh Conversion | 3 | February 2, 2021 14:05 |
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops | avinashjagdale | OpenFOAM Meshing & Mesh Conversion | 53 | March 8, 2019 10:42 |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 10:38 |
RPM in Wind Turbine | Pankaj | CFX | 9 | November 23, 2009 05:05 |