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

Bugfix/integral symmetry factor #256

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ba1bfd9
Added symmetry correction flag and symmetry factor variable
the-florist Aug 31, 2024
cbd4298
Added symmetry correction flag to all params in all Examples
the-florist Aug 31, 2024
4c790f6
Adding params changes, so I can bugfix separately
the-florist Aug 31, 2024
62fab66
Bug fixes to symmetry factor implementation
the-florist Sep 1, 2024
4aef8c9
Trying to add symmetry factor from GRAMR but I think I need to start …
the-florist Sep 3, 2024
e7d64cd
Symmetry factor implementation in GRAMR
the-florist Sep 8, 2024
ea2bb8d
Merge branch 'bugfix/integral-symm-factor-try-2' into bugfix/integral…
the-florist Sep 8, 2024
b40f45f
Merge branch 'bugfix/integral-symm-factor-try-2' into bugfix/integral…
the-florist Sep 8, 2024
f9fa5f3
Merge branch 'bugfix/integral-symmetry-factor' of https://github.com/…
the-florist Sep 8, 2024
cd53124
Removed symmetry argument from uses of AMRReductions
the-florist Sep 8, 2024
ae197d4
Fixed clang tidy warnings
the-florist Sep 8, 2024
1eb4cd3
Fixed clang tidy warnings
the-florist Sep 8, 2024
dd57179
Merge branch 'bugfix/integral-symmetry-factor' of https://github.com/…
the-florist Sep 8, 2024
d6808dc
Clang formatting changes, after running clang-format locally
the-florist Sep 9, 2024
d01cdf7
Fixed typo on line 40 of BoundaryConditions.cpp
the-florist Sep 9, 2024
8bbb859
Added default to the symmetry_correction flag
the-florist Sep 9, 2024
5b6c063
Symmetry factor implementation
the-florist Sep 9, 2024
a4e72e0
Pre-pull commit
the-florist Sep 9, 2024
327021d
AH-solver-bug
the-florist Sep 9, 2024
0bee0fa
Removal of old Chombo Parameter function argument from AMRReductions …
the-florist Sep 10, 2024
634240c
Fixed Katy's comments on PR
the-florist Oct 14, 2024
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
5 changes: 5 additions & 0 deletions Examples/BinaryBH/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom
0 7 #Weyl

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down
5 changes: 5 additions & 0 deletions Examples/BinaryBH/params_two_punctures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom
0 7 #Weyl

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down
22 changes: 14 additions & 8 deletions Examples/BinaryBH/params_very_cheap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
verbosity = 0

# location / naming of output files
# output_path = "" # Main path for all files. Must exist!
output_path = "/nfs/st01/hpc-gr-epss/eaf49/PR-dump" # Main path for all files. Must exist!
Copy link
Member

Choose a reason for hiding this comment

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

Your output path sneaked in here :-)

chk_prefix = BinaryBHChk_
plot_prefix = BinaryBHPlot_
# restart_file = BinaryBHChk_000360.3d.hdf5
Expand Down Expand Up @@ -108,6 +108,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom
0 7 #Weyl

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
Copy link
Member

Choose a reason for hiding this comment

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

As per comment below, I think we could remove all of these and have it always on.

symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down Expand Up @@ -155,7 +160,7 @@ sigma = 0.3
track_punctures = 1
puncture_tracking_level = 1

# calculate_constraint_norms = 0
calculate_constraint_norms = 1

# min_chi = 1.e-4
# min_lapse = 1.e-4
Expand Down Expand Up @@ -183,14 +188,15 @@ modes = 2 0 # l m for spherical harmonics
#################################################
# Apparent Horizon Finder parameters

AH_activate = 1
AH_num_ranks = 4
AH_num_points_u = 11
AH_num_points_v = 10
AH_solve_interval = 2
AH_print_interval = 2
AH_activate = 0
AH_num_ranks = 65
AH_num_points_u = 65
AH_num_points_v = 48
# AH_solve_interval = 2
# AH_print_interval = 2
# AH_merger_search_factor = 1.
# AH_merger_pre_factor = 1.
AH_set_origins_to_punctures = 1

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

5 changes: 5 additions & 0 deletions Examples/KerrBH/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
0 1 2 3 1 2 3 #lapse shift and B
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down
5 changes: 5 additions & 0 deletions Examples/KerrBH/params_cheap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
0 1 2 3 1 2 3 #lapse shift and B
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down
5 changes: 5 additions & 0 deletions Examples/ScalarField/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ vars_parity = 0 0 4 6 0 5 0 #chi and hij
0 0 #phi and Pi
vars_parity_diagnostic = 0 1 2 3 #Ham and Mom

# Additionally, if reflective boundaries selected,
# choose if symmetry factor will be applied to integrals.
# 0 = false (default), 1 = true
symmetry_correction = 1

# if sommerfeld boundaries selected, must select
# non zero asymptotic values
num_nonzero_asymptotic_vars = 5
Expand Down
1 change: 1 addition & 0 deletions Source/BoxUtils/AMRReductions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ template <VariableType var_t> class AMRReductions
double m_domain_volume;
Vector<LevelData<FArrayBox> *> m_level_data_ptrs;
Vector<int> m_ref_ratios;
const int m_symmetry_factor;

//! constructs a Vector of LevelData<FArrayBox> pointers and stores them
void set_level_data_vect(const GRAMR &a_gramr);
Expand Down
8 changes: 5 additions & 3 deletions Source/BoxUtils/AMRReductions.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ template <VariableType var_t>
AMRReductions<var_t>::AMRReductions(const GRAMR &a_gramr,
const int a_base_level)
: m_base_level(a_base_level),
m_coarsest_dx(a_gramr.get_gramrlevels()[0]->get_dx())
m_coarsest_dx(a_gramr.get_gramrlevels()[0]->get_dx()),
m_symmetry_factor(a_gramr.get_gramrlevels()[0]->get_symm())
{
set_level_data_vect(a_gramr);
set_ref_ratios_vect(a_gramr);
Expand Down Expand Up @@ -109,7 +110,7 @@ Real AMRReductions<var_t>::norm(const Interval &a_vars,
pow(m_domain_volume, 1.0 / static_cast<double>(a_norm_exponent));
}

return norm;
return norm * static_cast<double>(m_symmetry_factor);
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 this needs to take account of the value of a_normalize_by_volume - if that is true then we don't need to scale the norm, as it is a per volume measure. In the case where that is false then this is correct.

}

template <VariableType var_t>
Expand All @@ -125,7 +126,8 @@ Real AMRReductions<var_t>::sum(const Interval &a_vars) const
CH_assert(a_vars.begin() >= 0 && a_vars.end() < m_num_vars);
CH_TIME("AMRReductions::sum");
return computeSum(m_level_data_ptrs, m_ref_ratios, m_coarsest_dx, a_vars,
m_base_level);
m_base_level) *
static_cast<double>(m_symmetry_factor);
}

template <VariableType var_t>
Expand Down
19 changes: 19 additions & 0 deletions Source/GRChomboCore/BoundaryConditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ BoundaryConditions::params_t::params_t()
vars_parity_diagnostic.fill(BoundaryConditions::EXTRAPOLATING_BC);
vars_asymptotic_values.fill(0.0);
extrapolation_order = 1;
symmetry_factor = 1;
}

void BoundaryConditions::params_t::set_is_periodic(
Expand Down Expand Up @@ -141,6 +142,23 @@ void BoundaryConditions::params_t::read_params(GRParmParse &pp)

if (reflective_boundaries_exist)
{
int symmetry_correction = 0;
pp.load("symmetry_correction", symmetry_correction, 0);
Copy link
Member

Choose a reason for hiding this comment

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

I would actually be tempted just to remove the symmetry_correction variable, and always work out this symmetry factor. I can't imagine going forward that someone will not want to use it. This also means we don't need to change all the params files for another variable that people will just ignore or find confusing.

Copy link
Member

Choose a reason for hiding this comment

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

(Also just for reference from a code convention perspective it should be a bool called uses_symmetry_correction or something like that)

if (symmetry_correction != 0)
{
for (int d = 0; d < CH_SPACEDIM; d++)
{
if (lo_boundary[d] == 2)
{
symmetry_factor *= 2;
}
else if (hi_boundary[d] == 2)
{
symmetry_factor *= 2;
}
}
}

pp.load("vars_parity", vars_parity);
if (pp.contains("vars_parity_diagnostic"))
pp.load("vars_parity_diagnostic", vars_parity_diagnostic);
Expand Down Expand Up @@ -215,6 +233,7 @@ void BoundaryConditions::define(double a_dx,
{
m_dx = a_dx;
m_params = a_params;
m_symmetry_factor = a_params.symmetry_factor;
m_domain = a_domain;
m_domain_box = a_domain.domainBox();
m_num_ghosts = a_num_ghosts;
Expand Down
4 changes: 4 additions & 0 deletions Source/GRChomboCore/BoundaryConditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class BoundaryConditions
bool sommerfeld_boundaries_exist;
bool extrapolating_boundaries_exist;
bool mixed_boundaries_exist;
int symmetry_factor;

std::array<int, NUM_VARS> vars_parity;
std::array<int, NUM_DIAGNOSTIC_VARS>
Expand All @@ -97,11 +98,14 @@ class BoundaryConditions
ProblemDomain m_domain; // the problem domain (excludes boundary cells)
Box m_domain_box; // The box representing the domain
bool is_defined; // whether the BoundaryConditions class members are defined
int m_symmetry_factor;

public:
/// Default constructor - need to call define afterwards
BoundaryConditions() { is_defined = false; }

int get_symm() const { return m_symmetry_factor; }
Copy link
Member

Choose a reason for hiding this comment

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

Abbreviated names are against our conventions :-) Amend to get_symmetry_factor()


/// define function sets members and is_defined set to true
void define(double a_dx, std::array<double, CH_SPACEDIM> a_center,
const params_t &a_params, ProblemDomain a_domain,
Expand Down
4 changes: 4 additions & 0 deletions Source/GRChomboCore/GRAMRLevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class GRAMRLevel : public AMRLevel, public InterpSource<>

// direction irrelevant, but relevant for InterpSource
ALWAYS_INLINE double get_dx(int dir = 0) const { return m_dx; };
ALWAYS_INLINE int get_symm(int dir = 0) const
Copy link
Member

Choose a reason for hiding this comment

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

Ditto - no abbreviation here.

{
return m_boundaries.get_symm();
}

/// Returns true if m_time is the same as the time at the end of the current
/// timestep on level a_level and false otherwise
Expand Down
2 changes: 2 additions & 0 deletions Tests/AMRInterpolatorTest/AMRInterpolatorTest.inputs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ lo_boundary = 2 0 2
# 1,2,3 = odd x, y, z
# 4,5,6 = odd xy, yz, xz
vars_parity = 0 1 # A and B

symmetry_correction = 0
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ lo_boundary = 1 2
vars_parity = 2 # V
vars_asymptotic_values = 0. # V

symmetry_correction = 0

#Max and min box sizes
max_grid_size = 32
block_factor = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ vars_asymptotic_values = 1. 1. 0. 0. 1. 0. 1. #chi and hij
1. 0. 0. 0. 0. 0. 0. #lapse shift and B
0. 0. 0. 0. # Ham and Mom

symmetry_correction = 0

#Max and min box sizes
max_grid_size = 32
block_factor = 16
Expand Down
1 change: 1 addition & 0 deletions run_clang_format
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
for f in $(find . -name "*.hpp"); do clang-format -style=file -i $f; done
for f in $(find . -name "*.cpp"); do clang-format -style=file -i $f; done