-
Notifications
You must be signed in to change notification settings - Fork 151
WIP: Additional analysis for multi-component Euler systems. #2414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
349373a
9277c5b
9826f54
5c43164
c889484
2821bf0
33ead0d
818c698
103c918
76adb10
373c1d6
4e6245b
a93e340
d7f3f55
5c4e4db
00d61c9
1424930
0dcc5ee
470c96d
db9b07d
a2e26c2
71f7e7a
c705cdf
0c50c08
9658874
423dd30
1081df0
6e31ee3
3612f4b
71ca315
b8a2716
52195d8
2d65ccc
89cbfc0
44c3f5f
d22561b
d825c93
3cdbc82
d7cd1b3
df58d7f
52b267b
f891791
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -246,10 +246,135 @@ function integrate(func::Func, u, | |||||||||||||
| UnstructuredMesh2D, P4estMesh{2}, P4estMeshView{2}, | ||||||||||||||
| T8codeMesh{2}}, | ||||||||||||||
| equations, dg::DG, cache; normalize = true) where {Func} | ||||||||||||||
| integrate_via_indices(u, mesh, equations, dg, cache; | ||||||||||||||
| normalize = normalize) do u, i, j, element, equations, dg | ||||||||||||||
| u_local = get_node_vars(u, equations, dg, i, j, element) | ||||||||||||||
| return func(u_local, equations) | ||||||||||||||
| @unpack boundaries = cache | ||||||||||||||
| m = methods(func) | ||||||||||||||
| if (m[1].nargs == 2) || (func == cons2cons) | ||||||||||||||
| return integrate_via_indices(u, mesh, equations, dg, cache; | ||||||||||||||
| normalize = normalize) do u, i, j, element, | ||||||||||||||
| equations, dg | ||||||||||||||
| u_local = get_node_vars(u, equations, dg, i, j, element) | ||||||||||||||
|
|
||||||||||||||
| func(u_local, equations) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| if (m[1].nargs == 4) && (func != cons2cons) | ||||||||||||||
| gradients_x = DGSpaceDerivative_WeakForm!(dg, cache, u, 1, equations, mesh) | ||||||||||||||
| gradients_y = DGSpaceDerivative_WeakForm!(dg, cache, u, 2, equations, mesh) | ||||||||||||||
| return integrate_via_indices(u, mesh, equations, dg, cache; | ||||||||||||||
| normalize = normalize) do u, i, j, element, | ||||||||||||||
| equations, dg | ||||||||||||||
| u_local = get_node_vars(u, equations, dg, i, j, element) | ||||||||||||||
| gradients_local = Vector([gradients_x[:, i, j, element], gradients_y[:, i, j, element]]) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| func(u_local, gradients_local, equations) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # Return the derivatives of the interpolatied polynomial. | ||||||||||||||
| function lagrange_derivatives(x, y) | ||||||||||||||
| n = length(x) | ||||||||||||||
| dydx = zeros(n) | ||||||||||||||
|
|
||||||||||||||
| for i in 1:n | ||||||||||||||
| for j in 1:n | ||||||||||||||
| if i != j | ||||||||||||||
| term = y[j] / (x[i] - x[j]) | ||||||||||||||
| for k in 1:n | ||||||||||||||
| if k != i && k != j | ||||||||||||||
| term *= (x[i] - x[k]) / (x[j] - x[k]) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| dydx[i] += term | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| return dydx | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # Andrew's functions for computing the derivatives. | ||||||||||||||
| function DGSpaceDerivative_WeakForm!(dg, | ||||||||||||||
| cache, | ||||||||||||||
| u, | ||||||||||||||
| direction::Int, | ||||||||||||||
| equations, | ||||||||||||||
| mesh) | ||||||||||||||
| # Get the required variables. | ||||||||||||||
| @unpack derivative_dhat, weights = dg.basis | ||||||||||||||
|
|
||||||||||||||
| # Compute the surface flux terms. | ||||||||||||||
| surface_flux_values = similar(u) | ||||||||||||||
| Trixi.calc_surface_integral!(surface_flux_values, u, mesh, equations, dg.surface_integral, dg, cache) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| # Translations. | ||||||||||||||
| D = derivative_dhat | ||||||||||||||
| spA_Dhat = D | ||||||||||||||
|
|
||||||||||||||
| n_vars, Np, _, n_elements = size(u) | ||||||||||||||
| gradients = similar(u) | ||||||||||||||
|
|
||||||||||||||
| u_local = zeros((n_vars, Np, Np)) | ||||||||||||||
|
|
||||||||||||||
| if direction == 1 | ||||||||||||||
| for elem in 1:n_elements | ||||||||||||||
| # We work in primitive variables here. | ||||||||||||||
| for i in 1:Np | ||||||||||||||
| for j in 1:Np | ||||||||||||||
| u_local[:, i, j] = cons2prim(u[:, i, j, elem], equations) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| # Volume contributions (weak form) | ||||||||||||||
| for v in 1:n_vars | ||||||||||||||
| # Interpolate polynomial. | ||||||||||||||
| for j in 1:Np | ||||||||||||||
| x = cache.elements.node_coordinates[1, :, j, elem] | ||||||||||||||
| y = u_local[v, :, j] | ||||||||||||||
| gradients[v, :, j, elem] .= lagrange_derivatives(x, y) | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # # Contract D in the ξ̂ (first spatial) direction | ||||||||||||||
| # gradients[v, :, :, elem] .= D * u[v, :, :, elem] | ||||||||||||||
| # # Average over element. | ||||||||||||||
|
Comment on lines
+336
to
+338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| average = sum(gradients[v, :, :, elem]/Np^2) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
| gradients[v, :, :, elem] .= average | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| elseif direction == 2 | ||||||||||||||
| for elem in 1:n_elements | ||||||||||||||
| # We work in primitive variables here. | ||||||||||||||
| for i in 1:Np | ||||||||||||||
| for j in 1:Np | ||||||||||||||
| u_local[:, i, j] = cons2prim(u[:, i, j, elem], equations) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| # Volume contributions (weak form) | ||||||||||||||
| for v in 1:n_vars | ||||||||||||||
| # Interpolate polynomial. | ||||||||||||||
| for i in 1:Np | ||||||||||||||
| x = cache.elements.node_coordinates[2, i, :, elem] | ||||||||||||||
| y = u_local[v, i, :] | ||||||||||||||
| gradients[v, i, :, elem] .= lagrange_derivatives(x, y) | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| # # Contract D in the ξ̂ (first spatial) direction | ||||||||||||||
| # gradients[v, :, :, elem] .= u[v, :, :, elem] * D' | ||||||||||||||
|
Comment on lines
+361
to
+362
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| # Average over element. | ||||||||||||||
| average = sum(gradients[v, :, :, elem]/Np^2) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||
| gradients[v, :, :, elem] .= average | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| return gradients | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
| function compute_flux_array!(Flux, u, direction, equations) | ||||||||||||||
| Np, nvars = size(Flux) | ||||||||||||||
| for i in 1:Np | ||||||||||||||
| Flux[i, :] .= flux(u[i, :], 1, direction, equations) | ||||||||||||||
| end | ||||||||||||||
| end | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶