Non-uniform temperature BC

I would like to run a simulation where some of the walls have an imposed temperature gradient on them. I noticed that such a boundary condition is not available yet. I wonder if the following code could do it: (never mind the wrong indentations, I couldnt display it properly here)

     class NavierStokesNoSlpTprofileWallBCInters(NavierStokesBaseBCInters):
        type = 'no-slp-Tprofilewall'
        cflux_state = 'ghost'

            def __init__(self, be, lhs, elemap, cfgsect, cfg):
            super().__init__(be, lhs, elemap, cfgsect, cfg)

            self.c.update(
            self._exp_opts(['cpTw', 'u', 'v', 'w'][:self.ndims + 1], lhs,
            default={'u': 0, 'v': 0, 'w': 0}
	    )
            )

if this code should Work, I would be thankful for any instructions on how to incorporate this into my version of pyfr. I am working a linux machine and pyfr was installed using pip.

Nathan

It looks like that will probably work, although type is used to specify the name of the mako macro used in the BC kernel. To avoid having to make a new macro you could just modify an existing BC otherwise you can just copy pyfr/solvers/navstokes/kernels/bcs/no-slp-isot-wall.mako to pyfr/solvers/navstokes/kernels/bcs/no-slp-Tproilewall.mako. That should do it.

To answer your question on how to modify pyfr on a Linux system, the best way is to probably follow something along these lines.

Prequesites:

These are not exhaustive but the major ones are:

  • git fork of pyfr
  • python version 3.x, x>=7 seems to work fine for me.
  • MPI (it is a reasonable idea to compile this your self. Personally I use UCX and then OpenMPI compiled with UCX aware.)

Steps

  • Make a python virtual environment: $ python3.8 -m venv pyfr_venv && cd pyfr_venv
  • Activate the venv: $ . ./bin/activate
  • Install some requirements for pyfr: $ pip install mpi4py h5py (for some reason I find you have to explicitly do these ones).
  • Install pyfr for the dependencies and then uninstall: $ pip install pyfr && pip uninstall pyfr
  • Clone you pyfr fork: $ git clone <some git repo> && cd PyFR
  • Install pyfr from the local version you just cloned: $ pip install -e .

That should do it, although I haven’t tested it exactly. Once you’ve done that you’ll be in a directory called /pyfr_venv/PyFR, inside of which is all the src for pyfr.

Let me know how you get on.

thank you for your answer Will
This indeed worked, although the macro file also required a bit of tweaking. I am attaching the revised mako code at the end of this message.

regarding the installation, what worked for us was installing the cloned version using the setup file (“Python setup.py install”) rather then via pip. maybe we were not giving the correct command when we tried installing via pip

Yep, I missed a . from the the pip install -e line. I have fixed this now.

Also if you want to include a code snippet a nice way to do it is by using backquotes. For inline code you can do:

Some text and then `inline code`

or to use a code block like I just did you use triple backquotes ```code```.

1 Like