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

mark region around Gas-Liquid interface for AMR

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2022, 10:37
Talking mark region around Gas-Liquid interface for AMR
  #1
New Member
 
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5
fengyi is on a distinguished road
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
Attached Images
File Type: png mark region I need.png (54.4 KB, 8 views)
fengyi is offline   Reply With Quote

Old   April 20, 2022, 18:49
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
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.
jherb is offline   Reply With Quote

Old   April 20, 2022, 23:57
Default
  #3
New Member
 
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5
fengyi is on a distinguished road
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
fengyi is offline   Reply With Quote

Old   April 21, 2022, 00:24
Default
  #4
New Member
 
Feng
Join Date: Aug 2021
Posts: 8
Rep Power: 5
fengyi is on a distinguished road
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,
fengyi is offline   Reply With Quote

Old   May 11, 2022, 17:32
Default
  #5
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
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:
Originally Posted by fengyi View Post
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,
jherb is offline   Reply With Quote

Reply

Tags
amr, scalar field

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


All times are GMT -4. The time now is 04:50.