Skip to content

Commit

Permalink
1D interpolation to grid from readin initial data
Browse files Browse the repository at this point in the history
  • Loading branch information
JCAurre committed May 21, 2024
1 parent b1b9f9b commit 3631f86
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Examples/Fluid_Kerr/InitialFluidData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "UserVariables.hpp" //This files needs NUM_VARS - total no. components
#include "VarsTools.hpp"
#include "simd.hpp"
#include <cmath>

//! Class which sets the initial fluid matter config
class InitialFluidData : public EoS
Expand All @@ -32,6 +33,8 @@ class InitialFluidData : public EoS
double rho0;
double awidth;
double delta;
double spacing;
double *rho_1D;
};

//! The constructor
Expand Down
7 changes: 7 additions & 0 deletions Examples/Fluid_Kerr/InitialFluidData.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ void InitialFluidData::compute(Cell<data_t> current_cell) const
double y = coords.y;
double z = coords.z;

int ind_L = static_cast<int>(floor(rr / m_params.spacing));
int ind_H = static_cast<int>(ceil(rr / m_params.spacing));
double rho_L = *(m_params.rho_1D + ind_L);
double rho_H = *(m_params.rho_1D + ind_H);
double rho_interp =
rho_L + (rr / m_params.spacing - ind_L) * (rho_H - rho_L);

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

Expand Down
2 changes: 1 addition & 1 deletion Examples/Fluid_Kerr/PerfectFluidLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void PerfectFluidLevel::initialData()
BoxLoops::loop(
make_compute_pack(SetValue(0.), KerrBH(m_p.kerr_params, m_dx),
InitialFluidData(m_p.initial_params, m_dx)),
m_state_new, m_state_new, INCLUDE_GHOST_CELLS);
m_state_new, m_state_new, INCLUDE_GHOST_CELLS, disable_simd());

fillAllGhosts();
BoxLoops::loop(GammaCalculator(m_dx), m_state_new, m_state_new,
Expand Down
16 changes: 16 additions & 0 deletions Examples/Fluid_Kerr/SimulationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ class SimulationParameters : public SimulationParametersBase
pp.load("fluid_delta", initial_params.delta, 0.2);
pp.load("lambda", lambda, 1.); // eigenvalue for numerical flux

// Reading data
pp.load("spacing", initial_params.spacing);
pp.load("lines", lines);
double rho_1D[lines];

double tmp_data;
ifstream read_file("rho_vs_r.csv");

for (int i = 0; i < lines; ++i)
{
read_file >> tmp_data;
rho_1D[i] = tmp_data;
}
initial_params.rho_1D = rho_1D;

// Initial Kerr data
pp.load("kerr_mass", kerr_params.mass);
pp.load("kerr_spin", kerr_params.spin);
Expand Down Expand Up @@ -65,6 +80,7 @@ class SimulationParameters : public SimulationParametersBase
// Initial data for matter and potential and BH
double G_Newton;
double lambda;
int lines;
InitialFluidData::params_t initial_params;
KerrBH::params_t kerr_params;
};
Expand Down
4 changes: 3 additions & 1 deletion Examples/Fluid_Kerr/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ G_Newton = 1.0
fluid_rho0 = 1.0
fluid_width = 5.
fluid_delta = 0.2

lines = 10000
spacing = 1e-3

# Kerr BH data
kerr_mass = 1.0
kerr_spin = 0.5
Expand Down

0 comments on commit 3631f86

Please sign in to comment.