diff --git a/applications/solvers/compressible/rhoSimplecFoam/UEqn.H b/applications/solvers/compressible/rhoSimplecFoam/UEqn.H deleted file mode 100644 index 21ec2646be..0000000000 --- a/applications/solvers/compressible/rhoSimplecFoam/UEqn.H +++ /dev/null @@ -1,11 +0,0 @@ - // Solve the Momentum equation - - tmp UEqn - ( - fvm::div(phi, U) - + turbulence->divDevRhoReff(U) - ); - - UEqn().relax(); - - solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/compressible/rhoSimplecFoam/hEqn.H b/applications/solvers/compressible/rhoSimplecFoam/hEqn.H deleted file mode 100644 index bec9ed3ae0..0000000000 --- a/applications/solvers/compressible/rhoSimplecFoam/hEqn.H +++ /dev/null @@ -1,28 +0,0 @@ -{ - fvScalarMatrix hEqn - ( - fvm::div(phi, h) - - fvm::Sp(fvc::div(phi), h) - - fvm::laplacian(turbulence->alphaEff(), h) - == - fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p, "div(U,p)")) - - p*fvc::div(phi/fvc::interpolate(rho)) - ); - - hEqn.relax(); - - hEqn.solve(); - - thermo.correct(); - - rho = thermo.rho(); - - if (!transonic) - { - rho.relax(); - } - - Info<< "rho max/min : " - << max(rho).value() << " " - << min(rho).value() << endl; -} diff --git a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H index 43443a507b..2e370cc447 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H +++ b/applications/solvers/compressible/rhoSimplecFoam/pEqn.H @@ -1,3 +1,8 @@ +rho = thermo.rho(); +rho = max(rho, rhoMin); +rho = min(rho, rhoMax); +rho.relax(); + volScalarField p0 = p; volScalarField AU = UEqn().A(); @@ -24,8 +29,8 @@ if (transonic) + phid*(fvc::interpolate(p) - fvc::interpolate(p, "UD")) ); - refCast(p.boundaryField()[1]).refValue() - = p.boundaryField()[1]; + //refCast(p.boundaryField()[1]).refValue() + // = p.boundaryField()[1]; fvScalarMatrix pEqn ( @@ -35,6 +40,7 @@ if (transonic) + fvc::div(phid)*p - fvm::laplacian(rho/AtU, p) ); + //pEqn.relax(); pEqn.setReference(pRefCell, pRefValue); diff --git a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C b/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C index 541e7b388f..c959cfdd3e 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C +++ b/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C @@ -57,6 +57,7 @@ int main(int argc, char *argv[]) #include "readSIMPLEControls.H" p.storePrevIter(); + rho.storePrevIter(); if (!transonic) { diff --git a/bin/foamJob b/bin/foamJob index 12f3211d2f..c882cefefe 100755 --- a/bin/foamJob +++ b/bin/foamJob @@ -188,12 +188,12 @@ then fi mpiopts="-np $NPROCS" - # + # # is the machine ready to run parallel? # echo "Parallel processing using $WM_MPLIB with $NPROCS processors" case "$WM_MPLIB" in - OPENMPI) + *OPENMPI) # add hostfile info for hostfile in \ hostfile \ diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 3b0c6f7fce..3c4aaf6a9a 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -221,7 +221,7 @@ done unset cmd case "$WM_MPLIB" in -OPENMPI) +*OPENMPI) cmd="mpirun -app $PWD/mpirun.schema : contents - lines=$(git grep -E -hn -e "$reBad" $scope"$f" | - sed -e 's@:.*@@' | - tr '\n' ' ' - ) - [ -n "$lines" ] && echo "$Indent$f -- lines: $lines" + case "$f" in + # exclude potential makefiles + (wmake/[Mm]akefile* | wmake/rules/*) + ;; + (*) + # parse line numbers from grep output: + # : contents + lines=$(git grep -E -hn -e "$reBad" $scope"$f" | + sed -e 's@:.*@@' | + tr '\n' ' ' + ) + [ -n "$lines" ] && echo "$Indent$f -- lines: $lines" + ;; + esac done ) @@ -243,7 +250,7 @@ checkLineLengthNonComments() # parse line numbers from grep output: # : contents lines=$(git grep -hn -e '^.\{81,\}' \ - --and --not -e "^ *//" \ + --and --not -e '^ *//' \ $scope"$f" | sed -e 's@:.*@@' | tr '\n' ' ' @@ -276,7 +283,7 @@ checkLineLengthNonDirective() # parse line numbers from grep output: # : contents lines=$(git grep -hn -e '^.\{81,\}' \ - --and --not -e "^ *#" \ + --and --not -e '^ *#' \ $scope"$f" | sed -e 's@:.*@@' | tr '\n' ' ' diff --git a/bin/tools/pre-receive-hook b/bin/tools/pre-receive-hook index f289b99be7..84ac684bc3 100755 --- a/bin/tools/pre-receive-hook +++ b/bin/tools/pre-receive-hook @@ -109,13 +109,20 @@ checkIllegalCode() badFiles=$( for f in $fileList do - # parse line numbers from grep output: - # : contents - lines=$(git grep -E -hn -e "$reBad" $scope"$f" | - sed -e 's@:.*@@' | - tr '\n' ' ' - ) - [ -n "$lines" ] && echo "$Indent$f -- lines: $lines" + case "$f" in + # exclude potential makefiles + (wmake/[Mm]akefile* | wmake/rules/*) + ;; + (*) + # parse line numbers from grep output: + # : contents + lines=$(git grep -E -hn -e "$reBad" $scope"$f" | + sed -e 's@:.*@@' | + tr '\n' ' ' + ) + [ -n "$lines" ] && echo "$Indent$f -- lines: $lines" + ;; + esac done ) @@ -206,7 +213,7 @@ checkLineLengthNonComments() # parse line numbers from grep output: # : contents lines=$(git grep -hn -e '^.\{81,\}' \ - --and --not -e "^ *//" \ + --and --not -e '^ *//' \ $scope"$f" | sed -e 's@:.*@@' | tr '\n' ' ' @@ -239,7 +246,7 @@ checkLineLengthNonDirective() # parse line numbers from grep output: # : contents lines=$(git grep -hn -e '^.\{81,\}' \ - --and --not -e "^ *#" \ + --and --not -e '^ *#' \ $scope"$f" | sed -e 's@:.*@@' | tr '\n' ' ' diff --git a/doc/changes/inotify.txt b/doc/changes/inotify.txt index 146dc55a05..35b50ee2d4 100644 --- a/doc/changes/inotify.txt +++ b/doc/changes/inotify.txt @@ -24,21 +24,63 @@ be quite a gain on large numbers of processors. - all file monitoring is done by an instance of 'fileMonitor' in the Time -class. The fileMonitor class can be found in OSspecific. Default is -to use the (linux-specific) 'inotify' system calls. -If compiled with -DFOAM_USE_STAT it will revert to the current 'stat' system -calls. +class. The fileMonitor class can be found in OSspecific. It uses either +timestamps as before or the (linux-specific) 'inotify' system framework +(available only if compiled with -DFOAM_USE_INOTIFY). -- inotify does not need timestamps. There is no need for fileModificationSkew +- the monitoring can be done in one of four modes as set by + OptimisationSwitches::fileModificationChecking + + - timeStamp : old behaviour : all nodes check the timestamp + - inotify : using inotify instead of timestamps + - timeStampMaster,inotifyMaster : only the master node checks the file + and only the master node reads it and distribute it to the + slaves. This makes runTimeModifiable possible on distributed + running (see below). + +- distributed running: + - set fileModificationChecking to e.g. timeStampMaster + - decompose a case, e.g. cavity + - copy system and constant to processor0/ + - put the all the processor* directories on the wanted nodes inside + the case directory. E.g. + - on master have /tmp/cavity/processor0 + - on slaveN have /tmp/cavity/processorN + - so to reiterate: + - there is no need for cavity/constant or cavity/system, all the + dictionaries are only in processor0/constant or processor0/system + - the slave processor directories have no system directory and the + constant directory only contains the mesh. + - start the job in distributed mode by specifying the slave roots + (so one less than the number of processors) with + the -roots command line option: + + mpirun -np 2 icoFoam -roots '("/tmp")' -parallel + + - the alternative to the -roots option is to have a + cavity/system/decomposeParDict on the master with + distributed yes; + roots ("/tmp"); + + +Details: +- timeStampMaster, inotifyMaster : this works only for IOdictionaries that +are READ_IF_MODIFIED. It means that slaves read exactly the same dictionary +as the master so cannot be used for dictionaries that contain e.g. mesh +specific information. + +- inotify is a monitoring framework used to monitor changes in +lots of files (e.g. used in desktop searched like beagle). You specify +files to monitor and then get warned for any changes to these files. +It does not need timestamps. There is no need for fileModificationSkew to allow for time differences. (there can still temporarily be a difference -in modified status between different processors due to nfs lagging) - +in modified status between different processors due to nfs lagging). The big +problem is that it does not work over nfs3 (not sure about nfs4). - fileMonitor stores two hashtables per file so there is a small overhead adding and removing files from monitoring. - - if runTimeModifiable is false at start of run no files will get monitored, however if runTimeModified gets set to false during the run the files will still get monitored (though never reloaded). This is only a hypothetical @@ -46,7 +88,6 @@ problem in that the kernel still stores events for the monitored files. However inotify is very efficient - e.g. it gets used to track changes on file systems for desktop search engines. - - in the old system one could call modified() on any object and get and uptodate state. In the new system it will return the state from the last runTime++ (which if it triggered any re-reads will have reset the diff --git a/etc/controlDict b/etc/controlDict index 4553dd2688..f9a23748ee 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -874,6 +874,14 @@ InfoSwitches OptimisationSwitches { fileModificationSkew 10; + + //- Modification checking: + // - timeStamp : use modification time on file + // - inotify : use inotify framework + // - timeStampMaster : do time stamp (and file reading) only on master. + // - inotifyMaster : do inotify (and file reading) only on master. + fileModificationChecking timeStampMaster;//inotify;timeStamp;inotifyMaster; + commsType nonBlocking; //scheduled; //blocking; floatTransfer 0; nProcsSimpleSum 0; diff --git a/etc/settings.csh b/etc/settings.csh index 8159eed539..f3bec0d915 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -90,17 +90,20 @@ switch ("$compilerInstall") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: + case Gcc++0x: set gcc_version=gcc-4.4.3 set gmp_version=gmp-5.0.1 set mpfr_version=mpfr-2.4.2 breaksw case Gcc45: + case Gcc45++0x: set gcc_version=gcc-4.5.0 set gmp_version=gmp-5.0.1 set mpfr_version=mpfr-2.4.2 set mpc_version=mpc-0.8.1 breaksw case Gcc44: + case Gcc44++0x: set gcc_version=gcc-4.4.3 set gmp_version=gmp-5.0.1 set mpfr_version=mpfr-2.4.2 @@ -190,6 +193,18 @@ case OpenFOAM: endsw +# +# add c++0x flags for external programs +# +if ( $?WM_CXXFLAGS ) then + switch ("$WM_COMPILER") + case Gcc*++0x: + setenv WM_CXXFLAGS "$WM_CXXFLAGS -std=c++0x" + breaksw + endsw +endif + + # boost and CGAL # ~~~~~~~~~~~~~~ @@ -236,9 +251,7 @@ case OPENMPI: breaksw case SYSTEMOPENMPI: - - # This uses the installed openmpi. It needs mpicc installed! - + # Use the system installed openmpi, get library directory via mpicc set mpi_version=openmpi-system # Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI diff --git a/etc/settings.sh b/etc/settings.sh index 5b53c59f2b..785c3f97dd 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -111,18 +111,18 @@ unset MPFR_ARCH_PATH case "${compilerInstall:-OpenFOAM}" in OpenFOAM) case "$WM_COMPILER" in - Gcc) + Gcc | Gcc++0x) gcc_version=gcc-4.4.3 gmp_version=gmp-5.0.1 mpfr_version=mpfr-2.4.2 ;; - Gcc45) + Gcc45 | Gcc45++0x) gcc_version=gcc-4.5.0 gmp_version=gmp-5.0.1 mpfr_version=mpfr-2.4.2 mpc_version=mpc-0.8.1 ;; - Gcc44) + Gcc44 | Gcc44++0x) gcc_version=gcc-4.4.3 gmp_version=gmp-5.0.1 mpfr_version=mpfr-2.4.2 @@ -213,6 +213,19 @@ OpenFOAM) esac +# +# add c++0x flags for external programs +# +if [ -n "$WM_CXXFLAGS" ] +then + case "$WM_COMPILER" in + Gcc*++0x) + WM_CXXFLAGS="$WM_CXXFLAGS -std=c++0x" + ;; + esac +fi + + # boost and CGAL # ~~~~~~~~~~~~~~ @@ -261,7 +274,7 @@ OPENMPI) ;; SYSTEMOPENMPI) - # use the system installed openmpi, get library directory via mpicc + # Use the system installed openmpi, get library directory via mpicc mpi_version=openmpi-system # Set compilation flags here instead of in wmake/rules/../mplibSYSTEMOPENMPI diff --git a/src/OSspecific/POSIX/Allwmake b/src/OSspecific/POSIX/Allwmake index d3b21b47fc..e8260fff31 100755 --- a/src/OSspecific/POSIX/Allwmake +++ b/src/OSspecific/POSIX/Allwmake @@ -12,9 +12,9 @@ unset COMP_FLAGS LINK_FLAGS if [ -f /usr/include/sys/inotify.h -a "${1%USE_STAT}" = "$1" ] then echo "Found -- using inotify for file monitoring." - unset COMP_FLAGS + export COMP_FLAGS="-DFOAM_USE_INOTIFY" else - export COMP_FLAGS="-DFOAM_USE_STAT" + unset COMP_FLAGS fi diff --git a/src/OSspecific/POSIX/clockTime/clockTime.C b/src/OSspecific/POSIX/clockTime/clockTime.C index 31a6d2c4bd..3c65d023ff 100644 --- a/src/OSspecific/POSIX/clockTime/clockTime.C +++ b/src/OSspecific/POSIX/clockTime/clockTime.C @@ -24,38 +24,25 @@ License \*---------------------------------------------------------------------------*/ #include "clockTime.H" -#include "scalar.H" #include -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void clockTime::getTime(struct timeval& t) +void Foam::clockTime::getTime(timeType& t) { - gettimeofday(&t, NULL); + gettimeofday(&t, 0); } -double clockTime::timeDifference -( - const struct timeval& start, - const struct timeval& end -) +double Foam::clockTime::timeDifference(const timeType& beg, const timeType& end) { - return end.tv_sec - start.tv_sec + 1E-6*(end.tv_usec - start.tv_usec); + return end.tv_sec - beg.tv_sec + 1E-6*(end.tv_usec - beg.tv_usec); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -clockTime::clockTime() +Foam::clockTime::clockTime() { getTime(startTime_); lastTime_ = startTime_; @@ -65,14 +52,14 @@ clockTime::clockTime() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -double clockTime::elapsedTime() const +double Foam::clockTime::elapsedTime() const { getTime(newTime_); return timeDifference(startTime_, newTime_); } -double clockTime::timeIncrement() const +double Foam::clockTime::timeIncrement() const { lastTime_ = newTime_; getTime(newTime_); @@ -80,8 +67,4 @@ double clockTime::timeIncrement() const } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OSspecific/POSIX/clockTime/clockTime.H b/src/OSspecific/POSIX/clockTime/clockTime.H index 5237233f05..c8bbbdba6c 100644 --- a/src/OSspecific/POSIX/clockTime/clockTime.H +++ b/src/OSspecific/POSIX/clockTime/clockTime.H @@ -44,43 +44,45 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class clockTime Declaration + Class clockTime Declaration \*---------------------------------------------------------------------------*/ class clockTime { // Private data - struct timeval startTime_; - mutable struct timeval lastTime_; - mutable struct timeval newTime_; + //- Time structure used + typedef struct timeval timeType; - static void getTime(struct timeval& t); + timeType startTime_; - static double timeDifference - ( - const struct timeval& start, - const struct timeval& end - ); + mutable timeType lastTime_; + mutable timeType newTime_; + + // Private Member Functions + + //- Retrieve the current time values from the system + static void getTime(timeType&); + + //- Difference between two times + static double timeDifference(const timeType& beg, const timeType& end); public: // Constructors - //- Construct from components + //- Construct with the current clock time clockTime(); // Member Functions - // Access + //- Return time (in seconds) from the start + double elapsedTime() const; - //- Returns CPU time from start of run - double elapsedTime() const; - - //- Returns CPU time from last call of clockTimeIncrement() - double timeIncrement() const; + //- Return time (in seconds) since last call to timeIncrement() + double timeIncrement() const; }; diff --git a/src/OSspecific/POSIX/cpuTime/cpuTime.C b/src/OSspecific/POSIX/cpuTime/cpuTime.C index b5ef0c4283..5af53026fd 100644 --- a/src/OSspecific/POSIX/cpuTime/cpuTime.C +++ b/src/OSspecific/POSIX/cpuTime/cpuTime.C @@ -21,45 +21,32 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - Starts timing CPU usage and return elapsed time from start. - \*---------------------------------------------------------------------------*/ #include "cpuTime.H" - #include -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // -long cpuTime::Hz_(sysconf(_SC_CLK_TCK)); +const long Foam::cpuTime::Hz_(sysconf(_SC_CLK_TCK)); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void cpuTime::getTime(struct tms& t) +void Foam::cpuTime::getTime(timeType& t) { times(&t); } -double cpuTime::timeDifference -( - const struct tms& start, - const struct tms& end -) +double Foam::cpuTime::timeDifference(const timeType& beg, const timeType& end) { return ( double ( (end.tms_utime + end.tms_stime) - - (start.tms_utime + start.tms_stime) + - (beg.tms_utime + beg.tms_stime) )/Hz_ ); } @@ -67,7 +54,7 @@ double cpuTime::timeDifference // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -cpuTime::cpuTime() +Foam::cpuTime::cpuTime() { getTime(startTime_); lastTime_ = startTime_; @@ -77,14 +64,14 @@ cpuTime::cpuTime() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -double cpuTime::elapsedCpuTime() const +double Foam::cpuTime::elapsedCpuTime() const { getTime(newTime_); return timeDifference(startTime_, newTime_); } -double cpuTime::cpuTimeIncrement() const +double Foam::cpuTime::cpuTimeIncrement() const { lastTime_ = newTime_; getTime(newTime_); @@ -92,8 +79,4 @@ double cpuTime::cpuTimeIncrement() const } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OSspecific/POSIX/cpuTime/cpuTime.H b/src/OSspecific/POSIX/cpuTime/cpuTime.H index e3a6376360..33e3259304 100644 --- a/src/OSspecific/POSIX/cpuTime/cpuTime.H +++ b/src/OSspecific/POSIX/cpuTime/cpuTime.H @@ -54,38 +54,41 @@ class cpuTime { // Private data - static long Hz_; + //- Time structure used + typedef struct tms timeType; - struct tms startTime_; - mutable struct tms lastTime_; - mutable struct tms newTime_; + //- Clock-ticks per second + static const long Hz_; - static void getTime(struct tms& t); + //- The start time + timeType startTime_; + mutable timeType lastTime_; + mutable timeType newTime_; - static double timeDifference - ( - const struct tms& start, - const struct tms& end - ); + // Private Member Functions + + //- Retrieve the current time values from the system + static void getTime(timeType&); + + //- Difference between two times + static double timeDifference(const timeType& beg, const timeType& end); public: // Constructors - //- Construct from components + //- Construct with the current clock time cpuTime(); // Member Functions - // Access + //- Return CPU time (in seconds) from the start + double elapsedCpuTime() const; - //- Returns CPU time from start of run - double elapsedCpuTime() const; - - //- Returns CPU time from last call of cpuTimeIncrement() - double cpuTimeIncrement() const; + //- Return CPU time (in seconds) since last call to cpuTimeIncrement() + double cpuTimeIncrement() const; }; diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index c7e590d6e5..069ef6de93 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -32,17 +32,17 @@ Class #include "PackedList.H" #include "PstreamReduceOps.H" #include "OSspecific.H" +#include "regIOobject.H" // for fileModificationSkew symbol -#ifdef FOAM_USE_STAT -# include "OSspecific.H" -# include "regIOobject.H" // for fileModificationSkew symbol -#else +#ifdef FOAM_USE_INOTIFY # include # include # include # define EVENT_SIZE ( sizeof (struct inotify_event) ) # define EVENT_LEN (EVENT_SIZE + 16) # define EVENT_BUF_LEN ( 1024 * EVENT_LEN ) +#else +# include "OSspecific.H" #endif // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -111,78 +111,77 @@ namespace Foam { public: -#ifdef FOAM_USE_STAT - //- From watch descriptor to modified time - DynamicList lastMod_; + const bool useInotify_; - //- initialize HashTable size - inline fileMonitorWatcher(const label sz = 20) - : - lastMod_(sz) - {} + // For inotify - inline bool addWatch(const label watchFd, const fileName& fName) - { - if (watchFd < lastMod_.size() && lastMod_[watchFd] != 0) - { - // Reuse of watchFd : should have lastMod set to 0. - FatalErrorIn("addWatch(const label, const fileName&)") - << "Problem adding watch " << watchFd - << " to file " << fName - << abort(FatalError); - } + //- File descriptor for the inotify instance + int inotifyFd_; - lastMod_(watchFd) = lastModified(fName); - return true; - } + //- Current watchIDs and corresponding directory id + DynamicList