Skip to content

Commit

Permalink
Separate extraction and excision; move volume extraction params to Fi…
Browse files Browse the repository at this point in the history
…xedBGSimulationParametersBase.hpp
  • Loading branch information
dinatraykova committed Jan 20, 2025
1 parent 907b725 commit fe30805
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 46 deletions.
16 changes: 12 additions & 4 deletions Examples/BoostedBHComplexScalar/BoostedBHScalarLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ void BoostedBHScalarLevel::specificPostTimeStep()
disable_simd());

// At any level, but after the timestep on the minimum extraction level
int min_level = 0.;
int min_level = 0;
if (m_p.activate_extraction == 1)
min_level = m_p.extraction_params.min_extraction_level();

bool calculate_diagnostics = at_level_timestep_multiple(min_level);
if (calculate_diagnostics)
{
Expand All @@ -80,7 +83,7 @@ void BoostedBHScalarLevel::specificPostTimeStep()
m_state_diagnostics, SKIP_GHOST_CELLS);

// excise within/outside specified radii, no simd
if (m_p.activate_extraction == 1)
if (m_p.activate_excision == 1)
{
BoxLoops::loop(
ExcisionDiagnostics<ScalarFieldWithPotential, BoostedBH>(
Expand All @@ -91,9 +94,8 @@ void BoostedBHScalarLevel::specificPostTimeStep()
}

// write out the integral after each timestep on the min_level
if (m_p.activate_extraction == 1)
if (m_p.activate_excision == 1)
{
min_level = m_p.extraction_params.min_extraction_level();
if (m_level == min_level)
{
bool first_step = (m_time == m_dt);
Expand All @@ -120,7 +122,13 @@ void BoostedBHScalarLevel::specificPostTimeStep()
"Lin. Mom. source"});
}
integral_file.write_time_data_line(data_for_writing);
}
}

if (m_p.activate_extraction == 1)
{
if (m_level == min_level)
{
// Now refresh the interpolator and do the interpolation
// only fill the actual ghost cells needed to save time
bool fill_ghosts = false;
Expand Down
18 changes: 0 additions & 18 deletions Examples/BoostedBHComplexScalar/SimulationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class SimulationParameters : public FixedBGSimulationParametersBase
pp.load("bh_mass", bg_params.mass, 1.0);
pp.load("bh_velocity", bg_params.velocity, 0.0);
pp.load("bh_center", bg_params.center, center);

// Volume extraction radii
if (activate_extraction)
{
pp.load("inner_r", inner_r, extraction_params.extraction_radii[0]);
pp.load("outer_r", outer_r, extraction_params.extraction_radii[1]);
}
}

void check_params()
Expand All @@ -49,15 +42,6 @@ class SimulationParameters : public FixedBGSimulationParametersBase
initial_params.mass < 0.2 / coarsest_dx / dt_multiplier,
"oscillations of scalar field do not appear to be "
"resolved on coarsest level");
if (activate_extraction)
{
warn_parameter("inner_r", inner_r,
extraction_params.extraction_radii[0] == inner_r,
"should be equal to first extraction radius");
warn_parameter("outer_r", outer_r,
extraction_params.extraction_radii[1] == outer_r,
"should be equal to second extraction radius");
}
warn_parameter("bh_mass", bg_params.mass, bg_params.mass >= 0.0,
"should be >= 0.0");
FOR(idir)
Expand All @@ -71,8 +55,6 @@ class SimulationParameters : public FixedBGSimulationParametersBase
}
}

// Problem specific parameters - the radii for the integrations
double inner_r, outer_r;
// Collection of parameters necessary for the initial conditions
InitialScalarData::params_t initial_params;
// Collection of parameters necessary for the metric background
Expand Down
2 changes: 2 additions & 0 deletions Examples/BoostedBHComplexScalar/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ num_points_phi = 36
num_points_theta = 24

# For volume integrals
# Default value is the same as activate_extraction
# activate_excision = 1
# By default these are set to the values of the extraction radii above
# inner_r = 3.0
# outer_r = 200.0
Expand Down
15 changes: 12 additions & 3 deletions Examples/KerrBHScalarField/KerrBHScalarLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ void KerrBHScalarLevel::specificPostTimeStep()

// At any level, but after the min_level timestep
int min_level = 0.;
if (m_p.activate_extraction == 1)
min_level = m_p.extraction_params.min_extraction_level();

bool calculate_diagnostics = at_level_timestep_multiple(min_level);
if (calculate_diagnostics)
{
Expand All @@ -94,7 +97,7 @@ void KerrBHScalarLevel::specificPostTimeStep()
m_state_diagnostics, SKIP_GHOST_CELLS);

// excise within/outside specified radii, no simd
if (m_p.activate_extraction == 1)
if (m_p.activate_excision == 1)
{
BoxLoops::loop(
ExcisionDiagnostics<ScalarFieldWithPotential, KerrSchild>(
Expand All @@ -105,9 +108,8 @@ void KerrBHScalarLevel::specificPostTimeStep()
}

// write out the integral after each timestep on minimum level
if (m_p.activate_extraction == 1)
if (m_p.activate_excision == 1)
{
min_level = m_p.extraction_params.min_extraction_level();
if (m_level == min_level)
{
bool first_step = (m_time == m_dt);
Expand All @@ -132,8 +134,15 @@ void KerrBHScalarLevel::specificPostTimeStep()
{"Energy density", "Ang. Mom. density"});
}
integral_file.write_time_data_line(data_for_writing);
}
}

if (m_p.activate_extraction == 1)
{
if (m_level == min_level)
{
// Now refresh the interpolator and do the interpolation
// only fill the actual ghost cells needed to save time
bool fill_ghosts = false;
m_gr_amr.m_interpolator->refresh(fill_ghosts);
m_gr_amr.fill_multilevel_ghosts(
Expand Down
19 changes: 1 addition & 18 deletions Examples/KerrBHScalarField/SimulationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ class SimulationParameters : public FixedBGSimulationParametersBase
pp.load("bh_mass", bg_params.mass, 1.0);
pp.load("bh_spin", bg_params.spin, 0.0);
pp.load("bh_center", bg_params.center, center);

// Volume extraction radii
if (activate_extraction)
{
pp.load("inner_r", inner_r, extraction_params.extraction_radii[0]);
pp.load("outer_r", outer_r, extraction_params.extraction_radii[1]);
}
}

void check_params()
Expand All @@ -53,15 +46,7 @@ class SimulationParameters : public FixedBGSimulationParametersBase
"resolved on coarsest level");
warn_parameter("bh_mass", bg_params.mass, bg_params.mass >= 0.0,
"should be >= 0.0");
if (activate_extraction)
{
warn_parameter("inner_r", inner_r,
extraction_params.extraction_radii[0] == inner_r,
"should be equal to first extraction radius");
warn_parameter("outer_r", outer_r,
extraction_params.extraction_radii[1] == outer_r,
"should be equal to second extraction radius");
}

check_parameter("bh_spin", bg_params.spin,
std::abs(bg_params.spin) <= bg_params.mass,
"must satisfy |a| <= M = " +
Expand All @@ -77,8 +62,6 @@ class SimulationParameters : public FixedBGSimulationParametersBase
}
}

// Problem specific parameters
double inner_r, outer_r;
// Collection of parameters necessary for the initial conditions
InitialScalarData::params_t initial_params;
// Collection of parameters necessary for the background metric
Expand Down
4 changes: 3 additions & 1 deletion Examples/KerrBHScalarField/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ num_points_phi = 36
num_points_theta = 24

# For volume integrals
# defaulted to extraction radii values above
# Default value is the same as activate_extraction
# activate_excision = 1
# By default these are set to the values of the extraction radii above
# inner_r = 7.0
# outer_r = 110.0

Expand Down
33 changes: 31 additions & 2 deletions Source/Background/FixedBGSimulationParametersBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class FixedBGSimulationParametersBase : public ChomboParameters
FilesystemTools::mkdir_recursive(data_path);

// Extraction params
pp.load("activate_extraction", activate_extraction, false);
pp.load("activate_extraction", activate_extraction, true);
pp.load("activate_excision", activate_excision, activate_extraction);

if (activate_extraction)
{
Expand Down Expand Up @@ -98,6 +99,23 @@ class FixedBGSimulationParametersBase : public ChomboParameters
pp.load("write_extraction", extraction_params.write_extraction,
false);
}

// For volume extraction and excision of diagnostic variables
if (activate_excision)
{
if (activate_extraction)
{
pp.load("inner_r", inner_r,
extraction_params.extraction_radii[0]);
pp.load("outer_r", outer_r,
extraction_params.extraction_radii[1]);
}
else
{
pp.load("inner_r", inner_r, 3.);
pp.load("outer_r", outer_r, L / 4.);
}
}
}

void check_params()
Expand Down Expand Up @@ -161,15 +179,26 @@ class FixedBGSimulationParametersBase : public ChomboParameters
"l must be >= 2 and m must satisfy -l <= m <= l");
}
}

if (activate_extraction && activate_excision)
{
warn_parameter("inner_r", inner_r,
extraction_params.extraction_radii[0] == inner_r,
"should be equal to first extraction radius");
warn_parameter("outer_r", outer_r,
extraction_params.extraction_radii[1] == outer_r,
"should be equal to second extraction radius");
}
}

public:
double sigma; // Kreiss-Oliger dissipation parameter
int nan_check;

// Collection of parameters necessary for the extraction
bool activate_extraction;
bool activate_extraction, activate_excision;
spherical_extraction_params_t extraction_params;
double inner_r, outer_r;

std::string data_path;
};
Expand Down

0 comments on commit fe30805

Please sign in to comment.