├── .github ├── FUNDING.yml └── workflows │ └── main.yml ├── .gitignore ├── OpenFOAM-10-280e795c1.patch ├── OpenFOAM-11-528c1e71cc.patch ├── OpenFOAM-12-17d0158143.patch ├── OpenFOAM-2.2.x-1f35a0ff.patch ├── OpenFOAM-2.4.x-2b147f4.patch ├── OpenFOAM-3.0.x-ec1903cb.patch ├── OpenFOAM-4.0.patch ├── OpenFOAM-4.1.patch ├── OpenFOAM-4.x-56a4152a9.patch ├── OpenFOAM-5.0.patch ├── OpenFOAM-5.x-7f7d351b7.patch ├── OpenFOAM-6-47517f2eb.patch ├── OpenFOAM-6.patch ├── OpenFOAM-7-83cd285f0.patch ├── OpenFOAM-8-1ac121041.patch ├── OpenFOAM-9-2b1d7d67c.patch ├── OpenFOAM-dev-046680c4a8.patch ├── OpenFOAM-v1912.patch ├── OpenFOAM-v2006.patch ├── OpenFOAM-v2012.patch ├── OpenFOAM-v2106.patch ├── OpenFOAM-v2206.patch ├── README.md ├── TODO.md ├── files ├── Alltest ├── README.md ├── RunFunctions ├── addr2line_mac.py ├── mkpatches.py ├── openfoam-env-setup.sh ├── printStack.C ├── sigFpe.C ├── sigFpe.H └── strip_binaries.py ├── formulae ├── mesquite.rb ├── metis64.rb ├── parmgridgen.rb ├── scotch.rb └── scotch64.rb ├── sha256sum.txt ├── swak4Foam-r2742.patch └── wmake ├── makefiles ├── apps ├── files └── general ├── rules ├── General │ ├── CGAL │ ├── X │ ├── bison │ ├── btyacc │ ├── btyacc++ │ ├── byacc │ ├── flex │ ├── flex++ │ ├── general │ ├── moc │ ├── mplib │ ├── mplibMPICH │ ├── mplibMPICH-GM │ ├── mplibOPENMPI │ ├── mplibQSMPI │ ├── mplibSGIMPI │ ├── mplibSYSTEMMPI │ ├── mplibSYSTEMOPENMPI │ ├── standard │ ├── transform │ ├── version │ └── yacc ├── darwin64Clang │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ └── general ├── linux64Clang │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibINTELMPI ├── linux64Gcc │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibINTELMPI ├── linux64GccKNL │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibINTELMPI ├── linux64Icc │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibINTELMPI ├── linux64IccKNL │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibINTELMPI ├── linuxARM7Gcc │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── linuxClang │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── linuxGcc │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── linuxIA64Gcc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ └── mplibMPI ├── linuxIA64Icc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibHPMPI │ ├── mplibIMPI │ ├── mplibINTELMPI │ └── mplibMPI ├── linuxIcc │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── linuxPPC64Gcc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── linuxPPC64leGcc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibHPMPI ├── solaris64Gcc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ └── mplibFJMPI └── solarisGcc │ ├── X │ ├── c │ ├── c++ │ ├── c++Debug │ ├── c++Opt │ ├── c++Prof │ ├── cDebug │ ├── cOpt │ ├── cProf │ ├── general │ ├── mplibMPI │ └── mplibMPICH ├── scripts ├── AllwmakeParseArguments ├── makeFiles ├── makeOptions ├── makeTargetDir └── wmakeFunctions ├── src ├── Makefile ├── dirToString.c └── wmkdep.l ├── wclean ├── wcleanLnIncludeAll ├── wcleanPlatform ├── wdep ├── wmake ├── wmakeCheckPwd ├── wmakeFilesAndOptions ├── wmakeLnInclude ├── wmakeLnIncludeAll ├── wmakePrintBuild ├── wmakeScheduler ├── wmakeSchedulerUptime ├── wrmdep └── wrmo /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mrklein 4 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: macOS-10.14 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Run a one-line script 13 | run: echo Hello, world! 14 | - name: Run a multi-line script 15 | run: | 16 | echo Add other actions to build, 17 | echo test, and deploy your project. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/platforms/** 2 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | - [X] wmake unification 2 | - [X] vim mode line in IOobject 3 | - [X] 4.x 4 | - [X] 4.1 5 | - [X] 4.0 6 | - [X] 2.4.x 7 | - [X] 2.2.x 8 | - [X] foamVersion key in file header 9 | - [X] 4.x 10 | - [X] 4.1 11 | - [X] 4.0 12 | - [X] 2.4.x 13 | - [X] 2.2.x 14 | - [X] Patch generation script 15 | -------------------------------------------------------------------------------- /files/Alltest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #------------------------------------------------------------------------------ 3 | # ========= | 4 | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 5 | # \\ / O peration | 6 | # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation 7 | # \\/ M anipulation | 8 | #------------------------------------------------------------------------------ 9 | # License 10 | # This file is part of OpenFOAM. 11 | # 12 | # OpenFOAM is free software: you can redistribute it and/or modify it 13 | # under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 18 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | # for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with OpenFOAM. If not, see . 24 | # 25 | # Script 26 | # Alltest 27 | # 28 | # Description 29 | # quickly tests the tutorials and writes out the scheme/solver information 30 | # 31 | #------------------------------------------------------------------------------ 32 | cd ${0%/*} || exit 1 # run from this directory 33 | 34 | usage() 35 | { 36 | while [ "$#" -ge 1 ]; do echo "$1"; shift; done 37 | cat</dev/null; exit 0' \ 162 | EXIT TERM INT 163 | cp ${MAIN_CONTROL_DICT} ${MAIN_CONTROL_DICT}.org 164 | 165 | sed -E \ 166 | -e s/"(fvSchemes[[:space:]]*)([0-9]);"/"\1 1;"/g \ 167 | -e s/"(solution[[:space:]]*)([0-9]);"/"\1 1;"/g \ 168 | ${MAIN_CONTROL_DICT}.org > ${MAIN_CONTROL_DICT} 169 | 170 | echo "Copying the tutorials" 171 | cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR} 172 | 173 | echo "Modifying the controlDicts to run only one time step" 174 | cd ${TEST_RUN_DIR} || exit 1 175 | 176 | for CD in `find . -name "controlDict*"` 177 | do 178 | mv ${CD} ${CD}.org 179 | sed -E \ 180 | -e s/"(startFrom[[:space:]]*)([a-zA-Z]*);"/"\1 latestTime;"/g \ 181 | -e s/"(stopAt[[:space:]]*)([a-zA-Z]*);"/"\1 nextWrite;"/g \ 182 | -e s/"(writeControl[[:space:]]*)([a-zA-Z]*);"/"\1 timeStep;"/g \ 183 | -e s/"(writeInterval[[:space:]]*)([0-9a-zA-Z.-]*);"/"\1 1;"/g \ 184 | ${CD}.org > ${CD} 185 | done 186 | 187 | if [ "$DEFAULT_SCHEMES" = true ] 188 | then 189 | echo "Modifying the fvSchemes to contain only default schemes" 190 | for FV_SC in `find . -name fvSchemes` 191 | do 192 | for S in $FV_SCHEMES 193 | do 194 | mv ${FV_SC} ${FV_SC}.org 195 | sed -e /"${S}"/,/$p/d ${FV_SC}.org > ${FV_SC} 196 | done 197 | setDefaultFvSchemes >> ${FV_SC} 198 | done 199 | fi 200 | 201 | ./Allrun 202 | 203 | sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp 204 | APPLICATIONS=\ 205 | `grep "applications=" temp | sed 's/applications=\"\([A-Za-z \t]*\)\"/\1/g'` 206 | 207 | rm $SCHEMES_FILE > /dev/null 2>&1 208 | for APP in $APPLICATIONS 209 | do 210 | echo $APP >> $SCHEMES_FILE 211 | echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE 212 | for ST in $FV_SCHEMES 213 | do 214 | rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1 215 | echo " ${ST}" >> $SCHEMES_FILE 216 | for LOG in `find ${APP} -name "log.${APP}"` 217 | do 218 | for S in `grep ${ST} ${LOG} | cut -d" " -f4` 219 | do 220 | echo " ${S}" >> $SCHEMES_TEMP 221 | done 222 | echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP 223 | done 224 | if [ -f $SCHEMES_TEMP ] 225 | then 226 | cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE 227 | fi 228 | done 229 | cat $SOLVERS_TEMP | tr " " "\n" | sort -u | tr "\n" " " >> $SOLVERS_FILE 230 | echo "" >> $SOLVERS_FILE 231 | done 232 | 233 | # ----------------------------------------------------------------- end-of-file 234 | -------------------------------------------------------------------------------- /files/README.md: -------------------------------------------------------------------------------- 1 | # Modified files that can be used separate from patches 2 | 3 | ## Alltest 4 | 5 | A file from `tutorials` folder. Changed sed patterns to correctly deal 6 | with tabs. 7 | 8 | ## addr2line_mac.py 9 | 10 | Added support for llvm debugger. Corrected source to pass pylint. If you'd like 11 | to use it with already installed OpenFOAM, rename it into addr2line4Mac.py and 12 | place in $WM_PROJECT_DIR/bin folder. 13 | 14 | ## openfoam-env-setup.sh 15 | 16 | File can be copied to home folder and sourced from .profile. Adds two types of 17 | functionality: automatic OpenFOAM environment setup and functions for 18 | environment setup per version. 19 | 20 | ## printStack.C 21 | 22 | OS X modification of new printStack implementation. Just in case you would like 23 | to integrate it in compiled code-base. 24 | 25 | ## sigFpe.C 26 | 27 | Modification of sigFpe.C to avoid infinite loop in parallel run. 28 | -------------------------------------------------------------------------------- /files/RunFunctions: -------------------------------------------------------------------------------- 1 | #---------------------------------*- sh -*------------------------------------- 2 | # ========= | 3 | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | # \\ / O peration | 5 | # \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation 6 | # \\/ M anipulation | 7 | #------------------------------------------------------------------------------ 8 | # License 9 | # This file is part of OpenFOAM. 10 | # 11 | # OpenFOAM is free software: you can redistribute it and/or modify it 12 | # under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | # for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with OpenFOAM. If not, see . 23 | # 24 | # Script 25 | # RunFunctions 26 | # 27 | # Description 28 | # Miscellaneous functions for running tutorial cases 29 | #------------------------------------------------------------------------------ 30 | 31 | isSIPEnabled() 32 | { 33 | $(which -s csrutil) && { 34 | [ $(csrutil status | awk '{print $5}' | tr -d ".") = "enabled" ] \ 35 | && return 0 36 | } 37 | return 1 38 | } 39 | 40 | # Workaround for cleared DYLD_LIBRARY_PATH 41 | [ "$(uname -s)" = "Darwin" ] \ 42 | && [ isSIPEnabled ] \ 43 | && source "$WM_PROJECT_DIR/etc/bashrc" 44 | 45 | getNumberOfProcessors() 46 | { 47 | grep numberOfSubdomains system/decomposeParDict \ 48 | | awk '{print $2}' \ 49 | | tr -d ";" 50 | } 51 | 52 | getApplication() 53 | { 54 | grep application system/controlDict \ 55 | | awk '{print $2}' \ 56 | | tr -d ";" 57 | } 58 | 59 | runApplication() 60 | { 61 | local force= 62 | local append= 63 | 64 | local app_run="$1" 65 | while [ "$(echo "$app_run" | cut -c1)" = "-" ]; do 66 | case $app_run in 67 | -f|--force|-force|-overwrite) 68 | force=y 69 | ;; 70 | -a|--append|-append) 71 | append=y 72 | ;; 73 | esac 74 | shift 75 | app_run="$1" 76 | done 77 | shift 78 | local app_name=${app_run##*/} 79 | 80 | [ -x "$(which $app_run)" ] || { 81 | echo "Application $app_run does not exist or is not executable." 82 | exit 1 83 | } 84 | 85 | [ "$force" = "y" ] && rm -f "log.$app_name" 86 | 87 | if [ -f "log.$app_name" ] 88 | then 89 | if [ "$append" = "y" ] 90 | then 91 | echo "Running $app_run on $PWD (appending to log.$app_name)" 92 | $app_run "$@" >> "log.$app_name" 2>&1 93 | else 94 | echo "$app_name already run on $PWD: remove log file to re-run" 95 | fi 96 | else 97 | echo "Running $app_run on $PWD" 98 | $app_run "$@" > "log.$app_name" 2>&1 99 | fi 100 | } 101 | 102 | runParallel() 103 | { 104 | local force= 105 | local append= 106 | 107 | local app_run="$1" 108 | while [ "$(echo "$app_run" | cut -c1)" = "-" ]; do 109 | case $app_run in 110 | -f|--force|-force) 111 | force=y 112 | ;; 113 | -a|--append|-append) 114 | append=y 115 | ;; 116 | esac 117 | shift 118 | app_run="$1" 119 | done 120 | shift 121 | local app_name=${app_run##*/} 122 | 123 | [ -x "$(which $app_run)" ] || { 124 | echo "Application $app_run does not exist or is not executable." 125 | exit 1 126 | } 127 | 128 | [ "$force" = "y" ] && rm -f "log.$app_name" 129 | 130 | local n_procs="$1" 131 | shift 132 | 133 | if [ -f "log.$app_name" ] 134 | then 135 | if [ "$append" = "y" ] 136 | then 137 | echo 138 | else 139 | echo "$app_name already run on $PWD: remove log file to re-run" 140 | fi 141 | else 142 | echo "Running $app_run in parallel on $PWD using $n_procs processes" 143 | 144 | ( mpirun -np "$n_procs" $app_run -parallel "$@" < /dev/null > "log.$app_name" 2>&1 ) 145 | fi 146 | } 147 | 148 | compileApplication() 149 | { 150 | echo "Compiling $1 application" 151 | wmake "$1" 152 | } 153 | 154 | cloneCase() 155 | { 156 | local force= 157 | 158 | local source_case="$1" 159 | while [ "$(echo "$source_case" | cut -c1)" = "-" ]; do 160 | case $app_run in 161 | -f|--force|-force) 162 | force=y 163 | ;; 164 | esac 165 | shift 166 | source_case="$1" 167 | done 168 | 169 | local target_case="$2" 170 | 171 | [ "$force" = "y" ] && rf -rf "$target_case" 172 | 173 | if [ -d "$target_case" ] 174 | then 175 | echo "Case already cloned: remove case directory $target_case to clone" 176 | else 177 | echo "Cloning $target_case case from $source_case" 178 | mkdir "$target_case" 179 | cpfiles="0 system constant" 180 | for f in $cpfiles 181 | do 182 | cp -r "$source_case/$f" "$target_case" 183 | done 184 | fi 185 | } 186 | 187 | # vim: set ft=sh: 188 | #------------------------------------------------------------------------------ 189 | -------------------------------------------------------------------------------- /files/addr2line_mac.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Emulation of addr2line utility.""" 4 | 5 | 6 | import subprocess as sp 7 | 8 | DEFAULT_ANSWER = "??:0" 9 | 10 | def gdb_is_available(): 11 | """Check if gdb is installed.""" 12 | res = sp.call(['which', '-s', 'gdb']) 13 | return res == 0 14 | 15 | def lldb_is_available(): 16 | """Check if lldb is installed.""" 17 | res = sp.call(['which', '-s', 'lldb']) 18 | return res == 0 19 | 20 | def addr2line_gdb(filename, address): 21 | """Convert address into line of source file using gdb.""" 22 | proc = sp.Popen("gdb -batch -x /dev/stdin", 23 | shell=True, 24 | bufsize=0, 25 | stdin=sp.PIPE, 26 | stdout=sp.PIPE, 27 | close_fds=True) 28 | 29 | (child_stdin, child_stdout) = (proc.stdin, proc.stdout) 30 | child_stdin.write("set sharedlibrary preload-libraries no\n") 31 | child_stdin.write("file " + filename + "\n") 32 | child_stdin.write("info line *" + address + "\n") 33 | res = child_stdout.readline() 34 | 35 | import re 36 | 37 | match = re.compile('Line (.+) of "(.+)" starts at').match(res) 38 | if match: 39 | return match.group(2) + ":" + match.group(1) 40 | else: 41 | return DEFAULT_ANSWER 42 | 43 | def addr2line_lldb(filename, address): 44 | """Convert address into line of source file using lldb.""" 45 | import sys 46 | 47 | lldb_python_path = sp.check_output(['lldb', '-P']) 48 | sys.path.insert(0, lldb_python_path[:-1]) 49 | 50 | import lldb 51 | 52 | addr = int(address, 16) 53 | 54 | dbg = lldb.SBDebugger.Create() 55 | dbg.SetAsync(False) 56 | tgt = dbg.CreateTargetWithFileAndArch(filename, 57 | lldb.LLDB_ARCH_DEFAULT) 58 | 59 | for mdl in tgt.module_iter(): 60 | sb_addr = mdl.ResolveFileAddress(addr) 61 | resolved_addr = mdl.ResolveSymbolContextForAddress( 62 | sb_addr, 63 | lldb.eSymbolContextEverything 64 | ) 65 | 66 | if resolved_addr.IsValid(): 67 | line_entry = resolved_addr.GetLineEntry() 68 | file_ = line_entry.GetFileSpec() 69 | line = line_entry.GetLine() 70 | if line_entry.ling != 0: 71 | return "{0}:{1}".format(file_, line) 72 | return DEFAULT_ANSWER 73 | 74 | 75 | def run(): 76 | """Determine file and line for a given address.""" 77 | import sys 78 | 79 | filename = sys.argv[1] 80 | address = sys.argv[2] 81 | 82 | answer = DEFAULT_ANSWER 83 | 84 | if gdb_is_available(): 85 | answer = addr2line_gdb(filename, address) 86 | 87 | if lldb_is_available(): 88 | answer = addr2line_lldb(filename, address) 89 | 90 | print answer, 91 | 92 | sys.exit(255) 93 | 94 | if __name__ == '__main__': 95 | run() 96 | -------------------------------------------------------------------------------- /files/mkpatches.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import print_function 5 | import sys 6 | 7 | __version__ = '0.0.1' 8 | __author__ = 'Alexey Matveichev' 9 | 10 | COMMITS = { 11 | 'RELEASES': { 12 | '4.0': '068045d', 13 | '4.1': '40e815b', 14 | '5.0': 'fe83070' 15 | }, 16 | 'ROLLING': { 17 | '2.2.x': '1f35a0ff', 18 | '2.4.x': '2b147f4', 19 | '3.0.x': 'ec1903cb', 20 | '4.x': '56a4152a9', 21 | '5.x': '718111a3b', 22 | 'dev': '1bb7db2b7' 23 | } 24 | } 25 | 26 | 27 | def _make_patch(version, start): 28 | """Create patch for a given version and starting commit. 29 | 30 | :version string: OpenFOAM version. 31 | :start string: Commit SHA1 for which diff will be calculated. 32 | """ 33 | 34 | import os 35 | import subprocess 36 | 37 | print('Creating patch for OpenFOAM-{0}'.format(version)) 38 | os.chdir('OpenFOAM-{0}'.format(version)) 39 | 40 | # Commit uncommitted changes 41 | dirty = subprocess.call(['git', 'diff-files', '--quiet']) 42 | if dirty == 1: 43 | print('Committing everything.') 44 | subprocess.call(['git', 'commit', '-a', '-m', 'mkpatches']) 45 | 46 | try: 47 | subprocess.check_output(['git', 'commit', '-a', '-m', 'Fix'], 48 | stderr=subprocess.STDOUT) 49 | except subprocess.CalledProcessError: 50 | pass 51 | diff = subprocess.check_output(['git', 'diff', '--patch-with-stat', start, 52 | 'HEAD']) 53 | os.chdir('..') 54 | 55 | diff_filename = None 56 | if version.endswith('x') or version == 'dev': 57 | diff_filename = 'OpenFOAM-{0}-{1}.patch'.format(version, start) 58 | else: 59 | diff_filename = 'OpenFOAM-{0}.patch'.format(version) 60 | 61 | if diff_filename is None: 62 | raise RuntimeError('Diff filename can not be None') 63 | 64 | f = open(os.path.join('patches', diff_filename), 'w') 65 | f.write(diff) 66 | f.close() 67 | 68 | 69 | def _make_patches(): 70 | """Create patches for known versions.""" 71 | from argparse import ArgumentParser 72 | parser = ArgumentParser(version='%prog {0}'.format(__version__)) 73 | parser.add_argument('-n', '--only', action='store', 74 | dest='version', nargs='+', 75 | help='Create patches only for given versions') 76 | parser.add_argument('-i', '--initial-commit', action='store', 77 | dest='commit', nargs=1) 78 | options = parser.parse_args() 79 | 80 | for release_type, pairs in sorted(COMMITS.items()): 81 | for version, commit in pairs.items(): 82 | if options.version is not None: 83 | if version in options.version: 84 | try: 85 | _make_patch(version, commit) 86 | except RuntimeError: 87 | return 127 88 | else: 89 | try: 90 | _make_patch(version, commit) 91 | except RuntimeError: 92 | return 127 93 | return 0 94 | 95 | if __name__ == '__main__': 96 | import sys 97 | sys.exit(_make_patches()) 98 | -------------------------------------------------------------------------------- /files/openfoam-env-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # If you'd like to setup environment every time terminal is launched 4 | # create .OpenFOAM/OpenFOAM-release file in your home folder. In the file put 5 | # the string with a version you'd like to use. This can be done with: 6 | # $ mkdir -p .OpenFOAM 7 | # $ cat 'N.X.Y' > .OpenFOAM/OpenFOAM-release 8 | # If you'd like to switch environment between versions use ofNxy commands. 9 | # 10 | # Currently N is 2, 3, 4, 5, 6, or 7. 11 | 12 | readonly FOAM_MOUNT_POINT="${FOAM_MOUNT_POINT:-"$HOME/OpenFOAM"}" 13 | readonly FOAM_RELEASE_FILE="${FOAM_RELEASE_FILE:-"$HOME/.OpenFOAM/OpenFOAM-release"}" 14 | readonly FOAM_DISK_IMAGE="${FOAM_DISK_IMAGE:-"$HOME/OpenFOAM.sparsebundle"}" 15 | 16 | mount_disk_image () { 17 | local oldpwd="$(pwd)" 18 | cd "$HOME" 19 | # Attempt to mount image 20 | hdiutil attach -quiet -mountpoint "$FOAM_MOUNT_POINT" "$FOAM_DISK_IMAGE" 21 | cd "$oldpwd" 22 | return 0 23 | } 24 | 25 | main () { 26 | [ -f "$FOAM_RELEASE_FILE" ] || return 1 27 | 28 | local release="$(cat "$FOAM_RELEASE_FILE")" 29 | local bashrc="$FOAM_MOUNT_POINT/OpenFOAM-$release/etc/bashrc" 30 | 31 | [ -f "$bashrc" ] || mount_disk_image 32 | 33 | if [ -f "$bashrc" ] 34 | then 35 | source "$bashrc" WM_NCOMPPROCS="$(sysctl -n hw.ncpu)" 36 | else 37 | echo "OpenFOAM $release doesn't seem to be installed." 38 | fi 39 | } 40 | 41 | # Reset environment variables for specified version 42 | ofxxx () { 43 | local release="$1" 44 | [ -n "$WM_PROJECT_DIR" ] && { 45 | [ -r "$WM_PROJECT_DIR/etc/config/unset.sh" ] \ 46 | && . "$WM_PROJECT_DIR/etc/config/unset.sh" 47 | } 48 | local bashrc="$FOAM_MOUNT_POINT/OpenFOAM-$release/etc/bashrc" 49 | if [ -f "$bashrc" ]; then 50 | source "$bashrc" WM_NCOMPPROCS="$(sysctl -n hw.ncpu)" 51 | else 52 | mount_disk_image 53 | if [ -f "$bashrc" ]; then 54 | source "$bashrc" WM_NCOMPPROCS="$(sysctl -n hw.ncpu)" 55 | else 56 | echo "OpenFOAM $release doesn't seem to be installed." 57 | fi 58 | fi 59 | } 60 | export -f ofxxx 61 | 62 | of5x() { 63 | ofxxx "5.x" 64 | } 65 | export -f of5x 66 | 67 | of6() { 68 | ofxxx "6" 69 | } 70 | export -f of6 71 | 72 | of7() { 73 | ofxxx "7" 74 | } 75 | export -f of7 76 | 77 | ofdev() { 78 | ofxxx "dev" 79 | } 80 | 81 | export -f ofdev 82 | 83 | pf () { 84 | paraFoam -builtin > /dev/null 2>&1 & 85 | } 86 | 87 | main 88 | 89 | # vi: set ft=sh et sw=4 ts=4 sts=4: 90 | -------------------------------------------------------------------------------- /files/sigFpe.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::sigFpe 26 | 27 | Description 28 | Set up trapping for floating point exceptions (signal FPE). 29 | 30 | Controlled by two env vars: 31 | \param FOAM_SIGFPE \n 32 | exception trapping 33 | \param FOAM_SETNAN \n 34 | initialization of all malloced memory to NaN. If FOAM_SIGFPE 35 | also set, this will cause usage of uninitialized scalars to trigger 36 | an abort. 37 | 38 | SourceFiles 39 | sigFpe.C 40 | 41 | \*---------------------------------------------------------------------------*/ 42 | 43 | #ifndef sigFpe_H 44 | #define sigFpe_H 45 | 46 | #include 47 | 48 | #if defined(linux) || defined(linuxAMD64) || defined(linuxIA64) 49 | # define LINUX 50 | #endif 51 | 52 | #if defined(LINUX) && defined(__GNUC__) 53 | # define LINUX_GNUC 54 | #endif 55 | 56 | #if defined(__APPLE__) 57 | #include 58 | #endif 59 | 60 | #include "UList.H" 61 | 62 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 63 | 64 | namespace Foam 65 | { 66 | 67 | /*---------------------------------------------------------------------------*\ 68 | Class sigFpe Declaration 69 | \*---------------------------------------------------------------------------*/ 70 | 71 | class sigFpe 72 | { 73 | // Private data 74 | 75 | //- Saved old signal trapping setting 76 | static struct sigaction oldAction_; 77 | 78 | # if defined(LINUX) 79 | 80 | //- Saved old malloc 81 | static void *(*oldMallocHook_)(size_t, const void *); 82 | 83 | //- NaN malloc function. From malloc_hook manpage. 84 | static void* nanMallocHook_(size_t size, const void *caller); 85 | 86 | # endif 87 | 88 | # if defined(__APPLE__) 89 | static void *(*oldMallocHook_) 90 | ( 91 | struct _malloc_zone_t *zone, 92 | size_t size 93 | ); 94 | 95 | static void *nanMallocHook_ 96 | ( 97 | struct _malloc_zone_t *zone, 98 | size_t size 99 | ); 100 | # endif 101 | 102 | 103 | // Static data members 104 | 105 | # if defined(LINUX_GNUC) || defined(__APPLE__) 106 | 107 | //- Handler for caught signals 108 | static void sigHandler(int); 109 | 110 | # endif 111 | 112 | 113 | public: 114 | 115 | 116 | // Constructors 117 | 118 | //- Construct null 119 | sigFpe(); 120 | 121 | 122 | //- Destructor 123 | ~sigFpe(); 124 | 125 | 126 | // Member functions 127 | 128 | //- Activate SIGFPE signal handler when FOAM_SIGFPE is %set 129 | // Fill memory with NaN when FOAM_SETNAN is %set 130 | void set(const bool verbose); 131 | 132 | //- Helper: fill block of data with NaN 133 | static void fillSignallingNan(UList&); 134 | 135 | }; 136 | 137 | 138 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 139 | 140 | } // End namespace Foam 141 | 142 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 143 | 144 | #endif 145 | 146 | // ************************************************************************* // 147 | -------------------------------------------------------------------------------- /files/strip_binaries.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Strip full path names from libraries and executables.""" 5 | 6 | from __future__ import print_function, division 7 | 8 | 9 | __version__ = '0.0.1' 10 | __author__ = 'Alexey Matveichev' 11 | 12 | 13 | def _strip_id(path): 14 | from subprocess import Popen, PIPE, call 15 | from os.path import basename 16 | 17 | p = Popen(['otool', '-D', path], stdout=PIPE) 18 | p.stdout.readline() 19 | file_id = p.stdout.readline()[:-1] 20 | p.communicate() 21 | call(['install_name_tool', '-id', basename(file_id), path]) 22 | print(' {0} -> {1}'.format(path, basename(file_id))) 23 | 24 | 25 | def _strip_libs(path, root): 26 | from subprocess import Popen, PIPE, call 27 | from os.path import basename 28 | 29 | p = Popen(['otool', '-L', path], stdout=PIPE) 30 | for l in p.stdout: 31 | if l.startswith('\t'): 32 | t = l.split(' ', 1)[0] 33 | t = t.strip() 34 | if t.startswith(root): 35 | call(['install_name_tool', '-change', t, basename(t), path]) 36 | print(' {0} -> {1} in {2}'.format(t, basename(t), path)) 37 | p.communicate() 38 | 39 | 40 | def _read_environment(version): 41 | from os.path import join 42 | from subprocess import Popen, PIPE 43 | 44 | bashrc = join('OpenFOAM-{0}'.format(version), 'etc', 'bashrc') 45 | p = Popen(['bash', '-c', 'source {0} && env'.format(bashrc)], stdout=PIPE) 46 | 47 | prj_dir = None 48 | prj_opts = None 49 | prj_copts = None 50 | prj_label_size = None 51 | 52 | for l in p.stdout: 53 | (key, _, value) = l.partition('=') 54 | if key == 'WM_PROJECT_DIR': 55 | prj_dir = value.strip('\n') 56 | if key == 'WM_OPTIONS': 57 | prj_opts = value.strip('\n') 58 | if key == 'WM_COMPILE_OPTION': 59 | prj_copts = value.strip('\n') 60 | if key == 'WM_LABEL_SIZE': 61 | prj_label_size = value.strip('\n') 62 | 63 | p.communicate() 64 | return prj_dir, prj_opts, prj_copts, prj_label_size 65 | 66 | 67 | def _strip(version, backup=True): 68 | from os import walk 69 | from os.path import join 70 | from shutil import copytree, Error 71 | from sys import stderr 72 | 73 | prj_dir, prj_opts, _, _ = _read_environment(version) 74 | 75 | plt_path = join(prj_dir, 'platforms', prj_opts) 76 | lib_path = join(prj_dir, 'platforms', prj_opts, 'lib') 77 | bin_path = join(prj_dir, 'platforms', prj_opts, 'bin') 78 | 79 | bkp_path = join(prj_dir, 'platforms', '{0}~'.format(prj_opts)) 80 | if backup: 81 | try: 82 | copytree(plt_path, bkp_path) 83 | except Error as e: 84 | stderr.write('Can not create backup: {0}\n'.format(e.message())) 85 | 86 | print('Stripping libraries:') 87 | for root, dirs, files in walk(lib_path): 88 | for name in files: 89 | _strip_id(join(root, name)) 90 | _strip_libs(join(root, name), plt_path) 91 | 92 | print('Stripping binaries:') 93 | for root, dirs, files in walk(bin_path): 94 | for name in files: 95 | _strip_libs(join(root, name), plt_path) 96 | 97 | 98 | def _get_kernel_version(): 99 | from os import uname 100 | _, _, release, _, _ = uname() 101 | return release 102 | 103 | 104 | def _make_archive(version): 105 | """Make archive of platforms/.../bin and platforms/.../lib folders""" 106 | 107 | from os import chdir 108 | from subprocess import call 109 | from os.path import join 110 | from sys import stdout 111 | from shutil import move 112 | 113 | # Name of the archive is: 114 | # v-D[-ls]