From e03ca4c4662ed6ade115944c1fcb0f268ed02c74 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 4 Aug 2017 11:09:32 +0200 Subject: [PATCH 01/32] CONFIG: add Cray compiler, cray mpich settings, wmake rules (fixes #558) - the cray C/C++ compilers appear to be option-compatible with gcc. - no wmake rules for 32bit builds (deemed to be unnecessary) --- etc/bashrc | 4 ++-- etc/config.csh/mpi | 22 ++++++++++++++++++++++ etc/config.csh/settings | 9 +++++++-- etc/config.sh/mpi | 22 ++++++++++++++++++++++ etc/config.sh/settings | 9 +++++++-- etc/cshrc | 4 ++-- wmake/rules/General/mplibCRAY-MPICH | 1 + wmake/rules/linux64Cray/c | 16 ++++++++++++++++ wmake/rules/linux64Cray/c++ | 24 ++++++++++++++++++++++++ wmake/rules/linux64Cray/c++Debug | 2 ++ wmake/rules/linux64Cray/c++Opt | 4 ++++ wmake/rules/linux64Cray/c++Prof | 2 ++ wmake/rules/linux64Cray/cDebug | 2 ++ wmake/rules/linux64Cray/cOpt | 2 ++ wmake/rules/linux64Cray/cProf | 2 ++ wmake/rules/linux64Cray/general | 9 +++++++++ wmake/rules/linux64Cray/mplibINTELMPI | 3 +++ wmake/rules/linux64Cray/openmp | 4 ++++ 18 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 wmake/rules/General/mplibCRAY-MPICH create mode 100644 wmake/rules/linux64Cray/c create mode 100644 wmake/rules/linux64Cray/c++ create mode 100644 wmake/rules/linux64Cray/c++Debug create mode 100644 wmake/rules/linux64Cray/c++Opt create mode 100644 wmake/rules/linux64Cray/c++Prof create mode 100644 wmake/rules/linux64Cray/cDebug create mode 100644 wmake/rules/linux64Cray/cOpt create mode 100644 wmake/rules/linux64Cray/cProf create mode 100644 wmake/rules/linux64Cray/general create mode 100644 wmake/rules/linux64Cray/mplibINTELMPI create mode 100644 wmake/rules/linux64Cray/openmp diff --git a/etc/bashrc b/etc/bashrc index e2e887ac64..597d5494d6 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -65,7 +65,7 @@ export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL +# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH @@ -89,7 +89,7 @@ export WM_COMPILE_OPTION=Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI -# | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI +# | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI export WM_MPLIB=SYSTEMOPENMPI #- Operating System: diff --git a/etc/config.csh/mpi b/etc/config.csh/mpi index e2ec875e4f..ae9a7c15a4 100644 --- a/etc/config.csh/mpi +++ b/etc/config.csh/mpi @@ -141,6 +141,28 @@ case MPICH-GM: _foamAddLib $GM_LIB_PATH breaksw +case CRAY-MPICH: + if ( ! $?MPICH_DIR ) setenv MPICH_DIR /dev/null + setenv FOAM_MPI cray-mpich + setenv MPI_ARCH_PATH $MPICH_DIR + + if ($?FOAM_VERBOSE && $?prompt) then + echo "Using $WM_MPLIB" + echo " FOAM_MPI : $FOAM_MPI" + echo " MPICH_DIR : $MPI_ARCH_PATH" + endif + + if ( ! -d "$MPI_ARCH_PATH" ) then + echo "Warning in $WM_PROJECT_DIR/etc/config.csh/mpi:" + echo " Not a valid $WM_MPLIB installation directory." + echo " Please set MPICH_DIR properly." + echo " Currently using '$MPI_ARCH_PATH'" + endif + + # _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + breaksw + case HPMPI: setenv FOAM_MPI hpmpi setenv MPI_HOME /opt/hpmpi diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 98442b94a1..40c3df8985 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -214,12 +214,17 @@ if (! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system # Adjustments for non-gcc compilers switch ("$WM_COMPILER") case Clang*: - # Using clang - not gcc + # Using clang compiler suite setenv WM_CC 'clang' setenv WM_CXX 'clang++' breaksw +case Cray*: + # Using cray system compilers + setenv WM_CC 'cc' + setenv WM_CXX 'CC' + breaksw case Icc*: - # Using icc - not gcc + # Using intel compilers setenv WM_CC 'icc' setenv WM_CXX 'icpc' breaksw diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi index a2d676d76b..1a87bf238f 100644 --- a/etc/config.sh/mpi +++ b/etc/config.sh/mpi @@ -160,6 +160,28 @@ MPICH-GM) _foamAddLib $GM_LIB_PATH ;; +CRAY-MPICH) + export FOAM_MPI=cray-mpich + export MPI_ARCH_PATH=$MPICH_DIR + + if [ "$FOAM_VERBOSE" -a "$PS1" ] + then + echo "Using $WM_MPLIB" 1>&2 + echo " FOAM_MPI : $FOAM_MPI" 1>&2 + echo " MPICH_DIR : $MPI_ARCH_PATH" 1>&2 + fi + + [ -d "$MPI_ARCH_PATH" ] || { + echo "Warning in $WM_PROJECT_DIR/etc/config.sh/mpi:" 1>&2 + echo " Not a valid $WM_MPLIB installation directory." 1>&2 + echo " Please set MPICH_DIR properly" 1>&2 + echo " Currently using '$MPI_ARCH_PATH'" 1>&2 + } + + # _foamAddPath $MPI_ARCH_PATH/bin + _foamAddLib $MPI_ARCH_PATH/lib + ;; + HPMPI) export FOAM_MPI=hpmpi export MPI_HOME=/opt/hpmpi diff --git a/etc/config.sh/settings b/etc/config.sh/settings index ebc4bf435a..20821fae2e 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -216,12 +216,17 @@ _foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN # Adjust for non-gcc compilers case "$WM_COMPILER" in Clang*) - # Using clang - not gcc + # Using clang compiler suite export WM_CC='clang' export WM_CXX='clang++' ;; +Cray*) + # Using cray system compilers + export WM_CC='cc' + export WM_CXX='CC' + ;; Icc*) - # Using icc - not gcc + # Using intel compilers export WM_CC='icc' export WM_CXX='icpc' ;; diff --git a/etc/cshrc b/etc/cshrc index 7b8da52c26..7cefb2f383 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -61,7 +61,7 @@ setenv WM_COMPILER_TYPE system #- Compiler: # WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL -# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL +# | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL | Cray setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH @@ -86,7 +86,7 @@ setenv WM_COMPILE_OPTION Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI -# | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI +# | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI setenv WM_MPLIB SYSTEMOPENMPI #- Operating System: diff --git a/wmake/rules/General/mplibCRAY-MPICH b/wmake/rules/General/mplibCRAY-MPICH new file mode 100644 index 0000000000..fdb91c1379 --- /dev/null +++ b/wmake/rules/General/mplibCRAY-MPICH @@ -0,0 +1 @@ +include $(GENERAL_RULES)/mplibMPICH diff --git a/wmake/rules/linux64Cray/c b/wmake/rules/linux64Cray/c new file mode 100644 index 0000000000..d08f441440 --- /dev/null +++ b/wmake/rules/linux64Cray/c @@ -0,0 +1,16 @@ +SUFFIXES += .c + +cWARN = -Wall + +cc = cc -m64 + +include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION) + +cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC + +ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ + +LINK_LIBS = $(cDBUG) + +LINKLIBSO = $(cc) -shared +LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linux64Cray/c++ b/wmake/rules/linux64Cray/c++ new file mode 100644 index 0000000000..30c2bc762e --- /dev/null +++ b/wmake/rules/linux64Cray/c++ @@ -0,0 +1,24 @@ +SUFFIXES += .C + +c++WARN = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof + +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + +CC = CC -std=c++11 -m64 + +include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION) + +ptFLAGS = -DNoRepository -ftemplate-depth-100 + +c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC + +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@ +cxxtoo = $(Ctoo) +cctoo = $(Ctoo) +cpptoo = $(Ctoo) + +LINK_LIBS = $(c++DBUG) + +LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linux64Cray/c++Debug b/wmake/rules/linux64Cray/c++Debug new file mode 100644 index 0000000000..19bdb9c334 --- /dev/null +++ b/wmake/rules/linux64Cray/c++Debug @@ -0,0 +1,2 @@ +c++DBUG = -ggdb3 -DFULLDEBUG +c++OPT = -O0 -fdefault-inline diff --git a/wmake/rules/linux64Cray/c++Opt b/wmake/rules/linux64Cray/c++Opt new file mode 100644 index 0000000000..599e6aba61 --- /dev/null +++ b/wmake/rules/linux64Cray/c++Opt @@ -0,0 +1,4 @@ +c++DBUG = +c++OPT = -O3 + +ROUNDING_MATH = -frounding-math diff --git a/wmake/rules/linux64Cray/c++Prof b/wmake/rules/linux64Cray/c++Prof new file mode 100644 index 0000000000..3bda4dad55 --- /dev/null +++ b/wmake/rules/linux64Cray/c++Prof @@ -0,0 +1,2 @@ +c++DBUG = -pg +c++OPT = -O2 diff --git a/wmake/rules/linux64Cray/cDebug b/wmake/rules/linux64Cray/cDebug new file mode 100644 index 0000000000..72b638f458 --- /dev/null +++ b/wmake/rules/linux64Cray/cDebug @@ -0,0 +1,2 @@ +cDBUG = -ggdb -DFULLDEBUG +cOPT = -O1 -fdefault-inline -finline-functions diff --git a/wmake/rules/linux64Cray/cOpt b/wmake/rules/linux64Cray/cOpt new file mode 100644 index 0000000000..17318709f1 --- /dev/null +++ b/wmake/rules/linux64Cray/cOpt @@ -0,0 +1,2 @@ +cDBUG = +cOPT = -O3 diff --git a/wmake/rules/linux64Cray/cProf b/wmake/rules/linux64Cray/cProf new file mode 100644 index 0000000000..ca3ac9bf5f --- /dev/null +++ b/wmake/rules/linux64Cray/cProf @@ -0,0 +1,2 @@ +cDBUG = -pg +cOPT = -O2 diff --git a/wmake/rules/linux64Cray/general b/wmake/rules/linux64Cray/general new file mode 100644 index 0000000000..a0c807e5d8 --- /dev/null +++ b/wmake/rules/linux64Cray/general @@ -0,0 +1,9 @@ +CPP = cpp -traditional-cpp $(GFLAGS) + +PROJECT_LIBS = -l$(WM_PROJECT) -ldl + +include $(GENERAL_RULES)/standard + +# include $(DEFAULT_RULES)/openmp +include $(DEFAULT_RULES)/c +include $(DEFAULT_RULES)/c++ diff --git a/wmake/rules/linux64Cray/mplibINTELMPI b/wmake/rules/linux64Cray/mplibINTELMPI new file mode 100644 index 0000000000..278e0b0f22 --- /dev/null +++ b/wmake/rules/linux64Cray/mplibINTELMPI @@ -0,0 +1,3 @@ +PFLAGS = -DMPICH_SKIP_MPICXX +PINC = -isystem $(MPI_ARCH_PATH)/include64 +PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi diff --git a/wmake/rules/linux64Cray/openmp b/wmake/rules/linux64Cray/openmp new file mode 100644 index 0000000000..bcb805f57c --- /dev/null +++ b/wmake/rules/linux64Cray/openmp @@ -0,0 +1,4 @@ +# Flags for compiling/linking openmp + +COMP_OPENMP = -DUSE_OMP -fopenmp +LINK_OPENMP = -lgomp From 79f2466ca525bfbd037c2ae7d30167a465e20272 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 18 Sep 2017 10:17:24 +0100 Subject: [PATCH 02/32] BUG: DESModelRegions - added missing field write() - see #591 --- src/functionObjects/field/DESModelRegions/DESModelRegions.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/functionObjects/field/DESModelRegions/DESModelRegions.C b/src/functionObjects/field/DESModelRegions/DESModelRegions.C index bb94a12767..ba30876431 100644 --- a/src/functionObjects/field/DESModelRegions/DESModelRegions.C +++ b/src/functionObjects/field/DESModelRegions/DESModelRegions.C @@ -172,6 +172,8 @@ bool Foam::functionObjects::DESModelRegions::write() << " writing field " << DESModelRegions.name() << nl << endl; + DESModelRegions.write(); + return true; } From 94cf702f6976527eef8a3923bd8f0359dec13606 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 18 Sep 2017 10:48:39 +0100 Subject: [PATCH 03/32] BUG: kOmegaSSTLM - corrected writing of coefficients. Fixes #592 --- .../turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C index 5d14d97bf9..371b0a51f1 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C @@ -373,7 +373,8 @@ kOmegaSSTLM::kOmegaSSTLM alphaRhoPhi, phi, transport, - propertiesName + propertiesName, + typeName ), ca1_ @@ -477,7 +478,12 @@ kOmegaSSTLM::kOmegaSSTLM this->mesh_, dimensionedScalar("0", dimless, 0) ) -{} +{ + if (type == typeName) + { + this->printCoeffs(type); + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // From 68e7533847dde7514df4cd8dcb444ec32dc380d6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 20 Sep 2017 17:01:56 +0200 Subject: [PATCH 04/32] STYLE: include in stdFoam, formatting of list loop macros --- .../containers/Lists/FixedList/FixedList.C | 6 +- src/OpenFOAM/containers/Lists/List/List.C | 18 ++++-- .../containers/Lists/List/ListLoopM.H | 12 +--- src/OpenFOAM/containers/Lists/UList/UList.C | 12 ++-- src/OpenFOAM/fields/Fields/Field/FieldM.H | 58 ++++++++++++------- src/OpenFOAM/include/stdFoam.H | 24 ++++---- 6 files changed, 78 insertions(+), 52 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index 03c3d16768..19163402da 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C @@ -35,10 +35,11 @@ void Foam::FixedList::swap(FixedList& a) List_ACCESS(T, a, ap); T tmp; List_FOR_ALL((*this), i) + { tmp = List_CELEM((*this), vp, i); List_ELEM((*this), vp, i) = List_CELEM(a, ap, i); List_ELEM(a, ap, i) = tmp; - List_END_FOR_ALL + } } @@ -53,9 +54,10 @@ bool Foam::FixedList::operator==(const FixedList& a) const List_CONST_ACCESS(T, (a), ap); List_FOR_ALL((*this), i) + { equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); if (!equal) break; - List_END_FOR_ALL + } return equal; } diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index ab8aea673f..04f731f211 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -69,8 +69,9 @@ Foam::List::List(const label s, const T& a) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = a; - List_END_FOR_ALL + } } } @@ -93,8 +94,9 @@ Foam::List::List(const label s, const zero) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = Zero; - List_END_FOR_ALL + } } } @@ -119,8 +121,9 @@ Foam::List::List(const List& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -139,8 +142,9 @@ Foam::List::List(const List& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T2, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = T(List_ELEM(a, ap, i)); - List_END_FOR_ALL + } } } @@ -178,8 +182,9 @@ Foam::List::List(List& a, bool reuse) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -390,8 +395,9 @@ void Foam::List::operator=(const UList& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } diff --git a/src/OpenFOAM/containers/Lists/List/ListLoopM.H b/src/OpenFOAM/containers/Lists/List/ListLoopM.H index 032edb3052..5f74321bc6 100644 --- a/src/OpenFOAM/containers/Lists/List/ListLoopM.H +++ b/src/OpenFOAM/containers/Lists/List/ListLoopM.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,10 +37,7 @@ Description #define List_FOR_ALL(f, i) \ const label _n##i = (f).size(); \ - for (label i=0; i<_n##i; ++i) \ - { - -#define List_END_FOR_ALL } + for (label i=0; i<_n##i; ++i) // Provide current element #define List_CELEM(f, fp, i) (fp[i]) @@ -60,10 +57,7 @@ Description #define List_FOR_ALL(f, i) \ label i = (f).size(); \ - while (i--) \ - { \ - -#define List_END_FOR_ALL } + while (i--) // Provide current element without incrementing pointer #define List_CELEM(f, fp, i) (*fp) diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index f479698744..599dd0f998 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -95,8 +95,9 @@ void Foam::UList::deepCopy(const UList& a) List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = List_ELEM(a, ap, i); - List_END_FOR_ALL + } } } } @@ -152,8 +153,9 @@ void Foam::UList::operator=(const T& t) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = t; - List_END_FOR_ALL + } } @@ -162,8 +164,9 @@ void Foam::UList::operator=(const zero) { List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) + { List_ELEM((*this), vp, i) = Zero; - List_END_FOR_ALL + } } @@ -244,9 +247,10 @@ bool Foam::UList::operator==(const UList& a) const List_CONST_ACCESS(T, (a), ap); List_FOR_ALL((*this), i) + { equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i)); if (!equal) break; - List_END_FOR_ALL + } return equal; } diff --git a/src/OpenFOAM/fields/Fields/Field/FieldM.H b/src/OpenFOAM/fields/Fields/Field/FieldM.H index 28d4788c17..46be4b350d 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldM.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldM.H @@ -120,8 +120,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } #define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC) \ @@ -135,13 +136,14 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i).FUNC(); \ - List_END_FOR_ALL \ + } // member function : this field f1 OP fUNC f2, f3 -#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)\ +#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3) \ \ /* check the three fields have same Field mesh */ \ checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3)"); \ @@ -153,9 +155,10 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) \ OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \ - List_END_FOR_ALL \ + } // member function : this field f1 OP fUNC f2, f3 @@ -171,8 +174,9 @@ void checkFields \ /* loop through fields performing s OP FUNC(f1, f2) */ \ List_FOR_ALL(f1, i) \ + { \ (s) OP FUNC(List_ELEM(f1, f1P, i), List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC f2, s @@ -188,8 +192,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i), (s)); \ - List_END_FOR_ALL + } // member function : s1 OP fUNC f, s2 @@ -201,8 +206,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f, i) \ + { \ (s1) OP FUNC(List_ELEM(f, fP, i), (s2)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC s, f2 @@ -218,21 +224,23 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC((s), List_ELEM(f2, f2P, i)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP fUNC s, f2 -#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)\ +#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2) \ \ /* set access to f1 at end of field */ \ List_ACCESS(typeF1, f1, f1P); \ \ /* loop through fields performing f1 OP1 FUNC(s1, s2) */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP FUNC((s1), (s2)); \ - List_END_FOR_ALL \ + } // member function : this f1 OP1 f2 OP2 FUNC s @@ -248,8 +256,9 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i) FUNC((s)); \ - List_END_FOR_ALL \ + } // define high performance macro functions for Field operations @@ -268,9 +277,10 @@ void checkFields \ /* loop through fields performing f1 OP1 f2 OP2 f3 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) \ OP2 List_ELEM(f3, f3P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 s OP2 f2 @@ -286,8 +296,9 @@ void checkFields \ /* loop through fields performing f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 (s) OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 f2 OP2 s @@ -303,8 +314,9 @@ void checkFields \ /* loop through fields performing f1 OP1 s OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) OP2 (s); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP f2 @@ -321,8 +333,9 @@ void checkFields \ /* loop through fields performing f1 OP f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f1 OP1 OP2 f2 @@ -338,8 +351,9 @@ void checkFields \ /* loop through fields performing f1 OP1 OP2 f2 */ \ List_FOR_ALL(f1, i) \ + { \ List_ELEM(f1, f1P, i) OP1 OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL \ + } // member operator : this field f OP s @@ -351,8 +365,9 @@ void checkFields \ /* loop through field performing f OP s */ \ List_FOR_ALL(f, i) \ + { \ List_ELEM(f, fP, i) OP (s); \ - List_END_FOR_ALL \ + } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -367,8 +382,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f, i) \ + { \ (s) OP List_ELEM(f, fP, i); \ - List_END_FOR_ALL + } // friend operator function : s OP1 f1 OP2 f2, allocates storage for s @@ -381,8 +397,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f1, i) \ + { \ (s) OP1 List_ELEM(f1, f1P, i) OP2 List_ELEM(f2, f2P, i); \ - List_END_FOR_ALL + } // friend operator function : s OP FUNC(f), allocates storage for s @@ -394,8 +411,9 @@ void checkFields \ /* loop through field performing s OP f */ \ List_FOR_ALL(f, i) \ + { \ (s) OP FUNC(List_ELEM(f, fP, i)); \ - List_END_FOR_ALL + } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H index 59b0d9f704..3141c38351 100644 --- a/src/OpenFOAM/include/stdFoam.H +++ b/src/OpenFOAM/include/stdFoam.H @@ -25,12 +25,13 @@ Namespace stdFoam Description - Includes some global templates and macros used by OpenFOAM. + Some global templates and macros used by OpenFOAM and some standard + C++ headers. - Some of the templates are defined here correspond to useful + Some of the templates defined here correspond to useful std templates that are part of future C++ standards, or that are in a state of change. Defining them here provides some additional - control over which definition are used within the OpenFOAM code-base. + control over which definitions are used within the OpenFOAM code-base. SeeAlso - http://en.cppreference.com/w/cpp/iterator/end @@ -42,6 +43,7 @@ SeeAlso #define StdFoam_H #include +#include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -114,12 +116,12 @@ constexpr auto cend(const C& c) -> decltype(c.end()) // } // \endcode // \sa forAllConstIters, forAllIter, forAllConstIters -#define forAllIters(container,it) \ +#define forAllIters(container,iter) \ for \ ( \ - auto it = stdFoam::begin(container); \ - it != stdFoam::end(container); \ - ++it \ + auto iter = stdFoam::begin(container); \ + iter != stdFoam::end(container); \ + ++iter \ ) @@ -132,12 +134,12 @@ constexpr auto cend(const C& c) -> decltype(c.end()) // } // \endcode // \sa forAllIters, forAllIter, forAllConstIter -#define forAllConstIters(container,cit) \ +#define forAllConstIters(container,iter) \ for \ ( \ - auto cit = stdFoam::cbegin(container); \ - cit != stdFoam::cend(container); \ - ++cit \ + auto iter = stdFoam::cbegin(container); \ + iter != stdFoam::cend(container); \ + ++iter \ ) From 049617d037d963533d554a1efc9e110f70e05589 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 20 Sep 2017 17:20:54 +0200 Subject: [PATCH 05/32] ENH: update List and DynamicList methods (issue #595) - improve functional compatibility with DynList (remove methods) * eg, remove an element from any position in a DynamicList * reduce the number of template parameters * remove/subset regions of DynamicList - propagate Swap template specializations for lists, hashtables - move construct/assignment to various containers. - add find/found methods for FixedList and UList for a more succinct (and clearer?) usage than the equivalent global findIndex() function. - simplify List_FOR_ALL loops --- .../test/DynamicList/Test-DynamicList.C | 109 ++- applications/test/Field/Make/files | 3 - applications/test/Field/Make/options | 2 - applications/test/Field/Test-Field.C | 11 - applications/test/Field/Test-Field.H | 58 -- applications/test/FixedList/Test-FixedList.C | 65 +- applications/test/FixedList/fixedListFile | Bin 30 -> 0 bytes applications/test/FixedList2/Make/files | 3 + applications/test/FixedList2/Make/options | 0 .../test/FixedList2/Test-FixedList2.C | 190 ++++++ applications/test/Function1/Test-Function1.C | 7 +- applications/test/HashSet/Test-hashSet.C | 25 + applications/test/HashTable/Test-hashTable.C | 28 + .../test/IndirectList/Test-IndirectList.C | 56 +- applications/test/List/Test-List.C | 24 +- applications/test/List2/Make/files | 3 + applications/test/List2/Make/options | 0 applications/test/List2/Test-List2.C | 269 ++++++++ applications/test/ListOps2/Make/files | 2 + applications/test/ListOps2/Make/options | 3 + applications/test/ListOps2/Test-ListOps2.C | 144 ++++ applications/test/Map/Test-Map.C | 58 +- .../test/UIndirectList/Test-UIndirectList.C | 87 ++- applications/test/sort/Test-sortList.C | 169 +++-- .../ideasUnvToFoam/ideasUnvToFoam.C | 3 +- .../containers/HashTables/HashSet/HashSet.C | 11 +- .../containers/HashTables/HashSet/HashSet.H | 35 +- .../HashTables/HashTable/HashTable.C | 39 ++ .../HashTables/HashTable/HashTable.H | 20 + .../HashTables/HashTable/HashTableI.H | 13 + src/OpenFOAM/containers/HashTables/Map/Map.H | 31 +- .../Lists/BiIndirectList/BiIndirectList.H | 20 +- .../Lists/BiIndirectList/BiIndirectListI.H | 38 +- .../Lists/DynamicList/DynamicList.C | 76 ++- .../Lists/DynamicList/DynamicList.H | 231 +++++-- .../Lists/DynamicList/DynamicListI.H | 645 +++++++++++++----- .../containers/Lists/FixedList/FixedList.C | 94 ++- .../containers/Lists/FixedList/FixedList.H | 91 ++- .../containers/Lists/FixedList/FixedListI.H | 115 +++- .../Lists/IndirectList/IndirectList.H | 60 +- .../Lists/IndirectList/IndirectListI.H | 1 - src/OpenFOAM/containers/Lists/List/List.C | 168 +++-- src/OpenFOAM/containers/Lists/List/List.H | 59 +- src/OpenFOAM/containers/Lists/List/ListI.H | 14 +- .../containers/Lists/List/ListLoopM.H | 49 +- .../Lists/ListOps/ListOpsTemplates.C | 2 +- .../Lists/SortableList/SortableList.C | 107 ++- .../Lists/SortableList/SortableList.H | 48 +- .../Lists/UIndirectList/UIndirectList.C | 87 +++ .../Lists/UIndirectList/UIndirectList.H | 81 ++- .../Lists/UIndirectList/UIndirectListI.H | 11 + .../Lists/UIndirectList/UIndirectListIO.C | 4 +- src/OpenFOAM/containers/Lists/UList/UList.C | 135 +++- src/OpenFOAM/containers/Lists/UList/UList.H | 75 +- src/OpenFOAM/containers/Lists/UList/UListI.H | 59 +- .../fields/Fields/DynamicField/DynamicField.C | 24 +- .../fields/Fields/DynamicField/DynamicField.H | 56 +- .../Fields/DynamicField/DynamicFieldI.H | 282 ++++---- src/OpenFOAM/fields/Fields/Field/FieldM.H | 179 +++-- src/OpenFOAM/meshes/meshShapes/face/face.H | 7 +- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 4 +- .../meshes/meshShapes/face/faceTemplates.C | 4 +- .../meshes/polyMesh/polyMeshFromShapeMesh.C | 6 +- .../primitiveMesh/primitiveMeshCellEdges.C | 6 +- src/OpenFOAM/primitives/Swap/Swap.H | 44 +- .../enrichedPatch/enrichedPatchPointPoints.C | 6 +- .../searchableBox/searchableBox.C | 2 +- .../searchableRotatedBox.C | 2 +- .../triSurfaceMesh/triSurfaceMesh.H | 2 +- .../triSurfaceSearch/triSurfaceSearch.C | 4 +- .../triSurfaceSearch/triSurfaceSearch.H | 2 +- wmake/rules/linux64GccKNL/c | 2 +- wmake/rules/linux64GccKNL/c++ | 2 +- wmake/rules/linux64IccKNL/c++ | 2 +- 74 files changed, 3205 insertions(+), 1169 deletions(-) delete mode 100644 applications/test/Field/Make/files delete mode 100644 applications/test/Field/Make/options delete mode 100644 applications/test/Field/Test-Field.C delete mode 100644 applications/test/Field/Test-Field.H delete mode 100644 applications/test/FixedList/fixedListFile create mode 100644 applications/test/FixedList2/Make/files create mode 100644 applications/test/FixedList2/Make/options create mode 100644 applications/test/FixedList2/Test-FixedList2.C create mode 100644 applications/test/List2/Make/files create mode 100644 applications/test/List2/Make/options create mode 100644 applications/test/List2/Test-List2.C create mode 100644 applications/test/ListOps2/Make/files create mode 100644 applications/test/ListOps2/Make/options create mode 100644 applications/test/ListOps2/Test-ListOps2.C create mode 100644 src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C diff --git a/applications/test/DynamicList/Test-DynamicList.C b/applications/test/DynamicList/Test-DynamicList.C index c8e2ed4a93..ca3f4fc787 100644 --- a/applications/test/DynamicList/Test-DynamicList.C +++ b/applications/test/DynamicList/Test-DynamicList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,7 +27,10 @@ Description #include "DynamicList.H" #include "IOstreams.H" +#include "FlatOutput.H" #include "ListOps.H" +#include "labelRange.H" +#include "labelIndList.H" using namespace Foam; @@ -44,15 +47,15 @@ void printInfo { Info<< " size=\"" << lst.size() << "\""; } - Info<< ">" << lst << "" << endl; + Info<< ">" << nl << flatOutput(lst) << nl << "" << endl; } -template +template void printInfo ( const word& tag, - const DynamicList& lst, + const DynamicList& lst, const bool showSize = false ) { @@ -62,7 +65,7 @@ void printInfo Info<< " size=\"" << lst.size() << "\" capacity=\"" << lst.capacity() << "\""; } - Info<< ">" << lst << "" << endl; + Info<< ">" << nl << flatOutput(lst) << nl << "" << endl; } @@ -71,7 +74,7 @@ void printInfo int main(int argc, char *argv[]) { - List> ldl(2); + List> ldl(2); ldl[0](0) = 0; ldl[0](2) = 2; @@ -89,7 +92,7 @@ int main(int argc, char *argv[]) ldl[1] = 3; - Info<< "" << ldl << "" << nl << "sizes: "; + Info<< "" << flatOutput(ldl) << "" << nl << "sizes: "; forAll(ldl, i) { Info<< " " << ldl[i].size() << "/" << ldl[i].capacity(); @@ -100,7 +103,7 @@ int main(int argc, char *argv[]) ll[0].transfer(ldl[0]); ll[1].transfer(ldl[1].shrink()); - Info<< "" << ldl << "" << nl << "sizes: "; + Info<< "" << flatOutput(ldl) << "" << nl << "sizes: "; forAll(ldl, i) { Info<< " " << ldl[i].size() << "/" << ldl[i].capacity(); @@ -111,18 +114,18 @@ int main(int argc, char *argv[]) // test the transfer between DynamicLists - DynamicList dlA + DynamicList