Skip to content

Commit

Permalink
made domain resizing occur less frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
c-white committed May 22, 2022
1 parent f853126 commit 1ab5bf2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
56 changes: 36 additions & 20 deletions src/simulation_reader/simulation_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Blacklight simulation reader

// C++ headers
#include <cmath> // abs
#include <cstdio> // snprintf
#include <fstream> // ifstream
#include <ios> // ios_base
Expand Down Expand Up @@ -426,29 +427,44 @@ double SimulationReader::Read(int snapshot)
data_stream.seekg(1, std::ios_base::cur);
ConvertCoordinates();
}
if (simulation_coord == Coordinates::sks and x2f.n2 == 1 and
(x2f(0,0) != 0.0 or x2f(0,x2f.n1-1) != Math::pi))
}

// Check coordinates
if (first_time)
{
if (simulation_coord == Coordinates::sks and x2f.n2 == 1)
{
std::ostringstream message;
message.setf(std::ios_base::scientific);
message.precision(16);
message << "Changing theta range from [" << x2f(0,0) << ", " << x2f(0,x2f.n1-1);
message << "] to [0, pi].";
BlacklightWarning(message.str().c_str());
x2f(0,0) = 0.0;
x2f(0,x2f.n1-1) = Math::pi;
bool error_low = std::abs(x2f(0,0)) > (x2f(0,1) - x2f(0,0)) * angular_domain_tolerance;
bool error_high = std::abs(x2f(0,x2f.n1-1) - Math::pi)
> (x2f(0,x2f.n1-1) - x2f(0,x2f.n1-2)) * angular_domain_tolerance;
if (error_low or error_high)
{
std::ostringstream message;
message.setf(std::ios_base::scientific);
message.precision(16);
message << "Changing theta range from [" << x2f(0,0) << ", " << x2f(0,x2f.n1-1);
message << "] to [0, pi].";
BlacklightWarning(message.str().c_str());
x2f(0,0) = 0.0;
x2f(0,x2f.n1-1) = Math::pi;
}
}
if (simulation_coord == Coordinates::sks and x3f.n2 == 1 and
(x3f(0,0) != 0.0 or x3f(0,x3f.n1-1) != 2.0 * Math::pi))
if (simulation_coord == Coordinates::sks and x3f.n2 == 1)
{
std::ostringstream message;
message.setf(std::ios_base::scientific);
message.precision(16);
message << "Changing phi range from [" << x3f(0,0) << ", " << x3f(0,x3f.n1-1);
message << "] to [0, 2*pi].";
BlacklightWarning(message.str().c_str());
x3f(0,0) = 0.0;
x3f(0,x3f.n1-1) = 2.0 * Math::pi;
bool error_low = std::abs(x3f(0,0)) > (x3f(0,1) - x3f(0,0)) * angular_domain_tolerance;
bool error_high = std::abs(x3f(0,x3f.n1-1) - 2.0 * Math::pi)
> (x3f(0,x3f.n1-1) - x3f(0,x3f.n1-2)) * angular_domain_tolerance;
if (error_low or error_high)
{
std::ostringstream message;
message.setf(std::ios_base::scientific);
message.precision(16);
message << "Changing phi range from [" << x3f(0,0) << ", " << x3f(0,x3f.n1-1);
message << "] to [0, 2*pi].";
BlacklightWarning(message.str().c_str());
x3f(0,0) = 0.0;
x3f(0,x3f.n1-1) = 2.0 * Math::pi;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/simulation_reader/simulation_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct SimulationReader
int num_arrays;
int latest_file_number;
const double extrapolation_tolerance = 1.0;
const double angular_domain_tolerance = 0.1;

// Data
int n_3_root;
Expand Down

0 comments on commit 1ab5bf2

Please sign in to comment.