Minimum changes to compile everything with gcc-4.3.0
This commit is contained in:
parent
4a2a23a710
commit
f6107f4033
110
bin/foamPackChanged
Executable file
110
bin/foamPackChanged
Executable file
@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# Script
|
||||
# foamPackChanged <directory> <tarFile>
|
||||
#
|
||||
# Description
|
||||
# Packs and compresses files that have a corresponding .orig file
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
tmpFile=${TMPDIR:-/tmp}/foamPackChanged.$$
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage : ${0##*/} directory tarFile"
|
||||
echo ""
|
||||
echo "Packs and compresses files that have a corresponding .orig file"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# canonical form (no double and no trailing dashes)
|
||||
packDir=$(echo "$1" | sed -e 's@//*@/@g' -e 's@/$@@')
|
||||
packFile=$2
|
||||
|
||||
if [ ! -d $packDir ]; then
|
||||
echo "Error: directory $packDir does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up on termination and on Ctrl-C
|
||||
trap 'rm -f $tmpFile 2>/dev/null; exit 0' EXIT TERM INT
|
||||
|
||||
fileCount=0
|
||||
cat /dev/null > $tmpFile
|
||||
|
||||
find -H $packDir \
|
||||
! -type d \
|
||||
-type f \
|
||||
-name "*.orig" \
|
||||
| sed \
|
||||
-e "\@$packDir/lib/@d" \
|
||||
-e "\@$packDir/src/other/mico-*/platforms@d" \
|
||||
-e "\@$packDir/src/other/mpich-*/platforms@d" \
|
||||
-e "\@$packDir/src/other/mpich-*/lib@d" \
|
||||
-e "\@$packDir/src/other/lam-*/platforms@d" \
|
||||
-e "\@$packDir/src/other/openmpi-*/platforms@d" \
|
||||
-e '\@applications/bin/@d' \
|
||||
-e '\@/t/@d' \
|
||||
-e '\@Make[.A-Za-z]*/[^/]*/@d' \
|
||||
-e '\@[Dd]oxygen/html@d' \
|
||||
-e '\@[Dd]oxygen/latex@d' \
|
||||
-e '\@[Dd]oxygen/man@d' \
|
||||
-e "s@$packDir/*@@" \
|
||||
| \
|
||||
(
|
||||
while read file
|
||||
do
|
||||
(( fileCount=$fileCount + 1 ))
|
||||
|
||||
file=${file%%.orig}
|
||||
|
||||
if [ -f "$packDir/$file" ]
|
||||
then
|
||||
echo $fileCount $file
|
||||
echo $packDir/$file >> $tmpFile
|
||||
else
|
||||
echo "[MISSING]" $file
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
# file fileCount
|
||||
fileCount=$(cat $tmpFile | wc -l)
|
||||
echo "----------------------------------------------------------------------"
|
||||
echo "pack $fileCount updated (non-.orig) files"
|
||||
|
||||
tar -czpf $packFile --files-from $tmpFile
|
||||
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
echo "Finished packing changed files from $packDir into $packFile"
|
||||
else
|
||||
echo "Error: failure packing changed files from $packDir into $packFile"
|
||||
rm -f $packFile 2>/dev/null
|
||||
fi
|
||||
echo "----------------------------------------------------------------------"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
12
bin/paraFoam.pvs
Normal file
12
bin/paraFoam.pvs
Normal file
@ -0,0 +1,12 @@
|
||||
# ParaView State Version 2.2
|
||||
|
||||
set kw(vtkTemp2) [$Application GetMainWindow]
|
||||
set kw(vtkTemp29) [$kw(vtkTemp2) GetMainView]
|
||||
set kw(vtkTemp980) [$kw(vtkTemp2) GetAnimationManager]
|
||||
[$kw(vtkTemp2) GetRotateCameraButton] SetState 1
|
||||
$kw(vtkTemp2) ChangeInteractorStyle 1
|
||||
set kw(vtkTemp840) [$kw(vtkTemp2) InitializeReadCustom "FoamReader" "%CASE%"]
|
||||
$kw(vtkTemp2) ReadFileInformation $kw(vtkTemp840) "%CASE%"
|
||||
$kw(vtkTemp2) FinalizeRead $kw(vtkTemp840) "%CASE%"
|
||||
set kw(vtkTemp868) [$kw(vtkTemp840) GetPVWidget {Filename}]
|
||||
$kw(vtkTemp868) SetValue "%CASE%"
|
2
bin/tools/README
Normal file
2
bin/tools/README
Normal file
@ -0,0 +1,2 @@
|
||||
Misc. tools for building applications, etc that are useful to have
|
||||
but which don't really need to be in the PATH.
|
193
bin/tools/buildParaView3.3
Executable file
193
bin/tools/buildParaView3.3
Executable file
@ -0,0 +1,193 @@
|
||||
#!/bin/sh
|
||||
set -x
|
||||
|
||||
# ParaView 3.x build script
|
||||
# - normally run from folder above source folder
|
||||
|
||||
# use the version number and the installation location specified
|
||||
# in etc/apps/paraview3/{bashrc,cshrc}
|
||||
: ${ParaView_VERSION:=3.3}
|
||||
: ${ParaView_INST_DIR:=$WM_PROJECT_INST_DIR/paraview-$ParaView_VERSION}
|
||||
|
||||
#!!User:
|
||||
# set to location of paraview sources and where to build paraview
|
||||
# PARAVIEW_SRC_DIR=$WM_PROJECT_INST_DIR/src/other/ParaView3
|
||||
PARAVIEW_SRC_DIR=/data/cfd2/work/cfdadmin/cvs/ParaView3
|
||||
PARAVIEW_BUILD_DIR=$PARAVIEW_SRC_DIR/platforms
|
||||
|
||||
# TODO: extract the version number from the CMakeLists.txt variables:
|
||||
# PARAVIEW_VERSION_MAJOR, and PARAVIEW_VERSION_MINOR
|
||||
# ParaView_VERSION="3.3"
|
||||
|
||||
# SET(PARAVIEW_VERSION_MAJOR 3)
|
||||
# SET(PARAVIEW_VERSION_MINOR 3)
|
||||
|
||||
#!!User:
|
||||
# select desired features, include Python whenever possible
|
||||
VERBOSE=OFF
|
||||
INCLUDE_MPI=OFF
|
||||
MPI_MAX_PROCS=32
|
||||
INCLUDE_PYTHON=ON
|
||||
INCLUDE_MESA=OFF
|
||||
|
||||
# initialisation
|
||||
oldpwd=$PWD
|
||||
unset OBJ_ADD
|
||||
|
||||
# always build shared libraries
|
||||
CMAKE_VARIABLES="-DBUILD_SHARED_LIBS:BOOL=ON"
|
||||
|
||||
if [ "$VERBOSE" = ON ]; then
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DCMAKE_VERBOSE_MAKEFILE=TRUE"
|
||||
fi
|
||||
|
||||
#****************************************************************************
|
||||
# FIX: Attempt to get around seg-fault when building documentation
|
||||
#CMAKE_VARIABLES="$CMAKE_VARIABLES -BUILD_DOCUMENTATION-ADVANCED:INTERNAL=0"
|
||||
#****************************************************************************
|
||||
|
||||
# set python specific options
|
||||
# NOTE - you'll need both python and python-devel packages installed
|
||||
# - might need to create a symbolic link to the python library
|
||||
# - anything after the '.so' gets in the way...
|
||||
# - might need to run cmake -> make twice to pick up all the links...
|
||||
if [ "$INCLUDE_PYTHON" = ON ]; then
|
||||
PYTHON_INCLUDE_DIR=/usr/include/python2.5
|
||||
PYTHON_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libpython2.5.so
|
||||
|
||||
if [ -d "$PYTHON_INCLUDE_DIR" ]; then
|
||||
OBJ_ADD="$OBJ_ADD-py"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DPARAVIEW_ENABLE_PYTHON=ON"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DPYTHON_INCLUDE_PATH=$PYTHON_INCLUDE_DIR"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DPYTHON_LIBRARY=$PYTHON_LIBRARY"
|
||||
else
|
||||
echo "non-existent PYTHON_INCLUDE_DIR: $PYTHON_INCLUDE_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# set MPI specific options
|
||||
if [ "$INCLUDE_MPI" = ON ]; then
|
||||
case "$WM_MPLIB" in
|
||||
OPENMPI)
|
||||
MPI_INCLUDE_PATH=$OPENMPI_ARCH_PATH/include
|
||||
MPI_LIBRARY=$OPENMPI_ARCH_PATH/lib/libmpi.so
|
||||
MPI_RUN=$OPENMPI_ARCH_PATH/bin/mpirun
|
||||
;;
|
||||
LAM)
|
||||
MPI_INCLUDE_PATH=$LAM_ARCH_PATH/include
|
||||
MPI_LIBRARY=$LAM_ARCH_PATH/lib/libmpi.so
|
||||
MPI_RUN=$LAM_ARCH_PATH/bin/mpirun
|
||||
;;
|
||||
MPICH)
|
||||
MPI_INCLUDE_PATH=$MPICH_ARCH_PATH/include
|
||||
MPI_LIBRARY=$MPICH_ARCH_PATH/lib/libmpich.so
|
||||
MPI_RUN=$MPICH_ARCH_PATH/bin/mpirun
|
||||
;;
|
||||
*)
|
||||
unset INCLUDE_MPI
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$INCLUDE_MPI" ]; then
|
||||
OBJ_ADD="$OBJ_ADD-mpi"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DVTK_USE_MPI=ON"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DPARAVIEW_USE_MPI=ON"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DMPI_INCLUDE_PATH=$MPI_INCLUDE_PATH"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DMPI_LIBRARY=$MPI_LIBRARY"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DVTK_MPIRUN_EXE=$MPI_RUN"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DVTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
|
||||
else
|
||||
echo "unknown/unsupported mpi: $WM_MPLIB"
|
||||
fi
|
||||
fi
|
||||
|
||||
# set MESA specific options
|
||||
if [ "$INCLUDE_MESA" = ON ]; then
|
||||
MESA_INCLUDE_DIR=/usr/include/GL
|
||||
MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so
|
||||
|
||||
if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]; then
|
||||
OBJ_ADD="$OBJ_ADD-mesa"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DVTK_OPENGL_HAS_OSMESA=ON"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DOSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR"
|
||||
CMAKE_VARIABLES="$CMAKE_VARIABLES -DOSMESA_LIBRARY=$MESA_LIBRARY"
|
||||
else
|
||||
echo "no MESA information found ... skipping"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# finalize the build/install environment
|
||||
PARAVIEW_OBJ_DIR=$PARAVIEW_BUILD_DIR/$WM_OPTIONS$OBJ_ADD
|
||||
PARAVIEW_APP_DIR=$ParaView_INST_DIR/platforms/$WM_OPTIONS$OBJ_ADD
|
||||
|
||||
# create paraview build folder
|
||||
mkdir -p $PARAVIEW_OBJ_DIR
|
||||
cd $PARAVIEW_OBJ_DIR
|
||||
|
||||
#
|
||||
# make paraview
|
||||
#
|
||||
|
||||
# provide a backdoor to skip cmake for repeated builds
|
||||
if [ -z "$build_no_cmake" ]
|
||||
then
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \
|
||||
$CMAKE_VARIABLES \
|
||||
$PARAVIEW_SRC_DIR
|
||||
fi
|
||||
|
||||
|
||||
if [ -r /proc/cpuinfo ]; then
|
||||
WM_NCOMPPROCS=`egrep "^processor" /proc/cpuinfo | wc -l`
|
||||
|
||||
[ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8
|
||||
|
||||
make -j $WM_NCOMPPROCS
|
||||
else
|
||||
make
|
||||
fi
|
||||
|
||||
|
||||
if [ -e "$PARAVIEW_OBJ_DIR/bin/paraview" ]; then
|
||||
echo "Info: Installation completed - proceeding to install"
|
||||
make install
|
||||
|
||||
# copy VTK headers to install directory
|
||||
echo "Info: Copying VTK headers"
|
||||
cp -r $PARAVIEW_SRC_DIR/VTK $PARAVIEW_APP_DIR
|
||||
cp -r $PARAVIEW_OBJ_DIR/VTK/vtkConfigure.h $PARAVIEW_APP_DIR/VTK
|
||||
cp -r $PARAVIEW_OBJ_DIR/VTK/vtkstd $PARAVIEW_APP_DIR/VTK
|
||||
|
||||
# copy all .so files to the lib folder
|
||||
# - NOTE: shouldn't be necessary - but some libs not copied over to the
|
||||
# install folder
|
||||
## echo "Info: Copying libs"
|
||||
## cp $PARAVIEW_OBJ_DIR/bin/*.so* $PARAVIEW_APP_DIR/lib/paraview-$ParaView_VERSION
|
||||
|
||||
echo "Info: Copying ParaViewConfig.cmake"
|
||||
cp $PARAVIEW_OBJ_DIR/ParaViewConfig.cmake $PARAVIEW_APP_DIR
|
||||
|
||||
if [ "$OBJ_ADD" ]; then
|
||||
echo "Creating symbolic link in $ParaView_INST_DIR/platforms from $WM_OPTIONS$OBJ_ADD to $WM_OPTIONS"
|
||||
( cd $ParaView_INST_DIR/platforms && ln -s $WM_OPTIONS$OBJ_ADD $WM_OPTIONS )
|
||||
fi
|
||||
|
||||
echo "Installation complete"
|
||||
echo "Set environment variables:"
|
||||
echo " - ParaView_DIR to $PARAVIEW_APP_DIR"
|
||||
echo " - ParaView_INST_DIR to $PARAVIEW_APP_DIR"
|
||||
echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN"
|
||||
echo "Add $ParaView_INST_DIR/bin to PATH"
|
||||
echo "Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
|
||||
|
||||
echo "done."
|
||||
else
|
||||
echo "*** Error: Installation failed - see output window"
|
||||
fi
|
||||
|
||||
# finalisation
|
||||
cd $oldpwd
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
402
src/OpenFOAM/interpolations/timeSeries/timeSeries.C
Normal file
402
src/OpenFOAM/interpolations/timeSeries/timeSeries.C
Normal file
@ -0,0 +1,402 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeSeries.H"
|
||||
#include "Istream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(const bounds bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(),
|
||||
bounding_(bound)
|
||||
{}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(const word& bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(),
|
||||
bounding_(timeSeries::WARN)
|
||||
{
|
||||
bounding(bound);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(Istream& is, const bounds bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(is),
|
||||
bounding_(bound)
|
||||
{}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(Istream& is, const word& bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(is),
|
||||
bounding_(timeSeries::WARN)
|
||||
{
|
||||
bounding(bound);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::~timeSeries()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::word Foam::timeSeries<T>::bounding() const
|
||||
{
|
||||
word enumName("warn");
|
||||
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
enumName = "error";
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
enumName = "warn";
|
||||
break;
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
enumName = "clamp";
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
enumName = "repeat";
|
||||
break;
|
||||
}
|
||||
|
||||
return enumName;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void Foam::timeSeries<T>::bounding(const word& bound)
|
||||
{
|
||||
if (bound == "error")
|
||||
{
|
||||
bounding_ = timeSeries::ERROR;
|
||||
}
|
||||
else if (bound == "warn")
|
||||
{
|
||||
bounding_ = timeSeries::WARN;
|
||||
}
|
||||
else if (bound == "clamp")
|
||||
{
|
||||
bounding_ = timeSeries::CLAMP;
|
||||
}
|
||||
else if (bound == "repeat")
|
||||
{
|
||||
bounding_ = timeSeries::REPEAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("Foam::timeSeries<T>::boundingEnum(const word&)")
|
||||
<< "bad bounding specifier " << bound << " using 'warn'" << endl;
|
||||
|
||||
bounding_ = timeSeries::WARN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void Foam::timeSeries<T>::check() const
|
||||
{
|
||||
label n = size();
|
||||
scalar prevTime = List<Tuple2<scalar, T> >::operator[](0).first();
|
||||
|
||||
for (label i = 1; i < n; ++i)
|
||||
{
|
||||
const scalar currTime = List<Tuple2<scalar, T> >::operator[](i).first();
|
||||
|
||||
// avoid duplicate times (divide-by-zero error)
|
||||
if (currTime <= prevTime)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::checkOrder() const"
|
||||
) << "out-of-order time: "
|
||||
<< currTime << " at index " << i << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
prevTime = currTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template<typename T>
|
||||
const Foam::Tuple2<Foam::scalar, T>&
|
||||
Foam::timeSeries<T>::operator[](const label i) const
|
||||
{
|
||||
label ii = i;
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
ii = 0;
|
||||
}
|
||||
else if (ii < 0)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
ii = 0;
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
while (ii < 0)
|
||||
{
|
||||
ii += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ii >= n)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
ii = n - 1;
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
while (ii >= n)
|
||||
{
|
||||
ii -= n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return List<Tuple2<scalar, T> >::operator[](ii);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T Foam::timeSeries<T>::operator()(const scalar timeValue) const
|
||||
{
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
return List<Tuple2<scalar, T> >::operator[](0).second();
|
||||
}
|
||||
|
||||
scalar minTime = List<Tuple2<scalar, T> >::operator[](0).first();
|
||||
scalar maxTime = List<Tuple2<scalar, T> >::operator[](n-1).first();
|
||||
scalar lookupTime = timeValue;
|
||||
|
||||
if (lookupTime < minTime)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const scalar) const"
|
||||
) << "time (" << lookupTime << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const scalar) const"
|
||||
) << "time (" << lookupTime << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
return List<Tuple2<scalar, T> >::operator[](0).second();
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
// adjust lookupTime to >= 0
|
||||
while (lookupTime < 0)
|
||||
{
|
||||
lookupTime += maxTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (lookupTime >= maxTime)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "time (" << lookupTime << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "time (" << lookupTime << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
return List<Tuple2<scalar, T> >::operator[](n-1).second();
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
// adjust lookupTime <= maxTime
|
||||
while (lookupTime > maxTime)
|
||||
{
|
||||
lookupTime -= maxTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
label lo = 0;
|
||||
label hi = 0;
|
||||
|
||||
// look for the correct range
|
||||
for (label i = 0; i < n; ++i)
|
||||
{
|
||||
if (lookupTime >= List<Tuple2<scalar, T> >::operator[](i).first())
|
||||
{
|
||||
lo = hi = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lo == hi)
|
||||
{
|
||||
// we are at the end of the table - or there is only a single entry
|
||||
return List<Tuple2<scalar, T> >::operator[](hi).second();
|
||||
}
|
||||
else if (hi == 0)
|
||||
{
|
||||
// this treatment should should only occur under these condition:
|
||||
// -> the 'REPEAT' treatment
|
||||
// -> (0 <= time <= minTime)
|
||||
// -> minTime > 0
|
||||
// Use the value at maxTime as the value for time=0
|
||||
lo = n - 1;
|
||||
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
+
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
)
|
||||
* (lookupTime / minTime)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal interpolation
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
+
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
)
|
||||
*
|
||||
(
|
||||
lookupTime
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).first()
|
||||
)
|
||||
/
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).first()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
162
src/OpenFOAM/interpolations/timeSeries/timeSeries.H
Normal file
162
src/OpenFOAM/interpolations/timeSeries/timeSeries.H
Normal file
@ -0,0 +1,162 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::timeSeries
|
||||
|
||||
Description
|
||||
A list of times and values.
|
||||
The time values must be positive and monotonically increasing.
|
||||
|
||||
The treatment of out-of-bounds values depends on the current setting
|
||||
of bounding.
|
||||
|
||||
If @a REPEAT bounding is in effect, the final time value is treated
|
||||
as being equivalent to time=0 for the following periods.
|
||||
|
||||
Note
|
||||
- Accessing an empty list will result in an error.
|
||||
- Accessing a list with a single element will always return the same value.
|
||||
|
||||
SourceFiles
|
||||
timeSeries.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeSeries_H
|
||||
#define timeSeries_H
|
||||
|
||||
#include "List.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeSeries Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
class timeSeries
|
||||
:
|
||||
public List<Tuple2<scalar, T> >
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for handling out-of-bound times
|
||||
enum bounds
|
||||
{
|
||||
ERROR, /*!< Exit with a FatalError */
|
||||
WARN, /*!< Issue warning and clamp value (default) */
|
||||
CLAMP, /*!< Clamp value to the start/end value */
|
||||
REPEAT /*!< Treat as a repeating list */
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Enumeration for handling out-of-bound times
|
||||
bounds bounding_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, optionally with a given bounding
|
||||
timeSeries(const bounds = timeSeries::WARN);
|
||||
|
||||
//- Construct null with a given bounding
|
||||
timeSeries(const word&);
|
||||
|
||||
//- Construct from Istream, optionally with a given bounding
|
||||
timeSeries(Istream&, const bounds = timeSeries::WARN);
|
||||
|
||||
//- Construct from Istream with a given bounding
|
||||
timeSeries(Istream&, const word&);
|
||||
|
||||
// Destructor
|
||||
|
||||
~timeSeries();
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the size
|
||||
label size() const
|
||||
{
|
||||
return List<Tuple2<scalar, T> >::size();
|
||||
}
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word bounding() const;
|
||||
|
||||
// Check
|
||||
|
||||
//- Check that list is monotonically increasing
|
||||
// Exit with a FatalError if there is a problem
|
||||
void check() const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Set the out-of-bounds treatment from enum, return previous setting
|
||||
bounds bounding(const bounds& bound)
|
||||
{
|
||||
bounds prev = bounding_;
|
||||
bounding_ = bound;
|
||||
return prev;
|
||||
}
|
||||
|
||||
//- Set the out-of-bounds treatment from word
|
||||
void bounding(const word& bound);
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return an element of constant Tuple2<scalar, T>
|
||||
const Tuple2<scalar, T>& operator[](const label) const;
|
||||
|
||||
//- Return an interpolated value
|
||||
T operator()(const scalar) const;
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "timeSeries.C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// ************************************************************************* //
|
3
wmake/rules/linux64Gcc43/X
Normal file
3
wmake/rules/linux64Gcc43/X
Normal file
@ -0,0 +1,3 @@
|
||||
XFLAGS =
|
||||
XINC = $(XFLAGS) -I/usr/X11R6/include
|
||||
XLIBS = -L/usr/X11R6/lib64 -lXext -lX11
|
16
wmake/rules/linux64Gcc43/c
Normal file
16
wmake/rules/linux64Gcc43/c
Normal file
@ -0,0 +1,16 @@
|
||||
.SUFFIXES: .c .h
|
||||
|
||||
cWARN = -Wall
|
||||
|
||||
cc = gcc -m64
|
||||
|
||||
include $(RULES)/c$(WM_COMPILE_OPTION)
|
||||
|
||||
cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $$SOURCE -o $@
|
||||
|
||||
LINK_LIBS = $(cDBUG)
|
||||
|
||||
LINKLIBSO = $(cc) -shared
|
||||
LINKEXE = $(cc) -Xlinker -z -Xlinker nodefs
|
21
wmake/rules/linux64Gcc43/c++
Normal file
21
wmake/rules/linux64Gcc43/c++
Normal file
@ -0,0 +1,21 @@
|
||||
.SUFFIXES: .C .cxx .cc .cpp
|
||||
|
||||
c++WARN = -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast
|
||||
|
||||
CC = g++ -m64
|
||||
|
||||
include $(RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
ptFLAGS = -DNoRepository -ftemplate-depth-40
|
||||
|
||||
c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $$SOURCE -o $@
|
||||
cxxtoo = $(Ctoo)
|
||||
cctoo = $(Ctoo)
|
||||
cpptoo = $(Ctoo)
|
||||
|
||||
LINK_LIBS = $(c++DBUG)
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared
|
||||
LINKEXE = $(CC) $(c++FLAGS)
|
2
wmake/rules/linux64Gcc43/c++Debug
Normal file
2
wmake/rules/linux64Gcc43/c++Debug
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -ggdb3 -DFULLDEBUG
|
||||
c++OPT = -O0 -fdefault-inline
|
4
wmake/rules/linux64Gcc43/c++Opt
Normal file
4
wmake/rules/linux64Gcc43/c++Opt
Normal file
@ -0,0 +1,4 @@
|
||||
c++DBUG =
|
||||
c++OPT = -march=opteron -O3
|
||||
#c++OPT = -march=nocona -O3
|
||||
# -ftree-vectorize -ftree-vectorizer-verbose=3
|
2
wmake/rules/linux64Gcc43/c++Prof
Normal file
2
wmake/rules/linux64Gcc43/c++Prof
Normal file
@ -0,0 +1,2 @@
|
||||
c++DBUG = -pg
|
||||
c++OPT = -O2
|
2
wmake/rules/linux64Gcc43/cDebug
Normal file
2
wmake/rules/linux64Gcc43/cDebug
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -ggdb -DFULLDEBUG
|
||||
cOPT = -O1 -fdefault-inline -finline-functions
|
2
wmake/rules/linux64Gcc43/cOpt
Normal file
2
wmake/rules/linux64Gcc43/cOpt
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG =
|
||||
cOPT = -march=opteron -O3 -fno-gcse
|
2
wmake/rules/linux64Gcc43/cProf
Normal file
2
wmake/rules/linux64Gcc43/cProf
Normal file
@ -0,0 +1,2 @@
|
||||
cDBUG = -pg
|
||||
cOPT = -O2
|
BIN
wmake/rules/linux64Gcc43/dirToString
Executable file
BIN
wmake/rules/linux64Gcc43/dirToString
Executable file
Binary file not shown.
11
wmake/rules/linux64Gcc43/general
Normal file
11
wmake/rules/linux64Gcc43/general
Normal file
@ -0,0 +1,11 @@
|
||||
CPP = /lib/cpp $(GFLAGS)
|
||||
LD = ld -A64
|
||||
|
||||
PROJECT_LIBS = -l$(WM_PROJECT) -liberty -ldl
|
||||
|
||||
include $(GENERAL_RULES)/standard
|
||||
|
||||
include $(RULES)/X
|
||||
include $(RULES)/c
|
||||
include $(RULES)/c++
|
||||
include $(GENERAL_RULES)/cint
|
3
wmake/rules/linux64Gcc43/mplib
Normal file
3
wmake/rules/linux64Gcc43/mplib
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS =
|
||||
PINC =
|
||||
PLIBS =
|
3
wmake/rules/linux64Gcc43/mplibGAMMA
Normal file
3
wmake/rules/linux64Gcc43/mplibGAMMA
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS =
|
||||
PINC = -I$(GAMMA_ARCH_PATH)/include
|
||||
PLIBS = -L$(GAMMA_ARCH_PATH)/lib -lgamma
|
3
wmake/rules/linux64Gcc43/mplibLAM
Normal file
3
wmake/rules/linux64Gcc43/mplibLAM
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS =
|
||||
PINC = -I$(LAM_ARCH_PATH)/include
|
||||
PLIBS = -L$(LAM_ARCH_PATH)/lib -lmpi -llam -lpthread -lutil
|
3
wmake/rules/linux64Gcc43/mplibMPICH
Normal file
3
wmake/rules/linux64Gcc43/mplibMPICH
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS =
|
||||
PINC = -I$(MPICH_ARCH_PATH)/include
|
||||
PLIBS = -L$(MPICH_ARCH_PATH)/lib -lmpich -lrt
|
3
wmake/rules/linux64Gcc43/mplibMPICH-GM
Normal file
3
wmake/rules/linux64Gcc43/mplibMPICH-GM
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS =
|
||||
PINC = -I$(MPICH_ARCH_PATH)/include
|
||||
PLIBS = -L$(MPICH_ARCH_PATH)/lib -lmpich -L$(GM_LIB_PATH) -lgm
|
3
wmake/rules/linux64Gcc43/mplibOPENMPI
Normal file
3
wmake/rules/linux64Gcc43/mplibOPENMPI
Normal file
@ -0,0 +1,3 @@
|
||||
PFLAGS = -DOMPI_SKIP_MPICXX
|
||||
PINC = -I$(OPENMPI_ARCH_PATH)/include
|
||||
PLIBS = -L$(OPENMPI_ARCH_PATH)/lib -lmpi
|
BIN
wmake/rules/linux64Gcc43/wmkdep
Executable file
BIN
wmake/rules/linux64Gcc43/wmkdep
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user