Skip to content

Commit

Permalink
Add element mask to SpectralElementGrid2D
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharshakandala committed Dec 5, 2024
1 parent 340603b commit 270cb57
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Grids/spectralelement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ mutable struct SpectralElementGrid2D{
D,
IS,
BS,
EM,
} <: AbstractSpectralElementGrid
topology::T
quadrature_style::Q
Expand All @@ -138,11 +139,12 @@ mutable struct SpectralElementGrid2D{
internal_surface_geometry::IS
boundary_surface_geometries::BS
enable_bubble::Bool
element_mask::EM
end

local_geometry_type(
::Type{SpectralElementGrid2D{T, Q, GG, LG, D, IS, BS}},
) where {T, Q, GG, LG, D, IS, BS} = eltype(LG) # calls eltype from DataLayouts
::Type{SpectralElementGrid2D{T, Q, GG, LG}},
) where {T, Q, GG, LG} = eltype(LG) # calls eltype from DataLayouts

"""
SpectralElementSpace2D(topology, quadrature_style; enable_bubble, horizontal_layout_type = DataLayouts.IJFH)
Expand All @@ -155,6 +157,7 @@ flag `enable_bubble` enables the `bubble correction` for more accurate element a
- quadrature_style: QuadratureStyle
- enable_bubble: Bool
- horizontal_layout_type: Type{<:AbstractData}
- mask spectral element (default is `true`)
The idea behind the so-called `bubble_correction` is that the numerical area
of the domain (e.g., the sphere) is given by the sum of nodal integration weights
Expand All @@ -176,12 +179,15 @@ where ``\\tilde{A}^e`` is the approximated area given by the sum of the interior
Note: This is accurate only for cubed-spheres of the [`Meshes.EquiangularCubedSphere`](@ref) and
[`Meshes.EquidistantCubedSphere`](@ref) type, not for [`Meshes.ConformalCubedSphere`](@ref).
The element mask can be used to block evaluation of tendencies for spectral elements for which it is set to `false`.
"""
function SpectralElementGrid2D(
topology::Topologies.Topology2D,
quadrature_style::Quadratures.QuadratureStyle;
horizontal_layout_type = DataLayouts.IJFH,
enable_bubble::Bool = false,
element_mask = Vector{Bool}(ones(Topologies.nlocalelems(topology))),
)
get!(
Cache.OBJECT_CACHE,
Expand All @@ -191,13 +197,15 @@ function SpectralElementGrid2D(
quadrature_style,
enable_bubble,
horizontal_layout_type,
element_mask,
),
) do
_SpectralElementGrid2D(
topology,
quadrature_style,
horizontal_layout_type;
enable_bubble,
element_mask,
)
end
end
Expand All @@ -217,12 +225,14 @@ _SpectralElementGrid2D(
quadrature_style::Quadratures.QuadratureStyle,
horizontal_layout_type = DataLayouts.IJFH;
enable_bubble::Bool,
element_mask::Vector{Bool},
) = _SpectralElementGrid2D(
topology,
quadrature_style,
Val(Topologies.nlocalelems(topology)),
horizontal_layout_type;
enable_bubble,
element_mask,
)

function _SpectralElementGrid2D(
Expand All @@ -231,6 +241,7 @@ function _SpectralElementGrid2D(
::Val{Nh},
::Type{horizontal_layout_type};
enable_bubble::Bool,
element_mask,
) where {Nh, horizontal_layout_type}
@assert horizontal_layout_type <: Union{DataLayouts.IJHF, DataLayouts.IJFH}
surface_layout_type = if horizontal_layout_type <: DataLayouts.IJFH
Expand Down Expand Up @@ -502,6 +513,7 @@ function _SpectralElementGrid2D(
internal_surface_geometry,
boundary_surface_geometries,
enable_bubble,
DA(element_mask),
)
end

Expand Down

0 comments on commit 270cb57

Please sign in to comment.