# Can I use periodic boundary conditions for U but not for p?

Cross-posted from Stack Overflow. (https://stackoverflow.com/questions/70686368/can-i-use-periodic-boundary-conditions-for-u-but-not-for-p)

I am trying to numerically compute the drag force around a cylinder due to pressure-driven flow. Here is a crude diagram:

I am using OpenFOAM v2012 (the openfoam.com version, not the openfoam.org version).

For the top and bottom walls, as well as the obstacle in the middle, I have noSlip boundary conditions for U and zeroGradient boundary conditions for p. However for the inlet on the left and the outlet on the right, I would like to have a periodic boundary condition for U, but instead of a periodic boundary condition for p I would instead like to have a pressure drop across the channel of 100. (This comes from dividing the atmospheric pressure, which is roughly 100 000 pascals, by the density of water, which is 1 000 kg/m^3. This is because the p file is not really the pressure, it is actually the pressure divided by the density, sometimes called p bar.)

However when I tried to implement this, I received the error

--> FOAM FATAL IO ERROR: (openfoam-2012 patch=210618)
inconsistent patch and patchField types for
patch type cyclic and patchField type fixedValue

file: /home/killian/foam_run/cylinder_2/0/p.boundaryField.inlet at line 25 to 26.



It appears OpenFOAM is not letting me mix my metaphors. Does anyone know a way around this? I have tried other BCs for U and p but I am running into issues where the solution is blowing up after some time.

Would appreciate any help.

• What is the equation you are trying to solve? Commented Jan 16, 2022 at 20:03
• @WolfgangBangerth Incompressible Navier-Stokes equations. Commented Jan 16, 2022 at 20:23
• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Commented Jan 17, 2022 at 14:38

As far we are in an Incompressible Navier Stokes formulation, The velocity field and the pressure field are related in the domain and on the boundary (I suppose you are using the incompressible solver and hence a projection method algorithm to decouple the velocity and the pressure, in OpenFOAM should be PISO one). Taking the explicit velocity corrector for OpenFOAM you end up with:

$$U^{n+1}=U^n+\nabla P^{n+1}$$

it means that if we impose on the boundary a value of the velocity, to mantain the boundary condition we should have a zerogradient pressure field at the boundary. As far as you are in the incompressible Navier-Stokes case hence, even if we use a decoupling algorithm, the pressure and velocity field are still bounded (in particular the final solution should be divergence free and, the boundary condition should be compatible). To fullfill your goal I would suggest to have a look at this discussion. Hence I suggest you 3 possible solutions:

• to impose the cyclic boundary condition for pressure and velocity and to use an initial forcing and use the right keyword to sustain the flux (that is done pratically in OpenFOAM by adding a source term to the momentum equation MeanVelocityForce in the fvOption dictionary).
• To impose the cyclic boundary conditions and modify the source term of the solved equations yourselves (as suggested here)
• To try a different set of boundary conditions (OpenFOAM has different kind of boundary conditions for inlet/outlet as you can see here). Sometimes they implement a more "practical" approach, so be careful in using them. One possible solution can be: Inlet: (pressure: fixed value, velocity: pressureInletOutletVelocity), Outlet: (pressure: fixed value, velocity: InletOutlet or simply ZeroGradient).

A last warning: in OpenFOAM for cyclic boundary condition pay attention also to your BlockMeshDict or to the generated Mesh files (have always a look at the link I suggested you).

• Thanks for this. However for some reason I am not getting the nice pressure gradient across the pipe, nor am I getting the parabolic flow profile I'm looking for. Is there some way to modify this approach? I will add a section in my question detailing my current progress. Commented Jan 18, 2022 at 10:40
• Edited with other approaches Commented Jan 18, 2022 at 14:34