- **OpenFOAM Programming & Development**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **Inlet conditions for cyclic problem**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/76219-inlet-conditions-cyclic-problem.html*)

Inlet conditions for cyclic problemHi all,
I made a simple application for the calculation of a fully developped flow in a duct. For this, I created a small piece of duct (2D) and coupled the IN and OUT using cyclic boundary conditions (see some of the other threads to know how). This may be a dumb question, but how can I set the bulk velocity of the flow to some constant in this case ? I have the initial conditions set, but it rapidly converges to a 0 m/s flow regime. thanks |

Hi fluent145,
you are having another problem you might not see at the moment. The pressure field will not be cyclic, when you have some flow. Instead you will have a uniform pressure gradient in your flow direction. Please have a look at openFoam's channelFoam. Its a solver for exactly your problem, handling pressure gradient explicitly. You can set the mean velocity in the domain to the value you want it to be. It's using LES but its not a big deal to make it run with RANS or laminar as well. Good luck, Stefan |

Hi Stefan,
Thanks for the reply. I already looked at the channelFoam example, but I can't figure out how I have to implement a pressure gradient to my field. In the initial conditions (0.org folder) all parameters (even pressure) are set to cyclic. There is however a p.gr file in the "0" directory which holds some scalar values for pressure (I presume for all cells ?), but is this actually used in the program ? I actually wanted to apply some massflow (say velocity) inlet condition and let the program calculate the pressure drop. This way, it seems I have to work the other way around ? |

I don't think you have to work around. The pressure gradient in flow direction is an output of this solver and doesn't have to be initialized. You can give an input for you target mass flow by checking the parameter Ubar in your transportProperties. This is the target mean velocity vector giving the flow direction, too. The pressure gradient in this flow direction will be modified iteratively until this mean velocity is reached. So it's independent of any initial conditions (but, of course, the initial conditions will affect the number of iterations until reaching convergence). The pressure gradient will be saved in uniform/gradP in your time directories.
You can set the pressure field p to uniform 0 for initial condition. This pressure field will have no gradient in your flow direction to satisfy cyclic BC. In the other direction, of course, you can have a gradient. Just check it out. You can save a lot of work using this solver. If there will arise further doubts, please fell free to ask me. Regards, Stefan |

I don't how I can implement this in my simpleFoam application.
Could you maybe tell me step by step how to do this ? |

Hi,
you can build up your code based on channelFoam. Just replace all the terms related to LES through RANS-Terms. You could have a look at simpleFoam to get the expressions you need. Furthermore, if you want to use SIMPLE instead of PISO you can replace it from simpleFoam, too. You must insert the "-flowDirection * gradP" into your UEqn. Take care that rUA you will need for later correction of gradP is the same as 1.0/AU using SIMPLE. Hope it helps, Stefan |

Hi Herbert
First of all, thanks for your attention. Im trying to create a new solver from conjugateHeatFoam, but with the SIMPLE algorithm (for steady state) and adding the ciyclic condition from chanelOodles that allows to fix the average velocity. I have done the first part of my solver: changing the conjugateHeatFoam to SIMPLE algorithm, but when I add the part which calculates the pressure gradient for the cyclic condition I obtain an error due to the class tmp<fvVectorMatrix> and if I change it to fvVectorMatrix, the "clear" operator for the UEqn.clear(); is not available. The UEqn.clear() is necessary for the SIMPLE algorithm. Do you have any idea? I would really thank you. Regards David |

Hi David,
which error is it that you recieve? If you want to access a member that's not available in tmp<fvVectorMatrix> but in fvVectorMatrix try UEqn() istead of UEqn when calling this member. Regards, Stefan |

Hi Stefan
Thank you very much, it works! Now I have another problem, in the solid region, I want to make periodic the temperature gradient instead of temperature. To do that I have thought in solve the temperature field in the fluid region and the temperature gradient field in the solid region. Then, if the temperature gradient is a variable (e.g GT), I would can apply cyclic conditions. I have change the solveEnergy.H solid equation in the following manner: Code:
` // Add solid equation` Code:
` // Add solid equation` Code:
`In file included from Prototipe01.C:63:` Regards David |

Hi David,
I think there are several problems. Firstly fvc::div() will return an volField and no matrix. Only fvm::div(DTSolid*GT) will return a matrix. Secondly I don't understand how you are evaluating GT. Are you solving an equation for this field in order to get cyclic boundary conditions involved? And what boundary conditions are you thinking about to apply for Tsolid? Regards, Stefan |

Hi Stefan
Thanks for reply. I have to say that I'm using conjugateHeatFoam solver. Because I need to apply cyclic conditions to the temperature gradient and not to the temperature Tsolid (in the solid region), I have created a new variable named GT which I want that it be the temperature gradient (surfaceScalarField) and deleted the Tsolid variable. So I want so solve a equation where the variables will be the temperature gradient GT (in the solid region) and the temperature T (in the fluid region). I don't know if there is any other way to specify a cyclic temperature gradient condition. That would be ideal for me, because the temperature b.c for my solid region (a wall duct) are zeroGradient for the outer wall, coupled with fluid for the inner wall and cyclic gradient for the extremes wall. The last one is the one I unknow. Thanks a lot for your help Regards David |

Hi David,
I wonder if you have already solved your problem. If not I would suggest to make an explicit iteration process for the temperature in your solid region instead of applying cyclic conditions. I would create a fixedValue-patch 1 and a fixedGradient-patch 2 and then patch gradient from 1 to 2 and the value form 2 to 1 (I think with an homogenous shift in your case). Normally such iteration converges pretty fast. The advantage of this method is, that you don't have to care about the coupling with fluid region, because you are solving for Tsolid (and not for the gradient). Regards, Stefan |

Hi Stefan
Thanks a lot for your help. I still haven't solved the problem. Your suggestion sounds great! but I have two problems: 1. How I can do that? Do you know if there are any tutorial case or anything similar where I can learn it from? 2. The problem is that the solid region has a heat/volume generation, and the temperature increases along the axial tube direction. Then, the temperature in one patch will be higher than in the other patch, and I cannot patch from one to other. The only thing is equal in both patches is the temperature gradient. That is the reason because I cannot apply a simple cyclic condition for the temperature. I don't know if I am explaining it well. For the fluid region I have used the directMapped condition for both temperature and velocity (for the temperature the outlet is zeroGradient and the inlet is directMapped and averaged to 300). But in the solid region I cannot do the same because I unknow the temperature gradient, I only know that it is cyclic. I really appreciate your help. Regards David |

All times are GMT -4. The time now is 02:59. |