From 83d777ef2e0d0e3df3c672c62a08f59da9621cff Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Mon, 29 Apr 2024 14:58:38 +0000 Subject: [PATCH 1/2] current_filename --- src/meshes/mesh_io.jl | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/meshes/mesh_io.jl b/src/meshes/mesh_io.jl index 28e6efa8c57..e9a3d78fa90 100644 --- a/src/meshes/mesh_io.jl +++ b/src/meshes/mesh_io.jl @@ -247,7 +247,7 @@ end function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) ndims, mesh_type = h5open(mesh_file, "r") do file return read(attributes(file)["ndims"]), - read(attributes(file)["mesh_type"]) + read(attributes(file)["mesh_type"]) end if mesh_type == "TreeMesh" @@ -259,7 +259,7 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) elseif mesh_type == "StructuredMesh" size_, mapping_as_string = h5open(mesh_file, "r") do file return read(attributes(file)["size"]), - read(attributes(file)["mapping"]) + read(attributes(file)["mapping"]) end size = Tuple(size_) @@ -289,23 +289,24 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) end mesh = StructuredMesh(size, mapping; RealT = RealT, unsaved_changes = false, - mapping_as_string = mapping_as_string) + mapping_as_string = mapping_as_string) mesh.current_filename = mesh_file elseif mesh_type == "UnstructuredMesh2D" mesh_filename, periodicity_ = h5open(mesh_file, "r") do file return read(attributes(file)["mesh_filename"]), - read(attributes(file)["periodicity"]) + read(attributes(file)["periodicity"]) end mesh = UnstructuredMesh2D(mesh_filename; RealT = RealT, - periodicity = periodicity_, - unsaved_changes = false) + periodicity = periodicity_, + unsaved_changes = false) + mesh.current_filename = mesh_file elseif mesh_type == "P4estMesh" p4est_filename, tree_node_coordinates, nodes, boundary_names_ = h5open(mesh_file, "r") do file return read(attributes(file)["p4est_file"]), - read(file["tree_node_coordinates"]), - read(file["nodes"]), - read(file["boundary_names"]) + read(file["tree_node_coordinates"]), + read(file["nodes"]), + read(file["boundary_names"]) end boundary_names = boundary_names_ .|> Symbol @@ -317,7 +318,7 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) p4est = load_p4est(p4est_file, Val(ndims)) mesh = P4estMesh{ndims}(p4est, tree_node_coordinates, - nodes, boundary_names, "", false, true) + nodes, boundary_names, mesh_file, false, true) else error("Unknown mesh type!") end @@ -355,7 +356,7 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) if mpi_isroot() ndims_, mesh_type = h5open(mesh_file, "r") do file return read(attributes(file)["ndims"]), - read(attributes(file)["mesh_type"]) + read(attributes(file)["mesh_type"]) end MPI.Bcast!(Ref(ndims_), mpi_root(), mpi_comm()) MPI.bcast(mesh_type, mpi_root(), mpi_comm()) @@ -383,9 +384,9 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) p4est_filename, tree_node_coordinates, nodes, boundary_names_ = h5open(mesh_file, "r") do file return read(attributes(file)["p4est_file"]), - read(file["tree_node_coordinates"]), - read(file["nodes"]), - read(file["boundary_names"]) + read(file["tree_node_coordinates"]), + read(file["nodes"]), + read(file["boundary_names"]) end boundary_names = boundary_names_ .|> Symbol @@ -405,7 +406,7 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) p4est = load_p4est(p4est_file, Val(ndims_)) mesh = P4estMesh{ndims_}(p4est, tree_node_coordinates, - nodes, boundary_names, "", false, true) + nodes, boundary_names, mesh_file, false, true) else error("Unknown mesh type!") end @@ -441,19 +442,19 @@ function load_mesh!(mesh::ParallelTreeMesh, mesh_file::AbstractString) @views MPI.Bcast!(mesh.tree.parent_ids[1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.child_ids[:, 1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.neighbor_ids[:, 1:n_cells], mpi_root(), - mpi_comm()) + mpi_comm()) @views MPI.Bcast!(mesh.tree.levels[1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.coordinates[:, 1:n_cells], mpi_root(), - mpi_comm()) + mpi_comm()) end else # non-root ranks # Set domain information mesh.tree.center_level_0 = MPI.Bcast!(collect(mesh.tree.center_level_0), - mpi_root(), mpi_comm()) + mpi_root(), mpi_comm()) mesh.tree.length_level_0 = MPI.Bcast!(collect(mesh.tree.length_level_0), - mpi_root(), mpi_comm())[1] + mpi_root(), mpi_comm())[1] mesh.tree.periodicity = Tuple(MPI.Bcast!(collect(mesh.tree.periodicity), - mpi_root(), mpi_comm())) + mpi_root(), mpi_comm())) # Set length n_cells = MPI.Bcast!(Ref(0), mpi_root(), mpi_comm())[] From dc573ab33725a851221a5cdcd7e7534b21f8b997 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 29 Apr 2024 17:03:35 +0200 Subject: [PATCH 2/2] fmt --- src/meshes/mesh_io.jl | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/meshes/mesh_io.jl b/src/meshes/mesh_io.jl index e9a3d78fa90..c1d78cbbf1e 100644 --- a/src/meshes/mesh_io.jl +++ b/src/meshes/mesh_io.jl @@ -247,7 +247,7 @@ end function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) ndims, mesh_type = h5open(mesh_file, "r") do file return read(attributes(file)["ndims"]), - read(attributes(file)["mesh_type"]) + read(attributes(file)["mesh_type"]) end if mesh_type == "TreeMesh" @@ -259,7 +259,7 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) elseif mesh_type == "StructuredMesh" size_, mapping_as_string = h5open(mesh_file, "r") do file return read(attributes(file)["size"]), - read(attributes(file)["mapping"]) + read(attributes(file)["mapping"]) end size = Tuple(size_) @@ -289,24 +289,24 @@ function load_mesh_serial(mesh_file::AbstractString; n_cells_max, RealT) end mesh = StructuredMesh(size, mapping; RealT = RealT, unsaved_changes = false, - mapping_as_string = mapping_as_string) + mapping_as_string = mapping_as_string) mesh.current_filename = mesh_file elseif mesh_type == "UnstructuredMesh2D" mesh_filename, periodicity_ = h5open(mesh_file, "r") do file return read(attributes(file)["mesh_filename"]), - read(attributes(file)["periodicity"]) + read(attributes(file)["periodicity"]) end mesh = UnstructuredMesh2D(mesh_filename; RealT = RealT, - periodicity = periodicity_, - unsaved_changes = false) + periodicity = periodicity_, + unsaved_changes = false) mesh.current_filename = mesh_file elseif mesh_type == "P4estMesh" p4est_filename, tree_node_coordinates, nodes, boundary_names_ = h5open(mesh_file, "r") do file return read(attributes(file)["p4est_file"]), - read(file["tree_node_coordinates"]), - read(file["nodes"]), - read(file["boundary_names"]) + read(file["tree_node_coordinates"]), + read(file["nodes"]), + read(file["boundary_names"]) end boundary_names = boundary_names_ .|> Symbol @@ -356,7 +356,7 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) if mpi_isroot() ndims_, mesh_type = h5open(mesh_file, "r") do file return read(attributes(file)["ndims"]), - read(attributes(file)["mesh_type"]) + read(attributes(file)["mesh_type"]) end MPI.Bcast!(Ref(ndims_), mpi_root(), mpi_comm()) MPI.bcast(mesh_type, mpi_root(), mpi_comm()) @@ -384,9 +384,9 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) p4est_filename, tree_node_coordinates, nodes, boundary_names_ = h5open(mesh_file, "r") do file return read(attributes(file)["p4est_file"]), - read(file["tree_node_coordinates"]), - read(file["nodes"]), - read(file["boundary_names"]) + read(file["tree_node_coordinates"]), + read(file["nodes"]), + read(file["boundary_names"]) end boundary_names = boundary_names_ .|> Symbol @@ -406,7 +406,7 @@ function load_mesh_parallel(mesh_file::AbstractString; n_cells_max, RealT) p4est = load_p4est(p4est_file, Val(ndims_)) mesh = P4estMesh{ndims_}(p4est, tree_node_coordinates, - nodes, boundary_names, mesh_file, false, true) + nodes, boundary_names, mesh_file, false, true) else error("Unknown mesh type!") end @@ -442,19 +442,19 @@ function load_mesh!(mesh::ParallelTreeMesh, mesh_file::AbstractString) @views MPI.Bcast!(mesh.tree.parent_ids[1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.child_ids[:, 1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.neighbor_ids[:, 1:n_cells], mpi_root(), - mpi_comm()) + mpi_comm()) @views MPI.Bcast!(mesh.tree.levels[1:n_cells], mpi_root(), mpi_comm()) @views MPI.Bcast!(mesh.tree.coordinates[:, 1:n_cells], mpi_root(), - mpi_comm()) + mpi_comm()) end else # non-root ranks # Set domain information mesh.tree.center_level_0 = MPI.Bcast!(collect(mesh.tree.center_level_0), - mpi_root(), mpi_comm()) + mpi_root(), mpi_comm()) mesh.tree.length_level_0 = MPI.Bcast!(collect(mesh.tree.length_level_0), - mpi_root(), mpi_comm())[1] + mpi_root(), mpi_comm())[1] mesh.tree.periodicity = Tuple(MPI.Bcast!(collect(mesh.tree.periodicity), - mpi_root(), mpi_comm())) + mpi_root(), mpi_comm())) # Set length n_cells = MPI.Bcast!(Ref(0), mpi_root(), mpi_comm())[]