From 5bb793c100226535fb706a8b6e3c115792b057a5 Mon Sep 17 00:00:00 2001 From: Sandeep Menon Date: Mon, 29 Nov 2010 11:05:16 -0500 Subject: [PATCH 01/11] objectMap: Adding capability to read from Istream. --- .../polyMesh/mapPolyMesh/objectMap/objectMap.H | 3 +++ .../polyMesh/mapPolyMesh/objectMap/objectMapI.H | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H index 047da6360..c20bb746b 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMap.H @@ -50,6 +50,7 @@ class objectMap; inline bool operator==(const objectMap& a, const objectMap& b); inline bool operator!=(const objectMap& a, const objectMap& b); inline Ostream& operator<<(Ostream&, const objectMap&); +inline Istream& operator>>(Istream&, objectMap&); /*---------------------------------------------------------------------------*\ @@ -101,6 +102,8 @@ public: // IOstream Operators friend Ostream& operator<<(Ostream&, const objectMap&); + + friend Istream& operator>>(Istream&, objectMap&); }; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMapI.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMapI.H index cde5b3a57..1574c47ab 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMapI.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/objectMap/objectMapI.H @@ -123,6 +123,18 @@ inline Ostream& operator<<(Ostream& os, const objectMap& a) } +inline Istream& operator>>(Istream& is, objectMap& a) +{ + is.readBegin("objectMap"); + is >> a.index_ >> a.masterObjects_; + is.readEnd("objectMap"); + + // Check state of Istream + is.check("Istream& operator>>(Istream&, objectMap&)"); + + return is; +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // Master namespace Foam From bb21195c46e8aa31fe67cf2af63963253c626e46 Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Mon, 29 Nov 2010 22:52:04 -0500 Subject: [PATCH 02/11] Correction to the compilation of mesquite-2.1.2. Bug fix contributed by Philippose Rajan --- ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec b/ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec index f3a558b4f..49207626e 100644 --- a/ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec +++ b/ThirdParty/rpmBuild/SPECS/mesquite-2.1.2.spec @@ -91,7 +91,6 @@ Group: Development/Tools [ -n "$WM_CXXFLAGS" ] && export CXXFLAGS="$WM_CXXFLAGS" [ -n "$WM_LDFLAGS" ] && export LDFLAGS="$WM_LDFLAGS" - GMP_VERSION=gmp-5.0.1 ./configure \ --prefix=%{_installPrefix} \ --enable-release \ @@ -104,6 +103,10 @@ Group: Development/Tools --enable-trap-fpe \ --disable-function-timers + # Remove the file include/Mesquite_all_headers.hpp + # This file will be regenerated during the compilation process + [ -e include/Mesquite_all_headers.hpp ] && rm -f include/Mesquite_all_headers.hpp + make %install From 190132af07da75118626832ada5af8a41d4b6022 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 30 Nov 2010 09:41:15 +0000 Subject: [PATCH 03/11] Cpp switch --- wmake/rules/linux64Gcc/general | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wmake/rules/linux64Gcc/general b/wmake/rules/linux64Gcc/general index 2710037b2..41494b9dc 100644 --- a/wmake/rules/linux64Gcc/general +++ b/wmake/rules/linux64Gcc/general @@ -1,4 +1,4 @@ -CPP = cpp $(GFLAGS) +CPP = cpp -P $(GFLAGS) LD = ld PROJECT_LIBS = -l$(WM_PROJECT) -liberty -ldl From 21fd0f60fb17c4a9c62ca765e4ffea32346ed405 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 30 Nov 2010 11:01:38 +0000 Subject: [PATCH 04/11] Added missing turbulence correct --- applications/solvers/multiphase/interFoam/interFoam.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/solvers/multiphase/interFoam/interFoam.C b/applications/solvers/multiphase/interFoam/interFoam.C index 16e4b0558..568d2b107 100644 --- a/applications/solvers/multiphase/interFoam/interFoam.C +++ b/applications/solvers/multiphase/interFoam/interFoam.C @@ -102,6 +102,8 @@ int main(int argc, char *argv[]) ); } + turbulence->correct(); + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" From 63ba19cf0f84884f0e4e053cd9fd167b05ac6831 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 30 Nov 2010 11:01:50 +0000 Subject: [PATCH 05/11] Formatting --- .../fvMesh/fvPatches/derived/cohesive/cohesiveFvPatch.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finiteVolume/fvMesh/fvPatches/derived/cohesive/cohesiveFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/derived/cohesive/cohesiveFvPatch.H index 56badda6d..1484b37eb 100644 --- a/src/finiteVolume/fvMesh/fvPatches/derived/cohesive/cohesiveFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/derived/cohesive/cohesiveFvPatch.H @@ -77,7 +77,7 @@ public: //- Construct from polyPatch cohesiveFvPatch ( - const polyPatch& patch, + const polyPatch& patch, const fvBoundaryMesh& bm ) : From 005dcf874bf67242ce200759cd658dc45a4f37e6 Mon Sep 17 00:00:00 2001 From: Sandeep Menon Date: Tue, 30 Nov 2010 10:59:55 -0500 Subject: [PATCH 06/11] Bug-fixes for parallel length-scale estimation. --- .../lengthScaleEstimator.C | 77 +++++++++++++++---- .../lengthScaleEstimator.H | 2 + 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C b/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C index a119596f2..f1a8149f9 100644 --- a/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C +++ b/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C @@ -242,6 +242,8 @@ void lengthScaleEstimator::writeLengthScaleInfo // Clear existing buffers sendLblBuffer_.clear(); recvLblBuffer_.clear(); + sendLvlBuffer_.clear(); + recvLvlBuffer_.clear(); sendSclBuffer_.clear(); recvSclBuffer_.clear(); @@ -251,7 +253,9 @@ void lengthScaleEstimator::writeLengthScaleInfo // Corresponding face labels sendLblBuffer_.setSize(boundary.size()); + sendLvlBuffer_.setSize(boundary.size()); recvLblBuffer_.setSize(boundary.size()); + recvLvlBuffer_.setSize(boundary.size()); // Length-scales corresponding to face-labels sendSclBuffer_.setSize(boundary.size()); @@ -266,6 +270,7 @@ void lengthScaleEstimator::writeLengthScaleInfo // Set the initial buffer size sendLblBuffer_[pI].setSize(boundary[pI].size(), 0); + sendLvlBuffer_[pI].setSize(boundary[pI].size(), 0); sendSclBuffer_[pI].setSize(boundary[pI].size(), 0.0); forAll(fCells, faceI) @@ -277,6 +282,7 @@ void lengthScaleEstimator::writeLengthScaleInfo { // Fill the send buffer. sendLblBuffer_[pI][nSendFaces[pI]] = faceI; + sendLvlBuffer_[pI][nSendFaces[pI]] = cellLevels[cI]; sendSclBuffer_[pI][nSendFaces[pI]] = lengthScale[cI]; nSendFaces[pI]++; @@ -285,6 +291,7 @@ void lengthScaleEstimator::writeLengthScaleInfo // Resize to actual value sendLblBuffer_[pI].setSize(nSendFaces[pI]); + sendLvlBuffer_[pI].setSize(nSendFaces[pI]); sendSclBuffer_[pI].setSize(nSendFaces[pI]); const processorPolyPatch& pp = @@ -330,6 +337,7 @@ void lengthScaleEstimator::writeLengthScaleInfo Pout << " Processor patch " << patchI << ' ' << pp.name() << " communicating with " << neiProcNo << " Sending: " << nSendFaces[patchI] + << " Recving: " << nRecvFaces[patchI] << endl; } @@ -345,6 +353,14 @@ void lengthScaleEstimator::writeLengthScaleInfo sendLblBuffer_[patchI].size()*sizeof(label) ); + OPstream::write + ( + Pstream::nonBlocking, + neiProcNo, + reinterpret_cast(&(sendLvlBuffer_[patchI][0])), + sendLblBuffer_[patchI].size()*sizeof(label) + ); + OPstream::write ( Pstream::nonBlocking, @@ -358,6 +374,7 @@ void lengthScaleEstimator::writeLengthScaleInfo { // Size the receive buffers recvLblBuffer_[patchI].setSize(nRecvFaces[patchI], 0); + recvLvlBuffer_[patchI].setSize(nRecvFaces[patchI], 0); recvSclBuffer_[patchI].setSize(nRecvFaces[patchI], 0.0); IPstream::read @@ -372,9 +389,17 @@ void lengthScaleEstimator::writeLengthScaleInfo ( Pstream::nonBlocking, neiProcNo, - reinterpret_cast(&(recvSclBuffer_[patchI][0])), + reinterpret_cast(&(recvLvlBuffer_[patchI][0])), nRecvFaces[patchI]*sizeof(label) ); + + IPstream::read + ( + Pstream::nonBlocking, + neiProcNo, + reinterpret_cast(&(recvSclBuffer_[patchI][0])), + nRecvFaces[patchI]*sizeof(scalar) + ); } } } @@ -410,17 +435,19 @@ void lengthScaleEstimator::readLengthScaleInfo forAll(recvLblBuffer_[patchI], i) { label nLabel = recvLblBuffer_[patchI][i]; + label pLevel = recvLvlBuffer_[patchI][i]; label cI = fCells[nLabel]; label& ngbLevel = cellLevels[cI]; // For an unvisited cell, update the level + bool unvisited = false; + if (ngbLevel == 0) { - ngbLevel = level + 1; - levelCells.insert(cI); - visitedCells++; + ngbLevel = pLevel + 1; + unvisited = true; } // Visit all neighbours and re-calculate length-scale @@ -459,27 +486,34 @@ void lengthScaleEstimator::readLengthScaleInfo if (isA(boundary[pF])) { // Determine the local index. - label local = boundary[pF].whichFace(cellCheck[faceI]); + label local = + ( + boundary[pF].whichFace(cellCheck[faceI]) + ); // Is this label present in the list? - forAll(recvLblBuffer_[pF], j) + label j = -1; + + if ((j = findIndex(recvLblBuffer_[pF], local)) > -1) { - if (recvLblBuffer_[pF][j] == local) + if + ( + (recvLvlBuffer_[pF][j] < ngbLevel) && + (recvLvlBuffer_[pF][j] > 0) + ) { sumLength += recvSclBuffer_[pF][j]; nTouchedNgb++; - - break; } } } else - if (fixedPatches_.found(boundary[pF].name())) + if (!isFreePatch(pF)) { sumLength += ( - fixedPatches_[boundary[pF].name()][0].scalarToken() + fixedLengthScale(cellCheck[faceI], pF, true) ); nTouchedNgb++; @@ -489,9 +523,26 @@ void lengthScaleEstimator::readLengthScaleInfo sumLength /= nTouchedNgb; // Scale the length and assign to this cell - scalar sLength = sumLength*growthFactor_; + if (level < maxRefineLevel_) + { + sumLength *= growthFactor_; + } + else + if (meanScale_ > 0.0) + { + // If a mean scale has been specified, + // override the value + sumLength = meanScale_; + } - lengthScale[cI] = sLength; + lengthScale[cI] = sumLength; + + if (unvisited) + { + levelCells.insert(cI); + + visitedCells++; + } } } } diff --git a/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.H b/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.H index 0b9366e14..92f1a2a0b 100644 --- a/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.H +++ b/src/dynamicMesh/dynamicFvMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.H @@ -84,6 +84,8 @@ class lengthScaleEstimator // Buffers for parallel length-scale calculations labelListList sendLblBuffer_; labelListList recvLblBuffer_; + labelListList sendLvlBuffer_; + labelListList recvLvlBuffer_; scalarListList sendSclBuffer_; scalarListList recvSclBuffer_; From c787812631d5df91519b247681e41eddb9b22e7c Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Wed, 1 Dec 2010 01:23:48 -0500 Subject: [PATCH 07/11] Fix typo in console message --- ThirdParty/AllMake.stage4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/AllMake.stage4 b/ThirdParty/AllMake.stage4 index a8c896d0b..d706853e3 100755 --- a/ThirdParty/AllMake.stage4 +++ b/ThirdParty/AllMake.stage4 @@ -68,7 +68,7 @@ then else echo "WARNING: Skipping the installation of ParaView-3.8.1." echo "WARNING: Please initialize the QT_DIR environment variable to your QT installation directory." - echo "WARNING: The command $QT_DIR/bin/qmake needs to be valid" + echo "WARNING: The command \$QT_DIR/bin/qmake needs to be valid" echo "WARNING: " fi From 8156ee2b1f519c6ba7b14fd0539a39dce97c942f Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Wed, 1 Dec 2010 08:07:16 -0500 Subject: [PATCH 08/11] Updating the ThirdParty packages env. variables before compiling a new package. Applying same recipe before compiling the OpenFOAM source code. --- Allwmake | 6 ++++- ThirdParty/AllMake.stage3 | 25 ++++++------------- .../tools/makeThirdPartyFunctionsForRPM | 10 +++++++- etc/settings.sh | 13 ++++++++++ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Allwmake b/Allwmake index 2458a1916..886b05cd0 100755 --- a/Allwmake +++ b/Allwmake @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cd ${0%/*} || exit 1 # run from this directory if [ "$PWD" != "$WM_PROJECT_DIR" ] @@ -16,6 +16,10 @@ fi #( cd $WM_THIRD_PARTY_DIR && ./Allwmake ) ( cd $WM_THIRD_PARTY_DIR && ./AllMake ) +# We make sure the ThirdParty packages environment variables are up-to-date +# before compiling the rest of OpenFOAM +. $WM_PROJECT_DIR/etc/settings.sh + # build OpenFOAM libraries and applications src/Allwmake applications/Allwmake diff --git a/ThirdParty/AllMake.stage3 b/ThirdParty/AllMake.stage3 index 97ae61948..595b4021b 100755 --- a/ThirdParty/AllMake.stage3 +++ b/ThirdParty/AllMake.stage3 @@ -56,7 +56,6 @@ echo Starting ThirdParty AllMake: Stage3 echo ======================================== echo - # Metis ( rpm_make metis-5.0pre2 http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.0pre2.tar.gz ) @@ -69,25 +68,17 @@ echo # Mesquite ( rpm_make mesquite-2.1.2 http://software.sandia.gov/~jakraft/mesquite-2.1.2.tar.gz ) +# The following two packages depends on the availability of OpenMPI +# The macro rpm_make() will make sure to update the ThirdParty environment variables before starting +# the compilation. +# Just make sure the OpenMPI environment variables are properly initialized, or that +# the AllMake.stage2 script completed correctly +# # Scotch -if [ -d "$OPENMPI_DIR" ]; then - ( rpm_make scotch-5.1.10b https://gforge.inria.fr/frs/download.php/27583/scotch-5.1.10b.tar.gz ) -else - echo "WARNING: The OPENMPI_DIR environment variable is not set." - echo "WARNING: Please make sure your environment is properly set up for openmpi. This is necessary for compiling scotch-5.1.10b" - echo "WARNING: Skipping the compilation of scotch-5.1.10b" - echo "" -fi +( rpm_make scotch-5.1.10b https://gforge.inria.fr/frs/download.php/27583/scotch-5.1.10b.tar.gz ) # ParMetis -if [ -d "$OPENMPI_DIR" ]; then - ( rpm_make ParMetis-3.1.1 http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/ParMetis-3.1.1.tar.gz ) -else - echo "WARNING: The OPENMPI_DIR environment variable is not set." - echo "WARNING: Please make sure your environment is properly set up for openmpi. This is necessary for compiling ParMetis-3.1.1" - echo "WARNING: Skipping the compilation of ParMetis-3.1.1" - echo "" -fi +( rpm_make ParMetis-3.1.1 http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/ParMetis-3.1.1.tar.gz ) echo ======================================== echo Done ThirdParty AllMake: Stage3 diff --git a/ThirdParty/tools/makeThirdPartyFunctionsForRPM b/ThirdParty/tools/makeThirdPartyFunctionsForRPM index e4d5aa7bc..c1454226f 100755 --- a/ThirdParty/tools/makeThirdPartyFunctionsForRPM +++ b/ThirdParty/tools/makeThirdPartyFunctionsForRPM @@ -50,6 +50,11 @@ echo "" rpm_make() { package="$1" + + # Make sure the ThirdParty environment is up-to-date + echo "Updating the ThirdParty environment variables before building package $package" + . $WM_PROJECT_DIR/etc/settings.sh + rpmName=$package-$WM_OPTIONS.$architecture rpmFile=$buildBase/RPMS/$architecture/$rpmName.rpm @@ -121,7 +126,10 @@ rpm_build() #Build RPM package echo "Building package $package" - rpmbuild --define "_topdir $buildBase" --dbpath $buildBase/rpmDB --clean -bb ./SPECS/$specFile "$@" + #rpmbuild --define "_topdir $buildBase" --dbpath $buildBase/rpmDB --clean -bb ./SPECS/$specFile "$@" + # + # Let's keep the compilation directory alive for now in order to facilitate postmortems of failed compilations + rpmbuild --define "_topdir $buildBase" --dbpath $buildBase/rpmDB -bb ./SPECS/$specFile "$@" } # diff --git a/etc/settings.sh b/etc/settings.sh index e0d2d6831..bec6bab7e 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -55,6 +55,19 @@ _foamAddLib() done } +# Source files, possibly with some verbosity +# Yes, this is the same definition as in the file etc/bash +# We need that definition available for scripts sourcing +# settings.sh directly. +_foamSource() +{ + while [ $# -ge 1 ] + do + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" + . $1 + shift + done +} # location of the jobControl directory export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl From 815b8ca4a39ee4bf1fdbb698c3d29a57bc85a0d9 Mon Sep 17 00:00:00 2001 From: Sandeep Menon Date: Wed, 1 Dec 2010 10:21:31 -0500 Subject: [PATCH 09/11] Pstream : expose outstanding requests OpenCFD commit: b01323b1133b6235016c --- src/Pstream/mpi/IPread.C | 43 +++++++++----------- src/Pstream/mpi/Make/files | 1 + src/Pstream/mpi/OPwrite.C | 41 +++++++++---------- src/Pstream/mpi/PstreamGlobals.C | 45 +++++++++++++++++++++ src/Pstream/mpi/PstreamGlobals.H | 69 ++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 44 deletions(-) create mode 100644 src/Pstream/mpi/PstreamGlobals.C create mode 100644 src/Pstream/mpi/PstreamGlobals.H diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/IPread.C index 9806d49bd..54401a910 100644 --- a/src/Pstream/mpi/IPread.C +++ b/src/Pstream/mpi/IPread.C @@ -8,10 +8,10 @@ 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 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 3 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 @@ -19,8 +19,7 @@ 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 + along with OpenFOAM. If not, see . Description Read token and binary block from IPstream @@ -30,15 +29,7 @@ Description #include "mpi.h" #include "IPstream.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// Outstanding non-blocking operations. -//! @cond fileScope -Foam::DynamicList IPstream_outstandingRequests_; -//! @endcond fileScope +#include "PstreamGlobals.H" // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // @@ -171,7 +162,7 @@ Foam::label Foam::IPstream::read return 0; } - IPstream_outstandingRequests_.append(request); + PstreamGlobals::IPstream_outstandingRequests_.append(request); return 1; } @@ -191,14 +182,14 @@ Foam::label Foam::IPstream::read void Foam::IPstream::waitRequests() { - if (IPstream_outstandingRequests_.size()) + if (PstreamGlobals::IPstream_outstandingRequests_.size()) { if ( MPI_Waitall ( - IPstream_outstandingRequests_.size(), - IPstream_outstandingRequests_.begin(), + PstreamGlobals::IPstream_outstandingRequests_.size(), + PstreamGlobals::IPstream_outstandingRequests_.begin(), MPI_STATUSES_IGNORE ) ) @@ -209,19 +200,20 @@ void Foam::IPstream::waitRequests() ) << "MPI_Waitall returned with error" << endl; } - IPstream_outstandingRequests_.clear(); + PstreamGlobals::IPstream_outstandingRequests_.clear(); } } bool Foam::IPstream::finishedRequest(const label i) { - if (i >= IPstream_outstandingRequests_.size()) + if (i >= PstreamGlobals::IPstream_outstandingRequests_.size()) { FatalErrorIn ( "IPstream::finishedRequest(const label)" - ) << "There are " << IPstream_outstandingRequests_.size() + ) << "There are " + << PstreamGlobals::IPstream_outstandingRequests_.size() << " outstanding send requests and you are asking for i=" << i << nl << "Maybe you are mixing blocking/non-blocking comms?" @@ -229,7 +221,12 @@ bool Foam::IPstream::finishedRequest(const label i) } int flag; - MPI_Test(&IPstream_outstandingRequests_[i], &flag, MPI_STATUS_IGNORE); + MPI_Test + ( + &PstreamGlobals::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 65016b83f..6b1d3f4c5 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 01430109e..4a2979701 100644 --- a/src/Pstream/mpi/OPwrite.C +++ b/src/Pstream/mpi/OPwrite.C @@ -8,10 +8,10 @@ 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 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 3 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 @@ -19,8 +19,7 @@ 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 + along with OpenFOAM. If not, see . Description Write primitive and binary block from OPstream @@ -30,13 +29,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 * * * * * * * * * * * * * * * // @@ -111,7 +104,7 @@ bool Foam::OPstream::write &request ); - OPstream_outstandingRequests_.append(request); + PstreamGlobals::OPstream_outstandingRequests_.append(request); } else { @@ -129,14 +122,14 @@ bool Foam::OPstream::write void Foam::OPstream::waitRequests() { - if (OPstream_outstandingRequests_.size()) + if (PstreamGlobals::OPstream_outstandingRequests_.size()) { if ( MPI_Waitall ( - OPstream_outstandingRequests_.size(), - OPstream_outstandingRequests_.begin(), + PstreamGlobals::OPstream_outstandingRequests_.size(), + PstreamGlobals::OPstream_outstandingRequests_.begin(), MPI_STATUSES_IGNORE ) ) @@ -147,19 +140,20 @@ void Foam::OPstream::waitRequests() ) << "MPI_Waitall returned with error" << Foam::endl; } - OPstream_outstandingRequests_.clear(); + PstreamGlobals::OPstream_outstandingRequests_.clear(); } } bool Foam::OPstream::finishedRequest(const label i) { - if (i >= OPstream_outstandingRequests_.size()) + if (i >= PstreamGlobals::OPstream_outstandingRequests_.size()) { FatalErrorIn ( "OPstream::finishedRequest(const label)" - ) << "There are " << OPstream_outstandingRequests_.size() + ) << "There are " + << PstreamGlobals::OPstream_outstandingRequests_.size() << " outstanding send requests and you are asking for i=" << i << nl << "Maybe you are mixing blocking/non-blocking comms?" @@ -167,7 +161,12 @@ bool Foam::OPstream::finishedRequest(const label i) } int flag; - MPI_Test(&OPstream_outstandingRequests_[i], &flag, MPI_STATUS_IGNORE); + MPI_Test + ( + &PstreamGlobals::OPstream_outstandingRequests_[i], + &flag, + MPI_STATUS_IGNORE + ); return flag != 0; } diff --git a/src/Pstream/mpi/PstreamGlobals.C b/src/Pstream/mpi/PstreamGlobals.C new file mode 100644 index 000000000..e6b460f6f --- /dev/null +++ b/src/Pstream/mpi/PstreamGlobals.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "PstreamGlobals.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// Outstanding non-blocking operations. +//! @cond fileScope +DynamicList PstreamGlobals::IPstream_outstandingRequests_; +DynamicList PstreamGlobals::OPstream_outstandingRequests_; +//! @endcond + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/Pstream/mpi/PstreamGlobals.H b/src/Pstream/mpi/PstreamGlobals.H new file mode 100644 index 000000000..2df0de627 --- /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 held by original author + \\/ 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 3 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, see . + +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 IPstream_outstandingRequests_; +extern DynamicList OPstream_outstandingRequests_; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 1cce90333844859412415d1e572c7c26336a2404 Mon Sep 17 00:00:00 2001 From: Sandeep Menon Date: Wed, 1 Dec 2010 20:01:52 -0500 Subject: [PATCH 10/11] Allow strict-aliasing and remove reinterpret_cast. Compliance for gcc-4.5.x --- .../blockMesh/curvedEdges/ellipseEdge.C | 6 +-- .../coordinateRotation/coordinateRotation.C | 17 +++---- .../coordinateRotation/coordinateRotation.H | 6 +-- .../coordinateSystems/coordinateSystem.H | 10 ++-- src/OpenFOAM/fields/Fields/Field/Field.C | 16 +++---- src/OpenFOAM/fields/Fields/Field/Field.H | 16 +++---- src/OpenFOAM/primitives/Tensor/Tensor.H | 23 ++++++---- src/OpenFOAM/primitives/Tensor/TensorI.H | 46 +++++++++---------- .../primitives/Tensor/tensor/tensor.C | 22 ++++++++- src/OpenFOAM/primitives/Tensor2D/Tensor2D.H | 21 ++++++--- src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H | 41 ++++++++--------- .../primitives/Tensor2D/tensor2D/tensor2D.C | 8 ++-- .../constraint/wedge/wedgeFaPatchField.C | 6 ++- .../faceLimitedFaGrad/faceLimitedFaGrads.C | 11 +++-- .../cfdTools/general/porousMedia/porousZone.H | 2 +- .../constraint/wedge/wedgeFvPatchField.C | 6 ++- .../cellLimitedGrad/cellLimitedGrads.C | 13 ++++-- wmake/rules/SiCortex64Gcc/c++ | 2 +- wmake/rules/SunOS64Gcc/c++ | 2 +- wmake/rules/darwinIntel/c++ | 2 +- wmake/rules/darwinIntel64/c++ | 2 +- wmake/rules/darwinPpc/c++ | 2 +- wmake/rules/linux64Gcc/c++ | 2 +- wmake/rules/linuxGcc/c++ | 2 +- wmake/rules/linuxIA64Gcc/c++ | 4 +- wmake/rules/linuxPPC64Gcc/c++ | 2 +- wmake/rules/solarisGcc/c++ | 2 +- 27 files changed, 162 insertions(+), 130 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/ellipseEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/ellipseEdge.C index 9df9bd656..a8ba5e1ef 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/ellipseEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/ellipseEdge.C @@ -78,11 +78,7 @@ Foam::ellipticCylindricalCS Foam::ellipseEdge::calcCS() Info << "p = " << p << " q = " << q << " n = " << normal << endl; } - tensor A; - A.x() = p; - A.z() = normal; - A.y() = normal ^ p; - + tensor A(p, normal ^ p, normal); vector2D p2D(1.0, 0.0); vector qTmp = (A & q); diff --git a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.C index dc939e944..e30de1c0c 100644 --- a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.C @@ -67,27 +67,23 @@ void Foam::coordinateRotation::calcTransform switch (order) { case e1e2: - Rtr.x() = a; - Rtr.y() = b; - Rtr.z() = c; + Rtr = tensor(a, b, c); break; case e2e3: - Rtr.x() = c; - Rtr.y() = a; - Rtr.z() = b; + Rtr = tensor(c, a, b); break; case e3e1: - Rtr.x() = b; - Rtr.y() = c; - Rtr.z() = a; + Rtr = tensor(b, c, a); break; default: FatalErrorIn("coordinateRotation::calcTransform()") << "programmer error" << endl << abort(FatalError); + // To satisfy compiler warnings + Rtr = tensor::zero; break; } @@ -187,7 +183,8 @@ Foam::autoPtr Foam::coordinateRotation::New ( "coordinateRotation::New(const dictionary&)", dict - ) << "Unknown coordinateRotation type " << rotType << nl << nl + ) << "Unknown coordinateRotation type " + << rotType << nl << nl << "Valid coordinateRotation types are :" << nl << "[default: axes " << typeName_() << "]" << dictionaryConstructorTablePtr_->toc() diff --git a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H index d2c653665..d758d49ad 100644 --- a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -185,19 +185,19 @@ public: } //- Return local Cartesian x-axis - vector& e1() const + const vector e1() const { return tensor::T().x(); } //- Return local Cartesian y-axis - vector& e2() const + const vector e2() const { return tensor::T().y(); } //- Return local Cartesian z-axis - vector& e3() const + const vector e3() const { return tensor::T().z(); } diff --git a/src/OpenFOAM/coordinateSystems/coordinateSystem.H b/src/OpenFOAM/coordinateSystems/coordinateSystem.H index 4f852e038..9cbe20f94 100644 --- a/src/OpenFOAM/coordinateSystems/coordinateSystem.H +++ b/src/OpenFOAM/coordinateSystems/coordinateSystem.H @@ -348,33 +348,33 @@ public: } //- Return local Cartesian x-axis - const vector& e1() const + const vector e1() const { return Rtr_.x(); } //- Return local Cartesian y-axis - const vector& e2() const + const vector e2() const { return Rtr_.y(); } //- Return local Cartesian z-axis - const vector& e3() const + const vector e3() const { return Rtr_.z(); } //- Return axis (e3: local Cartesian z-axis) // @deprecated method e3 is preferred - const vector& axis() const + const vector axis() const { return Rtr_.z(); } //- Return direction (e1: local Cartesian x-axis) // @deprecated method e1 is preferred - const vector& direction() const + const vector direction() const { return Rtr_.x(); } diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index 2ec8f5039..1ef3555fd 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -67,7 +67,7 @@ template Field::Field ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) : List(mapAddressing.size()) @@ -79,7 +79,7 @@ template Field::Field ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) : List(mapAddressing.size()) @@ -298,7 +298,7 @@ template void Field::map ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) { Field& f = *this; @@ -327,7 +327,7 @@ template void Field::map ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) { map(tmapF(), mapAddressing); @@ -469,7 +469,7 @@ template void Field::rmap ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) { Field& f = *this; @@ -489,7 +489,7 @@ template void Field::rmap ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ) { rmap(tmapF(), mapAddressing); @@ -501,7 +501,7 @@ template void Field::rmap ( const UList& mapF, - const labelList& mapAddressing, + const unallocLabelList& mapAddressing, const scalarList& mapWeights ) { @@ -519,7 +519,7 @@ template void Field::rmap ( const tmp >& tmapF, - const labelList& mapAddressing, + const unallocLabelList& mapAddressing, const scalarList& mapWeights ) { diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index 3cbca2e55..e9558c72d 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -128,14 +128,14 @@ public: Field ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- Construct by 1 to 1 mapping from the given tmp field Field ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- Construct by interpolative mapping from the given field @@ -215,14 +215,14 @@ public: void map ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- 1 to 1 map from the given tmp field void map ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- Interpolative map from the given field @@ -265,21 +265,21 @@ public: void rmap ( const UList& mapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- 1 to 1 reverse-map from the given tmp field void rmap ( const tmp >& tmapF, - const labelList& mapAddressing + const unallocLabelList& mapAddressing ); //- Interpolative reverse map from the given field void rmap ( const UList& mapF, - const labelList& mapAddressing, + const unallocLabelList& mapAddressing, const scalarList& weights ); @@ -287,7 +287,7 @@ public: void rmap ( const tmp >& tmapF, - const labelList& mapAddressing, + const unallocLabelList& mapAddressing, const scalarList& weights ); diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index c8d569eed..cd0e2825b 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -101,6 +101,14 @@ public: //- Construct given SymmTensor inline Tensor(const SymmTensor&); + //- Construct given the three vectors + inline Tensor + ( + const Vector& x, + const Vector& y, + const Vector& z + ); + //- Construct given the nine components inline Tensor ( @@ -117,14 +125,6 @@ public: // Access - inline const Vector& x() const; - inline const Vector& y() const; - inline const Vector& z() const; - - inline Vector& x(); - inline Vector& y(); - inline Vector& z(); - inline const Cmpt& xx() const; inline const Cmpt& xy() const; inline const Cmpt& xz() const; @@ -145,6 +145,13 @@ public: inline Cmpt& zy(); inline Cmpt& zz(); + // Access vector components. + // Note: returning const only to find out lhs usage + + inline const Vector x() const; + inline const Vector y() const; + inline const Vector z() const; + //- Transpose inline Tensor T() const; diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index 6dc437068..2cd3d21b3 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -65,6 +65,21 @@ inline Tensor::Tensor(const SymmTensor& st) } +//- Construct given the three vector components +template +inline Tensor::Tensor +( + const Vector& x, + const Vector& y, + const Vector& z +) +{ + this->v_[XX] = x.x(); this->v_[XY] = x.y(); this->v_[XZ] = x.z(); + this->v_[YX] = y.x(); this->v_[YY] = y.y(); this->v_[YZ] = y.z(); + this->v_[ZX] = z.x(); this->v_[ZY] = z.y(); this->v_[ZZ] = z.z(); +} + + //- Construct from components template inline Tensor::Tensor @@ -91,40 +106,21 @@ inline Tensor::Tensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline const Vector& Tensor::x() const +inline const Vector Tensor::x() const { - return reinterpret_cast&>(this->v_[XX]); + return Vector(this->v_[XX], this->v_[XY], this->v_[XZ]); } template -inline const Vector& Tensor::y() const +inline const Vector Tensor::y() const { - return reinterpret_cast&>(this->v_[YX]); + return Vector(this->v_[YX], this->v_[YY], this->v_[YZ]); } template -inline const Vector& Tensor::z() const +inline const Vector Tensor::z() const { - return reinterpret_cast&>(this->v_[ZX]); -} - - -template -inline Vector& Tensor::x() -{ - return reinterpret_cast&>(this->v_[XX]); -} - -template -inline Vector& Tensor::y() -{ - return reinterpret_cast&>(this->v_[YX]); -} - -template -inline Vector& Tensor::z() -{ - return reinterpret_cast&>(this->v_[ZX]); + return Vector(this->v_[ZX], this->v_[ZY], this->v_[ZZ]); } diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index b5866f123..adcde4bf2 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -267,8 +267,16 @@ tensor eigenVectors(const tensor& t) { vector evals(eigenValues(t)); - tensor evs; + // Modification for strict-aliasing compliance. + // Sandeep Menon, 01/Dec/2010 + tensor evs + ( + (mag(evals.x()) < SMALL) ? vector(0, 0, 1) : eigenVector(t, evals.x()), + (mag(evals.y()) < SMALL) ? vector(0, 1, 0) : eigenVector(t, evals.y()), + (mag(evals.z()) < SMALL) ? vector(1, 0, 0) : eigenVector(t, evals.z()) + ); + /* // Test for null eigen values to return a not null eigen vector // Jovani Favero, 18/Nov/2009 if (mag(evals.x()) < SMALL) @@ -297,6 +305,7 @@ tensor eigenVectors(const tensor& t) { evs.z() = eigenVector(t, evals.z()); } + */ return evs; } @@ -490,8 +499,16 @@ tensor eigenVectors(const symmTensor& t) { vector evals(eigenValues(t)); - tensor evs; + // Modification for strict-aliasing compliance. + // Sandeep Menon, 01/Dec/2010 + tensor evs + ( + (mag(evals.x()) < SMALL) ? vector(0, 0, 1) : eigenVector(t, evals.x()), + (mag(evals.y()) < SMALL) ? vector(0, 1, 0) : eigenVector(t, evals.y()), + (mag(evals.z()) < SMALL) ? vector(1, 0, 0) : eigenVector(t, evals.z()) + ); + /* // Test for null eigen values to return a not null eigen vector. // Jovani Favero, 18/Nov/2009 if (mag(evals.x()) < SMALL) @@ -520,6 +537,7 @@ tensor eigenVectors(const symmTensor& t) { evs.z() = eigenVector(t, evals.z()); } + */ return evs; } diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H index 40a5d409a..a9f0f593a 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H @@ -93,7 +93,14 @@ public: //- Construct given SphericalTensor2D inline Tensor2D(const SphericalTensor2D&); - //- Construct given the nine components + //- Construct given the two vectors + inline Tensor2D + ( + const Vector2D& x, + const Vector2D& y + ); + + //- Construct given the four components inline Tensor2D ( const Cmpt txx, const Cmpt txy, @@ -108,12 +115,6 @@ public: // Access - inline const Vector2D& x() const; - inline const Vector2D& y() const; - - inline Vector2D& x(); - inline Vector2D& y(); - inline const Cmpt& xx() const; inline const Cmpt& xy() const; inline const Cmpt& yx() const; @@ -124,6 +125,12 @@ public: inline Cmpt& yx(); inline Cmpt& yy(); + // Access vector components. + // Note: returning const only to find out lhs usage + + inline const Vector2D x() const; + inline const Vector2D y() const; + //- Transpose inline Tensor2D T() const; diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H index 60188aa10..556eae234 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H @@ -51,6 +51,18 @@ inline Tensor2D::Tensor2D(const SphericalTensor2D& st) } +template +inline Tensor2D::Tensor2D +( + const Vector2D& x, + const Vector2D& y +) +{ + this->v_[XX] = x.x(); this->v_[XY] = x.y(); + this->v_[YX] = y.x(); this->v_[YY] = y.y(); +} + + template inline Tensor2D::Tensor2D ( @@ -73,51 +85,38 @@ inline Tensor2D::Tensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline const Vector2D& Tensor2D::x() const +inline const Vector2D Tensor2D::x() const { - return reinterpret_cast&>(this->v_[XX]); + return Vector2D(this->v_[XX], this->v_[XY]); } template -inline const Vector2D& Tensor2D::y() const +inline const Vector2D Tensor2D::y() const { - return reinterpret_cast&>(this->v_[YX]); + return Vector2D(this->v_[YX], this->v_[YY]); } template -inline Vector2D& Tensor2D::x() -{ - return reinterpret_cast&>(this->v_[XX]); -} - -template -inline Vector2D& Tensor2D::y() -{ - return reinterpret_cast&>(this->v_[YX]); -} - - -template -inline const Cmpt& Tensor2D::xx() const +inline const Cmpt& Tensor2D::xx() const { return this->v_[XX]; } template -inline const Cmpt& Tensor2D::xy() const +inline const Cmpt& Tensor2D::xy() const { return this->v_[XY]; } template -inline const Cmpt& Tensor2D::yx() const +inline const Cmpt& Tensor2D::yx() const { return this->v_[YX]; } template -inline const Cmpt& Tensor2D::yy() const +inline const Cmpt& Tensor2D::yy() const { return this->v_[YY]; } diff --git a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C index f9a9ada57..16da8b100 100644 --- a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C +++ b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C @@ -160,9 +160,11 @@ tensor2D eigenVectors(const tensor2D& t) { vector2D evals(eigenValues(t)); - tensor2D evs; - evs.x() = eigenVector(t, evals.x()); - evs.y() = eigenVector(t, evals.y()); + tensor2D evs + ( + eigenVector(t, evals.x()), + eigenVector(t, evals.y()) + ); return evs; } diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C index 9a925bea0..9de051ee3 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C @@ -159,9 +159,11 @@ void wedgeFaPatchField::evaluate(const Pstream::commsTypes) template tmp > wedgeFaPatchField::snGradTransformDiag() const { - diagTensor diagT = + const diagTensor diagT = 0.5*diag(I - refCast(this->patch()).faceT()); + const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); + return tmp > ( new Field @@ -171,7 +173,7 @@ tmp > wedgeFaPatchField::snGradTransformDiag() const ( pow ( - reinterpret_cast(diagT), + diagV, pTraits::rank> ::type>::zero ) diff --git a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C index 51652c7b9..eda8ff989 100644 --- a/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C +++ b/src/finiteArea/finiteArea/gradSchemes/limitedGradSchemes/faceLimitedFaGrad/faceLimitedFaGrads.C @@ -375,7 +375,7 @@ tmp faceLimitedGrad::grad ); } } - + if (fa::debug) { Info<< "gradient limiter for: " << vsf.name() @@ -388,9 +388,12 @@ tmp faceLimitedGrad::grad forAll(gIf, celli) { - gIf[celli].x() = cmptMultiply(limiter[celli], gIf[celli].x()); - gIf[celli].y() = cmptMultiply(limiter[celli], gIf[celli].y()); - gIf[celli].z() = cmptMultiply(limiter[celli], gIf[celli].z()); + gIf[celli] = tensor + ( + cmptMultiply(limiter[celli], gIf[celli].x()), + cmptMultiply(limiter[celli], gIf[celli].y()), + cmptMultiply(limiter[celli], gIf[celli].z()) + ); } g.correctBoundaryConditions(); diff --git a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H index 6f69e3e33..5efa08d0d 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H +++ b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H @@ -267,7 +267,7 @@ public: } //- Return axis - const vector& axis() const + vector axis() const { return coordSys_.axis(); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index ba1951739..33c813566 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C @@ -169,9 +169,11 @@ void wedgeFvPatchField::evaluate(const Pstream::commsTypes) template tmp > wedgeFvPatchField::snGradTransformDiag() const { - diagTensor diagT = + const diagTensor diagT = 0.5*diag(I - refCast(this->patch()).cellT()); + const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); + return tmp > ( new Field @@ -181,7 +183,7 @@ tmp > wedgeFvPatchField::snGradTransformDiag() const ( pow ( - reinterpret_cast(diagT), + diagV, pTraits::rank> ::type>::zero ) diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C index 432e320bb..21245a5ca 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C @@ -21,7 +21,7 @@ License 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 "cellLimitedGrad.H" @@ -377,7 +377,7 @@ tmp cellLimitedGrad::grad ); } } - + if (fv::debug) { Info<< "gradient limiter for: " << vsf.name() @@ -390,9 +390,12 @@ tmp cellLimitedGrad::grad forAll(gIf, celli) { - gIf[celli].x() = cmptMultiply(limiter[celli], gIf[celli].x()); - gIf[celli].y() = cmptMultiply(limiter[celli], gIf[celli].y()); - gIf[celli].z() = cmptMultiply(limiter[celli], gIf[celli].z()); + gIf[celli] = tensor + ( + cmptMultiply(limiter[celli], gIf[celli].x()), + cmptMultiply(limiter[celli], gIf[celli].y()), + cmptMultiply(limiter[celli], gIf[celli].z()) + ); } g.correctBoundaryConditions(); diff --git a/wmake/rules/SiCortex64Gcc/c++ b/wmake/rules/SiCortex64Gcc/c++ index f0a8cf504..124594622 100644 --- a/wmake/rules/SiCortex64Gcc/c++ +++ b/wmake/rules/SiCortex64Gcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ -mabi=64 #CC = scg++ -mabi=64 diff --git a/wmake/rules/SunOS64Gcc/c++ b/wmake/rules/SunOS64Gcc/c++ index 36b5c29b2..95f8b8f47 100644 --- a/wmake/rules/SunOS64Gcc/c++ +++ b/wmake/rules/SunOS64Gcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ -m64 diff --git a/wmake/rules/darwinIntel/c++ b/wmake/rules/darwinIntel/c++ index d80b4b5d8..482c56aa6 100644 --- a/wmake/rules/darwinIntel/c++ +++ b/wmake/rules/darwinIntel/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ $(WM_CXXFLAGS) diff --git a/wmake/rules/darwinIntel64/c++ b/wmake/rules/darwinIntel64/c++ index d80b4b5d8..482c56aa6 100644 --- a/wmake/rules/darwinIntel64/c++ +++ b/wmake/rules/darwinIntel64/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ $(WM_CXXFLAGS) diff --git a/wmake/rules/darwinPpc/c++ b/wmake/rules/darwinPpc/c++ index d80b4b5d8..482c56aa6 100644 --- a/wmake/rules/darwinPpc/c++ +++ b/wmake/rules/darwinPpc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ $(WM_CXXFLAGS) diff --git a/wmake/rules/linux64Gcc/c++ b/wmake/rules/linux64Gcc/c++ index 9d074e271..7f581a713 100644 --- a/wmake/rules/linux64Gcc/c++ +++ b/wmake/rules/linux64Gcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor CC = g++ -m64 diff --git a/wmake/rules/linuxGcc/c++ b/wmake/rules/linuxGcc/c++ index 64d679757..3358676b8 100644 --- a/wmake/rules/linuxGcc/c++ +++ b/wmake/rules/linuxGcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ -m32 diff --git a/wmake/rules/linuxIA64Gcc/c++ b/wmake/rules/linuxIA64Gcc/c++ index cfa9abbca..2726e55bb 100644 --- a/wmake/rules/linuxIA64Gcc/c++ +++ b/wmake/rules/linuxIA64Gcc/c++ @@ -1,12 +1,12 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ include $(RULES)/c++$(WM_COMPILE_OPTION) -ptFLAGS = -DNoRepository -ftemplate-depth-30 +ptFLAGS = -DNoRepository -ftemplate-depth-40 c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC diff --git a/wmake/rules/linuxPPC64Gcc/c++ b/wmake/rules/linuxPPC64Gcc/c++ index 7590b089a..3ff598498 100644 --- a/wmake/rules/linuxPPC64Gcc/c++ +++ b/wmake/rules/linuxPPC64Gcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast CC = g++ -m64 -mcpu=power5+ diff --git a/wmake/rules/solarisGcc/c++ b/wmake/rules/solarisGcc/c++ index 6b9154c0a..491cb2373 100644 --- a/wmake/rules/solarisGcc/c++ +++ b/wmake/rules/solarisGcc/c++ @@ -1,6 +1,6 @@ .SUFFIXES: .C .cxx .cc .cpp -c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter +c++WARN = -Wall -Wextra -Wno-unused-parameter CC = g++ From 7eb1b7c884807a05dc922b46a4171188739bbc2f Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 2 Dec 2010 13:30:24 +0000 Subject: [PATCH 11/11] gcc-4.5.1 porting changes: strict aliasing --- .../coordinateRotation/coordinateRotation.H | 6 ++-- .../coordinateSystems/coordinateSystem.H | 8 ++--- .../primitives/Tensor/tensor/tensor.C | 34 ++----------------- src/OpenFOAM/primitives/Tensor2D/Tensor2D.H | 5 ++- src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H | 4 +-- 5 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H index d758d49ad..098355901 100644 --- a/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/OpenFOAM/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -185,19 +185,19 @@ public: } //- Return local Cartesian x-axis - const vector e1() const + vector e1() const { return tensor::T().x(); } //- Return local Cartesian y-axis - const vector e2() const + vector e2() const { return tensor::T().y(); } //- Return local Cartesian z-axis - const vector e3() const + vector e3() const { return tensor::T().z(); } diff --git a/src/OpenFOAM/coordinateSystems/coordinateSystem.H b/src/OpenFOAM/coordinateSystems/coordinateSystem.H index 9cbe20f94..fc3a3985f 100644 --- a/src/OpenFOAM/coordinateSystems/coordinateSystem.H +++ b/src/OpenFOAM/coordinateSystems/coordinateSystem.H @@ -348,26 +348,26 @@ public: } //- Return local Cartesian x-axis - const vector e1() const + vector e1() const { return Rtr_.x(); } //- Return local Cartesian y-axis - const vector e2() const + vector e2() const { return Rtr_.y(); } //- Return local Cartesian z-axis - const vector e3() const + vector e3() const { return Rtr_.z(); } //- Return axis (e3: local Cartesian z-axis) // @deprecated method e3 is preferred - const vector axis() const + vector axis() const { return Rtr_.z(); } diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index adcde4bf2..5f466159c 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -269,6 +269,9 @@ tensor eigenVectors(const tensor& t) // Modification for strict-aliasing compliance. // Sandeep Menon, 01/Dec/2010 + + // Test for null eigen values to return a not null eigen vector + // Jovani Favero, 18/Nov/2009 tensor evs ( (mag(evals.x()) < SMALL) ? vector(0, 0, 1) : eigenVector(t, evals.x()), @@ -276,37 +279,6 @@ tensor eigenVectors(const tensor& t) (mag(evals.z()) < SMALL) ? vector(1, 0, 0) : eigenVector(t, evals.z()) ); - /* - // Test for null eigen values to return a not null eigen vector - // Jovani Favero, 18/Nov/2009 - if (mag(evals.x()) < SMALL) - { - evs.x() = vector(0, 0, 1); - } - else - { - evs.x() = eigenVector(t, evals.x()); - } - - if (mag(evals.y()) < SMALL) - { - evs.y() = vector(0, 1, 0); - } - else - { - evs.y() = eigenVector(t, evals.y()); - } - - if (mag(evals.z()) < SMALL) - { - evs.z() = vector(1, 0, 0); - } - else - { - evs.z() = eigenVector(t, evals.z()); - } - */ - return evs; } diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H index a9f0f593a..0f124cc41 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H @@ -126,10 +126,9 @@ public: inline Cmpt& yy(); // Access vector components. - // Note: returning const only to find out lhs usage - inline const Vector2D x() const; - inline const Vector2D y() const; + inline Vector2D x() const; + inline Vector2D y() const; //- Transpose inline Tensor2D T() const; diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H index 556eae234..3c111cfbb 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H @@ -85,13 +85,13 @@ inline Tensor2D::Tensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline const Vector2D Tensor2D::x() const +inline Vector2D Tensor2D::x() const { return Vector2D(this->v_[XX], this->v_[XY]); } template -inline const Vector2D Tensor2D::y() const +inline Vector2D Tensor2D::y() const { return Vector2D(this->v_[YX], this->v_[YY]); }