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

Fix restart transient with variable time step #1093

Merged
merged 14 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to the Lethe project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-04-16

### Fixed

- MINOR Simulations with adaptive time-stepping would checkpoint correctly, but would not restart with the correct time-step due to the way the time-step was read from the checkpointing files. This is now fixed and tested. [#1093](https://github.com/lethe-cfd/lethe/pull/1093)

## [Master] - 2024-04-07

### Added
Expand Down
9 changes: 9 additions & 0 deletions applications_tests/lethe-fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ file(COPY taylor-green-vortex-restart_gls_bdf1/enstrophy.checkpoint DESTINATION
file(COPY taylor-green-vortex-restart_gls_bdf1/kinetic_energy.checkpoint DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart_gls_bdf1.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart_gls_bdf1/L2Error_FD.checkpoint DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart_gls_bdf1.${_build_type}/mpirun=1/")

file(COPY taylor-green-vortex-restart-bdf1-adaptive/restart.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/restart.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/restart.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/restart.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/restart.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/enstrophy.checkpoint DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/kinetic_energy.checkpoint DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")
file(COPY taylor-green-vortex-restart-bdf1-adaptive/L2Error_FD.checkpoint DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/taylor-green-vortex-restart-bdf1-adaptive.${_build_type}/mpirun=1/")


file(COPY cylinder_unstructured.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY poiseuille_restart_files/poiseuille_restart.averagevelocities DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/poiseuille_restart.${_build_type}/mpirun=1/")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Running on 1 MPI rank(s)...
Number of active cells: 1
Number of degrees of freedom: 12
Volume of triangulation: 39.4784
************************
---> Simulation Restart
************************
Number of active cells: 1024
Number of degrees of freedom: 3267
Volume of triangulation: 39.4784

*********************************************************************************
Transient iteration: 19 Time: 0.511589 Time step: 0.0555984 CFL: 0.0937518
*********************************************************************************
Enstrophy : 0.0686874
Kinetic energy : 0.0342889

*********************************************************************************
Transient iteration: 20 Time: 0.572748 Time step: 0.0611582 CFL: 0.0927773
*********************************************************************************
Enstrophy : 0.0544932
Kinetic energy : 0.0272031

*********************************************************************************
Transient iteration: 21 Time: 0.6 Time step: 0.0272524 CFL: 0.0909005
*********************************************************************************
Enstrophy : 0.0489892
Kinetic energy : 0.0244555
time error_velocity
0.0100 9.702604e-04
0.0210 1.497541e-03
0.0331 2.266297e-03
0.0464 3.238495e-03
0.0611 4.415871e-03
0.0772 5.813999e-03
0.0949 7.453486e-03
0.1144 9.356386e-03
0.1358 1.154396e-02
0.1594 1.403464e-02
0.1853 1.684182e-02
0.2138 1.997132e-02
0.2452 2.341851e-02
0.2797 2.716517e-02
0.3177 3.117615e-02
0.3595 3.539619e-02
0.4054 3.974710e-02
0.4560 4.412568e-02
0.5116 4.840382e-02
0.5727 5.242945e-02
0.6000 5.140802e-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Listing of Parameters
#----------------------

set dimension = 2

#---------------------------------------------------
# Simulation Control
#---------------------------------------------------

subsection simulation control
set method = bdf1
set adapt = true
set max cfl = 1
set time step = 0.01 # Time step
set time end = 0.60 # End time of simulation
set output frequency = 0 # Frequency of simulation output
end

#---------------------------------------------------
# FEM
#---------------------------------------------------

subsection FEM
set velocity order = 1
set pressure order = 1
end

#---------------------------------------------------
# Initial condition
#---------------------------------------------------

subsection initial conditions
set type = L2projection
subsection uvwp
set Function expression = cos(x)*sin(y); -sin(x)*cos(y); -1./4*(cos(2*x)+cos(2*y));
end
end

#---------------------------------------------------
# Physical Properties
#---------------------------------------------------

subsection physical properties
set number of fluids = 1
subsection fluid 0
set kinematic viscosity = 1.000
end
end

#---------------------------------------------------
# Analytical Solution
#---------------------------------------------------

subsection analytical solution
set verbosity = quiet
set enable = true
subsection uvwp
set Function constants = viscosity=1
set Function expression = exp(-2*viscosity*t)* cos(x) * sin(y) ; -sin(x) * cos(y) * exp(-2*viscosity*t); 0
end
end

#--------------------------------------------------
# Restart
#--------------------------------------------------

subsection restart
# Enable checkpointing
set checkpoint = false
# Prefix for the filename of checkpoints
set filename = restart
# Frequency for checkpointing
set frequency = 1
# Enable restart from checkpoint
set restart = true
end

#---------------------------------------------------
# Post-Processing
#---------------------------------------------------

subsection post-processing
set verbosity = verbose
set calculate enstrophy = true
set calculate kinetic energy = true
end

#---------------------------------------------------
# Mesh
#---------------------------------------------------

subsection mesh
set type = dealii
set grid type = hyper_cube
set grid arguments = 0 : 6.28318530718 : true
set initial refinement = 5 # initial mesh refinement
end

#---------------------------------------------------
# Boundary Conditions
#---------------------------------------------------

subsection boundary conditions
set number = 2
subsection bc 0
set type = periodic
set id = 0
set periodic_id = 1
set periodic_direction = 0
end
subsection bc 1
set type = periodic
set id = 2
set periodic_id = 3
set periodic_direction = 1
end
end

#---------------------------------------------------
# Non-Linear Solver Control
#---------------------------------------------------

subsection non-linear solver
subsection fluid dynamics
set verbosity = quiet
set tolerance = 1e-6
set max iterations = 5
end
end

#---------------------------------------------------
# Linear Solver Control
#---------------------------------------------------

subsection linear solver
subsection fluid dynamics
set verbosity = quiet
set method = gmres
set max iters = 5000
set relative residual = 1e-4
set minimum residual = 1e-9
set ilu preconditioner absolute tolerance = 1e-10
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0 0 2 0 4 time 14 error_velocity 0 0 2 0 0 0 14 error_velocity 0 0 0 0 18 0 0 0 100 9.70260438756596509e-04 100 1.49754055734914893e-03 100 2.26629717992125413e-03 100 3.23849465845258604e-03 100 4.41587088391762368e-03 100 5.81399899031224618e-03 100 7.45348605033036363e-03 100 9.35638645623649082e-03 100 1.15439608889093444e-02 100 1.40346418651400764e-02 100 1.68418208442545417e-02 100 1.99713182759173012e-02 100 2.34185102245543161e-02 100 2.71651688444639501e-02 100 3.11761540150923208e-02 100 3.53961946713119632e-02 100 3.97471025974981060e-02 100 4.41256835874094810e-02 14 error_velocity 1 c 4 0 0 6 4 time 18 0 100 1.00000000000000002e-02 100 2.10000000000000013e-02 100 3.31000000000000044e-02 100 4.64100000000000068e-02 100 6.10510000000000080e-02 100 7.71561000000000052e-02 100 9.48717100000000119e-02 100 1.14358881000000023e-01 100 1.35794769100000046e-01 100 1.59374246010000054e-01 100 1.85311670611000068e-01 100 2.13842837672100078e-01 100 2.45227121439310108e-01 100 2.79749833583241125e-01 100 3.17724816941565291e-01 100 3.59497298635721829e-01 100 4.05447028499294038e-01 100 4.55990999999999980e-01 4 time 1 c 4 0 0 6 0 0 0 0 0 0 0 0 0 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0 0 2 0 4 time 9 enstrophy 0 0 2 0 0 0 9 enstrophy 0 0 0 0 19 0 0 0 100 5.00800056059643506e-01 100 4.81292453184982649e-01 100 4.60730446886153500e-01 100 4.39148232491193169e-01 100 4.16599769896649319e-01 100 3.93161107437332569e-01 100 3.68932426473623065e-01 100 3.44039621819007491e-01 100 3.18635202496210468e-01 100 2.92898273914864504e-01 100 2.67033353019284048e-01 100 2.41267778667671601e-01 100 2.15847518126948579e-01 100 1.91031244145675655e-01 100 1.67082671187051279e-01 100 1.44261294302352155e-01 100 1.22811866702692465e-01 100 1.02953166017756031e-01 100 8.48670369593871599e-02 9 enstrophy 1 c 12 0 0 14 4 time 19 0 100 0.00000000000000000e+00 100 1.00000000000000002e-02 100 2.10000000000000013e-02 100 3.31000000000000044e-02 100 4.64100000000000068e-02 100 6.10510000000000080e-02 100 7.71561000000000052e-02 100 9.48717100000000119e-02 100 1.14358881000000023e-01 100 1.35794769100000046e-01 100 1.59374246010000054e-01 100 1.85311670611000068e-01 100 2.13842837672100078e-01 100 2.45227121439310108e-01 100 2.79749833583241125e-01 100 3.17724816941565291e-01 100 3.59497298635721829e-01 100 4.05447028499294038e-01 100 4.55990999999999980e-01 4 time 1 c 12 0 0 14 0 0 0 0 0 0 0 0 0 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Listing of Parameters
#----------------------

set dimension = 2

#---------------------------------------------------
# Simulation Control
#---------------------------------------------------

subsection simulation control
set method = bdf1
set adapt = true
set max cfl = 1
set time step = 0.01 # Time step
set time end = 0.455991 # End time of simulation
set output frequency = 0 # Frequency of simulation output
end

#---------------------------------------------------
# FEM
#---------------------------------------------------

subsection FEM
set velocity order = 1
set pressure order = 1
end

#---------------------------------------------------
# Initial condition
#---------------------------------------------------

subsection initial conditions
set type = L2projection
subsection uvwp
set Function expression = cos(x)*sin(y); -sin(x)*cos(y); -1./4*(cos(2*x)+cos(2*y));
end
end

#---------------------------------------------------
# Physical Properties
#---------------------------------------------------

subsection physical properties
set number of fluids = 1
subsection fluid 0
set kinematic viscosity = 1.000
end
end

#---------------------------------------------------
# Analytical Solution
#---------------------------------------------------

subsection analytical solution
set verbosity = quiet
set enable = true
subsection uvwp
set Function constants = viscosity=1
set Function expression = exp(-2*viscosity*t)* cos(x) * sin(y) ; -sin(x) * cos(y) * exp(-2*viscosity*t); 0
end
end

#--------------------------------------------------
# Restart
#--------------------------------------------------

subsection restart
# Enable checkpointing
set checkpoint = true
# Prefix for the filename of checkpoints
set filename = restart
# Frequency for checkpointing
set frequency = 1
# Enable restart from checkpoint
set restart = false
end

#---------------------------------------------------
# Post-Processing
#---------------------------------------------------

subsection post-processing
set verbosity = verbose
set calculate enstrophy = true
set calculate kinetic energy = true
end

#---------------------------------------------------
# Mesh
#---------------------------------------------------

subsection mesh
set type = dealii
set grid type = hyper_cube
set grid arguments = 0 : 6.28318530718 : true
set initial refinement = 5 # initial mesh refinement
end

#---------------------------------------------------
# Boundary Conditions
#---------------------------------------------------

subsection boundary conditions
set number = 2
subsection bc 0
set type = periodic
set id = 0
set periodic_id = 1
set periodic_direction = 0
end
subsection bc 1
set type = periodic
set id = 2
set periodic_id = 3
set periodic_direction = 1
end
end

#---------------------------------------------------
# Non-Linear Solver Control
#---------------------------------------------------

subsection non-linear solver
subsection fluid dynamics
set verbosity = verbose
set tolerance = 1e-6
set max iterations = 5
end
end

#---------------------------------------------------
# Linear Solver Control
#---------------------------------------------------

subsection linear solver
subsection fluid dynamics
set verbosity = verbose
set method = gmres
set max iters = 5000
set relative residual = 1e-4
set minimum residual = 1e-9
set ilu preconditioner absolute tolerance = 1e-10
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0 0 2 0 4 time 14 kinetic-energy 0 0 2 0 0 0 14 kinetic-energy 0 0 0 0 19 0 0 0 100 2.49999992602278481e-01 100 2.40261774191911137e-01 100 2.29997195802589066e-01 100 2.19223328289914227e-01 100 2.07967108505439036e-01 100 1.96266499870904693e-01 100 1.84171513043521584e-01 100 1.71744994867286033e-01 100 1.59063078031495136e-01 100 1.46215172173789792e-01 100 1.33303372400469994e-01 100 1.20441166544648065e-01 100 1.07751341763395181e-01 100 9.53630278053799463e-02 100 8.34078712491547469e-02 100 7.20154123375654071e-02 100 6.13078321689155964e-02 100 5.13943447997732006e-02 100 4.23657273294573145e-02 14 kinetic-energy 1 c 12 0 0 14 4 time 19 0 100 0.00000000000000000e+00 100 1.00000000000000002e-02 100 2.10000000000000013e-02 100 3.31000000000000044e-02 100 4.64100000000000068e-02 100 6.10510000000000080e-02 100 7.71561000000000052e-02 100 9.48717100000000119e-02 100 1.14358881000000023e-01 100 1.35794769100000046e-01 100 1.59374246010000054e-01 100 1.85311670611000068e-01 100 2.13842837672100078e-01 100 2.45227121439310108e-01 100 2.79749833583241125e-01 100 3.17724816941565291e-01 100 3.59497298635721829e-01 100 4.05447028499294038e-01 100 4.55990999999999980e-01 4 time 1 c 12 0 0 14 0 0 0 0 0 0 0 0 0 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0
Time File
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Simulation control
dt_0 0.050544
dt_1 0.0459497
dt_2 0.0417725
dt_3 0.037975
CFL 0.0937518
Time 0.455991
Iter 18
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version nproc n_attached_fixed_size_objs n_attached_variable_size_objs n_coarse_cells
5 1 1 0 1
Binary file not shown.
Loading
Loading