Skip to content

Commit

Permalink
Merge pull request #242 from lucass-carneiro/main
Browse files Browse the repository at this point in the history
Moving boxes example thorn
  • Loading branch information
eschnett authored Oct 26, 2023
2 parents 9122a5e + b9ed1b1 commit afb1a5d
Show file tree
Hide file tree
Showing 68 changed files with 5,871 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MovingBoxToy/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Cactus Code Thorn MovingBoxToy
Author(s) : Lucas Timotheo Sanches <[email protected]>
Maintainer(s): Lucas Timotheo Sanches <[email protected]>
Licence : LGPL
--------------------------------------------------------------------------

1. Purpose

Show how to create moving refinement boxes
1 change: 1 addition & 0 deletions MovingBoxToy/configuration.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Configuration definitions for thorn MovingBoxToy
5 changes: 5 additions & 0 deletions MovingBoxToy/interface.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Interface definition for thorn MovingBoxToy

IMPLEMENTS: MovingBoxToy

INHERITS: BoxInBox
59 changes: 59 additions & 0 deletions MovingBoxToy/par/circle.par
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ActiveThorns = "
MovingBoxToy
BoxInBox
CarpetX
CoordinatesX
IOUtil
"

Cactus::cctk_show_schedule = no
Cactus::presync_mode = "mixed-error"

CarpetX::poison_undefined_values = yes

CarpetX::ncells_x = 64
CarpetX::ncells_y = 64
CarpetX::ncells_z = 64

CarpetX::dtfac = CarpetX::ncells_x

CarpetX::max_num_levels = 8
CarpetX::regrid_every = 1

BoxInBox::num_regions = 2

BoxInBox::num_levels_1 = 2
BoxInBox::position_x_1 = -0.5
BoxInBox::radius_x_1[1] = 0.25
BoxInBox::radius_y_1[1] = 0.25
BoxInBox::radius_z_1[1] = 0.25

BoxInBox::num_levels_2 = 2
BoxInBox::position_x_2 = +0.5
BoxInBox::radius_x_2[1] = 0.25
BoxInBox::radius_y_2[1] = 0.25
BoxInBox::radius_z_2[1] = 0.25

CarpetX::boundary_x = "dirichlet"
CarpetX::boundary_y = "dirichlet"
CarpetX::boundary_z = "dirichlet"
CarpetX::boundary_upper_x = "dirichlet"
CarpetX::boundary_upper_y = "dirichlet"
CarpetX::boundary_upper_z = "dirichlet"

Cactus::cctk_itlast = 20

IO::out_dir = $parfile
IO::out_every = 1
IO::parfile_write = no

CarpetX::out_metadata = no
CarpetX::out_norm_vars = "all"
CarpetX::out_norm_omit_unstable = yes

CarpetX::out_silo_vars = "
CarpetX::regrid_error
CoordinatesX::vertex_coords
CoordinatesX::cell_coords
"

1 change: 1 addition & 0 deletions MovingBoxToy/param.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Parameter definitions for thorn MovingBoxToy
15 changes: 15 additions & 0 deletions MovingBoxToy/schedule.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Schedule definitions for thorn MovingBoxToy

SCHEDULE MovingBoxToy_MoveBoxes AT postinitial BEFORE EstimateError
{
LANG: C
READS: BoxInBox::positions
WRITES: BoxInBox::positions
} "Update box positions"

SCHEDULE MovingBoxToy_MoveBoxes AT poststep BEFORE EstimateError
{
LANG: C
READS: BoxInBox::positions
WRITES: BoxInBox::positions
} "Update box positions"
7 changes: 7 additions & 0 deletions MovingBoxToy/src/make.code.defn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Main make.code.defn file for thorn MovingBoxToy

# Source files in this directory
SRCS = movingboxtoy.cxx

# Subdirectories containing source files
SUBDIRS =
32 changes: 32 additions & 0 deletions MovingBoxToy/src/movingboxtoy.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <cctk.h>
#include <cctk_Arguments.h>
#include <cctk_Parameters.h>

#include <cmath>

template <typename T>
constexpr auto pow2(T val) noexcept -> T {
return val * val;
}

extern "C" void MovingBoxToy_MoveBoxes(CCTK_ARGUMENTS) {
DECLARE_CCTK_ARGUMENTSX_MovingBoxToy_MoveBoxes;
DECLARE_CCTK_PARAMETERS;

using std::cos;
using std::sqrt;

const CCTK_REAL omega{M_PI/4};

// Radius of each box
const auto R1 = sqrt(pow2(position_x[0]) + pow2(position_y[0]) + pow2(position_z[0]));
const auto R2 = sqrt(pow2(position_x[1]) + pow2(position_y[1]) + pow2(position_z[1]));

// Trajectory of box 1
position_x[0] = R1 * cos(omega * cctk_time);
position_y[0] = R1 * sin(omega * cctk_time);

// Trajectory of box 2
position_x[1] = -R2 * cos(omega * cctk_time);
position_y[1] = -R2 * sin(omega * cctk_time);
}
59 changes: 59 additions & 0 deletions MovingBoxToy/test/circle.par
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ActiveThorns = "
MovingBoxToy
BoxInBox
CarpetX
CoordinatesX
IOUtil
"

Cactus::cctk_show_schedule = no
Cactus::presync_mode = "mixed-error"

CarpetX::poison_undefined_values = yes

CarpetX::ncells_x = 64
CarpetX::ncells_y = 64
CarpetX::ncells_z = 64

CarpetX::dtfac = CarpetX::ncells_x

CarpetX::max_num_levels = 8
CarpetX::regrid_every = 1

BoxInBox::num_regions = 2

BoxInBox::num_levels_1 = 2
BoxInBox::position_x_1 = -0.5
BoxInBox::radius_x_1[1] = 0.25
BoxInBox::radius_y_1[1] = 0.25
BoxInBox::radius_z_1[1] = 0.25

BoxInBox::num_levels_2 = 2
BoxInBox::position_x_2 = +0.5
BoxInBox::radius_x_2[1] = 0.25
BoxInBox::radius_y_2[1] = 0.25
BoxInBox::radius_z_2[1] = 0.25

CarpetX::boundary_x = "dirichlet"
CarpetX::boundary_y = "dirichlet"
CarpetX::boundary_z = "dirichlet"
CarpetX::boundary_upper_x = "dirichlet"
CarpetX::boundary_upper_y = "dirichlet"
CarpetX::boundary_upper_z = "dirichlet"

Cactus::cctk_itlast = 5

IO::out_dir = $parfile
IO::out_every = 1
IO::parfile_write = no

CarpetX::out_metadata = no
CarpetX::out_norm_vars = "all"
CarpetX::out_norm_omit_unstable = yes

CarpetX::out_tsv_vars = "
CarpetX::regrid_error
CoordinatesX::vertex_coords
CoordinatesX::cell_coords
"

Loading

0 comments on commit afb1a5d

Please sign in to comment.