diff --git a/applications/test/fieldDependency/Make/files b/applications/test/fieldDependency/Make/files new file mode 100644 index 0000000000..98fd335a17 --- /dev/null +++ b/applications/test/fieldDependency/Make/files @@ -0,0 +1,3 @@ +fieldDependency.C + +EXE = $(FOAM_USER_APPBIN)/fieldDependency diff --git a/applications/test/fieldDependency/Make/options b/applications/test/fieldDependency/Make/options new file mode 100644 index 0000000000..fa15f12452 --- /dev/null +++ b/applications/test/fieldDependency/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/test/fieldDependency/fieldDependency.C b/applications/test/fieldDependency/fieldDependency.C new file mode 100644 index 0000000000..fa3c7b2e86 --- /dev/null +++ b/applications/test/fieldDependency/fieldDependency.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Description + Test field dependencies. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "volFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Main program: + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + Info<< "Creating field T\n" << endl; + volScalarField T + ( + IOobject + ( + "T", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0) + ); + + Info<< "Creating field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0) + ); + + + Info<< "p.eventNo:" << p.eventNo() << endl; + Info<< "p.uptodate:" << p.upToDate("T")<< endl; + + // Change T and mark as uptodate. + Info<< "Changing T" << endl; + T = 0.0; + T.setUpToDate(); + Info<< "T.eventNo:" << T.eventNo() << endl; + + // Check p dependency: + Info<< "p.uptodate:" << p.upToDate("T")<< endl; + + // Change p and mark as uptodate. + Info<< "Changing p." << endl; + p.setUpToDate(); + Info<< "p.uptodate:" << p.upToDate("T")<< endl; + Info<< "p.eventNo:" << p.eventNo() << endl; + + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 54fd1bdf4f..d16f4f23cc 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -445,12 +445,12 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); - scalar minCos = Foam::cos(featureAngle*constant::mathematical::pi/180.0); + scalar minCos = Foam::cos(degToRad(featureAngle)); scalar concaveAngle = defaultConcaveAngle; args.optionReadIfPresent("concaveAngle", concaveAngle); - scalar concaveSin = Foam::sin(concaveAngle*constant::mathematical::pi/180.0); + scalar concaveSin = Foam::sin(degToRad(concaveAngle)); 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 c83ab27583..f9f47c815a 100644 --- a/applications/utilities/mesh/advanced/splitCells/splitCells.C +++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C @@ -539,9 +539,8 @@ int main(int argc, char *argv[]) scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])())); - scalar radAngle = featureAngle*constant::mathematical::pi/180.0; - scalar minCos = Foam::cos(radAngle); - scalar minSin = Foam::sin(radAngle); + scalar minCos = Foam::cos(degToRad(featureAngle)); + scalar minSin = Foam::sin(degToRad(featureAngle)); bool readSet = args.optionFound("set"); bool geometry = args.optionFound("geometry"); diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index 9ed5e27004..ba2b615df1 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -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*constant::mathematical::pi/180.0); + scalar tanTheta = Foam::tan(degToRad(2.5)); 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 740b87a391..af2c429bdc 100644 --- a/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C +++ b/applications/utilities/mesh/conversion/polyDualMesh/polyDualMeshApp.C @@ -91,7 +91,7 @@ void simpleMarkFeatures labelList& multiCellFeaturePoints ) { - scalar minCos = Foam::cos(featureAngle*constant::mathematical::pi/180.0); + scalar minCos = Foam::cos(degToRad(featureAngle)); 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*constant::mathematical::pi/180.0); + scalar minCos = Foam::cos(degToRad(featureAngle)); 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 bfd1dae882..da0f868388 100644 --- a/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C +++ b/applications/utilities/mesh/conversion/starToFoam/createCoupleMatches.C @@ -99,7 +99,7 @@ void starMesh::createCoupleMatches() << coupleI << ". STAR couple ID: " << couples_[coupleI].coupleID() << endl << "The angle between face normals is " - << Foam::acos(faceAreaAngle)/constant::mathematical::pi*180 + << radToDeg(Foam::acos(faceAreaAngle)) << " deg." << endl << "master cell: " << fp.masterCell() << " STAR number: " << starCellID_[fp.masterCell()] diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C index eac10738cf..67abf36564 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeModel/wedge/wedge.C @@ -51,8 +51,7 @@ wedge::wedge(const dictionary& dict) axis_(coeffDict_.lookup("axis")), angle_ ( - readScalar(coeffDict_.lookup("angle")) - *constant::mathematical::pi/180.0 + degToRad(readScalar(coeffDict_.lookup("angle"))) ) {} diff --git a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C index 7161e6bb70..15affd66e0 100644 --- a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C +++ b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C @@ -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*constant::mathematical::pi/180.0); + scalar minCos = Foam::cos(degToRad(featureAngle)); Info<< "Feature:" << featureAngle << endl << "minCos :" << minCos << endl diff --git a/src/Allwmake b/src/Allwmake index 2564ccf9e3..e4724a1e8f 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -38,8 +38,6 @@ wmake libso sampling wmake libso dynamicMesh wmake libso dynamicFvMesh wmake libso topoChangerFvMesh -wmake libso fvMotionSolver -wmake libso engine wmake libso ODE wmake libso randomProcesses @@ -56,4 +54,7 @@ wmake libso errorEstimation fvAgglomerationMethods/Allwmake +wmake libso fvMotionSolver +wmake libso engine + # ----------------------------------------------------------------- end-of-file diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 6ba6b90cf1..2823c2a9ec 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -1,6 +1,6 @@ global/global.Cver -global/dimensionedConstants/dimensionedConstants.C -global/dimensionedConstants/constants/constants.C +global/constants/constants.C +global/constants/dimensionedConstants.C global/argList/argList.C global/clock/clock.C diff --git a/src/OpenFOAM/db/Time/TimeState.H b/src/OpenFOAM/db/Time/TimeState.H index 56fb54d7b8..a9f1c90ef2 100644 --- a/src/OpenFOAM/db/Time/TimeState.H +++ b/src/OpenFOAM/db/Time/TimeState.H @@ -72,10 +72,8 @@ public: TimeState(); - // Destructor - - //- Virtual destructor - virtual ~TimeState(); + //- Destructor + virtual ~TimeState(); // Member functions @@ -89,22 +87,34 @@ public: virtual scalar timeToUserTime(const scalar t) const; //- Return current time value - virtual scalar timeOutputValue() const; + scalar timeOutputValue() const; //- Return current time index - virtual label timeIndex() const; + label timeIndex() const; + + //- Return time step value + inline scalar deltaTValue() const + { + return deltaT_; + } + + //- Return old time step value + inline scalar deltaT0Value() const + { + return deltaT0_; + } //- Return time step - virtual dimensionedScalar deltaT() const; + dimensionedScalar deltaT() const; //- Return old time step - virtual dimensionedScalar deltaT0() const; + dimensionedScalar deltaT0() const; // Check //- Return true if this is an output time - virtual bool outputTime() const; + bool outputTime() const; }; diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.C b/src/OpenFOAM/global/constants/atomic/atomicConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.C rename to src/OpenFOAM/global/constants/atomic/atomicConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H b/src/OpenFOAM/global/constants/atomic/atomicConstants.H similarity index 97% rename from src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H rename to src/OpenFOAM/global/constants/atomic/atomicConstants.H index c257374441..b732207d2c 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/atomic/atomicConstants.H +++ b/src/OpenFOAM/global/constants/atomic/atomicConstants.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Namespace - Foam::constant::atom + Foam::constant::atomic Description Atomic constants @@ -68,7 +68,7 @@ namespace atomic // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace atomic -} // end namespace constant +} // End namespace constant } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/constants.C b/src/OpenFOAM/global/constants/constants.C similarity index 96% rename from src/OpenFOAM/global/dimensionedConstants/constants/constants.C rename to src/OpenFOAM/global/constants/constants.C index f921cba983..079343360f 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/constants.C +++ b/src/OpenFOAM/global/constants/constants.C @@ -22,9 +22,6 @@ 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 - \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/constants.H b/src/OpenFOAM/global/constants/constants.H similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/constants.H rename to src/OpenFOAM/global/constants/constants.H diff --git a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C b/src/OpenFOAM/global/constants/dimensionedConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.C rename to src/OpenFOAM/global/constants/dimensionedConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H b/src/OpenFOAM/global/constants/dimensionedConstants.H similarity index 93% rename from src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H rename to src/OpenFOAM/global/constants/dimensionedConstants.H index 989089c0b0..fbba918e24 100644 --- a/src/OpenFOAM/global/dimensionedConstants/dimensionedConstants.H +++ b/src/OpenFOAM/global/constants/dimensionedConstants.H @@ -27,9 +27,10 @@ Global Description Dictionary reading and supplying the dimensioned constants used within - OpenFOAM particularly for thermodynamics. The values are read from the - OpenFOAM controlDict and should be changed to run with a different set of - units from the default SI units. + OpenFOAM, particularly for thermodynamics. + + The values are read from the OpenFOAM etc/controlDict and should be + changed to run with a different set of units from the default SI units. SourceFiles dimensionedConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.C b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.C rename to src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H similarity index 97% rename from src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H rename to src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H index 54586cda47..0d4cd6df14 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/electromagnetic/electromagneticConstants.H +++ b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Namespace - Foam::constant::em + Foam::constant::electromagnetic Description Electromagnetic constants @@ -77,7 +77,7 @@ namespace electromagnetic // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace electromagnetic -} // end namespace constant +} // End namespace constant } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.C b/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.C rename to src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.H b/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.H similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/fundamental/fundamentalConstants.H rename to src/OpenFOAM/global/constants/fundamental/fundamentalConstants.H diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/math/mathematicalConstants.H b/src/OpenFOAM/global/constants/math/mathematicalConstants.H similarity index 79% rename from src/OpenFOAM/global/dimensionedConstants/constants/math/mathematicalConstants.H rename to src/OpenFOAM/global/constants/math/mathematicalConstants.H index 0c7e584ed8..64811272d8 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/math/mathematicalConstants.H +++ b/src/OpenFOAM/global/constants/math/mathematicalConstants.H @@ -26,7 +26,7 @@ Namespace Foam::constant::mathematical Description - mathematical constants + mathematical constants and conversion functions \*---------------------------------------------------------------------------*/ @@ -56,7 +56,24 @@ namespace mathematical // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace mathematical -} // end namespace constant +} // End namespace constant + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Conversion from degrees to radians +inline scalar degToRad(const scalar& deg) +{ + return (deg*constant::mathematical::pi/180.0); +} + +//- Conversion from radians to degrees +inline scalar radToDeg(const scalar& rad) +{ + return (rad*180.0/constant::mathematical::pi); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.C b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.C rename to src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H similarity index 97% rename from src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H rename to src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H index 7f25e0dfb7..920f390e27 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/physicoChemical/physicoChemicalConstants.H +++ b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Namespace - Foam::constant::phys + Foam::constant::physicoChemical Description Physico-chemical constants @@ -71,7 +71,7 @@ namespace physicoChemical // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace physicoChemical -} // end namespace constant +} // End namespace constant } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.C b/src/OpenFOAM/global/constants/universal/universalConstants.C similarity index 100% rename from src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.C rename to src/OpenFOAM/global/constants/universal/universalConstants.C diff --git a/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H b/src/OpenFOAM/global/constants/universal/universalConstants.H similarity index 98% rename from src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H rename to src/OpenFOAM/global/constants/universal/universalConstants.H index 305e30fe19..85f8f1d9d8 100644 --- a/src/OpenFOAM/global/dimensionedConstants/constants/universal/universalConstants.H +++ b/src/OpenFOAM/global/constants/universal/universalConstants.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Namespace - Foam::constant::uni + Foam::constant::universal Description Universal constants diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 030b3df9ae..c63dceec4e 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -59,11 +59,8 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName) IOobject::NO_WRITE ) ), - relaxationFactors_ - ( - ITstream("relaxationFactors", - tokenList())() - ), + cache_(ITstream("cache", tokenList())()), + relaxationFactors_(ITstream("relaxationFactors", tokenList())()), defaultRelaxationFactor_(0), solvers_(ITstream("solvers", tokenList())()) { @@ -151,44 +148,14 @@ Foam::label Foam::solution::upgradeSolverDict } -bool Foam::solution::read() +bool Foam::solution::cache(const word& name) const { - if (regIOobject::read()) + if (debug) { - const dictionary& dict = solutionDict(); - - if (dict.found("relaxationFactors")) - { - relaxationFactors_ = dict.subDict("relaxationFactors"); - } - - relaxationFactors_.readIfPresent("default", defaultRelaxationFactor_); - - if (dict.found("solvers")) - { - solvers_ = dict.subDict("solvers"); - upgradeSolverDict(solvers_); - } - - return true; + Info<< "Find cache entry for " << name << endl; } - else - { - return false; - } -} - -const Foam::dictionary& Foam::solution::solutionDict() const -{ - if (found("select")) - { - return subDict(word(lookup("select"))); - } - else - { - return *this; - } + return cache_.found(name); } @@ -235,6 +202,19 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const } +const Foam::dictionary& Foam::solution::solutionDict() const +{ + if (found("select")) + { + return subDict(word(lookup("select"))); + } + else + { + return *this; + } +} + + const Foam::dictionary& Foam::solution::solverDict(const word& name) const { if (debug) @@ -259,4 +239,37 @@ const Foam::dictionary& Foam::solution::solver(const word& name) const } +bool Foam::solution::read() +{ + if (regIOobject::read()) + { + const dictionary& dict = solutionDict(); + + if (dict.found("cache")) + { + cache_ = dict.subDict("cache"); + } + + if (dict.found("relaxationFactors")) + { + relaxationFactors_ = dict.subDict("relaxationFactors"); + } + + relaxationFactors_.readIfPresent("default", defaultRelaxationFactor_); + + if (dict.found("solvers")) + { + solvers_ = dict.subDict("solvers"); + upgradeSolverDict(solvers_); + } + + return true; + } + else + { + return false; + } +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index d3bf008475..36724bf495 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -53,6 +53,9 @@ class solution { // Private data + //- Dictionary of temporary fields to cache + dictionary cache_; + //- Dictionary of relaxation factors for all the fields dictionary relaxationFactors_; @@ -62,6 +65,7 @@ class solution //- Dictionary of solver parameters for all the fields dictionary solvers_; + // Private Member Functions //- Disallow default bitwise copy construct and assignment @@ -90,9 +94,8 @@ public: // Access - //- Return the selected sub-dictionary of solvers if the "select" - // keyword is given, otherwise return the complete dictionary - const dictionary& solutionDict() const; + //- Return true if the given field should be cached + bool cache(const word& name) const; //- Return true if the relaxation factor is given for the field bool relax(const word& name) const; @@ -100,6 +103,10 @@ public: //- Return the relaxation factor for the given field scalar relaxationFactor(const word& name) const; + //- Return the selected sub-dictionary of solvers if the "select" + // keyword is given, otherwise return the complete dictionary + const dictionary& solutionDict() const; + //- Return the solver controls dictionary for the given field const dictionary& solverDict(const word& name) const; diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C b/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C index c5f9a80250..cf7dfc9400 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C +++ b/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C @@ -159,9 +159,9 @@ Foam::pointHit Foam::face::intersection if (curHit.hit()) { - if (Foam::mag(curHit.distance()) < nearestHitDist) + if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist)) { - nearestHitDist = Foam::mag(curHit.distance()); + nearestHitDist = curHit.distance(); nearest.setHit(); nearest.setPoint(curHit.hitPoint()); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C index 258cb163a1..6350c93446 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C @@ -410,7 +410,7 @@ bool Foam::primitiveMesh::checkFaceOrthogonality // Severe nonorthogonality threshold const scalar severeNonorthogonalityThreshold = - ::cos(nonOrthThreshold_/180.0*constant::mathematical::pi); + ::cos(degToRad(nonOrthThreshold_)); scalar minDDotS = GREAT; @@ -472,9 +472,8 @@ bool Foam::primitiveMesh::checkFaceOrthogonality if (debug || report) { Info<< " Mesh non-orthogonality Max: " - << ::acos(minDDotS)/constant::mathematical::pi*180.0 - << " average: " << - ::acos(sumDDotS/neiSize)/constant::mathematical::pi*180.0 + << radToDeg(::acos(minDDotS)) + << " average: " << radToDeg(::acos(sumDDotS/neiSize)) << endl; } } @@ -839,7 +838,7 @@ bool Foam::primitiveMesh::checkFaceAngles << exit(FatalError); } - const scalar maxSin = Foam::sin(maxDeg/180.0*constant::mathematical::pi); + const scalar maxSin = Foam::sin(degToRad(maxDeg)); const pointField& p = points(); const faceList& fcs = faces(); @@ -915,8 +914,7 @@ bool Foam::primitiveMesh::checkFaceAngles if (nConcave > 0) { scalar maxConcaveDegr = - Foam::asin(Foam::min(1.0, maxEdgeSin)) - *180.0/constant::mathematical::pi; + radToDeg(Foam::asin(Foam::min(1.0, maxEdgeSin))); if (debug || report) { diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C index 688bdd81a2..8fce92f3c8 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheckMotion.C @@ -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)/constant::mathematical::pi*180.0 + << ": Angle = " << radToDeg(::acos(dDotS)) << " deg." << endl; nDotProductErrors++; diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C index 5e83fd9e78..f17e07c323 100644 --- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C @@ -44,8 +44,7 @@ namespace Foam } // Angle for polys to be considered splitHexes. -const Foam::scalar Foam::topoCellLooper::featureCos = - Foam::cos(10.0*constant::mathematical::pi/180.0); +const Foam::scalar Foam::topoCellLooper::featureCos = Foam::cos(degToRad(10.0)); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C index ea8ab52a7f..16606233d0 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/undoableMeshCutter/undoableMeshCutter.C @@ -192,7 +192,7 @@ Foam::undoableMeshCutter::undoableMeshCutter faceRemover_ ( mesh, - Foam::cos(30.0/180.0*constant::mathematical::pi) + Foam::cos(degToRad(30.0)) ) {} diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C index d95e1f34e9..83d0000ea3 100644 --- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C +++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C @@ -248,7 +248,7 @@ Foam::scalar Foam::polyMeshGeometry::checkNonOrtho << " between cells " << mesh.faceOwner()[faceI] << " and " << nei << ": Angle = " - << ::acos(dDotS)/constant::mathematical::pi*180.0 + << radToDeg(::acos(dDotS)) << " deg." << endl; } @@ -269,7 +269,7 @@ Foam::scalar Foam::polyMeshGeometry::checkNonOrtho << " between cells " << mesh.faceOwner()[faceI] << " and " << nei << ": Angle = " - << ::acos(dDotS)/constant::mathematical::pi*180.0 + << radToDeg(::acos(dDotS)) << " deg." << endl; } @@ -368,8 +368,7 @@ bool Foam::polyMeshGeometry::checkFaceDotProduct const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Severe nonorthogonality threshold - const scalar severeNonorthogonalityThreshold = - ::cos(orthWarn/180.0*constant::mathematical::pi); + const scalar severeNonorthogonalityThreshold = ::cos(degToRad(orthWarn)); // Calculate coupled cell centre @@ -504,9 +503,8 @@ bool Foam::polyMeshGeometry::checkFaceDotProduct if (nDDotS > 0) { Info<< "Mesh non-orthogonality Max: " - << ::acos(minDDotS)/constant::mathematical::pi*180.0 - << " average: " << - ::acos(sumDDotS/nDDotS)/constant::mathematical::pi*180.0 + << radToDeg(::acos(minDDotS)) + << " average: " << radToDeg(::acos(sumDDotS/nDDotS)) << endl; } } @@ -1258,7 +1256,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles << abort(FatalError); } - const scalar maxSin = Foam::sin(maxDeg/180.0*constant::mathematical::pi); + const scalar maxSin = Foam::sin(degToRad(maxDeg)); const faceList& fcs = mesh.faces(); @@ -1338,8 +1336,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles if (maxEdgeSin > SMALL) { scalar maxConcaveDegr = - Foam::asin(Foam::min(1.0, maxEdgeSin)) - *180.0/constant::mathematical::pi; + radToDeg(Foam::asin(Foam::min(1.0, maxEdgeSin))); Info<< "There are " << nConcave << " faces with concave angles between consecutive" diff --git a/src/engine/engineTime/engineTime.C b/src/engine/engineTime/engineTime.C index ef0d016880..8adf64fdcd 100644 --- a/src/engine/engineTime/engineTime.C +++ b/src/engine/engineTime/engineTime.C @@ -123,12 +123,6 @@ bool Foam::engineTime::read() } -Foam::scalar Foam::engineTime::degToRad(const scalar deg) const -{ - return constant::mathematical::pi*deg/180.0; -} - - Foam::scalar Foam::engineTime::degToTime(const scalar theta) const { // 6 * rpm => deg/s diff --git a/src/engine/engineTime/engineTime.H b/src/engine/engineTime/engineTime.H index f97701d240..e63a7caa0b 100644 --- a/src/engine/engineTime/engineTime.H +++ b/src/engine/engineTime/engineTime.H @@ -121,9 +121,6 @@ public: // Conversion - //- Convert degrees to radians - scalar degToRad(const scalar rad) const; - //- Convert degrees to seconds (for given engine speed in RPM) scalar degToTime(const scalar theta) const; diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C index 87cc39bfdc..5bcb692065 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolation.C @@ -345,7 +345,8 @@ void surfaceInterpolation::makeCorrectionVectors() const // Calculate the non-orthogonality for meshes with 1 face or more if (returnReduce(magSf.size(), sumOp