From 6845ace0e54294825cf07992bd97394a0a39d4e9 Mon Sep 17 00:00:00 2001 From: dinatraykova Date: Fri, 28 Jul 2023 18:55:19 +0200 Subject: [PATCH] Bug fixes --- Examples/PerfectFluid/FluidCCZ4RHS.hpp | 15 ++++++----- Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp | 30 ++++++++++----------- Examples/PerfectFluid/PerfectFluid.hpp | 22 +++++++-------- Examples/PerfectFluid/PerfectFluid.impl.hpp | 10 ++++--- Examples/PerfectFluid/PerfectFluidLevel.cpp | 8 +++--- Examples/PerfectFluid/WENODerivatives.hpp | 22 +++++++-------- 6 files changed, 55 insertions(+), 52 deletions(-) diff --git a/Examples/PerfectFluid/FluidCCZ4RHS.hpp b/Examples/PerfectFluid/FluidCCZ4RHS.hpp index 365d65381..99eca672e 100644 --- a/Examples/PerfectFluid/FluidCCZ4RHS.hpp +++ b/Examples/PerfectFluid/FluidCCZ4RHS.hpp @@ -31,7 +31,7 @@ */ template + class deriv_t = FourthOrderDerivatives, class weno_t = WENODerivatives> class FluidCCZ4RHS : public CCZ4RHS { public: @@ -43,8 +43,8 @@ class FluidCCZ4RHS : public CCZ4RHS template using MatterVars = typename matter_t::template Vars; - template - using MatterDiff2Vars = typename matter_t::template Diff2Vars; + // template + // using MatterDiff2Vars = typename matter_t::template Diff2Vars; template using CCZ4Vars = typename CCZ4::template Vars; @@ -62,13 +62,13 @@ class FluidCCZ4RHS : public CCZ4RHS void enum_mapping(mapping_function_t mapping_function) { CCZ4Vars::enum_mapping(mapping_function); - MatterVars::enum_mapping(mapping_function); + MatterVars::enum_mapping(mapping_function); } }; template - struct Diff2Vars : public CCZ4Diff2Vars, - public MatterDiff2Vars + struct Diff2Vars : public CCZ4Diff2Vars + // public MatterDiff2Vars { /// Defines the mapping between members of Vars and Chombo grid /// variables (enum in User_Variables) @@ -76,7 +76,7 @@ class FluidCCZ4RHS : public CCZ4RHS void enum_mapping(mapping_function_t mapping_function) { CCZ4Diff2Vars::enum_mapping(mapping_function); - MatterDiff2Vars::enum_mapping(mapping_function); + //MatterDiff2Vars::enum_mapping(mapping_function); } }; @@ -109,6 +109,7 @@ class FluidCCZ4RHS : public CCZ4RHS ) const; // Class members + weno_t m_weno; matter_t my_matter; //!< The matter object, e.g. a scalar field. const double m_G_Newton; //!< Newton's constant, set to one by default. }; diff --git a/Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp b/Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp index 3b961feb2..875373aa1 100644 --- a/Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp +++ b/Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp @@ -11,8 +11,8 @@ #define FLUIDCCZ4RHS_IMPL_HPP_ #include "DimensionDefinitions.hpp" -template -FluidCCZ4RHS::FluidCCZ4RHS( +template +FluidCCZ4RHS::FluidCCZ4RHS( matter_t a_matter, CCZ4_params_t a_params, double a_dx, double a_sigma, int a_formulation, double a_G_Newton) : CCZ4RHS(a_params, a_dx, a_sigma, a_formulation, @@ -21,9 +21,9 @@ FluidCCZ4RHS::FluidCCZ4RHS( { } -template +template template -void FluidCCZ4RHS::compute( +void FluidCCZ4RHS::compute( Cell current_cell) const { // copy data from chombo gridpoint into local variables @@ -32,17 +32,17 @@ void FluidCCZ4RHS::compute( const auto d2 = this->m_deriv.template diff2(current_cell); const auto advec = this->m_deriv.template advection(current_cell, matter_vars.shift); - ///const auto lm = this->m_weno.template get_Pface - // (current_cell, WENODerivatives::LEFT_MINUS); + const auto lm = this->m_weno.template get_Pface + (current_cell, WENODerivatives::LEFT_MINUS); // (current_cell,0); - //const auto lp = this->m_weno.template get_Pface - // (current_cell, WENODerivatives::LEFT_PLUS); + const auto lp = this->m_weno.template get_Pface + (current_cell, WENODerivatives::LEFT_PLUS); // (current_cell,1); - //const auto rm = this->m_weno.template get_Pface - // (current_cell, WENODerivatives::RIGHT_MINUS); + const auto rm = this->m_weno.template get_Pface + (current_cell, WENODerivatives::RIGHT_MINUS); //(current_cell,2); - //const auto rp = this->m_weno.template get_Pface - // (current_cell, WENODerivatives::RIGHT_PLUS); + const auto rp = this->m_weno.template get_Pface + (current_cell, WENODerivatives::RIGHT_PLUS); //(current_cell,3); // Call CCZ4 RHS - work out RHS without matter, no dissipation @@ -53,7 +53,7 @@ void FluidCCZ4RHS::compute( add_emtensor_rhs(matter_rhs, matter_vars, d1); // add evolution of matter fields themselves - my_matter.add_matter_rhs(matter_rhs, matter_vars, d1, d1, d1, d1); + my_matter.add_matter_rhs(matter_rhs, matter_vars, lm, lp, rm, rp); // Add dissipation to all terms this->m_deriv.add_dissipation(matter_rhs, current_cell, this->m_sigma); @@ -63,9 +63,9 @@ void FluidCCZ4RHS::compute( } // Function to add in EM Tensor matter terms to CCZ4 rhs -template +template template -void FluidCCZ4RHS::add_emtensor_rhs( +void FluidCCZ4RHS::add_emtensor_rhs( Vars &matter_rhs, const Vars &matter_vars, const Vars> &d1) const { diff --git a/Examples/PerfectFluid/PerfectFluid.hpp b/Examples/PerfectFluid/PerfectFluid.hpp index 4fd21779c..0a7e8641a 100644 --- a/Examples/PerfectFluid/PerfectFluid.hpp +++ b/Examples/PerfectFluid/PerfectFluid.hpp @@ -70,20 +70,20 @@ template class PerfectFluid //! Structure containing the rhs variables for the matter fields requiring //! 2nd derivs - template struct Diff2Vars - { - data_t rho; + // template struct Diff2Vars + //{ + // data_t rho; /// Defines the mapping between members of Vars and Chombo grid /// variables (enum in User_Variables) - template - void enum_mapping(mapping_function_t mapping_function) - { - VarsTools::define_enum_mapping(mapping_function, c_rho, rho); + // template + // void enum_mapping(mapping_function_t mapping_function) + // { + // VarsTools::define_enum_mapping(mapping_function, c_rho, rho); // VarsTools::define_enum_mapping( // mapping_function, GRInterval(), Avec); - } - }; + // } + //}; //! The function which calculates the EM Tensor, given the vars and //! derivatives @@ -97,12 +97,12 @@ template class PerfectFluid //! The function which adds in the RHS for the matter field vars template class vars_t, - template class diff2_vars_t, + // template class diff2_vars_t, template class rhs_vars_t> void add_matter_rhs( rhs_vars_t &rhs, //!< value of the RHS for all vars const vars_t &vars, //!< value of the variables - const vars_t> &lm, //!< value of the left_minus weno + const vars_t> &lm, //!< value of the left_minus weno const vars_t> &lp, //!< value of the left_plus weno const vars_t> &rm, //!< value of the right_minus weno const vars_t> &rp) //!< value of the right_plus weno diff --git a/Examples/PerfectFluid/PerfectFluid.impl.hpp b/Examples/PerfectFluid/PerfectFluid.impl.hpp index 208111b5f..2a5561460 100644 --- a/Examples/PerfectFluid/PerfectFluid.impl.hpp +++ b/Examples/PerfectFluid/PerfectFluid.impl.hpp @@ -48,7 +48,7 @@ emtensor_t PerfectFluid::compute_emtensor( // S_ij = T_ij FOR(i, j) { - out.Sij[i][j] = vars.rho * hh * WW * vi_D[i] * vi_D[j] + out.Sij[i][j] = vars.rho * hh * WW * vi_D[i] * vi_D[j] + vars.h[i][j] * P_of_rho / chi_regularised; } @@ -66,7 +66,7 @@ emtensor_t PerfectFluid::compute_emtensor( template template class vars_t, - template class diff2_vars_t, + // template class diff2_vars_t, template class rhs_vars_t> void PerfectFluid::add_matter_rhs( rhs_vars_t &rhs, const vars_t &vars, @@ -74,11 +74,13 @@ void PerfectFluid::add_matter_rhs( const vars_t> &lp, const vars_t> &rm, const vars_t> &rp) const +//const vars_t> &d1, +// const vars_t &advec) const { using namespace TensorAlgebra; - const auto h_UU = compute_inverse_sym(vars.h); - const auto chris = compute_christoffel(d1.h, h_UU); + //const auto h_UU = compute_inverse_sym(vars.h); + // const auto chris = compute_christoffel(d1.h, h_UU); data_t P_of_rho = 0.0; data_t dPdrho = 0.0; diff --git a/Examples/PerfectFluid/PerfectFluidLevel.cpp b/Examples/PerfectFluid/PerfectFluidLevel.cpp index ae8b773ca..5ca0a8045 100644 --- a/Examples/PerfectFluid/PerfectFluidLevel.cpp +++ b/Examples/PerfectFluid/PerfectFluidLevel.cpp @@ -96,8 +96,8 @@ void PerfectFluidLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs, if (m_p.max_spatial_derivative_order == 4) { FluidCCZ4RHS - FourthOrderDerivatives> + FourthOrderDerivatives, WENODerivatives> + //FourthOrderDerivatives> my_ccz4_matter(perfect_fluid, m_p.ccz4_params, m_dx, m_p.sigma, m_p.formulation, m_p.G_Newton); BoxLoops::loop(my_ccz4_matter, a_soln, a_rhs, EXCLUDE_GHOST_CELLS); @@ -105,8 +105,8 @@ void PerfectFluidLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs, else if (m_p.max_spatial_derivative_order == 6) { FluidCCZ4RHS - FourthOrderDerivatives> + SixthOrderDerivatives, WENODerivatives> + //FourthOrderDerivatives> my_ccz4_matter(perfect_fluid, m_p.ccz4_params, m_dx, m_p.sigma, m_p.formulation, m_p.G_Newton); BoxLoops::loop(my_ccz4_matter, a_soln, a_rhs, EXCLUDE_GHOST_CELLS); diff --git a/Examples/PerfectFluid/WENODerivatives.hpp b/Examples/PerfectFluid/WENODerivatives.hpp index 0f266f886..688ab08ed 100644 --- a/Examples/PerfectFluid/WENODerivatives.hpp +++ b/Examples/PerfectFluid/WENODerivatives.hpp @@ -24,15 +24,15 @@ class WENODerivatives }; //public: - WENODerivatives(double a_eW) : m_eW(a_eW){} - + // WENODerivatives(double a_eW) : m_eW(a_eW){} + WENODerivatives(){} template ALWAYS_INLINE data_t get_Pface(const double *in_ptr, const int idx, const int stride, int dir_switch) const { data_t beta[3] = {0.,0.,0.}; const double dd[3] = {3./10.,3./5.,1./10.}; - //const double eW = 1.; + const double eW = 1.; data_t alpha[3] = {0.,0.,0.}; data_t sum_alpha; data_t weights[3] = {0.,0.,0.}; @@ -47,8 +47,8 @@ class WENODerivatives // Negative fluxes to compute primitive variables // at the left cell boundary i-1/2: p^{L-}_{i-1/2} { - pim2 = in[idx - 3.*stride]; - pim1 = in[idx - 2.*stride]; + pim2 = in[idx - 3*stride]; + pim1 = in[idx - 2*stride]; pi0 = in[idx - stride]; pip1 = in[idx]; pip2 = in[idx + stride]; @@ -63,11 +63,11 @@ class WENODerivatives { // Positive fluxes to compute primitive variables // at the left cell boundary i-1/2: p^{L+}_{i-1/2} - pim2 = in[idx - 2.*stride]; + pim2 = in[idx - 2*stride]; pim1 = in[idx - stride]; pi0 = in[idx]; pip1 = in[idx + stride]; - pip2 = in[idx + 2.*stride]; + pip2 = in[idx + 2*stride]; // ENO polynomials v[0] = ( -pim2 + 5.*pim1 + 2.*pi0 )/6.; @@ -80,11 +80,11 @@ class WENODerivatives // Negative fluxes to compute primitive variables // at the right cell boundary i+1/2: p^{R-}_{i+1/2} { - pim2 = in[idx - 2.*stride]; + pim2 = in[idx - 2*stride]; pim1 = in[idx - stride]; pi0 = in[idx]; pip1 = in[idx + stride]; - pip2 = in[idx + 2.*stride]; + pip2 = in[idx + 2*stride]; // ENO polynomials v[0] = (2.*pim2 - 7.*pim1 + 11.*pi0 )/6.; @@ -99,8 +99,8 @@ class WENODerivatives pim2 = in[idx - stride]; pim1 = in[idx]; pi0 = in[idx + stride]; - pip1 = in[idx + 2.*stride]; - pip2 = in[idx + 3.*stride]; + pip1 = in[idx + 2*stride]; + pip2 = in[idx + 3*stride]; // ENO polynomials v[0] = ( -pim2 + 5.*pim1 + 2.*pi0 )/6.;