diff --git a/src/meshes/structured_mesh.jl b/src/meshes/structured_mesh.jl index aa4402121e..81c6c1fd8d 100644 --- a/src/meshes/structured_mesh.jl +++ b/src/meshes/structured_mesh.jl @@ -106,17 +106,13 @@ function StructuredMesh(cells_per_dimension, faces::Tuple; # Collect definitions of face functions in one string (separated by semicolons) face2substring(face) = code_string(face, ntuple(_ -> RealT, NDIMS - 1)) - join_newline(strings) = join(strings, "\n") + join_newline(strings) = join(strings, ";") 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;faces = $(string(faces));mapping = transfinite_mapping(faces)""" return StructuredMesh(cells_per_dimension, mapping; RealT = RealT, periodicity = periodicity, @@ -141,8 +137,10 @@ function StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max; RealT = promote_type(eltype(coordinates_min), eltype(coordinates_max)) mapping = coordinates2mapping(coordinates_min, coordinates_max) - mapping_as_string = """ - coordinates_min = $coordinates_min;coordinates_max = $coordinates_max;mapping = coordinates2mapping(coordinates_min, coordinates_max)""" + ndims = length(cells_per_dimension) + mapping_as_string = join(["[$(coordinates_min[i]),$(coordinates_max[i])]" + for i in 1:ndims], "x") * + """;mapping = coordinates2mapping(coordinates_min, coordinates_max)""" return StructuredMesh(cells_per_dimension, mapping; RealT = RealT, periodicity = periodicity, mapping_as_string = mapping_as_string) @@ -358,12 +356,18 @@ function Base.show(io::IO, ::MIME"text/plain", mesh::StructuredMesh) "StructuredMesh{" * string(ndims(mesh)) * ", " * string(real(mesh)) * "}") summary_line(io, "size", size(mesh)) - - summary_line(io, "mapping", "") # Print code lines of mapping_as_string mapping_lines = split(mesh.mapping_as_string, ";") - for i in eachindex(mapping_lines) - summary_line(increment_indent(io), "line $i", strip(mapping_lines[i])) + + if occursin("coordinates", mesh.mapping_as_string) + summary_line(io, "mapping", "linear") + + summary_line(increment_indent(io), "domain", strip(mapping_lines[1])) + else + summary_line(io, "mapping", "") + for i in eachindex(mapping_lines) + summary_line(increment_indent(io), "line $i", strip(mapping_lines[i])) + end end summary_footer(io) end