Skip to content
Open
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
97 changes: 97 additions & 0 deletions tests/checkpoint_13_particle_generator_random.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright (C) 2022 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_13_particle_generator_random ; "
"rm -rf output1.tmp ; "
"(cat " ASPECT_SOURCE_DIR "/tests/checkpoint_13_particle_generator_random.prm "
" ; "
" echo 'set Output directory = output1.tmp' "
") "
"| env -i OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 PATH=\"$PATH\" mpirun --oversubscribe -np 2 ../../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_13_particle_generator_random ; "
" rm -rf output2.tmp ; mkdir output2.tmp ; "
" mv 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_13_particle_generator_random ; "
"(cat " ASPECT_SOURCE_DIR "/tests/checkpoint_13_particle_generator_random.prm "
" ; "
" echo 'set Output directory = output2.tmp' "
" ; "
" echo 'set Resume computation = true' "
") "
"| env -i OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 PATH=\"$PATH\" mpirun --oversubscribe -np 2 ../../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_13_particle_generator_random ; "
"cp output1.tmp/particles/particles-00006.0000.gnuplot particles-00006.0000.gnuplot1;"
"cp output2.tmp/particles/particles-00006.0000.gnuplot particles-00006.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();
104 changes: 104 additions & 0 deletions tests/checkpoint_13_particle_generator_random.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Test checkpoint/restart of Particle::Generator::Interface's random-number
# generator. The checkpoint at step 4 precedes refinement at model time 0.5.
# Refinement creates underpopulated cells, which triggers random particle
# insertion. The continuous and resumed particle locations are compared at
# step 6.

set Dimension = 2
set CFL number = 1.0
set Maximum time step = 0.1
set End time = 0.6
set Start time = 0
set Adiabatic surface temperature = 0
set Surface pressure = 0
set Use years instead of seconds = false
set Nonlinear solver scheme = single Advection, single Stokes

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 List of model names = 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
set Time steps between mesh refinement = 5
set Additional refinement times = 0.5
set Strategy = minimum refinement function

subsection Minimum refinement function
set Variable names = x,y,t
set Function expression = if(t > 0.4, 6, 5)
end
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
set Minimum particles per cell = 2
set Load balancing strategy = add particles

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 Random uniform
set Number of particles = 1000
end
end
end
Loading
Loading