Skip to content

Commit

Permalink
Load vars in initial data
Browse files Browse the repository at this point in the history
  • Loading branch information
dinatraykova committed Mar 27, 2024
1 parent 41457c7 commit 2171d67
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions Examples/Fluid_Kerr/InitialFluidData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
// aka Kevin data
class InitialFluidData
{
// Now the non grid ADM vars
template <class data_t>
using MetricVars = ADMConformalVars::VarsWithGauge<data_t>;

public:
//! A structure for the input params for fluid properties and initial
//! conditions
Expand All @@ -45,50 +41,48 @@ class InitialFluidData
//! Function to compute the value of all the initial vars on the grid
template <class data_t> void compute(Cell<data_t> current_cell) const
{
// load vars
FluidCCZ4RHS<PerfectFluid<>>::Vars<data_t> vars;
VarsTools::assign(vars, 0.);
// where am i?
Coordinates<data_t> coords(current_cell, m_dx, m_params.center);
data_t rr = coords.get_radius();
data_t rr2 = rr * rr;

const auto metric_vars = current_cell.template load_vars<MetricVars>();

data_t x = coords.x;
double y = coords.y;
double z = coords.z;

Tensor<1, data_t> vi, Sj;
data_t chi_regularised = simd_max(metric_vars.chi, 1e-6);
// Tensor<1, data_t> vi, Sj;
data_t chi_regularised = simd_max(vars.chi, 1e-6);

vi[0] = 0.;
vi[1] = 0.;
vi[2] = 0.;
// vi[0] = 0.;
// vi[1] = 0.;
// vi[2] = 0.;

// calculate the field value
data_t rho = m_params.rho0 * (exp(-pow(rr / m_params.awidth, 2.0))) +
m_params.delta;
vars.rho = m_params.rho0 * (exp(-pow(rr / m_params.awidth, 2.0))) +
m_params.delta;
data_t v2 = 0.;
FOR(i, j) v2 += metric_vars.h[i][j] * vi[i] * vi[j] / chi_regularised;
data_t eps = 0.;
data_t P = rho * (1. + eps) / 3.;
FOR(i, j)
v2 += vars.h[i][j] * vars.vi[i] * vars.vi[j] / chi_regularised;
vars.eps = 0.;
data_t P = vars.rho * (1. + vars.eps) / 3.;
data_t WW = 1. / (1. - v2);
data_t hh = 1. + eps + P / rho;
data_t hh = 1. + vars.eps + P / vars.rho;

data_t D = rho * sqrt(WW);
data_t tau = rho * hh * WW - P - D;
vars.D = vars.rho * sqrt(WW);
vars.tau = vars.rho * hh * WW - P - vars.D;
FOR(i)
{
Sj[i] = 0.;
vars.Sj[i] = 0.;
FOR(j)
Sj[i] +=
rho * hh * WW * metric_vars.h[i][j] * vi[j] / chi_regularised;
vars.Sj[i] += vars.rho * hh * WW * vars.h[i][j] * vars.vi[j] /
chi_regularised;
}

// store the vars
current_cell.store_vars(rho, c_rho);
current_cell.store_vars(vi, GRInterval<c_vi1, c_vi3>());
current_cell.store_vars(D, c_D);
current_cell.store_vars(Sj, GRInterval<c_Sj1, c_Sj3>());
current_cell.store_vars(tau, c_tau);
current_cell.store_vars(vars);
}

protected:
Expand Down

0 comments on commit 2171d67

Please sign in to comment.