Shock sensor: ZeroDivisionError: float division by zero

Hi, i’m sukyung.

I’m conducting a compressible analysis of Reynolds number =15,000 and Mach number = 0.6.

As attached below, it was performed normally in pseudo scheme: rk34, multip=[(4,1)].
However, after changing to pseudo scheme: tvd-rk3, multip= [(4, 1), (3, 1), (2, 1), (1, 5), (0, 5), (1, 3), (2, 3), (2, 3), (3, 3), (4, 4)], “ZeroDivisionError: float division by zero” was obtained.
When only the pseudo scheme was changed, an error did not occur, so it is considered to be related to multip.

Is multip also applicable in the navier-stokes system? So what is the way to solve zerodivision error?

I want to accelerate the convergence of analysis. What are some things that can be applied for convergence?

[backend]
precision = single ;double
rank-allocator = linear

[backend-cuda]
device-id = local-rank ;round-robin

[constants]
gamma = 1.2941
Pr = 0.72
Uin= 135.737408 ;m/s
Vin= 38.922076 ;m/s
w = 0.0

Pc = 51.3756 ;pa
rhoc= 0.0012 ;kg/m^3
mu = 1.370e-5
cpTref =230401 ;j~ * K
cpTs = 187359.12

[solver]
system = navier-stokes ;compressible n-s
order = 4 ;order of polynomial solution basis
;anti-alias = flux
viscosity-correction = sutherland ;none
shock-capturing = artificial-viscosity ;none

[solver-artificial-viscosity]
max-artvisc = 0.01
s0 = 0.01
kappa = 5.0

[solver-time-integrator]
formulation = dual
scheme =sdirk33 ;sdirk34
pseudo-scheme = rk34 ;
tstart = 0.0
tend = 155.1


dt =4e-4 ;
pseudo-dt = 1e-8  ;


controller = none
pseudo-niters-min = 1
pseudo-niters-max = 10
pseudo-resid-norm = l2 ;uniform ;l2
pseudo-resid-tol = 1e-4 ;1e-8 ;
;;pseudo-resid-tol-p = 1.0 ;;;;;;
pseudo-controller = none  ;local-pi ;
;;atol = 1e-6 ;1e-3
;;safety-fact = 0.9
;;min-fact = 0.99 ;0.3
;;max-fact = 1.005 ;2.5
;;pseudo-dt-max-mult = 2.5



[solver-dual-time-integrator-multip]
pseudo-dt-fact = 2.3
;cycle = [(1, 1)]
;;cycle = [(2, 1), (1, 1), (0, 2), (1, 1), (2, 1)]
;;cycle = [(3, 1), (2, 1), (1, 1), (0, 2), (1, 1), (2, 1), (3, 3)]
;;cycle = [(3, 1), (2, 2), (1, 4), (0, 8), (1, 4), (2, 2), (3, 1)]
cycle=[(4,1)]
;cycle = [(4, 1), (3, 1), (2, 1), (1, 1), (0, 5), (1, 2), (2, 2), (3, 2), (4, 4)] ;working p4
;cycle = [(4, 1), (3, 1), (2, 1), (1, 1), (0, 10), (1, 2), (2, 2), (3, 2), (4, 4)] ;working p4

[solver-interfaces]
riemann-solver = rusanov
ldg-beta = 0.5 ;0.5 ;idk
ldg-tau = 0.1 ;0.1 ;idk



[solver-interfaces-line]
flux-pts = gauss-legendre
quad-deg = 11
quad-pts = gauss-legendreP1

[solver-interfaces-tri]
flux-pts = williams-shunn
quad-deg = 11
quad-pts = williams-shunn

[solver-interfaces-quad]
flux-pts = gauss-legendre
quad-deg = 11
quad-pts = gauss-legendre

[solver-elements-tri]
soln-pts = williams-shunn

[solver-elements-quad]
soln-pts = gauss-legendre

[solver-elements-hex]
soln-pts = gauss-legendre
quad-deg = 11
quad-pts = gauss-legendre

[solver-elements-tet]
soln-pts = shunn-ham
quad-deg = 11
quad-pts = shunn-ham

[solver-elements-pri]
soln-pts = williams-shunn~gauss-legendre
quad-deg = 11
quad-pts = williams-shunn~gauss-legendre

[solver-elements-pyr]
soln-pts = gauss-legendre
quad-deg = 11
quad-pts = witherden-vincent



[soln-plugin-writer]
dt-out = 1.0
basedir = .
basename = {t:.2f}


[soln-plugin-tavg-1]
nsteps = 10
dt-out = 1.0
tstart = 80.0
mode = continuous
basedir = .
basename = tavg-{t:04.2f}

avg-p = p
avg-u = u
avg-v = v
;avg-w = w

avg-pp = p*p
avg-uu = u*u
avg-uv = u*v
;avg-uw = u*w
avg-vv = v*v
;avg-vw = v*w
;avg-ww = w*w

fun-avg-upup = uu - u*u
fun-avg-upvp = uv - u*v
;fun-avg-upwp = uw - u*w
fun-avg-vpvp = vv - v*v
;fun-avg-vpwp = vw - v*w
;fun-avg-wpwp = ww - w*w
fun-avg-urms = sqrt(uu - u*u + vv - v*v)
;fun-avg-urms = sqrt(uu - u*u + vv - v*v +ww - w*w)




[soln-plugin-nancheck]
nsteps = 10

;[soln-plugin-residual]
;nsteps = 10
;file = residual.csv
;header = true

[soln-plugin-pseudostats]
flushsteps = 100
file = residual2.csv
header = true

[soln-plugin-fluidforce-upper]
nsteps = 100
file = upper_forces2.csv
header = true
morigin = (0.25, 0.0, 0.0)

[soln-plugin-fluidforce-lower]
nsteps = 100
file = lower_forces2.csv
header = true
morigin = (0.25, 0.0, 0.0)


[soln-bcs-inlet]
type = char-riem-inv
rho = rhoc
u = Uin
v = Vin
w = 0
p = Pc

[soln-bcs-outlet]
type = char-riem-inv
rho = rhoc
u = Uin
v = Vin
w = 0
p = Pc

[soln-bcs-upper]
type = no-slp-adia-wall

[soln-bcs-lower]
type = no-slp-adia-wall

[soln-ics]
rho = rhoc
u = Uin
v = Vin
w = 0
p = Pc
[solver-time-integrator]
formulation = dual
scheme =sdirk33 ;sdirk34
pseudo-scheme = tvd-rk3 ;
tstart = 0.0
tend = 50.001
dt =4e-4 ;
pseudo-dt = 1e-8  ;
controller = none
pseudo-niters-min = 1
pseudo-niters-max = 10
pseudo-resid-norm = l2 ;uniform ;l2
pseudo-resid-tol = 1e-5 ;1e-8 ;
pseudo-resid-tol-p = 1e-2 ;;;;;;
pseudo-controller = none 

[solver-dual-time-integrator-multip]
pseudo-dt-fact = 1.5
cycle = [(4, 1), (3, 1), (2, 1), (1, 5), (0, 5),(1, 3), (2, 3), (3, 3), (4, 4)] ;working p4
mpirun -np 4 pyfr restart -b cuda -p clf5605.pyfrm 12.00.pyfrs Re15000_M06_tvd.ini 
Traceback (most recent call last):
  File "/home/sk/python3.11/pyfr/bin/pyfr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/__main__.py", line 118, in main
    args.process(args)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/__main__.py", line 270, in process_restart
    _process_common(args, mesh, soln, cfg)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/__main__.py", line 236, in _process_common
    solver = get_solver(backend, rallocs, mesh, soln, cfg)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/solvers/__init__.py", line 16, in get_solver
    return get_integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/__init__.py", line 36, in get_integrator
    return integrator(backend, systemcls, rallocs, mesh, initsoln, cfg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/phys/controllers.py", line 8, in __init__
    super().__init__(*args, **kwargs)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/phys/steppers.py", line 16, in __init__
    super().__init__(*args, **kwargs)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/phys/base.py", line 16, in __init__
    self.pseudointegrator = get_pseudo_integrator(
                            ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/pseudo/__init__.py", line 58, in get_pseudo_integrator
    return DualMultiPIntegrator(backend, systemcls, rallocs, mesh,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/pseudo/multip.py", line 121, in __init__
    self.pintgs[l] = lpsint(
                     ^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/pseudo/pseudocontrollers.py", line 11, in __init__
    super().__init__(*args, **kwargs)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/integrators/dual/pseudo/base.py", line 51, in __init__
    self.system = systemcls(backend, rallocs, mesh, initsoln,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/solvers/base/system.py", line 64, in __init__
    self._gen_kernels(nregs, eles, int_inters, mpi_inters, bc_inters)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/solvers/base/system.py", line 197, in _gen_kernels
    kern = kgetter(i)
           ^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/solvers/baseadvecdiff/elements.py", line 140, in <lambda>
    self.kernels['shocksensor'] = lambda uin: self._be.kernel(
                                              ^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/backends/base/backend.py", line 169, in kernel
    return kern(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/backends/base/kernels.py", line 154, in kernel_meth
    src, ndim, argn, argt = self._render_kernel(name, mod, extrns,
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/util.py", line 40, in newmeth
    res = cache[key] = meth(self, *args, **kwargs)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/backends/base/kernels.py", line 66, in _render_kernel
    src = tpl.render(**tplargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/pyfr/template.py", line 36, in render
    return super().render(*args, **self.dfltargs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/mako/template.py", line 439, in render
    return runtime._render(self, self.callable_, args, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/mako/runtime.py", line 874, in _render
    _render_context(
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/mako/runtime.py", line 916, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/home/sk/python3.11/pyfr/lib/python3.11/site-packages/mako/runtime.py", line 943, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x7f133b8c4090", line 44, in render_body
  File "memory:0x7f1414034050", line 42, in render_body
ZeroDivisionError: float division by zero
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 2 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

I think the issue is that in the shock sensor there is a divide by order: https://github.com/PyFR/PyFR/blob/bd38d5e9ac678753d28cfde0235ce6a8e88e0d56/pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako#L4

And so when you make a p-multigrid cycle that goes to p=0, this causes an issue.

We should add a check because at p=0 you don’t need a shock sensor.