From bc298f028c3522e225151dc04ab178d32eff99df Mon Sep 17 00:00:00 2001 From: dinatraykova Date: Thu, 28 Mar 2024 17:40:16 +0100 Subject: [PATCH] General P_over_rho in InitialData and PrimitiveRecovery --- Examples/Fluid_Kerr/DefaultEoS.hpp | 3 +-- Examples/Fluid_Kerr/EoS.hpp | 15 +++------------ Examples/Fluid_Kerr/InitialFluidData.hpp | 5 +---- Examples/Fluid_Kerr/InitialFluidData.impl.hpp | 8 ++++---- Examples/Fluid_Kerr/PerfectFluidLevel.cpp | 6 ++---- Examples/Fluid_Kerr/PrimitiveRecovery.hpp | 5 +++-- Examples/Fluid_Kerr/SimulationParameters.hpp | 2 -- 7 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Examples/Fluid_Kerr/DefaultEoS.hpp b/Examples/Fluid_Kerr/DefaultEoS.hpp index 12505ffbe..e37e4b87f 100644 --- a/Examples/Fluid_Kerr/DefaultEoS.hpp +++ b/Examples/Fluid_Kerr/DefaultEoS.hpp @@ -19,8 +19,7 @@ class DefaultEoS template class vars_t> void compute_eos(data_t &P_over_rho, const vars_t &vars) const { - // The pressure value in function of rho - P_over_rho = 1. / 3.; + P_over_rho = (1. + vars.eps) / 3.; } }; diff --git a/Examples/Fluid_Kerr/EoS.hpp b/Examples/Fluid_Kerr/EoS.hpp index 1769c44a5..9f1d42f75 100644 --- a/Examples/Fluid_Kerr/EoS.hpp +++ b/Examples/Fluid_Kerr/EoS.hpp @@ -10,25 +10,16 @@ class EoS { - public: - struct params_t - { - double eos_w; - }; - - private: - params_t m_params; - public: //! The constructor - EoS(params_t a_params) : m_params(a_params) {} + EoS() {} //! Set the pressure of the perfect fluid here template class vars_t> void compute_eos(data_t &P_over_rho, const vars_t &vars) const { - // The pressure value in function of rho - P_over_rho = m_params.eos_w * (1. + vars.eps); + // The pressure value as a function of rho + P_over_rho = (1. + vars.eps) / 3.; } }; diff --git a/Examples/Fluid_Kerr/InitialFluidData.hpp b/Examples/Fluid_Kerr/InitialFluidData.hpp index 24cdcb20e..a8645b23d 100644 --- a/Examples/Fluid_Kerr/InitialFluidData.hpp +++ b/Examples/Fluid_Kerr/InitialFluidData.hpp @@ -17,7 +17,7 @@ #include "simd.hpp" //! Class which sets the initial fluid matter config -class InitialFluidData +class InitialFluidData : public EoS { public: //! A structure for the input params for fluid properties and initial @@ -33,9 +33,6 @@ class InitialFluidData //! The constructor InitialFluidData(params_t a_params, double a_dx); - // : m_dx(a_dx), m_params(a_params) - //{ - //} //! Function to compute the value of all the initial vars on the grid //! The constructor diff --git a/Examples/Fluid_Kerr/InitialFluidData.impl.hpp b/Examples/Fluid_Kerr/InitialFluidData.impl.hpp index d87e2743a..6f4728538 100644 --- a/Examples/Fluid_Kerr/InitialFluidData.impl.hpp +++ b/Examples/Fluid_Kerr/InitialFluidData.impl.hpp @@ -18,12 +18,10 @@ inline InitialFluidData::InitialFluidData(params_t a_params, double a_dx) template void InitialFluidData::compute(Cell current_cell) const { - // Set up EoS - // data_t P_over_rho = 0.; - // my_eos.compute_eos(P_over_rho, vars); // load vars FluidCCZ4RHS>::Vars vars; VarsTools::assign(vars, 0.); + // where am i? Coordinates coords(current_cell, m_dx, m_params.center); data_t rr = coords.get_radius(); @@ -46,7 +44,9 @@ void InitialFluidData::compute(Cell current_cell) const data_t v2 = 0.; FOR(i, j) v2 += vars.h[i][j] * vars.vi[i] * vars.vi[j] / chi_regularised; vars.eps = 0.; - data_t P_over_rho = vars.rho * (1. + vars.eps) / 3.; + data_t P_over_rho = 0.; + EoS::compute_eos(P_over_rho, vars); + data_t WW = 1. / (1. - v2); data_t hh = 1. + vars.eps + P_over_rho; diff --git a/Examples/Fluid_Kerr/PerfectFluidLevel.cpp b/Examples/Fluid_Kerr/PerfectFluidLevel.cpp index 8727982c4..b7cba57cf 100644 --- a/Examples/Fluid_Kerr/PerfectFluidLevel.cpp +++ b/Examples/Fluid_Kerr/PerfectFluidLevel.cpp @@ -56,8 +56,6 @@ void PerfectFluidLevel::initialData() // First set everything to zero then initial conditions for scalar field - // here a Kerr BH and a scalar field profile - // EoS eos(m_p.eos_params); - // PerfectFluidEoS perfect_fluid(eos); BoxLoops::loop( make_compute_pack(SetValue(0.), KerrBH(m_p.kerr_params, m_dx), InitialFluidData(m_p.initial_params, m_dx)), @@ -73,7 +71,7 @@ void PerfectFluidLevel::initialData() void PerfectFluidLevel::prePlotLevel() { fillAllGhosts(); - EoS eos(m_p.eos_params); + EoS eos; PerfectFluidEoS perfect_fluid(m_dx, m_p.lambda, eos); BoxLoops::loop(MatterConstraints(perfect_fluid, m_dx, m_p.G_Newton, c_Ham, @@ -93,7 +91,7 @@ void PerfectFluidLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs, a_soln, a_soln, INCLUDE_GHOST_CELLS, disable_simd()); // Calculate MatterCCZ4 right hand side with matter_t = ScalarField - EoS eos(m_p.eos_params); + EoS eos; PerfectFluidEoS perfect_fluid(m_dx, m_p.lambda, eos); if (m_p.max_spatial_derivative_order == 4) { diff --git a/Examples/Fluid_Kerr/PrimitiveRecovery.hpp b/Examples/Fluid_Kerr/PrimitiveRecovery.hpp index 08ecbb1ac..308c2e40d 100644 --- a/Examples/Fluid_Kerr/PrimitiveRecovery.hpp +++ b/Examples/Fluid_Kerr/PrimitiveRecovery.hpp @@ -10,13 +10,14 @@ #include "CCZ4Geometry.hpp" #include "Cell.hpp" #include "DefaultEoS.hpp" +#include "EoS.hpp" #include "Tensor.hpp" #include "TensorAlgebra.hpp" #include "UserVariables.hpp" #include "VarsTools.hpp" // template -class PrimitiveRecovery +class PrimitiveRecovery : public EoS { public: template struct Vars @@ -50,7 +51,7 @@ class PrimitiveRecovery vars.rho = vars.D / Wa; vars.eps = -1. + xa / Wa * (1. - Wa * Wa) + Wa * (1. + q); - P_over_rho = (1. + vars.eps) / 3.; + EoS::compute_eos(P_over_rho, vars); xn = Wa * (1. + vars.eps + P_over_rho); diff = abs(xn - xa); diff --git a/Examples/Fluid_Kerr/SimulationParameters.hpp b/Examples/Fluid_Kerr/SimulationParameters.hpp index 2f65a6be2..0383a5415 100644 --- a/Examples/Fluid_Kerr/SimulationParameters.hpp +++ b/Examples/Fluid_Kerr/SimulationParameters.hpp @@ -36,7 +36,6 @@ class SimulationParameters : public SimulationParametersBase pp.load("fluid_width", initial_params.awidth, 0.1); pp.load("fluid_delta", initial_params.delta, 0.2); pp.load("lambda", lambda, 1.); // eigenvalue for numerical flux - pp.load("eos_w", eos_params.eos_w, 1. / 3.); // Initial Kerr data pp.load("kerr_mass", kerr_params.mass); @@ -67,7 +66,6 @@ class SimulationParameters : public SimulationParametersBase double G_Newton; double lambda; InitialFluidData::params_t initial_params; - EoS::params_t eos_params; KerrBH::params_t kerr_params; };