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
107 changes: 107 additions & 0 deletions inputs/disk/wave_killing.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# ========================================================================================
# (C) (or copyright) 2026. 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.
# ========================================================================================

# This file was created in part by generative AI
#
<artemis>
problem = disk
coordinates = axisymmetric

<parthenon/job>
problem_id = disk_wave_killing

<parthenon/output1>
variables = gas.prim.density, &
gas.prim.velocity, &
gas.prim.pressure, &
dust.prim.density, &
dust.prim.velocity
file_type = hdf5
dt = 1.0

<parthenon/time>
nlim = 3
tlim = 1.0
integrator = rk2
ncycle_out = 1

<parthenon/mesh>
nx1 = 32
x1min = 0.5
x1max = 2.0
ix1_bc = ic
ox1_bc = ic

nx2 = 16
x2min = -0.2
x2max = 0.2
ix2_bc = ic
ox2_bc = ic

nx3 = 1
x3min = -0.5
x3max = 0.5
ix3_bc = periodic
ox3_bc = periodic

<parthenon/meshblock>
nx1 = 8
nx2 = 8
nx3 = 1

<physics>
gas = true
dust = true
gravity = true

<gas>
cfl = 0.3
reconstruct = plm
riemann = hllc-general
dfloor = 1.0e-10
siefloor = 1.0e-10

<gas/eos/ideal>
gamma = 1.4

<dust>
cfl = 0.3
nspecies = 2
size_input = direct
sizes = 1.0e-4, 1.0e-3
grain_density = 1.0
reconstruct = plm
riemann = hlle
dfloor = 1.0e-10

<gravity/point>
mass = 1.0

<problem>
r0 = 1.0
rho0 = 1.0
dslope = -1.0
flare = 0.0
h0 = 0.1
polytropic_index = 1.0
quiet_start = true

<problem/wave_killing>
x1_inner = 0.7
x1_outer = 1.8
x1_inner_rate = 5.0
x1_outer_rate = 5.0
x2_inner = -0.15
x2_outer = 0.15
x2_inner_rate = 5.0
x2_outer_rate = 5.0
31 changes: 31 additions & 0 deletions src/artemis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
// the public, perform publicly and display publicly, and to permit others to do so.
//========================================================================================

// This file was created in part by generative AI

// C++ includes
#include <utility>

// Artemis includes
#include "artemis.hpp"
#include "artemis_driver.hpp"
Expand All @@ -36,6 +41,32 @@

namespace artemis {

namespace {
std::vector<UserSourceTask> user_source_tasks;
} // namespace

//----------------------------------------------------------------------------------------
//! \fn void Artemis::RegisterUserSourceTask
//! \brief Registers a named problem-generator source task in execution order
void RegisterUserSourceTask(const std::string &name, UserSourceTaskFn function) {
PARTHENON_REQUIRE(!name.empty(), "User source task names cannot be empty");
PARTHENON_REQUIRE(function != nullptr, "Cannot register a null user source task");
for (const auto &task : user_source_tasks) {
PARTHENON_REQUIRE(task.name != name, "Duplicate user source task name: " + name);
}
user_source_tasks.push_back({name, std::move(function)});
}

//----------------------------------------------------------------------------------------
//! \fn void Artemis::ClearUserSourceTasks
//! \brief Clears source tasks registered by a previous problem modifier
void ClearUserSourceTasks() { user_source_tasks.clear(); }

//----------------------------------------------------------------------------------------
//! \fn const std::vector<UserSourceTask> &Artemis::GetUserSourceTasks
//! \brief Returns problem-generator source tasks in registration order
const std::vector<UserSourceTask> &GetUserSourceTasks() { return user_source_tasks; }

//----------------------------------------------------------------------------------------
//! \fn Packages_t Artemis::ProcessPackages
//! \brief Process and initialize relevant packages
Expand Down
16 changes: 16 additions & 0 deletions src/artemis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
// 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.
//========================================================================================

// This file was created in part by generative AI
#ifndef ARTEMIS_ARTEMIS_HPP_
#define ARTEMIS_ARTEMIS_HPP_

// C++ includes
#include <functional>
#include <limits>
#include <string>
#include <vector>

// Parthenon includes
#include <parthenon/driver.hpp>
Expand Down Expand Up @@ -235,6 +239,18 @@ inline int ProblemDimension(parthenon::ParameterInput *pin) {
// Custom AMR criteria
namespace artemis {
extern std::function<AmrTag(MeshBlockData<Real> *mbd)> ProblemCheckRefinementBlock;

using UserSourceTaskFn =
std::function<TaskStatus(MeshData<Real> *md, const Real time, const Real dt)>;

struct UserSourceTask {
std::string name;
UserSourceTaskFn function;
};

void RegisterUserSourceTask(const std::string &name, UserSourceTaskFn function);
void ClearUserSourceTasks();
const std::vector<UserSourceTask> &GetUserSourceTasks();
} // namespace artemis

#endif // ARTEMIS_ARTEMIS_HPP_
12 changes: 10 additions & 2 deletions src/artemis_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// the public, perform publicly and display publicly, and to permit others to do so.
//========================================================================================

// This file was created in part by generative AI

// NOTE(PDM): The following is largely borrowed from the open-source LANL phoebus
// software, with additional extensions motivated by other downstream development.

Expand Down Expand Up @@ -324,11 +326,17 @@ TaskCollection ArtemisDriver<GEOM>::StepTasks() {
tl.AddTask(rt_src, RotatingFrame::RotatingFrameForce, u0.get(), time, bdt);
}

// Apply problem-generator source terms in registration order
TaskID user_src = rframe_src;
for (const auto &task : GetUserSourceTasks()) {
user_src = tl.AddTask(user_src, task.name, task.function, u0.get(), time, bdt);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know you could pass names to tasks

}

// Apply drag source term
// NOTE(@pdmullen): RK integrated, operator split drag (RHS computed from U)
TaskID drag_src = rframe_src;
TaskID drag_src = user_src;
if (do_drag) {
drag_src = tl.AddTask(rframe_src, Drag::DragSource<GEOM>, u0.get(), time, bdt);
drag_src = tl.AddTask(user_src, Drag::DragSource<GEOM>, u0.get(), time, bdt);
}

// Apply cooling source term
Expand Down
Loading
Loading