Skip to content

Commit

Permalink
Merge pull request #5 from trixi-framework/verbose_kwarg
Browse files Browse the repository at this point in the history
Ability to return verbose output messages
  • Loading branch information
andrewwinters5000 authored May 27, 2021
2 parents dc750d5 + 918ae5a commit 111cf47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/HOHQMesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ the filenames for the mesh file, plot file, and statistics file are generated au
control file name. For example, `path/to/ControlFile.control` will result in output files
`ControlFile.mesh`, `ControlFile.tec`, and `ControlFile.txt`.
You can activate verbose output from HOHQMesh that prints additional messages and debugging
mesh information with the keyword argument `verbose`.
This function returns the output to `stdout` of the HOHQMesh binary when generating the mesh.
"""
function generate_mesh(control_file;
output_directory="out",
mesh_filename=nothing, plot_filename=nothing, stats_filename=nothing)
mesh_filename=nothing, plot_filename=nothing, stats_filename=nothing,
verbose=false)
@assert isfile(control_file) "'$control_file' is not a valid path to an existing file"

# Determine output filenames
Expand Down Expand Up @@ -66,7 +70,11 @@ function generate_mesh(control_file;
flush(tmpio)

# Run HOHQMesh and store output
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -f $tmppath`)
if verbose
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -verbose -f $tmppath`)
else
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -f $tmppath`)
end
end

String(output)
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ using Test
@test generate_mesh(control_file) isa String
end

@testset "generate_mesh(; verbose=true)" begin
control_file = joinpath(HOHQMesh.examples_dir(), "GingerbreadMan.control")
@test generate_mesh(control_file, verbose=true) isa String
end

end # testset "HOHQMesh.jl"

0 comments on commit 111cf47

Please sign in to comment.