Compilation tweaks for mingw

This commit is contained in:
Dominik Christ 2015-08-04 13:39:06 +01:00
parent 28eddd18e9
commit 0a6a65972d
105 changed files with 12801 additions and 27 deletions

76
Allwmake.mingw Normal file
View file

@ -0,0 +1,76 @@
#!/bin/sh
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# Allwmake.mingw
#
# Description
# Top-level build script for use with MSYS shell for MinGW-based builds on Windows.
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
cd ${0%/*} || exit 1 # run from this directory
echo
echo "======================== FOAM-EXTEND MINGW WINDOWS TOP-LEVEL BUILD SCRIPT ========================"
if [ "$PWD" != "$WM_PROJECT_DIR" ]
then
echo "Error: Current directory is not \$WM_PROJECT_DIR"
echo " The environment variable are not consistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
fi
cd $WM_PROJECT_DIR/ThirdParty/mingwBuild
echo
echo "In directory `pwd`"
echo "Configuring your OpenMPI installation ..."
./configure_OpenMPI.sh
PACKAGES_DIR=$WM_PROJECT_DIR/ThirdParty/packages
if [ -d $PACKAGES_DIR ] ; then
echo "Third-party dependencies packages $PACKAGES_DIR already exists."
else
echo "Building third-party dependencies ... (see `pwd`/build.log)"
./build.sh > build.log 2>&1
echo "Installing third-party dependencies ..."
rm -rf $PACKAGES_DIR
mv x64/install $PACKAGES_DIR
fi
cd $WM_PROJECT_DIR
echo
echo "In directory `pwd`"
echo "Build foam-extend ... (see `pwd`/Allwmake.log)"
./Allwmake > Allwmake.log 2>&1
echo "Copying MinGW dependencies to $FOAM_APPBIN ..."
cp -p $MINGW_HOME/bin/libgcc_s_seh-1.dll $FOAM_APPBIN
cp -p $MINGW_HOME/bin/libstdc++-6.dll $FOAM_APPBIN
cp -p $MINGW_HOME/bin/libwinpthread-1.dll $FOAM_APPBIN
echo
echo "All done!"

293
ThirdParty/mingwBuild/build.sh vendored Normal file
View file

@ -0,0 +1,293 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# build.sh
#
# Description
# Downloads, extracts, builds and installs thirdy-party dependencies.
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
# {{{ DEFINE UTILITY FUNCTIONS
download() {
file=$1
url=$2
if [ -f $BUILD_HOME/downloads/$file ] ; then
echo "Using already existing file $BUILD_HOME/downloads/$file"
else
wget --no-check-certificate $url -O $BUILD_HOME/downloads/$file
fi
}
extract() {
file=$1
program=$2
cp -p $BUILD_HOME/downloads/$file .
package=`basename $file`
if [ "$program" = "7zip" ] ; then
"$ZIP_EXE" x $package
else
$program -cd $package | tar xvf -
fi
rm $package
}
unzip_dir() {
dir=$1
mkdir $dir
cd $dir
extract $dir.zip 7zip
cd ..
}
patch() {
dir=$1
cp -rp $BUILD_HOME/$ARCH/patches/$dir .
}
mkchk() {
dir=$1
if [ ! -d $dir ] ; then
mkdir $dir
fi
}
mkdel() {
dir=$1
rm -rf $dir > /dev/null 2>&1
mkdir $dir
}
# }}}
# {{{ DEFINE PROCESS FUNCTIONS
start() {
echo "======================== FOAM-EXTEND THIRD-PARTY DEPENDENCIES WINDOWS BUILD SCRIPT ========================"
}
initialise() {
echo ""
if [ ! "$MINGW_HOME" ] ; then
echo "*** ERROR: MINGW_HOME environment variable not specified."
exit 1
else
echo "Using MINGW_HOME=$MINGW_HOME"
fi
BUILD_HOME=`pwd`
ZIP_EXE="7z.exe"
ARCH="x64"
BUILD_DIR=$BUILD_HOME/$ARCH/build
INSTALL_DIR=$BUILD_HOME/$ARCH/install
OUT_DIR=$BUILD_HOME/$ARCH/output
mkchk $BUILD_HOME/downloads
echo ""
echo "All stdout/stderr output is redirected to the directory $OUT_DIR"
echo "All builds occur in the directory $BUILD_DIR"
echo "The script will install the completed builds in the directory $INSTALL_DIR"
}
cleanup() {
echo ""
echo "Removing previous builds ..."
mkdel $BUILD_DIR
mkdel $INSTALL_DIR
mkdel $OUT_DIR
}
build_library() {
PACKAGE=$1
echo "- Building $PACKAGE ..."
LOG_FILE=$OUT_DIR/$PACKAGE.log
cd $BUILD_DIR
case $PACKAGE in
dlfcn-win32-master)
download $PACKAGE.zip https://github.com/dlfcn-win32/dlfcn-win32/archive/master.zip > $LOG_FILE 2>&1
extract $PACKAGE.zip 7zip >> $LOG_FILE 2>&1
cd $PACKAGE
./configure --prefix=$INSTALL_DIR/system >> $LOG_FILE 2>&1
make >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/system
make install >> $LOG_FILE 2>&1
;;
system)
cd $INSTALL_DIR
patch system
;;
pthreads-w32-2-9-1-release)
download $PACKAGE.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip > $LOG_FILE 2>&1
unzip_dir $PACKAGE >> $LOG_FILE 2>&1
patch $PACKAGE
;;
metis-5.1.0)
download $PACKAGE.tar.gz http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/$PACKAGE.tar.gz > $LOG_FILE 2>&1
extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
patch $PACKAGE
cd $PACKAGE
mkdir build/windows
cd build/windows
cmake -G "MSYS Makefiles" -DCMAKE_CONFIGURATION-TYPES="Release" -DGKLIB_PATH="../../GKlib" ../.. >> $LOG_FILE 2>&1
make >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/$PACKAGE
mkdir $INSTALL_DIR/$PACKAGE/bin
mkdir $INSTALL_DIR/$PACKAGE/include
mkdir $INSTALL_DIR/$PACKAGE/lib
cp -p programs/*.exe $INSTALL_DIR/$PACKAGE/bin
cp -p ../../include/metis.h $INSTALL_DIR/$PACKAGE/include
cp -p libmetis/libmetis.a $INSTALL_DIR/$PACKAGE/lib
;;
parmetis-4.0.3)
download $PACKAGE.tar.gz http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/$PACKAGE.tar.gz > $LOG_FILE 2>&1
extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
patch $PACKAGE
cd $PACKAGE
mkdir build/windows
cd build/windows
cmake -G "MSYS Makefiles" -DCMAKE_CONFIGURATION-TYPES="Release" -DGKLIB_PATH="../../metis/GKlib" ../.. >> $LOG_FILE 2>&1
$BUILD_HOME/parmetis_includes_hack.pl
make >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/$PACKAGE
mkdir $INSTALL_DIR/$PACKAGE/bin
mkdir $INSTALL_DIR/$PACKAGE/include
mkdir $INSTALL_DIR/$PACKAGE/lib
cp -p programs/*.exe $INSTALL_DIR/$PACKAGE/bin
cp -p ../../metis/include/metis.h $INSTALL_DIR/$PACKAGE/include
cp -p ../../include/parmetis.h $INSTALL_DIR/$PACKAGE/include
cp -p libmetis/libmetis.a $INSTALL_DIR/$PACKAGE/lib
cp -p libparmetis/libparmetis.a $INSTALL_DIR/$PACKAGE/lib
;;
ParMGridGen-1.0)
export EXTRA_SYSTEM_HOME=$INSTALL_DIR/system
download $PACKAGE.tar.gz http://www.mgnet.org/mgnet/Codes/parmgridgen/$PACKAGE.tar.gz > $LOG_FILE 2>&1
extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
patch $PACKAGE
cd $PACKAGE
make serial >> $LOG_FILE 2>&1
make parallel >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/$PACKAGE
mkdir $INSTALL_DIR/$PACKAGE/bin
mkdir $INSTALL_DIR/$PACKAGE/include
mkdir $INSTALL_DIR/$PACKAGE/lib
cp -p *.exe $INSTALL_DIR/$PACKAGE/bin
cp -p libmgrid.a $INSTALL_DIR/$PACKAGE/lib
cp -p libparmgrid.a $INSTALL_DIR/$PACKAGE/lib
cp -p MGridGen/IMlib/libIMlib.a $INSTALL_DIR/$PACKAGE/lib
cp -p ParMGridGen/IMParMetis-2.0/libIMparmetis.a $INSTALL_DIR/$PACKAGE/lib
cp -p MGridGen/IMlib/*.h $INSTALL_DIR/$PACKAGE/include
cp -p MGridGen/Lib/*.h $INSTALL_DIR/$PACKAGE/include
export EXTRA_SYSTEM_HOME=
;;
scotch_6.0.0)
export PTHREADS_HOME=$BUILD_DIR/pthreads-w32-2-9-1-release
download $PACKAGE.tar.gz https://gforge.inria.fr/frs/download.php/31831 > $LOG_FILE 2>&1
extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
patch $PACKAGE
cd $PACKAGE/src
make scotch >> $LOG_FILE 2>&1
make ptscotch >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/$PACKAGE
make install prefix=$INSTALL_DIR/$PACKAGE >> $PACKAGE.log 2>&1
export PTHREADS_HOME=
;;
mesquite-2.1.2)
export CPPFLAGS=-fpermissive
download $PACKAGE.tar.gz http://downloads.sourceforge.net/project/openfoam-extend/foam-extend-3.0/ThirdParty/$PACKAGE.tar.gz > $LOG_FILE 2>&1
extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
cd $PACKAGE
cp -p $MINGW_HOME/bin/libstdc++-6.dll utils
./configure --prefix=$INSTALL_DIR >> $LOG_FILE 2>&1
make >> $LOG_FILE 2>&1
mkdir $INSTALL_DIR/$PACKAGE
make install prefix=$INSTALL_DIR/$PACKAGE >> $LOG_FILE 2>&1
export CPPFLAGS=
;;
*)
echo "*** ERROR: Unknown package '$PACKAGE'"
exit 1
;;
esac
}
build_libraries() {
echo ""
echo "Building libraries ..."
build_library dlfcn-win32-master
build_library system
build_library pthreads-w32-2-9-1-release
build_library metis-5.1.0
build_library parmetis-4.0.3
build_library ParMGridGen-1.0
build_library scotch_6.0.0
build_library mesquite-2.1.2
}
create_dirs() {
echo ""
echo "Checking for build directories and creating them if required ..."
mkchk $BUILD_DIR
mkchk $INSTALL_DIR
mkchk $OUT_DIR
}
finish() {
echo ""
echo "All done!"
}
# }}}
# {{{ MAIN EXECUTION
cd ${0%/*} || exit 1 # run from this directory
start
initialise
mkchk $ARCH
cleanup
build_libraries
finish
# }}}

82
ThirdParty/mingwBuild/clean.sh vendored Normal file
View file

@ -0,0 +1,82 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# build.sh
#
# Description
# Removes previous thirdy-party dependencies build directories (does not remove installed packages directory)
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
# {{{ DEFINE UTILITY FUNCTIONS
remove_dir() {
dir=$1
rm -rf $dir > /dev/null 2>&1
}
# }}}
# {{{ DEFINE PROCESS FUNCTIONS
start() {
echo "======================== FOAM-EXTEND THIRD-PARTY DEPENDENCIES WINDOWS CLEAN SCRIPT ========================"
}
initialise() {
echo ""
BUILD_HOME=`pwd`
ARCH="x64"
BUILD_DIR=$BUILD_HOME/$ARCH/build
INSTALL_DIR=$BUILD_HOME/$ARCH/install
OUT_DIR=$BUILD_HOME/$ARCH/output
}
cleanup() {
echo ""
echo "Removing previous builds ..."
remove_dir $BUILD_DIR
remove_dir $INSTALL_DIR
remove_dir $OUT_DIR
remove_dir $BUILD_HOME/downloads
}
finish() {
echo ""
echo "All done!"
}
# }}}
# {{{ MAIN EXECUTION
cd ${0%/*} || exit 1 # run from this directory
start
initialise
cleanup
finish
# }}}

View file

@ -0,0 +1,67 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# configure_OpenMPI.sh
#
# Description
# Generates static OpenMPI library to enable compilation with MINGW toolchain.
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
if [ -f "$MPI_ROOTDIR/lib/libmpi.a" ] ; then
echo "$MPI_ROOTDIR/lib/libmpi.a already exists."
exit 1
fi
INSTALL=1
if [ $1 ] ; then
if [ $1 = "--no-install" ] ; then
INSTALL=0
echo "*** WARNING: Will not install exported libmpi.a and libmpi.def"
fi
fi
tmp=`echo $RANDOM$RANDOM$RANDOM`
current_dir=`pwd`
mkdir -p /tmp/$tmp
cd /tmp/$tmp
pexports $MPI_ROOTDIR/bin/libmpi.dll > libmpi.def
dlltool --dllname libmpi.dll --def libmpi.def --output-lib libmpi.a
if [ $INSTALL -eq 1 ] ; then
mv libmpi.a $MPI_ROOTDIR/lib
mv libmpi.def $MPI_ROOTDIR/lib
cd $current_dir
rm -rf /tmp/$tmp
echo "Installed exported libraries into $MPI_ROOTDIR/lib"
else
cd $current_dir
echo "Exported libraries left in directory /tmp/$tmp"
fi

View file

@ -0,0 +1,70 @@
#!/usr/bin/perl
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# parmetis_includes_hack.pl
#
# Description
# Adds OpenMPI lib/includes dirs to CMake-generated GCC options.
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
use strict;
use warnings;
use File::Find;
my $MPI_ROOTDIR = $ENV{"MPI_ROOTDIR"};
$MPI_ROOTDIR =~ s/^\/\w//;
my $drive_letter = $&;
$drive_letter =~ s/\///;
$MPI_ROOTDIR = uc($drive_letter) . ":" . $MPI_ROOTDIR;
my @dirs = (".");
find(\&wanted, @dirs);
sub wanted
{
my $file = $_;
my $path = $File::Find::name;
if ($file eq "linklibs.rsp" or $file eq "includes_C.rsp")
{
open (FILE, '<', $file) or die ("ERROR: Can't open '$path' [$!]");
my @contents = <FILE>;
close (FILE);
my $string = ($file eq "linklibs.rsp") ? "-L$MPI_ROOTDIR/lib -lmpi" : "-I$MPI_ROOTDIR/include";
open (FILE, '>', $file) or die ("ERROR: Can't open '$path' [$!]");
foreach my $line (@contents)
{
chomp($line);
print FILE $line . $string;
}
close (FILE);
}
}

View file

@ -0,0 +1,285 @@
/*
* IMlib.h
*
* Irene's library of most frequently used routines
*
*/
#ifndef _IMLIB_H_
#define _IMLIB_H_
/* Undefine the following #define in order to use short int as the idxtype */
#define IDXTYPE_INT
/* Undefine the following #define in order to use float as the realtype */
/*#define TYPE_REAL*/
/* Indexes are as long as integers for now */
#ifdef IDXTYPE_INT
typedef int idxtype;
#else
typedef short idxtype;
#endif
/* floats for now */
#ifdef TYPE_REAL
typedef float realtype;
#else
typedef double realtype;
#endif
/*************************************************************************
* Header file inclusion section
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <time.h>
#include "rand48.h"
#ifdef DMALLOC
#include <dmalloc.h>
#else
#include <malloc.h>
#endif
/*************************************************************************
* Data structure definition section
**************************************************************************/
/*-------------------------------------------------------------
* The following data structure stores int key-value pairs
*-------------------------------------------------------------*/
struct IKeyValueType {
int key;
int val;
};
typedef struct IKeyValueType IKeyValueType;
/*-------------------------------------------------------------
* The following data structure stores int key-value pairs
*-------------------------------------------------------------*/
struct idxKeyValueType {
idxtype key;
idxtype val;
};
typedef struct idxKeyValueType idxKeyValueType;
/*-------------------------------------------------------------
* The following data structure stores int-key - double-value pairs
*-------------------------------------------------------------*/
struct FKeyValueType {
double key;
int val, val1, val2;
};
typedef struct FKeyValueType FKeyValueType;
/*-------------------------------------------------------------
* The following data structure stores int-key - double-value pairs
*-------------------------------------------------------------*/
struct realKeyValueType {
realtype key;
int val, val1, val2;
};
typedef struct realKeyValueType realKeyValueType;
/*************************************************************************
* Definition Section
**************************************************************************/
#define LTERM (void **) 0 /* List terminator for IMfree() */
/*************************************************************************
* Macros Section
**************************************************************************/
/*-------------------------------------------------------------
* Usefull commands
*-------------------------------------------------------------*/
#define sign(a, b) ((b) >= 0 ? ((a) >= 0.0 ? a : -a) : ((a) >= 0.0 ? -a : a))
#define amax(a, b) ((a) >= (b) ? (a) : (b))
#define amin(a, b) ((a) >= (b) ? (b) : (a))
#define RandomInRange(u) ((int)(drand48()*((double)(u))))
#define RandomInRangeFast(u) ((rand()>>3)%(u))
#define SWAP(a, b, tmp) do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0)
#define INC_DEC(a, b, val) do {(a) += (val); (b) -= (val);} while(0)
#define icopy(n, a, b) (int *)memcpy((void *)(b), (void *)(a), sizeof(int)*(n))
#define idxcopy(n, a, b) (idxtype *)memcpy((void *)(b), (void *)(a), sizeof(idxtype)*(n))
#define scopy(n, a, b) (double *)memcpy((void *)(b), (void *)(a), sizeof(double)*(n))
#define fcopy(n, a, b) (double *)memcpy((void *)(b), (void *)(a), sizeof(double)*(n))
#define realcopy(n, a, b) (realtype *)memcpy((void *)(b), (void *)(a), sizeof(realtype)*(n))
/*-------------------------------------------------------------
* Timing macros
*-------------------------------------------------------------*/
#define cleartimer(tmr) (tmr = 0.0)
#define starttimer(tmr) (tmr -= seconds())
#define stoptimer(tmr) (tmr += seconds())
#define gettimer(tmr) (tmr)
/*-------------------------------------------------------------
* Debuging memory leaks
*-------------------------------------------------------------*/
#ifdef DMALLOC
#define imalloc(n, msg) (malloc(sizeof(int)*(n)))
#define fmalloc(n, msg) (malloc(sizeof(double)*(n)))
#define idxmalloc(n, msg) ((idxtype *)malloc(sizeof(idxtype)*(n)))
#define realmalloc(n, msg) ((realtype *)malloc(sizeof(realtype)*(n)))
#define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n))))
#define idxsmalloc(n, val, msg) (idxset((n), (val), (idxtype *)malloc(sizeof(idxtype)*(n))))
#define fsmalloc(n, val, msg) (fset((n), (val), malloc(sizeof(double)*(n))))
#define realsmalloc(n, val, msg) (realset((n), (val), (realtype *)malloc(sizeof(realtype)*(n))))
#define IMmalloc(a, b) (malloc((a)))
#endif
#ifdef DMALLOC
# define MALLOC_CHECK(ptr) \
if (malloc_verify((ptr)) == DMALLOC_VERIFY_ERROR) { \
printf("***MALLOC_CHECK failed on line %d of file %s: " #ptr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define MALLOC_CHECK(ptr) ;
#endif
/*-------------------------------------------------------------
* CSR conversion macros
*-------------------------------------------------------------*/
#define MAKECSR(i, n, a) \
do { \
for (i=1; i<n; i++) a[i] += a[i-1]; \
for (i=n; i>0; i--) a[i] = a[i-1]; \
a[0] = 0; \
} while(0)
/*-------------------------------------------------------------
* Program Assertions
*-------------------------------------------------------------*/
#ifdef DEBUG
# define ASSERT(expr) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define ASSERT(expr) ;
#endif
#ifdef DEBUG
# define ASSERTP(expr,msg) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
printf msg ; \
printf("\n"); \
abort(); \
}
#else
# define ASSERTP(expr,msg) ;
#endif
/*************************************************************************
* Function prototypes
**************************************************************************/
/*-------------------------------------------------------------
* blas.c
*-------------------------------------------------------------*/
int *iset(int, int, int *);
idxtype *idxset(int, idxtype, idxtype *);
double *fset(int, double, double *);
realtype *realset(int, realtype, realtype *);
int iamax(int, int *);
int idxamax(int, idxtype *);
int famax(int, double *);
int iamin(int, int *);
int idxamin(int, idxtype *);
int famin(int, double *);
int charsum(int, char *);
int isum(int, int *);
int idxsum(int, idxtype *);
double ssum(int, double *);
double ssum_strd(int, double *, int);
void sscale(int, double, double *);
double snorm2(int, double *);
double sdot(int, double *, double *);
void saxpy(int, double, double *, int, double *, int);
/*-------------------------------------------------------------
* file.c
*-------------------------------------------------------------*/
FILE *IMfopen(char *, char *, char *);
void IMfclose(FILE *);
/*-------------------------------------------------------------
* memory.c
*-------------------------------------------------------------*/
#ifndef DMALLOC
int *imalloc(int, char *);
idxtype *idxmalloc(int, char *);
double *fmalloc(int, char *);
realtype *realmalloc(int, char *);
int *ismalloc(int, int, char *);
idxtype *idxsmalloc(int, idxtype, char *);
double *fsmalloc(int, double, char *);
realtype *realsmalloc(int, realtype, char *);
void *IMmalloc(int, char *);
#endif
/* void IMfree(void **, ...); */
/*-------------------------------------------------------------
* util.c
*-------------------------------------------------------------*/
void *errexit(char *,...);
int IMlog2(int);
double flog2(double);
int ispow2(int);
double seconds(void);
/*-------------------------------------------------------------
* Sorting routines
*-------------------------------------------------------------*/
void dfkeysort(int, FKeyValueType *);
void dkeysort(int, IKeyValueType *);
void ifkeysort(int, FKeyValueType *);
void ifkeysort2(int, FKeyValueType *);
void ifloatsort(int, double *);
void iintsort(int, int *);
void ikeysort(int, IKeyValueType *);
void idxkeysort(int, idxKeyValueType *);
void ikeysort2(int, IKeyValueType *);
void idxkeysort2(int, idxKeyValueType *);
/*-------------------------------------------------------------
* sort.c
*-------------------------------------------------------------*/
void ikeyvalsort_org(int, IKeyValueType *);
int IncKeyValueCmp(const void *, const void *);
void dkeyvalsort(int, IKeyValueType *);
void BucketSortKeysInc(int, idxtype, idxtype *, int *, int *);
int DecKeyValueCmp(const void *, const void *);
int BSearch(int, idxtype *, int);
void RandomPermute(int, idxtype *, int);
void RandomPermuteFine(int, int *, int);
void FastRandomPermute(int, idxtype *, int);
#endif

View file

@ -0,0 +1,111 @@
/*
* Copyright 2001, Regents of the University of Minnesota
*
* mgridgen.c
*
* This file contains the top level routines for the sparse hierarchical
* clustering algorithm.
*
* George Irene
*/
#include "mgridgen.h"
#include "rand48.h"
/*************************************************************************
* This function is the entry point for the SHCluster() routine.
**************************************************************************/
void MGridGen(int nvtxs, idxtype *xadj, realtype *vvol, realtype *vsurf,
idxtype *adjncy, realtype *adjwgt, int minsize, int maxsize,
int *options, int *nmoves, int *nparts, idxtype *part)
{
GraphType graph;
CtrlType ctrl;
srand(4321);
srand48(7654321L);
/*------------------------------------------------------------
* Set up the various control structures
*------------------------------------------------------------*/
ctrl.CType = options[OPTION_CTYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
ctrl.dim = options[OPTION_DIM];
ctrl.minsize = minsize;
ctrl.maxsize = maxsize;
ctrl.nparts = -1;
/*------------------------------------------------------------
* Set up the graph
*------------------------------------------------------------*/
SetUpGraph(&graph, nvtxs, xadj, vvol, vsurf, adjncy, adjwgt);
CreateGrid(&ctrl, &graph);
*nparts = ctrl.nparts;
icopy(nvtxs, graph.where, part);
*nmoves = graph.nmoves;
FreeGraph(&graph);
}
/*************************************************************************
* This function is the entry point for performing refinement
**************************************************************************/
void MGridGenRefine(int nvtxs, idxtype *xadj, realtype *vvol, realtype *vsurf,
idxtype *adjncy, idxtype *fusedinfo, realtype *adjwgt,
int minsize, int maxsize, int *options, int *nmoves,
int *nparts, idxtype *part)
{
int i;
GraphType graph;
CtrlType ctrl;
srand(4321);
srand48(7654321L);
/*------------------------------------------------------------
* Set up the various control structures
*------------------------------------------------------------*/
ctrl.CType = options[OPTION_CTYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
ctrl.dim = options[OPTION_DIM];
ctrl.minsize = minsize;
ctrl.maxsize = maxsize;
ctrl.nparts = -1;
/*------------------------------------------------------------
* Set up the graph
*------------------------------------------------------------*/
SetUpGraph(&graph, nvtxs, xadj, vvol, vsurf, adjncy, adjwgt);
graph.cmap = NULL;
graph.where = idxmalloc(graph.nvtxs, "graph.where");
for (i=0; i<graph.nvtxs; i++)
graph.where[i] = fusedinfo[i];
RefineKWayOnce(&ctrl, &graph, 10);
*nparts = ctrl.nparts;
icopy(nvtxs, graph.where, part);
*nmoves = graph.nmoves;
FreeGraph(&graph);
}
/*************************************************************************
* This function creates the coarse grid
**************************************************************************/
void CreateGrid(CtrlType *ctrl, GraphType *graph)
{
GraphType *cgraph;
cgraph = Coarsen(ctrl, graph);
RefineKWay(ctrl, graph, cgraph, 10);
}

View file

@ -0,0 +1,64 @@
#--------------------------------------------------------------------------
# Which make to use
make = gmake
# Which compiler to use
# CC is the compiler for the serial code
# PARCC is the compiter for the parallel code
CC = gcc
PARCC = gcc
# What optimization level to use
OPTFLAGS = -O3
# What options to be used by the compiler
COPTIONS =
# Which loader to use
LD = gcc
PARLD = gcc
# What options to be used by the loader
LDOPTIONS = -O3
# Where to put the executable
BINDIR = ../..
# Additional libraries
DMALLOCDIR = /usr/local
IMLIBDIR = ../../MGridGen/IMlib
# Include directories for the compiler
INCDIR = -I$(MPI_ROOTDIR)/include -I$(EXTRA_SYSTEM_HOME)/include
# In which directories to look for any additional libraries
LIBDIR = -L../.. \
-L$(MPI_ROOTDIR)/lib
# Set some flags
DEBUGFLAGS =
# What additional libraries to link the programs with (eg., -lmpi)
LIBS = -lmgrid -lm
PARLIBS = -lparmgrid -lmgrid -lmpi -lm
# What archiving to use
AR = ar rv
# What to use for indexing the archive
#RANLIB = ranlib
RANLIB = ar -ts
#--------------------------------------------------------------------------
#
# Do not change any of the following
#
VERNUM = 1.0
#*************************************************************************
# Compilation flags
#*************************************************************************
ddmalloc = no
dmalloc = no
debug = no

View file

@ -0,0 +1,137 @@
/*
* Copyright 2001, Regents of the University of Minnesota
*
* macros.h
*
* This file contains macros used in multilevel
*
* George
*/
#include "rand48.h"
/*************************************************************************
* The following macro returns a random number in the specified range
**************************************************************************/
#define RandomInRange(u) ((int)(drand48()*((double)(u))))
#define RandomInRangeFast(u) ((rand()>>2)%(u))
#define amax(a, b) ((a) >= (b) ? (a) : (b))
#define amin(a, b) ((a) >= (b) ? (b) : (a))
#define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b)))
#define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b)))
#define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b)))
#define SWAP(a, b, tmp) \
do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0)
#define INC_DEC(a, b, val) \
do {(a) += (val); (b) -= (val);} while(0)
#define scopy(n, a, b) memcpy((b), (a), sizeof(float)*(n))
#define idxcopy(n, a, b) memcpy((b), (a), sizeof(idxtype)*(n))
#define realcopy(n, a, b) memcpy((b), (a), sizeof(realtype)*(n))
#define HASHFCT(key, size) ((key)%(size))
/*************************************************************************
* Timer macros
**************************************************************************/
#define cleartimer(tmr) (tmr = 0.0)
#define starttimer(tmr) (tmr -= MPI_Wtime())
#define stoptimer(tmr) (tmr += MPI_Wtime())
#define gettimer(tmr) (tmr)
/*************************************************************************
* This macro is used to handle dbglvl
**************************************************************************/
#define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd);
/*************************************************************************
* These macros are used for debuging memory leaks
**************************************************************************/
#ifdef DMALLOC
#define imalloc(n, msg) (malloc(sizeof(int)*(n)))
#define fmalloc(n, msg) (malloc(sizeof(float)*(n)))
#define idxmalloc(n, msg) (malloc(sizeof(idxtype)*(n)))
#define realmalloc(n, msg) ((realtype *)malloc(sizeof(realtype)*(n)))
#define ismalloc(n, val, msg) (iset((n), (val), malloc(sizeof(int)*(n))))
#define idxsmalloc(n, val, msg) (idxset((n), (val), malloc(sizeof(idxtype)*(n))))
#define realsmalloc(n, val, msg) (realset((n), (val), (realtype *)malloc(sizeof(realtype)*(n))))
#define IMmalloc(a, b) (malloc(a))
#endif
#ifdef DMALLOC
# define MALLOC_CHECK(ptr) \
if (malloc_verify((ptr)) == DMALLOC_VERIFY_ERROR) { \
printf("***MALLOC_CHECK failed on line %d of file %s: " #ptr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define MALLOC_CHECK(ptr) ;
#endif
/*************************************************************************
* This macro converts a length array in a CSR one
**************************************************************************/
#define MAKECSR(i, n, a) \
do { \
for (i=1; i<n; i++) a[i] += a[i-1]; \
for (i=n; i>0; i--) a[i] = a[i-1]; \
a[0] = 0; \
} while(0)
#ifdef DEBUG
# define ASSERT(ctrl, expr) \
if (!(expr)) { \
myprintf(ctrl, "***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define ASSERT(ctrl, expr) ;
#endif
#ifdef DEBUG
# define ASSERTP(ctrl, expr,msg) \
if (!(expr)) { \
myprintf(ctrl, "***ASSERTION failed on line %d of file %s:" #expr "\n", \
__LINE__, __FILE__); \
myprintf msg ; \
abort(); \
}
#else
# define ASSERTP(ctrl, expr,msg) ;
#endif
#ifdef DEBUGS
# define ASSERTS(expr) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define ASSERTS(expr) ;
#endif
#ifdef DEBUGS
# define ASSERTSP(expr, msg) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
printf msg ; \
abort(); \
}
#else
# define ASSERTSP(expr, msg) ;
#endif

View file

@ -0,0 +1,108 @@
/*
* Copyright 2001, Regents of the University of Minnesota
*
* macros.h
*
* This file contains macros used in multilevel
*
* George Irene
*/
#include "rand48.h"
/*************************************************************************
* This macro is used to normalize the weights of two nodes
**************************************************************************/
#define ARATIO1(dim, surf, vol) ((dim == 2) ? (pow((surf), 2)/(vol)) : (pow((surf), 1.5)/(vol)))
#define ARATIO(dim, surf, vol) ((dim == 2) ? ((surf)*(surf)/(vol)) : (sqrt((surf)*(surf)*(surf))/(vol)))
#define ARATIO2(dim, surf, vol) ((dim == 2) ? ((surf)*(surf)*(surf)*(surf)/(vol)*(vol)) : ((surf)*(surf)*(surf)/((vol)*(vol))))
/*************************************************************************
* The following macro returns a random number in the specified range
**************************************************************************/
#define RandomInRange(u) ((int)(drand48()*((double)(u))))
#define amax(a, b) ((a) >= (b) ? (a) : (b))
#define amin(a, b) ((a) >= (b) ? (b) : (a))
#define AND(a, b) ((a) < 0 ? ((-(a))&(b)) : ((a)&(b)))
#define OR(a, b) ((a) < 0 ? -((-(a))|(b)) : ((a)|(b)))
#define XOR(a, b) ((a) < 0 ? -((-(a))^(b)) : ((a)^(b)))
#define SWAP(a, b, tmp) \
do {(tmp) = (a); (a) = (b); (b) = (tmp);} while(0)
#define INC_DEC(a, b, val) \
do {(a) += (val); (b) -= (val);} while(0)
#define HASHFCT(key, size) ((key)%(size))
/*************************************************************************
* Timer macros
**************************************************************************/
#undef cleartimer
#undef starttimer
#undef stoptimer
#undef gettimer
#define cleartimer(tmr) (tmr = 0.0)
#define starttimer(tmr) (tmr -= MPI_Wtime())
#define stoptimer(tmr) (tmr += MPI_Wtime())
#define gettimer(tmr) (tmr)
/*************************************************************************
* This macro is used to handle dbglvl
**************************************************************************/
#define IFSET(a, flag, cmd) if ((a)&(flag)) (cmd);
#undef ASSERT
#undef ASSERTP
#ifdef DEBUG
# define ASSERT(ctrl, expr) \
if (!(expr)) { \
MGridmyprintf(ctrl, "***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define ASSERT(ctrl, expr) ;
#endif
#ifdef DEBUG
# define ASSERTP(ctrl, expr,msg) \
if (!(expr)) { \
MGridmyprintf(ctrl, "***ASSERTION failed on line %d of file %s:" #expr "\n", \
__LINE__, __FILE__); \
MGridmyprintf msg ; \
abort(); \
}
#else
# define ASSERTP(ctrl, expr,msg) ;
#endif
#ifdef DEBUGS
# define ASSERTS(expr) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
abort(); \
}
#else
# define ASSERTS(expr) ;
#endif
#ifdef DEBUGS
# define ASSERTSP(expr, msg) \
if (!(expr)) { \
printf("***ASSERTION failed on line %d of file %s: " #expr "\n", \
__LINE__, __FILE__); \
printf msg ; \
abort(); \
}
#else
# define ASSERTSP(expr, msg) ;
#endif

View file

@ -0,0 +1,71 @@
/*!
\file gk_arch.h
\brief This file contains various architecture-specific declerations
\date Started 3/27/2007
\author George
\version\verbatim $Id: gk_arch.h 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
*/
#ifndef _GK_ARCH_H_
#define _GK_ARCH_H_
/*************************************************************************
* Architecture-specific differences in header files
**************************************************************************/
#ifdef LINUX
#if !defined(__USE_XOPEN)
#define __USE_XOPEN
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 600
#endif
#if !defined(__USE_XOPEN2K)
#define __USE_XOPEN2K
#endif
#endif
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#ifdef __MSC__
#include "ms_stdint.h"
#include "ms_inttypes.h"
#include "ms_stat.h"
#else
#ifndef SUNOS
#include <stdint.h>
#endif
#include <inttypes.h>
#include <sys/types.h>
// #include <sys/resource.h>
#include <sys/time.h>
#endif
/*************************************************************************
* Architecture-specific modifications
**************************************************************************/
#ifdef WIN32
typedef ptrdiff_t ssize_t;
#endif
#ifdef SUNOS
#define PTRDIFF_MAX INT64_MAX
#endif
#ifdef __MSC__
/* MSC does not have rint() function */
#define rint(x) ((int)((x)+0.5))
/* MSC does not have INFINITY defined */
#ifndef INFINITY
#define INFINITY FLT_MAX
#endif
#endif
#endif

View file

@ -0,0 +1,64 @@
/*!
\file gk_getopt.h
\brief This file contains GNU's externs/structs/prototypes
\date Started 3/27/2007
\author George
\version\verbatim $Id: gk_getopt.h 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
*/
#ifndef _GK_GETOPT_H_
#define _GK_GETOPT_H_
/* Externals from getopt.c */
//extern char *gk_optarg;
//extern int gk_optind;
//extern int gk_opterr;
//extern int gk_optopt;
/*! \brief The structure that stores the information about the command-line options
This structure describes a single long option name for the sake of
gk_getopt_long(). The argument <tt>long_options</tt> must be an array
of these structures, one for each long option. Terminate the array with
an element containing all zeros.
*/
struct gk_option {
char *name; /*!< This field is the name of the option. */
int has_arg; /*!< This field says whether the option takes an argument.
It is an integer, and there are three legitimate values:
no_argument, required_argument and optional_argument.
*/
int *flag; /*!< See the discussion on ::gk_option#val */
int val; /*!< These fields control how to report or act on the option
when it occurs.
If flag is a null pointer, then the val is a value which
identifies this option. Often these values are chosen
to uniquely identify particular long options.
If flag is not a null pointer, it should be the address
of an int variable which is the flag for this option.
The value in val is the value to store in the flag to
indicate that the option was seen. */
};
/* Names for the values of the `has_arg' field of `struct gk_option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
/* Function prototypes */
//extern int gk_getopt(int __argc, char **__argv, char *__shortopts);
//extern int gk_getopt_long(int __argc, char **__argv, char *__shortopts,
// struct gk_option *__longopts, int *__longind);
//extern int gk_getopt_long_only (int __argc, char **__argv,
// char *__shortopts, struct gk_option *__longopts, int *__longind);
#endif

View file

@ -0,0 +1,71 @@
/*!
\file gk_arch.h
\brief This file contains various architecture-specific declerations
\date Started 3/27/2007
\author George
\version\verbatim $Id: gk_arch.h 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
*/
#ifndef _GK_ARCH_H_
#define _GK_ARCH_H_
/*************************************************************************
* Architecture-specific differences in header files
**************************************************************************/
#ifdef LINUX
#if !defined(__USE_XOPEN)
#define __USE_XOPEN
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 600
#endif
#if !defined(__USE_XOPEN2K)
#define __USE_XOPEN2K
#endif
#endif
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#ifdef __MSC__
#include "ms_stdint.h"
#include "ms_inttypes.h"
#include "ms_stat.h"
#else
#ifndef SUNOS
#include <stdint.h>
#endif
#include <inttypes.h>
#include <sys/types.h>
// #include <sys/resource.h>
#include <sys/time.h>
#endif
/*************************************************************************
* Architecture-specific modifications
**************************************************************************/
#ifdef WIN32
typedef ptrdiff_t ssize_t;
#endif
#ifdef SUNOS
#define PTRDIFF_MAX INT64_MAX
#endif
#ifdef __MSC__
/* MSC does not have rint() function */
#define rint(x) ((int)((x)+0.5))
/* MSC does not have INFINITY defined */
#ifndef INFINITY
#define INFINITY FLT_MAX
#endif
#endif
#endif

View file

@ -0,0 +1,64 @@
/*!
\file gk_getopt.h
\brief This file contains GNU's externs/structs/prototypes
\date Started 3/27/2007
\author George
\version\verbatim $Id: gk_getopt.h 10711 2011-08-31 22:23:04Z karypis $ \endverbatim
*/
#ifndef _GK_GETOPT_H_
#define _GK_GETOPT_H_
/* Externals from getopt.c */
//extern char *gk_optarg;
//extern int gk_optind;
//extern int gk_opterr;
//extern int gk_optopt;
/*! \brief The structure that stores the information about the command-line options
This structure describes a single long option name for the sake of
gk_getopt_long(). The argument <tt>long_options</tt> must be an array
of these structures, one for each long option. Terminate the array with
an element containing all zeros.
*/
struct gk_option {
char *name; /*!< This field is the name of the option. */
int has_arg; /*!< This field says whether the option takes an argument.
It is an integer, and there are three legitimate values:
no_argument, required_argument and optional_argument.
*/
int *flag; /*!< See the discussion on ::gk_option#val */
int val; /*!< These fields control how to report or act on the option
when it occurs.
If flag is a null pointer, then the val is a value which
identifies this option. Often these values are chosen
to uniquely identify particular long options.
If flag is not a null pointer, it should be the address
of an int variable which is the flag for this option.
The value in val is the value to store in the flag to
indicate that the option was seen. */
};
/* Names for the values of the `has_arg' field of `struct gk_option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
/* Function prototypes */
//extern int gk_getopt(int __argc, char **__argv, char *__shortopts);
//extern int gk_getopt_long(int __argc, char **__argv, char *__shortopts,
// struct gk_option *__longopts, int *__longind);
//extern int gk_getopt_long_only (int __argc, char **__argv,
// char *__shortopts, struct gk_option *__longopts, int *__longind);
#endif

View file

@ -0,0 +1,183 @@
/*
* Module: sched.h
*
* Purpose:
* Provides an implementation of POSIX realtime extensions
* as defined in
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(_SCHED_H)
#define _SCHED_H
#undef PTW32_SCHED_LEVEL
#if defined(_POSIX_SOURCE)
#define PTW32_SCHED_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_SCHED_LEVEL
#define PTW32_SCHED_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
#undef PTW32_SCHED_LEVEL
#define PTW32_SCHED_LEVEL 2
/* Include Non-Portable extensions */
#endif
#define PTW32_SCHED_LEVEL_MAX 3
#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
/* Include everything */
#endif
#if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
/*
* When building the library, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the library,
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
#else
# define PTW32_DLLPORT
#endif
/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
*/
#if !defined(PTW32_CONFIG_H)
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
# endif
# if defined(__MINGW64__)
# define HAVE_STRUCT_TIMESPEC
# define HAVE_MODE_T
# elif defined(_UWIN) || defined(__MINGW32__)
# define HAVE_MODE_T
# endif
#endif
/*
*
*/
#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
#if defined(NEED_ERRNO)
#include "need_errno.h"
#else
#include <errno.h>
#endif
#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
/* For pid_t */
# include <sys/types.h>
/* Required by Unix 98 */
# include <time.h>
# else
typedef __int64 pid_t;
# endif
#else
typedef int pid_t;
#endif
/* Thread scheduling policies */
enum {
SCHED_OTHER = 0,
SCHED_FIFO,
SCHED_RR,
SCHED_MIN = SCHED_OTHER,
SCHED_MAX = SCHED_RR
};
struct sched_param {
int sched_priority;
};
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
PTW32_DLLPORT int __cdecl sched_yield (void);
PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
/*
* Note that this macro returns ENOTSUP rather than
* ENOSYS as might be expected. However, returning ENOSYS
* should mean that sched_get_priority_{min,max} are
* not implemented as well as sched_rr_get_interval.
* This is not the case, since we just don't support
* round-robin scheduling. Therefore I have chosen to
* return the same value as sched_setscheduler when
* SCHED_RR is passed to it.
*/
#define sched_rr_get_interval(_pid, _interval) \
( errno = ENOTSUP, (int) -1 )
#if defined(__cplusplus)
} /* End of extern "C" */
#endif /* __cplusplus */
#undef PTW32_SCHED_LEVEL
#undef PTW32_SCHED_LEVEL_MAX
#endif /* !_SCHED_H */

View file

@ -0,0 +1,70 @@
# This make include file is intended for building under MinGW32. As is,
# it relies on :
# - pthread-win32 (http://sourceware.org/pthreads-win32/),
# - zlib (http://www.zlib.net/)
# - mpich2 (http://www.mcs.anl.gov/research/projects/mpich2/).
# It must be adapted to reflect your environment, in particular
# installation root directories, include path and library name.
# Since all files are linked with the MPI libraries, this file is
# for compiling PT-Scotch only. To compile Scotch, remove the
# -DSCOTCH_PTSCOTCH flag, as well as all references to MPI in the
# CFLAGS and CLIBFLAGS =
#LDFLAGS variables.
#MPI_ROOTDIR = /c/Programs/OpenMPI_v1.6.1-x64
EXE =
LIB = .a
OBJ = .o
MAKE = make
AR = ar
ARFLAGS = -ruv
CAT = cat
CCS = gcc
CCP = mpicc
CCD = mpicc -I$(MPI_ROOTDIR)/include
#--- Compiler/loader flags
CFLAGS_CPL = -O0 -g3 --std=c99
CFLAGS_INC =
CFLAGS_DEF = -DCOMMON_RANDOM_FIXED_SEED -DCOMMON_STUB_FORK -DSCOTCH_PTSCOTCH -DSCOTCH_RENAME -D'pipe(pfds)=_pipe(pfds,1024,0x8000)' -DHAVE_STDINT_H=0 -DHAVE_UINT_T=1
CLIBFLAGS =
LDFLAGS =
PGMFILES=$(PROGRAMFILES)
#--- MPI
CFLAGS_INC += -I$(MPI_ROOTDIR)/include
#--- Comment/Uncomment for threaded MPI
CLIBFLAGS =
LDFLAGS += -L$(MPI_ROOTDIR)/bin -lm -lmpi -lmpid
#CLIBFLAGS =
#LDFLAGS += -L$(MPI_ROOTDIR)/lib -lm -lmpich2mt
#--- Pthread : Uncomment for pthread support
#PTHREAD_ROOTDIR = $(PGMFILES)/pthread-win32
#CFLAGS_INC += -I$(PTHREAD_ROOTDIR)/include
#CLIBFLAGS =
LDFLAGS += -L$(PTHREADS_HOME)/Pre-built.2/lib/x64 -lpthreadGC2
#--- zlib: Uncomment for compressed files
#ZLIB_ROOTDIR = $(PGMFILES)/zlib-1.2.3
#CFLAGS_INC += -I$(ZLIB_ROOTDIR)/include
#CLIBFLAGS =
LDFLAGS += -lz
#--- COMMON_PTHREAD: Uncomment for compressed files
#CFLAGS_DEF += -DCOMMON_PTHREAD -DCOMMON_FILE_COMPRESS_GZ
#--- SCOTCH_PTHREAD: Uncomment for threaded MPI
#CFLAGS_DEF += -DSCOTCH_PTHREAD
CFLAGS = $(CFLAGS_CPL) $(CFLAGS_INC) $(CFLAGS_DEF)
CP = cp
LEX = flex -Pscotchyy -olex.yy.c
LN = cp
MKDIR = mkdir
MV = mv
RANLIB = ranlib
YACC = bison -pscotchyy -y -b y

View file

@ -0,0 +1,19 @@
#ifndef RAND48_H
#define RAND48_H
#define drand48() (rand()*(1./RAND_MAX))
static long _rand = 1;
static __inline__ void srand48(long seed)
{
_rand = seed;
}
static __inline__ long lrand48(void)
{
long val = (int)(abs(10000.0*sin(_rand)));
_rand++;
return val;
}
#endif //RAND48_H

View file

@ -0,0 +1,40 @@
// From http://www.linuxjournal.com/article/5574
#ifndef _TIMES_H
#define _TIMES_H
#ifdef _WIN32
#include <sys/timeb.h>
#include <sys/types.h>
#include <winsock2.h>
int gettimeofday(struct timeval* t,void* timezone);
// from linux's sys/times.h
//#include <features.h>
#define __need_clock_t
#include <time.h>
/* Structure describing CPU time used by a process and its children. */
struct tms
{
clock_t tms_utime; /* User CPU time. */
clock_t tms_stime; /* System CPU time. */
clock_t tms_cutime; /* User CPU time of dead children. */
clock_t tms_cstime; /* System CPU time of dead children. */
};
/* Store the CPU time used by this process and all its
dead children (and their dead children) in BUFFER.
Return the elapsed real time, or (clock_t) -1 for errors.
All times are in CLK_TCKths of a second. */
clock_t times (struct tms *__buffer);
typedef long long suseconds_t ;
#endif
#endif

View file

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
EXE_LIBS = \
LIB_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \
-lspecie

View file

@ -4,6 +4,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-IBCs/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \

View file

@ -3,4 +3,5 @@ EXE_INC = \
-I../phaseModel/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lphaseModel

View file

@ -3,3 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I../phaseModel/lnInclude \
-I../interfacialModels/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lphaseModel

View file

@ -3,4 +3,5 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lincompressibleTransportModels

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
LIB_LIBS = \
-lfiniteVolume

View file

@ -7,7 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/tetFiniteElement/lnInclude \
-I$(LIB_SRC)/dynamicMesh/meshMotion/tetMotionSolver/lnInclude
EXE_LIBS = \
LIB_LIBS = \
-lfiniteArea \
-lfiniteVolume \
-lmeshTools \

View file

@ -1,6 +1,13 @@
ifneq ($(FLEX_DIR), "")
EXE_INC = \
-I$(FLEX_DIR)/include \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
else
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
endif
EXE_LIBS = \
-lreactionThermophysicalModels \

View file

@ -56,6 +56,12 @@ foamInstall=$HOME/$WM_PROJECT
# END OF (NORMAL) USER EDITABLE PART
################################################################################
# Set $USER if it has not been set (eg. on Windows/MSYS systems)
if [ -z $USER ]
then
export USER=`whoami`
fi
# note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
@ -192,6 +198,15 @@ export FOAM_SIGFPE=
export WM_ARCH=`uname -s`
case $WM_ARCH in
MINGW32_NT-6.1)
WM_ARCH=MINGW32_NT-6.1
export WM_ARCH_BASE=mingw
export WM_COMPILER_LIB_ARCH=64
export WM_CFLAGS='-m64 -fPIC'
export WM_CXXFLAGS='-m64 -fPIC'
export WM_LDFLAGS='-m64'
;;
Linux)
WM_ARCH=linux

127
etc/bashrc.mingw Normal file
View file

@ -0,0 +1,127 @@
#!/bin/sh
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# etc/bashrc.mingw
#
# Description
# Startup file for FOAM for use with MSYS shell for MinGW-based builds on Windows.
# Calls the main etc/bashrc script.
# Sourced from ~/.profile or ~/.bashrc
#
# Author:
# Cesare Guardino, Alstom Power Ltd., (2015)
#
#------------------------------------------------------------------------------
# {{{ DEFINE USER EDITABLE FUNCTIONS
set_system_paths() {
echo "Setting installations directories of required tools ..."
export CMAKE_HOME=/c/Programs/cmake-3.2.3-win32-x86
#export GIT_HOME=/c/Programs/Git
#export JAVA_HOME="/c/Program Files/Java/jre1.8.0_45"
export MINGW_HOME=/c/Programs/x86_64-4.8.2-release-win32-seh-rt_v3-rev3/mingw64
export MPI_ROOTDIR=/c/Programs/OpenMPI_v1.6.1-x64
export PERL_HOME=/c/Programs/strawberry-perl-5.20.2.1-64bit/perl
#export PEXPORTS_HOME=/c/Programs/pexports-0.46-mingw32
#export PYTHON_HOME=/c/Programs/Python27
#export SUBVERSION_HOME=/c/Programs/svn-win32-1.8.13
export WGET_HOME=/c/Programs/wget-1.11.4-1
export ZIP_HOME="/c/Program Files/7-Zip"
}
add_to_path() {
echo "Adding required tools to PATH ..."
export PATH=$ZIP_HOME:$PATH
export PATH=$WGET_HOME/bin:$PATH
#export PATH=$JAVA_HOME/bin:$PATH
#export PATH=$PYTHON_HOME:$PATH
#export PATH=$SUBVERSION_HOME/bin:$PATH
#export PATH=$GIT_HOME/cmd:$PATH
export PATH=$PERL_HOME/bin:$PATH
export PATH=$CMAKE_HOME/bin:$PATH
export PATH=$MPI_ROOTDIR/bin:$PATH
#export PATH=$PEXPORTS_HOME/bin:$PATH
export PATH=$MINGW_HOME/bin:$PATH
}
# }}}
# {{{ DEFINE PROCESS FUNCTIONS
setup_foam_env() {
: ${WM_OSTYPE:=POSIX}; export WM_OSTYPE
export export FLEX_DIR=$(echo $WD\.. | sed 's/\\/\//g' | sed 's/\(.*\):/\/\1/')
FOAM_ETC_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export FOAM_INST_DIR=$(readlink -f $FOAM_ETC_DIR/../..)
. $FOAM_ETC_DIR/bashrc
. $FOAM_ETC_DIR/prefs.sh.mingw
}
set_OMPI_env() {
echo "Setting OpenMPI environment settings ..."
export OMPI_MPICC=gcc.exe
export OMPI_MPIXX=g++.exe
export OMPI_CXXFLAGS==-I$MPI_ROOTDIR/include
export OMPI_CFLAGS=-I$MPI_ROOTDIR/include
export OMPI_CXXFLAGS=-I$MPI_ROOTDIR/include
export OMPI_LDFLAGS=-L$MPI_ROOTDIR/lib
export OMPI_LIBS=$OMPI_LDFLAGS
}
check_versions() {
echo "Checking versions of installed system tools (based on PATH) ..."
echo "7-Zip: " `which 7z` [`(7z --help 2>&1) 2> /dev/null | head -2`]
echo "CMake: " `which cmake` [`(cmake --version 2>&1) 2> /dev/null | head -1`]
echo "G++: " `which g++` [`(g++ --version 2>&1) 2> /dev/null | head -1`]
echo "GCC: " `which gcc` [`(gcc --version 2>&1) 2> /dev/null | head -1`]
echo "Git: " `which git` [`(git --version 2>&1) 2> /dev/null | head -1`]
echo "Java: " `which java` [`(java -version 2>&1) 2> /dev/null | head -1`]
echo "Make: " `which make` [`(make --version 2>&1) 2> /dev/null | head -1`]
echo "MinGW-w64: " $MINGW_HOME
echo "OpenMPI: " `which mpirun` [`(mpirun --version 2>&1) 2> /dev/null | head -1`]
echo "PEexports: " `which pexports` [`(pexports -v 2>&1) 2> /dev/null | head -1`]
echo "Perl: " `which perl` [`(perl -v 2>&1) 2> /dev/null | head -2`]
echo "Python: " `which python` [`(python --version 2>&1) 2> /dev/null | head -1`]
echo "Subversion: " `which svn` [`(svn --version 2>&1) 2> /dev/null | head -1`]
echo "Wget: " `which wget` [`(wget --version 2>&1) 2> /dev/null | head -3`]
}
finish() {
echo
echo "=========================================================================================="
echo "FOAM_INST_DIR=$FOAM_INST_DIR"
echo "ENVIRONMENT SETUP COMPLETE."
echo "=========================================================================================="
echo
}
# }}}
# {{{ MAIN EXECUTION
set_system_paths
setup_foam_env
add_to_path
set_OMPI_env
check_versions
finish
# }}}

242
etc/prefs.sh.mingw Normal file
View file

@ -0,0 +1,242 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | foam-extend: Open Source CFD
# \\ / O peration | Version: 3.2
# \\ / A nd | Web: http://www.foam-extend.org
# \\/ M anipulation | For copyright notice see file Copyright
#------------------------------------------------------------------------------
# License
# This file is part of foam-extend.
#
# foam-extend 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.
#
# foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/prefs.sh
#
# Description
# Preset variables for the FOAM configuration - POSIX shell syntax.
#
# The prefs.sh file will be sourced by the FOAM etc/bashrc when it is
# found
#
#------------------------------------------------------------------------------
export FOAM_VERBOSE=1
# Specify system compiler
# ~~~~~~~~~~~~~~~~~~~~~~~
#compilerInstall=System
#compilerInstall=FOAM
# Specify system openmpi
# ~~~~~~~~~~~~~~~~~~~~~~
#
# Normally, you don't need to set more than these 3 env. variables
# The other openmpi related variables will be initialized using
# the command mpicc --showme:
#
#export WM_MPLIB=SYSTEMOPENMPI
export OPENMPI_DIR=$MPI_ROOTDIR
export OPENMPI_BIN_DIR=$OPENMPI_DIR/bin
#
#export OPENMPI_LIB_DIR="`$OPENMPI_BIN_DIR/mpicc --showme:libdirs`"
#export OPENMPI_INCLUDE_DIR="`$OPENMPI_BIN_DIR/mpicc --showme:incdirs`"
#export OPENMPI_COMPILE_FLAGS="`$OPENMPI_BIN_DIR/mpicc --showme:compile`"
#export OPENMPI_LINK_FLAGS="`$OPENMPI_BIN_DIR/mpicc --showme:link`"
# Specify system installed ThirdParty packages/libraries
# NB: The packages installed under $WM_THIRD_PARTY_DIR
# will always override these values.
# So build your ThirdParty directory accordingly.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# System installed CUDA
#export CUDA_SYSTEM=1
#export CUDA_DIR=path_to_system_installed_cuda
#export CUDA_BIN_DIR=$CUDA_DIR/bin
#export CUDA_LIB_DIR=$CUDA_DIR/lib
#export CUDA_INCLUDE_DIR=$CUDA_DIR/include
#export CUDA_ARCH=sm_20
# System installed Mesquite
#export MESQUITE_SYSTEM=1
export MESQUITE_DIR=$WM_THIRD_PARTY_DIR/packages/mesquite-2.1.2
export MESQUITE_BIN_DIR=$MESQUITE_DIR/bin
export MESQUITE_LIB_DIR=$MESQUITE_DIR/lib
export MESQUITE_INCLUDE_DIR=$MESQUITE_DIR/include
# System installed Metis
#export METIS_SYSTEM=1
export METIS_DIR=$WM_THIRD_PARTY_DIR/packages/metis-5.1.0
export METIS_BIN_DIR=$METIS_DIR/bin
export METIS_LIB_DIR=$METIS_DIR/lib
export METIS_INCLUDE_DIR=$METIS_DIR/include
# System installed ParMetis
#export PARMETIS_SYSTEM=1
export PARMETIS_DIR=$WM_THIRD_PARTY_DIR/packages/parmetis-4.0.3
export PARMETIS_BIN_DIR=$PARMETIS_DIR/bin
export PARMETIS_LIB_DIR=$PARMETIS_DIR/lib
export PARMETIS_INCLUDE_DIR=$PARMETIS_DIR/include
# System installed ParMGridgen
#export PARMGRIDGEN_SYSTEM=1
export PARMGRIDGEN_DIR=$WM_THIRD_PARTY_DIR/packages/ParMGridGen-1.0
export PARMGRIDGEN_BIN_DIR=$PARMGRIDGEN_DIR/bin
export PARMGRIDGEN_LIB_DIR=$PARMGRIDGEN_DIR/lib
export PARMGRIDGEN_INCLUDE_DIR=$PARMGRIDGEN_DIR/include
# System installed Libccmio
#export LIBCCMIO_SYSTEM=1
#export LIBCCMIO_DIR=path_to_system_installed_libccmio
#export LIBCCMIO_BIN_DIR=$LIBCCMIO_DIR/bin
#export LIBCCMIO_LIB_DIR=$LIBCCMIO_DIR/lib
#export LIBCCMIO_INCLUDE_DIR=$LIBCCMIO_DIR/include
# System installed Scotch
#export SCOTCH_SYSTEM=1
export SCOTCH_DIR=$WM_THIRD_PARTY_DIR/packages/scotch_6.0.0
export SCOTCH_BIN_DIR=$SCOTCH_DIR/bin
export SCOTCH_LIB_DIR=$SCOTCH_DIR/lib
export SCOTCH_INCLUDE_DIR=$SCOTCH_DIR/include
# System installed CMake
#export CMAKE_SYSTEM=1
#export CMAKE_DIR=path_to_system_installed_cmake
#export CMAKE_BIN_DIR=$CMAKE_DIR/bin
# System installed Python
#export PYTHON_SYSTEM=1
#export PYTHON_DIR=path_to_system_installed_python
#export PYTHON_BIN_DIR=$PYTHON_DIR/bin
# System installed PyFoam
#export PYFOAM_SYSTEM=1
#export PYFOAM_DIR=path_to_system_installed_python
#export PYFOAM_BIN_DIR=$PYFOAM_DIR/bin
# System installed hwloc
#export HWLOC_SYSTEM=1
#export HWLOC_DIR=path_to_system_installed_hwloc
#export HWLOC_BIN_DIR=$HWLOC_DIR/bin
# System installed Qt
# This is the only package we assume is system installed by default.
# So we don't use a variable called QT_SYSTEM, but instead a variable
# called QT_THIRD_PARTY in order to override to the ThirdParty QT
# package.
#
# If you choose to use the system installed version of QT, keep
# the variable QT_THIRD_PARTY commented, and uncomment the initialization
# of the variable QT_DIR and QT_BIN_DIR. Make sure both variables are
# properly initialized.
#
# If you choose instead to use the ThirdParty version of QT, only uncomment
# the variable QT_THIRD_PARTY and set it to 1. Keep the initialization
# of the variables QT_DIR nd QT_BIN_DIR commented. The QT ThirdParty scripts
# will take care of setting the variables QT_DIR and QT_BIN_DIR to the
# proper values.
#
#export QT_THIRD_PARTY=1
#export QT_DIR=path_to_system_installed_qt
#export QT_BIN_DIR=$QT_DIR/bin
# System installed ParaView
#export PARAVIEW_SYSTEM=1
#export PARAVIEW_DIR=path_to_system_installed_paraview
#export PARAVIEW_BIN_DIR=$PARAVIEW_DIR/bin
# System installed bison
#export BISON_SYSTEM=1
# System installed flex
#export FLEX_SYSTEM=1
# System installed m4
#export M4_SYSTEM=1
# Specify ParaView version
# ~~~~~~~~~~~~~~~~~~~~~~~~
#export ParaView_VERSION=git # eg, cvs/git version
#export ParaView_MAJOR=3.7
# System identifier for the FOAM CDash test harness on foam-extend
#
# By default, your system FQN/hostname will be used as the system identifier
# when publishing your test harness results on the FOAM CDash server
# on foam-extend.
# You can override your identifier using this environment variable
#export CDASH_SUBMIT_LOCAL_HOST_ID=choose_your_CDash_system_identifer
# Mac OS X MacPorts root directory.
# The default value is '/opt/local/etc/macports'.
# In order to disable the usage of MacPorts on Mac OSX, simply initialize this
# variable to a non-existing directory, or to a dummy value.
#export MACOSX_MACPORTS_ROOT="_not_using_"
# ThirdParty packages: build control variables
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# By enabling any of these variables, you will active the compilation and
# installation of the corresponding ThirdParty package
#
# For AllMake.stage1
#export WM_THIRD_PARTY_USE_GCC_492=1
#export WM_THIRD_PARTY_USE_GCC_484=1
#export WM_THIRD_PARTY_USE_GCC_463=1
#export WM_THIRD_PARTY_USE_GCC_451=1
#export WM_THIRD_PARTY_USE_GCC_445=1
#export WM_THIRD_PARTY_USE_PYTHON_27=1
#export WM_THIRD_PARTY_USE_M4_1416=1
#export WM_THIRD_PARTY_USE_BISON_27=1
#export WM_THIRD_PARTY_USE_FLEX_2535=1
#export WM_THIRD_PARTY_USE_CMAKE_322=1
#
# For AllMake.stage2
#export WM_THIRD_PARTY_USE_OPENMPI_184=1
#export WM_THIRD_PARTY_USE_OPENMPI_184_ConfigureAdditionalArgs='--enable-mpi-cxx --with-openib=/usr --with-openib-libdir=/usr/lib64'
#export WM_THIRD_PARTY_USE_OPENMPI_165=1
#export WM_THIRD_PARTY_USE_OPENMPI_165_ConfigureAdditionalArgs='--enable-mpi-cxx --with-openib=/usr --with-openib-libdir=/usr/lib64'
#export WM_THIRD_PARTY_USE_OPENMPI_15=1
#export WM_THIRD_PARTY_USE_OPENMPI_143=1
#export WM_THIRD_PARTY_USE_OPENMPI_141=1
#
# For AllMake.stage3
#export WM_THIRD_PARTY_USE_METIS_510=1
#export WM_THIRD_PARTY_USE_PARMGRIDGEN_10=1
#export WM_THIRD_PARTY_USE_LIBCCMIO_261=1
#export WM_THIRD_PARTY_USE_MESQUITE_212=1
#export WM_THIRD_PARTY_USE_SCOTCH_604=1
##export WM_THIRD_PARTY_USE_SCOTCH_600=1
#export WM_THIRD_PARTY_USE_PARMETIS_403=1
##export WM_THIRD_PARTY_USE_ZOLTAN_36=1
#export WM_THIRD_PARTY_USE_PYFOAM_064=1
#export WM_THIRD_PARTY_USE_HWLOC_1101=1
#export WM_THIRD_PARTY_USE_HWLOC_172=1
#
# For AllMake.stage4
#export WM_THIRD_PARTY_USE_QT_486=1
#export WM_THIRD_PARTY_USE_PARAVIEW_431=1
#export WM_THIRD_PARTY_USE_PARAVIEW_410=1
# Add in preset user preferences: will override site preferences
#if [ -e $WM_PROJECT_USER_DIR/etc/prefs.sh ]
#then
# _foamSource $WM_PROJECT_USER_DIR/etc/prefs.sh
#fi
# ----------------------------------------------------------------- end-of-file

View file

@ -250,6 +250,12 @@ OPENMPI)
_foamSource $WM_THIRD_PARTY_DIR/packages/$mpi_version/platforms/$WM_OPTIONS/etc/$mpi_version.sh
fi
# On windows set mpi_version explicitly
if [ "$WM_ARCH_BASE" == "mingw" ]
then
mpi_version=openmpi-1.6.1
fi
export FOAM_MPI_LIBBIN=$FOAM_LIBBIN/$mpi_version
unset mpi_version
;;
@ -498,6 +504,13 @@ esac
_foamAddLib $FOAM_MPI_LIBBIN
# Add DLLs on PATH for Windows (cannot use LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ "$WM_ARCH_BASE" == "mingw" ]
then
_foamAddPath $FOAM_LIBBIN $FOAM_LIBBIN/$mpi_version
fi
# Set the minimum MPI buffer size (used by all platforms except SGI MPI)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
minBufferSize=20000000

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
Copyright : (C) 2011 Symscape
Website : www.symscape.com
-------------------------------------------------------------------------------
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/>.
Class
MSwindows
Description
SourceFiles
MSwindows.C
\*---------------------------------------------------------------------------*/
#ifndef MSwindows_H
#define MSwindows_H
#include <string>
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace MSwindows
{
//- Declare name of the class and it's debug switch
NamespaceName("MSwindows");
//- Get last windows api error from GetLastError
std::string getLastError();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,14 @@
signals/sigFpe.C
signals/sigSegv.C
signals/sigInt.C
signals/sigQuit.C
regExp.C
timer.C
fileStat.C
MSwindows.C
cpuTime/cpuTime.C
clockTime/clockTime.C
multiThreader/multiThreader.C
printStack.C
LIB = $(FOAM_LIBBIN)/libOSspecific

View file

View file

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "clockTime.H"
#include "scalar.H"
#include <sys/time.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void clockTime::getTime(struct timeval& t)
{
gettimeofday(&t, NULL);
}
double clockTime::timeDifference
(
const struct timeval& start,
const struct timeval& end
)
{
return end.tv_sec - start.tv_sec + 1E-6*(end.tv_usec - start.tv_usec);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
clockTime::clockTime()
{
getTime(startTime_);
lastTime_ = startTime_;
newTime_ = startTime_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
double clockTime::elapsedTime() const
{
getTime(newTime_);
return timeDifference(startTime_, newTime_);
}
double clockTime::timeIncrement() const
{
lastTime_ = newTime_;
getTime(newTime_);
return timeDifference(lastTime_, newTime_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::clockTime
Description
Starts timing (using rtc) and returns elapsed time from start.
Better resolution (2uSec instead of ~20mSec) than cpuTime.
SourceFiles
clockTime.C
\*---------------------------------------------------------------------------*/
#ifndef clockTime_H
#define clockTime_H
#include <sys/types.h>
#include <sys/time.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class clockTime Declaration
\*---------------------------------------------------------------------------*/
class clockTime
{
// Private data
struct timeval startTime_;
mutable struct timeval lastTime_;
mutable struct timeval newTime_;
static void getTime(struct timeval& t);
static double timeDifference
(
const struct timeval& start,
const struct timeval& end
);
public:
// Constructors
//- Construct from components
clockTime();
// Member Functions
// Access
//- Returns CPU time from start of run
double elapsedTime() const;
//- Returns CPU time from last call of clockTimeIncrement()
double timeIncrement() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
Starts timing CPU usage and return elapsed time from start.
\*---------------------------------------------------------------------------*/
#include "cpuTime.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void cpuTime::getTime(std::clock_t& t)
{
t = std::clock();
}
double cpuTime::timeDifference
(
const std::clock_t& start,
const std::clock_t& end
)
{
const double difference = std::difftime(end, start) / CLOCKS_PER_SEC;
return difference;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cpuTime::cpuTime()
{
getTime(startTime_);
lastTime_ = startTime_;
newTime_ = startTime_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
double cpuTime::elapsedCpuTime() const
{
getTime(newTime_);
return timeDifference(startTime_, newTime_);
}
double cpuTime::cpuTimeIncrement() const
{
lastTime_ = newTime_;
getTime(newTime_);
return timeDifference(lastTime_, newTime_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cpuTime
Description
Starts timing CPU usage and return elapsed time from start.
SeeAlso
clockTime
SourceFiles
cpuTime.C
\*---------------------------------------------------------------------------*/
#ifndef cpuTime_H
#define cpuTime_H
#include <ctime>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cpuTime Declaration
\*---------------------------------------------------------------------------*/
class cpuTime
{
// Private data
std::clock_t startTime_;
mutable std::clock_t lastTime_;
mutable std::clock_t newTime_;
static void getTime(std::clock_t& t);
static double timeDifference
(
const std::clock_t& start,
const std::clock_t& end
);
public:
// Constructors
//- Construct from components
cpuTime();
// Member Functions
// Access
//- Returns CPU time from start of run
double elapsedCpuTime() const;
//- Returns CPU time from last call of cpuTimeIncrement()
double cpuTimeIncrement() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,202 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fileStat.H"
#include "IOstreams.H"
#include "timer.H"
#include <unistd.h>
#undef major
#undef minor
#undef makedev
# define major(dev) ((int)(((dev) >> 8) & 0xff))
# define minor(dev) ((int)((dev) & 0xff))
# define makedev(major, minor) ((((unsigned int) (major)) << 8) \
| ((unsigned int) (minor)))
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null
fileStat::fileStat()
:
isValid_(false)
{}
// Construct from components
fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
{
// Work on volatile
volatile bool locIsValid = false;
timer myTimer(maxTime);
if (!timedOut(myTimer))
{
if (::stat(fName.c_str(), &status_) != 0)
{
locIsValid = false;
}
else
{
locIsValid = true;
}
}
// Copy into (non-volatile, possible register based) member var
isValid_ = locIsValid;
}
// Construct from Istream.
fileStat::fileStat(Istream& is)
{
is >> *this;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// compare two fileStates for same device
bool fileStat::sameDevice(const fileStat& stat2) const
{
return
isValid_
&& (
major(status_.st_dev) == major(stat2.status().st_dev)
&& minor(status_.st_dev) == minor(stat2.status().st_dev)
);
}
// compare two fileStates for same Inode
bool fileStat::sameINode(const fileStat& stat2) const
{
return isValid_ && (status_.st_ino == stat2.status().st_ino);
}
// compare state against inode
bool fileStat::sameINode(const label iNode) const
{
return isValid_ && (status_.st_ino == ino_t(iNode));
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// Input in list syntax
Istream& operator>>(Istream& is, fileStat& fStat)
{
// Read beginning of machine info list
is.readBegin("fileStat");
label
devMaj, devMin,
ino, mode, uid, gid,
rdevMaj, rdevMin,
size, atime, mtime, ctime;
is >> fStat.isValid_
>> devMaj
>> devMin
>> ino
>> mode
>> uid
>> gid
>> rdevMaj
>> rdevMin
>> size
>> atime
>> mtime
>> ctime;
dev_t st_dev = makedev(devMaj, devMin);
fStat.status_.st_dev = st_dev;
fStat.status_.st_ino = ino;
fStat.status_.st_mode = mode;
fStat.status_.st_uid = uid;
fStat.status_.st_gid = gid;
dev_t st_rdev = makedev(rdevMaj, rdevMin);
fStat.status_.st_rdev = st_rdev;
fStat.status_.st_size = size;
fStat.status_.st_atime = atime;
fStat.status_.st_mtime = mtime;
fStat.status_.st_ctime = ctime;
// Read end of machine info list
is.readEnd("fileStat");
// Check state of Istream
is.check("Istream& operator>>(Istream&, fileStat&)");
return is;
}
// Output in list syntax
Ostream& operator<<(Ostream& os, const fileStat& fStat)
{
// Set precision so 32bit unsigned int can be printed
// int oldPrecision = os.precision();
int oldPrecision = 0;
os.precision(10);
os << token::BEGIN_LIST << fStat.isValid_
<< token::SPACE << label(major(fStat.status_.st_dev))
<< token::SPACE << label(minor(fStat.status_.st_dev))
<< token::SPACE << label(fStat.status_.st_ino)
<< token::SPACE << label(fStat.status_.st_mode)
<< token::SPACE << label(fStat.status_.st_uid)
<< token::SPACE << label(fStat.status_.st_gid)
<< token::SPACE << label(major(fStat.status_.st_rdev))
<< token::SPACE << label(minor(fStat.status_.st_rdev))
<< token::SPACE << label(fStat.status_.st_size)
<< token::SPACE << label(fStat.status_.st_atime)
<< token::SPACE << label(fStat.status_.st_mtime)
<< token::SPACE << label(fStat.status_.st_ctime)
<< token::END_LIST;
os.precision(oldPrecision);
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileStat
Description
Wrapper for stat() system call.
Warning
on Linux (an maybe on others) a stat() of an nfs mounted (remote)
file does never timeout and cannot be interrupted!
So e.g. Foam::ping first and hope nfs is running.
SourceFiles
fileStat.C
\*---------------------------------------------------------------------------*/
#ifndef fileStat_H
#define fileStat_H
#include <sys/stat.h>
#include <sys/types.h>
#include "label.H"
#include "fileName.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fileStat Declaration
\*---------------------------------------------------------------------------*/
class fileStat
{
// Private data
struct stat status_;
bool isValid_;
public:
// Constructors
//- Empty constructor
fileStat();
//- Construct from components
fileStat(const fileName& fName, const unsigned int maxTime=0);
//- Construct from Istream
fileStat(Istream&);
// Member Functions
// Access
//- Raw status
const struct stat& status() const
{
return status_;
}
//- Did constructor fail
bool isValid() const
{
return isValid_;
}
// Check
//- compare two fileStats for same device
bool sameDevice(const fileStat& stat2) const;
//- compare two fileStats for same Inode
bool sameINode(const fileStat& stat2) const;
//- compare state against inode
bool sameINode(const label iNode) const;
// IOstream Operators
friend Istream& operator>>(Istream&, fileStat&);
friend Ostream& operator<<(Ostream&, const fileStat&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,707 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
multiThreader
Description
Implementation of the multiThreader class
Author
Sandeep Menon
University of Massachusetts Amherst
\*----------------------------------------------------------------------------*/
#include "multiThreader.H"
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(IOmultiThreader, 0);
bool multiThreader::debug = false;
bool Mutex::debug = false;
bool rwMutex::debug = false;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
multiThreader::multiThreader(int numThreads)
:
maxQueueSize_(10),
poolInfo_(NULL)
{
if (numThreads > 0)
{
numThreads_ = numThreads;
if (debug)
{
Info << "Initializing threading environment with "
<< numThreads_ << " threads." << endl;
}
}
else
{
// Default number of threads at one (single-threaded)
numThreads_ = 1;
if (debug)
{
Info << "Defaulting threading environment to one thread." << endl;
}
}
// Initialize the thread pool
initializeThreadPool();
}
Mutex::Mutex()
{
// Set attributes based on debug flag
pthread_mutexattr_t attribute;
pthread_mutexattr_init(&attribute);
if (debug)
{
pthread_mutexattr_settype(&attribute, PTHREAD_MUTEX_ERRORCHECK);
}
else
{
pthread_mutexattr_settype(&attribute, PTHREAD_MUTEX_NORMAL);
}
if (pthread_mutex_init(&lock_, &attribute))
{
FatalErrorIn("multiThreader::Mutex::Mutex()")
<< "Unable to initialize mutex"
<< abort(FatalError);
}
// Destroy the attribute
pthread_mutexattr_destroy(&attribute);
}
rwMutex::rwMutex()
{
// Set attributes for the mutex
pthread_rwlockattr_t attribute;
pthread_rwlockattr_init(&attribute);
if (pthread_rwlock_init(&lock_, &attribute))
{
FatalErrorIn("multiThreader::rwMutex::rwMutex()")
<< "Unable to initialize read-write mutex"
<< abort(FatalError);
}
// Destroy the attribute
pthread_rwlockattr_destroy(&attribute);
}
Conditional::Conditional()
{
if (pthread_cond_init(&condition_, NULL))
{
FatalErrorIn("multiThreader::Conditional::Conditional()")
<< "Unable to initialize condition"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
multiThreader::~multiThreader()
{
destroyThreadPool();
}
Mutex::~Mutex()
{
if (pthread_mutex_destroy(&lock_))
{
FatalErrorIn("multiThreader::Mutex::~Mutex()")
<< "Unable to destroy mutex"
<< abort(FatalError);
}
}
rwMutex::~rwMutex()
{
if (pthread_rwlock_destroy(&lock_))
{
FatalErrorIn("multiThreader::rwMutex::~rwMutex()")
<< "Unable to destroy read-write mutex"
<< abort(FatalError);
}
}
Conditional::~Conditional()
{
if (pthread_cond_destroy(&condition_))
{
FatalErrorIn("multiThreader::Conditional::~Conditional()")
<< "Unable to destroy condition"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * //
void multiThreader::initializeThreadPool()
{
// Initialize threads only if multi-threaded
if (multiThreaded())
{
// Allocate the threadPool structure
poolInfo_ = new threadPool;
// Initialize fields
poolInfo_->threader = this;
poolInfo_->numThreads = numThreads_;
poolInfo_->queueSize = 0;
poolInfo_->threads = new pthread_t[numThreads_];
poolInfo_->head = NULL;
poolInfo_->tail = NULL;
// Initialize flags
poolInfo_->queueClosed = false;
poolInfo_->shutDown = false;
// Initialize thread attributes
pthread_attr_init(&(poolInfo_->attr));
pthread_attr_setdetachstate
(
&(poolInfo_->attr),
PTHREAD_CREATE_JOINABLE
);
// Create worker threads and have them wait for jobs
for (int tIndex = 0; tIndex < numThreads_; tIndex++)
{
int status = pthread_create
(
&(poolInfo_->threads[tIndex]),
&(poolInfo_->attr),
reinterpret_cast<externThreadFunctionType>
(
poolThread
),
reinterpret_cast<void *>
(
poolInfo_
)
);
if (status != 0)
{
FatalErrorIn("multiThreader::initializeThreadPool()")
<< "pthread_create could not initialize thread: "
<< tIndex
<< abort(FatalError);
}
}
}
}
threadReturnType multiThreader::poolThread(void *arg)
{
// Typecast the argument into the required structure
threadPool *poolInfo = reinterpret_cast<threadPool *>(arg);
// Work queue loop
while (true)
{
// Lock the work queue
poolInfo->queueLock.lock();
// Wait for work to arrive in the queue
while ((poolInfo->queueSize == 0) && (!poolInfo->shutDown))
{
# ifdef FULLDEBUG
if (debug)
{
Info << "poolThread::Wait on queueNotEmpty." << endl;
}
# endif
poolInfo->threader->waitForCondition
(
poolInfo->queueNotEmpty,
poolInfo->queueLock
);
}
// Check for shutdown
if (poolInfo->shutDown)
{
poolInfo->queueLock.unlock();
pthread_exit(NULL);
}
// Pick an item off the queue, and get to work
workQueueItem *myWorkItem = poolInfo->head;
poolInfo->queueSize--;
if (poolInfo->queueSize == 0)
{
poolInfo->head = poolInfo->tail = NULL;
}
else
{
poolInfo->head = myWorkItem->next;
}
// Handle a waiting destructor
if (poolInfo->queueSize == 0)
{
# ifdef FULLDEBUG
if (debug)
{
Info << "poolThread::Signaling: Empty queue." << endl;
}
# endif
poolInfo->threader->signal(poolInfo->queueEmpty);
}
// Unlock the work queue
poolInfo->queueLock.unlock();
// Perform the work
myWorkItem->function(myWorkItem->arg);
// Free up the work item
delete myWorkItem;
}
return threadReturnValue;
}
void multiThreader::addToWorkQueue
(
void (*tFunction)(void*),
void *arg
) const
{
if (singleThreaded())
{
# ifdef FULLDEBUG
if (debug)
{
Info << "addToWorkQueue:: Not in multiThreaded mode." << endl;
}
# endif
return;
}
// Lock the work queue
poolInfo_->queueLock.lock();
// If occupied, wait for the queue to free-up
while
(
(poolInfo_->queueSize == maxQueueSize_)
&& (!(poolInfo_->shutDown || poolInfo_->queueClosed))
)
{
# ifdef FULLDEBUG
if (debug)
{
Info << "addToWorkQueue:: Wait on queueNotFull." << endl;
}
# endif
waitForCondition(poolInfo_->queueNotFull, poolInfo_->queueLock);
}
// Is the pool in the process of being destroyed?
// Unlock the mutex and return to caller.
if (poolInfo_->shutDown || poolInfo_->queueClosed)
{
poolInfo_->queueLock.unlock();
return;
}
// Allocate a new work structure
workQueueItem *newWorkItem = new workQueueItem;
newWorkItem->function = tFunction;
newWorkItem->arg = arg;
newWorkItem->next = NULL;
// Add new work structure to the queue
if (poolInfo_->queueSize == 0)
{
poolInfo_->tail = poolInfo_->head = newWorkItem;
broadCast(poolInfo_->queueNotEmpty);
}
else
{
poolInfo_->tail->next = newWorkItem;
poolInfo_->tail = newWorkItem;
}
poolInfo_->queueSize++;
// Unlock the work queue
poolInfo_->queueLock.unlock();
}
void multiThreader::destroyThreadPool()
{
// Destroy threads only if multi-threaded
if (multiThreaded())
{
// Lock the work queue
poolInfo_->queueLock.lock();
// Is a shutdown already in progress?
if (poolInfo_->queueClosed || poolInfo_->shutDown)
{
// Unlock the mutex and return
poolInfo_->queueLock.unlock();
return;
}
poolInfo_->queueClosed = true;
// Wait for workers to drain the queue
while (poolInfo_->queueSize != 0)
{
waitForCondition(poolInfo_->queueEmpty, poolInfo_->queueLock);
}
poolInfo_->shutDown = true;
// Unlock the work queue
poolInfo_->queueLock.unlock();
// Wake up workers so that they check the shutdown flag
broadCast(poolInfo_->queueNotEmpty);
broadCast(poolInfo_->queueNotFull);
// Wait for all workers to exit
for(int i=0; i < numThreads_; i++)
{
if (pthread_join(poolInfo_->threads[i],NULL))
{
FatalErrorIn("multiThreader::destroyThreadPool()")
<< "pthread_join failed."
<< abort(FatalError);
}
}
// Destroy the attribute
pthread_attr_destroy(&(poolInfo_->attr));
// Deallocate the work-queue and pool structure
delete [] poolInfo_->threads;
workQueueItem *currentNode;
while(poolInfo_->head != NULL)
{
currentNode = poolInfo_->head->next;
poolInfo_->head = poolInfo_->head->next;
delete currentNode;
}
delete poolInfo_;
}
}
void multiThreader::waitForCondition
(
Conditional& condition,
Mutex& mutex
) const
{
if (pthread_cond_wait(condition(),mutex()))
{
FatalErrorIn("multiThreader::waitForCondition()")
<< "Conditional wait failed."
<< abort(FatalError);
}
}
void multiThreader::broadCast(Conditional& condition) const
{
if (pthread_cond_broadcast(condition()))
{
FatalErrorIn("multiThreader::broadCast()")
<< "Unable to broadcast."
<< abort(FatalError);
}
}
void multiThreader::signal(Conditional& condition) const
{
if (pthread_cond_signal(condition()))
{
FatalErrorIn("multiThreader::signal()")
<< "Unable to signal."
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the number of threads
int multiThreader::getNumThreads() const
{
return numThreads_;
}
//- Obtain the thread ID for a given index
pthread_t multiThreader::getID(int index) const
{
if (multiThreaded())
{
if (poolInfo_ && index > -1 && index < numThreads_)
{
return poolInfo_->threads[index];
}
else
{
FatalErrorIn("multiThreader::getID(int index)")
<< "Invalid request for ID."
<< abort(FatalError);
}
}
return pthread_self();
}
//- Return true if the number of threads is equal to one.
bool multiThreader::singleThreaded() const
{
return (numThreads_ == 1);
}
//- Return true if the number of threads is more than one.
bool multiThreader::multiThreaded() const
{
return (numThreads_ > 1);
}
//- Return the maxQueueSize
int multiThreader::getMaxQueueSize() const
{
return maxQueueSize_;
}
//- Set the maxQueueSize
void multiThreader::setMaxQueueSize(int size) const
{
if (size > 0)
{
maxQueueSize_ = size;
}
else
{
FatalErrorIn("multiThreader::setMaxQueueSize(int size)")
<< "Improper value for MaxQueueSize."
<< abort(FatalError);
}
}
void Mutex::lock() const
{
if (pthread_mutex_lock(&lock_))
{
FatalErrorIn("multiThreader::Mutex::lock()")
<< "Unable to lock mutex."
<< abort(FatalError);
}
}
bool Mutex::tryLock() const
{
label retVal;
if ((retVal = pthread_mutex_trylock(&lock_)) != 0)
{
# ifdef FULLDEBUG
if (debug)
{
if (retVal == EINVAL)
{
FatalErrorIn("multiThreader::Mutex::trylock()")
<< "Mutex returned EINVAL."
<< abort(FatalError);
}
if (retVal == EFAULT)
{
FatalErrorIn("multiThreader::Mutex::trylock()")
<< "Mutex returned EFAULT."
<< abort(FatalError);
}
}
# endif
}
return retVal;
}
void Mutex::unlock() const
{
if (pthread_mutex_unlock(&lock_))
{
FatalErrorIn("multiThreader::Mutex::unlock()")
<< "Unable to unlock the mutex."
<< abort(FatalError);
}
}
void rwMutex::lock(const lockType lType) const
{
if (lType == READ_LOCK)
{
if (pthread_rwlock_rdlock(&lock_))
{
FatalErrorIn("multiThreader::rwMutex::lock()")
<< "Unable to read lock the mutex."
<< abort(FatalError);
}
}
else
if (lType == WRITE_LOCK)
{
if (pthread_rwlock_wrlock(&lock_))
{
FatalErrorIn("multiThreader::rwMutex::lock()")
<< "Unable to write lock the mutex."
<< abort(FatalError);
}
}
else
{
FatalErrorIn("multiThreader::rwMutex::lock()")
<< "Undefined mutex type."
<< abort(FatalError);
}
}
bool rwMutex::tryLock(const lockType lType) const
{
label retVal = -1;
if (lType == READ_LOCK)
{
if ((retVal = pthread_rwlock_tryrdlock(&lock_)) != 0)
{
if (retVal == EINVAL)
{
FatalErrorIn("multiThreader::rwMutex::tryLock()")
<< "Read mutex returned EINVAL."
<< abort(FatalError);
}
if (retVal == EFAULT)
{
FatalErrorIn("multiThreader::rwMutex::tryLock()")
<< "Read mutex returned EFAULT."
<< abort(FatalError);
}
}
}
else
if (lType == WRITE_LOCK)
{
if ((retVal = pthread_rwlock_trywrlock(&lock_)) != 0)
{
if (retVal == EINVAL)
{
FatalErrorIn("multiThreader::rwMutex::tryLock()")
<< "Write mutex returned EINVAL."
<< abort(FatalError);
}
if (retVal == EFAULT)
{
FatalErrorIn("multiThreader::rwMutex::tryLock()")
<< "Write mutex returned EFAULT."
<< abort(FatalError);
}
}
}
else
{
FatalErrorIn("multiThreader::rwMutex::tryLock()")
<< "Undefined mutex type."
<< abort(FatalError);
}
return retVal;
}
void rwMutex::unlock() const
{
if (pthread_rwlock_unlock(&lock_))
{
FatalErrorIn("multiThreader::rwMutex::unlock()")
<< "Unable to unlock the read-write mutex."
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void multiThreader::operator=(const multiThreader& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn("multiThreader::operator=(const multiThreader&)")
<< "Attempted assignment to self"
<< abort(FatalError);
}
}
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,324 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
multiThreader
Description
Class which provides support for generic multi-threaded execution of class
methods using POSIX threads.
The IOmultiThreader is an inherited class which allows integration with
the object registry, thereby allowing a single multi-threader object to
be accessed by multiple classes in a global sense.
Thread-pooling is implemented as described in:
"Using POSIX Threads: Programming with Pthreads"
by Brad Nichols, Dick Buttlar, Jackie Farrell
O'Reilly & Associates, Inc.
Author
Sandeep Menon
University of Massachusetts Amherst
SourceFiles
multiThreader.C
\*---------------------------------------------------------------------------*/
#ifndef multiThreader_H
#define multiThreader_H
#include "error.H"
#include "regIOobject.H"
#include <pthread.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
extern "C"
{
typedef void *(*externThreadFunctionType)(void *);
}
typedef void *(*threadFunctionType)(void *);
#define threadReturnType void *
#define threadReturnValue NULL
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Mutex
{
// Private data
mutable pthread_mutex_t lock_;
public:
// Debug switch
static bool debug;
// Constructor
Mutex();
// Destructor
~Mutex();
// Lock the mutex
void lock() const;
// Try to acquire the mutex.
// Returns zero if successful
bool tryLock() const;
// Unlock the mutex
void unlock() const;
// Operator overload
inline pthread_mutex_t* operator()()
{
return &lock_;
}
};
class rwMutex
{
// Private data
mutable pthread_rwlock_t lock_;
public:
// Enumerants for lock-types
enum lockType
{
READ_LOCK,
WRITE_LOCK
};
// Debug switch
static bool debug;
// Constructor
rwMutex();
// Destructor
~rwMutex();
// Lock the mutex
void lock(const lockType lType) const;
// Try to acquire a lock
bool tryLock(const lockType lType) const;
// Unlock the mutex
void unlock() const;
// Operator overload
inline pthread_rwlock_t* operator()()
{
return &lock_;
}
};
class Conditional
{
// Private data
mutable pthread_cond_t condition_;
public:
// Constructor
Conditional();
// Destructor
~Conditional();
// Operator overload
inline pthread_cond_t* operator()()
{
return &condition_;
}
};
/*---------------------------------------------------------------------------*\
Class multiThreader Declaration
\*---------------------------------------------------------------------------*/
class multiThreader
{
// Private data
mutable int numThreads_;
mutable int maxQueueSize_;
// Work-queue item: Holds a pointer to the method and its argument
struct workQueueItem
{
void (*function)(void*);
void *arg;
workQueueItem *next;
};
// Common structure for all threads in the pool.
mutable struct threadPool
{
multiThreader *threader;
int numThreads;
int queueSize;
pthread_t *threads;
pthread_attr_t attr;
workQueueItem *head, *tail;
// Flags
bool queueClosed;
bool shutDown;
// Synchronization
Mutex queueLock;
Conditional queueNotEmpty;
Conditional queueNotFull;
Conditional queueEmpty;
} *poolInfo_;
// Private Member Functions
void initializeThreadPool();
static threadReturnType poolThread(void *arg);
void destroyThreadPool();
//- Disallow default bitwise copy construct
multiThreader(const multiThreader&);
//- Disallow default bitwise assignment
void operator=(const multiThreader&);
public:
// Debug switch
static bool debug;
// Constructor
//- Construct with specified number of threads
multiThreader(int numThreads);
// Destructor
~multiThreader();
// Member Functions
//- Return the number of threads
int getNumThreads() const;
//- Obtain the thread ID for a given index
pthread_t getID(int index) const;
//- Return true if the number of threads is equal to one.
bool singleThreaded() const;
//- Return true if the number of threads is more than one.
bool multiThreaded() const;
//- Return the maxQueueSize
int getMaxQueueSize() const;
//- Set the maxQueueSize
void setMaxQueueSize(int size) const;
//- Add a function to the work queue
void addToWorkQueue(void (*tFunction)(void*), void *arg) const;
//- Conditional handling
void waitForCondition(Conditional&, Mutex&) const;
void broadCast(Conditional&) const;
void signal(Conditional&) const;
};
/*---------------------------------------------------------------------------*\
Class IOmultiThreader Declaration
\*---------------------------------------------------------------------------*/
class IOmultiThreader
:
public regIOobject,
public multiThreader
{
// Member functions
//- Disallow default bitwise copy construct
IOmultiThreader(const IOmultiThreader&);
//- Disallow default bitwise assignment
void operator=(const IOmultiThreader&);
public:
//- Runtime type information
TypeName("multiThreader");
// Constructors
//- Construct from IOobject and specified number of threads
IOmultiThreader(const IOobject& io, int numThreads)
:
regIOobject(io),
multiThreader(numThreads)
{}
// Destructor
virtual ~IOmultiThreader() {}
// Member functions
bool writeData(Ostream&) const
{
return true;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,214 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
threadHandler
Description
Helper class used to assist in multi-threading and synchronization.
Use this class to pass information to a threaded static member-function
belonging to the class T.
Author
Sandeep Menon
University of Massachusetts Amherst
All rights reserved
SourceFiles
threadHandlerI.H
\*---------------------------------------------------------------------------*/
#ifndef threadHandler_H
#define threadHandler_H
#include "FixedList.H"
#include "List.H"
#include "multiThreader.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class threadHandler Declaration
\*---------------------------------------------------------------------------*/
template<class T>
class threadHandler
{
// Reference to the template class
T& tRef_;
// Reference to the multiThreader class
const multiThreader& threader_;
// List of function argument pointers
List<void *> argList_;
// Total number of threads
const label nThreads_;
// ID generated by the pthreads API
pthread_t pthreadID_;
// Is this a master/slave thread
mutable bool master_;
// Synchronization mutexes
mutable Mutex startMutex_;
mutable Mutex stopMutex_;
// Conditionals for synchronization
mutable Conditional startConditional_;
mutable Conditional stopConditional_;
// On some implementations, a conditional wait
// might return prematurely due to a spurious
// wake-up signal. Use a predicate to avoid this
// behaviour.
mutable FixedList<bool, 2> predicate_;
public:
// Enumerants for signalling
enum signalType
{
START,
STOP
};
// Constructor
threadHandler
(
T& tPtr,
const multiThreader& threader
);
// Destructor
~threadHandler();
// Return a reference to the template class
inline T& reference();
// Set a size for the argument list
inline void setSize(const label size);
// Set a argument pointer for a particular index
inline void set(const label index, void* argPtr);
// Return a reference to the multiThreader
inline const multiThreader& threader() const;
// Return the number of threads
inline label nThreads() const;
// Designate as master thread
inline void setMaster() const;
// Designate as slave thread
inline void setSlave() const;
// Is this a master thread?
inline bool master() const;
// Is this a slave thread?
inline bool slave() const;
// Lock this thread
inline void lock(const signalType sType) const;
// Unlock this thread
inline void unlock(const signalType sType) const;
// Send signal to a waiting conditional
inline void sendSignal(const signalType sType) const;
// Wait for signal
inline void waitForSignal(const signalType sType) const;
// Return state of the predicate variable
inline bool predicate(const signalType sType) const;
// Set the predicate variable
inline void setPredicate(const signalType sType) const;
// Unset the predicate variable
inline void unsetPredicate(const signalType sType) const;
// Set the ID
inline void setID(const pthread_t& pt);
// Return the ID
inline pthread_t ID() const;
// Does the calling thread correspond to this handler?
inline bool self() const;
// Return an argument pointer at a particular index
inline void * operator()(const label index);
};
// Lock all threads provided by sequence
template <class T>
void lockThreads
(
const List<label>& sequence,
const PtrList<threadHandler<T> >& handler
);
// Synchronize all threads provided by sequence
template <class T>
void synchronizeThreads
(
const List<label>& sequence,
const PtrList<threadHandler<T> >& handler
);
// Execute threads for the submitted static function by sequence
template <class T>
void executeThreads
(
const List<label>& sequence,
PtrList<threadHandler<T> >& handler,
void (*tFunction)(void*)
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "threadHandlerI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,467 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Constructor for threadHandler
template<class T>
threadHandler<T>::threadHandler
(
T& tRef,
const multiThreader& threader
)
:
tRef_(tRef),
threader_(threader),
argList_(0),
nThreads_(threader.getNumThreads()),
pthreadID_(pthread_self()),
master_(false),
predicate_(false)
{}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * //
template<class T>
threadHandler<T>::~threadHandler()
{
// Null the argument list pointer copies
// to avoid multiple deallocations.
forAll(argList_, indexI)
{
argList_[indexI] = NULL;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Return a reference to the template class
template<class T>
inline T& threadHandler<T>::reference()
{
return tRef_;
}
// Set a size for the argument list
template<class T>
inline void threadHandler<T>::setSize
(
const label size
)
{
argList_.setSize(size, NULL);
}
// Set a argument pointer for a particular index
template<class T>
inline void threadHandler<T>::set
(
const label index,
void* argPtr
)
{
if (!argList_.size())
{
FatalErrorIn("threadHandler<T>::set")
<< "Attempt to access element from zero sized list"
<< abort(FatalError);
}
else
if (index < 0 || index >= argList_.size())
{
FatalErrorIn("threadHandler<T>::set")
<< "index " << index << " out of range 0 ... "
<< argList_.size()-1
<< abort(FatalError);
}
argList_[index] = argPtr;
}
// Return a reference to the multiThreader
template<class T>
inline const multiThreader& threadHandler<T>::threader() const
{
return threader_;
}
// Return the number of threads
template<class T>
inline label threadHandler<T>::nThreads() const
{
return nThreads_;
}
// Designate as master thread
template<class T>
inline void threadHandler<T>::setMaster() const
{
master_ = true;
}
// Designate as slave thread
template<class T>
inline void threadHandler<T>::setSlave() const
{
master_ = false;
}
// Is this a master thread?
template<class T>
inline bool threadHandler<T>::master() const
{
return (master_ == true);
}
// Is this a slave thread?
template<class T>
inline bool threadHandler<T>::slave() const
{
return !master();
}
// Lock this thread
template<class T>
inline void threadHandler<T>::lock
(
const signalType sType
) const
{
if (sType == START)
{
startMutex_.lock();
}
else
if (sType == STOP)
{
stopMutex_.lock();
}
}
// Unlock this thread
template<class T>
inline void threadHandler<T>::unlock
(
const signalType sType
) const
{
if (sType == START)
{
startMutex_.unlock();
}
else
if (sType == STOP)
{
stopMutex_.unlock();
}
}
// Send signal to a waiting conditional
template<class T>
inline void threadHandler<T>::sendSignal
(
const signalType sType
) const
{
lock(sType);
if (predicate(sType))
{
InfoIn("threadHandler::sendSignal()")
<< "Predicate is already set."
<< endl;
}
else
{
// Set predicate before signalling
setPredicate(sType);
}
if (sType == START)
{
threader().signal
(
startConditional_
);
}
else
if (sType == STOP)
{
threader().signal
(
stopConditional_
);
}
else
{
FatalErrorIn("threadHandler::sendSignal()")
<< "Undefined enumerant."
<< abort(FatalError);
}
unlock(sType);
}
// Wait for signal
template<class T>
inline void threadHandler<T>::waitForSignal
(
const signalType sType
) const
{
if (sType == START)
{
threader().waitForCondition
(
startConditional_,
startMutex_
);
}
else
if (sType == STOP)
{
threader().waitForCondition
(
stopConditional_,
stopMutex_
);
}
else
{
FatalErrorIn("threadHandler::waitForSignal()")
<< "Undefined enumerant."
<< abort(FatalError);
}
if (!predicate(sType))
{
FatalErrorIn("threadHandler::waitForSignal()")
<< "Spurious wake-up."
<< abort(FatalError);
}
unsetPredicate(sType);
// Unlock the acquired mutex
unlock(sType);
}
// Return state of the predicate variable
template<class T>
inline bool threadHandler<T>::predicate
(
const signalType sType
) const
{
return predicate_[sType];
}
// Set the predicate variable
template<class T>
inline void threadHandler<T>::setPredicate
(
const signalType sType
) const
{
predicate_[sType] = true;
}
// Unset the predicate variable
template<class T>
inline void threadHandler<T>::unsetPredicate
(
const signalType sType
) const
{
predicate_[sType] = false;
}
// Return the ID
template<class T>
inline void threadHandler<T>::setID(const pthread_t& pt)
{
pthreadID_ = pt;
}
// Return the ID
template<class T>
inline pthread_t threadHandler<T>::ID() const
{
return pthreadID_;
}
// Does the calling thread correspond to this handler?
template<class T>
inline bool threadHandler<T>::self() const
{
return pthread_equal(ID(), pthread_self());
}
// Return an argument pointer at a particular index
template<class T>
inline void * threadHandler<T>::operator()
(
const label index
)
{
if (!argList_.size())
{
FatalErrorIn("threadHandler<T>::operator()")
<< "Attempt to access element from zero sized list"
<< abort(FatalError);
}
else
if (index < 0 || index >= argList_.size())
{
FatalErrorIn("threadHandler<T>::operator()")
<< "index " << index << " out of range 0 ... "
<< argList_.size()-1
<< abort(FatalError);
}
else
if (!argList_[index])
{
FatalErrorIn("threadHandler<T>::operator()")
<< "Hanging pointer. This is not allowed."
<< abort(FatalError);
}
return argList_[index];
}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// Lock all threads provided by sequence
template <class T>
void lockThreads
(
const List<label>& sequence,
const PtrList<threadHandler<T> >& handler
)
{
forAll(sequence, i)
{
handler[sequence[i]].lock(threadHandler<T>::START);
handler[sequence[i]].lock(threadHandler<T>::STOP);
handler[sequence[i]].unsetPredicate(threadHandler<T>::START);
handler[sequence[i]].unsetPredicate(threadHandler<T>::STOP);
}
}
// Synchronize all threads provided by sequence
template <class T>
void synchronizeThreads
(
const List<label>& sequence,
const PtrList<threadHandler<T> >& handler
)
{
forAll(sequence, i)
{
// Wait for a signal from this thread before moving on.
handler[sequence[i]].waitForSignal(threadHandler<T>::STOP);
}
}
// Execute threads for the submitted static function by sequence
template <class T>
void executeThreads
(
const List<label>& sequence,
PtrList<threadHandler<T> >& handler,
void (*tFunction)(void*)
)
{
if (!handler.size())
{
FatalErrorIn
(
"\n\n"
"template <class T>\n"
"void executeThreads\n"
"(\n"
" const List<label>& sequence,\n"
" PtrList<threadHandler<T> >& handler,\n"
" void (*tFunction)(void*)\n"
")\n"
)
<< "Empty handler list."
<< abort(FatalError);
}
// Fetch threader reference
const multiThreader& threader = handler[0].threader();
// Lock slave threads by sequence
lockThreads(sequence, handler);
forAll(sequence, i)
{
// Submit jobs to the work queue
threader.addToWorkQueue(tFunction, &(handler[sequence[i]]));
// Wait for a signal from this thread before moving on.
handler[sequence[i]].waitForSignal(threadHandler<T>::START);
}
// Synchronize threads
synchronizeThreads(sequence, handler);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,440 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "OSspecific.H"
#include "IFstream.H"
#include "readHexLabel.H"
#include <cxxabi.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <search.h>
#include <stdio.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
string pOpen(const string &cmd, label line=0)
{
const int MAX = 1000;
FILE *cmdPipe = popen(cmd.c_str(), "r");
if (cmdPipe)
{
// Read line number of lines
for (label cnt = 0; cnt <= line; cnt++)
{
char buffer[MAX];
char* s = fgets(buffer, MAX-1, cmdPipe);
if (s == NULL)
{
#ifdef darwin
// workaround for the Python-Script
for(int i=0;i<MAX;i++) {
if(buffer[i]=='\n') {
buffer[i]='\0';
}
}
return buffer;
#else
return "";
#endif
}
if (cnt == line)
{
string str(buffer);
return str.substr(0, str.size()-1);
}
}
pclose(cmdPipe);
}
return "";
}
// use popen to call addr2line (using bfd.h directly would have
// meant relinking everything)
void printSourceFileAndLine
(
Ostream& os,
const HashTable<label, fileName>& addressMap,
const fileName& filename,
const word& address
)
{
word myAddress = address;
#ifndef darwin
if (filename.ext() == "so")
#else
if (filename.ext() == "dylib")
#endif
{
// Convert offset into .so into offset into executable.
void *addr;
sscanf(myAddress.c_str(), "%p",&addr);
//Dl_info info;
//dladdr(addr, &info);
unsigned long offset(0);// = reinterpret_cast<unsigned long>(info.dli_fbase);
IStringStream addressStr(address.substr(2));
label addressValue = readHexLabel(addressStr);
label relativeAddress = addressValue-offset;
// Reconstruct hex word from address
OStringStream nStream;
nStream << "0x" << hex << relativeAddress;
myAddress = nStream.str();
}
if (filename[0] == '/')
{
string line = pOpen
(
#ifndef darwin
"addr2line -f --demangle=auto --exe "
#else
// "gaddr2line -f --inline --demangle=auto --exe "
"addr2line4Mac.py "
#endif
+ filename
+ " "
+ myAddress,
1
);
if (line == "")
{
os << " addr2line failed";
}
else if (line == "??:0")
{
os << " in " << filename;
}
else
{
string cwdLine(line.replaceAll(cwd() + '/', ""));
string homeLine(cwdLine.replaceAll(home(), '~'));
os << " at " << homeLine.c_str();
}
}
}
#ifdef darwin
// Trying to emulate the original backtrace and backtrace_symbol from the glibc
// After an idea published by Rush Manbert at http://lists.apple.com/archives/xcode-users/2006/Apr/msg00528.html
template<int level>
void *getStackAddress()
{
const unsigned int stackLevel=level;
return (
__builtin_frame_address(level)
? __builtin_return_address(stackLevel)
: (void *)0
);
};
#define GET_STACK_ADDRESS(lvl) \
case lvl: {return getStackAddress<lvl>(); break; }
// please don't laugh. For some reason this is necessary (the compiler won't accept it otherwise)
void *getStackAddress(int level)
{
switch(level) {
GET_STACK_ADDRESS(0);
GET_STACK_ADDRESS(1);
GET_STACK_ADDRESS(2);
GET_STACK_ADDRESS(3);
GET_STACK_ADDRESS(4);
GET_STACK_ADDRESS(5);
GET_STACK_ADDRESS(6);
GET_STACK_ADDRESS(7);
GET_STACK_ADDRESS(8);
GET_STACK_ADDRESS(9);
GET_STACK_ADDRESS(10);
GET_STACK_ADDRESS(11);
GET_STACK_ADDRESS(12);
GET_STACK_ADDRESS(13);
GET_STACK_ADDRESS(14);
GET_STACK_ADDRESS(15);
GET_STACK_ADDRESS(16);
GET_STACK_ADDRESS(17);
GET_STACK_ADDRESS(18);
GET_STACK_ADDRESS(19);
GET_STACK_ADDRESS(20);
GET_STACK_ADDRESS(21);
default:
return (void *)0;
break;
}
}
unsigned backtrace(void **bt, unsigned maxAddrs)
{
unsigned valid=0;
bool ok=true;
for(int level=0;level<maxAddrs;level++) {
if(ok) {
bt[level]=getStackAddress(level);
if(bt[level]!=(void *)0) {
valid=level;
} else {
ok=false;
}
} else {
bt[level]=(void *)0;
}
}
return valid;
}
// This function is a potential memory leak. But I don't care because the program is terminating anyway
char **backtrace_symbols(void **bt,unsigned nr)
{
char **strings=(char **)malloc(sizeof(char *)*nr);
for(unsigned i=0;i<nr;i++) {
Dl_info info;
int result=dladdr(bt[i],&info);
char tmp[1000];
#ifdef darwinIntel64
sprintf(tmp,"%s(%s+%p) [%p]",info.dli_fname,info.dli_sname,(void *)((unsigned long)bt[i]-(unsigned long)info.dli_saddr),bt[i]);
#else
sprintf(tmp,"%s(%s+%p) [%p]",info.dli_fname,info.dli_sname,(void *)((unsigned int)bt[i]-(unsigned int)info.dli_saddr),bt[i]);
#endif
strings[i]=(char *)malloc(strlen(tmp)+1);
strcpy(strings[i],tmp);
}
return strings;
}
#endif
void getSymbolForRaw
(
Ostream& os,
const string& raw,
const fileName& filename,
const word& address
)
{
if (filename.size() && filename[0] == '/')
{
string fcnt = pOpen
(
#ifndef darwin
"addr2line -f --demangle=auto --exe "
#else
// "gaddr2line -f --inline --demangle=auto --exe "
"addr2line4Mac.py "
#endif
+ filename
+ " "
+ address
);
if (fcnt != "")
{
os << fcnt.c_str();
return;
}
}
os << "Uninterpreted: " << raw.c_str();
}
void error::printStack(Ostream& os)
{
// Do not print anything if FOAM_ABORT is not set
if (!env("FOAM_ABORT"))
{
return;
}
// Reads the starting addresses for the dynamically linked libraries
// from the /proc/pid/maps-file
// I'm afraid this works only for Linux 2.6-Kernels (may work on 2.4)
// Note2: the filenames in here will have softlinks resolved so will
// go wrong when having e.g. OpenFOAM installed under a softlink.
HashTable<label, fileName> addressMap;
{
IFstream is("/proc/" + name(pid()) + "/maps");
while(is.good())
{
string line;
is.getLine(line);
string::size_type space = line.rfind(' ') + 1;
fileName libPath = line.substr(space, line.size()-space);
if (libPath.size() && libPath[0] == '/')
{
string offsetString(line.substr(0, line.find('-')));
IStringStream offsetStr(offsetString);
addressMap.insert(libPath, readHexLabel(offsetStr));
}
}
}
// Get raw stack symbols
void *array[100] = {0};
size_t size = 0; //backtrace(array, 100);
char **strings = 0; //backtrace_symbols(array, size);
// See if they contain function between () e.g. "(__libc_start_main+0xd0)"
// and see if cplus_demangle can make sense of part before +
// HJ, formatting of stack backtrace. 17/Dec/2008
os << nl;
for (size_t i = 0; i < size; i++)
{
string msg(strings[i]);
fileName programFile;
word address;
os << '#' << label(i) << " ";
//os << "Raw : " << msg << "\n\t";
{
string::size_type lPos = msg.find('[');
string::size_type rPos = msg.find(']');
if (lPos != string::npos && rPos != string::npos && lPos<rPos)
{
address = msg.substr(lPos+1, rPos-lPos-1);
msg = msg.substr(0, lPos);
}
string::size_type bracketPos = msg.find('(');
string::size_type spacePos = msg.find(' ');
if (bracketPos != string::npos || spacePos != string::npos)
{
programFile = msg.substr(0, min(spacePos, bracketPos));
// not an absolute path
if (programFile[0] != '/')
{
string tmp = pOpen("which " + programFile);
if (tmp[0] == '/' || tmp[0] == '~')
{
programFile = tmp;
}
}
}
}
string::size_type bracketPos = msg.find('(');
if (bracketPos != string::npos)
{
string::size_type start = bracketPos+1;
string::size_type plusPos = msg.find('+', start);
if (plusPos != string::npos)
{
string cName(msg.substr(start, plusPos-start));
int status;
char* cplusNamePtr = abi::__cxa_demangle
(
cName.c_str(),
NULL, // have it malloc itself
0,
&status
);
if (status == 0 && cplusNamePtr)
{
os << cplusNamePtr;
free(cplusNamePtr);
}
else
{
os << cName.c_str();
}
}
else
{
string::size_type endBracketPos = msg.find(')', start);
if (endBracketPos != string::npos)
{
string fullName(msg.substr(start, endBracketPos-start));
os << fullName.c_str() << nl;
}
else
{
// Print raw message
getSymbolForRaw(os, msg, programFile, address);
}
}
}
else
{
// Print raw message
getSymbolForRaw(os, msg, programFile, address);
}
printSourceFileAndLine(os, addressMap, programFile, address);
os << nl;
}
free(strings);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,202 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "regExp.H"
#include "label.H"
#include "string.H"
#include "List.H"
#include "IOstreams.H"
// Alternative regular expression libraries to consider are:
// Boost http://www.boost.org/libs/regex/doc/
// GRETA http://research.microsoft.com/projects/greta/
// Henry Spencer's http://arglist.com/regex/
//
// Chose DEELX http://www.regexlab.com/en/deelx/
// for its ease of integration - one header file
#include "deelx.h"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regExp::regExp()
:
preg_(0)
{}
Foam::regExp::regExp(const char* pattern, const bool ignoreCase)
:
preg_(0)
{
set(pattern, ignoreCase);
}
Foam::regExp::regExp(const std::string& pattern, const bool ignoreCase)
:
preg_(0)
{
set(pattern.c_str(), ignoreCase);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regExp::~regExp()
{
clear();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::regExp::set(const char* pattern, const bool ignoreCase) const
{
clear();
// avoid NULL pointer and zero-length patterns
if (pattern && *pattern)
{
int cflags = EXTENDED;
if (ignoreCase)
{
cflags |= IGNORECASE;
}
preg_ = new CRegexpT<char>(pattern, cflags);
}
}
void Foam::regExp::set(const std::string& pattern, const bool ignoreCase) const
{
return set(pattern.c_str(), ignoreCase);
}
bool Foam::regExp::clear() const
{
if (preg_)
{
delete preg_;
preg_ = 0;
return true;
}
return false;
}
std::string::size_type Foam::regExp::find(const std::string& str) const
{
std::string::size_type pos = std::string::npos;
if (preg_ && !str.empty())
{
const MatchResult result = preg_->Match(str.c_str());
if( 0 < result.IsMatched() )
{
pos = result.GetStart();
}
}
return pos;
}
bool Foam::regExp::match(const std::string& str) const
{
bool isExactMatch = false;
if( preg_ && !str.empty() )
{
const MatchResult result = preg_->MatchExact(str.c_str());
isExactMatch = (0 < result.IsMatched());
}
return isExactMatch;
}
bool Foam::regExp::match(const string& str, List<string>& groups) const
{
bool isMatch = false;
if( preg_ && !str.empty() )
{
const MatchResult results = preg_->MatchExact(str.c_str());
isMatch = (0 < results.IsMatched());
if( isMatch )
{
int const notFound = -1;
int start, end;
const int groupsCount = results.MaxGroupNumber();
groups.setSize(groupsCount);
for (int i = 0; groupsCount > i; ++i)
{
start = results.GetGroupStart(i);
end = results.GetGroupEnd(i);
if ((notFound < start) && (notFound < end))
{
groups[i] = str.substr(start, end - start);
}
else
{
groups[i].clear();
}
}
}
}
if( !isMatch )
{
groups.clear();
}
return isMatch;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::regExp::operator=(const char* pat)
{
set(pat);
}
void Foam::regExp::operator=(const std::string& pat)
{
set(pat);
}
// ************************************************************************* //

View file

@ -0,0 +1,185 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::regExp
Description
Wrapper around POSIX extended regular expressions.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
These differ somewhat from @c Perl and @c sed regular expressions.
SourceFiles
regExp.C
\*---------------------------------------------------------------------------*/
#ifndef regExp_H
#define regExp_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include <string>
template <class T> class CRegexpT;
namespace Foam
{
// Forward declaration of classes
class string;
template<class T> class List;
/*---------------------------------------------------------------------------*\
Class regExp Declaration
\*---------------------------------------------------------------------------*/
class regExp
{
// Private data
//- Precompiled regular expression
mutable CRegexpT<char>* preg_;
// Private member functions
//- Disallow default bitwise copy construct
regExp(const regExp&);
//- Disallow default bitwise assignment
void operator=(const regExp&);
public:
//- Is character a regular expression meta-character?
// any character: '.' \n
// quantifiers: '*', '+', '?' \n
// grouping: '(', '|', ')' \n
// range: '[', ']' \n
//
// Don't bother checking for '{digit}' bounds
inline static bool meta(char c)
{
return
(
(c == '.') // any character
|| (c == '*' || c == '+' || c == '?') // quantifiers
|| (c == '(' || c == ')' || c == '|') // grouping/branching
|| (c == '[' || c == ']') // range
);
}
// Constructors
//- Construct null
regExp();
//- Construct from character array, optionally ignoring case
regExp(const char*, const bool ignoreCase=false);
//- Construct from std::string (or string), optionally ignoring case
regExp(const std::string&, const bool ignoreCase=false);
// Destructor
~regExp();
// Member functions
//- Access
//- Return true if a precompiled expression does not exist
inline bool empty() const
{
return !preg_;
}
//- Does a precompiled expression exist?
inline bool exists() const
{
return preg_ ? true : false;
}
//- Editing
//- Compile pattern into a regular expression, optionally ignoring case
void set(const char*, const bool ignoreCase=false) const;
//- Compile pattern into a regular expression, optionally ignoring case
void set(const std::string&, const bool ignoreCase=false) const;
//- Release precompiled expression.
// Returns true if precompiled expression existed before clear
bool clear() const;
//- Searching
//- Find position within string.
// Returns the index where it begins or string::npos if not found
std::string::size_type find(const std::string& str) const;
//- Return true if it matches the entire string
// The begin-of-line (^) and end-of-line ($) anchors are implicit
bool match(const std::string&) const;
//- Return true if it matches and sets the sub-groups matched
// The begin-of-line (^) and end-of-line ($) anchors are implicit
bool match(const string&, List<string>& groups) const;
//- Return true if the regex was found in within string
bool search(const std::string& str) const
{
return std::string::npos != find(str);
}
// Member Operators
//- Assign and compile pattern from a character array
// Always case sensitive
void operator=(const char*);
//- Assign and compile pattern from string
// Always case sensitive
void operator=(const std::string&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,169 @@
/*---------------------------------------------------------------------------*\
Copyright : (C) 2011 Symscape
Website : www.symscape.com
-------------------------------------------------------------------------------
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/>.
Class
sigFpe
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "sigFpe.H"
#include "JobInfo.H"
#include "OSspecific.H"
#include "IOstreams.H"
#include <float.h>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
__p_sig_fn_t Foam::sigFpe::oldAction_ = SIG_DFL;
static unsigned int fpOld_ = 0;
static void clearFpe()
{
//_clearfp();
//_controlfp(fpOld_, 0xFFFFFFFF);
}
void Foam::sigFpe::sigFpeHandler(int)
{
const __p_sig_fn_t success = ::signal(SIGFPE, oldAction_);
// Reset old handling
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigSegv::sigFpeHandler()"
) << "Cannot reset SIGFPE trapping"
<< abort(FatalError);
}
// Update jobInfo file
jobInfo.signalEnd();
error::printStack(Perr);
clearFpe();
// Throw signal (to old handler)
::raise(SIGFPE);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigFpe::sigFpe()
{
oldAction_ = SIG_DFL;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigFpe::~sigFpe()
{
if( env("FOAM_SIGFPE") )
{
clearFpe();
// Reset signal
const __p_sig_fn_t success = ::signal(SIGFPE, oldAction_);
oldAction_ = SIG_DFL;
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigFpe::~sigFpe()"
) << "Cannot reset SIGFPE trapping"
<< abort(FatalError);
}
}
if( env("FOAM_SETNAN") )
{
WarningIn("Foam::sigFpe::~sigFpe()")
<< "FOAM_SETNAN not supported under MSwindows "
<< endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigFpe::set(const bool verbose)
{
if( SIG_DFL != oldAction_ )
{
FatalErrorIn
(
"Foam::sigFpe::set()"
) << "Cannot call sigFpe::set() more than once"
<< abort(FatalError);
}
if( env("FOAM_SIGFPE") )
{
if( verbose )
{
Info<< "SigFpe : Enabling floating point exception trapping"
<< " (FOAM_SIGFPE)." << endl;
}
/*
fpOld_ = _controlfp(0, 0);
const unsigned int fpNew =
fpOld_ & ~(_EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW);
_controlfp(fpNew, _MCW_EM);
oldAction_ = ::signal(SIGFPE, &Foam::sigFpe::sigFpeHandler);
if( SIG_ERR == oldAction_ )
{
oldAction_ = SIG_DFL;
FatalErrorIn
(
"Foam::sigFpe::set()"
) << "Cannot set SIGFPE trapping"
<< abort(FatalError);
}
*/
}
if( env("FOAM_SETNAN") )
{
if( verbose )
{
WarningIn("Foam::sigFpe::set()")
<< "FOAM_SETNAN not supported under MSwindows "
<< endl;
}
}
}
// ************************************************************************* //

View file

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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::sigFpe
Description
Set up trapping for floating point exceptions (signal FPE).
Controlled by two env vars:
@param FOAM_SIGFPE \n
exception trapping
@param FOAM_SETNAN \n
initialization of all malloced memory to NaN. If FOAM_SIGFPE
also set, this will cause usage of uninitialized scalars to trigger
an abort.
SourceFiles
sigFpe.C
\*---------------------------------------------------------------------------*/
#ifndef sigFpe_H
#define sigFpe_H
#include "OSspecific.H"
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sigFpe Declaration
\*---------------------------------------------------------------------------*/
class sigFpe
{
// Private data
//- Saved old signal trapping setting
static __p_sig_fn_t oldAction_;
// Static data members
//- Handler for caught signals
static void sigFpeHandler(int);
public:
// Constructors
sigFpe();
// Destructor
~sigFpe();
// Member functions
void set(const bool verbose);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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 "error.H"
#include "sigInt.H"
#include "JobInfo.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
__p_sig_fn_t Foam::sigInt::oldAction_ = SIG_DFL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sigInt::sigIntHandler(int)
{
// Reset old handling
const __p_sig_fn_t success = ::signal(SIGINT, oldAction_);
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigInt::sigIntHandler()"
) << "Cannot reset SIGINT trapping"
<< abort(FatalError);
}
// Update jobInfo file
jobInfo.signalEnd();
// Throw signal (to old handler)
raise(SIGINT);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigInt::sigInt()
{
oldAction_ = SIG_DFL;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigInt::~sigInt()
{
// Reset old handling
const __p_sig_fn_t success = ::signal(SIGINT, oldAction_);
oldAction_ = SIG_DFL;
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigInt::~sigInt()"
) << "Cannot reset SIGINT trapping"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigInt::set(const bool verbose)
{
if( SIG_DFL != oldAction_ )
{
FatalErrorIn
(
"Foam::sigInt::set()"
) << "Cannot call sigInt::set() more than once"
<< abort(FatalError);
}
oldAction_ = ::signal(SIGINT, &Foam::sigInt::sigIntHandler);
if( SIG_ERR == oldAction_ )
{
oldAction_ = SIG_DFL;
FatalErrorIn
(
"Foam::sigInt::set()"
) << "Cannot set SIGINT trapping"
<< abort(FatalError);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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::sigInt
Description
Signal handler for INT interupt.
The standard interupt handler is overridden to ensure that the
runningJob file is removed.
See Also
Foam::JobInfo
SourceFiles
sigInt.C
\*---------------------------------------------------------------------------*/
#ifndef sigInt_H
#define sigInt_H
#include "OSspecific.H"
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sigInt Declaration
\*---------------------------------------------------------------------------*/
class sigInt
{
// Private data
//- Saved old signal trapping setting
static __p_sig_fn_t oldAction_;
// Private Member Functions
static void sigIntHandler(int);
public:
// Constructors
sigInt();
// Destructor
~sigInt();
// Member functions
void set(const bool verbose);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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 "error.H"
#include "sigQuit.H"
#include "JobInfo.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
__p_sig_fn_t Foam::sigQuit::oldAction_ = SIG_DFL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sigQuit::sigQuitHandler(int)
{
// Reset old handling
const __p_sig_fn_t success = ::signal(SIGBREAK, oldAction_);
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigQuit::sigQuitHandler()"
) << "Cannot reset SIGQUIT trapping"
<< abort(FatalError);
}
// Update jobInfo file
jobInfo.signalEnd();
error::printStack(Perr);
// Throw signal (to old handler)
::raise(SIGBREAK);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigQuit::sigQuit()
{
oldAction_ = SIG_DFL;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigQuit::~sigQuit()
{
// Reset old handling
if( SIG_DFL != oldAction_ )
{
const __p_sig_fn_t success = ::signal(SIGBREAK, oldAction_);
oldAction_ = SIG_DFL;
if( SIG_ERR == success )
{
FatalErrorIn("Foam::sigQuit::~sigQuit()")
<< "Cannot reset SIGBREAK trapping"
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigQuit::set(const bool verbose)
{
if( SIG_DFL != oldAction_ )
{
FatalErrorIn
(
"Foam::sigQuit::set()"
) << "Cannot call sigQuit::set() more than once"
<< abort(FatalError);
}
oldAction_ = ::signal(SIGBREAK, &Foam::sigQuit::sigQuitHandler);
if( SIG_ERR == oldAction_ )
{
oldAction_ = SIG_DFL;
FatalErrorIn
(
"Foam::sigQuit::set()"
) << "Cannot set SIGQUIT trapping"
<< abort(FatalError);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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::sigQuit
Description
Signal handler for QUIT interupt.
The standard interupt handler is overridden to ensure that the
runningJob file is removed.
See Also
Foam::JobInfo
SourceFiles
sigQuit.C
\*---------------------------------------------------------------------------*/
#ifndef sigQuit_H
#define sigQuit_H
#include "OSspecific.H"
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sigQuit Declaration
\*---------------------------------------------------------------------------*/
class sigQuit
{
// Private data
//- Saved old signal trapping setting
static __p_sig_fn_t oldAction_;
// Private Member Functions
static void sigQuitHandler(int);
public:
// Constructors
sigQuit();
// Destructor
~sigQuit();
// Member functions
void set(const bool verbose);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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 "error.H"
#include "sigSegv.H"
#include "JobInfo.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
__p_sig_fn_t Foam::sigSegv::oldAction_ = SIG_DFL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sigSegv::sigSegvHandler(int)
{
// Reset old handling
const __p_sig_fn_t success = ::signal(SIGSEGV, oldAction_);
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigSegv::sigSegvHandler()"
) << "Cannot reset SIGSEGV trapping"
<< abort(FatalError);
}
// Update jobInfo file
jobInfo.signalEnd();
error::printStack(Perr);
// Throw signal (to old handler)
::raise(SIGSEGV);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigSegv::sigSegv()
{
oldAction_ = SIG_DFL;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigSegv::~sigSegv()
{
// Reset old handling
const __p_sig_fn_t success = ::signal(SIGSEGV, oldAction_);
oldAction_ = SIG_DFL;
if( SIG_ERR == success )
{
FatalErrorIn
(
"Foam::sigSegv::~sigSegv()"
) << "Cannot reset SIGSEGV trapping"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigSegv::set(const bool verbose)
{
if( SIG_DFL != oldAction_ )
{
FatalErrorIn
(
"Foam::sigSegv::set()"
) << "Cannot call sigSegv::set() more than once"
<< abort(FatalError);
}
oldAction_ = ::signal(SIGSEGV, &Foam::sigSegv::sigSegvHandler);
if( SIG_ERR == oldAction_ )
{
oldAction_ = SIG_DFL;
FatalErrorIn
(
"Foam::sigSegv::set()"
) << "Cannot set SIGSEGV trapping"
<< abort(FatalError);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 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::sigSegv
Description
Signal handler for SEGV interupt.
The standard interupt handler is overridden to ensure that the
runningJob file is removed.
See Also
Foam::JobInfo
SourceFiles
sigSegv.C
\*---------------------------------------------------------------------------*/
#ifndef sigSegv_H
#define sigSegv_H
#include "OSspecific.H"
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sigSegv Declaration
\*---------------------------------------------------------------------------*/
class sigSegv
{
// Private data
//- Saved old signal trapping setting
static __p_sig_fn_t oldAction_;
// Private Member Functions
static void sigSegvHandler(int);
public:
// Constructors
sigSegv();
// Destructor
~sigSegv();
// Member functions
void set(const bool verbose);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,175 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "scalar.H"
#include "MSwindows.H"
#define WINVER 0x0500 // To access CreateTimerQueueTimer
#include <windows.h>
#define SIGALRM 14
#include "error.H"
#include "timer.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::timer, 0);
jmp_buf Foam::timer::envAlarm;
__p_sig_fn_t Foam::timer::oldAction_ = SIG_DFL;
static HANDLE hTimer_ = NULL;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
void Foam::timer::signalHandler(int)
{
if (debug)
{
Info<< "Foam::timer::signalHandler(int sig) : "
<< " timed out. Jumping."
<< endl;
}
longjmp(envAlarm, 1);
}
static VOID CALLBACK timerExpired(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{
::raise(SIGALRM);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::timer::timer(const unsigned int newTimeOut)
:
newTimeOut_(newTimeOut)
{
if (newTimeOut > 0)
{
// Is singleton since handler is static function
if( NULL != hTimer_ )
{
FatalErrorIn
(
"Foam::timer::timer(const unsigned int)"
) << "timer already used."
<< abort(FatalError);
}
// Install alarm signal handler:
oldAction_ = ::signal(SIGALRM, &Foam::timer::signalHandler);
if( SIG_ERR == oldAction_ )
{
oldAction_ = SIG_DFL;
FatalErrorIn
(
"Foam::timer::timer(const unsigned int)"
) << "sigaction(SIGALRM) error"
<< abort(FatalError);
}
if (debug)
{
Info<< "Foam::timer::timer(const unsigned int) : "
<< " installing timeout " << int(newTimeOut_)
<< " seconds." << endl;
}
const bool success =
::CreateTimerQueueTimer(&hTimer_,
NULL,
(WAITORTIMERCALLBACK)timerExpired,
NULL ,
newTimeOut * 1000,
0, 0);
if (!success)
{
hTimer_ = NULL;
FatalErrorIn
(
"Foam::timer::timer(const unsigned int)"
) << "CreateTimerQueueTimer, "
<< MSwindows::getLastError()
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::timer::~timer()
{
if (newTimeOut_ > 0)
{
// Reset timer
const bool timerSuccess =
::DeleteTimerQueueTimer(NULL, hTimer_, NULL);
hTimer_ = NULL;
if (!timerSuccess)
{
FatalErrorIn
(
"Foam::timer::~timer() "
) << "DeleteTimerQueueTimer, "
<< MSwindows::getLastError()
<< abort(FatalError);
}
if (debug)
{
Info<< "Foam::timer::~timer() timeOut="
<< int(newTimeOut_) << endl;
}
const __p_sig_fn_t signalSuccess = signal(SIGALRM, oldAction_);
oldAction_ = SIG_DFL;
// Restore signal handler
if (SIG_ERR == signalSuccess)
{
FatalErrorIn
(
"Foam::timer::~timer()"
) << "sigaction(SIGALRM) error"
<< abort(FatalError);
}
}
}
// ************************************************************************* //

View file

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::timer
Description
Implements a timeout mechanism via sigalarm.
Example usage:
@code
timer myTimer(5); // 5 sec
..
if (timedOut(myTimer))
{
// timed out
}
else
{
// do something possible blocking
}
@endcode
Constructor set signal handler on sigalarm and alarm(). Destructor
clears these.
timedOut is macro because setjmp can't be in member function of timer.
?something to do with stack frames.
Warning
The setjmp restores complete register state so including local vars
held in regs. So if in blocking part something gets calced in a stack
based variable make sure it is declared 'volatile'.
SourceFiles
timer.C
\*---------------------------------------------------------------------------*/
#ifndef timer_H
#define timer_H
#include "className.H"
#include <signal.h>
#include <setjmp.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- check it a timeout has occured
// keep setjmp in same stack frame so no function calls
#define timedOut(x) \
(((x).newTimeOut_ > 0) ? setjmp(Foam::timer::envAlarm) : false)
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timer Declaration
\*---------------------------------------------------------------------------*/
class timer
{
// Private data
//- old signal
static __p_sig_fn_t oldAction_;
//- old alarm() value
static unsigned int oldTimeOut_;
// Private Member Functions
//- alarm handler
static void signalHandler(int);
public:
// Public data
//- Declare name of the class and its debug switch
ClassName("timer");
//- current time out value. Needed by macro timedOut
unsigned int newTimeOut_;
//- state for setjmp. Needed by macro timedOut
static jmp_buf envAlarm;
// Constructors
//- Construct from components.
// newTimeOut=0 makes it do nothing.
timer(const unsigned int newTimeOut);
// Destructor
~timer();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,3 +1,15 @@
ifeq ($(WM_ARCH_BASE), mingw)
EXE_INC = -g \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
-I$(PARMGRIDGEN_INCLUDE_DIR)
LIB_LIBS = \
-lfiniteVolume \
-L$(PARMGRIDGEN_LIB_DIR) -lIMlib -lmgrid
else
EXE_INC = -g \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
@ -9,3 +21,4 @@ EXE_INC = -g \
LIB_LIBS = \
-lfiniteVolume \
-L$(PARMGRIDGEN_LIB_DIR) -lIMlib -lMGridGen
endif

View file

@ -4,10 +4,10 @@ set -x
wmakeLnInclude decompositionMethods
wmake libso scotchDecomp
wmake libso decompositionMethods
wmake libso metisDecomp
wmake libso parMetisDecomp
wmake libso scotchDecomp
wmake libso decompositionMethods
# ----------------------------------------------------------------- end-of-file

View file

@ -4,5 +4,6 @@ EXE_INC = \
-I../scotchDecomp/lnInclude
LIB_LIBS = \
-ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy \
-L$(METIS_LIB_DIR) -lmetis

View file

@ -9,4 +9,8 @@ EXE_INC = \
LIB_LIBS = \
-L$(FOAM_MPI_LIBBIN) \
-L$(PARMETIS_LIB_DIR) -lparmetis
-L$(METIS_LIB_DIR) -lmetis \
-L$(PARMETIS_LIB_DIR) -lmetis -lparmetis \
-ldecompositionMethods \
-lmetisDecomp \
-L$(OPENMPI_DIR)/lib -lmpi

View file

@ -8,6 +8,13 @@ LIB_LIBS = \
-lfoam \
-L$(SCOTCH_LIB_DIR) -lscotch \
-L$(SCOTCH_LIB_DIR) -lscotcherrexit
else ifeq ($(WM_ARCH_BASE), mingw)
/* No librt for MinGW */
LIB_LIBS = \
-ldecompositionMethods \
-L$(SCOTCH_LIB_DIR) -lscotch \
-L$(SCOTCH_LIB_DIR) -lscotcherrexit \
-L$(OPENMPI_DIR)/lib -lmpi
else
LIB_LIBS = \
-L$(SCOTCH_LIB_DIR) -lscotch \

View file

@ -7,6 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
LIB_LIBS = \
-lpthread \
-ldynamicMesh \
-ldynamicFvMesh \
-ldecompositionMethods \

View file

@ -50,13 +50,13 @@ namespace fv
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
template<> inline
tmp<BlockLduSystem<vector, scalar> > gaussDivScheme<vector>::fvmUDiv
(
const GeometricField<vector, fvPatchField, volMesh>&
) const;
template<>
template<> inline
tmp<BlockLduSystem<vector, scalar> > gaussDivScheme<vector>::fvmUDiv
(
const surfaceScalarField& flux,

View file

@ -3,9 +3,19 @@ include $(RULES)/mplib$(WM_MPLIB)
EXE_INC = $(PFLAGS) $(PINC)\
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3
ifeq ($(WM_ARCH_BASE), mingw)
LIB_LIBS = $(PLIBS)\
$(FOAM_LIBBIN)/libOSspecific.o \
-lz \
-L$(WM_THIRD_PARTY_DIR)/packages/system/lib \
-ldl \
-lpsapi \
-lpthread
else
LIB_LIBS = $(PLIBS)\
$(FOAM_LIBBIN)/libOSspecific.o \
-lz
endif
$(OBJECTS_DIR)/global.o: FORCE

View file

@ -76,6 +76,12 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
functionLibPtr =
dlopen(lName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
#elif defined mingw
if(!functionLibPtr && functionLibName.ext()=="so") {
fileName lName=functionLibName.lessExt()+".dll";
functionLibPtr =
dlopen(lName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
#endif
if (!functionLibPtr)
{

View file

@ -49,7 +49,11 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Return the PID of this process
#ifdef mingw
int pid();
#else
pid_t pid();
#endif
//- Return the parent PID of this process
pid_t ppid();

View file

@ -46,7 +46,7 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
Foam::Switch::switchType Foam::Switch::asEnum(const bool b)
{
return b ? Switch::TRUE : Switch::FALSE;
return b ? Switch::FOAM_TRUE : Switch::FOAM_FALSE;
}
@ -122,7 +122,7 @@ bool Foam::Switch::asBool
const char* Foam::Switch::asText(const bool b)
{
return b ? names[Switch::TRUE] : names[Switch::FALSE];
return b ? names[Switch::FOAM_TRUE] : names[Switch::FOAM_FALSE];
}

View file

@ -75,7 +75,7 @@ public:
// These also correspond to the entries in names.
enum switchType
{
FALSE = 0, TRUE = 1,
FOAM_FALSE = 0, FOAM_TRUE = 1,
OFF = 2, ON = 3,
NO = 4, YES = 5,
NO_1 = 6, YES_1 = 7,
@ -127,7 +127,7 @@ public:
//- Construct null as false
Switch()
:
switch_(Switch::FALSE)
switch_(Switch::FOAM_FALSE)
{}
//- Construct from bool
@ -178,7 +178,7 @@ public:
//- Assignment from bool
const Switch& operator=(const bool b)
{
switch_ = (b ? Switch::TRUE : Switch::FALSE);
switch_ = (b ? Switch::FOAM_TRUE : Switch::FOAM_FALSE);
return *this;
}

View file

@ -33,6 +33,8 @@ Description
#ifndef Hash_H
#define Hash_H
#include <inttypes.h>
#include "label.H"
#include "uLabel.H"
#include "Hasher.H"
@ -71,7 +73,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hash specialization for hashing pointer addresses.
// Treat a pointer like a long.
// Treat a pointer like a intptr_t.
// This should work for both 32-bit and 64-bit pointers.
template<>
class Hash<void*>
@ -83,12 +85,12 @@ public:
unsigned operator()(const void* const& p, unsigned seed) const
{
return Hash<long>()(long(p), seed);
return Hash<intptr_t>()(intptr_t(p), seed);
}
unsigned operator()(const void* const& p) const
{
return Hash<long>()(long(p));
return Hash<intptr_t>()(intptr_t(p));
}
};

View file

@ -56,6 +56,8 @@ Description
# define FOAM_LABEL_MAX INT_MAX
# include "int.H"
# include "long.H"
# include "longLong.H"
namespace Foam
{

View file

@ -25,6 +25,10 @@ License
#include "Random.H"
#ifdef mingw
#include "rand48.h"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View file

@ -1,10 +1,20 @@
ParMGridGen = $(WM_THIRD_PARTY_DIR)/ParMGridGen-1.0
ParMGridGen = $(WM_THIRD_PARTY_DIR)/packages/ParMGridGen-1.0
TYPE_REAL=
#if defined(WM_SP)
TYPE_REAL=-DTYPE_REAL
#endif
ifeq ($(WM_ARCH_BASE), mingw)
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(PARMGRIDGEN_INCLUDE_DIR) \
$(TYPE_REAL)
LIB_LIBS = \
-lfiniteVolume \
-L$(PARMGRIDGEN_LIB_DIR) -lmgrid
else
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(PARMGRIDGEN_INCLUDE_DIR)/Lib \
@ -13,3 +23,6 @@ EXE_INC = \
LIB_LIBS = \
-L$(PARMGRIDGEN_LIB_DIR) -lMGridGen
endif

View file

@ -10,6 +10,7 @@
EXE_INC = \
$(OMP_FLAGS) \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lmeshTools

View file

@ -2,16 +2,16 @@ ifneq ($(FLEX_DIR), "")
EXE_INC = \
-I$(FLEX_DIR)/include \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3 \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
else
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3
endif
EXE_INC = \
-I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3 \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
endif
LIB_LIBS = \
-ldecompositionMethods \

View file

@ -45,7 +45,7 @@ namespace Foam
// Forward declaration of classes
class octreeDataTriSurface;
template<>
template<> inline
bool treeLeaf<octreeDataTriSurface>::findNearest
(
const octreeDataTriSurface& shapes,

View file

@ -8,3 +8,4 @@ LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lsurfMesh \
-llagrangian

View file

@ -3,4 +3,5 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
LIB_LIBS = \
-lspecie \
-lfiniteVolume

View file

@ -4,3 +4,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/liquids/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude
LIB_LIBS = \
-lspecie \
-lliquids

View file

@ -1 +1,5 @@
EXE_INC = -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude
LIB_LIBS = \
-lthermophysicalFunctions

View file

@ -4,4 +4,5 @@ EXE_INC = \
LIB_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \
-lspecie

View file

@ -12,4 +12,6 @@ EXE_INC = \
endif
LIB_LIBS = \
-lfiniteVolume
-lbasicThermophysicalModels \
-lfiniteVolume \
-lspecie

View file

@ -1,2 +1,5 @@
EXE_INC = \
-I${LIB_SRC}/thermophysicalModels/solids/lnInclude
LIB_LIBS = \
-lsolids

View file

@ -92,6 +92,9 @@ LIB = libNULL
ifeq ($(WM_ARCH_BASE),darwin)
# Using Mac OSX
SO = dylib
else ifeq ($(WM_ARCH_BASE),mingw)
# Using MinGW-w64 compiler on Windows
SO = dll
else
SO = so
endif
@ -166,6 +169,12 @@ $(SEXE): $(OBJECTS)
# define link statements for libraries
#------------------------------------------------------------------------------
ifneq (,$(findstring libfoam,$(LIB)))
EXTRA_LIBS=
else
EXTRA_LIBS=-lfoam
endif
libso: $(LIB).$(SO)
@echo \'$(LIB).$(SO)\' is up to date.
@ -175,6 +184,9 @@ $(LIB).$(SO): $(OBJECTS)
ifeq ($(WM_ARCH_BASE),darwin)
@cd $(OBJECTS_DIR) ; \
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) -install_name $(notdir $(LIB)).$(SO) -o $(LIB).$(SO)
else ifeq ($(WM_ARCH_BASE),mingw)
@cd $(OBJECTS_DIR) ; \
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) $(EXTRA_LIBS) -o $(LIB).$(SO) -Wl,--out-implib,$(LIB).a
else
@cd $(OBJECTS_DIR) ; \
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) -o $(LIB).$(SO)

View file

@ -0,0 +1,2 @@
by bgschaid. 2010-10-06 on Centos 5.5 with gcc 4.1

View file

@ -0,0 +1,3 @@
XFLAGS =
XINC = $(XFLAGS) -I/usr/X11R6/include
XLIBS = -L/usr/X11R6/lib64 -lXext -lX11

View file

@ -0,0 +1,16 @@
.SUFFIXES: .c .h
cWARN = -Wall
cc = gcc
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 --add-needed -Xlinker -z -Xlinker nodefs

View file

@ -0,0 +1,22 @@
.SUFFIXES: .C .cxx .cc .cpp
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor
CC = g++
include $(RULES)/c++$(WM_COMPILE_OPTION)
ptFLAGS = -DNoRepository -ftemplate-depth-200
GFLAGS = -DWM_$(WM_PRECISION_OPTION)
c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -I$(OPENMPI_DIR)/include -I$(WM_THIRD_PARTY_DIR)/packages/system/include -Dmingw -DBIG_ENDIAN=0 -DLITTLE_ENDIAN=1 -DBYTE_ORDER=BIG_ENDIAN
Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $$SOURCE -o $@
cxxtoo = $(Ctoo)
cctoo = $(Ctoo)
cpptoo = $(Ctoo)
LINK_LIBS = $(c++DBUG) -L$(OPENMPI_DIR)/lib -lmpi -lpthread -lz -L$(WM_THIRD_PARTY_DIR)/packages/system/lib -ldl -lpsapi
LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed $(FOAM_LIBBIN)/libOSspecific.o

View file

@ -0,0 +1,2 @@
c++DBUG = -ggdb3 -DFULLDEBUG
c++OPT = -O0 -fdefault-inline

View file

@ -0,0 +1,4 @@
c++DBUG =
c++OPT = -O3
#c++OPT = -march=nocona -O3
# -ftree-vectorize -ftree-vectorizer-verbose=3

View file

@ -0,0 +1,2 @@
c++DBUG = -pg
c++OPT = -O2

View file

@ -0,0 +1,2 @@
cDBUG = -ggdb -DFULLDEBUG
cOPT = -O1 -fdefault-inline -finline-functions

View file

@ -0,0 +1,2 @@
cDBUG =
cOPT = -O3

View file

@ -0,0 +1,2 @@
cDBUG = -pg
cOPT = -O2

View file

@ -0,0 +1,11 @@
CPP = cpp -traditional-cpp
LD = ld
PROJECT_LIBS = -l$(WM_PROJECT) -liberty
include $(GENERAL_RULES)/standard
include $(RULES)/X
include $(RULES)/c
include $(RULES)/c++
include $(RULES)/nvcc

View file

@ -0,0 +1,3 @@
PFLAGS =
PINC =
PLIBS =

View file

@ -0,0 +1,3 @@
PFLAGS =
PINC = -I$(MPI_ARCH_PATH)/include
PLIBS = -L$(MPI_ARCH_PATH)/lib -lgamma

View file

@ -0,0 +1,3 @@
PFLAGS =
PINC = -I$(MPI_ARCH_PATH)/include -D_MPICC_H
PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_amd64 -lmpi

View file

@ -0,0 +1,3 @@
PFLAGS =
PINC = -I$(MPI_ARCH_PATH)/include
PLIBS = -L$(MPI_ARCH_PATH)/lib -lmpich

Some files were not shown because too many files have changed in this diff Show more