# Fix values at a boundary

**URL:** <https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137>\
**Category:** Cases\
**Created:** [14 July 2024 13:38 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137 "2024-07-14T13:38:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [14 July 2024 13:38 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/1 "2024-07-14T13:38:58Z")

</div>

Hello,

how may I fix all the variables at a given boundary to a given value?

Best regards

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [14 July 2024 23:23 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/2 "2024-07-14T23:23:16Z")

</div>

FR is a discontinuous scheme. Fixing values is inconsistent with this; or to put it another way: the fact the values are prescribed at a boundary does not mean that the solution value at that boundary will be the same value as there are _two_ solutions: one from the boundary side and one from the fluid side. As the scheme is discontinuous these can be different while still being consistent with the PDE.

Regards, Freddie.

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [15 July 2024 05:31 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/3 "2024-07-15T05:31:17Z")

</div>

Hi Freddie, thanks a lot for the answer.  
Then I would kindly ask how would you set up a 2d riemann problem? I got correctly the 4 quadrants but after a while the solution at the boundary starts to “smear” out among the edges of the various zones (I’m currently using sup-in-fa as boundary condition for each of the quadrant)

Best regards

---

<div class="post-metadata">

**Author:** ![p.vincent](https://yyz2.discourse-cdn.com/free1/user_avatar/pyfr.discourse.group/p.vincent/32/225_2.png) [@p.vincent](https://pyfr.discourse.group/u/p.vincent)\
**Post date:** [18 July 2024 02:33 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/4 "2024-07-18T02:33:45Z")

</div>

Could you send an image?

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [20 July 2024 08:58 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/5 "2024-07-20T08:58:05Z")

</div>

Yes sure

This is the initial condition

 ![rp-0.0000000000](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/a3fc6b59c24e7e0974ba0d0826c86d53c46be091.jpeg)

and this is the flow that develops

 ![rp-0.4800000000](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/31c38b4640aa63352370db2b49ea3c63df5a9dcc.jpeg)

but I would expect something like this

 ![Screenshot 2024-07-20 at 10.57.22](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/a2ddded455222f47c37b03a5514bb6e66e12045a.png)

Any idea?

Best regards

---

<div class="post-metadata">

**Author:** ![tdzanic](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tdzanic](https://pyfr.discourse.group/u/tdzanic)\
**Post date:** [21 July 2024 01:24 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/6 "2024-07-21T01:24:23Z")

</div>

Have you tried using free (sup-out-fn) BCs or combining it with slip walls for cases that allow it? I believe for that case the flow is parallel/zero along the top and right boundaries, so you could do a slip adiabatic wall there and sup-out-fn BCs on the bottom and left walls if sup-out-fn everywhere doesn’t work (free BCs for all boundaries is typically sensitive to numerical disturbances). The ICs also seem a little strange since your discontinuities aren’t in the center of the domain, is that on purpose?

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [21 July 2024 05:23 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/7 "2024-07-21T05:23:40Z")

</div>

Hi Tarik,

thanks for the answer

> Have you tried using free (sup-out-fn)

Yes but as you pointed out it is subjected to numerical disturbances as you can see in the following picture which refers to a free bc on left and bottom as you recommended but the same happens also with all free bcs.

 ![rp-0.0400000000](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/dceb33db8d2ae901fc190160efab090840849d0a.jpeg)

> The ICs also seem a little strange since your discontinuities aren’t in the center of the domain, is that on purpose?

Yes that was a test with a discontinuity located at x=.8, y=.8 in a [0,1]^2 domain. The picture I sent now is located at x=y=1 in a [0,2]^2 domain, but this is not the cause of the issues

Any further idea on how to solve this?

---

<div class="post-metadata">

**Author:** ![tdzanic](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tdzanic](https://pyfr.discourse.group/u/tdzanic)\
**Post date:** [21 July 2024 05:35 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/8 "2024-07-21T05:35:25Z")

</div>

Could you share the mesh and ini file you’re using?

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [21 July 2024 10:05 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/9 "2024-07-21T10:05:25Z")

</div>

Hi @tdzanic,

thanks for looking into this, mesh and ini file are available at this link

> **[2drp.ini](https://wetransfer.com/downloads/bae2f72bcb9968ef82751148c718237d20240721100417/e5e9da)**
>
> 2 files sent via WeTransfer, the simplest way to send your files around the world

Let me know if you can correctly download them

Best regards

---

<div class="post-metadata">

**Author:** ![tdzanic](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tdzanic](https://pyfr.discourse.group/u/tdzanic)\
**Post date:** [21 July 2024 17:09 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/10 "2024-07-21T17:09:32Z")

</div>

You can prescribe the exact solution at the boundary similarly to what’s done with the double Mach reflection test case, which is the discontinuity propagating at a constant shock speed of roughly `v_s = 0.4221156` (downwards on the left boundary and leftwards on the bottom boundary). The ini file would then have:

```auto
[soln-bcs-bottom]
type = sup-in-fa
t1 = 0.5 * (1 + tanh(1000000 * (x - 1.0 + t*0.4221156)))
rho = r4 * %(t1)s + r3 * (1 - %(t1)s)
u = u4 * %(t1)s + u3 * (1 - %(t1)s)
v = v4 * %(t1)s + v3 * (1 - %(t1)s)
p = p4 * %(t1)s + p3 * (1 - %(t1)s)

[soln-bcs-right]
type = slp-adia-wall

[soln-bcs-top]
type = slp-adia-wall

[soln-bcs-left]
type = sup-in-fa
t1 = 0.5 * (1 + tanh(1000000 * (y - 1.0 + t*0.4221156)))
rho = r2 * %(t1)s + r3 * (1 - %(t1)s)
u = u2 * %(t1)s + u3 * (1 - %(t1)s)
v = v2 * %(t1)s + v3 * (1 - %(t1)s)
p = p2 * %(t1)s + p3 * (1 - %(t1)s)

```

It’s not perfect since you’ll get some numerical artifacts where the numerical solution meets the exact solution at the boundary, but with this, I get these results at `t=1.1`:  
 ![image](https://global.discourse-cdn.com/free1/uploads/pyfr/original/1X/6e6be64a4172d2b4b5151abf2e4e2020039d9850.jpeg)

You can adjust your initial discontinuity in the ICs/BCs as you wish.

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [21 July 2024 18:37 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/11 "2024-07-21T18:37:08Z")

</div>

Hi Tarik,

I’m extremely grateful for your help! Thanks a lot!

Best regards

---

<div class="post-metadata">

**Author:** ![tdzanic](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@tdzanic](https://pyfr.discourse.group/u/tdzanic)\
**Post date:** [21 July 2024 19:49 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/12 "2024-07-21T19:49:17Z")

</div>

No problem. I also noticed that your ini file is running Navier-Stokes with `mu = 0`. Unless you need to evaluate corrected gradients somewhere, you’ll get a pretty large speedup by switching to Euler.

---

<div class="post-metadata">

**Author:** ![Frankx9](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@Frankx9](https://pyfr.discourse.group/u/Frankx9)\
**Post date:** [21 July 2024 20:10 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/13 "2024-07-21T20:10:30Z")

</div>

Thanks for the hint!  
This was just because I was also trying the artificial viscosity and was easier to switch between them (simulations were small)

---

<div class="post-metadata">

**Author:** ![Olaf](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@Olaf](https://pyfr.discourse.group/u/Olaf)\
**Post date:** [3 March 2025 14:43 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/14 "2025-03-03T14:43:49Z")

</div>

is sup-out-fn good for the outlet of an engine intake?. Asuming the outlet is supersonic.

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [3 March 2025 17:01 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/15 "2025-03-03T17:01:38Z")

</div>

If the flow at the outlet is indeed supersonic then it is a reasonable option.

Regards, Freddie.

---

<div class="post-metadata">

**Author:** ![Olaf](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@Olaf](https://pyfr.discourse.group/u/Olaf)\
**Post date:** [11 March 2025 17:34 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/16 "2025-03-11T17:34:55Z")

</div>

Thanks for the answer!

Is it possible in PyFR to declare a wall with a fixed velocity?. in my case I want to create a suction boundary to control de boundary layer separation. In case it is possible what bc would it be?

Thanks a lot for the help!

Regards Olaf.

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [12 March 2025 10:56 UTC](https://pyfr.discourse.group/t/fix-values-at-a-boundary/1137/17 "2025-03-12T10:56:39Z")

</div>

If you mean a wall which is moving with some velocity then this is indeed possible. See the couette flow test case for an example of this.

Regards, Freddie.
