301: 3D Laplace equation

(source code)

module Example301_Laplace3Dusing VoronoiFVM, ExtendableGridsusing GridVisualize# Flux function which describes the flux# between neighboring control volumesfunction g!(f, u, edge, data)    f[1] = u[1, 1] - u[1, 2]    return nothingendfunction s(f, node, data)    n = view(node.coord, :, node.index)    f[1] = n[1] * sin(5.0 * n[2]) * exp(n[3])    return nothingendfunction main(; Plotter = nothing, n = 5, assembly = :edgewise)    nspecies = 1    ispec = 1    X = collect(0:(1 / n):1)    grid = simplexgrid(X, X, X)    physics = VoronoiFVM.Physics(; flux = g!, source = s)    sys = VoronoiFVM.System(grid, physics; assembly = assembly)    enable_species!(sys, ispec, [1])    boundary_dirichlet!(sys, ispec, 5, 0.0)    boundary_dirichlet!(sys, ispec, 6, 0.0)    solution = solve(sys)    scalarplot(grid, solution[1, :]; Plotter = Plotter)    return solution[43]end# Called by unit testusing Testfunction runtests()    testval = 0.012234524449380824    @test main(; assembly = :edgewise) ≈ testval &&        main(; assembly = :cellwise) ≈ testval    return nothingendend

This page was generated using Literate.jl.