Skip to content

Commit

Permalink
Unify LaplaceDiffusion1D, LaplaceDiffusion2D, and `LaplaceDiffusi…
Browse files Browse the repository at this point in the history
…on3D` BCs (#1421)

* unify laplace diffusion BCs

* format files

* remove 3d bcs

* Update src/equations/laplace_diffusion_3d.jl

Co-authored-by: Michael Schlottke-Lakemper <[email protected]>

---------

Co-authored-by: Daniel Doehring <[email protected]>
Co-authored-by: Daniel Doehring <[email protected]>
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
  • Loading branch information
4 people authored Apr 28, 2024
1 parent 6554973 commit 73a1513
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 69 deletions.
11 changes: 6 additions & 5 deletions src/equations/laplace_diffusion_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,36 @@ function flux(u, gradients, orientation::Integer, equations_parabolic::LaplaceDi
return equations_parabolic.diffusivity * dudx
end

# Dirichlet-type boundary condition for use with a parabolic solver in weak form
# Dirichlet and Neumann boundary conditions for use with parabolic solvers in weak form.
# Note that these are general, so they apply to LaplaceDiffusion in any spatial dimension.
@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion1D)
equations_parabolic::AbstractLaplaceDiffusion)
return boundary_condition.boundary_value_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion1D)
equations_parabolic::AbstractLaplaceDiffusion)
return flux_inner
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion1D)
equations_parabolic::AbstractLaplaceDiffusion)
return boundary_condition.boundary_normal_flux_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion1D)
equations_parabolic::AbstractLaplaceDiffusion)
return flux_inner
end
33 changes: 1 addition & 32 deletions src/equations/laplace_diffusion_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,4 @@ function penalty(u_outer, u_inner, inv_h, equations_parabolic::LaplaceDiffusion2
return dg.penalty_parameter * (u_outer - u_inner) * equations_parabolic.diffusivity
end

# Dirichlet-type boundary condition for use with a parabolic solver in weak form
@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion2D)
return boundary_condition.boundary_value_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion2D)
return flux_inner
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion2D)
return boundary_condition.boundary_normal_flux_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion2D)
return flux_inner
end
# General Dirichlet and Neumann boundary condition functions are defined in `src/equations/laplace_diffusion_1d.jl`.
33 changes: 1 addition & 32 deletions src/equations/laplace_diffusion_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,4 @@ function penalty(u_outer, u_inner, inv_h, equations_parabolic::LaplaceDiffusion3
return dg.penalty_parameter * (u_outer - u_inner) * equations_parabolic.diffusivity
end

# Dirichlet-type boundary condition for use with a parabolic solver in weak form
@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion3D)
return boundary_condition.boundary_value_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionDirichlet)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion3D)
return flux_inner
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Divergence,
equations_parabolic::LaplaceDiffusion3D)
return boundary_condition.boundary_normal_flux_function(x, t, equations_parabolic)
end

@inline function (boundary_condition::BoundaryConditionNeumann)(flux_inner, u_inner,
normal::AbstractVector,
x, t,
operator_type::Gradient,
equations_parabolic::LaplaceDiffusion3D)
return flux_inner
end
# General Dirichlet and Neumann boundary condition functions are defined in `src/equations/laplace_diffusion_1d.jl`.

0 comments on commit 73a1513

Please sign in to comment.