# PyFR boundary conditions for turbomachinery

**URL:** <https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961>\
**Category:** Cases\
**Tags:** config, compressible\
**Created:** [27 October 2023 15:28 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961 "2023-10-27T15:28:49Z")\
**Posts on this page:** 14\
**Page:** 3

<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:** [18 January 2024 20:54 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/41 "2024-01-18T20:54:30Z")

</div>

You can try inspecting the reference snapshot solution files and seeing if there is a configuration file stack (as in previous configurations that had been used as part of the start up procedure). These may have the information you are looking for.

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:** [26 January 2024 12:49 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/42 "2024-01-26T12:49:12Z")

</div>

Hi @fdw,

in the snapshots unfortunately there was not such value.

One question: is it feasible (even if not in the current version of pyFR) to copy just a part of the soln from the GPU memory?

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:** [26 January 2024 14:30 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/43 "2024-01-26T14:30:25Z")

</div>

It depends what parts. Requesting scattered values will be very inefficient (and may be slower than requesting the entire solution) since it requires a large number of small copies. Requesting small contiguous parts can be efficient, but elements are not contiguous (so asking for an element with 64 solution points requires 64 copy operations). None of these interfaces are wired up in PyFR at the moment, however.

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:** [26 January 2024 14:56 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/44 "2024-01-26T14:56:53Z")

</div>

Hi @fdw,

thanks for the answer.  
And what about view matrices to access all the elements on a given boundary for a given partition at once? How can these be setted up, if possible?

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:** [26 January 2024 15:15 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/45 "2024-01-26T15:15:37Z")

</div>

Use an `XchgView` to pack the data (on the GPU) into a contiguous matrix and then copy this matrix back to the host. This is exactly how PyFR handles communication between MPI ranks (pack the scattered data into a buffer and then send it over the network).

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:** [26 January 2024 15:39 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/46 "2024-01-26T15:39:38Z")

</div>

Hi @fdw,

the issue is that this in my understading does not fall into any of the categories:

```auto
        self._scal_lhs = self._scal_xchg_view(lhs, 'get_scal_fpts_for_inter')
        self._scal_rhs = be.xchg_matrix_for_view(self._scal_lhs)

```

or

```auto
        self._vect_lhs = self._vect_xchg_view(lhs, 'get_vect_fpts_for_inter')
        self._vect_rhs = be.xchg_matrix_for_view(self._vect_lhs)

```

otherwise kernel will see a scalar or a vector, am I right?

I should introduce a modified view to achieve that and then use xchg\_matrix\_for\_view on this “new” view?

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:** [28 January 2024 00:12 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/47 "2024-01-28T00:12:22Z")

</div>

Your case falls exactly into `get_scal_fpts_for_inter`. Vector is if you want to access gradient quantities. However, you have indicated that you want the solution at the boundary points.

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:** [28 January 2024 10:13 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/48 "2024-01-28T10:13:03Z")

</div>

Hi @fdw,

> However, you have indicated that you want the solution at the boundary points.

you’re right but I was going by easier steps and I was satisfied with the boundary state `ur` for now and later I was planning in doing something similar to the fluid force plugin but even in that case in the actual code I don’t see any predefined way to reference only those elements that have a given boundary, am I right? If so how can this be accomplished?

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:** [28 January 2024 13:14 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/49 "2024-01-28T13:14:17Z")

</div>

The fluid force plugin does exactly this. See:

> <https://github.com/PyFR/PyFR/blob/09eff9370758d4ea1e3d853978949f30933a6bb2/pyfr/plugins/fluidforce.py#L88>

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:** [28 January 2024 13:24 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/50 "2024-01-28T13:24:56Z")

</div>

I was speaking of the kernel side, not the plugin side

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:** [28 January 2024 13:27 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/51 "2024-01-28T13:27:05Z")

</div>

On the kernel side you need to create a view as I showed in my above post.

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:** [28 January 2024 13:29 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/52 "2024-01-28T13:29:13Z")

</div>

Which one?

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:** [28 January 2024 13:41 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/53 "2024-01-28T13:41:29Z")

</div>

As I said in my above post this is the view you want:

> <https://github.com/PyFR/PyFR/blob/09eff9370758d4ea1e3d853978949f30933a6bb2/pyfr/solvers/baseadvec/inters.py#L55>

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:** [28 January 2024 14:22 UTC](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961/54 "2024-01-28T14:22:52Z")

</div>

Hi @fdw,

I’ve introduced this lines in the `BaseAdvectionBCInters`

```auto
        self._scal_lhs_pi = self._scal_xchg_view(lhs, 'get_scal_fpts_for_inter')
        self.kernels['scal_fpts_pack_pi'] = lambda: be.kernel(
        'pack', self._scal_lhs_pi
        )
        bc_fpts_tag = next(self._mpi_tag_counter)
        lhsrank = 0 # Mesh is not partitioned
        self.mpireqs['bc_fpts_send_pi'] = lambda: self._scal_lhs_pi.sendreq(
            lhsrank, bc_fpts_tag
        )

```

then in the

```auto
        g2.add_all(k['bcint/scal_fpts_pack_pi'])
        for send, pack in zip(m['bc_fpts_send_pi'], k['bcint/scal_fpts_pack_pi']):
            g2.add_mpi_req(send, deps=[pack])
        g2.add_all(k['bcint/controller'], deps=k['bcint/comm_flux'] + k['bcint/scal_fpts_pack_pi'])
        g2.add_all(k['bcint/scal_fpts_unpack_pi'])

```

just before

```auto
g2.commit()

```

the values to the `bcint/controller` are passed as:

```auto
            self.kernels['controller'] = lambda: self._be.kernel(
                'controller', tplargs=self._tplargs, dims=[self.ninterfpts],
                extrns=self._external_args, ul=self._scal_lhs_pi, nl=self._pnorm_lhs,
                **self._external_vals
            )

```

In this way the controller kernel should see al the boundary fpts at once?

Best regards

[Previous page](https://pyfr.discourse.group/t/pyfr-boundary-conditions-for-turbomachinery/961.md?page=2)
