Skip to content

Commit

Permalink
add convenience constructor for MeshData (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlchan authored Sep 17, 2024
1 parent 98f1090 commit fa1e004
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/MeshData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ MeshData(mesh::Tuple{<:Tuple, Matrix{Int64}}, rd::RefElemData, other_args...; kw
MeshData(VXYZ, EToV, rd::RefElemData, other_args...; kwargs...) =
MeshData(VXYZ..., EToV, rd, other_args...; kwargs...) # splats VXYZ

"""
MeshData(cells_per_dimension, rd::RefElemData{NDIMS};
coordinates_min = ntuple(_ -> -1.0, NDIMS),
coordinates_max = ntuple(_ -> 1.0, NDIMS),
is_periodic=ntuple(_ -> false, NDIMS)) where {NDIMS}
Returns a `MeshData` initialized on a uniform mesh with `cells_per_dimension` elements per
dimension scaled to the following tensor product domain:
`[coordinates_min[1], coordinates_max[1]]x[coordinates_min[2], coordinates_max[2]], ...`.
"""
function MeshData(cells_per_dimension, rd::RefElemData{NDIMS};
coordinates_min = ntuple(_ -> -1.0, NDIMS),
coordinates_max = ntuple(_ -> 1.0, NDIMS),
is_periodic=ntuple(_ -> false, NDIMS)) where {NDIMS}
VXYZ, EToV = uniform_mesh(rd.element_type, cells_per_dimension)
VXYZ = map((x, xmin, xmax) -> (@. 0.5 * (x + 1) * (xmax - xmin) + xmin),
VXYZ, coordinates_min, coordinates_max)
return MeshData(VXYZ, EToV, rd; is_periodic)
end

function MeshData(VX::AbstractVector, EToV, rd::RefElemData{1}; is_periodic=(false, ))

# Construct global coordinates
Expand Down

0 comments on commit fa1e004

Please sign in to comment.