Example for Dam breaking
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
Example for Dam breaking
Hi, I am sort of new to Code Saturne, though I have finished some simple simulation of non-Newtonian simulation in axisymmetric tube by modifying the SRC.
I have wandered for several days on the internet in the search for possible tutorial/information/example of Dam Breaking or material slumping with Code_Saturne. However I am still very confused about where to start.
For case of Dam Breaking in OpenFoam, https://cfd.direct/openfoam/user-guide/v7-dambreak/ it is possible to assign the phase fraction (alpha) in space directly. I am not sure how to achieve it in CS. Does it have something to do with "Interior to boundary faces(boundary insertion)" and the setting of the "porosity" of specific volume? Should I assign the ALE Free Surface at the internal boundary together with the Homogeneous Eulerian VoF model?
Or, should I define the phase fraction in any subroutine?
Maybe the question is sort of simple or even silly, but it is really quite frustrated finding no relevant resources. If it can be done easily I can upload some example for the future tutorial. Otherwise I would have to go to another hell of OpenFoam
Thank you very much.
PoChun Tseng
I have wandered for several days on the internet in the search for possible tutorial/information/example of Dam Breaking or material slumping with Code_Saturne. However I am still very confused about where to start.
For case of Dam Breaking in OpenFoam, https://cfd.direct/openfoam/user-guide/v7-dambreak/ it is possible to assign the phase fraction (alpha) in space directly. I am not sure how to achieve it in CS. Does it have something to do with "Interior to boundary faces(boundary insertion)" and the setting of the "porosity" of specific volume? Should I assign the ALE Free Surface at the internal boundary together with the Homogeneous Eulerian VoF model?
Or, should I define the phase fraction in any subroutine?
Maybe the question is sort of simple or even silly, but it is really quite frustrated finding no relevant resources. If it can be done easily I can upload some example for the future tutorial. Otherwise I would have to go to another hell of OpenFoam
Thank you very much.
PoChun Tseng
-
- Posts: 4070
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Example for Dam breaking
Hello,
Did you search for VoF posts in this forum ? I seem to remember there were a few questions on this subject some months ago.
I am not familar with the use of VoF in code_saturne, so I can only suggest ways of searching, and if you really find nothing useful, I can try to remind some people who have worked on this to check your post.
In any case, VoF has no relation to boundary insertion (which is a mesh prepossessing operation). I am not sure about the reltion to "porosity", but porosity can be used in many applications outside of VoF in any case.
Also VoF and ALE are alternative and independent approaches, so I do not believe you need to assign an ALE Free Surface.
Best regards,
Yvan
Did you search for VoF posts in this forum ? I seem to remember there were a few questions on this subject some months ago.
I am not familar with the use of VoF in code_saturne, so I can only suggest ways of searching, and if you really find nothing useful, I can try to remind some people who have worked on this to check your post.
In any case, VoF has no relation to boundary insertion (which is a mesh prepossessing operation). I am not sure about the reltion to "porosity", but porosity can be used in many applications outside of VoF in any case.
Also VoF and ALE are alternative and independent approaches, so I do not believe you need to assign an ALE Free Surface.
Best regards,
Yvan
Re: Example for Dam breaking
Dear Yvan,
Thank you for the rapid reply. I found the clue to go on after a more detailed search of the recent post.
I have found the key info from a post in 2019. viewtopic.php?p=13658
In the post, Luciano pointed out that
If I selected the VoF model in gui, should I still set the variable ivofmt = 0 in cs_user_parameters.f90?
Besides, I tried to specify the ivolf2 in different volume zones cs_user_initialization.f90. However, the SRC failed at call getcel(’2’, nlelt, lstelt) in the early stage and a syntax error was reported. Could you please help me figure it out?
I am using CS 6.0.6 in Ubuntu. The result is attached for reference.
Thank you very much.
Sincerely,
Po-Chun
Thank you for the rapid reply. I found the clue to go on after a more detailed search of the recent post.
I have found the key info from a post in 2019. viewtopic.php?p=13658
In the post, Luciano pointed out that
The remaining questions are:To activate VOF you have to set the variable ivofmt = 0 using the cs_user_parameters.f90 routine and the void fraction is store in the ivolf2 array.
If I selected the VoF model in gui, should I still set the variable ivofmt = 0 in cs_user_parameters.f90?
Besides, I tried to specify the ivolf2 in different volume zones cs_user_initialization.f90. However, the SRC failed at call getcel(’2’, nlelt, lstelt) in the early stage and a syntax error was reported. Could you please help me figure it out?
I am using CS 6.0.6 in Ubuntu. The result is attached for reference.
Thank you very much.
Sincerely,
Po-Chun
- Attachments
-
- 20210529-2315.zip
- (4.53 KiB) Downloaded 100 times
-
- Posts: 4070
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Example for Dam breaking
Hello,
you need to add :
use cs_c_bindings
in the "Module files" section of the file to avoid the syntax error.
If you set it using the GUI, you should not need to set ivofmt (looking at the sources, it seems it is set by the GUI). In any case, user subroutines have priority over the GUI (they are called after so can overwrite/complete settings).
Best regards,
Yvan
you need to add :
use cs_c_bindings
in the "Module files" section of the file to avoid the syntax error.
If you set it using the GUI, you should not need to set ivofmt (looking at the sources, it seems it is set by the GUI). In any case, user subroutines have priority over the GUI (they are called after so can overwrite/complete settings).
Best regards,
Yvan
Re: Example for Dam breaking
Hello,
Thank you again for the reply. The SRC still failed with a Syntax error in argument list after adding use cs_c_bindings in the Module files section.
Thank you very much.
PoChun
Thank you again for the reply. The SRC still failed with a Syntax error in argument list after adding use cs_c_bindings in the Module files section.
Should I attach other files or information to aid in the troubleshooting?use cs_c_bindings
integer nvar , nscal
integer nlelt , iel, iel2nd
double precision dt(ncelet)
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: cvar_voidf
allocate(lstelt(ncel)) ! temporary array for cells selection
call getcel(’2’, nlelt, lstelt)
1
Error: Syntax error in argument list at (1)
Thank you very much.
PoChun
- Attachments
-
- 20210530-1032.zip
- (4.54 KiB) Downloaded 107 times
-
- Posts: 280
- Joined: Fri Dec 04, 2015 1:42 pm
Re: Example for Dam breaking
Hello,
May be I am wrong, but I think that you should use single quotes '...' for string criteria and not single closing quotes ’..’.
Regards,
Luciano
May be I am wrong, but I think that you should use single quotes '...' for string criteria and not single closing quotes ’..’.
Regards,
Luciano
Re: Example for Dam breaking
Thank you Luciano for pointing out my mistake.
Your answer indeed solved the problem. I am quite excited now
I reproduced the mistake because I copied the getcel example directly from the PDF practical user's guide (3.9.4 Using selection criteria in user subroutines) without through checking.
Anyway, later I will post more details about how to use VoF for newbies like me.
Sincerely,
PoChun
Your answer indeed solved the problem. I am quite excited now
I reproduced the mistake because I copied the getcel example directly from the PDF practical user's guide (3.9.4 Using selection criteria in user subroutines) without through checking.
Anyway, later I will post more details about how to use VoF for newbies like me.
Sincerely,
PoChun
Last edited by hsnu1137 on Sun May 30, 2021 10:19 am, edited 1 time in total.
Re: Example for Dam breaking
For those interested in the Homogeneous Eulerian VoF/Volume of fluid method,
I may share some simple steps here.
First in GUI:
example code:
The first argument of getcel may be the selection criteria in Volume zones
i.e. the 'volume group' created by Salome-Mesh, or something direct like 'box[0.01, 0.01, 0, 0.03, 0.03, 0.02]' as the link below
https://www.code-saturne.org/cms/sites/ ... ect_c.html
Best,
PoChun
I may share some simple steps here.
First in GUI:
- Select Homogeneous Eulerian VoF in Claculation features
- Assign Gravity in Body forces
- Assign Density&Viscosity of the two fluids (fully filled with μ1 means: void fraction=0)
example code:
With the code we may initialize specific volume zone filled with the first fluid with getcel.implicit none
! Arguments
integer nvar , nscal
integer nlelt , iel, iel2nd
double precision dt(ncelet)
! Local variables
! INSERT_VARIABLE_DEFINITIONS_HERE
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: cvar_voidf
!===============================================================================
! Initialization
!===============================================================================
allocate(lstelt(ncel)) ! temporary array for cells selection
! INSERT_MAIN_CODE_HERE
!--------
! Formats
!--------
! getcel('1 or 2', nlelt, lstelt) select cells
call getcel('box[0.01, 0.01, 0, 0.03, 0.03, 0.02]', nlelt, lstelt)
call field_get_val_s(ivarfl(ivolf2), cvar_voidf)
! Assign void to the whole volume first
do iel = 1, ncel
cvar_voidf(iel) = 1
enddo
! Assign non-void to the selected volume then
do iel = 1, nlelt
iel2nd = lstelt(iel)
cvar_voidf(iel2nd) = 0
enddo
The first argument of getcel may be the selection criteria in Volume zones
i.e. the 'volume group' created by Salome-Mesh, or something direct like 'box[0.01, 0.01, 0, 0.03, 0.03, 0.02]' as the link below
https://www.code-saturne.org/cms/sites/ ... ect_c.html
Best,
PoChun
Last edited by hsnu1137 on Sun May 30, 2021 11:11 am, edited 1 time in total.
Re: Example for Dam breaking
By the way,
I encountered the same problem as the post viewtopic.php?p=15275 while adding an inlet.
The concept is quite strange because I thought the array ivolf2 applies to the cell only...
Best regards,
PoChun
I encountered the same problem as the post viewtopic.php?p=15275 while adding an inlet.
Should I use getfbr to assign the void_fraction to the boundary face of inlet?@ At least one boundary face declared as inlet (or
@ outlet) with prescribed velocity with an entering
@ flow for which the value of void_fraction has not been
@ specified (Dirichlet condition).
@ The calculation will not be run.
The concept is quite strange because I thought the array ivolf2 applies to the cell only...
Best regards,
PoChun
-
- Posts: 280
- Joined: Fri Dec 04, 2015 1:42 pm
Re: Example for Dam breaking
Hello,
But you are solving the dam break problem, you don't need an inlet boundary condition.
Check this post(viewtopic.php?f=2&t=2830) where I set the void fraction to an inlet boundary condition.
Regards,
Luciano
But you are solving the dam break problem, you don't need an inlet boundary condition.
Check this post(viewtopic.php?f=2&t=2830) where I set the void fraction to an inlet boundary condition.
Regards,
Luciano