From dfcbca52395b10b3113cb9e6c10739d1ac364c5b Mon Sep 17 00:00:00 2001 From: the-florist Date: Tue, 30 Jul 2024 11:52:35 +0100 Subject: [PATCH] Removed Ham_abs variable (got it mixed up with Ham_abs_terms) --- Examples/ScalarField/ConstraintStatistics.hpp | 10 +++++----- Examples/ScalarField/DiagnosticVariables.hpp | 2 -- Examples/ScalarField/ScalarFieldLevel.cpp | 6 +++--- Source/CCZ4/NewConstraints.hpp | 4 +--- Source/CCZ4/NewConstraints.impl.hpp | 10 +++------- Source/Matter/NewMatterConstraints.hpp | 2 +- Source/Matter/NewMatterConstraints.impl.hpp | 16 ++++++++++++---- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Examples/ScalarField/ConstraintStatistics.hpp b/Examples/ScalarField/ConstraintStatistics.hpp index 99c352874..2d3338f93 100644 --- a/Examples/ScalarField/ConstraintStatistics.hpp +++ b/Examples/ScalarField/ConstraintStatistics.hpp @@ -27,19 +27,19 @@ class ConstraintStatistics CH_TIME("ConstraintStatistics::compute"); data_t Ham = current_cell.load_vars(c_Ham); - data_t HamAbs = current_cell.load_vars(c_Ham_abs); + data_t HamAbs = current_cell.load_vars(c_Ham_abs_terms); data_t HamAbsAAD = abs(HamAbs - m_Ham_abs_mean); data_t HamVar = pow(Ham - m_Ham_mean, 2.); - data_t HamNorm = Ham/m_Ham_abs_mean; - data_t HamNormSq = HamNorm*HamNorm; + data_t HamNorm = Ham/m_Ham_abs_mean; + data_t HamNormSq = HamNorm*HamNorm; data_t Mom = current_cell.load_vars(c_Mom); data_t MomAAD = abs(Mom - m_Mom_mean); //store class (Vars) variables as diagnostic variables on the grid current_cell.store_vars(HamNorm, c_Ham_norm); - current_cell.store_vars(HamNormSq, c_Ham_norm_sq); - current_cell.store_vars(HamVar, c_Ham_var); + current_cell.store_vars(HamNormSq, c_Ham_norm_sq); + current_cell.store_vars(HamVar, c_Ham_var); current_cell.store_vars(HamAbsAAD, c_Ham_abs_AAD); current_cell.store_vars(MomAAD, c_Mom_AAD); } diff --git a/Examples/ScalarField/DiagnosticVariables.hpp b/Examples/ScalarField/DiagnosticVariables.hpp index e1dfb1e99..124051936 100644 --- a/Examples/ScalarField/DiagnosticVariables.hpp +++ b/Examples/ScalarField/DiagnosticVariables.hpp @@ -13,7 +13,6 @@ enum c_ch2, c_Ham, - c_Ham_abs, c_Mom, c_Ham_abs_terms, c_Mom_abs_terms, @@ -34,7 +33,6 @@ static const std::array variable_names = { "ChiSq", "Ham", - "HamAbs", "Mom", "Ham_abs_terms", "Mom_abs_terms", diff --git a/Examples/ScalarField/ScalarFieldLevel.cpp b/Examples/ScalarField/ScalarFieldLevel.cpp index 8db13ad83..8c2d902cd 100644 --- a/Examples/ScalarField/ScalarFieldLevel.cpp +++ b/Examples/ScalarField/ScalarFieldLevel.cpp @@ -106,7 +106,7 @@ void ScalarFieldLevel::prePlotLevel() ScalarFieldWithPotential scalar_field(potential); BoxLoops::loop( MatterConstraints( - scalar_field, m_dx, m_p.G_Newton, c_Ham, c_Ham_abs, Interval(c_Mom, c_Mom), m_p.min_chi, + scalar_field, m_dx, m_p.G_Newton, c_Ham, Interval(c_Mom, c_Mom), m_p.min_chi, c_Ham_abs_terms, Interval(c_Mom_abs_terms, c_Mom_abs_terms)), m_state_new, m_state_diagnostics, EXCLUDE_GHOST_CELLS); } @@ -183,7 +183,7 @@ void ScalarFieldLevel::specificPostTimeStep() ScalarFieldWithPotential scalar_field(potential); BoxLoops::loop( MatterConstraints( - scalar_field, m_dx, m_p.G_Newton, c_Ham, c_Ham_abs, Interval(c_Mom, c_Mom), m_p.min_chi, + scalar_field, m_dx, m_p.G_Newton, c_Ham, Interval(c_Mom, c_Mom), m_p.min_chi, c_Ham_abs_terms, Interval(c_Mom_abs_terms, c_Mom_abs_terms)), m_state_new, m_state_diagnostics, EXCLUDE_GHOST_CELLS); @@ -194,7 +194,7 @@ void ScalarFieldLevel::specificPostTimeStep() double vol = amr_reductions.get_domain_volume(); double hamBar = amr_reductions.sum(c_Ham)/vol; - double hamAbsBar = amr_reductions.sum(c_Ham_abs)/vol; + double hamAbsBar = amr_reductions.sum(c_Ham_abs_terms)/vol; double momBar = amr_reductions.sum(c_Mom)/vol; BoxLoops::loop( diff --git a/Source/CCZ4/NewConstraints.hpp b/Source/CCZ4/NewConstraints.hpp index d56ec9559..ed575ba16 100644 --- a/Source/CCZ4/NewConstraints.hpp +++ b/Source/CCZ4/NewConstraints.hpp @@ -34,7 +34,6 @@ class Constraints template struct Vars { data_t Ham; - data_t Ham_abs; data_t Ham_abs_terms; Tensor<1, data_t> Mom; Tensor<1, data_t> Mom_abs_terms; @@ -47,7 +46,7 @@ class Constraints // conformally decomposed expressions which can be used in to normalize // the constraint violations // Any zero-length Interval or negative var is not calculated - Constraints(double dx, int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms, + Constraints(double dx, int a_c_Ham, const Interval &a_c_Moms, const double a_c_chi_min, int a_c_Ham_abs_terms = -1, const Interval &a_c_Moms_abs_terms = Interval(), @@ -58,7 +57,6 @@ class Constraints protected: const FourthOrderDerivatives m_deriv; const int m_c_Ham; - const int m_c_Ham_abs; const Interval m_c_Moms; const double m_min_chi; const int m_c_Ham_abs_terms = -1; diff --git a/Source/CCZ4/NewConstraints.impl.hpp b/Source/CCZ4/NewConstraints.impl.hpp index 9f24326c0..87557948a 100644 --- a/Source/CCZ4/NewConstraints.impl.hpp +++ b/Source/CCZ4/NewConstraints.impl.hpp @@ -15,12 +15,12 @@ #include "VarsTools.hpp" inline Constraints::Constraints( - double dx, int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms, + double dx, int a_c_Ham, const Interval &a_c_Moms, const double a_c_chi_min, int a_c_Ham_abs_terms /*defaulted*/, const Interval &a_c_Moms_abs_terms /*defaulted*/, double cosmological_constant /*defaulted*/) - : m_deriv(dx), m_c_Ham(a_c_Ham), m_c_Ham_abs(a_c_Ham_abs), m_c_Moms(a_c_Moms), + : m_deriv(dx), m_c_Ham(a_c_Ham), m_c_Moms(a_c_Moms), m_min_chi(a_c_chi_min), m_c_Ham_abs_terms(a_c_Ham_abs_terms), m_c_Moms_abs_terms(a_c_Moms_abs_terms), @@ -52,7 +52,7 @@ Constraints::Vars Constraints::constraint_equations( { Vars out; - if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0 || m_c_Ham_abs >= 0) + if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0) { auto ricci = CCZ4Geometry::compute_ricci(vars, d1, d2, h_UU, chris); @@ -67,8 +67,6 @@ Constraints::Vars Constraints::constraint_equations( abs(ricci.scalar) + abs(tr_A2) + abs((GR_SPACEDIM - 1.) * vars.K * vars.K / GR_SPACEDIM); out.Ham_abs_terms += 2.0 * abs(m_cosmological_constant); - - out.Ham_abs = abs(out.Ham); } if (m_c_Moms.size() > 0 || m_c_Moms_abs_terms.size() > 0) @@ -112,8 +110,6 @@ void Constraints::store_vars(Vars &out, { if (m_c_Ham >= 0) current_cell.store_vars(out.Ham, m_c_Ham); - if (m_c_Ham_abs >= 0) - current_cell.store_vars(out.Ham_abs, m_c_Ham_abs); if (m_c_Ham_abs_terms >= 0) current_cell.store_vars(out.Ham_abs_terms, m_c_Ham_abs_terms); if (m_c_Moms.size() == GR_SPACEDIM) diff --git a/Source/Matter/NewMatterConstraints.hpp b/Source/Matter/NewMatterConstraints.hpp index 9b502164d..d4cd134d3 100644 --- a/Source/Matter/NewMatterConstraints.hpp +++ b/Source/Matter/NewMatterConstraints.hpp @@ -51,7 +51,7 @@ template class MatterConstraints : public Constraints hardcoded ones. */ MatterConstraints(const matter_t a_matter, double dx, double G_Newton, - int a_c_Ham, int a_c_Ham_abs, const Interval &a_c_Moms, + int a_c_Ham, const Interval &a_c_Moms, const double a_c_chi_min, int a_c_Ham_abs_terms = -1, const Interval &a_c_Moms_abs_terms = Interval()); diff --git a/Source/Matter/NewMatterConstraints.impl.hpp b/Source/Matter/NewMatterConstraints.impl.hpp index 5b45d63cf..9e169ad1a 100644 --- a/Source/Matter/NewMatterConstraints.impl.hpp +++ b/Source/Matter/NewMatterConstraints.impl.hpp @@ -13,10 +13,10 @@ template MatterConstraints::MatterConstraints( - const matter_t a_matter, double dx, double G_Newton, int a_c_Ham, int a_c_Ham_abs, + const matter_t a_matter, double dx, double G_Newton, int a_c_Ham, const Interval &a_c_Moms, const double a_c_chi_min, int a_c_Ham_abs_terms /* defaulted*/, const Interval &a_c_Moms_abs_terms /*defaulted*/) - : Constraints(dx, a_c_Ham, a_c_Ham_abs, a_c_Moms, a_c_chi_min, a_c_Ham_abs_terms, a_c_Moms_abs_terms, + : Constraints(dx, a_c_Ham, a_c_Moms, a_c_chi_min, a_c_Ham_abs_terms, a_c_Moms_abs_terms, 0.0 /*No cosmological constant*/), my_matter(a_matter), m_G_Newton(G_Newton) { @@ -41,13 +41,21 @@ void MatterConstraints::compute(Cell current_cell) const // Energy Momentum Tensor const auto emtensor = my_matter.compute_emtensor(vars, d1, h_UU, chris.ULL); + /*cout << std::fixed << setprecision(12) << "Ham: " << out.Ham << "\n"; + cout << std::fixed << setprecision(12) << "HamAbs: " << out.Ham_abs_terms << "\n"; + cout << std::fixed << setprecision(12) << "Rho term: " << 16.0 * M_PI * m_G_Newton * emtensor.rho << "\n";*/ + //MayDay::Error(); + // Hamiltonian constraint if (m_c_Ham >= 0 || m_c_Ham_abs_terms >= 0) { out.Ham += -16.0 * M_PI * m_G_Newton * emtensor.rho; out.Ham_abs_terms += 16.0 * M_PI * m_G_Newton * abs(emtensor.rho); - out.Ham_abs = abs(out.Ham); - } + } + + /*cout << std::fixed << setprecision(12) << "Ham with rho: " << out.Ham << "\n"; + cout << std::fixed << setprecision(12) << "HamAbs with rho: " << out.Ham_abs_terms << "\n"; + MayDay::Error();*/ // Momentum constraints if (m_c_Moms.size() > 0 || m_c_Moms_abs_terms.size() > 0)