Skip to content
Draft
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
5 changes: 2 additions & 3 deletions massive_star/init_1d.H
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ AMREX_INLINE void init_1d() {
// are mapping onto, and then we want to force it into HSE on that
// mesh.

std::cout << "here " << problem_rp::nx << " " << NPTS_MODEL << std::endl;

if (problem_rp::nx > NPTS_MODEL) {
amrex::Error("too many zones requested -- increase NPTS_MODEL");
}
Expand Down Expand Up @@ -131,6 +129,7 @@ AMREX_INLINE void init_1d() {

std::ofstream of;
of.open("model.orig");
// note the rows will be in reversed order if input file is descending in radius

of << "# initial model as read in" << std::endl;

Expand All @@ -153,7 +152,7 @@ AMREX_INLINE void init_1d() {
Real M_total = (4.0_rt / 3.0_rt) * M_PI * std::pow(initial_model.r(0), 3) *
initial_model.state(0, model::idens);

for (int i = 1; i < initial_model.npts-1; ++i) {
for (int i = 1; i < initial_model.npts; ++i) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed off-by-one error here. didn't impact anything else, just listed total mass


// integrate 4pi r**2 rho using trapezoid

Expand Down
22 changes: 22 additions & 0 deletions read_model.H
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ read_file(const std::string filename, initial_model_t& initial_model) {
initial_model.npts = i;

mf.close();

// ensure model is in order of ascending radius, not descending
if (initial_model.r(initial_model.npts-1) < initial_model.r(0)) {
amrex::Array2D<amrex::Real, 0, NPTS_MODEL-1, 0, model::nvar-1> state_copy;
amrex::Array1D<amrex::Real, 0, NPTS_MODEL-1> r_copy;

for (int i = 0; i < initial_model.npts; ++i){ // copy
r_copy(i) = initial_model.r(i);
for (int j = 0; j < model::nvar; ++j) {
state_copy(i,j) = initial_model.state(i,j);
std::cout << state_copy(i,j) << " ";
}
}
std::cout << std::endl << "compared to:" << std::endl;
for (int i = 0; i < initial_model.npts; ++i){ // reverse
initial_model.r(i) = r_copy(initial_model.npts-1-i);
for (int j = 0; j < model::nvar; ++j) {
//std::cout << state_copy(i,j) << " "; //THIS LINE CAUSES SEGFAULT IF UNCOMMENTED
//initial_model.state(i,j) = state_copy(initial_model.npts-1-i,j);
}
}
}
}

#endif