Skip to content

Commit 852f927

Browse files
lzpelpaulromano
andauthored
Fix M_PI being unavailable where _USE_MATH_DEFINES comes too late (#4023)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 61c8a59 commit 852f927

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎examples/custom_source/source_ring.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define _USE_MATH_DEFINES
12
#include <cmath> // for M_PI
23
#include <memory> // for unique_ptr
34

‎examples/parameterized_custom_source/parameterized_source_ring.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define _USE_MATH_DEFINES
12
#include <cmath>
23
#include <memory>
34
#include <unordered_map>

‎src/external/quartic_solver.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <algorithm>
21
#define _USE_MATH_DEFINES // to make M_PI declared in Intel and MSVC compilers
2+
#include <algorithm>
33
#include <cmath>
44
#include <complex>
55
#include <cstdlib>

‎src/mesh.cpp‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "openmc/mesh.h"
22
#include <algorithm> // for copy, equal, min, min_element
33
#include <cassert>
4-
#include <cstdint> // for uint64_t
5-
#include <cstring> // for memcpy
6-
#define _USE_MATH_DEFINES // to make M_PI declared in Intel and MSVC compilers
7-
#include <cmath> // for ceil
8-
#include <cstddef> // for size_t
4+
#include <cmath> // for ceil
5+
#include <cstddef> // for size_t
6+
#include <cstdint> // for uint64_t
7+
#include <cstring> // for memcpy
98
#include <limits>
109
#include <numeric> // for accumulate
1110
#include <string>
@@ -1829,7 +1828,7 @@ StructuredMesh::MeshIndex CylindricalMesh::get_indices(
18291828
} else {
18301829
mapped_r[1] = std::atan2(r.y, r.x);
18311830
if (mapped_r[1] < 0)
1832-
mapped_r[1] += 2 * M_PI;
1831+
mapped_r[1] += 2 * PI;
18331832
}
18341833

18351834
MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh);
@@ -2123,7 +2122,7 @@ StructuredMesh::MeshIndex SphericalMesh::get_indices(
21232122
mapped_r[1] = std::acos(r.z / mapped_r.x);
21242123
mapped_r[2] = std::atan2(r.y, r.x);
21252124
if (mapped_r[2] < 0)
2126-
mapped_r[2] += 2 * M_PI;
2125+
mapped_r[2] += 2 * PI;
21272126
}
21282127

21292128
MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh);

‎src/plot.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "openmc/plot.h"
22

33
#include <algorithm>
4-
#define _USE_MATH_DEFINES // to make M_PI declared in Intel and MSVC compilers
54
#include <cmath>
65
#include <cstdio>
76
#include <fstream>
@@ -1328,7 +1327,7 @@ std::pair<Position, Direction> RayTracePlot::get_pixel_ray(
13281327
int horiz, int vert) const
13291328
{
13301329
// Compute field of view in radians
1331-
constexpr double DEGREE_TO_RADIAN = M_PI / 180.0;
1330+
constexpr double DEGREE_TO_RADIAN = PI / 180.0;
13321331
double horiz_fov_radians = horizontal_field_of_view_ * DEGREE_TO_RADIAN;
13331332
double p0 = static_cast<double>(pixels()[0]);
13341333
double p1 = static_cast<double>(pixels()[1]);

0 commit comments

Comments
 (0)