Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/global/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,6 @@ bool Old_Style_Parse_Param(const char *name, const char *value, struct Parameter
} else if (strcmp(name, "prng_seed") == 0) {
parms->prng_seed = atoi(value);
#endif // PARTICLES
#ifdef ROTATED_PROJECTION
} else if (strcmp(name, "nxr") == 0) {
parms->nxr = atoi(value);
} else if (strcmp(name, "nzr") == 0) {
parms->nzr = atoi(value);
} else if (strcmp(name, "delta") == 0) {
parms->delta = atof(value);
} else if (strcmp(name, "theta") == 0) {
parms->theta = atof(value);
} else if (strcmp(name, "phi") == 0) {
parms->phi = atof(value);
} else if (strcmp(name, "Lx") == 0) {
parms->Lx = atof(value);
} else if (strcmp(name, "Lz") == 0) {
parms->Lz = atof(value);
} else if (strcmp(name, "n_delta") == 0) {
parms->n_delta = atoi(value);
} else if (strcmp(name, "ddelta_dt") == 0) {
parms->ddelta_dt = atof(value);
} else if (strcmp(name, "flag_delta") == 0) {
parms->flag_delta = atoi(value);
#endif /*ROTATED_PROJECTION*/
#ifdef TILED_INITIAL_CONDITIONS
} else if (strcmp(name, "tile_length") == 0) {
parms->tile_length = atof(value);
Expand Down
13 changes: 0 additions & 13 deletions src/global/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,6 @@ struct Parameters {
char sw_filename[MAXLEN];
#endif
#endif
#ifdef ROTATED_PROJECTION
// initialize rotation parameters to zero
int nxr;
int nzr;
Real delta = 0;
Real theta = 0;
Real phi = 0;
Real Lx;
Real Lz;
int n_delta = 0;
Real ddelta_dt = 0;
int flag_delta = 0;
#endif /*ROTATED_PROJECTION*/
#ifdef COSMOLOGY
Real H0;
Real Omega_M;
Expand Down
35 changes: 0 additions & 35 deletions src/grid/grid3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,41 +213,6 @@ void Grid3D::Initialize(struct Parameters *P)
// allocate memory
AllocateMemory();

#ifdef ROTATED_PROJECTION
// x-dir pixels in projection
R.nx = P->nxr;
// z-dir pixels in projection
R.nz = P->nzr;
// minimum x location to project
R.nx_min = 0;
// minimum z location to project
R.nz_min = 0;
// maximum x location to project
R.nx_max = R.nx;
// maximum z location to project
R.nz_max = R.nz;
// rotation angle about z direction
R.delta = M_PI * (P->delta / 180.); // convert to radians
// rotation angle about x direction
R.theta = M_PI * (P->theta / 180.); // convert to radians
// rotation angle about y direction
R.phi = M_PI * (P->phi / 180.); // convert to radians
// x-dir physical size of projection
R.Lx = P->Lx;
// z-dir physical size of projection
R.Lz = P->Lz;
// initialize a counter for rotated outputs
R.i_delta = 0;
// number of rotated outputs in a complete revolution
R.n_delta = P->n_delta;
// rate of rotation between outputs, for an actual simulation
R.ddelta_dt = P->ddelta_dt;
// are we not rotating about z(0)?
// are we outputting multiple rotations(1)? or rotating during a
// simulation(2)?
R.flag_delta = P->flag_delta;
#endif /*ROTATED_PROJECTION*/

// Values for lower limit for density and temperature
#ifdef TEMPERATURE_FLOOR
H.temperature_floor = P->temperature_floor;
Expand Down
74 changes: 7 additions & 67 deletions src/grid/grid3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,67 +50,11 @@
#include "../analysis/analysis.h"
#endif

struct Rotation {
/*! \var nx
* \brief Number of pixels in x-dir of rotated, projected image*/
int nx;

/*! \var nz
* \brief Number of pixels in z-dir of rotated, projected image*/
int nz;

/*! \var nx_min
* \brief Left most point in the projected image for this subvolume*/
int nx_min;

/*! \var nx_max
* \brief Right most point in the projected image for this subvolume*/
int nx_max;

/*! \var nz_min
* \brief Bottom most point in the projected image for this subvolume*/
int nz_min;

/*! \var nz_max
* \brief Top most point in the projected image for this subvolume*/
int nz_max;

/*! \var delta
* \brief Rotation angle about z axis in simulation frame*/
Real delta;

/*! \var theta
* \brief Rotation angle about x axis in simulation frame*/
Real theta;

/*! \var phi
* \brief Rotation angle about y axis in simulation frame*/
Real phi;

/*! \var Lx
* \brief Physical x-dir size of projected image*/
Real Lx;

/*! \var Lz
* \brief Physical z-dir size of projected image*/
Real Lz;

/*! \var i_delta
* \brief number of output projection for delta rotation*/
int i_delta;

/*! \var n_delta
* \brief total number of output projection for delta rotation*/
Real n_delta;

/*! \var ddelta_dt
* \brief rate of delta rotation*/
Real ddelta_dt;

/*! \var flag_delta
* \brief output mode for box rotation*/
int flag_delta;
};
// forward-declare the Rotation struct
namespace io
{
struct Rotation;
}

struct Header {
/*! \var n_cells
Expand Down Expand Up @@ -293,10 +237,6 @@ class Grid3D
* \brief Header for the grid */
struct Header H;

/*! \var struct Rotation R
* \brief Rotation struct for data projections */
struct Rotation R;

#ifdef GRAVITY
// Object that contains data for gravity
Grav3D Grav;
Expand Down Expand Up @@ -508,12 +448,12 @@ class Grid3D
/*! \fn void Write_Header_Rotated_HDF5(hid_t file_id)
* \brief Write the relevant header info to the HDF5 file for rotated
* projection. */
void Write_Header_Rotated_HDF5(hid_t file_id);
void Write_Header_Rotated_HDF5(hid_t file_id, io::Rotation &R);

/*! \fn void Write_Rotated_Projection_HDF5(hid_t file_id)
* \brief Write rotated projected data to a file, at the current simulation
* time. */
void Write_Rotated_Projection_HDF5(hid_t file_id);
void Write_Rotated_Projection_HDF5(hid_t file_id, const io::Rotation &R);

/*! \fn void Write_Slices_HDF5(hid_t file_id)
* \brief Write xy, xz, and yz slices of all data to a file. */
Expand Down
20 changes: 14 additions & 6 deletions src/io/FnameTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "../io/FnameTemplate.h"

#include <filesystem>
#include <sstream>
#include <string>

std::string FnameTemplate::effective_output_dir_path(int nfile) const noexcept
{
Expand All @@ -24,18 +26,19 @@ std::string FnameTemplate::effective_output_dir_path(int nfile) const noexcept
}
}

std::string FnameTemplate::format_fname(int nfile, const std::string &pre_extension_suffix) const noexcept
std::string FnameTemplate::format_fname(int nfile, std::string_view pre_extension_suffix,
std::optional<std::string_view> post_extension_suffix) const noexcept
{
#ifdef MPI_CHOLLA
int file_proc_id = procID;
#else
int file_proc_id = 0;
#endif
return format_fname(nfile, file_proc_id, pre_extension_suffix);
return format_fname(nfile, file_proc_id, pre_extension_suffix, post_extension_suffix);
}

std::string FnameTemplate::format_fname(int nfile, int file_proc_id,
const std::string &pre_extension_suffix) const noexcept
std::string FnameTemplate::format_fname(int nfile, int file_proc_id, std::string_view pre_extension_suffix,
std::optional<std::string_view> post_extension_suffix) const noexcept
{
// get the leading section of the string
const std::string path_prefix =
Expand All @@ -52,7 +55,12 @@ std::string FnameTemplate::format_fname(int nfile, int file_proc_id,
const char *extension = ".txt";
#endif

std::string procID_part = "." + std::to_string(file_proc_id); // initialized to empty string
std::stringstream s;

return path_prefix + std::to_string(nfile) + pre_extension_suffix + extension + procID_part;
s << path_prefix << std::to_string(nfile) << pre_extension_suffix << extension;
if (post_extension_suffix.has_value()) {
s << '.' << *post_extension_suffix;
}
s << '.' << std::to_string(file_proc_id);
return s.str();
}
8 changes: 6 additions & 2 deletions src/io/FnameTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#pragma once

#include <optional>
#include <string>
#include <string_view>

#include "../io/ParameterMap.h"

Expand Down Expand Up @@ -58,9 +60,11 @@ class FnameTemplate
std::string effective_output_dir_path(int nfile) const noexcept;

/* format the file path */
std::string format_fname(int nfile, const std::string& pre_extension_suffix) const noexcept;
std::string format_fname(int nfile, std::string_view pre_extension_suffix,
std::optional<std::string_view> post_extension_suffix = std::nullopt) const noexcept;

std::string format_fname(int nfile, int file_proc_id, const std::string& pre_extension_suffix) const noexcept;
std::string format_fname(int nfile, int file_proc_id, std::string_view pre_extension_suffix,
std::optional<std::string_view> post_extension_suffix = std::nullopt) const noexcept;

private:
bool separate_cycle_dirs_;
Expand Down
Loading