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

Add ADM Mass / Spin and Extrapolation to Infinity #121

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions Examples/BinaryBH/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ modes = 2 0 # l m for spherical harmonics
4 3
4 4

extraction_extrapolation_order = 3
extraction_extrapolation_radii = 0 1 2
Comment on lines +183 to +184
Copy link
Member

Choose a reason for hiding this comment

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

Can't extrapolate Weyl4 as time is not retarded.


# integral_file_prefix = "Weyl4_mode_"

# write_extraction = 0
Expand Down
7 changes: 6 additions & 1 deletion Examples/KerrBH/DiagnosticVariables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ enum
c_Mom2,
c_Mom3,

c_Madm,
c_Jadm,

NUM_DIAGNOSTIC_VARS
};

Expand All @@ -23,7 +26,9 @@ namespace DiagnosticVariables
static const std::array<std::string, NUM_DIAGNOSTIC_VARS> variable_names = {
"Ham",

"Mom1", "Mom2", "Mom3"};
"Mom1", "Mom2", "Mom3",

"M_adm", "J_adm"};
}

#endif /* DIAGNOSTICVARIABLES_HPP */
47 changes: 42 additions & 5 deletions Examples/KerrBH/KerrBHLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "KerrBHLevel.hpp"
#include "BoxLoops.hpp"
#include "CCZ4RHS.hpp"
#include "ChiTaggingCriterion.hpp"
#include "ChiExtractionTaggingCriterion.hpp"
#include "ComputePack.hpp"
#include "KerrBHLevel.hpp"
#include "NanCheck.hpp"
Expand All @@ -20,6 +20,9 @@
#include "GammaCalculator.hpp"
#include "KerrBH.hpp"

#include "ADMQuantities.hpp"
#include "ADMQuantitiesExtraction.hpp"

void KerrBHLevel::specificAdvance()
{
// Enforce the trace free A_ij condition and positive chi and alpha
Expand All @@ -38,9 +41,9 @@ void KerrBHLevel::initialData()
if (m_verbosity)
pout() << "KerrBHLevel::initialData " << m_level << endl;

// First set everything to zero then calculate initial data Get the Kerr
// solution in the variables, then calculate the \tilde\Gamma^i numerically
// as these are non zero and not calculated in the Kerr ICs
// First set everything to zero then calculate initial data
// Get the Kerr solution in the variables, then calculate the \tilde\Gamma^i
// numerically as these are non zero and not calculated in the Kerr ICs
BoxLoops::loop(
make_compute_pack(SetValue(0.), KerrBH(m_p.kerr_params, m_dx)),
m_state_new, m_state_new, INCLUDE_GHOST_CELLS);
Expand Down Expand Up @@ -97,5 +100,39 @@ void KerrBHLevel::preTagCells()
void KerrBHLevel::computeTaggingCriterion(FArrayBox &tagging_criterion,
const FArrayBox &current_state)
{
BoxLoops::loop(ChiTaggingCriterion(m_dx), current_state, tagging_criterion);
BoxLoops::loop(ChiExtractionTaggingCriterion(m_dx, m_level, m_p.max_level,
m_p.extraction_params,
m_p.activate_extraction),
current_state, tagging_criterion);
}

void KerrBHLevel::specificPostTimeStep()
{
CH_TIME("KerrBHLevel::specificPostTimeStep");
// Do the extraction on the min extraction level
if (m_p.activate_extraction == 1)
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure you corrected this elsewhere.

Suggested change
if (m_p.activate_extraction == 1)
if (m_p.activate_extraction)

{
int min_level = m_p.extraction_params.min_extraction_level();
bool calculate_adm = at_level_timestep_multiple(min_level);
if (calculate_adm)
{
// Populate the ADM Mass and Spin values on the grid
fillAllGhosts();
BoxLoops::loop(ADMQuantities(m_p.extraction_params.center, m_dx,
c_Madm, c_Jadm),
m_state_new, m_state_diagnostics,
EXCLUDE_GHOST_CELLS);

if (m_level == min_level)
{
CH_TIME("ADMExtraction");
// Now refresh the interpolator and do the interpolation
m_gr_amr.m_interpolator->refresh();
ADMQuantitiesExtraction my_extraction(
m_p.extraction_params, m_dt, m_time, m_restart_time, c_Madm,
c_Jadm);
my_extraction.execute_query(m_gr_amr.m_interpolator);
}
}
}
}
3 changes: 3 additions & 0 deletions Examples/KerrBH/KerrBHLevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class KerrBHLevel : public GRAMRLevel
/// Things to do before tagging cells (i.e. filling ghosts)
virtual void preTagCells() override;

// to do post each time step on every level
virtual void specificPostTimeStep() override;

virtual void
computeTaggingCriterion(FArrayBox &tagging_criterion,
const FArrayBox &current_state) override;
Expand Down
10 changes: 10 additions & 0 deletions Examples/KerrBH/Main_KerrBH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ int runGRChombo(int argc, char *argv[])
DefaultLevelFactory<KerrBHLevel> kerr_bh_level_fact(gr_amr, sim_params);
setupAMRObject(gr_amr, kerr_bh_level_fact);

// Set up interpolator:
// call this after amr object setup so grids known
// and need it to stay in scope throughout run
// Note: 'interpolator' needs to be in scope when gr_amr.run() is called,
// otherwise pointer is lost
AMRInterpolator<Lagrange<4>> interpolator(
gr_amr, sim_params.origin, sim_params.dx, sim_params.boundary_params,
sim_params.verbosity);
gr_amr.set_interpolator(&interpolator);

using Clock = std::chrono::steady_clock;
using Minutes = std::chrono::duration<double, std::ratio<60, 1>>;

Expand Down
3 changes: 3 additions & 0 deletions Examples/KerrBH/SimulationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class SimulationParameters : public SimulationParametersBase
pp.load("kerr_mass", kerr_params.mass);
pp.load("kerr_spin", kerr_params.spin);
pp.load("kerr_center", kerr_params.center, center);

pp.load("activate_extraction", activate_extraction, false);
Copy link
Member

Choose a reason for hiding this comment

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

Might as well use the one in SimulationParametersBase

}

void check_params()
Expand All @@ -51,6 +53,7 @@ class SimulationParameters : public SimulationParametersBase
}

KerrBH::params_t kerr_params;
bool activate_extraction;
Copy link
Member

Choose a reason for hiding this comment

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

(as above)

};

#endif /* SIMULATIONPARAMETERS_HPP_ */
23 changes: 23 additions & 0 deletions Examples/KerrBH/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
0 1 2 3 #Theta and Gamma
0 1 2 3 1 2 3 #lapse shift and B
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom
0 0 #ADM M and J

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
Expand Down Expand Up @@ -144,4 +145,26 @@ sigma = 0.3
# min_lapse = 1.e-4

#################################################
# Extraction parameters

# extraction_center = 256 256 256 # defaults to center
activate_extraction = 1
num_extraction_radii = 3
extraction_radii = 30. 40. 50.
extraction_levels = 2 1 0
num_points_phi = 50
num_points_theta = 51
# num_modes = 3
# modes = 2 0 # l m for spherical harmonics
# 2 1
# 2 2

# integral_file_prefix = "Weyl4_mode_"

Copy link
Member

Choose a reason for hiding this comment

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

Can you add the extrapolation parameters here (even if just commented out)?

# write_extraction = 0
# extraction_subpath = "data/extraction" # directory for 'write_extraction = 1'
# extraction_file_prefix = "Weyl4_extraction_"

#################################################


29 changes: 28 additions & 1 deletion Examples/KerrBH/params_cheap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
0 1 2 3 #Theta and Gamma
0 1 2 3 1 2 3 #lapse shift and B
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom
0 0 #ADM M and J

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
Expand All @@ -118,7 +119,7 @@ max_steps = 4
# Spatial derivative order (only affects CCZ4 RHS)
max_spatial_derivative_order = 4 # can be 4 or 6

nan_check = 1
# nan_check = 1
Copy link
Member

Choose a reason for hiding this comment

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

Why?


# Lapse evolution
lapse_advec_coeff = 1.0
Expand All @@ -144,3 +145,29 @@ sigma = 0.3
# min_lapse = 1.e-4

#################################################
# Extraction parameters

# extraction_center = 256 256 256 # defaults to center
activate_extraction = 1
num_extraction_radii = 3
extraction_radii = 30. 40. 50.
extraction_levels = 1 1 0
num_points_phi = 50
num_points_theta = 51
# num_modes = 3
# modes = 2 0 # l m for spherical harmonics
# 2 1
# 2 2

extraction_extrapolation_order = 3
extraction_extrapolation_radii = 0 1 2

# integral_file_prefix = "Weyl4_mode_"

# write_extraction = 0
# extraction_subpath = "data/extraction" # directory for 'write_extraction = 1'
# extraction_file_prefix = "Weyl4_extraction_"

#################################################


16 changes: 13 additions & 3 deletions Source/AMRInterpolator/SurfaceExtraction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,25 @@ template <class SurfaceGeometry> class SurfaceExtraction
std::string data_path, integral_file_prefix;
std::string extraction_path, extraction_file_prefix;

std::vector<int>
radii_idxs_for_extrapolation; // 2 for 2nd order, 3 for 3rd order

int min_extraction_level()
{
return *(std::min_element(extraction_levels.begin(),
extraction_levels.end()));
}

//! deletes invalid or repeated
void validate_extrapolation_radii();
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this via parameter checking instead? This will make it more transparent to the user.

};

using vars_t = std::tuple<int, VariableType, Derivative>;

protected:
const SurfaceGeometry m_geom; //!< the geometry class which knows about
//!< the particular surface
const params_t m_params;
params_t m_params;
Copy link
Member

Choose a reason for hiding this comment

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

This can be made const again after the changes I suggested elsewhere are implemented.

std::vector<std::tuple<int, VariableType, Derivative>>
m_vars; //!< the vector of pairs of
//!< variables and derivatives to extract
Expand Down Expand Up @@ -189,8 +195,12 @@ template <class SurfaceGeometry> class SurfaceExtraction
//! convenience caller for write_integrals in the case of just integral per
//! surface
void write_integral(const std::string &a_filename,
const std::vector<double> a_integrals,
const std::string a_label = "") const;
const std::vector<double> &a_integrals,
const std::string &a_label = "") const;

// returns empty vector if no extrapolation is done
std::vector<double> richardson_extrapolation(
const std::vector<std::vector<double>> &integrals) const;
Comment on lines +202 to +203
Copy link
Member

Choose a reason for hiding this comment

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

I think it's slightly odd that this function returns an empty vector in the case of no extrapolation. It would be better if it was only called if there is extrapolation that needs to be done.

};

#include "SurfaceExtraction.impl.hpp"
Expand Down
Loading