Commit 1dcf2fb3 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: use ""_deg user-literal for degrees to radians conversion

ENH: add degToRad() multiplier (useful for scalar fields)

- use degToRad() functions throughout instead of scattered local solutions
parent 287deeb2
......@@ -34,6 +34,7 @@ License
#include "fvcFlux.H"
#include "fvcMeshPhi.H"
#include "surfaceInterpolate.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -43,10 +44,6 @@ namespace Foam
}
const Foam::scalar Foam::multiphaseMixtureThermo::convertToRad =
Foam::constant::mathematical::pi/180.0;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::multiphaseMixtureThermo::calcAlphas()
......@@ -855,7 +852,7 @@ void Foam::multiphaseMixtureThermo::correctContactAngle
bool matched = (tp.key().first() == alpha1.name());
scalar theta0 = convertToRad*tp().theta0(matched);
const scalar theta0 = degToRad(tp().theta0(matched));
scalarField theta(boundary[patchi].size(), theta0);
scalar uTheta = tp().uTheta();
......@@ -863,8 +860,8 @@ void Foam::multiphaseMixtureThermo::correctContactAngle
// Calculate the dynamic contact angle if required
if (uTheta > SMALL)
{
scalar thetaA = convertToRad*tp().thetaA(matched);
scalar thetaR = convertToRad*tp().thetaR(matched);
const scalar thetaA = degToRad(tp().thetaA(matched));
const scalar thetaR = degToRad(tp().thetaR(matched));
// Calculated the component of the velocity parallel to the wall
vectorField Uwall
......
......@@ -144,9 +144,6 @@ private:
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Private member functions
......
......@@ -30,12 +30,7 @@ License
#include "fvcDiv.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
const Foam::scalar Foam::threePhaseInterfaceProperties::convertToRad =
Foam::constant::mathematical::pi/180.0;
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -83,7 +78,7 @@ void Foam::threePhaseInterfaceProperties::correctContactAngle
scalarField theta
(
convertToRad
degToRad()
* (
twoPhaseAlpha2*(180 - a2cap.theta(U[patchi], nHatp))
+ twoPhaseAlpha3*(180 - a3cap.theta(U[patchi], nHatp))
......
......@@ -91,10 +91,6 @@ class threePhaseInterfaceProperties
public:
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Constructors
//- Construct from volume fraction field alpha and IOdictionary
......
......@@ -35,12 +35,7 @@ License
#include "fvcDiv.H"
#include "fvcFlux.H"
#include "fvcAverage.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
const Foam::scalar Foam::multiphaseSystem::convertToRad =
Foam::constant::mathematical::pi/180.0;
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -290,7 +285,7 @@ void Foam::multiphaseSystem::correctContactAngle
bool matched = (tp.key().first() == phase1.name());
scalar theta0 = convertToRad*tp().theta0(matched);
const scalar theta0 = degToRad(tp().theta0(matched));
scalarField theta(boundary[patchi].size(), theta0);
scalar uTheta = tp().uTheta();
......@@ -298,8 +293,8 @@ void Foam::multiphaseSystem::correctContactAngle
// Calculate the dynamic contact angle if required
if (uTheta > SMALL)
{
scalar thetaA = convertToRad*tp().thetaA(matched);
scalar thetaR = convertToRad*tp().thetaR(matched);
const scalar thetaA = degToRad(tp().thetaA(matched));
const scalar thetaR = degToRad(tp().thetaR(matched));
// Calculated the component of the velocity parallel to the wall
vectorField Uwall
......
......@@ -187,9 +187,6 @@ private:
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Private member functions
......
......@@ -33,12 +33,7 @@ License
#include "fvcSnGrad.H"
#include "fvcDiv.H"
#include "fvcFlux.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
const Foam::scalar Foam::multiphaseMixture::convertToRad =
Foam::constant::mathematical::pi/180.0;
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -456,7 +451,7 @@ void Foam::multiphaseMixture::correctContactAngle
bool matched = (tp.key().first() == alpha1.name());
scalar theta0 = convertToRad*tp().theta0(matched);
const scalar theta0 = degToRad(tp().theta0(matched));
scalarField theta(boundary[patchi].size(), theta0);
scalar uTheta = tp().uTheta();
......@@ -464,8 +459,8 @@ void Foam::multiphaseMixture::correctContactAngle
// Calculate the dynamic contact angle if required
if (uTheta > SMALL)
{
scalar thetaA = convertToRad*tp().thetaA(matched);
scalar thetaR = convertToRad*tp().thetaR(matched);
const scalar thetaA = degToRad(tp().thetaA(matched));
const scalar thetaR = degToRad(tp().thetaR(matched));
// Calculated the component of the velocity parallel to the wall
vectorField Uwall
......
......@@ -154,9 +154,6 @@ private:
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Private member functions
......
......@@ -40,6 +40,8 @@ License
#include "fvmLaplacian.H"
#include "fvmSup.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
namespace Foam
......@@ -48,9 +50,6 @@ namespace Foam
defineRunTimeSelectionTable(multiphaseSystem, dictionary);
}
const Foam::scalar Foam::multiphaseSystem::convertToRad =
Foam::constant::mathematical::pi/180.0;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -399,7 +398,7 @@ void Foam::multiphaseSystem::correctContactAngle
bool matched = (tp.key().first() == phase1.name());
scalar theta0 = convertToRad*tp().theta0(matched);
const scalar theta0 = degToRad(tp().theta0(matched));
scalarField theta(boundary[patchi].size(), theta0);
scalar uTheta = tp().uTheta();
......@@ -407,8 +406,8 @@ void Foam::multiphaseSystem::correctContactAngle
// Calculate the dynamic contact angle if required
if (uTheta > SMALL)
{
scalar thetaA = convertToRad*tp().thetaA(matched);
scalar thetaR = convertToRad*tp().thetaR(matched);
const scalar thetaA = degToRad(tp().thetaA(matched));
const scalar thetaR = degToRad(tp().thetaR(matched));
// Calculated the component of the velocity parallel to the wall
vectorField Uwall
......
......@@ -65,9 +65,6 @@ class multiphaseSystem
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Private member functions
......
......@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
fileName pointsFile(runTime.constantPath()/"points.tmp");
OFstream pFile(pointsFile);
scalar a(degToRad(0.1));
const scalar a = 0.1_deg;
tensor rotateZ =
tensor
(
......
......@@ -419,7 +419,7 @@ if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
{
// Distribute the points to be +/- 2.5deg from the x-z plane
scalar tanTheta = Foam::tan(degToRad(2.5));
const scalar tanTheta = Foam::tan(2.5_deg);
SLList<face>::iterator iterf = pFaces[WEDGE][0].begin();
SLList<face>::iterator iterb = pFaces[WEDGE][1].begin();
......
......@@ -33,10 +33,10 @@ License
using namespace Foam::vectorTools;
const Foam::scalar Foam::conformalVoronoiMesh::searchConeAngle
= Foam::cos(degToRad(30));
= Foam::cos(30.0_deg);
const Foam::scalar Foam::conformalVoronoiMesh::searchAngleOppositeSurface
= Foam::cos(degToRad(150));
= Foam::cos(150.0_deg);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
......
......@@ -53,6 +53,18 @@ inline constexpr scalar radToDeg(const scalar rad) noexcept
return (rad*180.0/M_PI);
}
//- Multiplication factor for degrees to radians conversion
inline constexpr scalar degToRad() noexcept
{
return (M_PI/180.0);
}
//- Multiplication factor for radians to degrees conversion
inline constexpr scalar radToDeg() noexcept
{
return (180.0/M_PI);
}
//- Conversion from atm to Pa
inline constexpr scalar atmToPa(const scalar atm) noexcept
{
......
......@@ -43,7 +43,7 @@ namespace Foam
}
// Angle for polys to be considered splitHexes.
const Foam::scalar Foam::topoCellLooper::featureCos = Foam::cos(degToRad(10.0));
const Foam::scalar Foam::topoCellLooper::featureCos = Foam::cos(10.0_deg);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -184,7 +184,7 @@ Foam::undoableMeshCutter::undoableMeshCutter
faceRemover_
(
mesh,
Foam::cos(degToRad(30.0))
Foam::cos(30.0_deg)
)
{}
......
......@@ -204,7 +204,7 @@ Foam::targetCoeffTrim::targetCoeffTrim
nIter_(50),
tol_(1e-8),
relax_(1.0),
dTheta_(degToRad(0.1)),
dTheta_(0.1_deg),
alpha_(1.0)
{
read(dict);
......
......@@ -178,12 +178,12 @@ void Foam::lumpedPointState::relax
if (prev.degrees_)
{
// Was degrees, now radians
convert = degToRad(1);
convert = degToRad();
}
else
{
// Was radians, now degrees
convert = radToDeg(1);
convert = radToDeg();
}
}
......
......@@ -148,14 +148,14 @@ Foam::label Foam::meshRefinement::createBaffle
// {
// return true;
// }
// else if (mag(n1&n2) > cos(degToRad(30)))
// else if (mag(n1&n2) > cos(30.0_deg))
// {
// // Both normals aligned. Check that test vector perpendicularish to
// // surface normal
// scalar magTestDir = mag(testDir);
// if (magTestDir > VSMALL)
// {
// if (mag(n1&(testDir/magTestDir)) < cos(degToRad(45)))
// if (mag(n1&(testDir/magTestDir)) < cos(45.0_deg))
// {
// //Pout<< "** disabling baffling face "
// // << mesh_.faceCentres()[faceI] << endl;
......
......@@ -526,7 +526,7 @@ Foam::label Foam::meshRefinement::markSurfaceGapRefinement
// const indexedOctree<treeDataTriSurface>& tree = s.tree();
//
//
// const scalar searchCos(Foam::cos(degToRad(30)));
// const scalar searchCos = Foam::cos(30.0_deg);
//
// // Normals for ray shooting and inside/outside detection
// vectorField nearNormal;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment