Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional arguments for interactive version of generate_mesh function #52

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/src/interactive_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,17 @@ To generate a mesh interactively you

## Advanced

All objects and information contained in the variable type `Project` are actually dictionaries of type `Dict{String, Any}`.
The `generate_mesh` function has two optional arguments. The first is the logical `verbose`
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
argument. One can pass `verbose=true` to output additional messages and information during
the meshing process. The second is the integer `subdivision_maximum` argument.
The default value is `subdivision_maximum=8`, meaning that elements can be up
to a factor of `2^8` smaller than the existing background grid.
Note, think before adjusting the `subdivision_maximum` level! It is often the case that
adjusting the boundary curves, background grid size, adding local refinement regions,
or some combination of these adjustments removes the need to adjust the subdivision depth.

All objects and information contained in the variable type `Project` are actually dictionaries
of type `Dict{String, Any}`.
Since Julia is not an object oriented language, the parameters and other parts of these internal dictionaries
can be accessed and edited directly by key and value.
However, if you do that, then certain features like `undo`/`redo` and automatic plot updating **will not work**.
14 changes: 11 additions & 3 deletions src/HOHQMesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,19 @@ control file name. For example, `path/to/ControlFile.control` will result in out
You can activate verbose output from HOHQMesh that prints additional messages and debugging
mesh information with the keyword argument `verbose`.

To override the maximum number of allowable subdivisions in the quad tree during meshing
adjust the value of `subdivision_maximum`. The default value of `subdivision_maximum` is 8,
meaning that elements can be up to a factor of `2^8` smaller than the background grid.
Note, think before doing this! It could be adjusting the boundary curves, background grid size,
adding local refinement regions, or some combination may remove the need to adjust
the subdivision depth.

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,
verbose=false)
verbose=false, subdivision_maximum=8)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
@assert isfile(control_file) "'$control_file' is not a valid path to an existing file"

# Determine output filenames
Expand Down Expand Up @@ -223,10 +230,11 @@ function generate_mesh(control_file;
flush(tmpio)

# Run HOHQMesh and store output
str_subdivision_maximum = string(subdivision_maximum)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
if verbose
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -verbose -f $tmppath`)
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -sLimit $str_subdivision_maximum -verbose -f $tmppath`)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
else
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -f $tmppath`)
readchomp(`$(HOHQMesh_jll.HOHQMesh()) -sLimit $str_subdivision_maximum -f $tmppath`)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down
17 changes: 14 additions & 3 deletions src/Mesh/Meshing.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

"""
generate_mesh(proj::Project)
generate_mesh(proj::Project; verbose::Bool, subdivision_maximum::Integer)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved

Generate a mesh from the information stored in a `Project` created using the
interactive mesh functionality. First a check is made
Expand All @@ -11,9 +11,19 @@ and use it to call the wrapper function that interfaces with HOHQMesh. The resul
will be saved to `proj.projectDirectory`. Also, if there is an active plot of the mesh project it
will update to display the generated mesh.

With the optional argument `verbose` one can activate verbose output from HOHQMesh
that prints additional messages and debugging mesh information.

To override the maximum number of allowable subdivisions in the quad tree during meshing
adjust the value of `subdivision_maximum`. The default value of `subdivision_maximum` is 8,
meaning that elements can be up to a factor of `2^8` smaller than the background grid.
Note, think before doing this! It could be adjusting the boundary curves, background grid size,
adding local refinement regions, or some combination may remove the need to adjust
the subdivision depth.

This function returns the output to `stdout` of the HOHQMesh binary when generating the mesh.
"""
function generate_mesh(proj::Project)
function generate_mesh(proj::Project; verbose=false, subdivision_maximum=8)
#
# Check to be sure background grid has been created (everything else is defaults)
#
Expand All @@ -30,7 +40,8 @@ function generate_mesh(proj::Project)

saveProject(proj)
fileName = joinpath(proj.projectDirectory,proj.name)*".control"
mesherOutput = generate_mesh(fileName, output_directory = proj.projectDirectory)
mesherOutput = generate_mesh(fileName, output_directory = proj.projectDirectory,
verbose=verbose, subdivision_maximum=subdivision_maximum)
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
println(mesherOutput)
postNotificationWithName(proj,"MESH_WAS_GENERATED_NOTIFICATION",(nothing,))
return nothing
Expand Down
2 changes: 1 addition & 1 deletion test/test_visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ using CairoMakie
@test_nowarn plotProject!(p_visu, MODEL+GRID)

# Create the mesh which contains a plotting update for ISM
@test_nowarn generate_mesh(p_visu)
@test_nowarn generate_mesh(p_visu, verbose=true)

# Destroy the mesh and reset the background grid
@test_nowarn remove_mesh!(p_visu)
Expand Down
Loading