From 47d9a4bc95ceedc6994f96e785ed1cbc0ed0e74d Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Sun, 16 Jul 2023 01:59:41 +0200 Subject: [PATCH 01/13] write some meta data --- src/visualization/write2vtk.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 12843ef66..e4e120d14 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -41,6 +41,9 @@ function trixi2vtk(v, u, t, system; output_directory="out", prefix="", iter=noth # Store particle index vtk["index"] = eachparticle(system) + # Write some meta data + vtk["time"] = t + # Extract custom quantities for this system for (key, func) in custom_quantities value = func(v, u, t, system) @@ -75,6 +78,16 @@ function write2vtk!(vtk, v, u, t, system::WeaklyCompressibleSPHSystem) for particle in eachparticle(system)] vtk["pressure"] = system.pressure + # write meta data + vtk["solver"] = "WCSPH" + vtk["correction_method"] = string(nameof(typeof(system.correction))) + vtk["acceleration"] = system.acceleration + vtk["viscosity"] = string(nameof(typeof(system.viscosity))) + vtk["smoothing_kernel"] = string(nameof(typeof(system.smoothing_kernel))) + vtk["smoothing_length"] = system.smoothing_length + vtk["density_calculator"] = string(nameof(typeof(system.density_calculator))) + vtk["state_equation"] = string(nameof(typeof(system.state_equation))) + return vtk end @@ -97,6 +110,13 @@ function write2vtk!(vtk, v, u, t, model, system) end function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system) + @unpack boundary_model = system + + vtk["smoothing_kernel"] = string(nameof(typeof(boundary_model.smoothing_kernel))) + vtk["smoothing_length"] = boundary_model.smoothing_length + vtk["density_calculator"] = string(nameof(typeof(boundary_model.density_calculator))) + vtk["state_equation"] = string(nameof(typeof(boundary_model.state_equation))) + write2vtk!(vtk, v, u, t, model, model.viscosity, system) end From 91e6b4277b8ac781e89ff68ae7fe20e44c240d94 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Sun, 16 Jul 2023 10:53:36 +0200 Subject: [PATCH 02/13] add type2string function additional data --- src/util.jl | 4 ++++ src/visualization/write2vtk.jl | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/util.jl b/src/util.jl index 797997044..19a8b31dc 100644 --- a/src/util.jl +++ b/src/util.jl @@ -299,3 +299,7 @@ macro autoinfiltrate(condition=true) lnn, esc(condition)) end + +function type2string(type) + return string(nameof(typeof(type))) +end diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index e4e120d14..9a9cffde7 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -80,13 +80,13 @@ function write2vtk!(vtk, v, u, t, system::WeaklyCompressibleSPHSystem) # write meta data vtk["solver"] = "WCSPH" - vtk["correction_method"] = string(nameof(typeof(system.correction))) + vtk["correction_method"] = type2string(system.correction) vtk["acceleration"] = system.acceleration - vtk["viscosity"] = string(nameof(typeof(system.viscosity))) - vtk["smoothing_kernel"] = string(nameof(typeof(system.smoothing_kernel))) + vtk["viscosity"] = type2string(system.viscosity) + vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) vtk["smoothing_length"] = system.smoothing_length - vtk["density_calculator"] = string(nameof(typeof(system.density_calculator))) - vtk["state_equation"] = string(nameof(typeof(system.state_equation))) + vtk["density_calculator"] = type2string(system.density_calculator) + vtk["state_equation"] = type2string(system.state_equation) return vtk end @@ -112,10 +112,12 @@ end function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system) @unpack boundary_model = system - vtk["smoothing_kernel"] = string(nameof(typeof(boundary_model.smoothing_kernel))) + # write meta data + vtk["boundary_model"] = "BoundaryModelDummyParticles" + vtk["smoothing_kernel"] = type2string(boundary_model.smoothing_kernel) vtk["smoothing_length"] = boundary_model.smoothing_length - vtk["density_calculator"] = string(nameof(typeof(boundary_model.density_calculator))) - vtk["state_equation"] = string(nameof(typeof(boundary_model.state_equation))) + vtk["density_calculator"] = type2string(boundary_model.density_calculator) + vtk["state_equation"] = type2string(boundary_model.state_equation) write2vtk!(vtk, v, u, t, model, model.viscosity, system) end @@ -125,6 +127,8 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, for particle in eachparticle(system)] vtk["pressure"] = model.pressure + # write meta data + vtk["viscosity_model"] = type2string(viscosity) return vtk end @@ -135,5 +139,8 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, vtk["pressure"] = model.pressure vtk["wall_velocity"] = view(model.cache.wall_velocity, 1:ndims(system), :) + # write meta data + vtk["viscosity_model"] = "ViscosityAdami" + return vtk end From 4e59cb8d725af39fb11c2bdf75bb1784b38c67c8 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 21 Jul 2023 16:22:23 +0200 Subject: [PATCH 03/13] write the pvd file --- src/TrixiParticles.jl | 2 +- src/visualization/write2vtk.jl | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/TrixiParticles.jl b/src/TrixiParticles.jl index 0e855ad8d..5850ddd9d 100644 --- a/src/TrixiParticles.jl +++ b/src/TrixiParticles.jl @@ -16,7 +16,7 @@ using StrideArrays: PtrArray, StaticInt using ThreadingUtilities using TimerOutputs: TimerOutput, TimerOutputs, print_timer, reset_timer! @reexport using SimpleUnPack: @unpack -using WriteVTK: vtk_grid, MeshCell, VTKCellTypes +using WriteVTK: vtk_grid, MeshCell, VTKCellTypes, paraview_collection, vtk_save using ForwardDiff # util needs to be first because of macro @trixi_timeit diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 37e52381d..a9dad43e6 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -35,9 +35,15 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix add_opt_str_pre(prefix) * "$system_name" * add_opt_str_post(iter)) + collection_file = joinpath(output_directory, + add_opt_str_pre(prefix) * "$system_name") + + pvd = paraview_collection(collection_file; append = true) + points = periodic_coords(current_coordinates(u, system), periodic_box) cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i,)) for i in axes(points, 2)] + vtk_grid(file, points, cells) do vtk write2vtk!(vtk, v, u, t, system) @@ -54,7 +60,11 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix vtk[string(key)] = func(v, u, t, system) end end + + # add to collection + pvd[t] = vtk end + vtk_save(pvd) end function trixi2vtk(coordinates; output_directory="out", prefix="", filename="coordinates") From 4a5e0fd6ce068756a5fc286dedf87e4c34cfa544 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Mon, 25 Sep 2023 17:37:58 +0200 Subject: [PATCH 04/13] format --- src/visualization/write2vtk.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index f1b8ba5d3..b764cc5a6 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -36,14 +36,13 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix * add_opt_str_post(iter)) collection_file = joinpath(output_directory, - add_opt_str_pre(prefix) * "$system_name") + add_opt_str_pre(prefix) * "$system_name") - pvd = paraview_collection(collection_file; append = true) + pvd = paraview_collection(collection_file; append=true) points = periodic_coords(current_coordinates(u, system), periodic_box) cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i,)) for i in axes(points, 2)] - vtk_grid(file, points, cells) do vtk write2vtk!(vtk, v, u, t, system) From 0e95c9d3d9763de4c08177cf30e7011259b06e2f Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Mon, 25 Sep 2023 17:42:57 +0200 Subject: [PATCH 05/13] merge error --- src/TrixiParticles.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TrixiParticles.jl b/src/TrixiParticles.jl index 6e141a8f4..8d02f2a81 100644 --- a/src/TrixiParticles.jl +++ b/src/TrixiParticles.jl @@ -15,7 +15,6 @@ using StaticArrays: @SMatrix, SMatrix, setindex using StrideArrays: PtrArray, StaticInt using ThreadingUtilities using TimerOutputs: TimerOutput, TimerOutputs, print_timer, reset_timer! -@reexport using SimpleUnPack: @unpack using WriteVTK: vtk_grid, MeshCell, VTKCellTypes, paraview_collection, vtk_save using ForwardDiff From cf07e811488d786b1c02545aae8c487b798381ed Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Mon, 25 Sep 2023 17:53:34 +0200 Subject: [PATCH 06/13] add additional output for viscosity models --- src/visualization/write2vtk.jl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index b764cc5a6..4b9cf670e 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -111,9 +111,21 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem) vtk["density_calculator"] = type2string(system.density_calculator) vtk["state_equation"] = type2string(system.state_equation) + write2vtk!(vtk, system.viscosity) return vtk end +function write2vtk!(vtk, viscosity::ViscosityAdami) + vtk["nu"] = viscosity.nu + vtk["epsilon"] = viscosity.epsilon +end + +function write2vtk!(vtk, viscosity::ArtificialViscosityMonaghan) + vtk["alpha"] = viscosity.alpha + vtk["beta"] = viscosity.beta + vtk["epsilon"] = viscosity.epsilon +end + function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem) n_fixed_particles = nparticles(system) - n_moving_particles(system) @@ -133,14 +145,12 @@ function write2vtk!(vtk, v, u, t, model, system) end function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system) - @unpack boundary_model = system - # write meta data vtk["boundary_model"] = "BoundaryModelDummyParticles" - vtk["smoothing_kernel"] = type2string(boundary_model.smoothing_kernel) - vtk["smoothing_length"] = boundary_model.smoothing_length - vtk["density_calculator"] = type2string(boundary_model.density_calculator) - vtk["state_equation"] = type2string(boundary_model.state_equation) + vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) + vtk["smoothing_length"] = system.boundary_model.smoothing_length + vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) + vtk["state_equation"] = type2string(system.boundary_model.state_equation) write2vtk!(vtk, v, u, t, model, model.viscosity, system) end From fd657210170899a0422ee6557a405c0becf848fa Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 5 Oct 2023 14:55:07 +0200 Subject: [PATCH 07/13] make meta data optional --- src/visualization/write2vtk.jl | 64 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 604d56003..7613dba08 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -47,7 +47,7 @@ end # Convert data for a single TrixiParticle system to VTK format function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix="", - iter=nothing, system_name=vtkname(system), custom_quantities...) + iter=nothing, system_name=vtkname(system), write_meta_data=true, custom_quantities...) mkpath(output_directory) # handle "_" on optional pre/postfix strings @@ -67,7 +67,7 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i,)) for i in axes(points, 2)] vtk_grid(file, points, cells) do vtk - write2vtk!(vtk, v, u, t, system) + write2vtk!(vtk, v, u, t, system, write_meta_data=write_meta_data) # Store particle index vtk["index"] = eachparticle(system) @@ -140,24 +140,26 @@ vtkname(system::FluidSystem) = "fluid" vtkname(system::TotalLagrangianSPHSystem) = "solid" vtkname(system::BoundarySPHSystem) = "boundary" -function write2vtk!(vtk, v, u, t, system::FluidSystem) +function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) vtk["velocity"] = view(v, 1:ndims(system), :) vtk["density"] = [particle_density(v, system, particle) for particle in eachparticle(system)] vtk["pressure"] = [particle_pressure(v, system, particle) for particle in eachparticle(system)] - # write meta data - vtk["solver"] = "WCSPH" - vtk["correction_method"] = type2string(system.correction) - vtk["acceleration"] = system.acceleration - vtk["viscosity"] = type2string(system.viscosity) - vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) - vtk["smoothing_length"] = system.smoothing_length - vtk["density_calculator"] = type2string(system.density_calculator) - vtk["state_equation"] = type2string(system.state_equation) - - write2vtk!(vtk, system.viscosity) + if write_meta_data + vtk["solver"] = "WCSPH" + vtk["correction_method"] = type2string(system.correction) + vtk["acceleration"] = system.acceleration + vtk["viscosity"] = type2string(system.viscosity) + vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) + vtk["smoothing_length"] = system.smoothing_length + vtk["density_calculator"] = type2string(system.density_calculator) + vtk["state_equation"] = type2string(system.state_equation) + + write2vtk!(vtk, system.viscosity) + end + return vtk end @@ -172,7 +174,7 @@ function write2vtk!(vtk, viscosity::ArtificialViscosityMonaghan) vtk["epsilon"] = viscosity.epsilon end -function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem) +function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem; write_meta_data=true) n_fixed_particles = nparticles(system) - n_moving_particles(system) vtk["velocity"] = hcat(view(v, 1:ndims(system), :), @@ -190,36 +192,40 @@ function write2vtk!(vtk, v, u, t, model, system) return vtk end -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system) - # write meta data - vtk["boundary_model"] = "BoundaryModelDummyParticles" - vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) - vtk["smoothing_length"] = system.boundary_model.smoothing_length - vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) - vtk["state_equation"] = type2string(system.boundary_model.state_equation) +function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; write_meta_data=true) + if write_meta_data + vtk["boundary_model"] = "BoundaryModelDummyParticles" + vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) + vtk["smoothing_length"] = system.boundary_model.smoothing_length + vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) + vtk["state_equation"] = type2string(system.boundary_model.state_equation) + end - write2vtk!(vtk, v, u, t, model, model.viscosity, system) + write2vtk!(vtk, v, u, t, model, model.viscosity, system, write_meta_data=write_meta_data) end -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, system) +function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, system; write_meta_data=true) vtk["hydrodynamic_density"] = [particle_density(v, system, particle) for particle in eachparticle(system)] vtk["pressure"] = model.pressure - # write meta data - vtk["viscosity_model"] = type2string(viscosity) + if write_meta_data + vtk["viscosity_model"] = type2string(viscosity) + end + return vtk end function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, - viscosity::ViscosityAdami, system) + viscosity::ViscosityAdami, system; write_meta_data=true) vtk["hydrodynamic_density"] = [particle_density(v, system, particle) for particle in eachparticle(system)] vtk["pressure"] = model.pressure vtk["wall_velocity"] = view(model.cache.wall_velocity, 1:ndims(system), :) - # write meta data - vtk["viscosity_model"] = "ViscosityAdami" + if write_meta_data + vtk["viscosity_model"] = "ViscosityAdami" + end return vtk end From 58cd5581de7d34c41992b768bdda4f3fdfe454a0 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 5 Oct 2023 17:56:06 +0200 Subject: [PATCH 08/13] fix --- examples/n_body/n_body_system.jl | 2 +- src/visualization/write2vtk.jl | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/n_body/n_body_system.jl b/examples/n_body/n_body_system.jl index 9ad29f6b2..80cdbdb5c 100644 --- a/examples/n_body/n_body_system.jl +++ b/examples/n_body/n_body_system.jl @@ -110,7 +110,7 @@ end TrixiParticles.vtkname(system::NBodySystem) = "n-body" -function TrixiParticles.write2vtk!(vtk, v, u, t, system::NBodySystem) +function TrixiParticles.write2vtk!(vtk, v, u, t, system::NBodySystem; write_meta_data=true) (; mass) = system vtk["velocity"] = v diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 7613dba08..6de8d6210 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -148,14 +148,19 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) for particle in eachparticle(system)] if write_meta_data - vtk["solver"] = "WCSPH" - vtk["correction_method"] = type2string(system.correction) vtk["acceleration"] = system.acceleration vtk["viscosity"] = type2string(system.viscosity) vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) vtk["smoothing_length"] = system.smoothing_length vtk["density_calculator"] = type2string(system.density_calculator) - vtk["state_equation"] = type2string(system.state_equation) + + if system isa WeaklyCompressibleSPHSystem + vtk["correction_method"] = type2string(system.correction) + vtk["state_equation"] = type2string(system.state_equation) + vtk["solver"] = "WCSPH" + else + vtk["solver"] = "EDAC" + end write2vtk!(vtk, system.viscosity) end @@ -181,14 +186,14 @@ function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem; write_meta_d zeros(ndims(system), n_fixed_particles)) vtk["material_density"] = system.material_density - write2vtk!(vtk, v, u, t, system.boundary_model, system) + write2vtk!(vtk, v, u, t, system.boundary_model, system, write_meta_data=write_meta_data) end -function write2vtk!(vtk, v, u, t, system::BoundarySPHSystem) - write2vtk!(vtk, v, u, t, system.boundary_model, system) +function write2vtk!(vtk, v, u, t, system::BoundarySPHSystem; write_meta_data=true) + write2vtk!(vtk, v, u, t, system.boundary_model, system, write_meta_data=write_meta_data) end -function write2vtk!(vtk, v, u, t, model, system) +function write2vtk!(vtk, v, u, t, model, system; write_meta_data=true) return vtk end From 084512bd8bbc9c81a86f74d94a47d7df91d10f40 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 5 Oct 2023 17:56:23 +0200 Subject: [PATCH 09/13] format --- src/visualization/write2vtk.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 6de8d6210..461d74765 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -47,7 +47,8 @@ end # Convert data for a single TrixiParticle system to VTK format function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix="", - iter=nothing, system_name=vtkname(system), write_meta_data=true, custom_quantities...) + iter=nothing, system_name=vtkname(system), write_meta_data=true, + custom_quantities...) mkpath(output_directory) # handle "_" on optional pre/postfix strings @@ -197,7 +198,8 @@ function write2vtk!(vtk, v, u, t, model, system; write_meta_data=true) return vtk end -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; write_meta_data=true) +function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; + write_meta_data=true) if write_meta_data vtk["boundary_model"] = "BoundaryModelDummyParticles" vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) @@ -206,10 +208,12 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; wr vtk["state_equation"] = type2string(system.boundary_model.state_equation) end - write2vtk!(vtk, v, u, t, model, model.viscosity, system, write_meta_data=write_meta_data) + write2vtk!(vtk, v, u, t, model, model.viscosity, system, + write_meta_data=write_meta_data) end -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, system; write_meta_data=true) +function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, system; + write_meta_data=true) vtk["hydrodynamic_density"] = [particle_density(v, system, particle) for particle in eachparticle(system)] vtk["pressure"] = model.pressure From 0d6a63b845d702a4f2e40f2fb2579ee79126de89 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 6 Oct 2023 10:33:03 +0200 Subject: [PATCH 10/13] Ignore markdown file changes --- .github/workflows/ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a17ce4fe1..4941456b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,25 @@ on: push: branches: - main + paths-ignore: + - 'AUTHORS.md' + - 'CITATION.bib' + - 'CONTRIBUTING.md' + - 'LICENSE.md' + - 'NEWS.md' + - 'README.md' + - '.github/workflows/CompatHelper.yml' + - 'docs/**' pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'CITATION.bib' + - 'CONTRIBUTING.md' + - 'LICENSE.md' + - 'NEWS.md' + - 'README.md' + - '.github/workflows/CompatHelper.yml' + - 'docs/**' workflow_dispatch: # Cancel redundant CI tests automatically From 2861be6022dfbcc0b682975b209664a2298c58a8 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 13 Oct 2023 15:23:15 +0200 Subject: [PATCH 11/13] [skip ci] review --- src/visualization/write2vtk.jl | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index 461d74765..bf94d0e82 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -72,8 +72,6 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix # Store particle index vtk["index"] = eachparticle(system) - - # Write some meta data vtk["time"] = t # Extract custom quantities for this system @@ -84,7 +82,7 @@ function trixi2vtk(v, u, t, system, periodic_box; output_directory="out", prefix end end - # add to collection + # Add to collection pvd[t] = vtk end vtk_save(pvd) @@ -150,14 +148,14 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) if write_meta_data vtk["acceleration"] = system.acceleration - vtk["viscosity"] = type2string(system.viscosity) + vtk["viscosity"] = repr(system.viscosity) vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) vtk["smoothing_length"] = system.smoothing_length vtk["density_calculator"] = type2string(system.density_calculator) if system isa WeaklyCompressibleSPHSystem - vtk["correction_method"] = type2string(system.correction) - vtk["state_equation"] = type2string(system.state_equation) + vtk["correction_method"] = repr(system.correction) + vtk["state_equation"] = repr(system.state_equation) vtk["solver"] = "WCSPH" else vtk["solver"] = "EDAC" @@ -170,14 +168,14 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) end function write2vtk!(vtk, viscosity::ViscosityAdami) - vtk["nu"] = viscosity.nu - vtk["epsilon"] = viscosity.epsilon + vtk["viscosity_nu"] = viscosity.nu + vtk["viscosity_epsilon"] = viscosity.epsilon end function write2vtk!(vtk, viscosity::ArtificialViscosityMonaghan) - vtk["alpha"] = viscosity.alpha - vtk["beta"] = viscosity.beta - vtk["epsilon"] = viscosity.epsilon + vtk["viscosity_alpha"] = viscosity.alpha + vtk["viscosity_beta"] = viscosity.beta + vtk["viscosity_epsilon"] = viscosity.epsilon end function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem; write_meta_data=true) @@ -205,7 +203,7 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) vtk["smoothing_length"] = system.boundary_model.smoothing_length vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) - vtk["state_equation"] = type2string(system.boundary_model.state_equation) + vtk["state_equation"] = repr(system.boundary_model.state_equation) end write2vtk!(vtk, v, u, t, model, model.viscosity, system, From 8d99d1a8aa3813ee12df31da0c608cc9adff6e79 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Sat, 14 Oct 2023 14:08:41 +0200 Subject: [PATCH 12/13] [skip ci] unpack all models --- src/visualization/write2vtk.jl | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index bf94d0e82..e9199df02 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -148,25 +148,44 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) if write_meta_data vtk["acceleration"] = system.acceleration - vtk["viscosity"] = repr(system.viscosity) + vtk["viscosity"] = type2string(system.viscosity) + write2vtk!(vtk, system.viscosity) vtk["smoothing_kernel"] = type2string(system.smoothing_kernel) vtk["smoothing_length"] = system.smoothing_length vtk["density_calculator"] = type2string(system.density_calculator) if system isa WeaklyCompressibleSPHSystem - vtk["correction_method"] = repr(system.correction) - vtk["state_equation"] = repr(system.state_equation) + vtk["correction_method"] = type2string(system.correction) + if system.correction isa AkinciFreeSurfaceCorrection + vtk["correction_rho0"] = system.correction.rho0 + end + vtk["state_equation"] = type2string(system.state_equation) + write2vtk!(vtk, system.state_equation) + vtk["solver"] = "WCSPH" else vtk["solver"] = "EDAC" end - - write2vtk!(vtk, system.viscosity) end return vtk end +function write2vtk!(vtk, state::StateEquationIdealGas) + vtk["state_equation_rho0"] = state.reference_density + vtk["state_equation_p0"] = state.reference_pressure + vtk["state_equation_pa"] = state.background_pressure + vtk["state_equation_c"] = state.sound_speed +end + +function write2vtk!(vtk, state::StateEquationCole) + vtk["state_equation_rho0"] = state.reference_density + vtk["state_equation_p0"] = state.reference_pressure + vtk["state_equation_pa"] = state.background_pressure + vtk["state_equation_c"] = state.sound_speed + vtk["state_equation_gamma"] = state.gamma +end + function write2vtk!(vtk, viscosity::ViscosityAdami) vtk["viscosity_nu"] = viscosity.nu vtk["viscosity_epsilon"] = viscosity.epsilon @@ -203,7 +222,7 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; vtk["smoothing_kernel"] = type2string(system.boundary_model.smoothing_kernel) vtk["smoothing_length"] = system.boundary_model.smoothing_length vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) - vtk["state_equation"] = repr(system.boundary_model.state_equation) + vtk["state_equation"] = type2string(system.boundary_model.state_equation) end write2vtk!(vtk, v, u, t, model, model.viscosity, system, From 51aae5a9c18430150dd26c6b78bc132f2ecf6785 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Mon, 16 Oct 2023 13:12:27 +0200 Subject: [PATCH 13/13] [skip ci] add additional meta data --- src/visualization/write2vtk.jl | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index e9199df02..2f66b642a 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -160,32 +160,24 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true) vtk["correction_rho0"] = system.correction.rho0 end vtk["state_equation"] = type2string(system.state_equation) - write2vtk!(vtk, system.state_equation) + vtk["state_equation_rho0"] = system.state_equation.reference_density + vtk["state_equation_p0"] = system.state_equation.reference_pressure + vtk["state_equation_pa"] = system.state_equation.background_pressure + vtk["state_equation_c"] = system.state_equation.sound_speed + if system.state_equation isa StateEquationCole + vtk["state_equation_gamma"] = system.state_equation.gamma + end vtk["solver"] = "WCSPH" else vtk["solver"] = "EDAC" + vtk["sound_speed"] = system.sound_speed end end return vtk end -function write2vtk!(vtk, state::StateEquationIdealGas) - vtk["state_equation_rho0"] = state.reference_density - vtk["state_equation_p0"] = state.reference_pressure - vtk["state_equation_pa"] = state.background_pressure - vtk["state_equation_c"] = state.sound_speed -end - -function write2vtk!(vtk, state::StateEquationCole) - vtk["state_equation_rho0"] = state.reference_density - vtk["state_equation_p0"] = state.reference_pressure - vtk["state_equation_pa"] = state.background_pressure - vtk["state_equation_c"] = state.sound_speed - vtk["state_equation_gamma"] = state.gamma -end - function write2vtk!(vtk, viscosity::ViscosityAdami) vtk["viscosity_nu"] = viscosity.nu vtk["viscosity_epsilon"] = viscosity.epsilon @@ -203,6 +195,10 @@ function write2vtk!(vtk, v, u, t, system::TotalLagrangianSPHSystem; write_meta_d vtk["velocity"] = hcat(view(v, 1:ndims(system), :), zeros(ndims(system), n_fixed_particles)) vtk["material_density"] = system.material_density + vtk["young_modulus"] = system.young_modulus + vtk["poisson_ratio"] = system.poisson_ratio + vtk["lame_lambda"] = system.lame_lambda + vtk["lame_mu"] = system.lame_mu write2vtk!(vtk, v, u, t, system.boundary_model, system, write_meta_data=write_meta_data) end @@ -215,6 +211,15 @@ function write2vtk!(vtk, v, u, t, model, system; write_meta_data=true) return vtk end +function write2vtk!(vtk, v, u, t, model::BoundaryModelMonaghanKajtar, system; + write_meta_data=true) + if write_meta_data + vtk["boundary_model"] = "BoundaryModelMonaghanKajtar" + vtk["boundary_spacing_ratio"] = model.beta + vtk["boundary_K"] = model.K + end +end + function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; write_meta_data=true) if write_meta_data