Skip to content

Commit

Permalink
Fixed bug with loading print directory to RF class automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
the-florist committed Jul 31, 2024
1 parent 2fd1b52 commit 3806a92
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Examples/ScalarField/ScalarFieldLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void ScalarFieldLevel::initialData()
CH_TIME("ScalarFieldLevel::initialData");
pout() << "ScalarFieldLevel::initialData " << m_level << endl;

RandomField pfield(m_p.random_field_params, m_p.initial_params, m_p.data_path, "position");
RandomField pfield(m_p.random_field_params, m_p.initial_params, "position");

BoxLoops::loop(
make_compute_pack(SetValue(0.), pfield),
Expand All @@ -77,7 +77,7 @@ void ScalarFieldLevel::initialData()
pfield.clear_data();
pout() << "Calculating position ICs ended.\n";

/*RandomField vfield(m_p.random_field_params, m_p.initial_params, m_p.data_path, "velocity");
/*RandomField vfield(m_p.random_field_params, m_p.initial_params, "velocity");
BoxLoops::loop(
make_compute_pack(vfield),
Expand Down
1 change: 1 addition & 0 deletions Examples/ScalarField/SimulationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SimulationParameters : public SimulationParametersBase
pp.load("N_fine", random_field_params.Nf, 128);
pp.load("L_full", random_field_params.L, 4.);
pp.load("tensor_amplitude", random_field_params.A, 1.e-6);
pp.load("output_path", random_field_params.print_path);
}

void check_params()
Expand Down
2 changes: 1 addition & 1 deletion Examples/ScalarField/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
verbosity = 0

# location / naming of output files
output_path = "/home/eaf49/rds/hpc-work/N128-Hnorm-and-new-PS" # Main path for all files. Must exist!
output_path = "/nfs/st01/hpc-gr-epss/eaf49/N128-Hnorm_newPS" # Main path for all files. Must exist!
chk_prefix = ScalarField_
plot_prefix = ScalarFieldp_
# restart_file = ScalarField_002100.3d.hdf5
Expand Down
4 changes: 2 additions & 2 deletions Source/InitialConditions/ScalarFields/RandomField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class RandomField
//! (used for convergence testing)
double L; //!< Box length in physical units
double A; //!< Amplitude applied to tensor field
std::string print_path;
};

RandomField(params_t a_params, InitialScalarData::params_t a_bkgd_params, std::string a_data_path, std::string a_spec_type);
RandomField(params_t a_params, InitialScalarData::params_t a_bkgd_params, std::string a_spec_type);

template <class data_t> void compute(Cell<data_t> current_cell) const;

Expand All @@ -47,7 +48,6 @@ class RandomField
protected:
const params_t m_params;
const InitialScalarData::params_t m_bkgd_params;
const std::string m_data_path;
const std::string m_spec_type;

bool debug;
Expand Down
10 changes: 5 additions & 5 deletions Source/InitialConditions/ScalarFields/RandomField.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#ifndef RANDOMFIELD_IMPL_HPP_
#define RANDOMFIELD_IMPL_HPP_

inline RandomField::RandomField(params_t a_params, InitialScalarData::params_t a_bkgd_params, std::string a_data_path, std::string a_spec_type)
: m_params(a_params), m_bkgd_params(a_bkgd_params), m_data_path(a_data_path), m_spec_type(a_spec_type)
inline RandomField::RandomField(params_t a_params, InitialScalarData::params_t a_bkgd_params, std::string a_spec_type)
: m_params(a_params), m_bkgd_params(a_bkgd_params), m_spec_type(a_spec_type)
{
kstar = 16.*(2.*M_PI/m_params.L);
epsilon = 0.5;//0.25 * (sqrt(3.)*2.*M_PI/m_params.L); //0.5;
Expand Down Expand Up @@ -281,7 +281,7 @@ inline void RandomField::calc_spectrum()
}
}

//std::ofstream hkprint(m_data_path+"h-k-printed.dat");
//std::ofstream hkprint(m_params.print_path+"/h-k-printed.dat");
//hkprint << std::fixed << setprecision(12);

for(int i=0; i<N; i++) for(int j=0; j<N; j++) for(int k=0; k<=N/2; k++)
Expand Down Expand Up @@ -310,7 +310,7 @@ inline void RandomField::calc_spectrum()
fftw_execute(hij_plan[l]);
}

std::ofstream hijprint(m_data_path+"hij-printed.dat");
std::ofstream hijprint(m_params.print_path+"/hij-printed.dat");
hijprint << std::fixed << setprecision(15);

int Nc = m_params.N;
Expand Down Expand Up @@ -350,7 +350,7 @@ inline void RandomField::calc_spectrum()

if (m_spec_type == "position")
{
ofstream pert_chars(m_data_path+"IC-pert-level.dat");
ofstream pert_chars(m_params.print_path+"/IC-pert-level.dat");
if(!pert_chars) { MayDay::Error("Pert. IC characteristics file unopened."); }

pert_chars << "Planck mass scale: " << m_bkgd_params.m_pl << "\n";
Expand Down

0 comments on commit 3806a92

Please sign in to comment.