Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dinatraykova committed Jul 28, 2023
1 parent 0330e51 commit 6845ace
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 52 deletions.
15 changes: 8 additions & 7 deletions Examples/PerfectFluid/FluidCCZ4RHS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

template <class matter_t, class gauge_t = MovingPunctureGauge,
class deriv_t = FourthOrderDerivatives>
class deriv_t = FourthOrderDerivatives, class weno_t = WENODerivatives>
class FluidCCZ4RHS : public CCZ4RHS<gauge_t, deriv_t>
{
public:
Expand All @@ -43,8 +43,8 @@ class FluidCCZ4RHS : public CCZ4RHS<gauge_t, deriv_t>
template <class data_t>
using MatterVars = typename matter_t::template Vars<data_t>;

template <class data_t>
using MatterDiff2Vars = typename matter_t::template Diff2Vars<data_t>;
// template <class data_t>
// using MatterDiff2Vars = typename matter_t::template Diff2Vars<data_t>;

template <class data_t>
using CCZ4Vars = typename CCZ4::template Vars<data_t>;
Expand All @@ -62,21 +62,21 @@ class FluidCCZ4RHS : public CCZ4RHS<gauge_t, deriv_t>
void enum_mapping(mapping_function_t mapping_function)
{
CCZ4Vars<data_t>::enum_mapping(mapping_function);
MatterVars<data_t>::enum_mapping(mapping_function);
MatterVars<data_t>::enum_mapping(mapping_function);
}
};

template <class data_t>
struct Diff2Vars : public CCZ4Diff2Vars<data_t>,
public MatterDiff2Vars<data_t>
struct Diff2Vars : public CCZ4Diff2Vars<data_t>
// public MatterDiff2Vars<data_t>
{
/// Defines the mapping between members of Vars and Chombo grid
/// variables (enum in User_Variables)
template <typename mapping_function_t>
void enum_mapping(mapping_function_t mapping_function)
{
CCZ4Diff2Vars<data_t>::enum_mapping(mapping_function);
MatterDiff2Vars<data_t>::enum_mapping(mapping_function);
//MatterDiff2Vars<data_t>::enum_mapping(mapping_function);
}
};

Expand Down Expand Up @@ -109,6 +109,7 @@ class FluidCCZ4RHS : public CCZ4RHS<gauge_t, deriv_t>
) 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.
};
Expand Down
30 changes: 15 additions & 15 deletions Examples/PerfectFluid/FluidCCZ4RHS.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#define FLUIDCCZ4RHS_IMPL_HPP_
#include "DimensionDefinitions.hpp"

template <class matter_t, class gauge_t, class deriv_t>
FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::FluidCCZ4RHS(
template <class matter_t, class gauge_t, class deriv_t, class weno_t>
FluidCCZ4RHS<matter_t, gauge_t, deriv_t, weno_t>::FluidCCZ4RHS(
matter_t a_matter, CCZ4_params_t<typename gauge_t::params_t> a_params,
double a_dx, double a_sigma, int a_formulation, double a_G_Newton)
: CCZ4RHS<gauge_t, deriv_t>(a_params, a_dx, a_sigma, a_formulation,
Expand All @@ -21,9 +21,9 @@ FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::FluidCCZ4RHS(
{
}

template <class matter_t, class gauge_t, class deriv_t>
template <class matter_t, class gauge_t, class deriv_t, class weno_t>
template <class data_t>
void FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::compute(
void FluidCCZ4RHS<matter_t, gauge_t, deriv_t, weno_t>::compute(
Cell<data_t> current_cell) const
{
// copy data from chombo gridpoint into local variables
Expand All @@ -32,17 +32,17 @@ void FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::compute(
const auto d2 = this->m_deriv.template diff2<Diff2Vars>(current_cell);
const auto advec =
this->m_deriv.template advection<Vars>(current_cell, matter_vars.shift);
///const auto lm = this->m_weno.template get_Pface<Vars>
// (current_cell, WENODerivatives::LEFT_MINUS);
const auto lm = this->m_weno.template get_Pface<Vars>
(current_cell, WENODerivatives::LEFT_MINUS);
// (current_cell,0);
//const auto lp = this->m_weno.template get_Pface<Vars>
// (current_cell, WENODerivatives::LEFT_PLUS);
const auto lp = this->m_weno.template get_Pface<Vars>
(current_cell, WENODerivatives::LEFT_PLUS);
// (current_cell,1);
//const auto rm = this->m_weno.template get_Pface<Vars>
// (current_cell, WENODerivatives::RIGHT_MINUS);
const auto rm = this->m_weno.template get_Pface<Vars>
(current_cell, WENODerivatives::RIGHT_MINUS);
//(current_cell,2);
//const auto rp = this->m_weno.template get_Pface<Vars>
// (current_cell, WENODerivatives::RIGHT_PLUS);
const auto rp = this->m_weno.template get_Pface<Vars>
(current_cell, WENODerivatives::RIGHT_PLUS);
//(current_cell,3);

// Call CCZ4 RHS - work out RHS without matter, no dissipation
Expand All @@ -53,7 +53,7 @@ void FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::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);
Expand All @@ -63,9 +63,9 @@ void FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::compute(
}

// Function to add in EM Tensor matter terms to CCZ4 rhs
template <class matter_t, class gauge_t, class deriv_t>
template <class matter_t, class gauge_t, class deriv_t, class weno_t>
template <class data_t>
void FluidCCZ4RHS<matter_t, gauge_t, deriv_t>::add_emtensor_rhs(
void FluidCCZ4RHS<matter_t, gauge_t, deriv_t, weno_t>::add_emtensor_rhs(
Vars<data_t> &matter_rhs, const Vars<data_t> &matter_vars,
const Vars<Tensor<1, data_t>> &d1) const
{
Expand Down
22 changes: 11 additions & 11 deletions Examples/PerfectFluid/PerfectFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ template <class eos_t = DefaultEoS> class PerfectFluid

//! Structure containing the rhs variables for the matter fields requiring
//! 2nd derivs
template <class data_t> struct Diff2Vars
{
data_t rho;
// template <class data_t> struct Diff2Vars
//{
// data_t rho;

/// Defines the mapping between members of Vars and Chombo grid
/// variables (enum in User_Variables)
template <typename mapping_function_t>
void enum_mapping(mapping_function_t mapping_function)
{
VarsTools::define_enum_mapping(mapping_function, c_rho, rho);
// template <typename mapping_function_t>
// void enum_mapping(mapping_function_t mapping_function)
// {
// VarsTools::define_enum_mapping(mapping_function, c_rho, rho);
// VarsTools::define_enum_mapping(
// mapping_function, GRInterval<c_Avec1, c_Avec3>(), Avec);
}
};
// }
//};

//! The function which calculates the EM Tensor, given the vars and
//! derivatives
Expand All @@ -97,12 +97,12 @@ template <class eos_t = DefaultEoS> class PerfectFluid

//! The function which adds in the RHS for the matter field vars
template <class data_t, template <typename> class vars_t,
template <typename> class diff2_vars_t,
// template <typename> class diff2_vars_t,
template <typename> class rhs_vars_t>
void add_matter_rhs(
rhs_vars_t<data_t> &rhs, //!< value of the RHS for all vars
const vars_t<data_t> &vars, //!< value of the variables
const vars_t<Tensor<1, data_t>> &lm, //!< value of the left_minus weno
const vars_t<Tensor<1, data_t>> &lm, //!< value of the left_minus weno
const vars_t<Tensor<1, data_t>> &lp, //!< value of the left_plus weno
const vars_t<Tensor<1, data_t>> &rm, //!< value of the right_minus weno
const vars_t<Tensor<1, data_t>> &rp) //!< value of the right_plus weno
Expand Down
10 changes: 6 additions & 4 deletions Examples/PerfectFluid/PerfectFluid.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ emtensor_t<data_t> PerfectFluid<eos_t>::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;
}

Expand All @@ -66,19 +66,21 @@ emtensor_t<data_t> PerfectFluid<eos_t>::compute_emtensor(

template <class eos_t>
template <class data_t, template <typename> class vars_t,
template <typename> class diff2_vars_t,
// template <typename> class diff2_vars_t,
template <typename> class rhs_vars_t>
void PerfectFluid<eos_t>::add_matter_rhs(
rhs_vars_t<data_t> &rhs, const vars_t<data_t> &vars,
const vars_t<Tensor<1, data_t>> &lm,
const vars_t<Tensor<1, data_t>> &lp,
const vars_t<Tensor<1, data_t>> &rm,
const vars_t<Tensor<1, data_t>> &rp) const
//const vars_t<Tensor<1, data_t>> &d1,
// const vars_t<data_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;
Expand Down
8 changes: 4 additions & 4 deletions Examples/PerfectFluid/PerfectFluidLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ void PerfectFluidLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs,
if (m_p.max_spatial_derivative_order == 4)
{
FluidCCZ4RHS<PerfectFluidEoS, MovingPunctureGauge,
// FourthOrderDerivatives, WENODerivatives>
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);
}
else if (m_p.max_spatial_derivative_order == 6)
{
FluidCCZ4RHS<PerfectFluidEoS, MovingPunctureGauge,
// SixthOrderDerivatives, WENODerivatives>
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);
Expand Down
22 changes: 11 additions & 11 deletions Examples/PerfectFluid/WENODerivatives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class data_t>
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.};
Expand All @@ -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];
Expand All @@ -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.;
Expand All @@ -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.;
Expand All @@ -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.;
Expand Down

0 comments on commit 6845ace

Please sign in to comment.