diff --git a/CMakeLists.txt b/CMakeLists.txt index 000798d..96bc953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,11 +171,12 @@ endif() # Note that these options may not play nice with nvcc wrapper if (TEST_INTEL_OPTIMIZATION) add_compile_options(-fp-model fast=2 -qopt_report5 -vec-threshold0 -qopt_report_phase=vec) -endif() +endif() add_subdirectory(src) add_subdirectory(example/calculate_pi) add_subdirectory(example/face_fields) add_subdirectory(example/advection) +add_subdirectory(example/particles) include(cmake/CheckCopyright.cmake) diff --git a/example/particles/CMakeLists.txt b/example/particles/CMakeLists.txt new file mode 100644 index 0000000..7a87429 --- /dev/null +++ b/example/particles/CMakeLists.txt @@ -0,0 +1,19 @@ +#========================================================================================= +# (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved. +# +# This program was produced under U.S. Government contract 89233218CNA000001 for Los +# Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC +# for the U.S. Department of Energy/National Nuclear Security Administration. All rights +# in the program are reserved by Triad National Security, LLC, and the U.S. Department +# of Energy/National Nuclear Security Administration. The Government is granted for +# itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide +# license in this material to reproduce, prepare derivative works, distribute copies to +# the public, perform publicly and display publicly, and to permit others to do so. +#========================================================================================= + +add_executable( + particles-example + main.cpp + particles.cpp +) +target_link_libraries(particles-example PRIVATE parthenon) diff --git a/example/particles/main.cpp b/example/particles/main.cpp new file mode 100644 index 0000000..fb11582 --- /dev/null +++ b/example/particles/main.cpp @@ -0,0 +1,60 @@ +//======================================================================================== +// (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved. +// +// This program was produced under U.S. Government contract 89233218CNA000001 for Los +// Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC +// for the U.S. Department of Energy/National Nuclear Security Administration. All rights +// in the program are reserved by Triad National Security, LLC, and the U.S. Department +// of Energy/National Nuclear Security Administration. The Government is granted for +// itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide +// license in this material to reproduce, prepare derivative works, distribute copies to +// the public, perform publicly and display publicly, and to permit others to do so. +//======================================================================================== + +#include "parthenon_manager.hpp" + +#include "particles.hpp" + +int main(int argc, char *argv[]) { + using parthenon::ParthenonManager; + using parthenon::ParthenonStatus; + ParthenonManager pman; + + // call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up + auto manager_status = pman.ParthenonInit(argc, argv); + if (manager_status == ParthenonStatus::complete) { + pman.ParthenonFinalize(); + return 0; + } + if (manager_status == ParthenonStatus::error) { + pman.ParthenonFinalize(); + return 1; + } + printf("File: %s Line: %i\n", __FILE__, __LINE__); + // Now that ParthenonInit has been called and setup succeeded, the code can now + // make use of MPI and Kokkos + + // Initialize the driver + particles_example::ParticleDriver driver(pman.pinput.get(), pman.pmesh.get(), + pman.pouts.get()); + printf("File: %s Line: %i\n", __FILE__, __LINE__); + + // start a timer + pman.PreDriver(); + printf("File: %s Line: %i\n", __FILE__, __LINE__); + + // This line actually runs the simulation + auto driver_status = driver.Execute(); + printf("File: %s Line: %i\n", __FILE__, __LINE__); + + // Make final outputs, print diagnostics + pman.PostDriver(driver_status); + printf("File: %s Line: %i\n", __FILE__, __LINE__); + + // call MPI_Finalize and Kokkos::finalize if necessary + pman.ParthenonFinalize(); + + // MPI and Kokkos can no longer be used + + return (0); +} diff --git a/example/particles/parthinput.particles b/example/particles/parthinput.particles new file mode 100644 index 0000000..fca535b --- /dev/null +++ b/example/particles/parthinput.particles @@ -0,0 +1,60 @@ +# ======================================================================================== +# Athena++ astrophysical MHD code +# Copyright(C) 2014 James M. Stone and other code contributors +# Licensed under the 3-clause BSD License, see LICENSE file for details +# ======================================================================================== +# (C) (or copyright) 2020. Triad National Security, LLC. All rights reserved. +# +# This program was produced under U.S. Government contract 89233218CNA000001 for Los +# Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC +# for the U.S. Department of Energy/National Nuclear Security Administration. All rights +# in the program are reserved by Triad National Security, LLC, and the U.S. Department +# of Energy/National Nuclear Security Administration. The Government is granted for +# itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide +# license in this material to reproduce, prepare derivative works, distribute copies to +# the public, perform publicly and display publicly, and to permit others to do so. +# ======================================================================================== + + +problem = Particle streaming + + +problem_id = particles + + +refinement = none +#numlevel = 3 + +nx1 = 64 +x1min = -0.5 +x1max = 0.5 +ix1_bc = periodic +ox1_bc = periodic + +nx2 = 64 +x2min = -0.5 +x2max = 0.5 +ix2_bc = periodic +ox2_bc = periodic + +nx3 = 1 +x3min = -0.5 +x3max = 0.5 + + +nx1 = 16 +nx2 = 16 +#nx3 = 1 + + +file_type = hdf5 +dt = 0.05 +variable = prim + +