Skip to content

Commit

Permalink
Fix mapping string in StructuredMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber committed Oct 2, 2023
1 parent 9e41775 commit 6363e6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/meshes/mesh_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT)
#
# This should be replaced with something more robust and secure,
# see https://github.com/trixi-framework/Trixi.jl/issues/541).
expr = Meta.parse(mapping_as_string)
expr = Meta.parseall(mapping_as_string)
if expr.head == :toplevel
expr.head = :block
end
Expand Down
6 changes: 3 additions & 3 deletions src/meshes/structured_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ function StructuredMesh(cells_per_dimension, faces::Tuple; RealT = Float64,

# Collect definitions of face functions in one string (separated by semicolons)
face2substring(face) = code_string(face, ntuple(_ -> Float64, NDIMS - 1))
join_semicolon(strings) = join(strings, "; ")
join_newline(strings) = join(strings, "\n")

faces_definition = faces .|> face2substring .|> string |> join_semicolon
faces_definition = faces .|> face2substring .|> string |> join_newline

# Include faces definition in `mapping_as_string` to allow for evaluation
# without knowing the face functions
mapping_as_string = "$faces_definition; faces = $(string(faces)); mapping = transfinite_mapping(faces)"
mapping_as_string = "$faces_definition\nfaces = $(string(faces))\nmapping = transfinite_mapping(faces)"

return StructuredMesh(cells_per_dimension, mapping; RealT = RealT,
periodicity = periodicity,
Expand Down

0 comments on commit 6363e6e

Please sign in to comment.