From 2e58cd19a04646f82bf2f40b1db5764d4e330389 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Sat, 15 Jun 2024 00:38:25 +0200 Subject: [PATCH 01/26] add new tutorial with syemmtry lines --- docs/make.jl | 1 + docs/src/tutorials/introduction.md | 17 +- docs/src/tutorials/symmetric_mesh.md | 418 +++++++++++++++++++++++++++ 3 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 docs/src/tutorials/symmetric_mesh.md diff --git a/docs/make.jl b/docs/make.jl index facf11a8..92614fbb 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -40,6 +40,7 @@ makedocs( joinpath("tutorials", "curved_outer_boundary.md"), joinpath("tutorials", "spline_curves.md"), joinpath("tutorials", "create_edit_curves.md"), + joinpath("tutorials", "symmetric_mesh.md"), ], "Advanced topics & developers" => [ "Development" => "development.md", diff --git a/docs/src/tutorials/introduction.md b/docs/src/tutorials/introduction.md index 47afe661..0cccf406 100644 --- a/docs/src/tutorials/introduction.md +++ b/docs/src/tutorials/introduction.md @@ -80,4 +80,19 @@ Demonstrates how to: * Construct and add parametric spline curves. * Construct and add a curve from parametric equations. * Construct and add straight line segments. -* Construct and add circular arc segments. \ No newline at end of file +* Construct and add circular arc segments. + +## [Symmetric mesh](@ref) + +This tutorial constructs a mesh given a closed chain of outer boundary curves +that is then reflected over a straight line indicated by the user. +The result is a mesh that is symmetric with respect to the prescribed +straight line. + +### Synopsis + +Demonstrates how to: +* Indicate a symmetry boundary line. +* Construct an outer boundary with several connected curves. +* Add the background grid when an outer boundary curve is present. +* Visualize an interactive mesh project. \ No newline at end of file diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md new file mode 100644 index 00000000..074dea53 --- /dev/null +++ b/docs/src/tutorials/symmetric_mesh.md @@ -0,0 +1,418 @@ +# Symmetric mesh + +The purpose of this tutorial is to demonstrate how to create an unstructured mesh +that is symmetric with respect to a straight line outer boundary prescribed by the user. +At the end of this tutorial one can find the scripts necessary to generate the meshes +described herein. + +### Synopsis + +This tutorial demonstrates how to: +* Indicate a symmetry boundary line. +* Construct an outer boundary with several connected curves. +* Add the background grid when an outer boundary curve is present. +* Visualize an interactive mesh project. + +## Initialization + +From a Julia REPL we load the HOHQMesh package as well as +[GLMakie](https://github.com/JuliaPlots/GLMakie.jl/), a backend of +[Makie.jl](https://github.com/JuliaPlots/Makie.jl/), to visualize the +curves, mesh, etc. from the interactive tool. +```julia +julia> using GLMakie, HOHQMesh +``` +Now we are ready to interactively generate unstructured quadrilateral meshes! + +We create a new project with the name `"symetric_mesh"` and +assign `"out"` to be the folder where any output files from the mesh generation process +will be saved. By default, the output files created by HOHQMesh will carry the same name +as the project. For example, the resulting HOHQMesh control file from this tutorial +will be named `symmetric_mesh.control`. +If the folder `out` does not exist, it will be created automatically in +the current file path. +```julia +symmetric_mesh = newProject("symmetric_mesh", "out") +``` + +## Adjusting project parameters + +When a new project is created it is filled with several default +`RunParameters` such as the polynomial order used to represent curved boundaries +or the mesh file format. These `RunParameters` can be queried and adjusted with +appropriate getter/setter pairs, see [Controlling the mesh generation](@ref) +for more details. + +For the `symmetric_mesh` project we query the current values for the polynomial +order and the mesh output format +```julia +julia> getPolynomialOrder(symmetric_mesh) +5 + +julia> getMeshFileFormat(symmetric_mesh) +"ISM-V2" +``` + +We change the default polynomial order in the `symmetric_mesh` to be $6$ with a corresponding +setter function +```julia +setPolynomialOrder!(symmetric_mesh, 6) +``` + +## Add a background grid + +HOHQMesh requires a background grid for the mesh generation process. This background grid sets +the base resolution of the desired mesh. HOHQMesh will automatically subdivide from this background +grid near sharp features of any curved boundaries. + +For a domain bounded by an outer boundary curve, this background grid is set by indicating the desired +element size in the $x$ and $y$ directions. To start, we set the background grid for `symmetric_mesh` +to have elements with side length $0.2$ in each direction +```julia +addBackgroundGrid!(spline_project, [0.2, 0.2, 0.0]) +``` + +## Add the outer boundary + +With the background grid size set, we next build the outer boundary for the present mesh project. +This outer boundary is composed of nine straight line segments and a half circle arc. +The curves are created such that they can be added to the mesh project `symmetric_mesh` +in counter-clockwise order as required by HOHQMesh. +```julia +line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], + [1.0, 0.0, 0.0]) + +line2 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) + +half_circle = newCircularArcCurve("circle", # curve name + [1.0, 0.75, 0.0], # circle center + 0.25, # circle radius + 270.0, # start angle + 90.0, # end angle + "degrees") # angle units + +line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], + [1.0, 1.5, 0.0]) + +line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], + [0.75, 1.5, 0.0]) + +line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], + [0.75, 1.75, 0.0]) + +line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], + [1.0, 1.75, 0.0]) + +line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], + [1.0, 2.0, 0.0]) + +line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], + [-0.05, 2.0, 0.0]) + +line9 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) +``` +The given boundary names will also be the names given in the resulting +mesh file. The only exception is the final boundary curve that is given +the name `"symmetry"`. This outer boundary curve is a special keyword +in HOHQMesh that indicates the prescribed straight line over which +a reflection will occur. + +!!! tip "Name of the symmetry boundary" + As noted above, `"symmetry"` is a keyword for the HOHQMesh generator that + prescribes over which line a reflection of the mesh occurs. Note + that Julia is a case sensitive language but Fortran is not. So, within the + Julia script one can name this reflection boundary line `"symmetry"` or `"Symmetry"` + or `"SYMMETRY"` or even something strange like `"sYmMeTrY"` and the mesh will still + generate successfully. + +Now that all the outer boundary curves are defined we add them to the `symmetric_mesh` +project in counter-clockwise order +```julia +addCurveToOuterBoundary!(symmetric_mesh, line1) +addCurveToOuterBoundary!(symmetric_mesh, line2) +addCurveToOuterBoundary!(symmetric_mesh, half_circle) +addCurveToOuterBoundary!(symmetric_mesh, line3) +addCurveToOuterBoundary!(symmetric_mesh, line4) +addCurveToOuterBoundary!(symmetric_mesh, line5) +addCurveToOuterBoundary!(symmetric_mesh, line6) +addCurveToOuterBoundary!(symmetric_mesh, line7) +addCurveToOuterBoundary!(symmetric_mesh, line8) +addCurveToOuterBoundary!(symmetric_mesh, line9) +``` + +We visualize the outer boundary curve chain and background grid with the following +```julia +plotProject!(symmetric_mesh, MODEL+GRID) +``` +Here, we take the sum of the keywords `MODEL` and `GRID` in order to simultaneously visualize +the outer boundary and background grid. The resulting plot is given below. The chain of outer boundary +curves is called `"Outer"` and its constituent curve segments are labeled accordingly with the names +prescribed in the curve construction above. + +![before_generation](add_figure1!) + +## Generate the mesh + +We next generate the mesh from the information contained in `symmetric_mesh`. +This will output the following files to the `out` folder: + +* `symmetric_mesh.control`: A HOHQMesh control file for the current project. +* `symmetric_mesh.tec`: A TecPlot formatted file to visualize the mesh with other software, e.g., [ParaView](https://www.paraview.org/). +* `symmetric_mesh.mesh`: A mesh file with format `ISM-V2` (the default format). + +To do this we execute the command +```julia +generate_mesh(symmetric_mesh) + + ******************* + 2D Mesh Statistics: + ******************* + Total time = 4.3447999999999987E-002 + Number of nodes = 422 + Number of Edges = 773 + Number of Elements = 352 + Number of Subdivisions = 2 + + Mesh Quality: + Measure Minimum Maximum Average Acceptable Low Acceptable High Reference + Signed Area 0.00147112 0.04240553 0.01102461 0.00000000 999.99900000 1.00000000 + Aspect Ratio 1.00102845 2.37276773 1.22432027 1.00000000 999.99900000 1.00000000 + Condition 1.00000549 2.97426696 1.13908196 1.00000000 4.00000000 1.00000000 + Edge Ratio 1.00185169 4.29126482 1.45727892 1.00000000 4.00000000 1.00000000 + Jacobian 0.00084327 0.03918949 0.00931776 0.00000000 999.99900000 1.00000000 + Minimum Angle 40.68137900 89.81152621 75.30939242 40.00000000 90.00000000 90.00000000 + Maximum Angle 90.10587561 140.86941819 105.72816725 90.00000000 135.00000000 90.00000000 + Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 +``` +The call to `generate_mesh` also prints mesh quality statistics to the screen +and updates the visualization. +The background grid is *removed* from the visualization when the mesh is generated. + +!!! note "Mesh visualization" + Currently, only the "skeleton" of the mesh is visualized. Thus, the high-order curved boundary information + is not seen in the plot but this information **is present** in the generated mesh file. + +![first_reflect_mesh](add_figure2!) + +!!! tip "Boundary names in the mesh file" + The boundary names of the original outer curves will be those defined by the user + in their construction above. The boundary labeled `"symmetry"` is now internal and + is marked appropriately as such. The reflected outer boundary names are appended + with `_R` (for reflected) in the mesh file. For instance, the reflected version + of the boundary `B2` has the name `B2_R` or the boundary named `circle` has the + reflected boundary counterpart named `circle_R`. + +## Changing the reflection line + +As an illustration, we redefine which of the straight lines in the outer boundary +curve chain is used for the reflection. Instead of the left boundary `O.10` in the +above example, we now set the reflection line to be the `O.2` curve on the right. +In doing so, we now label the left boundary curve `O.10` to be `"B9"`. +The redefinition of these two outer boundary curves are +```julia +line2 = newEndPointsLineCurve("symmetry", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) +line9 = newEndPointsLineCurve("B9", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) +``` +We then redefine the complete outer boundary in the `symmetric_mesh` project +(again in counter-clockwise order) with +```julia +addCurveToOuterBoundary!(symmetric_mesh, line1) +addCurveToOuterBoundary!(symmetric_mesh, line2) +addCurveToOuterBoundary!(symmetric_mesh, half_circle) +addCurveToOuterBoundary!(symmetric_mesh, line3) +addCurveToOuterBoundary!(symmetric_mesh, line4) +addCurveToOuterBoundary!(symmetric_mesh, line5) +addCurveToOuterBoundary!(symmetric_mesh, line6) +addCurveToOuterBoundary!(symmetric_mesh, line7) +addCurveToOuterBoundary!(symmetric_mesh, line8) +addCurveToOuterBoundary!(symmetric_mesh, line9) +``` +We visualize the new version of outer boundary curve chain and background grid with +```julia +plotProject!(symmetric_mesh, MODEL+GRID) +``` + +![before_generation2](add_figure3!) + +We then generate the new mesh from the information contained in `symmetric_mesh`. +This saves the control, tec, and mesh files into the `out` folder and yields +```julia +generate_mesh(symmetric_mesh) + + ******************* + 2D Mesh Statistics: + ******************* + Total time = 4.4684999999999975E-002 + Number of nodes = 428 + Number of Edges = 779 + Number of Elements = 352 + Number of Subdivisions = 2 + + Mesh Quality: + Measure Minimum Maximum Average Acceptable Low Acceptable High Reference + Signed Area 0.00147112 0.04240553 0.01102461 0.00000000 999.99900000 1.00000000 + Aspect Ratio 1.00102845 2.37276773 1.22432027 1.00000000 999.99900000 1.00000000 + Condition 1.00000549 2.97426696 1.13908196 1.00000000 4.00000000 1.00000000 + Edge Ratio 1.00185169 4.29126482 1.45727892 1.00000000 4.00000000 1.00000000 + Jacobian 0.00084327 0.03918949 0.00931776 0.00000000 999.99900000 1.00000000 + Minimum Angle 40.68137900 89.81152621 75.30939242 40.00000000 90.00000000 90.00000000 + Maximum Angle 90.10587561 140.86941819 105.72816725 90.00000000 135.00000000 90.00000000 + Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 +``` + +![first_reflect_mesh2](add_figure4!) + +## Summary + +In this tutorial we demonstrated how to: +* Indicate a symmetry boundary line. +* Construct an outer boundary with several connected curves. +* Add the background grid when an outer boundary curve is present. +* Visualize an interactive mesh project. + +For completeness, we include two scripts with all the commands to generate the meshes displayed +for a reflection about the left boundary line `O.10` and a reflection about the right boundary +line `O.2`. Note, we **do not** include the plotting in these scripts. +```julia +# Interactive mesh with reflection on the left +# +# Keywords: outer boundary, reflection, symmetric mesh +using HOHQMesh + +# new project +symmetric_mesh = newProject("symmetric_mesh", "out") + +# reset mesh polydeg +setPolynomialOrder!(symmetric_mesh, 6) + +# A background grid is required for the mesh generation +addBackgroundGrid!(symmetric_mesh, [0.2, 0.2, 0.0]) + +# Create all the outer boundary curves and add them to the mesh project. +# Note: (1) Curve names are those that will be present in the mesh file +# (2) Boundary named "symmetry" is where reflection occurs + +line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], + [1.0, 0.0, 0.0]) + +line2 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) + +half_circle = newCircularArcCurve("circle", # curve name + [1.0, 0.75, 0.0], # circle center + 0.25, # circle radius + 270.0, # start angle + 90.0, # end angle + "degrees") # angle units + +line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], + [1.0, 1.5, 0.0]) + +line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], + [0.75, 1.5, 0.0]) + +line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], + [0.75, 1.75, 0.0]) + +line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], + [1.0, 1.75, 0.0]) + +line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], + [1.0, 2.0, 0.0]) + +line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], + [-0.05, 2.0, 0.0]) + +line9 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) + +# Add all of the boundary curves into +# the project in counter-clockwise order +addCurveToOuterBoundary!(symmetric_mesh, line1) +addCurveToOuterBoundary!(symmetric_mesh, line2) +addCurveToOuterBoundary!(symmetric_mesh, half_circle) +addCurveToOuterBoundary!(symmetric_mesh, line3) +addCurveToOuterBoundary!(symmetric_mesh, line4) +addCurveToOuterBoundary!(symmetric_mesh, line5) +addCurveToOuterBoundary!(symmetric_mesh, line6) +addCurveToOuterBoundary!(symmetric_mesh, line7) +addCurveToOuterBoundary!(symmetric_mesh, line8) +addCurveToOuterBoundary!(symmetric_mesh, line9) + +# Generate the mesh. Saves the mesh file to the directory "out". +generate_mesh(symmetric_mesh) +``` +and +```julia +# Interactive mesh with reflection on the right +# +# Keywords: outer boundary, reflection, symmetric mesh +using HOHQMesh + +# new project +symmetric_mesh = newProject("symmetric_mesh", "out") + +# reset mesh polydeg +setPolynomialOrder!(symmetric_mesh, 6) + +# A background grid is required for the mesh generation +addBackgroundGrid!(symmetric_mesh, [0.2, 0.2, 0.0]) + +# Create all the outer boundary curves and add them to the mesh project. +# Note: (1) Curve names are those that will be present in the mesh file +# (2) Boundary named "symmetry" is where reflection occurs + +line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], + [1.0, 0.0, 0.0]) + +line2 = newEndPointsLineCurve("symmetry", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) + +half_circle = newCircularArcCurve("circle", # curve name + [1.0, 0.75, 0.0], # circle center + 0.25, # circle radius + 270.0, # start angle + 90.0, # end angle + "degrees") # angle units + +line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], + [1.0, 1.5, 0.0]) + +line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], + [0.75, 1.5, 0.0]) + +line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], + [0.75, 1.75, 0.0]) + +line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], + [1.0, 1.75, 0.0]) + +line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], + [1.0, 2.0, 0.0]) + +line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], + [-0.05, 2.0, 0.0]) + +line9 = newEndPointsLineCurve("B9", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) + +# Add all of the boundary curves into +# the project in counter-clockwise order +addCurveToOuterBoundary!(symmetric_mesh, line1) +addCurveToOuterBoundary!(symmetric_mesh, line2) +addCurveToOuterBoundary!(symmetric_mesh, half_circle) +addCurveToOuterBoundary!(symmetric_mesh, line3) +addCurveToOuterBoundary!(symmetric_mesh, line4) +addCurveToOuterBoundary!(symmetric_mesh, line5) +addCurveToOuterBoundary!(symmetric_mesh, line6) +addCurveToOuterBoundary!(symmetric_mesh, line7) +addCurveToOuterBoundary!(symmetric_mesh, line8) +addCurveToOuterBoundary!(symmetric_mesh, line9) + +# Generate the mesh. Saves the mesh file to the directory "out". +generate_mesh(symmetric_mesh) +``` \ No newline at end of file From 02eefde17cbf4bfdb74127e02654f8a3a489d67f Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Sat, 15 Jun 2024 00:48:37 +0200 Subject: [PATCH 02/26] add proper figure links --- docs/src/tutorials/symmetric_mesh.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 074dea53..797674d0 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -24,7 +24,7 @@ julia> using GLMakie, HOHQMesh ``` Now we are ready to interactively generate unstructured quadrilateral meshes! -We create a new project with the name `"symetric_mesh"` and +We create a new project with the name `"symmetric_mesh"` and assign `"out"` to be the folder where any output files from the mesh generation process will be saved. By default, the output files created by HOHQMesh will carry the same name as the project. For example, the resulting HOHQMesh control file from this tutorial @@ -151,7 +151,7 @@ the outer boundary and background grid. The resulting plot is given below. The c curves is called `"Outer"` and its constituent curve segments are labeled accordingly with the names prescribed in the curve construction above. -![before_generation](add_figure1!) +![before_generation](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/6712cbe8-d7bf-4142-99af-dc032f26e768) ## Generate the mesh @@ -194,7 +194,7 @@ The background grid is *removed* from the visualization when the mesh is generat Currently, only the "skeleton" of the mesh is visualized. Thus, the high-order curved boundary information is not seen in the plot but this information **is present** in the generated mesh file. -![first_reflect_mesh](add_figure2!) +![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/daa915fa-11ac-411e-950c-e31958494df3) !!! tip "Boundary names in the mesh file" The boundary names of the original outer curves will be those defined by the user @@ -236,7 +236,7 @@ We visualize the new version of outer boundary curve chain and background grid w plotProject!(symmetric_mesh, MODEL+GRID) ``` -![before_generation2](add_figure3!) +![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2672e82d-6512-491a-9ff6-4ce3fd06da88) We then generate the new mesh from the information contained in `symmetric_mesh`. This saves the control, tec, and mesh files into the `out` folder and yields @@ -264,7 +264,7 @@ generate_mesh(symmetric_mesh) Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 ``` -![first_reflect_mesh2](add_figure4!) +![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/9e416528-dc42-465b-b874-3641bb0d1e7e) ## Summary From 43d7dce60aef8176bfe81a7eeb1125fe746e540b Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Sat, 15 Jun 2024 00:54:49 +0200 Subject: [PATCH 03/26] fix weird spacing --- docs/src/tutorials/symmetric_mesh.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 797674d0..8bb9ea26 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -330,8 +330,7 @@ line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], line9 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], [-0.05, 0.0, 0.0]) -# Add all of the boundary curves into -# the project in counter-clockwise order +# Add all of the boundary curves into the project in counter-clockwise order addCurveToOuterBoundary!(symmetric_mesh, line1) addCurveToOuterBoundary!(symmetric_mesh, line2) addCurveToOuterBoundary!(symmetric_mesh, half_circle) @@ -400,8 +399,7 @@ line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], line9 = newEndPointsLineCurve("B9", [-0.05, 2.0, 0.0], [-0.05, 0.0, 0.0]) -# Add all of the boundary curves into -# the project in counter-clockwise order +# Add all of the boundary curves into the project in counter-clockwise order addCurveToOuterBoundary!(symmetric_mesh, line1) addCurveToOuterBoundary!(symmetric_mesh, line2) addCurveToOuterBoundary!(symmetric_mesh, half_circle) From 3069efe34237e191a6accc1661de63b37968e552 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Tue, 18 Jun 2024 07:27:43 +0200 Subject: [PATCH 04/26] add missing keyword to docstring --- src/HOHQMesh.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HOHQMesh.jl b/src/HOHQMesh.jl index 99c1daa6..fcc51b83 100644 --- a/src/HOHQMesh.jl +++ b/src/HOHQMesh.jl @@ -154,7 +154,7 @@ export MODEL, GRID, MESH, EMPTY, REFINEMENTS, ALL generate_mesh(control_file; output_directory="out", mesh_filename=nothing, plot_filename=nothing, stats_filename=nothing, - verbose=false) + verbose=false, subdivision_maximum=8) Generate a mesh based on the `control_file` with the HOHQMesh mesh generator and store resulting files in `output_directory`. From 16345dea79c691bc9269ebc1e903acf790b3227a Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 12:27:11 +0200 Subject: [PATCH 05/26] add new helper function to rename inner or outer boundary curves --- src/HOHQMesh.jl | 2 +- src/Project/ModelAPI.jl | 16 ++++++------- src/Project/Project.jl | 52 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/HOHQMesh.jl b/src/HOHQMesh.jl index fcc51b83..7003804e 100644 --- a/src/HOHQMesh.jl +++ b/src/HOHQMesh.jl @@ -108,7 +108,7 @@ export addCurveToOuterBoundary!, getInnerBoundaryCurve # Functions from `Project.jl` -export newProject, openProject, saveProject +export newProject, openProject, saveProject, renameCurve! # Functions from `RefinementRegionsAPI.jl` export newRefinementCenter, diff --git a/src/Project/ModelAPI.jl b/src/Project/ModelAPI.jl index bfa5ebc6..c8dac82c 100644 --- a/src/Project/ModelAPI.jl +++ b/src/Project/ModelAPI.jl @@ -224,12 +224,12 @@ function insertInnerBoundaryCurveAtIndex!(proj::Project, crv::Dict{String,Any}, insert!(lst,indx,crv) if i > length(proj.innerBoundaryPoints) # New inner boundary chain - a = [] - push!(a,curvePoints(crv,defaultPlotPts)) - push!(proj.innerBoundaryPoints,a) + a = [] + push!(a,curvePoints(crv,defaultPlotPts)) + push!(proj.innerBoundaryPoints,a) else - innerBoundaryPoints = proj.innerBoundaryPoints[i] - insert!(innerBoundaryPoints,indx,curvePoints(crv,defaultPlotPts)) + innerBoundaryPoints = proj.innerBoundaryPoints[i] + insert!(innerBoundaryPoints,indx,curvePoints(crv,defaultPlotPts)) end insert!(proj.innerBoundaryNames[i],indx,crv["name"]) @@ -247,7 +247,7 @@ function removeInnerBoundaryCurveAtIndex!(proj::Project, indx::Int, chainName::S i, chain = getInnerBoundaryChainWithName(proj,chainName) lst = chain["LIST"] if indx > 0 - crv = lst[indx] + crv = lst[indx] deleteat!(lst, indx) if isempty(lst) # Boundary chain contained a single curve # Complete removal. Requires a different function to be posted @@ -363,7 +363,7 @@ end """ - getInnerBoundaryWithName(proj::Project, name::String) + getInnerBoundaryChainWithName(proj::Project, name::String) Get the inner boundary CHAIN with the given name. If one does not exist, it is created. @@ -395,7 +395,7 @@ end """ function getInnerBoundaryCurve(proj::Project, curveName::String, boundaryName::String) i, chain = getInnerBoundaryChainWithName(proj, boundaryName) - lst = chain["LIST"] + lst = chain["LIST"] for crv in lst if crv["name"] == curveName return crv diff --git a/src/Project/Project.jl b/src/Project/Project.jl index dc42e445..69beb797 100644 --- a/src/Project/Project.jl +++ b/src/Project/Project.jl @@ -281,17 +281,61 @@ function projectGrid(proj::Project) end +""" + renameCurve!(proj::Project, oldName::String, newName::String) + +Any curve(s) on the outer boundary or in the inner boundary chain(s) +with `oldName` are renamed with `newName`. +""" +function renameCurve!(proj::Project, oldName::String, newName::String) +# +# Check if the curve is in the outer boundary +# + for (i, s) in enumerate(proj.outerBndryNames) + if s == oldName + # Rename in global list used in the legend of `proj.plt` + proj.outerBndryNames[i] = newName + # Rename in the appropriate `crv` used when the mesh file is created + crv = getOuterBoundaryCurveWithName(proj, oldName) + setCurveName!(crv, newName) + end + end +# +# Otherwise, find the curve to rename among the inner boundary curve chain(s) +# + chains = getAllInnerBoundaries(proj) + for (chain_idx, chain) in enumerate(chains) + crvList = chain["LIST"] + for (crv_idx, crv) in enumerate(crvList) + if crv["name"] == oldName + # Rename in global list used in the legend of `proj.plt` + proj.innerBoundaryNames[chain_idx][crv_idx] = newName + # Rename in the appropriate `crv` used when the mesh file is created + setCurveName!(crv, newName) + end + end + end + + if !isnothing(proj.plt) + options = proj.plotOptions + updatePlot!(proj, options) + end + + return nothing +end + + # # NOTIFICATION ACTIONS # -function curveDidChange(proj::Project,crv::Dict{String,Any}) +function curveDidChange(proj::Project, crv::Dict{String,Any}) curveName = getCurveName(crv) # # Find the curve location: See if the curve is in the outer boundary # for (i,s) in enumerate(proj.outerBndryNames) if s == curveName - proj.outerBndryPoints[i] = curvePoints(crv,defaultPlotPts) + proj.outerBndryPoints[i] = curvePoints(crv, defaultPlotPts) if !isnothing(proj.plt) options = proj.plotOptions updatePlot!(proj, options) @@ -302,12 +346,12 @@ function curveDidChange(proj::Project,crv::Dict{String,Any}) # # Otherwise, see if it is an inner boundary # - crvNumber, bndryNumber = innerBoundaryIndices(proj,curveName) + crvNumber, bndryNumber = innerBoundaryIndices(proj, curveName) if crvNumber == 0 || bndryNumber == 0 return nothing end innerBoundaryPoints = proj.innerBoundaryPoints[bndryNumber] - innerBoundaryPoints[crvNumber] = curvePoints(crv,defaultPlotPts) + innerBoundaryPoints[crvNumber] = curvePoints(crv, defaultPlotPts) proj.backgroundGridShouldUpdate = true if !isnothing(proj.plt) From a8b03c1c569c7343dcee396e849fe09aa95f63ee Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 14:11:07 +0200 Subject: [PATCH 06/26] rewrite and simplify the symmetric mesh tutorial --- docs/src/tutorials/introduction.md | 6 +- docs/src/tutorials/symmetric_mesh.md | 225 ++++++++++----------------- 2 files changed, 87 insertions(+), 144 deletions(-) diff --git a/docs/src/tutorials/introduction.md b/docs/src/tutorials/introduction.md index 0cccf406..389f50ea 100644 --- a/docs/src/tutorials/introduction.md +++ b/docs/src/tutorials/introduction.md @@ -85,9 +85,8 @@ Demonstrates how to: ## [Symmetric mesh](@ref) This tutorial constructs a mesh given a closed chain of outer boundary curves -that is then reflected over a straight line indicated by the user. -The result is a mesh that is symmetric with respect to the prescribed -straight line. +that is then reflected over a straight line or several co-linear lines indicated by the user. +The result is a mesh that is symmetric with respect to the prescribed straight line. ### Synopsis @@ -95,4 +94,5 @@ Demonstrates how to: * Indicate a symmetry boundary line. * Construct an outer boundary with several connected curves. * Add the background grid when an outer boundary curve is present. +* Rename boundaries in an existing interactive mesh project. * Visualize an interactive mesh project. \ No newline at end of file diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 8bb9ea26..47dbd79c 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -2,7 +2,7 @@ The purpose of this tutorial is to demonstrate how to create an unstructured mesh that is symmetric with respect to a straight line outer boundary prescribed by the user. -At the end of this tutorial one can find the scripts necessary to generate the meshes +At the end of this tutorial one can find the script necessary to generate the meshes described herein. ### Synopsis @@ -11,6 +11,7 @@ This tutorial demonstrates how to: * Indicate a symmetry boundary line. * Construct an outer boundary with several connected curves. * Add the background grid when an outer boundary curve is present. +* Rename boundaries in an existing interactive mesh project. * Visualize an interactive mesh project. ## Initialization @@ -67,9 +68,9 @@ grid near sharp features of any curved boundaries. For a domain bounded by an outer boundary curve, this background grid is set by indicating the desired element size in the $x$ and $y$ directions. To start, we set the background grid for `symmetric_mesh` -to have elements with side length $0.2$ in each direction +to have elements with side length $0.25$ in each direction ```julia -addBackgroundGrid!(spline_project, [0.2, 0.2, 0.0]) +addBackgroundGrid!(spline_project, [0.25, 0.25, 0.0]) ``` ## Add the outer boundary @@ -79,10 +80,13 @@ This outer boundary is composed of nine straight line segments and a half circle The curves are created such that they can be added to the mesh project `symmetric_mesh` in counter-clockwise order as required by HOHQMesh. ```julia -line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], +line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) + +line2 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], [1.0, 0.0, 0.0]) -line2 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], +line3 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], [1.0, 0.5, 0.0]) half_circle = newCircularArcCurve("circle", # curve name @@ -92,26 +96,23 @@ half_circle = newCircularArcCurve("circle", # curve name 90.0, # end angle "degrees") # angle units -line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], +line4 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], [1.0, 1.5, 0.0]) -line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], +line5 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], [0.75, 1.5, 0.0]) -line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], +line6 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], [0.75, 1.75, 0.0]) -line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], +line7 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], [1.0, 1.75, 0.0]) -line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], +line8 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], [1.0, 2.0, 0.0]) -line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], +line9 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], [-0.05, 2.0, 0.0]) - -line9 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) ``` The given boundary names will also be the names given in the resulting mesh file. The only exception is the final boundary curve that is given @@ -121,8 +122,8 @@ a reflection will occur. !!! tip "Name of the symmetry boundary" As noted above, `"symmetry"` is a keyword for the HOHQMesh generator that - prescribes over which line a reflection of the mesh occurs. Note - that Julia is a case sensitive language but Fortran is not. So, within the + prescribes over which line a reflection of the mesh occurs. The Fortran implementation + for this keyword in HOHQMesh is not case sensitive. So, within the Julia script one can name this reflection boundary line `"symmetry"` or `"Symmetry"` or `"SYMMETRY"` or even something strange like `"sYmMeTrY"` and the mesh will still generate successfully. @@ -169,21 +170,21 @@ generate_mesh(symmetric_mesh) ******************* 2D Mesh Statistics: ******************* - Total time = 4.3447999999999987E-002 - Number of nodes = 422 - Number of Edges = 773 - Number of Elements = 352 + Total time = 4.0154999999999996E-002 + Number of nodes = 343 + Number of Edges = 626 + Number of Elements = 284 Number of Subdivisions = 2 Mesh Quality: Measure Minimum Maximum Average Acceptable Low Acceptable High Reference - Signed Area 0.00147112 0.04240553 0.01102461 0.00000000 999.99900000 1.00000000 - Aspect Ratio 1.00102845 2.37276773 1.22432027 1.00000000 999.99900000 1.00000000 - Condition 1.00000549 2.97426696 1.13908196 1.00000000 4.00000000 1.00000000 - Edge Ratio 1.00185169 4.29126482 1.45727892 1.00000000 4.00000000 1.00000000 - Jacobian 0.00084327 0.03918949 0.00931776 0.00000000 999.99900000 1.00000000 - Minimum Angle 40.68137900 89.81152621 75.30939242 40.00000000 90.00000000 90.00000000 - Maximum Angle 90.10587561 140.86941819 105.72816725 90.00000000 135.00000000 90.00000000 + Signed Area 0.00227157 0.06552808 0.01366911 0.00000000 999.99900000 1.00000000 + Aspect Ratio 1.00389317 2.07480912 1.22443835 1.00000000 999.99900000 1.00000000 + Condition 1.00048947 1.93007666 1.12853177 1.00000000 4.00000000 1.00000000 + Edge Ratio 1.00607156 3.56541719 1.44892631 1.00000000 4.00000000 1.00000000 + Jacobian 0.00158627 0.06202757 0.01120120 0.00000000 999.99900000 1.00000000 + Minimum Angle 48.35050023 89.33703938 75.39251039 40.00000000 90.00000000 90.00000000 + Maximum Angle 90.94150752 129.91539960 106.20679399 90.00000000 135.00000000 90.00000000 Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 ``` The call to `generate_mesh` also prints mesh quality statistics to the screen @@ -199,42 +200,36 @@ The background grid is *removed* from the visualization when the mesh is generat !!! tip "Boundary names in the mesh file" The boundary names of the original outer curves will be those defined by the user in their construction above. The boundary labeled `"symmetry"` is now internal and - is marked appropriately as such. The reflected outer boundary names are appended + is marked appropriately as such. The reflected boundary names are appended with `_R` (for reflected) in the mesh file. For instance, the reflected version of the boundary `B2` has the name `B2_R` or the boundary named `circle` has the reflected boundary counterpart named `circle_R`. ## Changing the reflection line -As an illustration, we redefine which of the straight lines in the outer boundary -curve chain is used for the reflection. Instead of the left boundary `O.10` in the -above example, we now set the reflection line to be the `O.2` curve on the right. -In doing so, we now label the left boundary curve `O.10` to be `"B9"`. -The redefinition of these two outer boundary curves are +We remove the current mesh that was just generated and re-plot the model curves +and background grid. ```julia -line2 = newEndPointsLineCurve("symmetry", [1.0, 0.0, 0.0], - [1.0, 0.5, 0.0]) -line9 = newEndPointsLineCurve("B9", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) -``` -We then redefine the complete outer boundary in the `symmetric_mesh` project -(again in counter-clockwise order) with -```julia -addCurveToOuterBoundary!(symmetric_mesh, line1) -addCurveToOuterBoundary!(symmetric_mesh, line2) -addCurveToOuterBoundary!(symmetric_mesh, half_circle) -addCurveToOuterBoundary!(symmetric_mesh, line3) -addCurveToOuterBoundary!(symmetric_mesh, line4) -addCurveToOuterBoundary!(symmetric_mesh, line5) -addCurveToOuterBoundary!(symmetric_mesh, line6) -addCurveToOuterBoundary!(symmetric_mesh, line7) -addCurveToOuterBoundary!(symmetric_mesh, line8) -addCurveToOuterBoundary!(symmetric_mesh, line9) +remove_mesh!(symmetric_mesh) +updatePlot!(symmetric_mesh, MODEL+GRID) ``` -We visualize the new version of outer boundary curve chain and background grid with +Additionally, the `remove_mesh!` command deletes the mesh information from +the interactive mesh project `symmetric_mesh` and the mesh file `symmetric_mesh.mesh` +from the `out` folder. However, the `symmetric_mesh.control` +and `symmetric_mesh.tec` files are still present in `out` directory. + +It is also possible to create a symmetry boundary composed of multiple be co-linear segments. +To illustrate this we first rename the current symmetry boundary curve `O.1` to have the name `"B9"`. +Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `"symmetry"`. +This is done with the function `renameCurve!` ```julia -plotProject!(symmetric_mesh, MODEL+GRID) +renameCurve!(symmetric_mesh, "symmetry", # existing curve name + "B9") # new curve name +renameCurve!(symmetric_mesh, "B2", "symmetry") +renameCurve!(symmetric_mesh, "B3", "symmetry") +renameCurve!(symmetric_mesh, "B7", "symmetry") ``` +After the boundary names are adjusted the plot updates automatically to give the figure below. ![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2672e82d-6512-491a-9ff6-4ce3fd06da88) @@ -246,23 +241,26 @@ generate_mesh(symmetric_mesh) ******************* 2D Mesh Statistics: ******************* - Total time = 4.4684999999999975E-002 - Number of nodes = 428 - Number of Edges = 779 - Number of Elements = 352 + Total time = 3.7763000000000019E-002 + Number of nodes = 337 + Number of Edges = 622 + Number of Elements = 284 Number of Subdivisions = 2 Mesh Quality: Measure Minimum Maximum Average Acceptable Low Acceptable High Reference - Signed Area 0.00147112 0.04240553 0.01102461 0.00000000 999.99900000 1.00000000 - Aspect Ratio 1.00102845 2.37276773 1.22432027 1.00000000 999.99900000 1.00000000 - Condition 1.00000549 2.97426696 1.13908196 1.00000000 4.00000000 1.00000000 - Edge Ratio 1.00185169 4.29126482 1.45727892 1.00000000 4.00000000 1.00000000 - Jacobian 0.00084327 0.03918949 0.00931776 0.00000000 999.99900000 1.00000000 - Minimum Angle 40.68137900 89.81152621 75.30939242 40.00000000 90.00000000 90.00000000 - Maximum Angle 90.10587561 140.86941819 105.72816725 90.00000000 135.00000000 90.00000000 + Signed Area 0.00227157 0.06552808 0.01366911 0.00000000 999.99900000 1.00000000 + Aspect Ratio 1.00389317 2.07480912 1.22443835 1.00000000 999.99900000 1.00000000 + Condition 1.00048947 1.93007666 1.12853177 1.00000000 4.00000000 1.00000000 + Edge Ratio 1.00607156 3.56541719 1.44892631 1.00000000 4.00000000 1.00000000 + Jacobian 0.00158627 0.06202757 0.01120120 0.00000000 999.99900000 1.00000000 + Minimum Angle 48.35050023 89.33703938 75.39251039 40.00000000 90.00000000 90.00000000 + Maximum Angle 90.94150752 129.91539960 106.20679399 90.00000000 135.00000000 90.00000000 Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 ``` +The updated visualization is given below. Note, the flexibility to define multiple +co-linear symmetric boundaries creates a symmetric mesh with closed internal boundaries. +In this example, a circle and a rectangle. ![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/9e416528-dc42-465b-b874-3641bb0d1e7e) @@ -272,6 +270,7 @@ In this tutorial we demonstrated how to: * Indicate a symmetry boundary line. * Construct an outer boundary with several connected curves. * Add the background grid when an outer boundary curve is present. +* Rename boundaries in an existing interactive mesh project. * Visualize an interactive mesh project. For completeness, we include two scripts with all the commands to generate the meshes displayed @@ -290,16 +289,19 @@ symmetric_mesh = newProject("symmetric_mesh", "out") setPolynomialOrder!(symmetric_mesh, 6) # A background grid is required for the mesh generation -addBackgroundGrid!(symmetric_mesh, [0.2, 0.2, 0.0]) +addBackgroundGrid!(symmetric_mesh, [0.25, 0.25, 0.0]) # Create all the outer boundary curves and add them to the mesh project. # Note: (1) Curve names are those that will be present in the mesh file # (2) Boundary named "symmetry" is where reflection occurs -line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], +line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) + +line2 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], [1.0, 0.0, 0.0]) -line2 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], +line3 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], [1.0, 0.5, 0.0]) half_circle = newCircularArcCurve("circle", # curve name @@ -309,28 +311,24 @@ half_circle = newCircularArcCurve("circle", # curve name 90.0, # end angle "degrees") # angle units -line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], +line4 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], [1.0, 1.5, 0.0]) -line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], +line5 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], [0.75, 1.5, 0.0]) -line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], +line6 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], [0.75, 1.75, 0.0]) -line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], +line7 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], [1.0, 1.75, 0.0]) -line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], +line8 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], [1.0, 2.0, 0.0]) -line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], +line9 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], [-0.05, 2.0, 0.0]) -line9 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) - -# Add all of the boundary curves into the project in counter-clockwise order addCurveToOuterBoundary!(symmetric_mesh, line1) addCurveToOuterBoundary!(symmetric_mesh, line2) addCurveToOuterBoundary!(symmetric_mesh, half_circle) @@ -344,72 +342,17 @@ addCurveToOuterBoundary!(symmetric_mesh, line9) # Generate the mesh. Saves the mesh file to the directory "out". generate_mesh(symmetric_mesh) -``` -and -```julia -# Interactive mesh with reflection on the right -# -# Keywords: outer boundary, reflection, symmetric mesh -using HOHQMesh - -# new project -symmetric_mesh = newProject("symmetric_mesh", "out") - -# reset mesh polydeg -setPolynomialOrder!(symmetric_mesh, 6) - -# A background grid is required for the mesh generation -addBackgroundGrid!(symmetric_mesh, [0.2, 0.2, 0.0]) - -# Create all the outer boundary curves and add them to the mesh project. -# Note: (1) Curve names are those that will be present in the mesh file -# (2) Boundary named "symmetry" is where reflection occurs - -line1 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], - [1.0, 0.0, 0.0]) - -line2 = newEndPointsLineCurve("symmetry", [1.0, 0.0, 0.0], - [1.0, 0.5, 0.0]) - -half_circle = newCircularArcCurve("circle", # curve name - [1.0, 0.75, 0.0], # circle center - 0.25, # circle radius - 270.0, # start angle - 90.0, # end angle - "degrees") # angle units -line3 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], - [1.0, 1.5, 0.0]) - -line4 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], - [0.75, 1.5, 0.0]) - -line5 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], - [0.75, 1.75, 0.0]) +# Delete the existing mesh before modifying boundary names. +remove_mesh!(symmetric_mesh) -line6 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], - [1.0, 1.75, 0.0]) - -line7 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], - [1.0, 2.0, 0.0]) - -line8 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], - [-0.05, 2.0, 0.0]) - -line9 = newEndPointsLineCurve("B9", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) - -# Add all of the boundary curves into the project in counter-clockwise order -addCurveToOuterBoundary!(symmetric_mesh, line1) -addCurveToOuterBoundary!(symmetric_mesh, line2) -addCurveToOuterBoundary!(symmetric_mesh, half_circle) -addCurveToOuterBoundary!(symmetric_mesh, line3) -addCurveToOuterBoundary!(symmetric_mesh, line4) -addCurveToOuterBoundary!(symmetric_mesh, line5) -addCurveToOuterBoundary!(symmetric_mesh, line6) -addCurveToOuterBoundary!(symmetric_mesh, line7) -addCurveToOuterBoundary!(symmetric_mesh, line8) -addCurveToOuterBoundary!(symmetric_mesh, line9) +# Rename the outer boundaries appropriately to set the symmetry boundary +# on the right composed of multiple co-linear segments. +renameCurve!(symmetric_mesh, "symmetry", # existing curve name + "B9") # new curve name +renameCurve!(symmetric_mesh, "B2", "symmetry") +renameCurve!(symmetric_mesh, "B3", "symmetry") +renameCurve!(symmetric_mesh, "B7", "symmetry") # Generate the mesh. Saves the mesh file to the directory "out". generate_mesh(symmetric_mesh) From 6378fe5031aa168cfc70744d53007e73ef4935db Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 14:30:04 +0200 Subject: [PATCH 07/26] adjust boundary names in tutorital to make it easier to follow --- docs/src/tutorials/symmetric_mesh.md | 93 ++++++++++++++-------------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 47dbd79c..ae78d423 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -83,11 +83,11 @@ in counter-clockwise order as required by HOHQMesh. line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], [-0.05, 0.0, 0.0]) -line2 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], - [1.0, 0.0, 0.0]) +line2 = newEndPointsLineCurve("bottom", [-0.05, 0.0, 0.0], + [1.0, 0.0, 0.0]) -line3 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], - [1.0, 0.5, 0.0]) +line3 = newEndPointsLineCurve("right", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) half_circle = newCircularArcCurve("circle", # curve name [1.0, 0.75, 0.0], # circle center @@ -96,23 +96,23 @@ half_circle = newCircularArcCurve("circle", # curve name 90.0, # end angle "degrees") # angle units -line4 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], - [1.0, 1.5, 0.0]) +line4 = newEndPointsLineCurve("right", [1.0, 1.0, 0.0], + [1.0, 1.5, 0.0]) -line5 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], - [0.75, 1.5, 0.0]) +line5 = newEndPointsLineCurve("bump", [1.0, 1.5, 0.0], + [0.75, 1.5, 0.0]) -line6 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], - [0.75, 1.75, 0.0]) +line6 = newEndPointsLineCurve("bump", [0.75, 1.5, 0.0], + [0.75, 1.75, 0.0]) -line7 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], - [1.0, 1.75, 0.0]) +line7 = newEndPointsLineCurve("bump", [0.75, 1.75, 0.0], + [1.0, 1.75, 0.0]) -line8 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], - [1.0, 2.0, 0.0]) +line8 = newEndPointsLineCurve("right", [1.0, 1.75, 0.0], + [1.0, 2.0, 0.0]) -line9 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], - [-0.05, 2.0, 0.0]) +line9 = newEndPointsLineCurve("top", [1.0, 2.0, 0.0], + [-0.05, 2.0, 0.0]) ``` The given boundary names will also be the names given in the resulting mesh file. The only exception is the final boundary curve that is given @@ -152,7 +152,7 @@ the outer boundary and background grid. The resulting plot is given below. The c curves is called `"Outer"` and its constituent curve segments are labeled accordingly with the names prescribed in the curve construction above. -![before_generation](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/6712cbe8-d7bf-4142-99af-dc032f26e768) +![before_generation](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/d332e86a-f958-4362-81b9-2ad40a408d94) ## Generate the mesh @@ -195,14 +195,14 @@ The background grid is *removed* from the visualization when the mesh is generat Currently, only the "skeleton" of the mesh is visualized. Thus, the high-order curved boundary information is not seen in the plot but this information **is present** in the generated mesh file. -![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/daa915fa-11ac-411e-950c-e31958494df3) +![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/1afd159e-e8c4-459f-ba7d-a31057b0c135) !!! tip "Boundary names in the mesh file" The boundary names of the original outer curves will be those defined by the user in their construction above. The boundary labeled `"symmetry"` is now internal and is marked appropriately as such. The reflected boundary names are appended with `_R` (for reflected) in the mesh file. For instance, the reflected version - of the boundary `B2` has the name `B2_R` or the boundary named `circle` has the + of the boundary `bottom` has the name `bottom_R` or the boundary named `circle` has the reflected boundary counterpart named `circle_R`. ## Changing the reflection line @@ -219,19 +219,17 @@ from the `out` folder. However, the `symmetric_mesh.control` and `symmetric_mesh.tec` files are still present in `out` directory. It is also possible to create a symmetry boundary composed of multiple be co-linear segments. -To illustrate this we first rename the current symmetry boundary curve `O.1` to have the name `"B9"`. +To illustrate this we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `"symmetry"`. This is done with the function `renameCurve!` ```julia renameCurve!(symmetric_mesh, "symmetry", # existing curve name - "B9") # new curve name -renameCurve!(symmetric_mesh, "B2", "symmetry") -renameCurve!(symmetric_mesh, "B3", "symmetry") -renameCurve!(symmetric_mesh, "B7", "symmetry") + "left") # new curve name +renameCurve!(symmetric_mesh, "right", "symmetry") ``` After the boundary names are adjusted the plot updates automatically to give the figure below. -![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2672e82d-6512-491a-9ff6-4ce3fd06da88) +![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/314a7bc7-0cb1-4708-bbb9-98ca85798d5b) We then generate the new mesh from the information contained in `symmetric_mesh`. This saves the control, tec, and mesh files into the `out` folder and yields @@ -262,7 +260,7 @@ The updated visualization is given below. Note, the flexibility to define multip co-linear symmetric boundaries creates a symmetric mesh with closed internal boundaries. In this example, a circle and a rectangle. -![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/9e416528-dc42-465b-b874-3641bb0d1e7e) +![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2476b6fe-79a4-4d3a-98b1-089714c76ade) ## Summary @@ -274,8 +272,9 @@ In this tutorial we demonstrated how to: * Visualize an interactive mesh project. For completeness, we include two scripts with all the commands to generate the meshes displayed -for a reflection about the left boundary line `O.10` and a reflection about the right boundary -line `O.2`. Note, we **do not** include the plotting in these scripts. +for a reflection about the left boundary line `O.1` as well as a reflection about +the right boundary composed of the three co-linear segments `O.3`, `O.5`, and `O.9`. +Note, we **do not** include the plotting in these scripts. ```julia # Interactive mesh with reflection on the left # @@ -298,11 +297,11 @@ addBackgroundGrid!(symmetric_mesh, [0.25, 0.25, 0.0]) line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], [-0.05, 0.0, 0.0]) -line2 = newEndPointsLineCurve("B1", [-0.05, 0.0, 0.0], - [1.0, 0.0, 0.0]) +line2 = newEndPointsLineCurve("bottom", [-0.05, 0.0, 0.0], + [1.0, 0.0, 0.0]) -line3 = newEndPointsLineCurve("B2", [1.0, 0.0, 0.0], - [1.0, 0.5, 0.0]) +line3 = newEndPointsLineCurve("right", [1.0, 0.0, 0.0], + [1.0, 0.5, 0.0]) half_circle = newCircularArcCurve("circle", # curve name [1.0, 0.75, 0.0], # circle center @@ -311,23 +310,23 @@ half_circle = newCircularArcCurve("circle", # curve name 90.0, # end angle "degrees") # angle units -line4 = newEndPointsLineCurve("B3", [1.0, 1.0, 0.0], - [1.0, 1.5, 0.0]) +line4 = newEndPointsLineCurve("right", [1.0, 1.0, 0.0], + [1.0, 1.5, 0.0]) -line5 = newEndPointsLineCurve("B4", [1.0, 1.5, 0.0], - [0.75, 1.5, 0.0]) +line5 = newEndPointsLineCurve("bump", [1.0, 1.5, 0.0], + [0.75, 1.5, 0.0]) -line6 = newEndPointsLineCurve("B5", [0.75, 1.5, 0.0], - [0.75, 1.75, 0.0]) +line6 = newEndPointsLineCurve("bump", [0.75, 1.5, 0.0], + [0.75, 1.75, 0.0]) -line7 = newEndPointsLineCurve("B6", [0.75, 1.75, 0.0], - [1.0, 1.75, 0.0]) +line7 = newEndPointsLineCurve("bump", [0.75, 1.75, 0.0], + [1.0, 1.75, 0.0]) -line8 = newEndPointsLineCurve("B7", [1.0, 1.75, 0.0], - [1.0, 2.0, 0.0]) +line8 = newEndPointsLineCurve("right", [1.0, 1.75, 0.0], + [1.0, 2.0, 0.0]) -line9 = newEndPointsLineCurve("B8", [1.0, 2.0, 0.0], - [-0.05, 2.0, 0.0]) +line9 = newEndPointsLineCurve("top", [1.0, 2.0, 0.0], + [-0.05, 2.0, 0.0]) addCurveToOuterBoundary!(symmetric_mesh, line1) addCurveToOuterBoundary!(symmetric_mesh, line2) @@ -349,10 +348,8 @@ remove_mesh!(symmetric_mesh) # Rename the outer boundaries appropriately to set the symmetry boundary # on the right composed of multiple co-linear segments. renameCurve!(symmetric_mesh, "symmetry", # existing curve name - "B9") # new curve name -renameCurve!(symmetric_mesh, "B2", "symmetry") -renameCurve!(symmetric_mesh, "B3", "symmetry") -renameCurve!(symmetric_mesh, "B7", "symmetry") + "left") # new curve name +renameCurve!(symmetric_mesh, "right", "symmetry") # Generate the mesh. Saves the mesh file to the directory "out". generate_mesh(symmetric_mesh) From afe1b96405752e60d25300b01f36121092a2562f Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 14:34:46 +0200 Subject: [PATCH 08/26] update text in final script at the end of the tutorial --- docs/src/tutorials/symmetric_mesh.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index ae78d423..e93ce218 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -276,7 +276,8 @@ for a reflection about the left boundary line `O.1` as well as a reflection abou the right boundary composed of the three co-linear segments `O.3`, `O.5`, and `O.9`. Note, we **do not** include the plotting in these scripts. ```julia -# Interactive mesh with reflection on the left +# Interactive mesh with reflection on the left over a single symmetry boundary +# as well as a reflection on the right over multiple co-linear symmetry boundaries. # # Keywords: outer boundary, reflection, symmetric mesh using HOHQMesh From 23b3ed31c6fbef0de7a63a256e08f9d3c9a8b913 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 14:57:08 +0200 Subject: [PATCH 09/26] add test for new renaming helper function --- test/test_project_with_viz.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_project_with_viz.jl b/test/test_project_with_viz.jl index 6b77cf52..58e983e6 100644 --- a/test/test_project_with_viz.jl +++ b/test/test_project_with_viz.jl @@ -33,6 +33,13 @@ using CairoMakie outer_line2 = newEndPointsLineCurve("outerline2", [-5.0, 3.0, 0.0], [0.0, -7.0, 0.0]) add!(p_scratch, outer_line2) + # Initial test the boundary name is correct + @test getCurveName(getOuterBoundaryCurveWithName(p_scratch, "outerline2")) == "outerline2" + + # Rename one of the outer boundary names and test that it was sucessful + renameCurve!(p_scratch, "outerline2", "LINE2") + @test getCurveName(getOuterBoundaryCurveWithName(p_scratch, "LINE2")) == "LINE2" + # Check the computed background grid against expected values x_grid_control = [-8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] y_grid_control = [-8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] @@ -52,6 +59,9 @@ using CairoMakie inner_top_arc = newCircularArcCurve("innerTopArc", [0.0, 5.0, 0.0], 1.0, 180.0, 0.0, "degrees") add!(p_scratch, inner_top_arc, "inner1") + # Rename one of the inner boundary names + renameCurve!(p_scratch, "innerBottomArc", "BottomArc") + # Add in a refinement center and adjust its width manually cent = newRefinementCenter("center1", "smooth", [0.0, -1.0, 0.0], 0.25, 1.0) add!(p_scratch, cent) From 121d7a2732de4c3c2140de9f1bedaceff2e781de Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Wed, 19 Jun 2024 14:59:22 +0200 Subject: [PATCH 10/26] fix typo --- test/test_project_with_viz.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_project_with_viz.jl b/test/test_project_with_viz.jl index 58e983e6..8b6282ba 100644 --- a/test/test_project_with_viz.jl +++ b/test/test_project_with_viz.jl @@ -36,7 +36,7 @@ using CairoMakie # Initial test the boundary name is correct @test getCurveName(getOuterBoundaryCurveWithName(p_scratch, "outerline2")) == "outerline2" - # Rename one of the outer boundary names and test that it was sucessful + # Rename one of the outer boundary names and test that it was successful renameCurve!(p_scratch, "outerline2", "LINE2") @test getCurveName(getOuterBoundaryCurveWithName(p_scratch, "LINE2")) == "LINE2" From a70681ce51320659cf34f63102bb71935cae1033 Mon Sep 17 00:00:00 2001 From: DavidAKopriva <85404032+DavidAKopriva@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:21:02 -0400 Subject: [PATCH 11/26] Update symmetric_mesh.md Make some corrections and editorial cahnges. --- docs/src/tutorials/symmetric_mesh.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index e93ce218..f60992e1 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -1,7 +1,7 @@ # Symmetric mesh The purpose of this tutorial is to demonstrate how to create an unstructured mesh -that is symmetric with respect to a straight line outer boundary prescribed by the user. +that is symmetric with respect to a straight line outer boundary as prescribed by the user. At the end of this tutorial one can find the script necessary to generate the meshes described herein. @@ -77,7 +77,7 @@ addBackgroundGrid!(spline_project, [0.25, 0.25, 0.0]) With the background grid size set, we next build the outer boundary for the present mesh project. This outer boundary is composed of nine straight line segments and a half circle arc. -The curves are created such that they can be added to the mesh project `symmetric_mesh` +The curves will afterwards be added to the mesh project `symmetric_mesh` in counter-clockwise order as required by HOHQMesh. ```julia line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], @@ -114,13 +114,12 @@ line8 = newEndPointsLineCurve("right", [1.0, 1.75, 0.0], line9 = newEndPointsLineCurve("top", [1.0, 2.0, 0.0], [-0.05, 2.0, 0.0]) ``` -The given boundary names will also be the names given in the resulting -mesh file. The only exception is the final boundary curve that is given -the name `"symmetry"`. This outer boundary curve is a special keyword -in HOHQMesh that indicates the prescribed straight line over which +The given boundary names will also be the element boundary names written to the mesh file. The only exception is the first boundary curve that is given +the name `"symmetry"`. The name of this outer boundary curve is a special keyword +in HOHQMesh that says it is the straight line across which a reflection will occur. -!!! tip "Name of the symmetry boundary" +!!! tip: "Name of the symmetry boundary" As noted above, `"symmetry"` is a keyword for the HOHQMesh generator that prescribes over which line a reflection of the mesh occurs. The Fortran implementation for this keyword in HOHQMesh is not case sensitive. So, within the @@ -187,13 +186,13 @@ generate_mesh(symmetric_mesh) Maximum Angle 90.94150752 129.91539960 106.20679399 90.00000000 135.00000000 90.00000000 Area Sign 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 1.00000000 ``` -The call to `generate_mesh` also prints mesh quality statistics to the screen +Note that the call to `generate_mesh` prints mesh quality statistics to the screen and updates the visualization. The background grid is *removed* from the visualization when the mesh is generated. !!! note "Mesh visualization" Currently, only the "skeleton" of the mesh is visualized. Thus, the high-order curved boundary information - is not seen in the plot but this information **is present** in the generated mesh file. + is not seen in the plot but this information **is present** in the mesh file generated. ![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/1afd159e-e8c4-459f-ba7d-a31057b0c135) @@ -203,11 +202,13 @@ The background grid is *removed* from the visualization when the mesh is generat is marked appropriately as such. The reflected boundary names are appended with `_R` (for reflected) in the mesh file. For instance, the reflected version of the boundary `bottom` has the name `bottom_R` or the boundary named `circle` has the - reflected boundary counterpart named `circle_R`. + reflected boundary counterpart named `circle_R`. These can be changed as desired by editing the mesh file. ## Changing the reflection line -We remove the current mesh that was just generated and re-plot the model curves +It is also possible to create a symmetry boundary composed of multiple be co-linear segments. + +To change the line along which the mesh is reflected, we remove the current mesh that was just generated and re-plot the model curves and background grid. ```julia remove_mesh!(symmetric_mesh) @@ -218,8 +219,8 @@ the interactive mesh project `symmetric_mesh` and the mesh file `symmetric_mesh. from the `out` folder. However, the `symmetric_mesh.control` and `symmetric_mesh.tec` files are still present in `out` directory. -It is also possible to create a symmetry boundary composed of multiple be co-linear segments. -To illustrate this we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. + +To illustrate the reflection about multiple boundary curves (which must be co-linear!), we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `"symmetry"`. This is done with the function `renameCurve!` ```julia From f62440eb07b896cef9fc4e563592fe5d6d0dda16 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Thu, 20 Jun 2024 21:32:07 +0200 Subject: [PATCH 12/26] remove colon to render tip box in docs --- docs/src/tutorials/symmetric_mesh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index f60992e1..cfdeb61c 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -119,7 +119,7 @@ the name `"symmetry"`. The name of this outer boundary curve is a special keywor in HOHQMesh that says it is the straight line across which a reflection will occur. -!!! tip: "Name of the symmetry boundary" +!!! tip "Name of the symmetry boundary" As noted above, `"symmetry"` is a keyword for the HOHQMesh generator that prescribes over which line a reflection of the mesh occurs. The Fortran implementation for this keyword in HOHQMesh is not case sensitive. So, within the From 37b27fd73975ea95d3cbd416c26c45799305948e Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Thu, 20 Jun 2024 21:34:50 +0200 Subject: [PATCH 13/26] add line breaks for readibility of the markdown source --- docs/src/tutorials/symmetric_mesh.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index cfdeb61c..2826008d 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -114,7 +114,8 @@ line8 = newEndPointsLineCurve("right", [1.0, 1.75, 0.0], line9 = newEndPointsLineCurve("top", [1.0, 2.0, 0.0], [-0.05, 2.0, 0.0]) ``` -The given boundary names will also be the element boundary names written to the mesh file. The only exception is the first boundary curve that is given +The given boundary names will also be the element boundary names written to the mesh file. +The only exception is the first boundary curve that is given the name `"symmetry"`. The name of this outer boundary curve is a special keyword in HOHQMesh that says it is the straight line across which a reflection will occur. @@ -208,7 +209,8 @@ The background grid is *removed* from the visualization when the mesh is generat It is also possible to create a symmetry boundary composed of multiple be co-linear segments. -To change the line along which the mesh is reflected, we remove the current mesh that was just generated and re-plot the model curves +To change the line along which the mesh is reflected, we remove the current mesh +that was just generated and re-plot the model curves and background grid. ```julia remove_mesh!(symmetric_mesh) @@ -220,7 +222,8 @@ from the `out` folder. However, the `symmetric_mesh.control` and `symmetric_mesh.tec` files are still present in `out` directory. -To illustrate the reflection about multiple boundary curves (which must be co-linear!), we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. +To illustrate the reflection about multiple boundary curves (which must be co-linear!), +we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `"symmetry"`. This is done with the function `renameCurve!` ```julia @@ -286,7 +289,7 @@ using HOHQMesh # new project symmetric_mesh = newProject("symmetric_mesh", "out") -# reset mesh polydeg +# reset the polynomial degree of the mesh setPolynomialOrder!(symmetric_mesh, 6) # A background grid is required for the mesh generation From 8582410e4fbdd945ca64cae2b991b4020f6689a7 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Thu, 20 Jun 2024 22:26:27 +0200 Subject: [PATCH 14/26] update remove_mesh command to remove control, plot and stats files --- docs/src/tutorials/create_edit_curves.md | 4 ++-- docs/src/tutorials/symmetric_mesh.md | 7 +++---- src/Mesh/Meshing.jl | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/src/tutorials/create_edit_curves.md b/docs/src/tutorials/create_edit_curves.md index 04f6ced6..6f446f03 100644 --- a/docs/src/tutorials/create_edit_curves.md +++ b/docs/src/tutorials/create_edit_curves.md @@ -280,8 +280,8 @@ remove_mesh!(sandbox_project) updatePlot!(sandbox_project, MODEL+GRID) ``` Additionally, the `remove_mesh!` command deletes the mesh information from the `sandbox_project` -and `sandbox.mesh` from the `out` folder. However, the `sandbox.control` and `sandbox.tec` files -are still present in `out` directory. +as well as the mesh file `sandbox.mesh`, control file `sandbox.control`, plot file `sandbox.tec`, +and mesh statistics file `sandbox.txt` from the `out` folder. ## Edit an inner boundary chain diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 2826008d..39ba0883 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -217,10 +217,9 @@ remove_mesh!(symmetric_mesh) updatePlot!(symmetric_mesh, MODEL+GRID) ``` Additionally, the `remove_mesh!` command deletes the mesh information from -the interactive mesh project `symmetric_mesh` and the mesh file `symmetric_mesh.mesh` -from the `out` folder. However, the `symmetric_mesh.control` -and `symmetric_mesh.tec` files are still present in `out` directory. - +the interactive mesh project `symmetric_mesh` as well as the mesh file `symmetric_mesh.mesh`, +control file `symmetric_mesh.control`, plot file `symmetric_mesh.tec`, +and mesh statistics file `symmetric_mesh.txt` from the `out` folder. To illustrate the reflection about multiple boundary curves (which must be co-linear!), we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. diff --git a/src/Mesh/Meshing.jl b/src/Mesh/Meshing.jl index 8aaceef7..fa101405 100644 --- a/src/Mesh/Meshing.jl +++ b/src/Mesh/Meshing.jl @@ -51,11 +51,21 @@ end """ remove_mesh!(proj::Project) -Remove the mesh file from `proj.projectDirectory` and delete the mesh from the plot +Remove the mesh file, control file, plot file, and stats file from `proj.projectDirectory` +and delete the mesh from the plot. """ function remove_mesh!(proj::Project) - meshFile = getMeshFileName(proj) - rm(meshFile) + # Remove all the output files associated with the current `proj` + fileName = getMeshFileName(proj) + rm(fileName) + # Get the control file name of the current project + fileName = joinpath(proj.projectDirectory,proj.name) * ".control" + rm(fileName) + fileName = getPlotFileName(proj) + rm(fileName) + fileName = getStatsFileName(proj) + rm(fileName) + # Delete the mesh nodes from internal storage used by the plotting routines proj.xMesh = Float64[] proj.yMesh = Float64[] postNotificationWithName(proj,"MESH_WAS_DELETED_NOTIFICATION",(nothing,)) From 15bdb778710bd6f58b20dbd3bc10655cfb874289 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Thu, 20 Jun 2024 23:07:41 +0200 Subject: [PATCH 15/26] add new helper function renameCruve to the API docs --- docs/src/interactive-api.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/src/interactive-api.md b/docs/src/interactive-api.md index 3c74ceb3..057e7ea8 100644 --- a/docs/src/interactive-api.md +++ b/docs/src/interactive-api.md @@ -437,6 +437,11 @@ and checked by ``` getCurveName(crv::Dict{String,Any}) ``` +Alternatively, the name of a curve on an outer or inner boundary +can be changed directly in the mesh project with the function +``` + renameCurve!(proj::Project, oldName::String, newName::String) +``` Otherwise there are special functions to change the parameters of curves ``` From ae33ce45e47a01bc2ef9d6e9d96f85c635058fc5 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Thu, 20 Jun 2024 23:13:59 +0200 Subject: [PATCH 16/26] adjust wording to be less awkward --- docs/src/tutorials/create_edit_curves.md | 2 +- docs/src/tutorials/symmetric_mesh.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/tutorials/create_edit_curves.md b/docs/src/tutorials/create_edit_curves.md index 6f446f03..75e6eb34 100644 --- a/docs/src/tutorials/create_edit_curves.md +++ b/docs/src/tutorials/create_edit_curves.md @@ -279,7 +279,7 @@ Note, this step is not required, but it helps avoid confusion when editing sever remove_mesh!(sandbox_project) updatePlot!(sandbox_project, MODEL+GRID) ``` -Additionally, the `remove_mesh!` command deletes the mesh information from the `sandbox_project` +The `remove_mesh!` command deletes the mesh information from the `sandbox_project` as well as the mesh file `sandbox.mesh`, control file `sandbox.control`, plot file `sandbox.tec`, and mesh statistics file `sandbox.txt` from the `out` folder. diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 39ba0883..611c7434 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -216,7 +216,7 @@ and background grid. remove_mesh!(symmetric_mesh) updatePlot!(symmetric_mesh, MODEL+GRID) ``` -Additionally, the `remove_mesh!` command deletes the mesh information from +The `remove_mesh!` command deletes the mesh information from the interactive mesh project `symmetric_mesh` as well as the mesh file `symmetric_mesh.mesh`, control file `symmetric_mesh.control`, plot file `symmetric_mesh.tec`, and mesh statistics file `symmetric_mesh.txt` from the `out` folder. From 5b80b72e577ed42fadbbf50183d34cb3d672087d Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Fri, 21 Jun 2024 23:48:35 +0200 Subject: [PATCH 17/26] update tutorial with new boundary names and other review comments --- docs/src/tutorials/symmetric_mesh.md | 51 +++++++++++++++------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 611c7434..436b265c 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -31,7 +31,7 @@ will be saved. By default, the output files created by HOHQMesh will carry the s as the project. For example, the resulting HOHQMesh control file from this tutorial will be named `symmetric_mesh.control`. If the folder `out` does not exist, it will be created automatically in -the current file path. +the current working directory. ```julia symmetric_mesh = newProject("symmetric_mesh", "out") ``` @@ -80,8 +80,8 @@ This outer boundary is composed of nine straight line segments and a half circle The curves will afterwards be added to the mesh project `symmetric_mesh` in counter-clockwise order as required by HOHQMesh. ```julia -line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) +line1 = newEndPointsLineCurve(":symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) line2 = newEndPointsLineCurve("bottom", [-0.05, 0.0, 0.0], [1.0, 0.0, 0.0]) @@ -116,17 +116,18 @@ line9 = newEndPointsLineCurve("top", [1.0, 2.0, 0.0], ``` The given boundary names will also be the element boundary names written to the mesh file. The only exception is the first boundary curve that is given -the name `"symmetry"`. The name of this outer boundary curve is a special keyword -in HOHQMesh that says it is the straight line across which +the name `":symmetry"`. +This outer boundary curve name is a special keyword +in HOHQMesh that says it is a straight line across which a reflection will occur. +Two worthwhile notes are + 1. the leading colon on this boundary name keyword is present to avoid conflicts with any other use of the *symmetry* name. + 2. if the curve designated as `":symmetry"` is not a straight line, then an error is thrown by HOHQMesh and the mesh will not be reflected. !!! tip "Name of the symmetry boundary" - As noted above, `"symmetry"` is a keyword for the HOHQMesh generator that - prescribes over which line a reflection of the mesh occurs. The Fortran implementation - for this keyword in HOHQMesh is not case sensitive. So, within the - Julia script one can name this reflection boundary line `"symmetry"` or `"Symmetry"` - or `"SYMMETRY"` or even something strange like `"sYmMeTrY"` and the mesh will still - generate successfully. + The name of the reflection boundary line is not + case-sensitive, thus`":symmetry"` or `":Symmetry"` or `":SYMMETRY"` + are all valid and will be recognized as the keyword for symmetry. Now that all the outer boundary curves are defined we add them to the `symmetric_mesh` project in counter-clockwise order @@ -152,7 +153,7 @@ the outer boundary and background grid. The resulting plot is given below. The c curves is called `"Outer"` and its constituent curve segments are labeled accordingly with the names prescribed in the curve construction above. -![before_generation](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/d332e86a-f958-4362-81b9-2ad40a408d94) +![before_generation](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2755fb08-9796-4e79-9d2d-055ef476dd4b) ## Generate the mesh @@ -195,11 +196,11 @@ The background grid is *removed* from the visualization when the mesh is generat Currently, only the "skeleton" of the mesh is visualized. Thus, the high-order curved boundary information is not seen in the plot but this information **is present** in the mesh file generated. -![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/1afd159e-e8c4-459f-ba7d-a31057b0c135) +![first_reflect_mesh](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/c271d208-6779-4e47-9045-a8cd21c5896d) !!! tip "Boundary names in the mesh file" The boundary names of the original outer curves will be those defined by the user - in their construction above. The boundary labeled `"symmetry"` is now internal and + in their construction above. The boundary labeled `":symmetry"` is now internal and is marked appropriately as such. The reflected boundary names are appended with `_R` (for reflected) in the mesh file. For instance, the reflected version of the boundary `bottom` has the name `bottom_R` or the boundary named `circle` has the @@ -223,18 +224,20 @@ and mesh statistics file `symmetric_mesh.txt` from the `out` folder. To illustrate the reflection about multiple boundary curves (which must be co-linear!), we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. -Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `"symmetry"`. +Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `":symmetry"`. This is done with the function `renameCurve!` ```julia -renameCurve!(symmetric_mesh, "symmetry", # existing curve name +renameCurve!(symmetric_mesh, ":symmetry", # existing curve name "left") # new curve name -renameCurve!(symmetric_mesh, "right", "symmetry") +renameCurve!(symmetric_mesh, "right", ":symmetry") ``` After the boundary names are adjusted the plot updates automatically to give the figure below. -![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/314a7bc7-0cb1-4708-bbb9-98ca85798d5b) +![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/0118a02f-0343-4280-8a63-eba5a59d69e3) We then generate the new mesh from the information contained in `symmetric_mesh`. +Again, a check ensures that the curves designated as `":symmetry"` are co-linear such that +an error is thrown if this is not the case and the mesh will not be reflected. This saves the control, tec, and mesh files into the `out` folder and yields ```julia generate_mesh(symmetric_mesh) @@ -263,7 +266,7 @@ The updated visualization is given below. Note, the flexibility to define multip co-linear symmetric boundaries creates a symmetric mesh with closed internal boundaries. In this example, a circle and a rectangle. -![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/2476b6fe-79a4-4d3a-98b1-089714c76ade) +![first_reflect_mesh2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/7e5baf73-9c48-45be-84e4-90eb331103a5) ## Summary @@ -296,10 +299,10 @@ addBackgroundGrid!(symmetric_mesh, [0.25, 0.25, 0.0]) # Create all the outer boundary curves and add them to the mesh project. # Note: (1) Curve names are those that will be present in the mesh file -# (2) Boundary named "symmetry" is where reflection occurs +# (2) Boundary named ":symmetry" is where reflection occurs -line1 = newEndPointsLineCurve("symmetry", [-0.05, 2.0, 0.0], - [-0.05, 0.0, 0.0]) +line1 = newEndPointsLineCurve(":symmetry", [-0.05, 2.0, 0.0], + [-0.05, 0.0, 0.0]) line2 = newEndPointsLineCurve("bottom", [-0.05, 0.0, 0.0], [1.0, 0.0, 0.0]) @@ -351,9 +354,9 @@ remove_mesh!(symmetric_mesh) # Rename the outer boundaries appropriately to set the symmetry boundary # on the right composed of multiple co-linear segments. -renameCurve!(symmetric_mesh, "symmetry", # existing curve name +renameCurve!(symmetric_mesh, ":symmetry", # existing curve name "left") # new curve name -renameCurve!(symmetric_mesh, "right", "symmetry") +renameCurve!(symmetric_mesh, "right", ":symmetry") # Generate the mesh. Saves the mesh file to the directory "out". generate_mesh(symmetric_mesh) From 821997f9361b975601921d5a8b1b47e45b7274b2 Mon Sep 17 00:00:00 2001 From: David Kopriva Date: Fri, 21 Jun 2024 15:50:44 -0700 Subject: [PATCH 18/26] Edits on renameCurve Make changes to indicate that renameCurve! will change the name of all curves that have a given name. --- docs/src/interactive-api.md | 4 ++-- docs/src/tutorials/symmetric_mesh.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/interactive-api.md b/docs/src/interactive-api.md index 057e7ea8..e131203b 100644 --- a/docs/src/interactive-api.md +++ b/docs/src/interactive-api.md @@ -437,8 +437,8 @@ and checked by ``` getCurveName(crv::Dict{String,Any}) ``` -Alternatively, the name of a curve on an outer or inner boundary -can be changed directly in the mesh project with the function +Alternatively, all curves on an outer or inner boundary with the same name +can have that name changed all at once everywhere in the project with the function ``` renameCurve!(proj::Project, oldName::String, newName::String) ``` diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 436b265c..6d67d470 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -224,8 +224,8 @@ and mesh statistics file `symmetric_mesh.txt` from the `out` folder. To illustrate the reflection about multiple boundary curves (which must be co-linear!), we first rename the current symmetry boundary curve `O.1` to have the name `"left"`. -Next, we rename the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `":symmetry"`. -This is done with the function `renameCurve!` +Next, we rename all the co-linear boundary curves `O.3`, `O.5`, and `O.9` to have the name `":symmetry"`. +Both are done with the function `renameCurve!` ```julia renameCurve!(symmetric_mesh, ":symmetry", # existing curve name "left") # new curve name From c22d2eab28d0b60df64cb1107d562786a5e8836d Mon Sep 17 00:00:00 2001 From: David Kopriva Date: Fri, 21 Jun 2024 16:03:30 -0700 Subject: [PATCH 19/26] Update symmetric_mesh.md Fix a typo and modify one sentence. --- docs/src/tutorials/symmetric_mesh.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/tutorials/symmetric_mesh.md b/docs/src/tutorials/symmetric_mesh.md index 6d67d470..e1d84171 100644 --- a/docs/src/tutorials/symmetric_mesh.md +++ b/docs/src/tutorials/symmetric_mesh.md @@ -208,7 +208,7 @@ The background grid is *removed* from the visualization when the mesh is generat ## Changing the reflection line -It is also possible to create a symmetry boundary composed of multiple be co-linear segments. +It is also possible to create a symmetry boundary composed of multiple co-linear segments. To change the line along which the mesh is reflected, we remove the current mesh that was just generated and re-plot the model curves @@ -236,8 +236,8 @@ After the boundary names are adjusted the plot updates automatically to give the ![before_generation2](https://github.com/trixi-framework/HOHQMesh.jl/assets/25242486/0118a02f-0343-4280-8a63-eba5a59d69e3) We then generate the new mesh from the information contained in `symmetric_mesh`. -Again, a check ensures that the curves designated as `":symmetry"` are co-linear such that -an error is thrown if this is not the case and the mesh will not be reflected. +Again, a check ensures that the curves designated as `":symmetry"` are co-linear. +An error is thrown if this is not the case and the mesh will not be reflected. This saves the control, tec, and mesh files into the `out` folder and yields ```julia generate_mesh(symmetric_mesh) From 0e3fd652d11776e5493793c537bba01da79d448b Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 09:29:51 +0200 Subject: [PATCH 20/26] add sleep commands to idle tests for a brief time to avoid file access issues on Windows --- test/test_visualization.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_visualization.jl b/test/test_visualization.jl index 0ad0d594..ac7de211 100644 --- a/test/test_visualization.jl +++ b/test/test_visualization.jl @@ -61,6 +61,10 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM @test_nowarn generate_mesh(p_visu, verbose=true) + # Add a slight delay between the file creation and deletion + # to avoid errors on Windows systems + sleep(0.1) + # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu) @@ -92,6 +96,10 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM-V2 @test_nowarn generate_mesh(p_visu) + # Add a slight delay between the file creation and deletion + # to avoid errors on Windows systems + sleep(0.1) + # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu) From 2d8594f74d8c0dfe273782155608fe7b2a1430ab Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 10:07:03 +0200 Subject: [PATCH 21/26] remove sleep commands, did not fix anything --- test/test_visualization.jl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/test_visualization.jl b/test/test_visualization.jl index ac7de211..0ad0d594 100644 --- a/test/test_visualization.jl +++ b/test/test_visualization.jl @@ -61,10 +61,6 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM @test_nowarn generate_mesh(p_visu, verbose=true) - # Add a slight delay between the file creation and deletion - # to avoid errors on Windows systems - sleep(0.1) - # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu) @@ -96,10 +92,6 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM-V2 @test_nowarn generate_mesh(p_visu) - # Add a slight delay between the file creation and deletion - # to avoid errors on Windows systems - sleep(0.1) - # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu) From 27158f3d44b6d4b119954dabfe197ab8b93ab196 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 10:32:14 +0200 Subject: [PATCH 22/26] see if only the control file removal causes Windows issue --- src/Mesh/Meshing.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Mesh/Meshing.jl b/src/Mesh/Meshing.jl index fa101405..6d5074e2 100644 --- a/src/Mesh/Meshing.jl +++ b/src/Mesh/Meshing.jl @@ -58,9 +58,10 @@ function remove_mesh!(proj::Project) # Remove all the output files associated with the current `proj` fileName = getMeshFileName(proj) rm(fileName) - # Get the control file name of the current project - fileName = joinpath(proj.projectDirectory,proj.name) * ".control" - rm(fileName) + # TODO: See if it is only the control file that causes issues on Windows + # # Get the control file name of the current project + # fileName = joinpath(proj.projectDirectory,proj.name) * ".control" + # rm(fileName) fileName = getPlotFileName(proj) rm(fileName) fileName = getStatsFileName(proj) From 56d74d74dc2c9d0576115ad3516718b24e91598f Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 11:34:58 +0200 Subject: [PATCH 23/26] add an additional close statement to see if Windows works --- src/HOHQMesh.jl | 2 ++ src/Mesh/Meshing.jl | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/HOHQMesh.jl b/src/HOHQMesh.jl index 7003804e..5c2473ec 100644 --- a/src/HOHQMesh.jl +++ b/src/HOHQMesh.jl @@ -236,6 +236,8 @@ function generate_mesh(control_file; readchomp(`$(HOHQMesh_jll.HOHQMesh()) -sLimit $subdivision_maximum -f $tmppath`) end end + # For safety, ensure that the filestream to the `control_file` is closed. + close(control_file) String(output) end diff --git a/src/Mesh/Meshing.jl b/src/Mesh/Meshing.jl index 6d5074e2..fa101405 100644 --- a/src/Mesh/Meshing.jl +++ b/src/Mesh/Meshing.jl @@ -58,10 +58,9 @@ function remove_mesh!(proj::Project) # Remove all the output files associated with the current `proj` fileName = getMeshFileName(proj) rm(fileName) - # TODO: See if it is only the control file that causes issues on Windows - # # Get the control file name of the current project - # fileName = joinpath(proj.projectDirectory,proj.name) * ".control" - # rm(fileName) + # Get the control file name of the current project + fileName = joinpath(proj.projectDirectory,proj.name) * ".control" + rm(fileName) fileName = getPlotFileName(proj) rm(fileName) fileName = getStatsFileName(proj) From 8b553b33d0bc73949bac33e6d49aa1f9e70198dd Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 11:48:42 +0200 Subject: [PATCH 24/26] move close statement to the proper place --- src/HOHQMesh.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HOHQMesh.jl b/src/HOHQMesh.jl index 5c2473ec..402aae53 100644 --- a/src/HOHQMesh.jl +++ b/src/HOHQMesh.jl @@ -228,6 +228,8 @@ function generate_mesh(control_file; end end flush(tmpio) + # For safety, ensure that the filestream to the `control_file` is closed. + close(control_file) # Run HOHQMesh and store output if verbose @@ -236,8 +238,6 @@ function generate_mesh(control_file; readchomp(`$(HOHQMesh_jll.HOHQMesh()) -sLimit $subdivision_maximum -f $tmppath`) end end - # For safety, ensure that the filestream to the `control_file` is closed. - close(control_file) String(output) end From f37eff954b7c85b5e49b6e6053fcb09eeefc3f1e Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 12:05:17 +0200 Subject: [PATCH 25/26] remove unnecessary close statments. Try to force file removal --- src/HOHQMesh.jl | 2 -- src/Mesh/Meshing.jl | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/HOHQMesh.jl b/src/HOHQMesh.jl index 402aae53..7003804e 100644 --- a/src/HOHQMesh.jl +++ b/src/HOHQMesh.jl @@ -228,8 +228,6 @@ function generate_mesh(control_file; end end flush(tmpio) - # For safety, ensure that the filestream to the `control_file` is closed. - close(control_file) # Run HOHQMesh and store output if verbose diff --git a/src/Mesh/Meshing.jl b/src/Mesh/Meshing.jl index fa101405..d19e2650 100644 --- a/src/Mesh/Meshing.jl +++ b/src/Mesh/Meshing.jl @@ -60,7 +60,7 @@ function remove_mesh!(proj::Project) rm(fileName) # Get the control file name of the current project fileName = joinpath(proj.projectDirectory,proj.name) * ".control" - rm(fileName) + rm(fileName; force=true) fileName = getPlotFileName(proj) rm(fileName) fileName = getStatsFileName(proj) From 526a29cb94b15192a0b0979e8dc1cb83aae91b05 Mon Sep 17 00:00:00 2001 From: Andrew Winters Date: Mon, 24 Jun 2024 14:13:36 +0200 Subject: [PATCH 26/26] try again with the sleep command --- src/Mesh/Meshing.jl | 2 +- test/test_visualization.jl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Mesh/Meshing.jl b/src/Mesh/Meshing.jl index d19e2650..fa101405 100644 --- a/src/Mesh/Meshing.jl +++ b/src/Mesh/Meshing.jl @@ -60,7 +60,7 @@ function remove_mesh!(proj::Project) rm(fileName) # Get the control file name of the current project fileName = joinpath(proj.projectDirectory,proj.name) * ".control" - rm(fileName; force=true) + rm(fileName) fileName = getPlotFileName(proj) rm(fileName) fileName = getStatsFileName(proj) diff --git a/test/test_visualization.jl b/test/test_visualization.jl index 0ad0d594..b3156b29 100644 --- a/test/test_visualization.jl +++ b/test/test_visualization.jl @@ -61,6 +61,9 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM @test_nowarn generate_mesh(p_visu, verbose=true) + # Add a delay to ensure that the Windows system has released the file handles + sleep(2.0) # arbitrarily pick 2 seconds + # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu) @@ -92,6 +95,9 @@ using CairoMakie # Create the mesh which contains a plotting update for ISM-V2 @test_nowarn generate_mesh(p_visu) + # Add a delay to ensure that the Windows system has released the file handles + sleep(2.0) # arbitrarily pick 2 seconds + # Destroy the mesh and reset the background grid @test_nowarn remove_mesh!(p_visu)