Skip to content

Commit

Permalink
Merge pull request #6066 from gassmoeller/test_checkpoint_restart
Browse files Browse the repository at this point in the history
Add test for checkpoint/restart multiple particle worlds
  • Loading branch information
tjhei authored Oct 10, 2024
2 parents b776b39 + d3dc1d9 commit 2d52085
Show file tree
Hide file tree
Showing 11 changed files with 1,258 additions and 0 deletions.
100 changes: 100 additions & 0 deletions tests/checkpoint_08_particles_multiple_worlds.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copyright (C) 2024 by the authors of the ASPECT code.
This file is part of ASPECT.
ASPECT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
ASPECT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ASPECT; see the file LICENSE. If not see
<http://www.gnu.org/licenses/>.
*/

#include <aspect/simulator.h>
#include <iostream>

/*
* Launch the following function when this plugin is created. Launch ASPECT
* twice to test checkpoint/resume and then terminate the outer ASPECT run.
*/
int f()
{
std::cout << "* starting from beginning:" << std::endl;

// call ASPECT with "--" and pipe an existing input file into it.
int ret;
std::string command;

command = ("cd output-checkpoint_08_particles_multiple_worlds ; "
"(cat " ASPECT_SOURCE_DIR "/tests/checkpoint_08_particles_multiple_worlds.prm "
" ; "
" echo 'set Output directory = output1.tmp' "
" ; "
" rm -rf output1.tmp ; mkdir output1.tmp "
") "
"| ../../aspect -- > /dev/null");
std::cout << "Executing the following command:\n"
<< command
<< std::endl;
ret = system (command.c_str());
if (ret!=0)
std::cout << "system() returned error " << ret << std::endl;

command = ("cd output-checkpoint_08_particles_multiple_worlds ; "
" rm -rf output2.tmp ; mkdir output2.tmp ; "
" cp output1.tmp/restart* output2.tmp/");
std::cout << "Executing the following command:\n"
<< command
<< std::endl;
ret = system (command.c_str());
if (ret!=0)
std::cout << "system() returned error " << ret << std::endl;


std::cout << "* now resuming:" << std::endl;
command = ("cd output-checkpoint_08_particles_multiple_worlds ; "
"(cat " ASPECT_SOURCE_DIR "/tests/checkpoint_08_particles_multiple_worlds.prm "
" ; "
" echo 'set Output directory = output2.tmp' "
" ; "
" echo 'set Resume computation = true' "
") "
"| ../../aspect -- > /dev/null");
std::cout << "Executing the following command:\n"
<< command
<< std::endl;
ret = system (command.c_str());
if (ret!=0)
std::cout << "system() returned error " << ret << std::endl;

std::cout << "* now comparing:" << std::endl;

ret = system ("cd output-checkpoint_08_particles_multiple_worlds; "
"cp output1.tmp/particles/particles-00009.0000.gnuplot particles-00009.0000.gnuplot1;"
"cp output2.tmp/particles/particles-00009.0000.gnuplot particles-00009.0000.gnuplot2;"
"cp output1.tmp/particles-2/particles-2-00009.0000.gnuplot particles-2-00009.0000.gnuplot1;"
"cp output2.tmp/particles-2/particles-2-00009.0000.gnuplot particles-2-00009.0000.gnuplot2;"
"cp output1.tmp/log.txt log.txt1;"
"cp output2.tmp/log.txt log.txt2;"
"cp output1.tmp/statistics statistics1;"
"cp output2.tmp/statistics statistics2;"
"");
if (ret!=0)
std::cout << "system() returned error " << ret << std::endl;

// terminate current process:
exit (0);
return 42;
}


// run this function by initializing a global variable by it
int i = f();
113 changes: 113 additions & 0 deletions tests/checkpoint_08_particles_multiple_worlds.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# test checkpoint/resume.

# This test is controlled via the plugin in checkpoint_08_particles_multiple_worlds.cc.
# The plugin will first execute ASPECT with this .prm and write the output into
# output1.tmp/. This will generate a snapshot that is then resumed from. The
# output for this second run will be written into output2.tmp/. Finally,
# output files will be copied into the main output folder for comparison.

# based on checkpoint_03.prm, but extended for multiple particle worlds.

set Dimension = 2
set CFL number = 1.0
set End time = 1e7
set Start time = 0
set Adiabatic surface temperature = 0
set Surface pressure = 0
set Use years in output instead of seconds = false
set Nonlinear solver scheme = single Advection, single Stokes
set Number of particle worlds = 2

subsection Checkpointing
set Steps between checkpoint = 4
end

subsection Gravity model
set Model name = vertical
end

subsection Geometry model
set Model name = box

subsection Box
set X extent = 1.2
set Y extent = 1
set Z extent = 1
end
end

subsection Initial temperature model
set Model name = perturbed box
end

subsection Material model
set Model name = simple

subsection Simple model
set Reference density = 1
set Reference specific heat = 1250
set Reference temperature = 1
set Thermal conductivity = 1e-6
set Thermal expansion coefficient = 2e-5
set Viscosity = 1
end
end

subsection Mesh refinement
set Initial adaptive refinement = 0
set Initial global refinement = 5
end

subsection Boundary velocity model
set Tangential velocity boundary indicators = 1
set Zero velocity boundary indicators = 0, 2, 3
end

subsection Postprocess
set List of postprocessors = composition statistics, temperature statistics, velocity statistics, particles

subsection Particles
set Time between data output = 0
set Data output format = ascii
end
end

subsection Termination criteria
set Checkpoint on termination = false
end

subsection Solver parameters
subsection Stokes solver parameters
set Use direct solver for Stokes system = true
end
end

subsection Particles
set List of particle properties = function, initial position, position, velocity

subsection Function
set Variable names = x,z
set Function expression = if( (z>0.2+0.02*cos(pi*x/0.9142)) , 0 , 1 )
end

subsection Generator
subsection Probability density function
set Number of particles = 100
end
end
end

subsection Particles 2
set List of particle properties = function, initial position, position, velocity

subsection Function
set Variable names = x,z
set Function expression = if( (z>0.2+0.02*cos(pi*x/0.9142)) , 1 , 0 )
end

subsection Generator
subsection Probability density function
set Number of particles = 100
end
end
end
122 changes: 122 additions & 0 deletions tests/checkpoint_08_particles_multiple_worlds/log.txt1
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@

Number of active cells: 1,024 (on 6 levels)
Number of degrees of freedom: 13,764 (9,539+4,225)

*** Timestep 0: t=0 seconds, dt=0 seconds
Solving temperature system... 0 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1 K, 1.041 K, 1.1 K
RMS, max velocity: 5.92e-09 m/s, 1.52e-08 m/s
Writing particle output: output1.tmp/particles/particles-00000

*** Timestep 1: t=1.02774e+06 seconds, dt=1.02774e+06 seconds
Solving temperature system... 25 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.001 K, 1.041 K, 1.099 K
RMS, max velocity: 5.75e-09 m/s, 1.46e-08 m/s
Writing particle output: output1.tmp/particles/particles-00001

*** Timestep 2: t=2.1003e+06 seconds, dt=1.07256e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.002 K, 1.041 K, 1.097 K
RMS, max velocity: 5.58e-09 m/s, 1.39e-08 m/s
Writing particle output: output1.tmp/particles/particles-00002

*** Timestep 3: t=3.22036e+06 seconds, dt=1.12006e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.003 K, 1.041 K, 1.096 K
RMS, max velocity: 5.4e-09 m/s, 1.34e-08 m/s
Writing particle output: output1.tmp/particles/particles-00003

*** Snapshot created!

*** Timestep 4: t=4.39059e+06 seconds, dt=1.17022e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.003 K, 1.041 K, 1.094 K
RMS, max velocity: 5.22e-09 m/s, 1.28e-08 m/s
Writing particle output: output1.tmp/particles/particles-00004

*** Timestep 5: t=5.61338e+06 seconds, dt=1.2228e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.004 K, 1.041 K, 1.093 K
RMS, max velocity: 5.03e-09 m/s, 1.22e-08 m/s
Writing particle output: output1.tmp/particles/particles-00005

*** Timestep 6: t=6.89231e+06 seconds, dt=1.27893e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.005 K, 1.041 K, 1.091 K
RMS, max velocity: 4.84e-09 m/s, 1.17e-08 m/s
Writing particle output: output1.tmp/particles/particles-00006

*** Timestep 7: t=8.23159e+06 seconds, dt=1.33928e+06 seconds
Solving temperature system... 19 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.006 K, 1.041 K, 1.09 K
RMS, max velocity: 4.65e-09 m/s, 1.11e-08 m/s
Writing particle output: output1.tmp/particles/particles-00007

*** Snapshot created!

*** Timestep 8: t=9.63611e+06 seconds, dt=1.40452e+06 seconds
Solving temperature system... 20 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.007 K, 1.041 K, 1.088 K
RMS, max velocity: 4.45e-09 m/s, 1.06e-08 m/s
Writing particle output: output1.tmp/particles/particles-00008

*** Timestep 9: t=1e+07 seconds, dt=363889 seconds
Solving temperature system... 9 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.007 K, 1.041 K, 1.087 K
RMS, max velocity: 4.41e-09 m/s, 1.05e-08 m/s
Writing particle output: output1.tmp/particles/particles-00009

Termination requested by criterion: end time



32 changes: 32 additions & 0 deletions tests/checkpoint_08_particles_multiple_worlds/log.txt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

*** Resuming from snapshot!

Number of active cells: 1,024 (on 6 levels)
Number of degrees of freedom: 13,764 (9,539+4,225)

*** Timestep 8: t=9.63611e+06 seconds, dt=1.40452e+06 seconds
Solving temperature system... 20 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.007 K, 1.041 K, 1.088 K
RMS, max velocity: 4.45e-09 m/s, 1.06e-08 m/s
Writing particle output: output2.tmp/particles/particles-00008

*** Timestep 9: t=1e+07 seconds, dt=363889 seconds
Solving temperature system... 9 iterations.
Advecting particles... done.
Advecting particles... done.
Solving Stokes system (direct)... done.

Postprocessing:
Temperature min/avg/max: 1.007 K, 1.041 K, 1.087 K
RMS, max velocity: 4.41e-09 m/s, 1.05e-08 m/s
Writing particle output: output2.tmp/particles/particles-00009

Termination requested by criterion: end time



Loading

0 comments on commit 2d52085

Please sign in to comment.