-
Notifications
You must be signed in to change notification settings - Fork 20
Restart from VTU #1037
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
Open
LasNikas
wants to merge
116
commits into
trixi-framework:dev
Choose a base branch
from
LasNikas:restart-from-vtu
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Restart from VTU #1037
Changes from 105 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
f1400fd
Update vtk2trixi function to return `NamedTuple` instead of `InitialC…
marcelschurer 217f711
Refactor vtk2trixi function to accept custom fields
marcelschurer 0fa5900
Enhance vtk2trixi function to support scalar and vector custom quanti…
marcelschurer 66f83a3
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer 38a9b2a
Fix typo in documentation for vtk2trixi function
marcelschurer 5d1192a
Fix capitalization in comments
marcelschurer 0713bdd
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer 2cf2b1c
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer eb98b4f
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer 1d33e8b
Merge branch 'main' into vtk2trixi-return-named-tuple
LasNikas 0b22696
Merge branch 'main' into vtk2trixi-return-named-tuple
svchb 7e51a81
add ELTYPE
cac637d
Merge branch 'main' into read-with-eltype
ffa4a1c
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer c51f2ac
Merge branch 'vtk2trixi-return-named-tuple' of https://github.com/mar…
marcelschurer 2b2fb72
Fix formatting in documentation
marcelschurer d460b88
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer a621cca
Merge branch 'main' into read-with-eltype
1b889b4
Merge branch 'main' into read-with-eltype
b043bd1
add `coordinates_eltype`
de55ebd
Merge branch 'main' into read-with-eltype
9515f84
Merge branch 'main' into vtk2trixi-return-named-tuple
marcelschurer a9b0f2f
Corrected failing doctest output
marcelschurer 0359425
first prototype
fd15671
write Q
364e24e
gpu fix
c1b0abf
add checks
eeebcc2
add docs
d8b5b00
Corrected failing doctest output
marcelschurer d21a549
adapt pressure model
b4020c8
use `foreach_no_alloc`
55be6a6
fix unit tests
4fe3c7d
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
a431873
fix unit tests
b27e54d
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
9339bcb
fix unit tests
5aa8f30
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
d8cda93
fix doc tests
be8a23e
better docs
8aff117
use stored type
868b449
add docs
6e390c2
add tests
f3a981b
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
6121e7d
fix formatting
dc02bd8
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
7369f71
fix eltype
3682dd8
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
3a97e49
Merge branch 'main' into fix_pressure_model
4dcece2
Merge branch 'main' into flow-rate-per-boundary-zone
38e376a
Merge branch 'main' into read-with-eltype
f347da8
Merge branch 'main' into vtk2trixi-return-named-tuple
LasNikas b25415f
Merge remote-tracking branch 'marcel/vtk2trixi-return-named-tuple' in…
a912326
revise #959
29b5b1a
fix buffer
daceea2
first poc
039dd13
Merge branch 'poc-restart' into restart-from-vtu
e9750b0
add show
695fe6c
remove mass
3acfe6c
Merge branch 'poc-restart' into restart-from-vtu
2d8bce8
add preconditioning
616a2dc
fix inactive particles
a80518c
fix zone IDs
439cb6b
add test
f3049a4
make it gpu compatible
1c7cd38
add gpu tests
c605502
fix tests
5987957
Merge branch 'poc-restart' into restart-from-vtu
1cada77
add checks
100590e
add example
358848d
add docs
2b56dc8
fix typo
63b760a
Merge branch 'main' into flow-rate-per-boundary-zone
7c08761
implement suggestions
90402fb
Merge branch 'main' into read-with-eltype
4a6bca1
implement suggestions
bbeade4
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
f8f788c
implement suggestions
ce0febf
Merge branch 'main' into read-with-eltype
9e4276a
use strings instead of RestartConditin
7564985
add test mixed types
2e744db
Merge branch 'main' into flow-rate-per-boundary-zone
b831fa5
Merge branch 'flow-rate-per-boundary-zone' into fix_pressure_model
6848fbf
Merge branch 'fix_pressure_model' into restart-from-vtu
c4ce276
Merge branch 'main' into poc-restart
5c600c4
Merge branch 'read-with-eltype' into poc-restart
54190e6
Merge branch 'poc-restart' into restart-from-vtu
16fcfba
Merge branch 'main' into vtk2trixi-return-named-tuple
cfba71c
add NEWS entry
2dcbc76
revise
0d587cd
fix doc test
f316d3d
Merge branch 'main' into restart-from-vtu
bb4e7da
Merge branch 'vtk2trixi-return-named-tuple' into restart-from-vtu
48a79e1
rm test file
f264c9a
fix merge bugs
df63263
fix preconditioning
e26a569
Merge branch 'main' into restart-from-vtu
47bc4c2
don't read IC
2ca0551
Merge branch 'main' into vtk2trixi-return-named-tuple
5afcc47
Merge branch 'main' into restart-from-vtu
ae5496a
fix merge bug
143e9dc
Merge branch 'dev' into vtk2trixi-return-named-tuple
cf0a4a2
Merge branch 'main' into vtk2trixi-return-named-tuple
a1fc021
fix NEWS entry
32872b0
Merge branch 'dev' into vtk2trixi-return-named-tuple
ab1476b
Merge branch 'vtk2trixi-return-named-tuple' into restart-from-vtu
8c50353
fix merge bug
6fa813a
Merge branch 'vtk2trixi-return-named-tuple' into restart-from-vtu
4b3b911
fix formatting
55635fc
better name
f02d724
add more tests
2542c15
Merge branch 'main' into restart-from-vtu
21853d3
Merge branch 'dev' into restart-from-vtu
6221cbc
revise example
16ee9d1
Merge branch 'dev' into restart-from-vtu
d69528d
Merge branch 'dev' into restart-from-vtu
ce37610
Merge branch 'dev' into restart-from-vtu
LasNikas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # ========================================================================================== | ||
| # Restart Example | ||
| # | ||
| # TODO | ||
| # ========================================================================================== | ||
| using TrixiParticles | ||
|
|
||
| # Run full simulation | ||
| # trixi_include(@__MODULE__, | ||
| # joinpath(examples_dir(), "fluid", "poiseuille_flow_2d.jl"), | ||
| # tspan=(0.0, 0.6), sound_speed_factor=10, particle_spacing=4e-5) | ||
|
|
||
| # Run half simulation | ||
| trixi_include(@__MODULE__, | ||
| joinpath(examples_dir(), "fluid", "poiseuille_flow_2d.jl"), | ||
| tspan=(0.0, 0.3), sound_speed_factor=10, particle_spacing=4e-5) | ||
|
|
||
| iter = round(Int, 0.3 / 0.02) | ||
|
|
||
| restart_file_fluid = joinpath("out", "fluid_1_$iter.vtu") | ||
| restart_file_open_boundary = joinpath("out", "open_boundary_1_$iter.vtu") | ||
| restart_file_boundary = joinpath("out", "boundary_1_$iter.vtu") | ||
|
|
||
| ode_restart = semidiscretize(semi, (0.3, 0.6); | ||
| restart_with=(restart_file_fluid, | ||
| restart_file_open_boundary, | ||
| restart_file_boundary)) | ||
|
|
||
| saving_callback = SolutionSavingCallback(dt=0.02, prefix="restart") | ||
|
|
||
| callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback()) | ||
|
|
||
| sol_restart = solve(ode_restart, RDPK3SpFSAL35(), abstol=1e-5, reltol=1e-3, dtmax=1e-2, | ||
| save_everystep=false, callback=callbacks) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| function set_initial_conditions!(v0_ode, u0_ode, semi, restart_with::Tuple{Vararg{String}}) | ||
| # Check number of systems | ||
| if length(semi.systems) != length(restart_with) | ||
| throw(ArgumentError("Number of systems in `semi` does not match number of restart files provided " * | ||
| "in `restart_with`")) | ||
| end | ||
|
|
||
| # Check that systems match | ||
| expected_system_names = system_names(semi.systems) | ||
| foreach_system(semi) do system | ||
| system_index = system_indices(system, semi) | ||
| filename = restart_with[system_index] | ||
| expected_system_name = expected_system_names[system_index] | ||
| if !occursin(expected_system_name, basename(splitext(filename)[1])) | ||
| throw(ArgumentError("Filename '$filename' for system $system_index does not contain expected name '$expected_system_name'. " * | ||
| "Expected a VTK file for system of type $(nameof(typeof(system))).")) | ||
| end | ||
| end | ||
|
|
||
| # Set initial conditions | ||
| foreach_noalloc(semi.systems, restart_with) do (system, restart_file) | ||
| v0_system = wrap_v(v0_ode, system, semi) | ||
| u0_system = wrap_u(u0_ode, system, semi) | ||
|
|
||
| restart_data = vtk2trixi(restart_file; create_initial_condition=false) | ||
| v_restart = restart_v(system, restart_data) | ||
| u_restart = restart_u(system, restart_data) | ||
|
|
||
| v0_system .= Adapt.adapt(semi.parallelization_backend, v_restart) | ||
| u0_system .= Adapt.adapt(semi.parallelization_backend, u_restart) | ||
|
|
||
| precondition_system!(system, restart_file) | ||
| end | ||
| end | ||
|
|
||
| function time_span(tspan, restart_with::Tuple{Vararg{String}}) | ||
| restart_data = vtk2trixi(first(restart_with)) | ||
| t_restart = convert(eltype(tspan), restart_data.time) | ||
|
|
||
| if !isapprox(tspan[1], t_restart) | ||
| @info "Adjusting initial time from $(tspan[1]) to restart time $t_restart" | ||
| end | ||
|
|
||
| return (t_restart, tspan[2]) | ||
| end | ||
|
|
||
| function write_density_and_pressure!(v_restart, system, density_calculator, | ||
| pressure, density) | ||
| return v_restart | ||
| end | ||
|
|
||
| function write_density_and_pressure!(v_restart, system, | ||
| density_calculator::ContinuityDensity, | ||
| pressure, density) | ||
| v_restart[size(v_restart, 1), :] = density | ||
|
|
||
| return v_restart | ||
| end | ||
|
|
||
| function write_density_and_pressure!(v_restart, system::EntropicallyDampedSPHSystem, | ||
| density_calculator::ContinuityDensity, | ||
| pressure, density) | ||
| v_restart[size(v_restart, 1), :] = density | ||
| v_restart[size(v_restart, 1) - 1, :] = pressure | ||
|
|
||
| return v_restart | ||
| end | ||
|
|
||
| precondition_system!(system, restart_file) = system | ||
|
|
||
| function initialize_neighborhood_searches!(semi, u0_ode, | ||
| restart_with::Tuple{Vararg{String}}) | ||
| foreach_system(semi) do system | ||
| foreach_system(semi) do neighbor | ||
| initialize_neighborhood_search!(semi, system, neighbor, u0_ode) | ||
| end | ||
| end | ||
|
|
||
| return semi | ||
| end | ||
|
|
||
| function initialize_neighborhood_search!(semi, system, neighbor, u0_ode) | ||
| # TODO Initialize after adapting to the GPU. | ||
| # Currently, this cannot use `semi.parallelization_backend` | ||
| # because data is still on the CPU. | ||
| PointNeighbors.initialize!(get_neighborhood_search(system, neighbor, semi), | ||
| initial_restart_coordinates(system, u0_ode, semi), | ||
| initial_restart_coordinates(neighbor, u0_ode, semi), | ||
| eachindex_y=each_active_particle(neighbor), | ||
| parallelization_backend=PolyesterBackend()) | ||
| return semi | ||
| end | ||
|
|
||
| function initialize_neighborhood_search!(semi, system::TotalLagrangianSPHSystem, | ||
| neighbor::TotalLagrangianSPHSystem, u0_ode) | ||
| # For TLSPH, the self-interaction NHS is already initialized in the system constructor | ||
| return semi | ||
| end | ||
|
|
||
| function initial_restart_coordinates(system, u0_ode, semi) | ||
| # Transfer to CPU if data is on the GPU. Do nothing if already on CPU. | ||
| return transfer2cpu(wrap_u(u0_ode, system, semi)) | ||
| end | ||
|
|
||
| function initial_restart_coordinates(system::Union{WallBoundarySystem, | ||
| AbstractStructureSystem}, u0_ode, semi) | ||
| return initial_coordinates(system) | ||
| end | ||
|
|
||
| function initialize!(semi::Semidiscretization, restart_with::Tuple{Vararg{String}}) | ||
| foreach_system(semi) do system | ||
| # Initialize this system | ||
| initialize_restart!(system, semi) | ||
| end | ||
|
|
||
| return semi | ||
| end | ||
|
|
||
| initialize_restart!(system, semi) = initialize!(system, semi) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.