mirror of
https://github.com/OPM/opm-upscaling.git
synced 2026-08-26 13:07:11 -05:00
Prefer Std::Numbers::PI
We have C++20 now and can use the portable alternative to spelling out the value or using the Posix-only 'M_PI' macro.
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -82,13 +83,13 @@ namespace {
|
||||
|
||||
double u(const Vec& x)
|
||||
{
|
||||
const double pi = 3.14159265358979323846264338327950288;
|
||||
constexpr auto pi = std::numbers::pi;
|
||||
return std::sin(2*pi*x[0]) * std::cos(2*pi*x[1]) * x[2];
|
||||
}
|
||||
|
||||
double Lu(const Vec& x)
|
||||
{
|
||||
const double pi = 3.14159265358979323846264338327950288;
|
||||
constexpr auto pi = std::numbers::pi;
|
||||
return -2 * 2*pi * 2*pi * std::sin(2*pi*x[0]) * std::cos(2*pi*x[1]) * x[2];
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -58,10 +59,6 @@
|
||||
|
||||
using namespace Opm::Elasticity;
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI std::acos(-1.0)
|
||||
#endif
|
||||
|
||||
//! \brief Display the available command line parameters
|
||||
void syntax(char** argv)
|
||||
{
|
||||
@@ -176,7 +173,7 @@ void parseCommandLine(int argc, char** argv, Params& p)
|
||||
if (method == "none")
|
||||
p.method = UPSCALE_NONE;
|
||||
p.Emin = param.getDefault<double>("Emin",0.0);
|
||||
p.dip = param.getDefault<double>("dip_angle", M_PI/2);
|
||||
p.dip = param.getDefault<double>("dip_angle", std::numbers::pi/2);
|
||||
p.azimuth = param.getDefault<double>("azimuth_angle", 0.0);
|
||||
p.ctol = param.getDefault<double>("ctol",1.e-6);
|
||||
#ifndef HAVE_OLD_CPGRID_API
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
@@ -281,8 +282,8 @@ bool BoundaryGrid::cubicSolve(double eps, double A, double B, double C,
|
||||
if (W <= -epsmall && P < 0) {
|
||||
double FI = acos(-Q/sqrt(-P*P*P));
|
||||
X.push_back( 2*std::sqrt(-P)*std::cos(FI/3));
|
||||
X.push_back(-2*std::sqrt(-P)*std::cos((FI+M_PI)/3));
|
||||
X.push_back(-2*std::sqrt(-P)*std::cos((FI-M_PI)/3));
|
||||
X.push_back(-2*std::sqrt(-P)*std::cos((FI+std::numbers::pi)/3));
|
||||
X.push_back(-2*std::sqrt(-P)*std::cos((FI-std::numbers::pi)/3));
|
||||
} else if (std::fabs(W) < epsmall && Q < 0) {
|
||||
X.push_back(2*std::pow(-Q,1.f/3));
|
||||
X.push_back(-.5f*X[0]);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
@@ -65,11 +66,11 @@ namespace Opm
|
||||
}
|
||||
|
||||
private:
|
||||
double cmpval() const
|
||||
{
|
||||
const double pi = 3.14159265358979323846264338327950288;
|
||||
return centroid[(canon_pos/2 + 1)%3] + pi*centroid[(canon_pos/2 + 2)%3];
|
||||
}
|
||||
double cmpval() const
|
||||
{
|
||||
return centroid[(canon_pos/2 + 1)%3]
|
||||
+ std::numbers::pi*centroid[(canon_pos/2 + 2)%3];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user