From f6b7786025a5a1934ec1c217d4aa283ccd91393d Mon Sep 17 00:00:00 2001 From: Fabian Preiss Date: Sun, 19 May 2019 17:24:41 +0200 Subject: [PATCH 01/12] fixed wrong usuage of `find` in `etc/getVariables.py` --- etc/getVariables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/getVariables.py b/etc/getVariables.py index 248f9862e..67b6d8e67 100755 --- a/etc/getVariables.py +++ b/etc/getVariables.py @@ -229,7 +229,7 @@ class BashConvert(ShellConvert): val=":".join(v) else: val=v - if val.find(" "): + if " " in val: return 'export %s="%s"' % (n,val) else: return 'export %s=%s' % (n,val) From 9e8966483f6cf6364dcdbaa955fbc7e258dcc59d Mon Sep 17 00:00:00 2001 From: Danial Khazaei Date: Mon, 8 Jul 2019 19:08:47 +0430 Subject: [PATCH 02/12] [bugfix]: writing to an object with no trivial copy-assignment [wclass-memaccess]. --- .../constraint/processor/ProcessorPointPatchField.C | 2 +- .../processorLduInterface/processorLduInterfaceTemplates.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C index 603211464..346951975 100644 --- a/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C +++ b/src/foam/fields/PointPatchFieldTemplates/constraint/processor/ProcessorPointPatchField.C @@ -170,7 +170,7 @@ receivePointField outstandingSendRequest_ = -1; outstandingRecvRequest_ = -1; - memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize()); + memcpy(static_cast(tf().begin()), receiveBuf_.begin(), tf().byteSize()); } else { diff --git a/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaces/processorLduInterface/processorLduInterfaceTemplates.C b/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaces/processorLduInterface/processorLduInterfaceTemplates.C index 9cc74ee76..1896b1056 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaces/processorLduInterface/processorLduInterfaceTemplates.C +++ b/src/foam/matrices/lduMatrix/lduAddressing/lduInterfaces/processorLduInterface/processorLduInterfaceTemplates.C @@ -107,7 +107,7 @@ void Foam::processorLduInterface::receive } else if (commsType == Pstream::nonBlocking) { - memcpy(f.begin(), receiveBuf_.begin(), f.byteSize()); + memcpy(static_cast(f.begin()), receiveBuf_.begin(), f.byteSize()); } else { From 69192ae1f4f1bf0874c0b27de2eb9f1f9278235b Mon Sep 17 00:00:00 2001 From: Danial Khazaei Date: Mon, 8 Jul 2019 19:13:27 +0430 Subject: [PATCH 03/12] [port]: re-write List container to suppress [-Walloc-size-larger-than=]. - Changes are ported from OpenFOAM-dev project. --- src/foam/containers/Lists/List/List.C | 114 ++++++------------------- src/foam/containers/Lists/List/List.H | 23 ++++- src/foam/containers/Lists/List/ListI.H | 75 ++++++++++++++++ 3 files changed, 121 insertions(+), 91 deletions(-) diff --git a/src/foam/containers/Lists/List/List.C b/src/foam/containers/Lists/List/List.C index 5c1d5a256..fd5efb256 100644 --- a/src/foam/containers/Lists/List/List.C +++ b/src/foam/containers/Lists/List/List.C @@ -50,15 +50,12 @@ Foam::List::List(const label s) { if (this->size_ < 0) { - FatalErrorIn("List::List(const label size)") + FatalErrorInFunction << "bad size " << this->size_ << abort(FatalError); } - if (this->size_) - { - this->v_ = new T[this->size_]; - } + alloc(); } @@ -70,15 +67,15 @@ Foam::List::List(const label s, const T& a) { if (this->size_ < 0) { - FatalErrorIn("List::List(const label size, const T&)") + FatalErrorInFunction << "bad size " << this->size_ << abort(FatalError); } + alloc(); + if (this->size_) { - this->v_ = new T[this->size_]; - List_ACCESS(T, (*this), vp); List_FOR_ALL((*this), i) List_ELEM((*this), vp, i) = a; @@ -95,15 +92,15 @@ Foam::List::List(const List& a) { if (this->size_) { - this->v_ = new T[this->size_]; + alloc(); -# ifdef USEMEMCPY + #ifdef USEMEMCPY if (contiguous()) { memcpy(this->v_, a.v_, this->byteSize()); } else -# endif + #endif { List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); @@ -125,11 +122,11 @@ Foam::List::List(const Xfer< List >& lst) // Construct as copy or re-use as specified. template -Foam::List::List(List& a, bool reUse) +Foam::List::List(List& a, bool reuse) : UList(nullptr, a.size_) { - if (reUse) + if (reuse) { this->v_ = a.v_; a.v_ = 0; @@ -137,15 +134,15 @@ Foam::List::List(List& a, bool reUse) } else if (this->size_) { - this->v_ = new T[this->size_]; + alloc(); -# ifdef USEMEMCPY + #ifdef USEMEMCPY if (contiguous()) { memcpy(this->v_, a.v_, this->byteSize()); } else -# endif + #endif { List_ACCESS(T, (*this), vp); List_CONST_ACCESS(T, a, ap); @@ -167,11 +164,11 @@ Foam::List::List(const UList& a, const unallocLabelList& map) { // Note:cannot use List_ELEM since third argument has to be index. - this->v_ = new T[this->size_]; + alloc(); forAll(*this, i) { - this->v_[i] = a[map[i]]; + this->operator[](i) = a[map[i]]; } } } @@ -181,32 +178,9 @@ Foam::List::List(const UList& a, const unallocLabelList& map) template template Foam::List::List(InputIterator first, InputIterator last) -{ - label s = 0; - for - ( - InputIterator iter = first; - iter != last; - ++iter - ) - { - s++; - } - - setSize(s); - - s = 0; - - for - ( - InputIterator iter = first; - iter != last; - ++iter - ) - { - this->operator[](s++) = iter(); - } -} +: + List(first, last, std::distance(first, last)) +{} // Construct as copy of FixedList @@ -216,15 +190,7 @@ Foam::List::List(const FixedList& lst) : UList(nullptr, Size) { - if (this->size_) - { - this->v_ = new T[this->size_]; - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } - } + allocCopyList(lst); } @@ -234,15 +200,7 @@ Foam::List::List(const PtrList& lst) : UList(nullptr, lst.size()) { - if (this->size_) - { - this->v_ = new T[this->size_]; - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } - } + allocCopyList(lst); } @@ -254,7 +212,7 @@ Foam::List::List(const SLList& lst) { if (this->size_) { - this->v_ = new T[this->size_]; + alloc(); label i = 0; for @@ -276,15 +234,7 @@ Foam::List::List(const IndirectList& lst) : UList(nullptr, lst.size()) { - if (this->size_) - { - this->v_ = new T[this->size_]; - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } - } + allocCopyList(lst); } @@ -294,15 +244,7 @@ Foam::List::List(const UIndirectList& lst) : UList(nullptr, lst.size()) { - if (this->size_) - { - this->v_ = new T[this->size_]; - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } - } + allocCopyList(lst); } @@ -312,15 +254,7 @@ Foam::List::List(const BiIndirectList& lst) : UList(nullptr, lst.size()) { - if (this->size_) - { - this->v_ = new T[this->size_]; - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } - } + allocCopyList(lst); } diff --git a/src/foam/containers/Lists/List/List.H b/src/foam/containers/Lists/List/List.H index ec667b2a8..2a37e5c35 100644 --- a/src/foam/containers/Lists/List/List.H +++ b/src/foam/containers/Lists/List/List.H @@ -80,6 +80,27 @@ class List public UList { + // Private member functions + + //- Allocate list storage + inline void alloc(); + + //- Reallocate list storage to the given size + inline void reAlloc(const label s); + + //- Copy list of given type + template + inline void copyList(const List2&); + + //- Allocate storage and copy list of given type + template + inline void allocCopyList(const List2&); + + //- Construct given start and end iterators and number of elements + template + inline List(InputIterator first, InputIterator last, const label s); + + protected: //- Override size to be inconsistent with allocated storage. @@ -118,7 +139,7 @@ public: List(const Xfer< List >&); //- Construct as copy or re-use as specified. - List(List&, bool reUse); + List(List&, bool reuse); //- Construct as subset. List(const UList&, const unallocLabelList& mapAddressing); diff --git a/src/foam/containers/Lists/List/ListI.H b/src/foam/containers/Lists/List/ListI.H index 74c501891..05bacc9d0 100644 --- a/src/foam/containers/Lists/List/ListI.H +++ b/src/foam/containers/Lists/List/ListI.H @@ -23,6 +23,81 @@ License \*---------------------------------------------------------------------------*/ +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +inline void Foam::List::alloc() +{ + if (this->size_ > 0) + { + this->v_ = new T[this->size_]; + } +} + + +template +inline void Foam::List::reAlloc(const label s) +{ + if (this->size_ != s) + { + clear(); + this->size_ = s; + alloc(); + } +} + + +template +template +inline void Foam::List::copyList(const List2& lst) +{ + if (this->size_) + { + forAll(*this, i) + { + this->operator[](i) = lst[i]; + } + } +} + + +template +template +inline void Foam::List::allocCopyList(const List2& lst) +{ + if (this->size_) + { + alloc(); + copyList(lst); + } +} + + +template +template +inline Foam::List::List +( + InputIterator first, + InputIterator last, + const label s +) +: + UList(nullptr, s) +{ + if (this->size_) + { + alloc(); + + InputIterator iter = first; + forAll(*this, i) + { + this->operator[](i) = *iter; + ++iter; + } + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template From 314069356ed6d387e0283567bd46bf804d1dcaa5 Mon Sep 17 00:00:00 2001 From: Danial Khazaei Date: Mon, 8 Jul 2019 19:34:33 +0430 Subject: [PATCH 04/12] [port]: disabled flex++ warnings during foam compile. --- wmake/rules/General/flex++ | 4 ++-- wmake/rules/SiCortex64Gcc/c++ | 3 +++ wmake/rules/SunOS64Gcc/c++ | 3 +++ wmake/rules/linux64Gcc/c++ | 3 +++ wmake/rules/linux64Icc/c++ | 3 +++ wmake/rules/linuxARM7Gcc/c++ | 3 +++ wmake/rules/linuxARM8Arm/c++ | 3 +++ wmake/rules/linuxARM8Gcc/c++ | 3 +++ wmake/rules/linuxGcc/c++ | 3 +++ wmake/rules/linuxIA64Gcc/c++ | 3 +++ wmake/rules/linuxIA64I64/c++ | 3 +++ wmake/rules/linuxIA64Icc/c++ | 3 +++ wmake/rules/linuxIcc/c++ | 3 +++ wmake/rules/linuxPPC64Gcc/c++ | 3 +++ wmake/rules/mingwGcc/c++ | 3 +++ wmake/rules/solarisGcc/c++ | 3 +++ 16 files changed, 47 insertions(+), 2 deletions(-) diff --git a/wmake/rules/General/flex++ b/wmake/rules/General/flex++ index 9af740a96..aabf584fb 100644 --- a/wmake/rules/General/flex++ +++ b/wmake/rules/General/flex++ @@ -2,8 +2,8 @@ # For older versions of flex, the option --c++ is not avaliable # Switching to flex++ is an alternative -#Ltoo = flex++ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@ -Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@ +#Ltoo = flex++ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $(c++LESSWARN) -c $*.C -o $@ +Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $(c++LESSWARN) -c $*.C -o $@ .L.dep: $(MAKE_DEP) diff --git a/wmake/rules/SiCortex64Gcc/c++ b/wmake/rules/SiCortex64Gcc/c++ index dafa8f5c3..04ce02186 100644 --- a/wmake/rules/SiCortex64Gcc/c++ +++ b/wmake/rules/SiCortex64Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -mabi=64 #CC = scg++ -mabi=64 diff --git a/wmake/rules/SunOS64Gcc/c++ b/wmake/rules/SunOS64Gcc/c++ index 936a030ee..046f21c1e 100644 --- a/wmake/rules/SunOS64Gcc/c++ +++ b/wmake/rules/SunOS64Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -m64 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linux64Gcc/c++ b/wmake/rules/linux64Gcc/c++ index 2f00832b7..19e6f87ce 100644 --- a/wmake/rules/linux64Gcc/c++ +++ b/wmake/rules/linux64Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 -m64 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linux64Icc/c++ b/wmake/rules/linux64Icc/c++ index c8b3d7ca9..7f5906d90 100644 --- a/wmake/rules/linux64Icc/c++ +++ b/wmake/rules/linux64Icc/c++ @@ -2,6 +2,9 @@ c++WARN = -wd327,584,654,819,1125,1476,1505,1572 +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -diag-disable 1224,2026,2305 + CC = icpc -DIntel include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxARM7Gcc/c++ b/wmake/rules/linuxARM7Gcc/c++ index f1f70ab80..381a65c60 100644 --- a/wmake/rules/linuxARM7Gcc/c++ +++ b/wmake/rules/linuxARM7Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxARM8Arm/c++ b/wmake/rules/linuxARM8Arm/c++ index fe83a320f..6333d9a4f 100644 --- a/wmake/rules/linuxARM8Arm/c++ +++ b/wmake/rules/linuxARM8Arm/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wno-undefined-var-template -Wno-deprecated-register -Wno-overloaded-virtual -Wno-null-dereference +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = armclang++ -std=c++11 -DARM_CLANG include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxARM8Gcc/c++ b/wmake/rules/linuxARM8Gcc/c++ index f1f70ab80..381a65c60 100644 --- a/wmake/rules/linuxARM8Gcc/c++ +++ b/wmake/rules/linuxARM8Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxGcc/c++ b/wmake/rules/linuxGcc/c++ index 9a972c577..f0ee56ac1 100644 --- a/wmake/rules/linuxGcc/c++ +++ b/wmake/rules/linuxGcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 -m32 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxIA64Gcc/c++ b/wmake/rules/linuxIA64Gcc/c++ index eaf8972e1..bf274ffba 100644 --- a/wmake/rules/linuxIA64Gcc/c++ +++ b/wmake/rules/linuxIA64Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxIA64I64/c++ b/wmake/rules/linuxIA64I64/c++ index a5a65d79d..269630818 100644 --- a/wmake/rules/linuxIA64I64/c++ +++ b/wmake/rules/linuxIA64I64/c++ @@ -2,6 +2,9 @@ c++WARN = -wd654,819,1125,1476,1505,1572 +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -diag-disable 1224,2026,2305 + CC = icpc -DIntel include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxIA64Icc/c++ b/wmake/rules/linuxIA64Icc/c++ index 625cbd186..8b1afeeb0 100644 --- a/wmake/rules/linuxIA64Icc/c++ +++ b/wmake/rules/linuxIA64Icc/c++ @@ -2,6 +2,9 @@ c++WARN = -wd327,654,819,1125,1476,1505,1572 +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -diag-disable 1224,2026,2305 + CC = icpc include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxIcc/c++ b/wmake/rules/linuxIcc/c++ index 8a3abc689..7dbc865df 100644 --- a/wmake/rules/linuxIcc/c++ +++ b/wmake/rules/linuxIcc/c++ @@ -2,6 +2,9 @@ c++WARN = -wd654 -wd1125 -vec-report0 +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -diag-disable 1224,2026,2305 + CC = icpc -DIntel include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/linuxPPC64Gcc/c++ b/wmake/rules/linuxPPC64Gcc/c++ index d8af9b25f..ed213f57e 100644 --- a/wmake/rules/linuxPPC64Gcc/c++ +++ b/wmake/rules/linuxPPC64Gcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 -m64 -mcpu=power5+ include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/mingwGcc/c++ b/wmake/rules/mingwGcc/c++ index a4c0fdfc2..fd754a354 100644 --- a/wmake/rules/mingwGcc/c++ +++ b/wmake/rules/mingwGcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds + CC = g++ -std=c++11 include $(RULES)/c++$(WM_COMPILE_OPTION) diff --git a/wmake/rules/solarisGcc/c++ b/wmake/rules/solarisGcc/c++ index 56edcd7a8..c790448d3 100644 --- a/wmake/rules/solarisGcc/c++ +++ b/wmake/rules/solarisGcc/c++ @@ -2,6 +2,9 @@ c++WARN = -Wall -Wextra -Wno-unused-parameter +# Suppress some warnings for flex++ and CGAL +c++LESSWARN = + CC = g++ -std=c++11 include $(RULES)/c++$(WM_COMPILE_OPTION) From 4e8d74617bfa3eea92a4a888fa382531a08ae8fa Mon Sep 17 00:00:00 2001 From: Danial Khazaei Date: Mon, 8 Jul 2019 19:36:38 +0430 Subject: [PATCH 05/12] [bugfix]: corrected APPBIN path for RichardsFoam solver. --- applications/solvers/incompressible/RichardsFoam/Make/files | 2 +- .../RichardsFoam/spatialMeanValueRichardsonFoam/Make/files | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/solvers/incompressible/RichardsFoam/Make/files b/applications/solvers/incompressible/RichardsFoam/Make/files index f2b8d52a1..6d64d17d5 100755 --- a/applications/solvers/incompressible/RichardsFoam/Make/files +++ b/applications/solvers/incompressible/RichardsFoam/Make/files @@ -1,3 +1,3 @@ RichardsFoam.C -EXE = $(FOAM_USER_APPBIN)/RichardsFoam +EXE = $(FOAM_APPBIN)/RichardsFoam diff --git a/applications/solvers/incompressible/RichardsFoam/spatialMeanValueRichardsonFoam/Make/files b/applications/solvers/incompressible/RichardsFoam/spatialMeanValueRichardsonFoam/Make/files index 32c9117fd..c352bdb19 100755 --- a/applications/solvers/incompressible/RichardsFoam/spatialMeanValueRichardsonFoam/Make/files +++ b/applications/solvers/incompressible/RichardsFoam/spatialMeanValueRichardsonFoam/Make/files @@ -1,3 +1,3 @@ spatialMeanValueRichardsonFoam.C -EXE = $(FOAM_USER_APPBIN)/spatialMeanValueRichardsonFoam +EXE = $(FOAM_APPBIN)/spatialMeanValueRichardsonFoam From 9e401eedca3b365612eca744571438d4a89f18d0 Mon Sep 17 00:00:00 2001 From: Danial Khazaei Date: Mon, 8 Jul 2019 21:10:15 +0430 Subject: [PATCH 06/12] [port]: completed List container implementation with new functions. --- src/foam/containers/Lists/List/List.C | 80 ++++++-------------------- src/foam/containers/Lists/List/List.H | 4 +- src/foam/containers/Lists/List/ListI.H | 16 +++++- 3 files changed, 32 insertions(+), 68 deletions(-) diff --git a/src/foam/containers/Lists/List/List.C b/src/foam/containers/Lists/List/List.C index fd5efb256..47f3aa4de 100644 --- a/src/foam/containers/Lists/List/List.C +++ b/src/foam/containers/Lists/List/List.C @@ -264,7 +264,10 @@ Foam::List::List(const BiIndirectList& lst) template Foam::List::~List() { - if (this->v_) delete[] this->v_; + if (this->v_) + { + delete[] this->v_; + } } @@ -275,7 +278,7 @@ void Foam::List::setSize(const label newSize) { if (newSize < 0) { - FatalErrorIn("List::setSize(const label)") + FatalErrorInFunction << "bad set size " << newSize << abort(FatalError); } @@ -303,8 +306,8 @@ void Foam::List::setSize(const label newSize) while (i--) *--av = *--vv; } } - if (this->v_) delete[] this->v_; + clear(); this->size_ = newSize; this->v_ = nv; } @@ -331,21 +334,12 @@ void Foam::List::setSize(const label newSize, const T& a) } -template -void Foam::List::clear() -{ - if (this->v_) delete[] this->v_; - this->size_ = 0; - this->v_ = 0; -} - - // Transfer the contents of the argument List into this List // and anull the argument list template void Foam::List::transfer(List& a) { - if (this->v_) delete[] this->v_; + clear(); this->size_ = a.size_; this->v_ = a.v_; @@ -384,13 +378,7 @@ void Foam::List::transfer(SortableList& a) template void Foam::List::operator=(const UList& a) { - if (a.size_ != this->size_) - { - if (this->v_) delete[] this->v_; - this->v_ = 0; - this->size_ = a.size_; - if (this->size_) this->v_ = new T[this->size_]; - } + reAlloc(a.size_); if (this->size_) { @@ -418,7 +406,7 @@ void Foam::List::operator=(const List& a) { if (this == &a) { - FatalErrorIn("List::operator=(const List&)") + FatalErrorInFunction << "attempted assignment to self" << abort(FatalError); } @@ -431,13 +419,7 @@ void Foam::List::operator=(const List& a) template void Foam::List::operator=(const SLList& lst) { - if (lst.size() != this->size_) - { - if (this->v_) delete[] this->v_; - this->v_ = 0; - this->size_ = lst.size(); - if (this->size_) this->v_ = new T[this->size_]; - } + reAlloc(lst.size()); if (this->size_) { @@ -459,18 +441,8 @@ void Foam::List::operator=(const SLList& lst) template void Foam::List::operator=(const IndirectList& lst) { - if (lst.size() != this->size_) - { - if (this->v_) delete[] this->v_; - this->v_ = 0; - this->size_ = lst.size(); - if (this->size_) this->v_ = new T[this->size_]; - } - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + reAlloc(lst.size()); + copyList(lst); } @@ -478,18 +450,8 @@ void Foam::List::operator=(const IndirectList& lst) template void Foam::List::operator=(const UIndirectList& lst) { - if (lst.size() != this->size_) - { - if (this->v_) delete[] this->v_; - this->v_ = 0; - this->size_ = lst.size(); - if (this->size_) this->v_ = new T[this->size_]; - } - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + reAlloc(lst.size()); + copyList(lst); } @@ -497,18 +459,8 @@ void Foam::List::operator=(const UIndirectList& lst) template void Foam::List::operator=(const BiIndirectList& lst) { - if (lst.size() != this->size_) - { - if (this->v_) delete[] this->v_; - this->v_ = 0; - this->size_ = lst.size(); - if (this->size_) this->v_ = new T[this->size_]; - } - - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + reAlloc(lst.size()); + copyList(lst); } // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * // diff --git a/src/foam/containers/Lists/List/List.H b/src/foam/containers/Lists/List/List.H index 2a37e5c35..67ba73ff7 100644 --- a/src/foam/containers/Lists/List/List.H +++ b/src/foam/containers/Lists/List/List.H @@ -205,8 +205,8 @@ public: //- Reset size of List and value for new elements. void setSize(const label, const T&); - //- Clear the list, i.e. set size to zero. - void clear(); + //- Clear the list, i.e. set size to zero + inline void clear(); //- Append an element at the end of the list inline void append(const T&); diff --git a/src/foam/containers/Lists/List/ListI.H b/src/foam/containers/Lists/List/ListI.H index 05bacc9d0..c4d827bcf 100644 --- a/src/foam/containers/Lists/List/ListI.H +++ b/src/foam/containers/Lists/List/ListI.H @@ -91,8 +91,7 @@ inline Foam::List::List InputIterator iter = first; forAll(*this, i) { - this->operator[](i) = *iter; - ++iter; + this->operator[](i) = *iter++; } } } @@ -121,6 +120,19 @@ inline const Foam::List& Foam::List::null() } +template +inline void Foam::List::clear() +{ + if (this->v_) + { + delete[] this->v_; + this->v_ = 0; + } + + this->size_ = 0; +} + + template inline void Foam::List::resize(const label newSize) { From 6a68bc39c72e512efdfd075fb7d877446d79b9ec Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Thu, 11 Jul 2019 16:45:54 -0400 Subject: [PATCH 07/12] foamToTecplot360: adjusting the compilation under macOS 10.14.5 (64 bits). The compilation constant MAC64 is necessary for the proper definition of integer types like UInt64_t, UInt32_t, and ArbParam_t --- .../foamToTecplot360/tecio/tecsrc/Make/tecioOptions | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions index b4ca99aef..8f5db43bf 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions @@ -2,10 +2,14 @@ TECIO_FLAGS = -DMAKEARCHIVE -DLINUX -DLINUX64 -DUSEENUM -DTHREED -U_WIN32 -DENGINE -#elif defined(darwinIntel) || defined(darwinIntel64) || defined(darwinPpc) || defined(darwinPpc64) +#elif defined(darwinIntel) || defined(darwinPpc) TECIO_FLAGS = -DMAKEARCHIVE -DDARWIN -DUSEENUM -DTHREED -U_WIN32 -DENGINE +#elif defined(darwinIntel64) || defined(darwinPpc64) + + TECIO_FLAGS = -DMAKEARCHIVE -DDARWIN -DUSEENUM -DTHREED -U_WIN32 -DENGINE -DMAC64 + #elif defined(linuxIA64) TECIO_FLAGS = -DMAKEARCHIVE -DLINUX -DLINUXI64 -DUSEENUM -DTHREED -U_WIN32 -DENGINE From fd0e75b82247cda60f086b04c34d90d793e35a6f Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Thu, 11 Jul 2019 17:00:12 -0400 Subject: [PATCH 08/12] ThirdParty: libccmio. Usual adjustments when moving to a newer version of macOS/OSX. In this case, macOS 10.14.5 (darwin18) --- ThirdParty/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 | 8 ++++++-- ThirdParty/rpmBuild/SPECS/libccmio-2.6.1.spec | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ThirdParty/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 b/ThirdParty/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 index 49c212c0c..7a6032342 100644 --- a/ThirdParty/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 +++ b/ThirdParty/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 @@ -7,7 +7,7 @@ diff -ruN libccmio-2.6.1_orig/config/config.gnu.to.star libccmio-2.6.1/config/co # $Id: config.gnu.to.star,v 1.4 2006/06/05 21:12:16 geoffp Exp $ -@@ -34,6 +34,14 @@ +@@ -34,6 +34,15 @@ x86_64-unknown-linux-gnu-null) echo linux64_2.4-x86-glibc_2.2.5 ;; ppc64-unknown-linux-gnu-null) echo linux64_2.6-pwr4-glibc_2.3.3 ;; i386-apple-darwin8-null) echo i386-apple-darwin8 ;; @@ -19,6 +19,7 @@ diff -ruN libccmio-2.6.1_orig/config/config.gnu.to.star libccmio-2.6.1/config/co + i386-apple-darwin15-null) echo i386-apple-darwin15 ;; + i386-apple-darwin16-null) echo i386-apple-darwin16 ;; + i386-apple-darwin17-null) echo i386-apple-darwin17 ;; ++ i386-apple-darwin18-null) echo i386-apple-darwin18 ;; *) echo unknown ;; esac @@ -40,7 +41,7 @@ diff -ruN libccmio-2.6.1_orig/config/config.system libccmio-2.6.1/config/config. # $Id: config.system,v 1.2 2005/09/29 22:19:19 geoffp Exp $ -@@ -87,6 +87,33 @@ +@@ -87,6 +87,36 @@ i386-apple-darwin8.11.1) echo i386-apple-darwin8 ;; @@ -70,6 +71,9 @@ diff -ruN libccmio-2.6.1_orig/config/config.system libccmio-2.6.1/config/config. + + i386-apple-darwin17.* ) + echo i386-apple-darwin17 ;; ++ ++ i386-apple-darwin18.* ) ++ echo i386-apple-darwin18 ;; + *) echo unknown diff --git a/ThirdParty/rpmBuild/SPECS/libccmio-2.6.1.spec b/ThirdParty/rpmBuild/SPECS/libccmio-2.6.1.spec index 53806ea6c..59249c4c3 100644 --- a/ThirdParty/rpmBuild/SPECS/libccmio-2.6.1.spec +++ b/ThirdParty/rpmBuild/SPECS/libccmio-2.6.1.spec @@ -107,6 +107,7 @@ Patch0: libccmio-2.6.1.patch_0 [ ! -d config/i386-apple-darwin15 ] && cp -r config/i386-apple-darwin8 config/i386-apple-darwin15 [ ! -d config/i386-apple-darwin16 ] && cp -r config/i386-apple-darwin8 config/i386-apple-darwin16 [ ! -d config/i386-apple-darwin17 ] && cp -r config/i386-apple-darwin8 config/i386-apple-darwin17 + [ ! -d config/i386-apple-darwin18 ] && cp -r config/i386-apple-darwin8 config/i386-apple-darwin18 %endif # Warning: # 1: The name of the ADF library will be renamed to libadf_ccmio since this From e9bcc973550937a1dea3eb3d3133b12b5c086fd4 Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Thu, 11 Jul 2019 17:05:45 -0400 Subject: [PATCH 09/12] ThirdParty: minor adjustments under macOS 10.14.5 for the compilation of ParMGridGen-1.0 and metis-5.1.0. The environment variable $CC has to be written between double-quotes when using it as a make command-line parameter for CC. --- ThirdParty/rpmBuild/SPECS/ParMGridGen-1.0.spec | 2 +- ThirdParty/rpmBuild/SPECS/metis-5.1.0.spec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ThirdParty/rpmBuild/SPECS/ParMGridGen-1.0.spec b/ThirdParty/rpmBuild/SPECS/ParMGridGen-1.0.spec index d52fc4073..3d378cac5 100644 --- a/ThirdParty/rpmBuild/SPECS/ParMGridGen-1.0.spec +++ b/ThirdParty/rpmBuild/SPECS/ParMGridGen-1.0.spec @@ -106,7 +106,7 @@ fi [ -n "$WM_LDFLAGS" ] && export LDFLAGS="$WM_LDFLAGS" [ -z "$WM_NCOMPPROCS" ] && WM_NCOMPPROCS=1 - make -j $WM_NCOMPPROCS CC=$CC + make -j $WM_NCOMPPROCS CC="$WM_CC" %install # Manual installation diff --git a/ThirdParty/rpmBuild/SPECS/metis-5.1.0.spec b/ThirdParty/rpmBuild/SPECS/metis-5.1.0.spec index f115d27ba..88ee4c8ca 100644 --- a/ThirdParty/rpmBuild/SPECS/metis-5.1.0.spec +++ b/ThirdParty/rpmBuild/SPECS/metis-5.1.0.spec @@ -109,10 +109,10 @@ fi %ifos darwin make config # The parameter -D_POSIX_C_SOURCE=200809 has a side effect on Mac OS X - make -j $WM_NCOMPPROCS OPTFLAGS="-O3 -fPIC" CC=$CC + make -j $WM_NCOMPPROCS OPTFLAGS="-O3 -fPIC" CC="$CC" %else make config - make -j $WM_NCOMPPROCS OPTFLAGS="-O3 -fPIC -D_POSIX_C_SOURCE=200809" CC=$CC + make -j $WM_NCOMPPROCS OPTFLAGS="-O3 -fPIC -D_POSIX_C_SOURCE=200809" CC="$CC" %endif %install From a2496c13886f289f687caa6bd6a782cbde59f757 Mon Sep 17 00:00:00 2001 From: Martin Beaudoin Date: Mon, 15 Jul 2019 23:13:43 -0400 Subject: [PATCH 10/12] Bugfix for the testHarness runFunctions: When using the '-l' option for the runApplicationAndReportOnError macro in the tutorials Allrun files, the default log filename will be overriden. In case of a runtime error for a testHarness test, we need to dump the last 50 lines from this filename instead of using the default log filename. --- testHarness/foam-extend/4.1/scripts/AdditionalRunFunctions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testHarness/foam-extend/4.1/scripts/AdditionalRunFunctions b/testHarness/foam-extend/4.1/scripts/AdditionalRunFunctions index 9ec85855a..f2c2331e1 100644 --- a/testHarness/foam-extend/4.1/scripts/AdditionalRunFunctions +++ b/testHarness/foam-extend/4.1/scripts/AdditionalRunFunctions @@ -36,10 +36,10 @@ verbose_report_on_runApplication_error() if [ "$reportOnErrorOnlyOnce" ] ; then echo " " echo " => Error running $APP_RUN..." - echo " => Here are the last 50 lines of the log file log.$APP_RUN..." + echo " => Here are the last 50 lines of the log file $LOG_NAME..." echo " " - if [ -f log.$APP_RUN ] ; then - tail -50 log.$APP_RUN + if [ -f $LOG_NAME ] ; then + tail -50 $LOG_NAME exit $ecode; fi fi From c762381f90887967b6d1eb3b1354fde453f97525 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Thu, 18 Jul 2019 15:23:59 +0200 Subject: [PATCH 11/12] Bugfix in solutionControl I made a mistake previously: in attempting to make the BC's fully consistent, I completely messed up the faceU field which is needed for all transient moving mesh simulations. --- .../solutionControl/solutionControl.C | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C index e0c332096..57dc90f7e 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C @@ -1019,18 +1019,11 @@ void Foam::solutionControl::reconstructTransientVelocity const volScalarField& p ) const { - // If the mesh is moving, flux needs to be relative before boundary - // conditions for velocity are corrected. VV and IG, 4/Jan/2016. - fvc::makeRelative(phi, U); - // Reconstruct the velocity using all the components from original equation U = 1.0/(1.0/rAU + ddtUEqn.A())* ( U/rAU + ddtUEqn.H() - fvc::grad(p) ); - - // Correct boundary conditions with relative flux - U.correctBoundaryConditions(); // Get name and the corresponding index const word& UName = U.name(); @@ -1074,6 +1067,13 @@ void Foam::solutionControl::reconstructTransientVelocity // Now that the normal component is zero, add the normal component from // conservative flux faceU += phi*rSf; + + // If the mesh is moving, flux needs to be relative before boundary + // conditions for velocity are corrected. VV and IG, 4/Jan/2016. + fvc::makeRelative(phi, U); + + // Correct boundary conditions with relative flux + U.correctBoundaryConditions(); } From 0ed5f51ce264555da5bf10a00a58524333c52ce1 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 18 Jul 2019 16:55:48 +0100 Subject: [PATCH 12/12] Reading heat transfer coefficients in a porous zone is optional --- .../cfdTools/general/porousMedia/porousZone.C | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C index b6df454f7..17210bf51 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C +++ b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.C @@ -221,17 +221,6 @@ Foam::porousZone::porousZone " ,nCellsAuxInlet = " << nCellsAuxInlet_ << " ,Qepsilon = " << Qepsilon_ << nl; } - else - { - FatalIOErrorIn - ( - "Foam::porousZone::porousZone" - "(const fvMesh&, const word&, const dictionary&)", - dict_ - ) << "\"heatTransfer\" dictionary not specified" - << exit(FatalIOError); - } - }