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
This commit is contained in:
Mark Olesen 2017-07-04 15:36:46 +02:00
parent f55c568f13
commit 6a0a8b99b3
31 changed files with 60 additions and 93 deletions

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
(

View File

@ -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();

View File

@ -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 * * * * * * * * * * * * //

View File

@ -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
{

View File

@ -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 * * * * * * * * * * * //

View File

@ -184,7 +184,7 @@ Foam::undoableMeshCutter::undoableMeshCutter
faceRemover_
(
mesh,
Foam::cos(degToRad(30.0))
Foam::cos(30.0_deg)
)
{}

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;

View File

@ -1632,7 +1632,7 @@ bool Foam::meshRefinement::isNormalGap
d /= magD;
// Check average normal with respect to intersection locations
if (mag(avg&d) > Foam::cos(degToRad(45)))
if (mag(avg&d) > Foam::cos(45.0_deg))
{
return true;
}

View File

@ -1134,7 +1134,7 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine
// }
//}
const scalar oppositeCos = Foam::cos(Foam::degToRad(135));
const scalar oppositeCos = Foam::cos(135.0_deg);
forAllConstIter(cellSet, transitionCells, iter)
{
@ -1861,8 +1861,8 @@ void Foam::snappyRefineDriver::mergePatchFaces
{
meshRefiner_.mergePatchFacesUndo
(
Foam::cos(degToRad(45.0)),
Foam::cos(degToRad(45.0)),
Foam::cos(45.0_deg),
Foam::cos(45.0_deg),
meshRefiner_.meshedPatches(),
motionDict,
labelList(mesh.nFaces(), -1)
@ -1873,8 +1873,8 @@ void Foam::snappyRefineDriver::mergePatchFaces
// Still merge refined boundary faces if all four are on same patch
meshRefiner_.mergePatchFaces
(
Foam::cos(degToRad(45.0)),
Foam::cos(degToRad(45.0)),
Foam::cos(45.0_deg),
Foam::cos(45.0_deg),
4, // only merge faces split into 4
meshRefiner_.meshedPatches()
);
@ -1885,7 +1885,7 @@ void Foam::snappyRefineDriver::mergePatchFaces
meshRefiner_.checkData();
}
meshRefiner_.mergeEdgesUndo(Foam::cos(degToRad(45.0)), motionDict);
meshRefiner_.mergeEdgesUndo(Foam::cos(45.0_deg), motionDict);
if (debug)
{

View File

@ -1117,7 +1117,7 @@ void Foam::snappySnapDriver::detectNearSurfaces
//// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//{
// const scalar cos45 = Foam::cos(degToRad(45));
// const scalar cos45 = Foam::cos(45.0_deg);
// vector n(cos45, cos45, cos45);
// n /= mag(n);
//

View File

@ -2839,7 +2839,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures
// Detect baffle edges. Assume initial mesh will have 0,90 or 180
// (baffle) degree angles so smoothing should make 0,90
// to be less than 90. Choose reasonable value
const scalar baffleFeatureCos = Foam::cos(degToRad(110));
const scalar baffleFeatureCos = Foam::cos(110.0_deg);
autoPtr<OBJstream> baffleEdgeStr;

View File

@ -301,7 +301,7 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
scalar cosI = n1 & n2;
if (cosI > Foam::cos(degToRad(89.0)))
if (cosI > Foam::cos(89.0_deg))
{
faceIDs.append(nbrFacei);
}

View File

@ -85,8 +85,7 @@ Foam::extendedEdgeMesh::sideVolumeTypeNames_
};
Foam::scalar Foam::extendedEdgeMesh::cosNormalAngleTol_ =
Foam::cos(degToRad(0.1));
Foam::scalar Foam::extendedEdgeMesh::cosNormalAngleTol_ = Foam::cos(0.1_deg);
Foam::label Foam::extendedEdgeMesh::convexStart_ = 0;

View File

@ -55,7 +55,7 @@ Foam::topoSetSource::addToUsageTable Foam::shapeToCell::usage_
// Angle for polys to be considered splitHexes.
Foam::scalar Foam::shapeToCell::featureCos = Foam::cos(degToRad(10.0));
Foam::scalar Foam::shapeToCell::featureCos = Foam::cos(10.0_deg);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -41,10 +41,10 @@ License
namespace Foam
{
defineTypeNameAndDebug(edgeIntersections, 0);
scalar edgeIntersections::alignedCos_ = cos(degToRad(89.0));
}
Foam::scalar Foam::edgeIntersections::alignedCos_ = Foam::cos(89.0_deg);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -41,7 +41,7 @@ namespace Foam
{
defineTypeNameAndDebug(surfaceFeatures, 0);
const scalar surfaceFeatures::parallelTolerance = sin(degToRad(1.0));
const scalar surfaceFeatures::parallelTolerance = sin(1.0_deg);
//! \cond fileScope

View File

@ -30,12 +30,7 @@ License
#include "fvcDiv.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
const Foam::scalar Foam::interfaceProperties::convertToRad =
Foam::constant::mathematical::pi/180.0;
#include "unitConversion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -72,7 +67,7 @@ void Foam::interfaceProperties::correctContactAngle
fvsPatchVectorField& nHatp = nHatb[patchi];
const scalarField theta
(
convertToRad*acap.theta(U_.boundaryField()[patchi], nHatp)
degToRad() * acap.theta(U_.boundaryField()[patchi], nHatp)
);
const vectorField nf

View File

@ -96,10 +96,6 @@ class interfaceProperties
public:
//- Conversion factor for degrees into radians
static const scalar convertToRad;
// Constructors
//- Construct from volume fraction field gamma and IOdictionary