Setting periodic boundary conditions

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
VDavid
Posts: 9
Joined: Wed May 04, 2022 11:07 am

Setting periodic boundary conditions

Post by VDavid »

Hello,

I am new to code_saturne and I am trying to simulate the flow over a series of urban street canyon (gaps between buildings). To do that, I chose to apply periodic boundary conditions between the inlet and outlet faces ('West' and 'East').
When I launch the simulation, those periodicities seem to be well defined, nevertheless the velocity inside my mesh stays at zero during the whole calculation. I think it might be due to my Boundary condition I set at the inlet 'West' (fixed horizontal velocity normal to the face).

Could you maybe help me out in finding the problem?

I have attached my setup file, my mesh and an extract from my listing.

Thanks so much in advance!

Bonne journée,

Victor
Attachments
extrait_listing.txt
(3.24 KiB) Downloaded 96 times
Mesh.jpg
setup.xml
(11.97 KiB) Downloaded 94 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Setting periodic boundary conditions

Post by Yvan Fournier »

Hello,

If your inlet and outlet are periodic, they are not boundary faces anymore, so boundary conditions on those faces will be ignored (0 face will be selected).

Your 2 options are:

- use a source term to drive the flow
- instead of "true" periodicity, use a "mapped inlet" to "recycle" the flow from outlet to inlet.

I recommend starting with the 2nd option, which is simpler and can be done in the GUI.

Best regards,

Yvan
VDavid
Posts: 9
Joined: Wed May 04, 2022 11:07 am

Re: Setting periodic boundary conditions

Post by VDavid »

Hello Yvan, thank you so much for your reply, I have now made the periodicity work and the simulation runs fine!
The only issue I have left is when setting my boundary condition at the top of the domain. I want to impose a tangential velocity component Ux = 8 m/s at z = 180 m (so at the top boundary), which should drive the flow through shear. However, this value is never actually reached and the flow still ends up slowing down after a certain number of iterations (see picture).
I have tried setting up this boundary condition using either a moving wall, or an inlet condition with a tangential velocity, none of them give me the correct value. The flow inside the domain is initialized at 8 m/s.

Am I missing something? Should I define my boundary condition otherwise?

Thanks a lot in advance!

Best regards,

Victor
Attachments
Capture.PNG
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Setting periodic boundary conditions

Post by Yvan Fournier »

Hello,

Is this a turbulent or laminar flow ? In the turbulent case, wall laws probably mean the actual prescribed value is less than that of the wall, due to the wall law. In laminar (or resolved) cases, the velocity near the wall should be closer to that you prescribed (and probably getting closer as you refine the mesh).

Best regards,

Yvan
VDavid
Posts: 9
Joined: Wed May 04, 2022 11:07 am

Re: Setting periodic boundary conditions

Post by VDavid »

Hello,

The flow is fully turbulent, so the problem might be due to the wall function, as you pointed out.

In case of the inlet type boundary condition with a tangential component (acting as a regular dirichlet), would that be the same problem? Would there also be some sort of wall function created?

Best regards,

Victor
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Setting periodic boundary conditions

Post by Yvan Fournier »

Hello,

If you want a driving force acting along the wall, you need a no-slip wall condition rather with a sliding wall rather than in inlet condition. The inlet can have a tangential component, but must also have a normal coponent.

To use a Dirichlet (rather than wall function) based no slip condition (cs_user_boundary_condition.f90), you need to use a user-defined function, so as to modify the "icodcl" conditon from 3 to 1 along the matching wall. But this only makes sense if your mesh is wall-resolved. Otherwise, using your initial setting is probably closer to reality.

If you want to impose a velocity in a periodic flow without needing a sliding wall (which is a completely different type of flow, as flow will be faster in the center instead of slower), you need to apply a source term to compensate for wall friction, and if you search for "periodicity" in this forum, you may find some quite old solution, which is still valid. Otherwise, using a mapped inlet can be done from the GUI.

Best Regards,

Yvan
VDavid
Posts: 9
Joined: Wed May 04, 2022 11:07 am

Re: Setting periodic boundary conditions

Post by VDavid »

Hello Yvan,

Thank you very much for your helpful answers! I have managed defining a horizontal inlet BC by activating the atmospheric module and giving the code a meteorological file containing a simple 1D velocity profile with only horizontal U-components. Right now, it looks like code saturne reads the velocity value at the top of the domain from that file and keeps it as BC during the calculation. Maybe it is the loophole that will solve my problem :D

Again, thanks a lot for your help!

Best regards,

Victor
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Setting periodic boundary conditions

Post by Yvan Fournier »

Hello,

If your flow is driven only by a "top" boundary condition and you have friction on the ground and possibly energy dissipation elsewhere, and nothing to account for the pressure gradient on the sides, it is quite possible that the velocity in you domain will be lower than what you expect, so you should check that the U-components seem correct.

Best regards,

Yvan
VDavid
Posts: 9
Joined: Wed May 04, 2022 11:07 am

Re: Setting periodic boundary conditions

Post by VDavid »

Hello Yvan,

I have now changed my approach to a source term. I defined a group of cells called 'Source_cells' on the top of the domain, where the velocity in x direction should be 8 m/s. I wrote that term into the ustsnv subroutine of cs_user_source_term.f90.
However, the value reached after convergence is still not larger than 3.6 m/s.
I added my Fortran routine as an attachment, could you please maybe check if I missed something?

Thank you very much in advance!

Bonne journée,

Victor
cs_user_source_terms.f90
(7.67 KiB) Downloaded 108 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Setting periodic boundary conditions

Post by Yvan Fournier »

Hello,

I'll won't be able to check before middle of next week.

Best regards,

Yvan
Post Reply