Skip to content
Commits on Source (2)
  • Mark OLESEN's avatar
    COMP: resolve label-size=64 ambiguities for clang · 89e12df4
    Mark OLESEN authored
    * DynList construction with integer parameter:
    
        DynList<T>(int32_t) - eg DynList<T> lst(10)
    
      Candidates are
    
         DynList(const label)
         template<class ListType> DynList(const ListType& lst)
    
      It picks the second as the beter match (error).
    
      Resolve by adding DynList(int32_t) constructor for label-size=64
    
    * Similar problem with copy assignment.
         dyList = -1 (for example) picks
         template<class ListType> operator=(const ListType& lst)
    
      Resolve by replacing general list assignment with assignments for
      DynList, UList, FixedList
    89e12df4
  • Mark OLESEN's avatar
    TUT: update run/clean scripts · 57b9896a
    Mark OLESEN authored
    57b9896a
......@@ -77,7 +77,7 @@ template<class T, Foam::label staticSize = 16>
class DynList
{
// Private data
//
//- pointer to the data
T* dataPtr_;
......@@ -108,6 +108,14 @@ class DynList
//- check if nAllocated_ is greater or equal to nextFree_
inline void checkAllocation() const;
//- Copy construct from almost any other type of list
template<class ListType>
inline void copyConstructList(const ListType& lst);
//- Copy assign from almost any other type of list
template<class ListType>
inline void copyAssignList(const ListType& lst);
public:
......@@ -117,7 +125,15 @@ public:
inline DynList();
//- Construct given size
explicit inline DynList(const label);
explicit inline DynList(const label nElem);
//- Construct given integer size
#if WM_LABEL_SIZE == 64
explicit inline DynList(const int32_t nElem)
:
DynList(label(nElem))
{}
#endif
//- Construct from given size and defualt value
explicit inline DynList(const label, const T&);
......@@ -212,14 +228,18 @@ public:
inline const T& rcValue(const label index) const;
//- Assignment of all entries to the given value
inline void operator=(const T&);
inline void operator=(const T& val);
//- Copy of another list
inline void operator=(const DynList<T, staticSize>&);
template<label AnySize>
inline void operator=(const DynList<T, AnySize>&);
//- Copy of another list type
template<class ListType>
inline void operator=(const ListType&);
//- Copy of another list
inline void operator=(const UList<T>& lst);
//- Copy of another list
template<unsigned FixedSize>
inline void operator=(const FixedList<T, FixedSize>& lst);
//- Compare the list with the another one
inline bool operator==(const DynList<T, staticSize>&) const;
......
......@@ -124,6 +124,50 @@ inline void Foam::Module::DynList<T, staticSize>::checkAllocation() const
}
template<class T, Foam::label staticSize>
template<class ListType>
inline void Foam::Module::DynList<T, staticSize>::copyConstructList
(
const ListType& lst
)
{
setSize(lst.size());
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = lst[i];
}
# ifdef DEBUG
checkAllocation();
# endif
}
template<class T, Foam::label staticSize>
template<class ListType>
inline void Foam::Module::DynList<T, staticSize>::copyAssignList
(
const ListType& lst
)
{
# ifdef DEBUG
checkAllocation();
# endif
allocateSize(lst.size());
nextFree_ = lst.size();
# ifdef DEBUG
checkAllocation();
# endif
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = lst[i];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, Foam::label staticSize>
......@@ -135,35 +179,25 @@ inline Foam::Module::DynList<T, staticSize>::DynList()
nextFree_(0)
{
setSize(0);
# ifdef DEBUG
checkAllocation();
# endif
}
template<class T, Foam::label staticSize>
inline Foam::Module::DynList<T, staticSize>::DynList(const label s)
inline Foam::Module::DynList<T, staticSize>::DynList(const label nElem)
:
dataPtr_(nullptr),
nAllocated_(0),
staticData_(),
nextFree_(0)
{
setSize(s);
# ifdef DEBUG
checkAllocation();
# endif
setSize(nElem);
}
template<class T, Foam::label staticSize>
inline Foam::Module::DynList<T, staticSize>::DynList
(
const label s,
const label nElem,
const T& val
)
:
......@@ -172,65 +206,44 @@ inline Foam::Module::DynList<T, staticSize>::DynList
staticData_(),
nextFree_(0)
{
setSize(s);
setSize(nElem);
for (label i = 0; i < s; ++i)
for (label i = 0; i < nElem; ++i)
{
this->operator[](i) = val;
}
# ifdef DEBUG
checkAllocation();
# endif
}
template<class T, Foam::label staticSize>
inline Foam::Module::DynList<T, staticSize>::DynList(const UList<T>& ul)
inline Foam::Module::DynList<T, staticSize>::DynList(const UList<T>& lst)
:
dataPtr_(nullptr),
nAllocated_(0),
staticData_(),
nextFree_(0)
{
setSize(ul.size());
forAll(ul, i)
{
this->operator[](i) = ul[i];
}
# ifdef DEBUG
checkAllocation();
# endif
copyConstructList(lst);
}
template<class T, Foam::label staticSize>
template<class ListType>
inline Foam::Module::DynList<T, staticSize>::DynList(const ListType& l)
inline Foam::Module::DynList<T, staticSize>::DynList(const ListType& lst)
:
dataPtr_(nullptr),
nAllocated_(0),
staticData_(),
nextFree_(0)
{
setSize(l.size());
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = l[i];
}
# ifdef DEBUG
checkAllocation();
# endif
copyConstructList(lst);
}
template<class T, Foam::label staticSize>
inline Foam::Module::DynList<T, staticSize>::DynList
(
const DynList<T, staticSize>& dl
const DynList<T, staticSize>& lst
)
:
dataPtr_(nullptr),
......@@ -238,15 +251,7 @@ inline Foam::Module::DynList<T, staticSize>::DynList
staticData_(),
nextFree_(0)
{
setSize(dl.size());
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = dl[i];
}
# ifdef DEBUG
checkAllocation();
# endif
copyConstructList(lst);
}
......@@ -583,48 +588,34 @@ inline void Foam::Module::DynList<T, staticSize>::operator=(const T& t)
template<class T, Foam::label staticSize>
template<Foam::label AnySize>
inline void Foam::Module::DynList<T, staticSize>::operator=
(
const DynList<T, staticSize>& dl
const DynList<T, AnySize>& lst
)
{
# ifdef DEBUG
checkAllocation();
# endif
allocateSize(dl.size());
nextFree_ = dl.size();
# ifdef DEBUG
checkAllocation();
# endif
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = dl[i];
}
copyAssignList(lst);
}
template<class T, Foam::label staticSize>
template<class ListType>
inline void Foam::Module::DynList<T, staticSize>::operator=(const ListType& l)
inline void Foam::Module::DynList<T, staticSize>::operator=
(
const UList<T>& lst
)
{
# ifdef DEBUG
checkAllocation();
# endif
allocateSize(l.size());
nextFree_ = l.size();
copyAssignList(lst);
}
# ifdef DEBUG
checkAllocation();
# endif
for (label i = 0; i < nextFree_; ++i)
{
this->operator[](i) = l[i];
}
template<class T, Foam::label staticSize>
template<unsigned FixedSize>
inline void Foam::Module::DynList<T, staticSize>::operator=
(
const FixedList<T, FixedSize>& lst
)
{
copyAssignList(lst);
}
......
......@@ -121,7 +121,7 @@ void Foam::Module::meshOctree::setOctantVectorsAndPositions()
// set vrtLeavesPos_
for (label vrtI = 0; vrtI < 8; ++vrtI)
{
FixedList<label, 3> vc(0);
FixedList<label, 3> vc(Zero);
if (vrtI & 1)
{
......@@ -142,7 +142,7 @@ void Foam::Module::meshOctree::setOctantVectorsAndPositions()
for (label i = 0; i < 8; ++i)
{
FixedList<label, 3> pos;
FixedList<label, 3> pos(Zero);
for (label j = 0; j < 3; ++j)
{
......
......@@ -136,7 +136,7 @@ void Foam::Module::meshOctreeAutomaticRefinement::setMaxRefLevel()
{
finished = false;
const scalar lSize = size/pow(2, label(maxRefLevel_));
const scalar lSize = size/pow(label(2), label(maxRefLevel_));
if (lSize < cs)
{
......
......@@ -81,12 +81,12 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
finished = false;
const scalar lSize = size/Foam::pow(2, label(globalRefLevel_));
const scalar lSize = size/Foam::pow(label(2), label(globalRefLevel_));
if (lSize <(maxSize*(1.0 - SMALL)))
{
const scalar bbSize =
0.5*maxSize*Foam::pow(2, label(globalRefLevel_));
0.5*maxSize*Foam::pow(label(2), label(globalRefLevel_));
rootBox.max() = c + point(bbSize, bbSize, bbSize);
rootBox.min() = c - point(bbSize, bbSize, bbSize);
finished = true;
......@@ -132,7 +132,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
finished = false;
const scalar lSize = maxSize/Foam::pow(2, addLevel);
const scalar lSize = maxSize/Foam::pow(label(2), addLevel);
if (lSize <= cs)
{
......@@ -237,7 +237,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
finished = false;
const scalar lSize = maxSize/Foam::pow(2, addLevel);
const scalar lSize = maxSize/Foam::pow(label(2), addLevel);
if (lSize <= cs)
{
......@@ -321,7 +321,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
finished = false;
const scalar lSize = maxSize/Foam::pow(2, addLevel);
const scalar lSize = maxSize/Foam::pow(label(2), addLevel);
if (lSize <= cs)
{
......@@ -405,7 +405,8 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters()
{
finished = false;
const scalar lSize = maxSize/Foam::pow(2, nLevel);
const scalar lSize =
maxSize/Foam::pow(label(2), nLevel);
if (lSize <= cs)
{
......
......@@ -96,7 +96,7 @@ Foam::Module::meshOctreeCubeCoordinates::refineForPosition
) const
{
//- create new boxes in z-order fashion
FixedList<label, 3> addPos(0);
FixedList<label, 3> addPos(Zero);
if (i & 1)
{
addPos[0] = 1;
......
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions
echo "--------"
echo "Cleaning tutorials ..."
echo "Removing backup files"
find . \( \
-name '*~' -o -name '*.bak' \
-name core -o -name 'core.[1-9]*' \
-name '*.pvs' -o -name '*.OpenFOAM' -name '*.foam' \
\) -type f -delete
rm -f logs testLoopReport > /dev/null 2>&1
removeLogs
echo "Cleaning tutorials"
foamCleanTutorials cases
echo "--------"
......
......@@ -3,30 +3,18 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 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 <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# Allrun
#
# Description
# Runs tutorial cases and summarizes the outcome as 'testLoopReport'
# Run tutorial cases and summarize the outcome as 'testLoopReport'
#
#------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # Run from this directory
......@@ -43,17 +31,16 @@ options:
-collect Collect logs only. Can be useful for aborted runs.
-help print the usage
* Runs tutorial cases and summarizes the outcome as 'testLoopReport'
Run tutorial cases and summarize the outcome as 'testLoopReport'
USAGE
exit 1
}
#------------------------------------------------------------------------------
unset optCollectOnly
# parse options
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
......@@ -76,88 +63,15 @@ do
shift
done
#------------------------------------------------------------------------------
# logReport <logfile>
# Extracts useful info from log file.
logReport()
{
local logfile=$1
# logfile is path/to/case/log.application
caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g')
app=$(echo $logfile | sed -e 's/\(.*\)log\.//g')
appAndCase="Application $app - case $caseName"
if grep -q "FOAM FATAL" $logfile
then
echo "$appAndCase: ** FOAM FATAL ERROR **"
return 1
fi
# Check for solution singularity on U equation
for eqn in Ux Uy Uz
do
if grep -q -E "${eqn}[:| ]*solution singularity" $logfile
then
if [ "$eqn" = Uz ]
then
# Can only get here if Ux,Uy,Uz all failed
echo "$appAndCase: ** Solution singularity **"
return 1
fi
else
break
fi
done
if grep -q -E "^[\t ]*[Ee]nd" $logfile
then
# Extract time from this type of content
## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s"
completionTime=$(tail -10 $logfile | \
sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}')
echo "$appAndCase: completed${completionTime:+ in }$completionTime"
else
echo "$appAndCase: unconfirmed completion"
fi
}
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions
if [ -z "$optCollectOnly" ]
then
# Recursively run all tutorials
foamRunTutorials -skipFirst $*
foamRunTutorials -skipFirst $* # Run tutorials recursively
fi
# Analyse all log files
echo "Collecting log files..." 1>&2
rm -f logs testLoopReport > /dev/null 2>&1
touch logs testLoopReport
for appDir in *
do
[ -d $appDir ] || continue
echo -n " $appDir..." 1>&2
logs=$(find -L $appDir -name 'log.*' -type f)
if [ -n "$logs" ]
then
echo 1>&2
else
echo " (no logs)" 1>&2
continue
fi
# Sort logs by time-stamp
for log in $(echo $logs | xargs ls -rt)
do
# Concatenate and summarize logs
cat "$log" >> logs 2>/dev/null
logReport $log
done
echo
done > testLoopReport
collectLogs
#------------------------------------------------------------------------------