Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update the wrapper function #12

Merged
merged 11 commits into from
Nov 5, 2021
78 changes: 78 additions & 0 deletions examples/ABAQUS_IceCreamCone.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
%
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
% -----------------------------------------------------------------------------
% Control file for a circular outer boundary and ice cream cone inner boundary.
% -----------------------------------------------------------------------------
%
% -------------
% Control Block
% -------------
%
\begin{CONTROL_INPUT}
\begin{RUN_PARAMETERS}
mesh file name = Benchmarks/MeshFiles/Tests/abaqus_ice_cream_cone.inp
plot file name = Benchmarks/PlotFiles/Tests/abaqus_ice_cream_cone.tec
stats file name = Benchmarks/StatsFiles/Tests/abaqus_ice_cream_cone.txt
test file name = Benchmarks/BenchmarkData/abaqus_ice_cream_cone.txt
mesh file format = ABAQUS
polynomial order = 4
plot file format = skeleton
\end{RUN_PARAMETERS}

\begin{MESH_PARAMETERS}
element type = quad
\end{MESH_PARAMETERS}

\begin{BACKGROUND_GRID}
background grid size = [1.0, 1.0, 0.0]
\end{BACKGROUND_GRID}

\begin{SPRING_SMOOTHER}
smoothing = ON
smoothing type = LinearAndCrossBarSpring
number of iterations = 25
\end{SPRING_SMOOTHER}

\end{CONTROL_INPUT}

\begin{MODEL}

\begin{OUTER_BOUNDARY}
\begin{PARAMETRIC_EQUATION_CURVE}
name = OuterCircle
xEqn = x(t) = 8.0*sin(2.0*pi*t)
yEqn = y(t) = 8.0*cos(2.0*pi*t)
zEqn = z(t) = 0.0
\end{PARAMETRIC_EQUATION_CURVE}

\end{OUTER_BOUNDARY}

\begin{INNER_BOUNDARIES}

\begin{CHAIN}
name = IceCreamCone
\begin{END_POINTS_LINE}
name = LeftSlant
xStart = [-2.0, 1.0, 0.0]
xEnd = [ 0.0, -3.0, 0.0]
\end{END_POINTS_LINE}

\begin{END_POINTS_LINE}
name = RightSlant
xStart = [ 0.0, -3.0, 0.0]
xEnd = [ 2.0, 1.0, 0.0]
\end{END_POINTS_LINE}

\begin{CIRCULAR_ARC}
name = IceCream
units = degrees
center = [ 0.0, 1.0, 0.0]
radius = 2.0
start angle = 0.0
end angle = 180.0
\end{CIRCULAR_ARC}
\end{CHAIN}

\end{INNER_BOUNDARIES}

\end{MODEL}
\end{FILE}
27 changes: 24 additions & 3 deletions src/HOHQMesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import HOHQMesh_jll
export generate_mesh


#TODO: add mesh_file_format parsed directly from the control file and set the
# appropriate mesh file name extension. Maybe also print a statement saying
# which type of mesh you just created
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
"""
generate_mesh(control_file;
output_directory="out",
mesh_filename=nothing, plot_filename=nothing, stats_filename=nothing)
mesh_filename=nothing, plot_filename=nothing, stats_filename=nothing,
verbose=false)

Generate a mesh based on the `control_file` with the HOHQMesh mesh generator and store resulting
files in `output_directory`.
Expand All @@ -32,8 +36,22 @@ function generate_mesh(control_file;

# Determine output filenames
filebase = splitext(basename(control_file))[1]
if isnothing(mesh_filename)
mesh_filename = filebase * ".mesh"

# Find the file line that gives the mesh file format
file_lines = readlines(open(control_file))
file_idx = findfirst(contains("mesh file format"), file_lines)

# Extract the mesh file format keyword
mesh_file_format = split(file_lines[file_idx])[5]

if mesh_file_format == "ISM" || mesh_file_format == "ISM-V2" || mesh_file_format == "ISM-v2"
if isnothing(mesh_filename)
mesh_filename = filebase * ".mesh"
end
elseif mesh_file_format == "ABAQUS"
if isnothing(mesh_filename)
mesh_filename = filebase * ".inp"
end
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
end
if isnothing(plot_filename)
plot_filename = filebase * ".tec"
Expand Down Expand Up @@ -77,6 +95,9 @@ function generate_mesh(control_file;
end
end

# Append a statement to indicate to the user which mesh file format was used
output = string(output, "\n", " Mesh file written in ", mesh_file_format, " format.")
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved

String(output)
end

Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
AbaqusReader = "bc6b9049-e460-56d6-94b4-a597b2c0390d"
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using HOHQMesh
using Test
using AbaqusReader

# Start with a clean environment: remove HOHQMesh output directory if it exists
outdir = "out"
isdir(outdir) && rm(outdir, recursive=true)

@testset "HOHQMesh.jl" begin

Expand All @@ -17,4 +22,16 @@ using Test
@test generate_mesh(control_file, verbose=true) isa String
end

@testset "generate_mesh() with ABAQUS output" begin
control_file = joinpath(HOHQMesh.examples_dir(), "ABAQUS_IceCreamCone.control")
generate_mesh(control_file)
parse_mesh = abaqus_read_mesh(joinpath(outdir, "ABAQUS_IceCreamCone.inp"))
# set some reference values for comparison. These are the corner IDs for element 114
ref_IDs = [140, 141, 154, 153]
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
@test sum(parse_mesh["elements"][114] - ref_IDs) == 0
andrewwinters5000 marked this conversation as resolved.
Show resolved Hide resolved
end

end # testset "HOHQMesh.jl"

# Clean up afterwards: delete HOHQMesh output directory
@test_nowarn rm(outdir, recursive=true)