# StructuredMesh parabolic equations supported Trixi

**URL:** https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231
**Category:** Specific Domains
**Tags:** package
**Created:** [July 19, 2024, 11:58am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231 "2024-07-19T11:58:13Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Kelian\_Renoux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kelian_renoux/32/210410_2.png) [@Kelian\_Renoux](https://discourse.julialang.org/u/Kelian_Renoux)
#### Post date: [July 19, 2024, 11:58am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/1 "2024-07-19T11:58:13Z")

</div>

Hi, i was using Trixi.jl for the Brown and Minion test case and i was trying to use the StructuredMesh function to refine the mesh cells by cells (20x20 to 25x25 and so on) but it seems that the create\_cache\_parabolic function is not defined for a StructuredMesh type

```julia
ERROR: LoadError: MethodError: no method matching create_cache_parabolic(::StructuredMesh{2, Float64}, ::CompressibleEulerEquations2D{Float64}, ::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive, Float64, Float64, CompressibleEulerEquations2D{Float64}}, ::DGSEM{LobattoLegendreBasis{Float64, 5, SVector{5, Float64}, Matrix{Float64}, Matrix{Float64}, Matrix{Float64}}, Trixi.LobattoLegendreMortarL2{Float64, 5, Matrix{Float64}, Matrix{Float64}}, SurfaceIntegralWeakForm{typeof(flux_hllc)}, VolumeIntegralWeakForm}, ::ViscousFormulationBassiRebay1, ::Type{Float64}, ::Type{Float64})

Closest candidates are:
  create_cache_parabolic(!Matched::P4estMesh{3}, ::Trixi.AbstractEquations, ::Trixi.AbstractEquationsParabolic, ::DG, ::Any, ::Any, ::Any)
   @ Trixi /scratch/stg-cfds/renoux/Trixi.jl/src/solvers/dgsem_p4est/dg_3d_parabolic.jl:11
  create_cache_parabolic(!Matched::P4estMesh{2}, ::Trixi.AbstractEquations, ::Trixi.AbstractEquationsParabolic, ::DG, ::Any, ::Any, ::Any)
   @ Trixi /scratch/stg-cfds/renoux/Trixi.jl/src/solvers/dgsem_p4est/dg_2d_parabolic.jl:11
  create_cache_parabolic(!Matched::TreeMesh{3, TreeType} where TreeType<:Trixi.AbstractTree{3}, ::Trixi.AbstractEquations, ::Trixi.AbstractEquationsParabolic, ::DG, ::Any, ::Any, ::Any)
   @ Trixi /scratch/stg-cfds/renoux/Trixi.jl/src/solvers/dgsem_tree/dg_3d_parabolic.jl:986

```

On the Trixi.jl documentation, i saw that CompressibleNavierStokesEquations() should be supported for StructuredMesh

 ![Capture d’écran 2024-07-19 à 13.57.28](https://global.discourse-cdn.com/julialang/original/3X/0/1/018d9899ddf93f37418feb82b58929b91f83f8d1.png)

So i just wanted to know if it was a mistake on my part or just a future implementation ?

---

<div class="post-metadata">

### Author: ![Kelian\_Renoux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kelian_renoux/32/210410_2.png) [@Kelian\_Renoux](https://discourse.julialang.org/u/Kelian_Renoux)
#### Post date: [July 19, 2024, 11:59am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/2 "2024-07-19T11:59:26Z")

</div>

Here is the following julia code

```julia
using Trixi, OrdinaryDiffEq

prandtl_number() = 0.72
mu = 0.00005

dg = DGSEM(polydeg = 4, surface_flux = flux_hllc)

equations = CompressibleEulerEquations2D(1.4)
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu, Prandtl = prandtl_number(), gradient_variables = GradientVariablesPrimitive())
"""
A compressible version of the double shear layer initial condition. Adapted from
Brown and Minion (1995). See Section 3, equations (27)-(28) for the original
incompressible version.

- David L. Brown and Michael L. Minion (1995)
  Performance of Under-resolved Two-Dimensional Incompressible Flow Simulations.
  [DOI: 10.1006/jcph.1995.1205](https://doi.org/10.1006/jcph.1995.1205)
"""
function initial_condition_BM_vortex(x, t, equations::CompressibleEulerEquations2D)

  L = 1.0
  x0 = 0.0
  Ma0 = 0.2 # Maximum Mach number
  rho0 = 1.2 # density outside the shear layer
  
  n_vortex=1
  l_ratio = 100.0 # length scale ratio (30.0 default)
  d_ratio = 1.0 # density ratio (4.0 default)
  v_ratio = 0.05 # velocity ratio (0.2 default)
  shear = 200.0 # shear value (15.0 default)

  y0 = L/2
  ya = y0 - L/4
  yb = y0 + L/4
  sigma = L / l_ratio
  u0 = shear*sigma/2
  v0 = v_ratio * u0
  rho1 = d_ratio * rho0

  B = tanh((x[2]-ya)/sigma)/2 - tanh((x[2]-yb)/sigma)/2

  rho = rho0 * (1.0 + B*(d_ratio-1.0))
  u = u0 * (2*B - 1.0)
  v = v0 * cos(2.0 * pi * n_vortex * (x[1]-x0)/L)# + u0

  c0 = u0 / Ma0
  temp0 = c0^2 / (equations.gamma*8.314)
  p0 = rho1 * 8.314 * temp0

    return prim2cons(SVector(rho, u, v, p0), equations)
end

initial_condition = initial_condition_BM_vortex

coordinates_min = (0.0,0.0) # minimum coordinates (min(x), min(y))
coordinates_max = (1.0,1.0) # maximum coordinates (max(x), max(y))

trees_per_dimension = (1,1)
nb_cells = 67
#mesh = P4estMesh(trees_per_dimension,
                 #polydeg = 1, initial_refinement_level = 6,
                 #coordinates_min = coordinates_min, coordinates_max = coordinates_max,
                 #periodicity = true)

mesh = StructuredMesh((nb_cells, nb_cells), coordinates_min, coordinates_max, periodicity = true)

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations,equations_parabolic), initial_condition, dg)

tspan = (0.0, 2.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

alive_callback = AliveCallback(alive_interval = 1000)

save_solution = SaveSolutionCallback(interval = 200,
                                     save_initial_solution = true,
                                     save_final_solution = true,
                                     solution_variables = cons2prim, output_directory="out_shearlayer")

analysis_interval = 100

analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

stepsize_callback = StepsizeCallback(cfl = 0.1)

callbacks = CallbackSet(summary_callback, save_solution, analysis_callback, stepsize_callback)

###############################################################################
# run the simulation

tol = 1.0e-6
sol = solve(ode, RDPK3SpFSAL49(); dt = 1.0e-3, abstol=tol, reltol=tol,
            ode_default_options()..., callback = callbacks);

summary_callback() # print the timer summary

```

---

<div class="post-metadata">

### Author: ![JoshuaLampert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshualampert/32/205964_2.png) [@JoshuaLampert](https://discourse.julialang.org/u/JoshuaLampert)
#### Post date: [July 22, 2024, 4:51pm UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/3 "2024-07-22T16:51:14Z")

</div>

Yes, you are right. The `StructuredMesh` does not support parabolic terms yet. This was an error in our documentation, which will be fixed soon. Thanks for pointing that out!

---

<div class="post-metadata">

### Author: ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)
#### Post date: [July 22, 2024, 7:46pm UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/4 "2024-07-22T19:46:59Z")

</div>

Thanks for the report. @JoshuaLampert has already prepared a hotfix for the docs. We should update the code to work with `StructuredMesh`es, too. In the meantime, you should be able to use the `P4estMesh`.

---

<div class="post-metadata">

### Author: ![Kelian\_Renoux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kelian_renoux/32/210410_2.png) [@Kelian\_Renoux](https://discourse.julialang.org/u/Kelian_Renoux)
#### Post date: [July 23, 2024, 7:12am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/5 "2024-07-23T07:12:05Z")

</div>

Thanks ! Glad i could help. I also had another question about the fonctionnalities for the DGmulti solver, I have tried to get an output in the format .h5 but the `SaveSolutionCallback` returns an error. Is it implemented in Trixi.jl for the DGmulti solver ?

---

<div class="post-metadata">

### Author: ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)
#### Post date: [July 23, 2024, 7:46am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/6 "2024-07-23T07:46:01Z")

</div>

No, the `SaveSolutionCallback` is not available for `DGMulti`. But you can plot numerical solutions using Plots.jl or Makie.jl (in an interactive session).

---

<div class="post-metadata">

### Author: ![Kelian\_Renoux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kelian_renoux/32/210410_2.png) [@Kelian\_Renoux](https://discourse.julialang.org/u/Kelian_Renoux)
#### Post date: [July 23, 2024, 7:58am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/7 "2024-07-23T07:58:47Z")

</div>

Thanks, I am trying to get the data from Julia to Python for learning purposes (Through CSV.jl), I was wondering how you manage the discontinuities in the plot of the solution ? Because we have (P+1)^(NDIM) points in a cell and the faces that are not at the boundaries share points with theirs neighbors.  
Thanks again for the quick response !

---

<div class="post-metadata">

### Author: ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)
#### Post date: [July 24, 2024, 6:26am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/8 "2024-07-24T06:26:23Z")

</div>

It depends on the setup. With Trixi2Vtk.jl and similar tools, we can interpolate solutions to a uniform grid of nodes strictly inside the elements for plotting. For other purposes (in particular in 1D), it can be very helpful to move the nodes at the element interfaces a tiny bit inside the element (like `nextfloat` and `prevfloat`) to really show the discontinuous solutions.

---

<div class="post-metadata">

### Author: ![Kelian\_Renoux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kelian_renoux/32/210410_2.png) [@Kelian\_Renoux](https://discourse.julialang.org/u/Kelian_Renoux)
#### Post date: [July 24, 2024, 7:02am UTC](https://discourse.julialang.org/t/structuredmesh-parabolic-equations-supported-trixi/117231/9 "2024-07-24T07:02:40Z")

</div>

Oh I see, to visualise the riemann problem at the faces of elements, thanks !
