From 6363e6e0c56d4f0b57d23ad2f898c1a9fe80231f Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:55:59 +0200 Subject: [PATCH] Fix mapping string in `StructuredMesh` --- src/meshes/mesh_io.jl | 2 +- src/meshes/structured_mesh.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/meshes/mesh_io.jl b/src/meshes/mesh_io.jl index b9895e7d454..da5c346fb91 100644 --- a/src/meshes/mesh_io.jl +++ b/src/meshes/mesh_io.jl @@ -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 diff --git a/src/meshes/structured_mesh.jl b/src/meshes/structured_mesh.jl index df067db833d..3e73ffa8770 100644 --- a/src/meshes/structured_mesh.jl +++ b/src/meshes/structured_mesh.jl @@ -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,