Skip to content

Commit

Permalink
Fix spectre BBH ID (#603)
Browse files Browse the repository at this point in the history
* Fix spectre BBH ID

* Add timer to interpolation

* fix lint

---------

Co-authored-by: Hengrui Zhu <[email protected]>
  • Loading branch information
nilsvu and HengruiZhu99 authored Jan 22, 2025
1 parent 27d2874 commit 98b0285
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions inputs/z4c/spectre_bbh/z4c_spectre_bbh.athinput
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ basename = bbh # problem ID: basename of output filenames

<problem>
pgen_name = z4c_spectre_bbh
id_filename_glob = BbhVolume*.h5
id_filename_glob = /home/nilsvu/2024-09-bbh-athenak/ID/BbhVolume*.h5
id_subfile_name = VolumeData
id_observation_step = -1

Expand Down Expand Up @@ -41,7 +41,7 @@ integrator = rk4 # time integration algorithm
cfl_number = 0.1 # The Courant, Friedrichs, & Lewy (CFL) Number
nlim = 50 # cycle limit
tlim = 50 # time limit
ndiag = 1 # cycles between diagostic output
ndiag = 1 # cycles between diagnostic output

<mesh_refinement>
refinement = static #adaptive # type of refinement
Expand All @@ -52,7 +52,7 @@ refinement_interval = 1

# amr chi method
<z4c_amr>
method = chi_min
method = chi
chi_min = 0.2

<refinement1>
Expand Down
10 changes: 7 additions & 3 deletions src/pgen/z4c_spectre_bbh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <Kokkos_Timer.hpp>

#include "athena.hpp"
#include "coordinates/cell_locations.hpp"
Expand All @@ -22,7 +23,6 @@
#include "parameter_input.hpp"
#include "z4c/z4c.hpp"
#include "z4c/z4c_amr.hpp"
#include "z4c/z4c_puncture_tracker.hpp"

#include <spectre/Exporter.hpp>

Expand Down Expand Up @@ -136,6 +136,7 @@ void LoadSpectreInitialData(MeshBlockPack *pmbp, const std::string &filename_glo
x[2].resize(sz);

int nmb = pmbp->nmb_thispack;
Kokkos::Timer timer{};
for (int m = 0; m < nmb; ++m) {
// Get the coordinates for this meshblock
Real &x1min = size.h_view(m).x1min;
Expand All @@ -156,8 +157,9 @@ void LoadSpectreInitialData(MeshBlockPack *pmbp, const std::string &filename_glo
}

// Interpolate data to the coordinates
timer.reset();
std::cout << "Interpolating initial data for meshblock " << m << "/"
<< nmb - 1 << " with " << sz << " points " << std::endl;
<< nmb - 1 << " with " << sz << " points..." << std::endl;
const auto data = spectre::Exporter::interpolate_to_points<3>(
filename_glob, subfile_name, spectre::Exporter::ObservationStep{observation_step},
{"SpatialMetric_xx", "SpatialMetric_yx", "SpatialMetric_yy",
Expand All @@ -166,6 +168,8 @@ void LoadSpectreInitialData(MeshBlockPack *pmbp, const std::string &filename_glo
"ExtrinsicCurvature_zx", "ExtrinsicCurvature_zy", "ExtrinsicCurvature_zz"},
/* target_points */ x,
/* extrapolate_into_excisions */ true);
std::cout << " done in " << timer.seconds() << " seconds." << std::endl;

const auto &gxx = data[0];
const auto &gyx = data[1];
const auto &gyy = data[2];
Expand Down Expand Up @@ -218,5 +222,5 @@ void LoadSpectreInitialData(MeshBlockPack *pmbp, const std::string &filename_glo
}

void RefinementCondition(MeshBlockPack *pmbp) {
pmbp->pz4c->pz4c_amr->Refine(pmbp);
pmbp->pz4c->pamr->Refine(pmbp);
}

0 comments on commit 98b0285

Please sign in to comment.