diff --git a/applications/solvers/combustion/dieselEngineFoam/createSpray.H b/applications/solvers/combustion/dieselEngineFoam/createSpray.H index ea4d0121b6..6b78689f09 100644 --- a/applications/solvers/combustion/dieselEngineFoam/createSpray.H +++ b/applications/solvers/combustion/dieselEngineFoam/createSpray.H @@ -30,7 +30,7 @@ scalar gasMass0 = fvc::domainIntegrate(rho).value(); if (dieselSpray.twoD()) { - gasMass0 *= 2.0*mathematicalConstant::pi/dieselSpray.angleOfWedge(); + gasMass0 *= constant::math::twoPi/dieselSpray.angleOfWedge(); } gasMass0 -= diff --git a/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C b/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C index e3f9c0b118..709b70f7a6 100644 --- a/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C +++ b/applications/solvers/combustion/dieselEngineFoam/dieselEngineFoam.C @@ -43,6 +43,7 @@ Description #include "OFstream.H" #include "volPointInterpolation.H" #include "thermoPhysicsTypes.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/combustion/dieselEngineFoam/spraySummary.H b/applications/solvers/combustion/dieselEngineFoam/spraySummary.H index 31337d0a77..2bacaa91ee 100644 --- a/applications/solvers/combustion/dieselEngineFoam/spraySummary.H +++ b/applications/solvers/combustion/dieselEngineFoam/spraySummary.H @@ -20,7 +20,7 @@ if (dieselSpray.twoD()) { - gasMass *= 2.0*mathematicalConstant::pi/dieselSpray.angleOfWedge(); + gasMass *= constant::math::twoPi/dieselSpray.angleOfWedge(); } scalar addedMass = gasMass - gasMass0; diff --git a/applications/solvers/combustion/dieselFoam/dieselFoam.C b/applications/solvers/combustion/dieselFoam/dieselFoam.C index 86460c1e9a..8d5dd0d9fa 100644 --- a/applications/solvers/combustion/dieselFoam/dieselFoam.C +++ b/applications/solvers/combustion/dieselFoam/dieselFoam.C @@ -41,6 +41,7 @@ Description #include "IFstream.H" #include "OFstream.H" #include "Switch.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/combustion/engineFoam/engineFoam.C b/applications/solvers/combustion/engineFoam/engineFoam.C index 9adf73cc67..8ff998217d 100644 --- a/applications/solvers/combustion/engineFoam/engineFoam.C +++ b/applications/solvers/combustion/engineFoam/engineFoam.C @@ -58,6 +58,7 @@ Description #include "ignition.H" #include "Switch.H" #include "OFstream.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index b2d007094e..276cac6ae0 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -28,7 +28,7 @@ License #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -182,7 +182,7 @@ void smoluchowskiJumpTFvPatchScalarField::updateCoeffs() } Field C2 = pmu/prho - *sqrt(ppsi*mathematicalConstant::pi/2.0) + *sqrt(ppsi*constant::math::piByTwo) *2.0*gamma_/Pr.value()/(gamma_ + 1.0) *(2.0 - accommodationCoeff_)/accommodationCoeff_; diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C index a087d0c964..7cf2ab1f25 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C @@ -28,7 +28,7 @@ Description #include "maxwellSlipUFvPatchVectorField.H" #include "addToRunTimeSelectionTable.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "surfaceFields.H" @@ -147,7 +147,7 @@ void maxwellSlipUFvPatchVectorField::updateCoeffs() const fvPatchField& ppsi = patch().lookupPatchField("psi"); - Field C1 = sqrt(ppsi*mathematicalConstant::pi/2.0) + Field C1 = sqrt(ppsi*constant::math::piByTwo) *(2.0 - accommodationCoeff_)/accommodationCoeff_; Field pnu = pmu/prho; diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C b/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C index 02d220138b..03e46a5c63 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "SchnerrSauer.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -77,7 +77,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::rRb { return pow ( - ((4*mathematicalConstant::pi*n_)/3) + ((4*constant::math::pi*n_)/3) *limitedAlpha1/(1.0 + alphaNuc() - limitedAlpha1), 1.0/3.0 ); @@ -87,7 +87,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::rRb Foam::dimensionedScalar Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::alphaNuc() const { - dimensionedScalar Vnuc = n_*mathematicalConstant::pi*pow3(dNuc_)/6; + dimensionedScalar Vnuc = n_*constant::math::pi*pow3(dNuc_)/6; return Vnuc/(1 + Vnuc); } diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C index 613dbfbaef..240207c8ab 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C @@ -29,11 +29,12 @@ License #include "Time.H" #include "subCycle.H" #include "fvCFD.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * // const scalar Foam::multiphaseMixture::convertToRad = - Foam::mathematicalConstant::pi/180.0; + Foam::constant::math::pi/180.0; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Gidaspow/GidaspowConductivity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Gidaspow/GidaspowConductivity.C index 5eb399afbf..fe24603713 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Gidaspow/GidaspowConductivity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Gidaspow/GidaspowConductivity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "GidaspowConductivity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -69,13 +69,13 @@ Foam::tmp Foam::GidaspowConductivity::kappa const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); return rhoa*da*sqrt(Theta)* ( 2.0*sqr(alpha)*g0*(1.0 + e)/sqrtPi + (9.0/8.0)*sqrtPi*g0*0.5*(1.0 + e)*sqr(alpha) - + (15.0/16.0)*sqrtPi*alpha + + (15.0/16.0)*sqrtPi*alpha + (25.0/64.0)*sqrtPi/((1.0 + e)*g0) ); } diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/HrenyaSinclair/HrenyaSinclairConductivity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/HrenyaSinclair/HrenyaSinclairConductivity.C index 3fdd409f5b..2d0acca9fa 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/HrenyaSinclair/HrenyaSinclairConductivity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/HrenyaSinclair/HrenyaSinclairConductivity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "HrenyaSinclairConductivity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -74,9 +74,9 @@ Foam::tmp Foam::HrenyaSinclairConductivity::kappa const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); - volScalarField lamda = + volScalarField lamda = scalar(1) + da/(6.0*sqrt(2.0)*(alpha + scalar(1.0e-5)))/L_; return rhoa*da*sqrt(Theta)* diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Syamlal/SyamlalConductivity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Syamlal/SyamlalConductivity.C index 8e555dd487..40c296f7e0 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Syamlal/SyamlalConductivity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/conductivityModel/Syamlal/SyamlalConductivity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "SyamlalConductivity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -69,7 +69,7 @@ Foam::tmp Foam::SyamlalConductivity::kappa const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); return rhoa*da*sqrt(Theta)* ( diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 5a6d4aa52d..dd3f345179 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -26,7 +26,7 @@ License #include "kineticTheoryModel.H" #include "surfaceInterpolate.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "fvCFD.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -204,7 +204,7 @@ void Foam::kineticTheoryModel::solve() volScalarField alpha = alpha_; alpha.max(1.0e-6); - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); surfaceScalarField phi = 1.5*rhoa_*phia_*fvc::interpolate(alpha_); diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Gidaspow/GidaspowViscosity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Gidaspow/GidaspowViscosity.C index b1a127e2e5..2a1c00b188 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Gidaspow/GidaspowViscosity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Gidaspow/GidaspowViscosity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "GidaspowViscosity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -70,7 +70,7 @@ Foam::kineticTheoryModels::GidaspowViscosity::mua const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); return rhoa*da*sqrt(Theta)* ( diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/HrenyaSinclair/HrenyaSinclairViscosity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/HrenyaSinclair/HrenyaSinclairViscosity.C index 8b43147895..b5e60e94c2 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/HrenyaSinclair/HrenyaSinclairViscosity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/HrenyaSinclair/HrenyaSinclairViscosity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "HrenyaSinclairViscosity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -77,7 +77,7 @@ Foam::kineticTheoryModels::HrenyaSinclairViscosity::mua const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); volScalarField lamda = scalar(1) + da/(6.0*sqrt(2.0)*(alpha + scalar(1.0e-5)))/L_; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Syamlal/SyamlalViscosity.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Syamlal/SyamlalViscosity.C index 28c2c56b07..892319df6c 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Syamlal/SyamlalViscosity.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/viscosityModel/Syamlal/SyamlalViscosity.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "SyamlalViscosity.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -69,7 +69,7 @@ Foam::tmp Foam::kineticTheoryModels::SyamlalViscosity::mua const dimensionedScalar& e ) const { - const scalar sqrtPi = sqrt(mathematicalConstant::pi); + const scalar sqrtPi = sqrt(constant::math::pi); return rhoa*da*sqrt(Theta)* ( diff --git a/applications/test/graphXi/graphXi.C b/applications/test/graphXi/graphXi.C index 2c3a5750f3..c717f6cc1f 100644 --- a/applications/test/graphXi/graphXi.C +++ b/applications/test/graphXi/graphXi.C @@ -32,7 +32,7 @@ Description #include "graph.H" #include "OFstream.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" using namespace Foam; @@ -50,7 +50,7 @@ int main() scalarField b = 0.5*(1.0 + erf(x)); scalarField c = 1.0 - b; - scalarField gradb = (1/::sqrt(mathematicalConstant::pi))*exp(-sqr(x)); + scalarField gradb = (1/::sqrt(constant::math::pi))*exp(-sqr(x)); scalarField lapb = -2*x*gradb; r = lapb*b*c/(gradb*gradb); diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index d4d6d11539..0905771d19 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C @@ -47,7 +47,7 @@ Description #include "polyTopoChanger.H" #include "polyMesh.H" #include "mapPolyMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "PackedBoolList.H" #include "SortableList.H" @@ -467,7 +467,7 @@ int main(int argc, char *argv[]) scalar angle(readScalar(IStringStream(args.additionalArgs()[1])())); bool overwrite = args.optionFound("overwrite"); - scalar maxCos = Foam::cos(angle*180/mathematicalConstant::pi); + scalar maxCos = Foam::cos(angle*180/constant::math::pi); Info<< "Merging:" << nl << " edges with length less than " << minLen << " meters" << nl diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 60c9439561..de7af2b077 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -53,7 +53,7 @@ Description #include "removePoints.H" #include "polyMesh.H" #include "mapPolyMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" using namespace Foam; @@ -445,12 +445,12 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); - scalar minCos = Foam::cos(featureAngle*mathematicalConstant::pi/180.0); + scalar minCos = Foam::cos(featureAngle*constant::math::pi/180.0); scalar concaveAngle = defaultConcaveAngle; args.optionReadIfPresent("concaveAngle", concaveAngle); - scalar concaveSin = Foam::sin(concaveAngle*mathematicalConstant::pi/180.0); + scalar concaveSin = Foam::sin(concaveAngle*constant::math::pi/180.0); bool snapMeshDict = args.optionFound("snapMesh"); bool overwrite = args.optionFound("overwrite"); diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C index 85afb3a771..1d9c0e5b54 100644 --- a/applications/utilities/mesh/advanced/splitCells/splitCells.C +++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C @@ -49,7 +49,7 @@ Description #include "cellSet.H" #include "cellModeller.H" #include "meshCutter.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "geomCellLooper.H" #include "plane.H" #include "edgeVertex.H" @@ -539,7 +539,7 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); - scalar radAngle = featureAngle * mathematicalConstant::pi/180.0; + scalar radAngle = featureAngle*constant::math::pi/180.0; scalar minCos = Foam::cos(radAngle); scalar minSin = Foam::sin(radAngle); diff --git a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C index 1da7ba049e..996cd67d4c 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C +++ b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C @@ -43,7 +43,7 @@ Description #include "symmetryPolyPatch.H" #include "wedgePolyPatch.H" #include "cyclicPolyPatch.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" using namespace Foam; diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index d315dce4a0..f1ec25a59c 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -223,7 +223,7 @@ const char* kivaPatchNames[nBCs] = "cylinderHead", "axis", "wedge", - "inflow", + "inflow", "outflow", "presin", "presout", @@ -434,7 +434,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(2.5*mathematicalConstant::pi/180.0); + scalar tanTheta = Foam::tan(2.5*constant::math::pi/180.0); SLList::iterator iterf = pFaces[WEDGE][0].begin(); SLList::iterator iterb = pFaces[WEDGE][1].begin(); diff --git a/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C index 2707469a6c..65dd5c952d 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C +++ b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C @@ -59,7 +59,7 @@ Usage #include "Time.H" #include "timeSelector.H" #include "fvMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "polyTopoChange.H" #include "mapPolyMesh.H" #include "PackedBoolList.H" @@ -91,7 +91,7 @@ void simpleMarkFeatures labelList& multiCellFeaturePoints ) { - scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0); + scalar minCos = Foam::cos(featureAngle*constant::math::pi/180.0); const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -387,7 +387,7 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); - scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0); + scalar minCos = Foam::cos(featureAngle*constant::math::pi/180.0); Info<< "Feature:" << featureAngle << endl << "minCos :" << minCos << endl diff --git a/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C b/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C index 910df915d8..0b135188e0 100644 --- a/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C +++ b/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C @@ -33,7 +33,7 @@ Description #include "IOmanip.H" #include "boundBox.H" #include "Map.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -99,7 +99,7 @@ void starMesh::createCoupleMatches() << coupleI << ". STAR couple ID: " << couples_[coupleI].coupleID() << endl << "The angle between face normals is " - << Foam::acos(faceAreaAngle)/mathematicalConstant::pi*180 + << Foam::acos(faceAreaAngle)/constant::math::pi*180 << " deg." << endl << "master cell: " << fp.masterCell() << " STAR number: " << starCellID_[fp.masterCell()] diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C index 886281274b..2039ffb0bb 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C @@ -29,7 +29,7 @@ Description \*---------------------------------------------------------------------------*/ #include "arcEdge.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -78,7 +78,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle() // find angles scalar tmp = (r3&r1)/(mag(r3)*mag(r1)); - angle_ = acos(tmp)*180.0/mathematicalConstant::pi; + angle_ = acos(tmp)*180.0/constant::math::pi; // check if the vectors define an exterior or an interior arcEdge if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) angle_ = 360 - angle_; @@ -162,7 +162,7 @@ Foam::vector Foam::arcEdge::position(const scalar lambda) const //- Return the length of the curve Foam::scalar Foam::arcEdge::length() const { - return angle_*radius_*mathematicalConstant::pi/180.0; + return angle_*radius_*constant::math::pi/180.0; } diff --git a/applications/utilities/mesh/generation/extrudeMesh/Make/options b/applications/utilities/mesh/generation/extrudeMesh/Make/options index ce0e27f401..1cdc68a2c7 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/Make/options +++ b/applications/utilities/mesh/generation/extrudeMesh/Make/options @@ -1,10 +1,14 @@ EXE_INC = \ -IextrudedMesh \ -IextrudeModel/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ + -lfiniteVolume \ + -lsurfMesh \ -lmeshTools \ -ldynamicMesh \ -lextrudeModel diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C index d149f85923..4d7d6bc81d 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C @@ -36,13 +36,14 @@ Description #include "Time.H" #include "dimensionedTypes.H" #include "IFstream.H" -#include "faceMesh.H" #include "polyTopoChange.H" #include "polyTopoChanger.H" #include "edgeCollapser.H" -#include "mathematicalConstants.H" #include "globalMeshData.H" #include "perfectInterface.H" +#include "addPatchCellLayer.H" +#include "fvMesh.H" +#include "MeshedSurfaces.H" #include "extrudedMesh.H" #include "extrudeModel.H" @@ -50,14 +51,148 @@ Description using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +enum ExtrudeMode +{ + MESH, + PATCH, + SURFACE +}; + +template<> +const char* NamedEnum::names[] = +{ + "mesh", + "patch", + "surface" +}; +static const NamedEnum ExtrudeModeNames; + + +void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName) +{ + // Create dummy system/fv* + { + IOobject io + ( + "fvSchemes", + mesh.time().system(), + regionName, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ); + + Info<< "Testing:" << io.objectPath() << endl; + + if (!io.headerOk()) + { + Info<< "Writing dummy " << regionName/io.name() << endl; + dictionary dummyDict; + dictionary divDict; + dummyDict.add("divSchemes", divDict); + dictionary gradDict; + dummyDict.add("gradSchemes", gradDict); + dictionary laplDict; + dummyDict.add("laplacianSchemes", laplDict); + + IOdictionary(io, dummyDict).regIOobject::write(); + } + } + { + IOobject io + ( + "fvSolution", + mesh.time().system(), + regionName, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ); + + if (!io.headerOk()) + { + Info<< "Writing dummy " << regionName/io.name() << endl; + dictionary dummyDict; + IOdictionary(io, dummyDict).regIOobject::write(); + } + } +} + + +label findPatchID(const polyBoundaryMesh& patches, const word& name) +{ + label patchID = patches.findPatchID(name); + + if (patchID == -1) + { + FatalErrorIn("findPatchID(const polyBoundaryMesh&, const word&)") + << "Cannot find patch " << name + << " in the source mesh.\n" + << "Valid patch names are " << patches.names() + << exit(FatalError); + } + return patchID; +} + + +labelList patchFaces(const polyBoundaryMesh& patches, const word& name) +{ + label patchID = findPatchID(patches, name); + const polyPatch& pp = patches[patchID]; + + return identity(pp.size()) + pp.start(); +} + + +void updateFaceLabels(const mapPolyMesh& map, labelList& faceLabels) +{ + const labelList& reverseMap = map.reverseFaceMap(); + + labelList newFaceLabels(faceLabels.size()); + label newI = 0; + + forAll(faceLabels, i) + { + label oldFaceI = faceLabels[i]; + + if (reverseMap[oldFaceI] >= 0) + { + newFaceLabels[newI++] = reverseMap[oldFaceI]; + } + } + newFaceLabels.setSize(newI); + faceLabels.transfer(newFaceLabels); +} + + + // Main program: int main(int argc, char *argv[]) { + #include "addRegionOption.H" #include "setRootCase.H" #include "createTimeExtruded.H" - autoPtr meshPtr(NULL); + // Get optional regionName + word regionName; + word regionDir; + if (args.optionReadIfPresent("region", regionName)) + { + regionDir = regionName; + Info<< "Create mesh " << regionName << " for time = " + << runTimeExtruded.timeName() << nl << endl; + } + else + { + regionName = fvMesh::defaultRegion; + Info<< "Create mesh for time = " + << runTimeExtruded.timeName() << nl << endl; + } + IOdictionary dict ( @@ -65,26 +200,44 @@ int main(int argc, char *argv[]) ( "extrudeProperties", runTimeExtruded.constant(), + regionDir, runTimeExtruded, IOobject::MUST_READ ) ); + // Point generator autoPtr model(extrudeModel::New(dict)); - const word sourceType(dict.lookup("constructFrom")); + // Whether to flip normals + const Switch flipNormals(dict.lookup("flipNormals")); - autoPtr fMesh; + // What to extrude + const ExtrudeMode mode = ExtrudeModeNames.read + ( + dict.lookup("constructFrom") + ); - if (sourceType == "patch") + + // Generated mesh (one of either) + autoPtr meshFromMesh; + autoPtr meshFromSurface; + + // Faces on front and back for stitching (in case of mergeFaces) + word frontPatchName; + labelList frontPatchFaces; + word backPatchName; + labelList backPatchFaces; + + if (mode == PATCH || mode == MESH) { fileName sourceCasePath(dict.lookup("sourceCase")); sourceCasePath.expand(); fileName sourceRootDir = sourceCasePath.path(); fileName sourceCaseDir = sourceCasePath.name(); - word patchName(dict.lookup("sourcePatch")); + dict.lookup("sourcePatch") >> frontPatchName; - Info<< "Extruding patch " << patchName + Info<< "Extruding patch " << frontPatchName << " on mesh " << sourceCasePath << nl << endl; @@ -94,31 +247,183 @@ int main(int argc, char *argv[]) sourceRootDir, sourceCaseDir ); - #include "createPolyMesh.H" + #include "createMesh.H" - label patchID = mesh.boundaryMesh().findPatchID(patchName); + const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (patchID == -1) + + // Topo change container. Either copy an existing mesh or start + // with empty storage (number of patches only needed for checking) + autoPtr meshMod + ( + ( + mode == MESH + ? new polyTopoChange(mesh) + : new polyTopoChange(patches.size()) + ) + ); + + // Extrusion engine. Either adding to existing mesh or + // creating separate mesh. + addPatchCellLayer layerExtrude(mesh, (mode == MESH)); + + indirectPrimitivePatch extrudePatch + ( + IndirectList + ( + mesh.faces(), + patchFaces(patches, frontPatchName) + ), + mesh.points() + ); + + // Only used for addPatchCellLayer into new mesh + labelList exposedPatchIDs; + if (mode == PATCH) { - FatalErrorIn(args.executable()) - << "Cannot find patch " << patchName - << " in the source mesh.\n" - << "Valid patch names are " << mesh.boundaryMesh().names() - << exit(FatalError); + dict.lookup("exposedPatchName") >> backPatchName; + exposedPatchIDs.setSize + ( + extrudePatch.size(), + findPatchID(patches, backPatchName) + ); } - const polyPatch& pp = mesh.boundaryMesh()[patchID]; - fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints())); + pointField layer0Points(extrudePatch.nPoints()); + pointField displacement(extrudePatch.nPoints()); + forAll(displacement, pointI) { - fileName surfName(runTime.path()/patchName + ".sMesh"); - Info<< "Writing patch as surfaceMesh to " - << surfName << nl << endl; - OFstream os(surfName); - os << fMesh() << nl; + const vector& patchNormal = extrudePatch.pointNormals()[pointI]; + + // layer0 point + layer0Points[pointI] = model() + ( + extrudePatch.localPoints()[pointI], + patchNormal, + 0 + ); + // layerN point + point extrudePt = model() + ( + extrudePatch.localPoints()[pointI], + patchNormal, + model().nLayers() + ); + displacement[pointI] = extrudePt - layer0Points[pointI]; } + + if (flipNormals) + { + Info<< "Flipping faces." << nl << endl; + displacement = -displacement; + } + + // Check if wedge (has layer0 different from original patch points) + // If so move the mesh to starting position. + if (gMax(mag(layer0Points-extrudePatch.localPoints())) > SMALL) + { + Info<< "Moving mesh to layer0 points since differ from original" + << " points - this can happen for wedge extrusions." << nl + << endl; + + pointField newPoints(mesh.points()); + forAll(extrudePatch.meshPoints(), i) + { + newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i]; + } + mesh.movePoints(newPoints); + } + + + // Layers per face + labelList nFaceLayers(extrudePatch.size(), model().nLayers()); + // Layers per point + labelList nPointLayers(extrudePatch.nPoints(), model().nLayers()); + // Displacement for first layer + vectorField firstLayerDisp = displacement*model().sumThickness(1); + // Expansion ratio not used. + scalarField ratio(extrudePatch.nPoints(), 1.0); + + layerExtrude.setRefinement + ( + ratio, // expansion ratio + extrudePatch, // patch faces to extrude + exposedPatchIDs, // if new mesh: patches for exposed faces + nFaceLayers, + nPointLayers, + firstLayerDisp, + meshMod() + ); + + // Reset points according to extrusion model + forAll(layerExtrude.addedPoints(), pointI) + { + const labelList& pPoints = layerExtrude.addedPoints()[pointI]; + forAll(pPoints, pPointI) + { + label meshPointI = pPoints[pPointI]; + + point modelPt + ( + model() + ( + extrudePatch.localPoints()[pointI], + extrudePatch.pointNormals()[pointI], + pPointI+1 // layer + ) + ); + + const_cast&> + ( + meshMod().points() + )[meshPointI] = modelPt; + } + } + + // Store faces on front and exposed patch (if mode=patch there are + // only added faces so cannot used map to old faces) + const labelListList& layerFaces = layerExtrude.layerFaces(); + backPatchFaces.setSize(layerFaces.size()); + frontPatchFaces.setSize(layerFaces.size()); + forAll(backPatchFaces, i) + { + backPatchFaces[i] = layerFaces[i][0]; + frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1]; + } + + // Create dummy fvSchemes, fvSolution + createDummyFvMeshFiles(mesh, regionDir); + + // Create actual mesh from polyTopoChange container + autoPtr map = meshMod().makeMesh + ( + meshFromMesh, + IOobject + ( + regionName, + runTimeExtruded.constant(), + runTimeExtruded, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + mesh + ); + + // Calculate face labels for front and back. + frontPatchFaces = renumber + ( + map().reverseFaceMap(), + frontPatchFaces + ); + backPatchFaces = renumber + ( + map().reverseFaceMap(), + backPatchFaces + ); } - else if (sourceType == "surface") + else { // Read from surface fileName surfName(dict.lookup("surface")); @@ -126,52 +431,62 @@ int main(int argc, char *argv[]) Info<< "Extruding surfaceMesh read from file " << surfName << nl << endl; - IFstream is(surfName); + MeshedSurface fMesh(surfName); - fMesh.reset(new faceMesh(is)); - - Info<< "Read patch from file " << surfName << nl - << endl; - } - else - { - FatalErrorIn(args.executable()) - << "Illegal 'constructFrom' specification. Should either be " - << "patch or surface." << exit(FatalError); - } - - Switch flipNormals(dict.lookup("flipNormals")); - - if (flipNormals) - { - Info<< "Flipping faces." << nl << endl; - - faceList faces(fMesh().size()); - forAll(faces, i) + if (flipNormals) { - faces[i] = fMesh()[i].reverseFace(); + Info<< "Flipping faces." << nl << endl; + faceList& faces = const_cast(fMesh.faces()); + forAll(faces, i) + { + faces[i] = fMesh[i].reverseFace(); + } } - fMesh.reset(new faceMesh(faces, fMesh().localPoints())); + + Info<< "Extruding surface with :" << nl + << " points : " << fMesh.points().size() << nl + << " faces : " << fMesh.size() << nl + << " normals[0] : " << fMesh.faceNormals()[0] + << nl + << endl; + + meshFromSurface.reset + ( + new extrudedMesh + ( + IOobject + ( + extrudedMesh::defaultRegion, + runTimeExtruded.constant(), + runTimeExtruded + ), + fMesh, + model() + ) + ); + + + // Get the faces on front and back + frontPatchName = "originalPatch"; + frontPatchFaces = patchFaces + ( + meshFromSurface().boundaryMesh(), + frontPatchName + ); + backPatchName = "otherSide"; + backPatchFaces = patchFaces + ( + meshFromSurface().boundaryMesh(), + backPatchName + ); } - Info<< "Extruding patch with :" << nl - << " points : " << fMesh().points().size() << nl - << " faces : " << fMesh().size() << nl - << " normals[0] : " << fMesh().faceNormals()[0] - << nl - << endl; - - extrudedMesh mesh + polyMesh& mesh = ( - IOobject - ( - extrudedMesh::defaultRegion, - runTimeExtruded.constant(), - runTimeExtruded - ), - fMesh(), - model() + meshFromMesh.valid() + ? meshFromMesh() + : meshFromSurface() ); @@ -184,17 +499,6 @@ int main(int argc, char *argv[]) << "Merge distance : " << mergeDim << nl << endl; - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - const label origPatchID = patches.findPatchID("originalPatch"); - const label otherPatchID = patches.findPatchID("otherSide"); - - if (origPatchID == -1 || otherPatchID == -1) - { - FatalErrorIn(args.executable()) - << "Cannot find patch originalPatch or otherSide." << nl - << "Valid patches are " << patches.names() << exit(FatalError); - } // Collapse edges // ~~~~~~~~~~~~~~ @@ -237,6 +541,10 @@ int main(int argc, char *argv[]) // Update fields mesh.updateMesh(map); + // Update stored data + updateFaceLabels(map(), frontPatchFaces); + updateFaceLabels(map(), backPatchFaces); + // Move mesh (if inflation used) if (map().hasMotionPoints()) { @@ -252,22 +560,33 @@ int main(int argc, char *argv[]) Switch mergeFaces(dict.lookup("mergeFaces")); if (mergeFaces) { + if (mode == MESH) + { + FatalErrorIn(args.executable()) + << "Cannot stitch front and back of extrusion since" + << " in 'mesh' mode (extrusion appended to mesh)." + << exit(FatalError); + } + Info<< "Assuming full 360 degree axisymmetric case;" << " stitching faces on patches " - << patches[origPatchID].name() << " and " - << patches[otherPatchID].name() << " together ..." << nl << endl; + << frontPatchName << " and " + << backPatchName << " together ..." << nl << endl; + + if (frontPatchFaces.size() != backPatchFaces.size()) + { + FatalErrorIn(args.executable()) + << "Differing number of faces on front (" + << frontPatchFaces.size() << ") and back (" + << backPatchFaces.size() << ")" + << exit(FatalError); + } + + polyTopoChanger stitcher(mesh); stitcher.setSize(1); - // Make list of masterPatch faces - labelList isf(patches[origPatchID].size()); - - forAll (isf, i) - { - isf[i] = patches[origPatchID].start() + i; - } - const word cutZoneName("originalCutFaceZone"); List fz @@ -276,8 +595,8 @@ int main(int argc, char *argv[]) new faceZone ( cutZoneName, - isf, - boolList(isf.size(), false), + frontPatchFaces, + boolList(frontPatchFaces.size(), false), 0, mesh.faceZones() ) @@ -286,26 +605,58 @@ int main(int argc, char *argv[]) mesh.addZones(List(0), fz, List(0)); // Add the perfect interface mesh modifier - stitcher.set + perfectInterface perfectStitcher ( + "couple", 0, - new perfectInterface - ( - "couple", - 0, - stitcher, - cutZoneName, - patches[origPatchID].name(), - patches[otherPatchID].name() - ) + stitcher, + cutZoneName, + word::null, // dummy patch name + word::null // dummy patch name ); - // Execute all polyMeshModifiers - autoPtr morphMap = stitcher.changeMesh(true); + // Topo change container + polyTopoChange meshMod(mesh); - mesh.movePoints(morphMap->preMotionPoints()); + perfectStitcher.setRefinement + ( + indirectPrimitivePatch + ( + IndirectList + ( + mesh.faces(), + frontPatchFaces + ), + mesh.points() + ), + indirectPrimitivePatch + ( + IndirectList + ( + mesh.faces(), + backPatchFaces + ), + mesh.points() + ), + meshMod + ); + + // Construct new mesh from polyTopoChange. + autoPtr map = meshMod.changeMesh(mesh, false); + + // Update fields + mesh.updateMesh(map); + + // Move mesh (if inflation used) + if (map().hasMotionPoints()) + { + mesh.movePoints(map().preMotionPoints()); + } } + mesh.setInstance(runTimeExtruded.constant()); + Info<< "Writing mesh to " << mesh.objectPath() << nl << endl; + if (!mesh.write()) { FatalErrorIn(args.executable()) << "Failed writing mesh" diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C index 7305431b96..5550c56b15 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.C @@ -43,6 +43,7 @@ Foam::extrudeModel::extrudeModel ) : nLayers_(readLabel(dict.lookup("nLayers"))), + expansionRatio_(readScalar(dict.lookup("expansionRatio"))), dict_(dict), coeffDict_(dict.subDict(modelType + "Coeffs")) {} @@ -62,5 +63,28 @@ Foam::label Foam::extrudeModel::nLayers() const } +Foam::scalar Foam::extrudeModel::expansionRatio() const +{ + return expansionRatio_; +} + + +Foam::scalar Foam::extrudeModel::sumThickness(const label layer) const +{ + // 1+r+r^2+ .. +r^(n-1) = (1-r^n)/(1-r) + + if (mag(1.0-expansionRatio_) < SMALL) + { + return scalar(layer)/nLayers_; + } + else + { + return + (1.0-pow(expansionRatio_, layer)) + / (1.0-pow(expansionRatio_, nLayers_)); + } +} + + // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H index d8f3699fd5..ac96bbeea6 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/extrudeModel/extrudeModel.H @@ -58,6 +58,8 @@ protected: const label nLayers_; + const scalar expansionRatio_; + const dictionary& dict_; const dictionary& coeffDict_; @@ -113,9 +115,15 @@ public: label nLayers() const; + scalar expansionRatio() const; + // Member Operators + //- Helper: calculate cumulative relative thickness for layer. + // (layer=0 -> 0; layer=nLayers -> 1) + scalar sumThickness(const label layer) const; + virtual point operator() ( const point& surfacePoint, diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C index c36098ab1e..cd42e91816 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.C @@ -72,7 +72,8 @@ point linearNormal::operator() const label layer ) const { - scalar d = thickness_*layer/nLayers_; + //scalar d = thickness_*layer/nLayers_; + scalar d = thickness_*sumThickness(layer); return surfacePoint + d*surfaceNormal; } diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H index 949547311b..2dbcdccb16 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearNormal/linearNormal.H @@ -64,7 +64,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary linearNormal(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C index e8d406b110..7d4fcff9ba 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.C @@ -67,8 +67,7 @@ point linearRadial::operator() scalar rs = mag(surfacePoint); vector rsHat = surfacePoint/rs; - scalar delta = (R_ - rs)/nLayers_; - scalar r = rs + layer*delta; + scalar r = rs + (R_ - rs)*sumThickness(layer); return r*rsHat; } diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H index 0fda12e1b1..66758c1b12 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/linearRadial/linearRadial.H @@ -61,7 +61,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary linearRadial(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C index fc6f040305..d35ad4e539 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.C @@ -49,7 +49,13 @@ sigmaRadial::sigmaRadial(const dictionary& dict) RTbyg_(readScalar(coeffDict_.lookup("RTbyg"))), pRef_(readScalar(coeffDict_.lookup("pRef"))), pStrat_(readScalar(coeffDict_.lookup("pStrat"))) -{} +{ + if (mag(expansionRatio() - 1.0) > SMALL) + { + WarningIn("sigmaRadial::sigmaRadial(const dictionary&)") + << "Ignoring expansionRatio setting." << endl; + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H index 525e89d11c..c74ad02457 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/sigmaRadial/sigmaRadial.H @@ -63,7 +63,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary sigmaRadial(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C index 3d2c883ea1..07ddf34eaf 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C @@ -26,7 +26,7 @@ License #include "wedge.H" #include "addToRunTimeSelectionTable.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,7 +52,7 @@ wedge::wedge(const dictionary& dict) angle_ ( readScalar(coeffDict_.lookup("angle")) - *mathematicalConstant::pi/180.0 + *constant::math::pi/180.0 ) {} @@ -88,8 +88,8 @@ point wedge::operator() } else { - //sliceAngle = angle_*(layer + 1)/nLayers_; - sliceAngle = angle_*layer/nLayers_; + //sliceAngle = angle_*layer/nLayers_; + sliceAngle = angle_*sumThickness(layer); } // Find projection onto axis (or rather decompose surfacePoint diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H index 39c4b4a2d3..18707c32d1 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.H @@ -77,7 +77,7 @@ public: // Constructors - //- Construct from components + //- Construct from dictionary wedge(const dictionary& dict); diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties index 45618034de..e1283ab8b5 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeProperties @@ -14,24 +14,28 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Where to get surface from: either from surface ('surface') or -// from (flipped) patch of existing case ('patch') -constructFrom patch; //surface; +// What to extrude: +// patch : from patch of another case ('sourceCase') +// mesh : as above but with original case included +// surface : from externally read surface -// If construct from (flipped) patch -sourceCase "$FOAM_RUN/icoFoam/cavity"; +//constructFrom mesh; +constructFrom patch; +//constructFrom surface; + +// If construct from patch/mesh: +sourceCase "../cavity"; sourcePatch movingWall; +// If construct from patch: patch to use for back (can be same as sourcePatch) +exposedPatchName movingWall; +// If construct from surface: +surface "movingWall.stl"; + + // Flip surface normals before usage. flipNormals false; -// If construct from surface -surface "movingWall.sMesh"; - - -// Do front and back need to be merged? Usually only makes sense for 360 -// degree wedges. -mergeFaces true; //- Linear extrusion in point-normal direction @@ -46,11 +50,13 @@ extrudeModel wedge; //- Extrudes into sphere with grading according to pressure (atmospherics) //extrudeModel sigmaRadial; -nLayers 20; +nLayers 10; + +expansionRatio 1.0; //0.9; wedgeCoeffs { - axisPt (0 0.1 0); + axisPt (0 0.1 -0.05); axis (-1 0 0); angle 360; // For nLayers=1 assume symmetry so angle/2 on each side } @@ -73,5 +79,10 @@ sigmaRadialCoeffs } +// Do front and back need to be merged? Usually only makes sense for 360 +// degree wedges. +mergeFaces true; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C index 758592590c..3c48f6d7d7 100644 --- a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C +++ b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C @@ -33,7 +33,7 @@ Description #include "Time.H" #include "boundaryMesh.H" #include "repatchPolyTopoChanger.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "OFstream.H" #include "ListOps.H" @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); bool overwrite = args.optionFound("overwrite"); - scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0); + scalar minCos = Foam::cos(featureAngle*constant::math::pi/180.0); Info<< "Feature:" << featureAngle << endl << "minCos :" << minCos << endl diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index 7d74e7208c..40ba0efade 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -208,8 +208,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh) // Dump halves { OFstream str(prefix+cycPatch.name()+"_half0.obj"); - Pout<< "Dumping cycPatch.name() half0 faces to " << str.name() - << endl; + Pout<< "Dumping " << cycPatch.name() + << " half0 faces to " << str.name() << endl; meshTools::writeOBJ ( str, @@ -226,8 +226,8 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh) } { OFstream str(prefix+cycPatch.name()+"_half1.obj"); - Pout<< "Dumping cycPatch.name() half1 faces to " << str.name() - << endl; + Pout<< "Dumping " << cycPatch.name() + << " half1 faces to " << str.name() << endl; meshTools::writeOBJ ( str, @@ -563,7 +563,7 @@ int main(int argc, char *argv[]) dumpCyclicMatch("initial_", mesh); // Read patch construct info from dictionary - PtrList patchSources(dict.lookup("patches")); + PtrList patchSources(dict.lookup("patchInfo")); diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatchDict b/applications/utilities/mesh/manipulation/createPatch/createPatchDict index 9704392a10..b8676f134d 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatchDict +++ b/applications/utilities/mesh/manipulation/createPatch/createPatchDict @@ -46,7 +46,7 @@ matchTolerance 1E-3; pointSync true; // Patches to create. -patches +patchInfo ( { // Name of new patch diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index e77fbaf022..c6d7b8f61e 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -67,9 +67,10 @@ Usage #include "transformField.H" #include "transformGeometricField.H" #include "IStringStream.H" +#include "mathConstants.H" using namespace Foam; -using namespace Foam::mathematicalConstant; +using namespace Foam::constant::math; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options index 823dae1ba7..01bd39cf76 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options @@ -5,5 +5,6 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ + -lgenericPatchFields \ -llagrangian diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options index 518c2a0099..9243ffdb03 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options @@ -6,4 +6,5 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -llagrangian \ + -lgenericPatchFields \ -lconversion diff --git a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/Make/options b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/Make/options index 1adeeefa12..a61c912ba0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/Make/options @@ -4,4 +4,5 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ + -lgenericPatchFields \ -llagrangian diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/Make/options b/applications/utilities/postProcessing/dataConversion/foamToGMV/Make/options index 3aab32c268..db1117a9b6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/Make/options @@ -14,4 +14,5 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ + -lgenericPatchFields \ -llagrangian diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options index 7d09e7e83f..2b32e21ed0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/Make/options @@ -6,5 +6,6 @@ EXE_INC = \ EXE_LIBS = \ -lfiniteVolume \ -llagrangian \ + -lgenericPatchFields \ -lmeshTools diff --git a/applications/utilities/postProcessing/dataConversion/smapToFoam/Make/options b/applications/utilities/postProcessing/dataConversion/smapToFoam/Make/options index fa15f12452..44268cc287 100644 --- a/applications/utilities/postProcessing/dataConversion/smapToFoam/Make/options +++ b/applications/utilities/postProcessing/dataConversion/smapToFoam/Make/options @@ -2,4 +2,5 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ + -lgenericPatchFields \ -lfiniteVolume diff --git a/applications/utilities/postProcessing/miscellaneous/pdfPlot/Make/options b/applications/utilities/postProcessing/miscellaneous/pdfPlot/Make/options index f248721341..a140053895 100644 --- a/applications/utilities/postProcessing/miscellaneous/pdfPlot/Make/options +++ b/applications/utilities/postProcessing/miscellaneous/pdfPlot/Make/options @@ -1,6 +1,8 @@ EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude EXE_LIBS = \ - -lpdf + -lpdf \ + -lsampling diff --git a/applications/utilities/postProcessing/miscellaneous/pdfPlot/createFields.H b/applications/utilities/postProcessing/miscellaneous/pdfPlot/createFields.H index c9255fc4cf..2dc6e7af70 100644 --- a/applications/utilities/postProcessing/miscellaneous/pdfPlot/createFields.H +++ b/applications/utilities/postProcessing/miscellaneous/pdfPlot/createFields.H @@ -2,7 +2,7 @@ ( IOobject ( - "pdfDictionary", + "pdfDict", runTime.constant(), runTime, IOobject::MUST_READ, @@ -10,20 +10,9 @@ ) ); - label nIntervals - ( - readLabel(pdfDictionary.lookup("nIntervals")) - ); + label nIntervals(readLabel(pdfDictionary.lookup("nIntervals"))); - label nSamples - ( - readLabel(pdfDictionary.lookup("nSamples")) - ); + label nSamples(readLabel(pdfDictionary.lookup("nSamples"))); - label samples[nIntervals]; - - for(label i=0;i p - ( - pdf::New(pdfDictionary, rndGen) - ); + autoPtr p(pdf::New(pdfDictionary, rndGen)); scalar xMin = p->minValue(); - scalar xMax = p->maxValue(); - for(label i=0;isample(); - label n = label((ps-xMin)*nIntervals/(xMax-xMin)); - //Info << "p[" << i << "] = " << ps << ", n = " << n << endl; + label n = label((ps - xMin)*nIntervals/(xMax - xMin)); samples[n]++; + + if (i % iCheck == 0) + { + Info<< " processed " << i << " samples" << endl; + + if (i == 10*iCheck) + { + iCheck *= 10; + } + } } - for(label i=0;itype(), pdfPath, runTime.graphFormat()); + Info << "End\n" << endl; return 0; diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index f3659e728a..9c288d7cbf 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -22,6 +22,7 @@ FoamFile // jplot // gnuplot // raw +// vtk setFormat raw; // Surface output format. Choice of @@ -62,6 +63,7 @@ fields // curve specified points, not nessecary on line, uses // tracking // cloud specified points, uses findCell +// triSurfaceMeshPointSet points of triSurface // // axis: how to write point coordinate. Choice of // - x/y/z: x/y/z coordinate only diff --git a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C index e9171c330c..92e3057093 100644 --- a/applications/utilities/preProcessing/engineSwirl/engineSwirl.C +++ b/applications/utilities/preProcessing/engineSwirl/engineSwirl.C @@ -31,7 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - scalar Vphi = (mathematicalConstant::pi*swirlRPMRatio*rpm/30).value(); + scalar Vphi = (constant::math::pi*swirlRPMRatio*rpm/30).value(); scalar b1 = j1(swirlProfile).value(); scalar b2 = 2.0*b1/swirlProfile.value() - j0(swirlProfile).value(); diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C index 5ba3727b39..d164709504 100644 --- a/applications/utilities/preProcessing/setFields/setFields.C +++ b/applications/utilities/preProcessing/setFields/setFields.C @@ -37,14 +37,22 @@ Description using namespace Foam; -template -void setFieldType +template +bool setFieldType ( + const word& fieldTypeDesc, const fvMesh& mesh, const labelList& selectedCells, Istream& fieldValueStream ) { + typedef GeometricField fieldType; + + if (fieldTypeDesc != fieldType::typeName + "Value") + { + return false; + } + word fieldName(fieldValueStream); IOobject fieldHeader @@ -61,15 +69,9 @@ void setFieldType Info<< " Setting " << fieldHeader.headerClassName() << " " << fieldName << endl; - GeoField field(fieldHeader, mesh); + fieldType field(fieldHeader, mesh); - typename GeoField::value_type value - ( - static_cast - ( - pTraits(fieldValueStream) - ) - ); + const Type& value = pTraits(fieldValueStream); if (selectedCells.size() == field.size()) { @@ -100,6 +102,8 @@ void setFieldType "Istream& fieldValueStream)" ) << "Field " << fieldName << " not found" << endl; } + + return true; } @@ -133,32 +137,21 @@ public: { word fieldType(fieldValues); - if (fieldType == "volScalarFieldValue") - { - setFieldType - (mesh_, selectedCells_, fieldValues); - } - else if (fieldType == "volVectorFieldValue") - { - setFieldType - (mesh_, selectedCells_, fieldValues); - } - else if (fieldType == "volSphericalTensorFieldValue") - { - setFieldType - (mesh_, selectedCells_, fieldValues); - } - else if (fieldType == "volSymmTensorFieldValue") - { - setFieldType - (mesh_, selectedCells_, fieldValues); - } - else if (fieldType == "volTensorFieldValue") - { - setFieldType - (mesh_, selectedCells_, fieldValues); - } - else + if + ( + !( + setFieldType + (fieldType, mesh_, selectedCells_, fieldValues) + || setFieldType + (fieldType, mesh_, selectedCells_, fieldValues) + || setFieldType + (fieldType, mesh_, selectedCells_, fieldValues) + || setFieldType + (fieldType, mesh_, selectedCells_, fieldValues) + || setFieldType + (fieldType, mesh_, selectedCells_, fieldValues) + ) + ) { WarningIn("setField::iNew::operator()(Istream& is)") << "field type " << fieldType << " not currently supported" diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C index c3243b71ae..78716d63c7 100644 --- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C +++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C @@ -43,9 +43,10 @@ Description #include "transformField.H" #include "Pair.H" #include "quaternion.H" +#include "mathConstants.H" using namespace Foam; -using namespace Foam::mathematicalConstant; +using namespace Foam::constant::math; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C b/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C index ce8a3e16f4..18befde0af 100644 --- a/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C +++ b/applications/utilities/thermophysical/chemkinToFoam/chemkinToFoam.C @@ -54,8 +54,8 @@ int main(int argc, char *argv[]) OFstream reactionsFile(FOAMChemistryFileName); reactionsFile - << "species" << cr.species() << ';' << endl << endl - << "reactions" << cr.reactions() << ';' << endl; + << "species" << cr.species() << token::END_STATEMENT << nl << nl + << "reactions" << cr.reactions() << token::END_STATEMENT << endl; OFstream thermoFile(FOAMThermodynamicsFileName); thermoFile<< cr.speciesThermo() << endl; diff --git a/bin/foamClearPolyMesh b/bin/foamClearPolyMesh index 1af677459d..ce3e563d31 100755 --- a/bin/foamClearPolyMesh +++ b/bin/foamClearPolyMesh @@ -130,6 +130,22 @@ for i in \ pointLevel \ refinementHistory \ surfaceIndex \ + points.gz \ + faces.gz \ + owner.gz \ + neighbour.gz \ + cells.gz \ + boundary.gz \ + pointZones.gz \ + faceZones.gz \ + cellZones.gz \ + meshModifiers.gz \ + parallelData.gz \ + sets.gz \ + cellLevel.gz \ + pointLevel.gz \ + refinementHistory.gz \ + surfaceIndex.gz \ ; do rm -rf $meshDir/$i diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 4a2015febf..5e0ea64c5e 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -72,6 +72,7 @@ cleanCase () constant/{cellToRegion,cellLevel*,pointLevel*} \ constant/polyMesh/sets/ \ VTK \ + sets/streamLines \ > /dev/null 2>&1 for f in `find . -name "*Dict"` diff --git a/etc/controlDict b/etc/controlDict index 6f47c9c273..ef72407eaf 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -878,34 +878,68 @@ OptimisationSwitches DimensionedConstants { - // SI units + unitSet SI; // USCS - //- Universal gas constant [J/(kmol K)] - R 8314.51; - - //- Standard pressure [Pa] - Pstd 1.0e5; - - //- Standard temperature [K] - Tstd 298.15; - - //- Stefan-Boltzmann constant [J/(K4 m2 s)] - sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 5.670e-08; - - /* USCS units - - //- Universal gas constant [lbm ft2/(s2 kmol R)] - R 3406.78; - - //- Standard pressure [lbm/(ft2)] - Pstd 2088.6; - - //- Standard temperature [degR] - Tstd 536.67; - - //- Stefan-Boltzmann constant [lbm /(degR4 ft s)] - sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 8.2292e-08; - */ + SICoeffs + { + universal + { + c c [ 0 1 -1 0 0 0 0 ] 2.99792e+08; + G G [ -1 3 -2 0 0 0 0 ] 6.67429e-11; + h h [ 1 2 -1 0 0 0 0 ] 6.62607e-34; + } + electromagnetic + { + e e [ 0 0 -1 0 0 1 0 ] 1.60218e-19; + } + atomic + { + me me [ 1 0 0 0 0 0 0 ] 9.10938e-31; + mp mp [ 1 0 0 0 0 0 0 ] 1.67262e-27; + } + physicoChemical + { + mu mu [ 1 0 0 0 0 0 0 ] 1.66054e-27; + k k [ 1 2 -2 -1 0 0 0 ] 1.38065e-23; + } + standard + { + //- Standard pressure [Pa] + Pstd Pstd [ 1 -1 -2 0 0 0 0 ] 100000; + //- Standard temperature [degK] + Tstd Tstd [ 0 0 0 1 0 0 0 ] 298.15; + } + } + USCSCoeffs + { + universal + { + c c [ 0 1 -1 0 0 0 0 ] 9.83558e+08; + G G [ -1 3 -2 0 0 0 0 ] 1.06909e-09; + h h [ 1 2 -1 0 0 0 0 ] 1.57234e-32; + } + electromagnetic + { + e e [ 0 0 -1 0 0 1 0 ] 1.60218e-19; + } + atomic + { + me me [ 1 0 0 0 0 0 0 ] 2.00825e-30; + mp mp [ 1 0 0 0 0 0 0 ] 3.68746e-27; + } + physicoChemical + { + mu mu [ 1 0 0 0 0 0 0 ] 3.66083e-27; + k k [ 1 2 -2 -1 0 0 0 ] 1.82012e-22; + } + standard + { + //- Standard pressure [lbm/ft^2] + Pstd Pstd [ 1 -1 -2 0 0 0 0 ] 2088.6; + //- Standard temperature [degR] + Tstd Tstd [ 0 0 0 1 0 0 0 ] 536.67; + } + } } diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 7bff2143ec..6ba6b90cf1 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -1,5 +1,6 @@ global/global.Cver global/dimensionedConstants/dimensionedConstants.C +global/dimensionedConstants/constants/constants.C global/argList/argList.C global/clock/clock.C diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H index 09db5931b8..db40ccfd4f 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H @@ -117,12 +117,6 @@ public: const std::streamsize bufSize ); - //- Non-blocking receives: wait until all have finished. - static void waitRequests(); - - //- Non-blocking receives: has request i finished? - static bool finishedRequest(const label i); - //- Return next token from stream Istream& read(token&); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H index 6db9a827b1..bccb5b08ef 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H @@ -115,12 +115,6 @@ public: const std::streamsize bufSize ); - //- Non-blocking writes: wait until all have finished. - static void waitRequests(); - - //- Non-blocking writes: has request i finished? - static bool finishedRequest(const label i); - //- Write next token to stream Ostream& write(const token&); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H index 5e8e5cbbb7..f54f02b271 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H @@ -264,6 +264,12 @@ public: // Spawns slave processes and initialises inter-communication static bool init(int& argc, char**& argv); + //- Non-blocking comms: wait until all have finished. + static void waitRequests(); + + //- Non-blocking comms: has request i finished? + static bool finishedRequest(const label i); + //- Is this a parallel run? static bool parRun() { diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index b3b6bb1d72..b2aa0d93e3 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -300,8 +300,7 @@ evaluate() // Block for any outstanding requests if (Pstream::defaultCommsType == Pstream::nonBlocking) { - IPstream::waitRequests(); - OPstream::waitRequests(); + Pstream::waitRequests(); } forAll(*this, patchi) diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.C b/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.C new file mode 100644 index 0000000000..943bdc5c38 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mathConstants.H" +#include "universalConstants.H" +#include "electromagneticConstants.H" +#include "atomicConstants.H" + +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +const char* Foam::constant::atomic::group = "atomic"; + + +const Foam::dimensionedScalar Foam::constant::atomic::alpha +( + dimensionedConstant + ( + group, + "alpha", + dimensionedScalar + ( + "alpha", + sqr(constant::electromagnetic::e) + /( + dimensionedScalar("C", dimless, 2.0) + *constant::electromagnetic::epsilon0 + *constant::universal::h + *constant::universal::c + ) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::atomic::Rinf +( + dimensionedConstant + ( + group, + "Rinf", + dimensionedScalar + ( + "Rinf", + sqr(alpha)*me*constant::universal::c + /(dimensionedScalar("C", dimless, 2.0)*constant::universal::h) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::atomic::a0 +( + dimensionedConstant + ( + group, + "a0", + dimensionedScalar + ( + "a0", + alpha + /(dimensionedScalar("C", dimless, 4.0*constant::math::pi)*Rinf) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::atomic::re +( + dimensionedConstant + ( + group, + "re", + dimensionedScalar + ( + "re", + sqr(constant::electromagnetic::e) + /( + dimensionedScalar("C", dimless, 4.0*constant::math::pi) + *constant::electromagnetic::epsilon0 + *me + *sqr(constant::universal::c) + ) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::atomic::Eh +( + dimensionedConstant + ( + group, + "Eh", + dimensionedScalar + ( + "Eh", + dimensionedScalar("C", dimless, 2.0) + *Rinf*constant::universal::h*constant::universal::c + ) + ) +); + + +// ************************************************************************* // + + + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H new file mode 100644 index 0000000000..c257374441 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::constant::atom + +Description + Atomic constants + +\*---------------------------------------------------------------------------*/ + +#ifndef atomicConstants_H +#define atomicConstants_H + +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace constant +{ +namespace atomic +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + //- Group name for atomic constants + extern const char* group; + + //- Fine-structure constant: default SI units: [] + extern const dimensionedScalar alpha; + + //- Rydberg constant: default SI units: [1/m] + extern const dimensionedScalar Rinf; + + //- Bohr radius: default SI units: [m] + extern const dimensionedScalar a0; + + //- Classical electron radius: default SI units: [m] + extern const dimensionedScalar re; + + //- Hartree energy: default SI units: [J] + extern const dimensionedScalar Eh; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace atomic +} // end namespace constant +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + + + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/constants.C b/src/OpenFOAM/global/dimensionedConstants/constants/constants.C new file mode 100644 index 0000000000..f921cba983 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/constants.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Collection of dimensioned constants + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Constants supplied in the main controlDict +#include "fundamentalConstants.C" + +// Derived constants +#include "universalConstants.C" +#include "electromagneticConstants.C" +#include "atomicConstants.C" +#include "physicoChemicalConstants.C" + + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/constants.H b/src/OpenFOAM/global/dimensionedConstants/constants/constants.H new file mode 100644 index 0000000000..14ab108667 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/constants.H @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::constant + +Description + Collection of constants + +\*---------------------------------------------------------------------------*/ + +#ifndef constants_H +#define constants_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Dimensionless coefficents + +// Mathematical constants +#include "mathConstants.H" + + +// Dimensioned constants + +// Fundamental constants +#include "fundamentalConstants.H" + +// Derived constants +#include "universalConstants.H" +#include "electromagneticConstants.H" +#include "atomicConstants.H" +#include "physicoChemicalConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.C b/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.C new file mode 100644 index 0000000000..77e2fec40c --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.C @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mathConstants.H" +#include "universalConstants.H" +#include "electromagneticConstants.H" +#include "atomicConstants.H" + +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +const char* Foam::constant::electromagnetic::group = "electromagnetic"; + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::mu0 +( + dimensionedConstant + ( + group, + "mu0", + dimensionedScalar + ( + "mu0", + dimless, + 4.0*constant::math::pi*1e-07 + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::epsilon0 +( + dimensionedConstant + ( + group, + "epsilon0", + dimensionedScalar + ( + "epsilon0", + dimensionedScalar("C", dimless, 1.0) + /(mu0*sqr(constant::universal::c)) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::Z0 +( + dimensionedConstant + ( + group, + "Z0", + dimensionedScalar + ( + "Z0", + mu0*constant::universal::c + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::kappa +( + dimensionedConstant + ( + group, + "kappa", + dimensionedScalar + ( + "kappa", + dimensionedScalar("C", dimless, 1.0/(4.0*constant::math::pi)) + /epsilon0 + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::G0 +( + dimensionedConstant + ( + group, + "G0", + dimensionedScalar + ( + "G0", + dimensionedScalar("C", dimless, 2)*sqr(e)/constant::universal::h + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::KJ +( + dimensionedConstant + ( + group, + "KJ", + dimensionedScalar + ( + "KJ", + dimensionedScalar("C", dimless, 2)*e/constant::universal::h + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::phi0 +( + dimensionedConstant + ( + group, + "phi0", + dimensionedScalar + ( + "phi0", + constant::universal::h/(dimensionedScalar("C", dimless, 2)*e) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::electromagnetic::RK +( + dimensionedConstant + ( + group, + "RK", + dimensionedScalar + ( + "RK", + constant::universal::h/sqr(e) + ) + ) +); + + +// ************************************************************************* // + + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H new file mode 100644 index 0000000000..54586cda47 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::constant::em + +Description + Electromagnetic constants + +\*---------------------------------------------------------------------------*/ + +#ifndef electromagneticConstants_H +#define electromagneticConstants_H + +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace constant +{ +namespace electromagnetic +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + //- Group name for electromagnetic constants + extern const char* group; + + //- Magnetic constant/permeability of free space: default SI units: [H/m] + extern const dimensionedScalar mu0; + + //- Electric constant: default SI units: [F/m] + extern const dimensionedScalar epsilon0; + + //- Characteristic impedance of a vacuum: default SI units: [ohm] + extern const dimensionedScalar Z0; + + //- Coulomb constant: default SI units: [N.m2/C2] + extern const dimensionedScalar kappa; + + //- Conductance quantum: default SI units: [S] + extern const dimensionedScalar G0; + + //- Josephson constant: default SI units: [Hz/V] + extern const dimensionedScalar KJ; + + //- Magnetic flux quantum: default SI units: [Wb] + extern const dimensionedScalar phi0; + + //- von Klitzing constant: default SI units: [ohm] + extern const dimensionedScalar RK; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace electromagnetic +} // end namespace constant +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.C b/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.C new file mode 100644 index 0000000000..37e7bf4806 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.C @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Fundamental dimensioned constants + +\*---------------------------------------------------------------------------*/ + +#include "fundamentalConstants.H" + +#include "universalConstants.H" +#include "electromagneticConstants.H" +#include "atomicConstants.H" +#include "physicoChemicalConstants.H" + +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Universal constants + +const Foam::dimensionedScalar Foam::constant::universal::c +( + dimensionedConstant(universal::group, "c") +); + + +const Foam::dimensionedScalar Foam::constant::universal::G +( + dimensionedConstant(universal::group, "G") +); + + +const Foam::dimensionedScalar Foam::constant::universal::h +( + dimensionedConstant(universal::group, "h") +); + + +// Electromagnetic + +const Foam::dimensionedScalar Foam::constant::electromagnetic::e +( + dimensionedConstant(electromagnetic::group, "e") +); + + +// Atomic + +const Foam::dimensionedScalar Foam::constant::atomic::me +( + dimensionedConstant(atomic::group, "me") +); + + +const Foam::dimensionedScalar Foam::constant::atomic::mp +( + dimensionedConstant(atomic::group, "mp") +); + + +// Physico-chemical + +const Foam::dimensionedScalar Foam::constant::physicoChemical::mu +( + dimensionedConstant(physicoChemical::group, "mu") +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::NA +( +// dimensionedConstant(physicoChemical::group, "NA") + dimensionedConstant + ( + physicoChemical::group, + "NA", + dimensionedScalar + ( + "NA", + dimless/dimMoles, + 6.0221417930e+23 + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::k +( + dimensionedConstant(physicoChemical::group, "k") +); + + +// Standard + +const Foam::dimensionedScalar Foam::constant::standard::Pstd +( + dimensionedConstant("standard", "Pstd") +); + + +const Foam::dimensionedScalar Foam::constant::standard::Tstd +( + dimensionedConstant("standard", "Tstd") +); + + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.H new file mode 100644 index 0000000000..de30291fe8 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.H @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Fundamental dimensioned constants + +\*---------------------------------------------------------------------------*/ + +#ifndef fundamentalConstants_H +#define fundamentalConstants_H + +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace constant +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace universal +{ + //- Speed of light in a vacuum + extern const dimensionedScalar c; + + //- Newtonian constant of gravitation + extern const dimensionedScalar G; + + //- Planck constant + extern const dimensionedScalar h; +} + +namespace electromagnetic +{ + //- Elementary charge + extern const dimensionedScalar e; +} + +namespace atomic +{ + //- Electron mass + extern const dimensionedScalar me; + + //- Proton mass + extern const dimensionedScalar mp; +} + +namespace physicoChemical +{ + //- Atomic mass unit + extern const dimensionedScalar mu; + + //- Avagadro number + extern const dimensionedScalar NA; + + //- Boltzmann constant + extern const dimensionedScalar k; +} + +namespace standard +{ + //- Standard pressure + extern const dimensionedScalar Pstd; + + //- Standard temperature + extern const dimensionedScalar Tstd; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace constant +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/mathematicalConstants/mathematicalConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/math/mathConstants.H similarity index 86% rename from src/OpenFOAM/primitives/mathematicalConstants/mathematicalConstants.H rename to src/OpenFOAM/global/dimensionedConstants/constants/math/mathConstants.H index c1b45e9694..f18f97d749 100644 --- a/src/OpenFOAM/primitives/mathematicalConstants/mathematicalConstants.H +++ b/src/OpenFOAM/global/dimensionedConstants/constants/math/mathConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,15 +23,15 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Namespace - Foam::mathematicalConstant + Foam::constant::math Description - Mathematical constants such as pi, e. + mathematical constants \*---------------------------------------------------------------------------*/ -#ifndef mathematicalConstants_H -#define mathematicalConstants_H +#ifndef mathConstants_H +#define mathConstants_H #include "scalar.H" @@ -39,19 +39,24 @@ Description namespace Foam { +namespace constant +{ +namespace math +{ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace mathematicalConstant -{ + static word group = "math"; + const scalar e(M_E); const scalar pi(M_PI); const scalar twoPi(2*pi); const scalar piByTwo(0.5*pi); -} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace math +} // end namespace constant } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,3 +64,6 @@ namespace mathematicalConstant #endif // ************************************************************************* // + + + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.C b/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.C new file mode 100644 index 0000000000..7446c67d97 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "mathConstants.H" +#include "universalConstants.H" +#include "electromagneticConstants.H" +#include "physicoChemicalConstants.H" + +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +const char* Foam::constant::physicoChemical::group = "physicoChemical"; + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::R +( + dimensionedConstant + ( + group, + "R", + dimensionedScalar + ( + "R", + NA*k + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::F +( + dimensionedConstant + ( + group, + "F", + dimensionedScalar + ( + "F", + NA*constant::electromagnetic::e + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::sigma +( + dimensionedConstant + ( + group, + "sigma", + dimensionedScalar + ( + "sigma", + dimensionedScalar("C", dimless, sqr(constant::math::pi)/60.0) + *pow4(k)/(pow3(constant::universal::hr)*sqr(constant::universal::c)) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::b +( + dimensionedConstant + ( + group, + "b", + dimensionedScalar + ( + "b", + (constant::universal::h*constant::universal::c/k) + /dimensionedScalar("C", dimless, 4.965114231) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::c1 +( + dimensionedConstant + ( + group, + "c1", + dimensionedScalar + ( + "c1", + dimensionedScalar("C", dimless, constant::math::twoPi) + *constant::universal::h*sqr(constant::universal::c) + ) + ) +); + + +const Foam::dimensionedScalar Foam::constant::physicoChemical::c2 +( + dimensionedConstant + ( + group, + "c2", + dimensionedScalar + ( + "c2", + constant::universal::h*constant::universal::c/k + ) + ) +); + + +// ************************************************************************* // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H new file mode 100644 index 0000000000..7f25e0dfb7 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::constant::phys + +Description + Physico-chemical constants + +\*---------------------------------------------------------------------------*/ + +#ifndef physicoChemicalConstants_H +#define physicoChemicalConstants_H + +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace constant +{ +namespace physicoChemical +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + //- Group name for physico-chemical constants + extern const char* group; + + //- Universal gas constant: default SI units: [J/mol/K] + extern const dimensionedScalar R; + + //- Faraday constant: default SI units: [C/mol] + extern const dimensionedScalar F; + + //- Stefan-Boltzmann constant: default SI units: [W/m2/K4] + extern const dimensionedScalar sigma; + + //- Wien displacement law constant: default SI units: [m.K] + extern const dimensionedScalar b; + + //- First radiation constant: default SI units: [W/m2] + extern const dimensionedScalar c1; + + //- Second radiation constant: default SI units: [m.K] + extern const dimensionedScalar c2; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace physicoChemical +} // end namespace constant +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + + + + diff --git a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C b/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.C similarity index 78% rename from src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C rename to src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.C index 0e5962910d..3284c51d4d 100644 --- a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.C +++ b/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,25 +24,30 @@ License \*---------------------------------------------------------------------------*/ -#include "radiationConstants.H" +#include "universalConstants.H" +#include "mathConstants.H" + #include "dimensionedConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Stefan-Boltzmann constant (default in [J/(K4 m2 s)]) -const Foam::dimensionedScalar Foam::radiation::sigmaSB +const char* Foam::constant::universal::group = "universal"; + + +const Foam::dimensionedScalar Foam::constant::universal::hr ( - Foam::dimensionedConstant + dimensionedConstant ( - "sigmaSB", + group, + "hr", dimensionedScalar ( - "sigmaSB", - dimensionSet(1, 0, -3, -4, 0, 0, 0), - 5.670E-08 + "hr", + h/(dimensionedScalar("C", dimless, constant::math::twoPi)) ) ) ); // ************************************************************************* // + diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H b/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H new file mode 100644 index 0000000000..305e30fe19 --- /dev/null +++ b/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::constant::uni + +Description + Universal constants + +\*---------------------------------------------------------------------------*/ + +#ifndef universalConstants_H +#define universalConstants_H + +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace constant +{ +namespace universal +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + //- Group name for universal constants + extern const char* group; + + //- Reduced Planck constant: default SI units: [J/s] + extern const dimensionedScalar hr; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace universal +} // End namespace constant +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C b/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C index a3a9893fde..b9a7d4277b 100644 --- a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C +++ b/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C @@ -44,6 +44,25 @@ dictionary& dimensionedConstants() ); } + +dimensionedScalar dimensionedConstant +( + const word& group, + const word& varName +) +{ + dictionary& dict = dimensionedConstants(); + + const word unitSet(dict.lookup("unitSet")); + + dictionary& unitDict(dict.subDict(unitSet + "Coeffs")); + + dictionary& groupDict = unitDict.subDict(group); + + return dimensionedScalar(groupDict.lookup(varName)); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H b/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H index 476638dbc7..989089c0b0 100644 --- a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H +++ b/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H @@ -40,6 +40,7 @@ SourceFiles #define dimensionedConstants_H #include "dictionary.H" +#include "dimensionedScalar.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,20 +51,42 @@ namespace Foam dictionary& dimensionedConstants(); + +dimensionedScalar dimensionedConstant(const word& group, const word& varName); + + template T dimensionedConstant ( - const char* switchName, - const T defaultValue + const word& group, + const word& varName, + const T& defaultValue ) { - if (dimensionedConstants().found(switchName)) + dictionary& dict = dimensionedConstants(); + + const word unitSet(dict.lookup("unitSet")); + + dictionary& unitDict(dict.subDict(unitSet + "Coeffs")); + + if (unitDict.found(group)) { - return pTraits(dimensionedConstants().lookup(switchName)); + dictionary& groupDict = unitDict.subDict(group); + if (groupDict.found(varName)) + { + return pTraits(groupDict.lookup(varName)); + } + else + { + groupDict.add(varName, defaultValue); + return defaultValue; + } } else { - dimensionedConstants().add(switchName, defaultValue); + unitDict.add(group, dictionary::null); + unitDict.subDict(group).add(varName, defaultValue); + return defaultValue; } } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index f371e697a1..a7bbf88005 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -27,7 +27,7 @@ License #include "face.H" #include "triFace.H" #include "triPointRef.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -99,13 +99,13 @@ Foam::label Foam::face::mostConcaveAngle if ((edgeNormal & n) > 0) { // Concave angle. - angle = mathematicalConstant::pi + edgeAngle; + angle = constant::math::pi + edgeAngle; } else { // Convex angle. Note '-' to take into account that rightEdge // and leftEdge are head-to-tail connected. - angle = mathematicalConstant::pi - edgeAngle; + angle = constant::math::pi - edgeAngle; } if (angle > maxAngle) @@ -214,7 +214,7 @@ Foam::label Foam::face::split label index = fcIndex(fcIndex(startIndex)); label minIndex = index; - scalar minDiff = Foam::mathematicalConstant::pi; + scalar minDiff = constant::math::pi; for(label i = 0; i < size() - 3; i++) { diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index e2c2dbf773..0c524920af 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -339,8 +339,7 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed) // Wait for all to finish - OPstream::waitRequests(); - IPstream::waitRequests(); + Pstream::waitRequests(); // Compact out all submap entries that are referring to unused elements diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index da1ed19d1e..bd3e6b744e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -287,8 +287,7 @@ void Foam::mapDistribute::distribute // Wait till all finished - IPstream::waitRequests(); - OPstream::waitRequests(); + Pstream::waitRequests(); // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -413,8 +412,7 @@ void Foam::mapDistribute::distribute // Wait for all to finish - OPstream::waitRequests(); - IPstream::waitRequests(); + Pstream::waitRequests(); // Collect neighbour fields @@ -717,8 +715,7 @@ void Foam::mapDistribute::distribute // Wait till all finished - IPstream::waitRequests(); - OPstream::waitRequests(); + Pstream::waitRequests(); // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -842,8 +839,7 @@ void Foam::mapDistribute::distribute // Wait for all to finish - OPstream::waitRequests(); - IPstream::waitRequests(); + Pstream::waitRequests(); // Collect neighbour fields diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C index 29841d3ec8..01879f089f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C @@ -27,7 +27,7 @@ License #include "primitiveMesh.H" #include "pyramidPointFaceRef.H" #include "ListOps.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "SortableList.H" @@ -410,7 +410,7 @@ bool Foam::primitiveMesh::checkFaceOrthogonality // Severe nonorthogonality threshold const scalar severeNonorthogonalityThreshold = - ::cos(nonOrthThreshold_/180.0*mathematicalConstant::pi); + ::cos(nonOrthThreshold_/180.0*constant::math::pi); scalar minDDotS = GREAT; @@ -472,9 +472,9 @@ bool Foam::primitiveMesh::checkFaceOrthogonality if (debug || report) { Info<< " Mesh non-orthogonality Max: " - << ::acos(minDDotS)/mathematicalConstant::pi*180.0 + << ::acos(minDDotS)/constant::math::pi*180.0 << " average: " << - ::acos(sumDDotS/neiSize)/mathematicalConstant::pi*180.0 + ::acos(sumDDotS/neiSize)/constant::math::pi*180.0 << endl; } } @@ -839,7 +839,7 @@ bool Foam::primitiveMesh::checkFaceAngles << exit(FatalError); } - const scalar maxSin = Foam::sin(maxDeg/180.0*mathematicalConstant::pi); + const scalar maxSin = Foam::sin(maxDeg/180.0*constant::math::pi); const pointField& p = points(); const faceList& fcs = faces(); @@ -916,7 +916,7 @@ bool Foam::primitiveMesh::checkFaceAngles { scalar maxConcaveDegr = Foam::asin(Foam::min(1.0, maxEdgeSin)) - *180.0/mathematicalConstant::pi; + *180.0/constant::math::pi; if (debug || report) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C index 8a82cc4189..1dafd61f61 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C @@ -31,7 +31,7 @@ Description #include "primitiveMesh.H" #include "pyramidPointFaceRef.H" #include "cell.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -200,7 +200,7 @@ bool Foam::primitiveMesh::checkMeshMotion ) << "Severe non-orthogonality in mesh motion for face " << faceI << " between cells " << own[faceI] << " and " << nei[faceI] - << ": Angle = " << ::acos(dDotS)/mathematicalConstant::pi*180.0 + << ": Angle = " << ::acos(dDotS)/constant::math::pi*180.0 << " deg." << endl; nDotProductErrors++; diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H index a21461bc62..881fb1d520 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H @@ -26,7 +26,7 @@ License #include "IOstreams.H" #include "pointHit.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -307,9 +307,9 @@ inline scalar triangle::quality() const return mag() / ( - mathematicalConstant::pi - * Foam::sqr(circumRadius()) - * 0.413497 + constant::math::pi + *Foam::sqr(circumRadius()) + *0.413497 + VSMALL ); } diff --git a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C index cd8ed8f9b5..7668cfe0e9 100644 --- a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C +++ b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C @@ -25,7 +25,6 @@ License \*---------------------------------------------------------------------------*/ #include "labelSymmTensor.H" -#include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index f365893125..6ecc1da313 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "tensor.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -150,10 +150,8 @@ vector eigenValues(const tensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = m2SqrtQ*cos((theta + mathematicalConstant::twoPi)/3) - - aBy3; - iii = m2SqrtQ*cos((theta - mathematicalConstant::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + constant::math::twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - constant::math::twoPi)/3) - aBy3; } else { @@ -345,10 +343,8 @@ vector eigenValues(const symmTensor& t) scalar aBy3 = a/3; i = m2SqrtQ*cos(theta/3) - aBy3; - ii = m2SqrtQ*cos((theta + mathematicalConstant::twoPi)/3) - - aBy3; - iii = m2SqrtQ*cos((theta - mathematicalConstant::twoPi)/3) - - aBy3; + ii = m2SqrtQ*cos((theta + constant::math::twoPi)/3) - aBy3; + iii = m2SqrtQ*cos((theta - constant::math::twoPi)/3) - aBy3; } else { diff --git a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C index e782cd0fea..b817d4ab5e 100644 --- a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C +++ b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C @@ -25,7 +25,6 @@ License \*---------------------------------------------------------------------------*/ #include "tensor2D.H" -#include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/transform/transform.H b/src/OpenFOAM/primitives/transform/transform.H index 33bf2b1d39..8d6657b41f 100644 --- a/src/OpenFOAM/primitives/transform/transform.H +++ b/src/OpenFOAM/primitives/transform/transform.H @@ -34,7 +34,7 @@ Description #define transform_H #include "tensor.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -104,7 +104,7 @@ inline Tensor transform(const tensor& tt, const Tensor& t) (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.zx() + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.zy() + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.zz(), - + (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.xx() + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.xy() + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.xz(), @@ -155,7 +155,7 @@ inline SymmTensor transform(const tensor& tt, const SymmTensor& st) (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.zx() + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.zy() + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.zz(), - + (tt.zx()*st.xx() + tt.zy()*st.xy() + tt.zz()*st.xz())*tt.zx() + (tt.zx()*st.xy() + tt.zy()*st.yy() + tt.zz()*st.yz())*tt.zy() + (tt.zx()*st.xz() + tt.zy()*st.yz() + tt.zz()*st.zz())*tt.zz() @@ -205,11 +205,11 @@ inline scalar pseudoAngle if (sin < -SMALL) { - return (3.0 + cos)*mathematicalConstant::piByTwo; + return (3.0 + cos)*constant::math::piByTwo; } else { - return (1.0 - cos)*mathematicalConstant::piByTwo; + return (1.0 - cos)*constant::math::piByTwo; } } diff --git a/src/Pstream/dummy/IPread.C b/src/Pstream/dummy/IPread.C index 6ab24bc152..8e3d64982b 100644 --- a/src/Pstream/dummy/IPread.C +++ b/src/Pstream/dummy/IPread.C @@ -86,17 +86,4 @@ int Foam::IPstream::read } -void Foam::IPstream::waitRequests() -{} - - -bool Foam::IPstream::finishedRequest(const label) -{ - notImplemented("IPstream::finishedRequest()"); - return false; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/Pstream/dummy/OPwrite.C b/src/Pstream/dummy/OPwrite.C index 1b7326bdd8..ad12d738fd 100644 --- a/src/Pstream/dummy/OPwrite.C +++ b/src/Pstream/dummy/OPwrite.C @@ -65,17 +65,4 @@ bool Foam::OPstream::write } -void Foam::OPstream::waitRequests() -{} - - -bool Foam::OPstream::finishedRequest(const label) -{ - notImplemented("OPstream::finishedRequest()"); - return false; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/Pstream/dummy/Pstream.C b/src/Pstream/dummy/Pstream.C index 2c3825eac4..bd22701cfe 100644 --- a/src/Pstream/dummy/Pstream.C +++ b/src/Pstream/dummy/Pstream.C @@ -61,6 +61,17 @@ void Foam::Pstream::abort() void Foam::reduce(scalar&, const sumOp&) {} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +void Foam::Pstream::waitRequests() +{} + + +bool Foam::Pstream::finishedRequest(const label i) +{ + notImplemented("Pstream::finishedRequest()"); + return false; +} + // ************************************************************************* // diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/IPread.C index c08c6b56ab..966ae7ddc9 100644 --- a/src/Pstream/mpi/IPread.C +++ b/src/Pstream/mpi/IPread.C @@ -30,6 +30,7 @@ Description #include "mpi.h" #include "IPstream.H" +#include "PstreamGlobals.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,7 +38,7 @@ Description // Outstanding non-blocking operations. //! @cond fileScope -Foam::DynamicList IPstream_outstandingRequests_; +//Foam::DynamicList IPstream_outstandingRequests_; //! @endcond fileScope // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // @@ -185,7 +186,7 @@ Foam::label Foam::IPstream::read return 0; } - IPstream_outstandingRequests_.append(request); + PstreamGlobals::outstandingRequests_.append(request); // Assume the message is completely received. return bufSize; @@ -204,52 +205,6 @@ Foam::label Foam::IPstream::read } -void Foam::IPstream::waitRequests() -{ - if (IPstream_outstandingRequests_.size()) - { - if - ( - MPI_Waitall - ( - IPstream_outstandingRequests_.size(), - IPstream_outstandingRequests_.begin(), - MPI_STATUSES_IGNORE - ) - ) - { - FatalErrorIn - ( - "IPstream::waitRequests()" - ) << "MPI_Waitall returned with error" << endl; - } - - IPstream_outstandingRequests_.clear(); - } -} - - -bool Foam::IPstream::finishedRequest(const label i) -{ - if (i >= IPstream_outstandingRequests_.size()) - { - FatalErrorIn - ( - "IPstream::finishedRequest(const label)" - ) << "There are " << IPstream_outstandingRequests_.size() - << " outstanding send requests and you are asking for i=" << i - << nl - << "Maybe you are mixing blocking/non-blocking comms?" - << Foam::abort(FatalError); - } - - int flag; - MPI_Test(&IPstream_outstandingRequests_[i], &flag, MPI_STATUS_IGNORE); - - return flag != 0; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/Pstream/mpi/Make/files b/src/Pstream/mpi/Make/files index 65016b83f8..6b1d3f4c57 100644 --- a/src/Pstream/mpi/Make/files +++ b/src/Pstream/mpi/Make/files @@ -1,5 +1,6 @@ OPwrite.C IPread.C Pstream.C +PstreamGlobals.C LIB = $(FOAM_MPI_LIBBIN)/libPstream diff --git a/src/Pstream/mpi/OPwrite.C b/src/Pstream/mpi/OPwrite.C index 4836b92c8b..1e963ec13f 100644 --- a/src/Pstream/mpi/OPwrite.C +++ b/src/Pstream/mpi/OPwrite.C @@ -30,13 +30,7 @@ Description #include "mpi.h" #include "OPstream.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// Outstanding non-blocking operations. -//! @cond fileScope -Foam::DynamicList OPstream_outstandingRequests_; -//! @endcond fileScope +#include "PstreamGlobals.H" // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -126,7 +120,7 @@ bool Foam::OPstream::write &request ); - OPstream_outstandingRequests_.append(request); + PstreamGlobals::outstandingRequests_.append(request); } else { @@ -142,52 +136,6 @@ bool Foam::OPstream::write } -void Foam::OPstream::waitRequests() -{ - if (OPstream_outstandingRequests_.size()) - { - if - ( - MPI_Waitall - ( - OPstream_outstandingRequests_.size(), - OPstream_outstandingRequests_.begin(), - MPI_STATUSES_IGNORE - ) - ) - { - FatalErrorIn - ( - "OPstream::waitRequests()" - ) << "MPI_Waitall returned with error" << Foam::endl; - } - - OPstream_outstandingRequests_.clear(); - } -} - - -bool Foam::OPstream::finishedRequest(const label i) -{ - if (i >= OPstream_outstandingRequests_.size()) - { - FatalErrorIn - ( - "OPstream::finishedRequest(const label)" - ) << "There are " << OPstream_outstandingRequests_.size() - << " outstanding send requests and you are asking for i=" << i - << nl - << "Maybe you are mixing blocking/non-blocking comms?" - << Foam::abort(FatalError); - } - - int flag; - MPI_Test(&OPstream_outstandingRequests_[i], &flag, MPI_STATUS_IGNORE); - - return flag != 0; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/Pstream/mpi/Pstream.C b/src/Pstream/mpi/Pstream.C index ba4629d754..a535f4804e 100644 --- a/src/Pstream/mpi/Pstream.C +++ b/src/Pstream/mpi/Pstream.C @@ -29,6 +29,7 @@ License #include "Pstream.H" #include "PstreamReduceOps.H" #include "OSspecific.H" +#include "PstreamGlobals.H" #include #include @@ -130,6 +131,19 @@ void Foam::Pstream::exit(int errnum) delete[] buff; # endif + if (PstreamGlobals::outstandingRequests_.size()) + { + label n = PstreamGlobals::outstandingRequests_.size(); + PstreamGlobals::outstandingRequests_.clear(); + + WarningIn("Pstream::exit(int)") + << "There are still " << n << " outstanding MPI_Requests." << endl + << "This means that your code exited before doing a" + << " Pstream::waitRequests()." << endl + << "This should not happen for a normal code exit." + << endl; + } + if (errnum == 0) { MPI_Finalize(); @@ -422,6 +436,57 @@ void Foam::reduce(scalar& Value, const sumOp& bop) } +void Foam::Pstream::waitRequests() +{ + if (PstreamGlobals::outstandingRequests_.size()) + { + if + ( + MPI_Waitall + ( + PstreamGlobals::outstandingRequests_.size(), + PstreamGlobals::outstandingRequests_.begin(), + MPI_STATUSES_IGNORE + ) + ) + { + FatalErrorIn + ( + "Pstream::waitRequests()" + ) << "MPI_Waitall returned with error" << Foam::endl; + } + + PstreamGlobals::outstandingRequests_.clear(); + } +} + + +bool Foam::Pstream::finishedRequest(const label i) +{ + if (i >= PstreamGlobals::outstandingRequests_.size()) + { + FatalErrorIn + ( + "Pstream::finishedRequest(const label)" + ) << "There are " << PstreamGlobals::outstandingRequests_.size() + << " outstanding send requests and you are asking for i=" << i + << nl + << "Maybe you are mixing blocking/non-blocking comms?" + << Foam::abort(FatalError); + } + + int flag; + MPI_Test + ( + &PstreamGlobals::outstandingRequests_[i], + &flag, + MPI_STATUS_IGNORE + ); + + return flag != 0; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.H b/src/Pstream/mpi/PstreamGlobals.C similarity index 83% rename from src/thermophysicalModels/radiation/radiationConstants/radiationConstants.H rename to src/Pstream/mpi/PstreamGlobals.C index 2e7e5602e8..f9271e5fe4 100644 --- a/src/thermophysicalModels/radiation/radiationConstants/radiationConstants.H +++ b/src/Pstream/mpi/PstreamGlobals.C @@ -22,32 +22,24 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -InNamespace - Foam::radiation - -Description - Constants used in radiation modelling - \*---------------------------------------------------------------------------*/ -#ifndef radiationConstants_H -#define radiationConstants_H - -#include "dimensionedScalar.H" +#include "PstreamGlobals.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace radiation -{ - //- Stefan-Boltzmann constant [J/(K4 m2 s)] - extern const dimensionedScalar sigmaSB; -} -} + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// Outstanding non-blocking operations. +//! @cond fileScope +DynamicList PstreamGlobals::outstandingRequests_; +//! @endcond fileScope // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#endif +} // End namespace Foam // ************************************************************************* // diff --git a/src/Pstream/mpi/PstreamGlobals.H b/src/Pstream/mpi/PstreamGlobals.H new file mode 100644 index 0000000000..07aa35a48f --- /dev/null +++ b/src/Pstream/mpi/PstreamGlobals.H @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::PstreamGlobals + +Description + Global functions and variables for working with parallel streams, + but principally for gamma/mpi + +SourceFiles + PstreamGlobals.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PstreamGlobals_H +#define PstreamGlobals_H + +#include "mpi.h" + +#include "DynamicList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PstreamGlobals Declaration +\*---------------------------------------------------------------------------*/ + +namespace PstreamGlobals +{ + +extern DynamicList outstandingRequests_; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index fea25e35eb..27ca388fe3 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -34,7 +34,7 @@ Description #include "removePoints.H" #include "pointFields.H" #include "motionSmoother.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "pointSet.H" #include "faceSet.H" #include "cellSet.H" @@ -2479,17 +2479,11 @@ void Foam::autoLayerDriver::mergePatchFacesUndo const dictionary& motionDict ) { - scalar minCos = Foam::cos - ( - layerParams.featureAngle() - * mathematicalConstant::pi/180.0 - ); + scalar minCos = + Foam::cos(layerParams.featureAngle()*constant::math::pi/180.0); - scalar concaveCos = Foam::cos - ( - layerParams.concaveAngle() - * mathematicalConstant::pi/180.0 - ); + scalar concaveCos = + Foam::cos(layerParams.concaveAngle()*constant::math::pi/180.0); Info<< nl << "Merging all faces of a cell" << nl @@ -2588,7 +2582,7 @@ void Foam::autoLayerDriver::addLayers ( pp, meshEdges, - layerParams.featureAngle()*mathematicalConstant::pi/180.0, + layerParams.featureAngle()*constant::math::pi/180.0, patchDisp, patchNLayers, @@ -2987,6 +2981,7 @@ void Foam::autoLayerDriver::addLayers ( invExpansionRatio, pp, + labelList(0), // exposed patchIDs, not used for adding layers nPatchFaceLayers, // layers per face nPatchPointLayers, // layers per point firstDisp, // thickness of layer nearest internal mesh diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C index 1ba66fffe9..3ea198e6c4 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C @@ -35,6 +35,7 @@ License #include "refinementSurfaces.H" #include "shellSurfaces.H" #include "mapDistributePolyMesh.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -678,8 +679,8 @@ void Foam::autoRefineDriver::mergePatchFaces meshRefiner_.mergePatchFaces ( - Foam::cos(45*mathematicalConstant::pi/180.0), - Foam::cos(45*mathematicalConstant::pi/180.0), + Foam::cos(45*constant::math::pi/180.0), + Foam::cos(45*constant::math::pi/180.0), meshRefiner_.meshedPatches() ); @@ -688,7 +689,7 @@ void Foam::autoRefineDriver::mergePatchFaces meshRefiner_.checkData(); } - meshRefiner_.mergeEdges(Foam::cos(45*mathematicalConstant::pi/180.0)); + meshRefiner_.mergeEdges(Foam::cos(45*constant::math::pi/180.0)); if (debug) { diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C index fad6642296..ea57136c1d 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C @@ -26,7 +26,7 @@ License #include "layerParameters.H" #include "polyBoundaryMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "refinementSurfaces.H" #include "searchableSurfaces.H" #include "regExp.H" @@ -192,12 +192,7 @@ Foam::layerParameters::layerParameters ), layerTerminationCos_ ( - Foam::cos - ( - 0.5 - * featureAngle_ - * mathematicalConstant::pi/180. - ) + Foam::cos(0.5*featureAngle_*constant::math::pi/180.0) ), maxThicknessToMedialRatio_ ( @@ -206,7 +201,7 @@ Foam::layerParameters::layerParameters minMedianAxisAngleCos_ ( Foam::cos(readScalar(dict.lookup("minMedianAxisAngle"))) - * mathematicalConstant::pi/180. + *constant::math::pi/180.0 ), nBufferCellsNoExtrude_ ( @@ -274,12 +269,7 @@ Foam::layerParameters::layerParameters ), layerTerminationCos_ ( - Foam::cos - ( - 0.5 - * featureAngle_ - * mathematicalConstant::pi/180. - ) + Foam::cos(0.5*featureAngle_*constant::math::pi/180.0) ), maxThicknessToMedialRatio_ ( @@ -288,7 +278,7 @@ Foam::layerParameters::layerParameters minMedianAxisAngleCos_ ( Foam::cos(readScalar(dict.lookup("minMedianAxisAngle"))) - * mathematicalConstant::pi/180. + *constant::math::pi/180.0 ), nBufferCellsNoExtrude_ ( diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/refinementParameters.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/refinementParameters.C index d63d527fae..ce3b82bfc6 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/refinementParameters.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/refinementParameters.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "refinementParameters.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "polyMesh.H" #include "globalIndex.H" @@ -63,7 +63,7 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict) } else { - curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0); + curvature_ = Foam::cos(featAngle*constant::math::pi/180.0); } } diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C index fb0a7e2121..2f3f4e60ca 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -37,6 +37,7 @@ License #include "searchableSurfaces.H" #include "polyMeshGeometry.H" #include "IOmanip.H" +#include "mathConstants.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -246,10 +247,7 @@ Foam::Map Foam::meshRefinement::findEdgeConnectedProblemCells nearestRegion[i] ); - scalar angle = - perpendicularAngle[region] - / 180.0 - * mathematicalConstant::pi; + scalar angle = perpendicularAngle[region]/180.0*constant::math::pi; if (angle >= 0) { @@ -306,7 +304,7 @@ bool Foam::meshRefinement::isCollapsedFace vector d = ownCc - mesh_.cellCentres()[nei]; scalar dDotS = (d & s)/(mag(d)*magS + VSMALL); - + if (dDotS < maxNonOrtho) { return true; diff --git a/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C b/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C index 3b1045cdb3..5fa27e142a 100644 --- a/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C +++ b/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C @@ -27,7 +27,7 @@ License #include "dynamicInkJetFvMesh.H" #include "addToRunTimeSelectionTable.H" #include "volFields.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -90,7 +90,7 @@ Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh() bool Foam::dynamicInkJetFvMesh::update() { scalar scalingFunction = - 0.5*(::cos(2*mathematicalConstant::pi*frequency_*time().value()) - 1.0); + 0.5*(::cos(constant::math::twoPi*frequency_*time().value()) - 1.0); Info<< "Mesh scaling. Time = " << time().value() << " scaling: " << scalingFunction << endl; @@ -113,7 +113,7 @@ bool Foam::dynamicInkJetFvMesh::update() fvMesh::movePoints(newPoints); - volVectorField& U = + volVectorField& U = const_cast(lookupObject("U")); U.correctBoundaryConditions(); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.C index d2f0c467d2..1fbd323685 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SDA/SDA.C @@ -26,9 +26,9 @@ License #include "SDA.H" #include "addToRunTimeSelectionTable.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" -using namespace Foam::mathematicalConstant; +using namespace Foam::constant::math; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -70,18 +70,18 @@ Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const scalar time = time_.value(); scalar Tpi = Tp_ + dTp_*(time/dTi_); // Current roll period [sec] - scalar wr = 2*pi/Tpi; // Current Freq [/sec] + scalar wr = twoPi/Tpi; // Current Freq [/sec] // Current Phase for roll [rad] scalar r = dTp_/dTi_; scalar u = Tp_ + r*time; - scalar phr = 2*pi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r; + scalar phr = twoPi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r; // Current Phase for Sway [rad] scalar phs = phr + pi; // Current Phase for Heave [rad] - scalar phh = phr + pi/2; + scalar phh = phr + piByTwo; scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_); diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SKA/SKA.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SKA/SKA.C index 6d4cdc4427..e15523f983 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SKA/SKA.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/SKA/SKA.C @@ -29,9 +29,9 @@ License #include "Tuple2.H" #include "IFstream.H" #include "interpolateXY.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" -using namespace Foam::mathematicalConstant; +using namespace Foam::constant::math; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C index e41ed4b427..7329c1dd90 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C @@ -27,11 +27,8 @@ License #include "solidBodyMotionFvMesh.H" #include "addToRunTimeSelectionTable.H" #include "volFields.H" -#include "mathematicalConstants.H" #include "transformField.H" -using namespace Foam::mathematicalConstant; - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam diff --git a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C index e31ad4c2a1..8e705ae525 100644 --- a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C @@ -28,7 +28,6 @@ License #include "cellFeatures.H" #include "polyMesh.H" #include "cellModeller.H" -#include "mathematicalConstants.H" #include "plane.H" #include "ListOps.H" #include "meshTools.H" @@ -36,18 +35,12 @@ License #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - defineTypeNameAndDebug(hexCellLooper, 0); - addToRunTimeSelectionTable(cellLooper, hexCellLooper, word); - - } diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C index 3572546e75..8f4a57aca7 100644 --- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C @@ -27,7 +27,7 @@ License #include "topoCellLooper.H" #include "cellFeatures.H" #include "polyMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "DynamicList.H" #include "ListOps.H" #include "meshTools.H" @@ -35,9 +35,8 @@ License #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + namespace Foam { defineTypeNameAndDebug(topoCellLooper, 0); @@ -46,7 +45,7 @@ namespace Foam // Angle for polys to be considered splitHexes. const Foam::scalar Foam::topoCellLooper::featureCos = - Foam::cos(10.0 * mathematicalConstant::pi/180.0); + Foam::cos(10.0*constant::math::pi/180.0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C index 15478458c9..57dd15eb54 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C @@ -32,16 +32,14 @@ License #include "cellCuts.H" #include "splitCell.H" #include "mapPolyMesh.H" -#include "mathematicalConstants.H" +#include "mathConstants.H" #include "meshTools.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(undoableMeshCutter, 0); - } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -193,8 +191,8 @@ Foam::undoableMeshCutter::undoableMeshCutter liveSplitCells_(mesh.nCells()/100 + 100), faceRemover_ ( - mesh, - Foam::cos(30./180. * mathematicalConstant::pi) + mesh, + Foam::cos(30.0/180.0*constant::math::pi) ) {} diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C index 37882a2cc0..4fbd137526 100644 --- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C +++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C @@ -27,6 +27,7 @@ License #include "polyMeshGeometry.H" #include "pyramidPointFaceRef.H" #include "syncTools.H" +#include "mathConstants.H" namespace Foam { @@ -247,7 +248,7 @@ Foam::scalar Foam::polyMeshGeometry::checkNonOrtho << " between cells " << mesh.faceOwner()[faceI] << " and " << nei << ": Angle = " - << ::acos(dDotS)/mathematicalConstant::pi*180.0 + << ::acos(dDotS)/constant::math::pi*180.0 << " deg." << endl; } @@ -268,7 +269,7 @@ Foam::scalar Foam::polyMeshGeometry::checkNonOrtho << " between cells " << mesh.faceOwner()[faceI] << " and " << nei << ": Angle = " - << ::acos(dDotS)/mathematicalConstant::pi*180.0 + << ::acos(dDotS)/constant::math::pi*180.0 << " deg." << endl; } @@ -368,7 +369,7 @@ bool Foam::polyMeshGeometry::checkFaceDotProduct // Severe nonorthogonality threshold const scalar severeNonorthogonalityThreshold = - ::cos(orthWarn/180.0*mathematicalConstant::pi); + ::cos(orthWarn/180.0*constant::math::pi); // Calculate coupled cell centre @@ -503,9 +504,9 @@ bool Foam::polyMeshGeometry::checkFaceDotProduct if (nDDotS > 0) { Info<< "Mesh non-orthogonality Max: " - << ::acos(minDDotS)/mathematicalConstant::pi*180.0 + << ::acos(minDDotS)/constant::math::pi*180.0 << " average: " << - ::acos(sumDDotS/nDDotS)/mathematicalConstant::pi*180.0 + ::acos(sumDDotS/nDDotS)/constant::math::pi*180.0 << endl; } } @@ -1170,7 +1171,7 @@ bool Foam::polyMeshGeometry::checkVolRatio { label face0 = baffles[i].first(); label face1 = baffles[i].second(); - + scalar ownVol = mag(cellVolumes[own[face0]]); scalar neiVol = mag(cellVolumes[own[face1]]); @@ -1257,7 +1258,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles << abort(FatalError); } - const scalar maxSin = Foam::sin(maxDeg/180.0*mathematicalConstant::pi); + const scalar maxSin = Foam::sin(maxDeg/180.0*constant::math::pi); const faceList& fcs = mesh.faces(); @@ -1338,7 +1339,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles { scalar maxConcaveDegr = Foam::asin(Foam::min(1.0, maxEdgeSin)) - * 180.0/mathematicalConstant::pi; + *180.0/constant::math::pi; Info<< "There are " << nConcave << " faces with concave angles between consecutive" @@ -1823,7 +1824,7 @@ bool Foam::polyMeshGeometry::checkCellDeterminant forAll(cFaces, cFaceI) { label faceI = cFaces[cFaceI]; - + scalar magArea = mag(faceAreas[faceI]); magAreaSum += magArea; @@ -1850,7 +1851,7 @@ bool Foam::polyMeshGeometry::checkCellDeterminant nWarnDet++; } } - + reduce(minDet, minOp()); reduce(sumDet, sumOp()); reduce(nSumDet, sumOp