|
[Sponsors] |
mark region around Gas-Liquid interface for AMR |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 19, 2022, 10:37 |
mark region around Gas-Liquid interface for AMR
|
#1 |
New Member
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5 |
Dear Foamers:
I'd like to refine gas-liquid interface using AMR, but I don't want to use the traditional AMR procedure(refine cells of 0.001<α<0.999 only), as it will only refine cells containning interface(one or two cells thick). I'd like to refine more cells around interface(as shown in the attachment). Therefore, I consider: can I define a scalar field (for example, the field name is regionforefine), and mark the grids at a certain distance near the gas-liquid interface, then assign the regionforefine of these grids to 1 and the regionforefine of other grids to 0, and then specify the grid with 0.5 < regionforefine < 1.5 for refine in dynamicmeshdict. At present, I have written the following codes in the C file of the solver, which can only mark the gas-liquid interface separately, but I have no idea how to expand the marked area inward and outward. Code:
if (alpha[i]>0.001&&alpha[i]<0.999) regionforrefine.field()[i]=1; else regionforrefine.field()[i]=0; Best regards, Feng |
|
April 20, 2022, 18:49 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
For this to work, you have to find all cells within a certain distance to the cells which fullful your critieria (e.g. 0.01 < alpha < 0.99).
You propably would want to use a library like this one: https://github.com/crvs/KDTree implementing KDTrees which are optimise the distance calculation for arbitrary locations. |
|
April 20, 2022, 23:57 |
|
#3 |
New Member
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5 |
Dear Joachim:
Thank you very much for your reply. 'which are optimise the distance calculation for arbitrary locations' The code function you mentioned seems suitable for my problem. However, it seems that this code can not used in OpenFOAM directly, and must be modified for my purpose. As I'm not familiar with C++, the modifying procedure is so hard for me. Thank you all the same, Joachim. Best regards, Feng |
|
April 21, 2022, 00:24 |
|
#4 |
New Member
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5 |
Dear Foamers:
I guess there must exist some Function or Syntax in OpenFOAM that can achieve my needs simply. I found a piece of code at dynamicrefinefvmesh.C(code at the end of this reply), Nbufferlayers here is the number filled in dynamicmeshdict when AMR is executed. The number of buffer layers can be controlled through this code. I think there are some advanced users who are capable of handling my problem simply, and your reply must will shed light on my problem. If I make some progress, I will update in this thread. But I am a beginner for OpenFOAM, there is a high chance that I will fail in the end. Code: // Extend with a buffer layer to prevent neighbouring points // being unrefined. for (label i = 0; i < nBufferLayers; ++i) { extendMarkedCells(refineCell); } Thank you for your attention. Best regards, |
|
May 11, 2022, 17:32 |
|
#5 | |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
With the code you found, you can add the n-next neighbor cells. But this is independent of the size of the cell. If you have a more or less equidistant grid, this could work.
Quote:
|
||
Tags |
amr, scalar field |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table bounds warnings at: END OF TIME STEP | CFXer | CFX | 4 | July 17, 2020 00:44 |
Coupled Heat and Mass Transfer | Mecroob | OpenFOAM Running, Solving & CFD | 1 | July 12, 2020 20:24 |
Domain Reference Pressure and mass flow inlet boundary | AdidaKK | CFX | 75 | August 20, 2018 06:37 |
My radial inflow turbine | Abo Anas | CFX | 27 | May 11, 2018 02:44 |
Modelling interface evaporations between (Hot) gas and volatile liquid Drop | himanshu28 | STAR-CCM+ | 0 | March 14, 2013 12:50 |