From 7213153c3a4625f995f174708199146efc84fa86 Mon Sep 17 00:00:00 2001 From: Hugh Carson Date: Tue, 5 Nov 2024 15:28:48 -0500 Subject: [PATCH] Update julia formatting given JuliaFormatter v2.0 --- examples/cpw/cpw.jl | 2 +- examples/cpw/mesh/mesh.jl | 212 +++++++++++++++++++-------------- examples/cylinder/cavity.jl | 16 +-- examples/cylinder/mesh/mesh.jl | 86 ++++++------- examples/rings/mesh/mesh.jl | 17 +-- 5 files changed, 186 insertions(+), 147 deletions(-) diff --git a/examples/cpw/cpw.jl b/examples/cpw/cpw.jl index dd5db420f..e2ae1f56d 100644 --- a/examples/cpw/cpw.jl +++ b/examples/cpw/cpw.jl @@ -74,7 +74,7 @@ function generate_cpw_data(; num_processors::Integer=1) data_wave_uniform = data_wave_uniform[:, 2:end] # Wrap phases - for p = 1:(size(data_lumped_adaptive, 2)÷2) + for p = 1:(size(data_lumped_adaptive, 2) ÷ 2) idx = (data_lumped_adaptive[:, 2 * p] .< 0.0) data_lumped_adaptive[idx, 2 * p] = data_lumped_adaptive[idx, 2 * p] .+ 180.0 diff --git a/examples/cpw/mesh/mesh.jl b/examples/cpw/mesh/mesh.jl index 6c9766a7f..449418892 100644 --- a/examples/cpw/mesh/mesh.jl +++ b/examples/cpw/mesh/mesh.jl @@ -42,19 +42,19 @@ Generate a mesh for the coplanar waveguide with wave ports using Gmsh """ function generate_cpw_wave_mesh(; filename::AbstractString, - refinement::Integer = 0, - order::Integer = 1, + refinement::Integer = 0, + order::Integer = 1, trace_width_μm::Real = 30.0, gap_width_μm::Real = 18.0, separation_width_μm::Real = 200.0, ground_width_μm::Real = 800.0, substrate_height_μm::Real = 500.0, metal_height_μm::Real = 0.0, - remove_metal_vol::Bool = true, + remove_metal_vol::Bool = true, length_μm::Real = 4000.0, - coax_ports::Bool = false, - verbose::Integer = 5, - gui::Bool = false + coax_ports::Bool = false, + verbose::Integer = 5, + gui::Bool = false ) @assert refinement >= 0 @assert order > 0 @@ -224,13 +224,14 @@ function generate_cpw_wave_mesh(; kernel.synchronize() # Add physical groups - metal_domains = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 3 && x[2] in metal, geom_dimtags)] + metal_domains = + last.( + collect( + Iterators.flatten( + geom_map[findall(x -> x[1] == 3 && x[2] in metal, geom_dimtags)] + ) ) ) - ) si_domain = last.(geom_map[findfirst(x -> x == (3, substrate), geom_dimtags)]) @assert length(si_domain) == 1 @@ -243,7 +244,8 @@ function generate_cpw_wave_mesh(; if length(metal_domains) > 0 && remove_metal_vol remove_dimtags = [(3, x) for x in metal_domains] - for tag in last.( + for tag in + last.( filter( x -> x[1] == 2, gmsh.model.getBoundary( @@ -287,13 +289,17 @@ function generate_cpw_wave_mesh(; end1_group = gmsh.model.addPhysicalGroup(2, end1, -1, "end1") end2_group = gmsh.model.addPhysicalGroup(2, end2, -1, "end2") - farfield = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in domain_boundary, geom_dimtags)] + farfield = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in domain_boundary, + geom_dimtags + )] + ) ) ) - ) filter!( x -> !( x in port1 || x in port2 || x in port3 || x in port4 || x in end1 || x in end2 @@ -303,34 +309,43 @@ function generate_cpw_wave_mesh(; farfield_group = gmsh.model.addPhysicalGroup(2, farfield, -1, "farfield") - trace = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in metal_boundary, geom_dimtags)] + trace = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in metal_boundary, + geom_dimtags + )] + ) ) ) - ) - gap = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in [n1, n2, n3, n4], geom_dimtags)] + gap = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in [n1, n2, n3, n4], + geom_dimtags + )] + ) ) ) - ) trace_group = gmsh.model.addPhysicalGroup(2, trace, -1, "trace") gap_group = gmsh.model.addPhysicalGroup(2, gap, -1, "gap") - trace_top = last.( - collect( - Iterators.flatten( - geom_map[findall( - x -> x[1] == 2 && x[2] in metal_boundary_top, - geom_dimtags - )] + trace_top = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in metal_boundary_top, + geom_dimtags + )] + ) ) ) - ) filter!( x -> !( x in port1 || x in port2 || x in port3 || x in port4 || x in end1 || x in end2 @@ -347,18 +362,20 @@ function generate_cpw_wave_mesh(; gmsh.option.setNumber("Mesh.MeshSizeFromCurvature", 0) gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0) - gap_points = last.( - filter( - x -> x[1] == 0, - gmsh.model.getBoundary([(2, z) for z in gap], false, true, true) + gap_points = + last.( + filter( + x -> x[1] == 0, + gmsh.model.getBoundary([(2, z) for z in gap], false, true, true) + ) ) - ) - gap_curves = last.( - filter( - x -> x[1] == 1, - gmsh.model.getBoundary([(2, z) for z in gap], false, false, false) + gap_curves = + last.( + filter( + x -> x[1] == 1, + gmsh.model.getBoundary([(2, z) for z in gap], false, false, false) + ) ) - ) gmsh.model.mesh.field.add("Distance", 1) gmsh.model.mesh.field.setNumbers(1, "PointsList", gap_points) @@ -461,18 +478,18 @@ Generate a mesh for the coplanar waveguide with lumped ports using Gmsh """ function generate_cpw_lumped_mesh(; filename::AbstractString, - refinement::Integer = 0, - order::Integer = 1, + refinement::Integer = 0, + order::Integer = 1, trace_width_μm::Real = 30.0, gap_width_μm::Real = 18.0, separation_width_μm::Real = 200.0, ground_width_μm::Real = 800.0, substrate_height_μm::Real = 500.0, metal_height_μm::Real = 0.0, - remove_metal_vol::Bool = true, + remove_metal_vol::Bool = true, length_μm::Real = 4000.0, - verbose::Integer = 5, - gui::Bool = false + verbose::Integer = 5, + gui::Bool = false ) @assert refinement >= 0 @assert order > 0 @@ -577,13 +594,14 @@ function generate_cpw_lumped_mesh(; kernel.synchronize() # Add physical groups - metal_domains = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 3 && x[2] in metal, geom_dimtags)] + metal_domains = + last.( + collect( + Iterators.flatten( + geom_map[findall(x -> x[1] == 3 && x[2] in metal, geom_dimtags)] + ) ) ) - ) si_domain = last.(geom_map[findfirst(x -> x == (3, substrate), geom_dimtags)]) @assert length(si_domain) == 1 @@ -596,7 +614,8 @@ function generate_cpw_lumped_mesh(; if length(metal_domains) > 0 && remove_metal_vol remove_dimtags = [(3, x) for x in metal_domains] - for tag in last.( + for tag in + last.( filter( x -> x[1] == 2, gmsh.model.getBoundary( @@ -622,13 +641,17 @@ function generate_cpw_lumped_mesh(; si_domain_group = gmsh.model.addPhysicalGroup(3, [si_domain], -1, "si") metal_domain_group = gmsh.model.addPhysicalGroup(3, metal_domains, -1, "metal") - farfield = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in domain_boundary, geom_dimtags)] + farfield = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in domain_boundary, + geom_dimtags + )] + ) ) ) - ) farfield_group = gmsh.model.addPhysicalGroup(2, farfield, -1, "farfield") @@ -650,20 +673,28 @@ function generate_cpw_lumped_mesh(; port3b_group = gmsh.model.addPhysicalGroup(2, port3b, -1, "port3b") port4b_group = gmsh.model.addPhysicalGroup(2, port4b, -1, "port4b") - trace = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in metal_boundary, geom_dimtags)] + trace = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in metal_boundary, + geom_dimtags + )] + ) ) ) - ) - gap = last.( - collect( - Iterators.flatten( - geom_map[findall(x -> x[1] == 2 && x[2] in [n1, n2, n3, n4], geom_dimtags)] + gap = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in [n1, n2, n3, n4], + geom_dimtags + )] + ) ) ) - ) filter!( x -> !( x in port1a || @@ -681,16 +712,17 @@ function generate_cpw_lumped_mesh(; trace_group = gmsh.model.addPhysicalGroup(2, trace, -1, "trace") gap_group = gmsh.model.addPhysicalGroup(2, gap, -1, "gap") - trace_top = last.( - collect( - Iterators.flatten( - geom_map[findall( - x -> x[1] == 2 && x[2] in metal_boundary_top, - geom_dimtags - )] + trace_top = + last.( + collect( + Iterators.flatten( + geom_map[findall( + x -> x[1] == 2 && x[2] in metal_boundary_top, + geom_dimtags + )] + ) ) ) - ) trace_top_group = gmsh.model.addPhysicalGroup(2, trace_top, -1, "trace2") @@ -701,18 +733,20 @@ function generate_cpw_lumped_mesh(; gmsh.option.setNumber("Mesh.MeshSizeFromCurvature", 0) gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0) - gap_points = last.( - filter( - x -> x[1] == 0, - gmsh.model.getBoundary([(2, z) for z in gap], false, true, true) + gap_points = + last.( + filter( + x -> x[1] == 0, + gmsh.model.getBoundary([(2, z) for z in gap], false, true, true) + ) ) - ) - gap_curves = last.( - filter( - x -> x[1] == 1, - gmsh.model.getBoundary([(2, z) for z in gap], false, false, false) + gap_curves = + last.( + filter( + x -> x[1] == 1, + gmsh.model.getBoundary([(2, z) for z in gap], false, false, false) + ) ) - ) gmsh.model.mesh.field.add("Distance", 1) gmsh.model.mesh.field.setNumbers(1, "PointsList", gap_points) diff --git a/examples/cylinder/cavity.jl b/examples/cylinder/cavity.jl index 15482acb7..aa7614944 100644 --- a/examples/cylinder/cavity.jl +++ b/examples/cylinder/cavity.jl @@ -236,19 +236,19 @@ function generate_cavity_convergence_data(; 0, 1, 0; - ϵᵣ = 2.08, - μᵣ = 1.0, - a_cm = radius, - d_cm = aspect_ratio * 2 * radius + ϵᵣ = 2.08, + μᵣ = 1.0, + a_cm = radius, + d_cm = aspect_ratio * 2 * radius ) f_TE_111_true, ~ = frequency_transverse( 1, 1, 1; - ϵᵣ = 2.08, - μᵣ = 1.0, - a_cm = radius, - d_cm = aspect_ratio * 2 * radius + ϵᵣ = 2.08, + μᵣ = 1.0, + a_cm = radius, + d_cm = aspect_ratio * 2 * radius ) dof = Vector{Vector{Int}}() diff --git a/examples/cylinder/mesh/mesh.jl b/examples/cylinder/mesh/mesh.jl index 5ab6b27cb..59d986e52 100644 --- a/examples/cylinder/mesh/mesh.jl +++ b/examples/cylinder/mesh/mesh.jl @@ -106,39 +106,42 @@ function generate_cylindrical_mesh(; # Add physical groups cylinder_group = gmsh.model.addPhysicalGroup(3, cylinder, -1, "cylinder") - @show top = last.( - gmsh.model.getEntitiesInBoundingBox( - -1.1 * radius, - -1.1 * radius, - 0.5 * height, - 1.1 * radius, - 1.1 * radius, - 1.1 * height, - 2 + @show top = + last.( + gmsh.model.getEntitiesInBoundingBox( + -1.1 * radius, + -1.1 * radius, + 0.5 * height, + 1.1 * radius, + 1.1 * radius, + 1.1 * height, + 2 + ) ) - ) - @show bottom = last.( - gmsh.model.getEntitiesInBoundingBox( - -1.1 * radius, - -1.1 * radius, - -0.1 * height, - 1.1 * radius, - 1.1 * radius, - 0.5 * height, - 2 + @show bottom = + last.( + gmsh.model.getEntitiesInBoundingBox( + -1.1 * radius, + -1.1 * radius, + -0.1 * height, + 1.1 * radius, + 1.1 * radius, + 0.5 * height, + 2 + ) ) - ) - @show symmetry = last.( - gmsh.model.getEntitiesInBoundingBox( - -1.1 * radius, - -0.1 * radius, - -0.1 * height, - 1.1 * radius, - 0.1 * radius, - 1.1 * height, - 2 + @show symmetry = + last.( + gmsh.model.getEntitiesInBoundingBox( + -1.1 * radius, + -0.1 * radius, + -0.1 * height, + 1.1 * radius, + 0.1 * radius, + 1.1 * height, + 2 + ) ) - ) exterior = [] for domain in cylinder _, domain_boundaries = gmsh.model.getAdjacencies(3, domain) @@ -171,24 +174,25 @@ function generate_cylindrical_mesh(; gmsh.option.setNumber("Mesh.Algorithm3D", 10) if (mesh_type == 2) - base_boundaries = last.( - gmsh.model.getEntitiesInBoundingBox( - -1.1 * radius, - -1.1 * radius, - -0.1 * height, - 1.1 * radius, - 1.1 * radius, - 0.1 * height, - 2 + base_boundaries = + last.( + gmsh.model.getEntitiesInBoundingBox( + -1.1 * radius, + -1.1 * radius, + -0.1 * height, + 1.1 * radius, + 1.1 * radius, + 0.1 * height, + 2 + ) ) - ) for boundary in base_boundaries gmsh.model.mesh.setRecombine(2, boundary) end end gmsh.model.mesh.generate(3) - for i = 0:(refinement-1) + for i = 0:(refinement - 1) gmsh.model.mesh.refine() end gmsh.model.mesh.setOrder(order) diff --git a/examples/rings/mesh/mesh.jl b/examples/rings/mesh/mesh.jl index 4693cea11..71c16337f 100644 --- a/examples/rings/mesh/mesh.jl +++ b/examples/rings/mesh/mesh.jl @@ -38,7 +38,7 @@ function generate_ring_mesh(; outer_radius = 100.0, rot_center::AbstractVector{<:Real} = [0.0, 0.0, 0.0], rot_axis::AbstractVector{<:Real} = [0.0, 0.0, 1.0], - rot_θ::Real = π / 2, + rot_θ::Real = π / 2, verbose::Integer = 5, gui::Bool = false ) @@ -185,14 +185,15 @@ function generate_ring_mesh(; gmsh.model.mesh.field.setNumber(1, "DistMax", 6.0 * outer_radius) gmsh.model.mesh.field.setNumber(1, "SizeMax", l_farfield) - mesh_curves = last.( - gmsh.model.getBoundary( - [(2, x) for x in [inner_ring, outer_ring, inner_terminal, outer_terminal]], - true, - false, - false + mesh_curves = + last.( + gmsh.model.getBoundary( + [(2, x) for x in [inner_ring, outer_ring, inner_terminal, outer_terminal]], + true, + false, + false + ) ) - ) gmsh.model.mesh.field.add("Distance", 2) gmsh.model.mesh.field.setNumbers(2, "CurvesList", mesh_curves)