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

WIP: Add particles #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 19 additions & 0 deletions example/particles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
55 changes: 55 additions & 0 deletions example/particles/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//========================================================================================
// (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;
}
// 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());

// start a timer
pman.PreDriver();

// This line actually runs the simulation
auto driver_status = driver.Execute();

// Make final outputs, print diagnostics
pman.PostDriver(driver_status);

// call MPI_Finalize and Kokkos::finalize if necessary
pman.ParthenonFinalize();

// MPI and Kokkos can no longer be used

return (0);
}
60 changes: 60 additions & 0 deletions example/particles/parthinput.particles
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# ========================================================================================
# Athena++ astrophysical MHD code
# Copyright(C) 2014 James M. Stone <[email protected]> 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.
# ========================================================================================

<comment>
problem = Particle streaming

<job>
problem_id = particles

<mesh>
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

<meshblock>
nx1 = 16
nx2 = 16
#nx3 = 1

<output1>
file_type = hdf5
dt = 0.05
variable = prim

<time>
tlim = 1.0
integrator = rk2

<Particles>
num_particles = 100
particle_speed = 1.0
Loading