Advertisement
SilenceAndI

bashrc_cfdem

Apr 15th, 2019
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 15.67 KB | None | 0 0
  1. #----------------------------------*-sh-*--------------------------------------
  2. # CFDEMcoupling
  3. # Christoph Goniva
  4. # June 2012
  5. #------------------------------------------------------------------------------
  6. #
  7. # Script
  8. #     etc/bashrc
  9. #
  10. # Description
  11. #     Startup file for cfdem exporting environment variables
  12. #     Sourced  ~/.bashrc
  13. #
  14. #- add this block to your ~/.bashrc and modify for your installation
  15. #- you can test the correctness using cfdemSystemTest.sh
  16.  
  17. ## STANDARD BLOCK FOR REGULAR INSTALLATIONS
  18. ##================================================#
  19. ##- source cfdem env vars
  20. #export CFDEM_VERSION=PUBLIC
  21. #export CFDEM_PROJECT_DIR=$HOME/CFDEM/CFDEMcoupling-$CFDEM_VERSION-$WM_PROJECT_VERSION
  22. #export CFDEM_PROJECT_USER_DIR=$HOME/CFDEM/$LOGNAME-$CFDEM_VERSION-$WM_PROJECT_VERSION
  23. #export CFDEM_bashrc=$CFDEM_PROJECT_DIR/src/lagrangian/cfdemParticle/etc/bashrc
  24. #export CFDEM_LIGGGHTS_SRC_DIR=$HOME/LIGGGHTS/LIGGGHTS-PUBLIC/src
  25. #export CFDEM_LIGGGHTS_MAKEFILE_NAME=auto
  26. #export CFDEM_LPP_DIR=$HOME/LIGGGHTS/mylpp/src
  27. #. $CFDEM_bashrc
  28. #================================================#
  29. #------------------------------------------------------------------------------
  30.  
  31. export HOME2=/local/name123
  32. #================================================#
  33. #- source cfdem env vars
  34. # export CFDEM_VERSION=PUBLIC
  35. # export CFDEM_PROJECT_DIR=$HOME2/CFDEM/CFDEMcoupling-$CFDEM_VERSION-$WM_PROJECT_VERSION
  36. # export CFDEM_PROJECT_USER_DIR=$HOME2/CFDEM/$LOGNAME-$CFDEM_VERSION-$WM_PROJECT_VERSION
  37. # export CFDEM_bashrc=$CFDEM_PROJECT_DIR/src/lagrangian/cfdemParticle/etc/bashrc
  38. # export CFDEM_LIGGGHTS_SRC_DIR=$HOME2/LIGGGHTS/LIGGGHTS-PUBLIC/src
  39. # export CFDEM_LIGGGHTS_MAKEFILE_NAME=auto
  40. # export CFDEM_LPP_DIR=$HOME2/LIGGGHTS/lpp/src
  41. # . $CFDEM_bashrc
  42. #================================================#
  43.  
  44.  
  45. ## EXTENDED BLOCK FOR HIGHLY CUSTOMIZED INSTALLATIONS
  46. ## you may insert this right above ". $CFDEM_bashrc"
  47. ##================================================#
  48. #export CFDEM_SRC_DIR=$CFDEM_PROJECT_DIR/src
  49. #export CFDEM_SOLVER_DIR=$CFDEM_PROJECT_DIR/applications/solvers
  50. #export CFDEM_DOC_DIR=$CFDEM_PROJECT_DIR/doc
  51. #export CFDEM_UT_DIR=$CFDEM_PROJECT_DIR/applications/utilities
  52. #export CFDEM_TUT_DIR=$CFDEM_PROJECT_DIR/tutorials
  53. #export CFDEM_LIGGGHTS_MAKEFILE_POSTIFX=
  54. #export CFDEM_VERBOSE=false
  55. #================================================#
  56.  
  57. #------------------------------------------------------------------------------
  58. #- export environment variables (adapt to your paths)
  59. #------------------------------------------------------------------------------
  60.  
  61. ## small function defs
  62. addPath()
  63. {
  64. for path in "$@"; do
  65.   export PATH="$path":"$PATH"
  66. done
  67. }
  68.  
  69. addLDLib()
  70. {
  71. for path in "$@"; do
  72.     export LD_LIBRARY_PATH="$path":"$LD_LIBRARY_PATH"
  73. done
  74. }
  75.  
  76. cfdemecho()
  77. {
  78. if [[ ! $CFDEM_VERBOSE == "false" ]]; then echo "$1"; fi
  79. }
  80.  
  81. setVar()
  82. {
  83. varCont=$(eval echo \$$1)
  84. if [[ "$varCont" == "" ]]; then
  85.   eval export $1="$2"
  86.   cfdemecho "using default $1 = $2"
  87. else
  88.   cfdemecho "using userdefined $1 = $varCont"
  89. fi
  90. }
  91.  
  92. cfdemecho "************************************"
  93. setVar CFDEM_SRC_DIR $CFDEM_PROJECT_DIR/src
  94. setVar CFDEM_SOLVER_DIR $CFDEM_PROJECT_DIR/applications/solvers
  95. setVar CFDEM_DOC_DIR $CFDEM_PROJECT_DIR/doc
  96. setVar CFDEM_UT_DIR $CFDEM_PROJECT_DIR/applications/utilities
  97. setVar CFDEM_TUT_DIR $CFDEM_PROJECT_DIR/tutorials
  98.  
  99. #check if default lammps lib path should be used
  100. setVar CFDEM_LAMMPS_LIB_DIR $CFDEM_LIGGGHTS_SRC_DIR/../lib
  101.  
  102. #test CFDEM_LAMMPS_LIB_DIR
  103. if [ -f "$CFDEM_LAMMPS_LIB_DIR/poems/Makefile.lammps" ]; then
  104.     :
  105. else
  106.     echo ""
  107.     echo "   !!! WARNING CFDEM_LAMMPS_LIB_DIR = $CFDEM_LAMMPS_LIB_DIR seems to be wrong !!!"
  108.     echo ""
  109. fi
  110.  
  111. #- LIGGGHTS lib name
  112. if [[ $CFDEM_LIGGGHTS_MAKEFILE_NAME == "auto" ]] && [[ $CFDEM_LIGGGHTS_MAKEFILE_POSTFIX != "" ]] ; then
  113.     export CFDEM_LIGGGHTS_LIB_NAME="lmp_"$CFDEM_LIGGGHTS_MAKEFILE_NAME"_"$CFDEM_LIGGGHTS_MAKEFILE_POSTFIX
  114. else
  115.     export CFDEM_LIGGGHTS_LIB_NAME=lmp_$CFDEM_LIGGGHTS_MAKEFILE_NAME
  116. fi
  117.  
  118. if [[ ${WM_COMPILE_OPTION} == "Debug" ]] && [[ $CFDEM_LIGGGHTS_MAKEFILE_NAME == "auto" ]]; then
  119.   export CFDEM_LIGGGHTS_LIB_NAME="${CFDEM_LIGGGHTS_LIB_NAME}-fulldebug"
  120. fi
  121.  
  122. #- LIGGGHTS lib path
  123. setVar CFDEM_LIGGGHTS_LIB_PATH $CFDEM_LIGGGHTS_SRC_DIR
  124.  
  125. #- LIGGGHTS executable
  126. export CFDEM_LIGGGHTS_EXEC=$CFDEM_LIGGGHTS_LIB_PATH/$CFDEM_LIGGGHTS_LIB_NAME
  127.  
  128. #- CFDEM lib name
  129. export CFDEM_LIB_NAME=lagrangianCFDEM-$CFDEM_VERSION-$WM_PROJECT_VERSION
  130.  
  131. #- CFDEM compressible lib name
  132. export CFDEM_LIB_COMP_NAME=lagrangianCFDEMcomp-$CFDEM_VERSION-$WM_PROJECT_VERSION
  133.  
  134. #check if additional libraries should be compiled together with solvers
  135. setVar CFDEM_ADD_LIBS_DIR $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/addLibs_universal
  136. setVar CFDEM_ADD_LIBS_NAME additionalLibs_$WM_PROJECT_VERSION
  137.  
  138. # check addLibs path and file name
  139. if [[ ! -f $CFDEM_ADD_LIBS_DIR/$CFDEM_ADD_LIBS_NAME ]]; then
  140.     echo "!!! ERROR !!!: CFDEM_ADD_LIBS_DIR/CFDEM_ADD_LIBS_NAME=$CFDEM_ADD_LIBS_DIR/$CFDEM_ADD_LIBS_NAME does not exist."
  141. fi
  142.  
  143. #-----------------------------------------------------
  144. # additional libraries
  145.  
  146. #- LMP Many2Many lib path and makefile
  147. export CFDEM_Many2ManyLIB_PATH=$CFDEM_SRC_DIR/lagrangian/cfdemParticle/subModels/dataExchangeModel/twoWayMany2Many/library
  148. export CFDEM_Many2ManyLIB_MAKEFILENAME=$CFDEM_LIGGGHTS_MAKEFILE_NAME
  149.  
  150. #- LMP M2M lib path and makefile
  151. export CFDEM_M2MLIB_PATH=$CFDEM_SRC_DIR/lagrangian/cfdemParticle/subModels/dataExchangeModel/M2M/library
  152. export CFDEM_M2MLIB_MAKEFILENAME=$CFDEM_LIGGGHTS_MAKEFILE_NAME
  153.  
  154. #- LMP M2MMS lib path and makefile
  155. export CFDEM_M2MMSLIB_PATH=$CFDEM_SRC_DIR/lagrangian/cfdemParticle/subModels/dataExchangeModel/M2M/library
  156. export CFDEM_M2MMSLIB_MAKEFILENAME=$CFDEM_LIGGGHTS_MAKEFILE_NAME
  157.  
  158. #- LMP POEMS lib default path
  159. export CFDEM_POEMSLIB_PATH=$CFDEM_LAMMPS_LIB_DIR/poems
  160. #-----------------------------------------------------
  161.  
  162. #- path to test harness
  163. export CFDEM_TEST_HARNESS_PATH=$CFDEM_PROJECT_USER_DIR/log/logFilesCFDEM-$CFDEM_VERSION-$WM_PROJECT_VERSION
  164.  
  165. #- path to libraries
  166. # check if pathes are already set automatically
  167. setVar CFDEM_LIB_DIR $CFDEM_PROJECT_DIR/platforms/$WM_OPTIONS/lib
  168. setVar CFDEM_USER_LIB_DIR $CFDEM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib
  169.  
  170. addLDLib "$CFDEM_LIB_DIR" "$CFDEM_USER_LIB_DIR"
  171.  
  172. #- path to apps
  173. setVar CFDEM_APP_DIR $CFDEM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
  174. setVar CFDEM_USER_APP_DIR $CFDEM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin
  175.  
  176. addPath "$CFDEM_APP_DIR" "$CFDEM_USER_APP_DIR"
  177.  
  178. #- path to OF version flag file
  179. export CFDEM_OFVERSION_DIR=$CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/OFversion
  180. #------------------------------------------------------------------------------
  181. #- settings for lpp postproc tool
  182. #------------------------------------------------------------------------------
  183.  
  184. #- nr of procs for lpp tool
  185. export CFDEM_LPP_NPROCS=1
  186.  
  187. #- nr of procs for lpp tool
  188. export CFDEM_LPP_CHUNKSIZE=1
  189.  
  190. #- shortcut to run lpp
  191. alias cfdemLpp='python -i $CFDEM_LPP_DIR/lpp.py --cpunum $CFDEM_LPP_NPROCS --chunksize $CFDEM_LPP_CHUNKSIZE'
  192.  
  193. #------------------------------------------------------------------------------
  194. #- aliases for easy navigation (no changes necessary)
  195. #------------------------------------------------------------------------------
  196. #- shortcut to cfdem path
  197. alias cfdem='cd $CFDEM_PROJECT_DIR'
  198.  
  199. #- shortcut to src path
  200. alias cfdemSrc='cd $CFDEM_SRC_DIR'
  201.  
  202. #- shortcut to etc path
  203. alias cfdemEtc='cd $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc'
  204.  
  205. #- shortcut to tutorial path
  206. alias cfdemTut='cd $CFDEM_TUT_DIR'
  207.  
  208. #- shortcut to solver path
  209. alias cfdemSol='cd $CFDEM_SOLVER_DIR'
  210.  
  211. #- shortcut to utilities path
  212. alias cfdemUt='cd $CFDEM_UT_DIR'
  213.  
  214. #- shortcut to run path
  215. alias cfdemRun='cd $CFDEM_PROJECT_USER_DIR/run'
  216.  
  217. #- shortcut to user solver path
  218. alias cfdemUsrSol='cd $CFDEM_PROJECT_USER_DIR/applications/solvers'
  219.  
  220. #- shortcut to documentation path
  221. alias cfdemDoc='cd $CFDEM_DOC_DIR'
  222.  
  223. #- shortcut to open the doxygen with firefox
  224. alias cfdemDox='firefox $CFDEM_DOC_DIR/doxygen/html/index.html'
  225.  
  226. #- shortcut to LIGGGHTS path
  227. alias cfdemLIG='cd $CFDEM_LIGGGHTS_SRC_DIR'
  228.  
  229. #- shortcut to system test
  230. alias cfdemSysTest='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/cfdemSystemTest.sh'
  231.  
  232. #- shortcut to pull LIGGGHTS
  233. alias cfdemPullLIG='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/pullLIGGGHTS.sh'
  234.  
  235. #- shortcut to pull CFDEMcoupling
  236. alias cfdemPullCFDEMcoupling='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/pullCFDEMcoupling.sh'
  237.  
  238. #- shortcut to clean CFDEM
  239. alias cfdemCleanCFDEM='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/cleanCFDEMcoupling.sh'
  240.  
  241. #- shortcut to compile LIGGGHTS + sublibraries
  242. alias cfdemCompLIG='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileLIGGGHTS.sh'
  243.  
  244. #- shortcut to compile LIGGGHTS' sublibraries
  245. alias cfdemCompLIGlibs='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileLIGGGHTS_lib.sh'
  246.  
  247. #- shortcut to compile CFDEMcoupling +LIGGGHTS
  248. alias cfdemCompCFDEMall='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileCFDEMcoupling_all.sh'
  249.  
  250. #- shortcut to compile CFDEMcoupling (src+solvers)
  251. alias cfdemCompCFDEM='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileCFDEMcoupling.sh'
  252.  
  253. #- shortcut to compile CFDEMcoupling src
  254. alias cfdemCompCFDEMsrc='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileCFDEMcoupling_src.sh'
  255.  
  256. #- shortcut to compile CFDEMcoupling solvers
  257. alias cfdemCompCFDEMsol='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileCFDEMcoupling_sol.sh'
  258.  
  259. #- shortcut to compile CFDEMcoupling utilities
  260. alias cfdemCompCFDEMuti='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/compileCFDEMcoupling_uti.sh'
  261.  
  262. #- shortcut to test basic tutorials
  263. alias cfdemTestTUT='bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/testTutorials.sh'
  264.  
  265. #- refresh link to LIGGGHTS binary
  266. alias cfdemRefreshLigLink='ln -sf $CFDEM_LIGGGHTS_LIB_PATH/lib$CFDEM_LIGGGHTS_LIB_NAME.so $CFDEM_LIB_DIR'
  267.  
  268. #- shortcut to change dictionaries according to OF version
  269. cfdemChangeTutOFversion() { bash $CFDEM_SRC_DIR/lagrangian/cfdemParticle/etc/OFVersionChange/shellScripts/cfdemChangeTutOFversion_all.sh $1; }
  270. export -f cfdemChangeTutOFversion
  271.  
  272. #- shortcut to visualize the clock model data
  273. alias vizClock='python $CFDEM_UT_DIR/vizClock/matPlot.py'
  274.  
  275. #- recursive touch of current directory
  276. alias touchRec='find ./* -exec touch {} \;'
  277.  
  278. #- shortcut to run liggghts in serial
  279. cfdemLiggghts() { $CFDEM_LIGGGHTS_EXEC -in $1; }
  280. export -f cfdemLiggghts
  281.  
  282. #- shortcut to run liggghts in parallel
  283. cfdemLiggghtsPar() { mpirun -np $2 $CFDEM_LIGGGHTS_EXEC -in $1; }
  284. export -f cfdemLiggghtsPar
  285.  
  286. #- shortcut to open files including a pattern
  287. cfdemGrep() { grep -rl "$1" ./* | xargs gedit; }
  288. export -f cfdemGrep
  289.  
  290. #- shortcut lo list files in a directory
  291. #cfdemListFiles() { find $1 | sed s:""$1"":: > listOfFiles.txt; }   #leave out the dir iteslf in list
  292. cfdemListFiles() { find $1 > listOfFiles.txt; }                     #keep the dir in list
  293. export -f cfdemListFiles
  294.  
  295. #- function to unload environment, everything starting with CFDEM_ and containing cfdem
  296. cfdemUnsetEnv() { unset cfdemLiggghts cfdemLiggghtsPar cfdemGrep cfdemListFiles cfdemChangeTutOFversion cfdemUnsetEnv;
  297.                   cfdemDirs="$CFDEM_PROJECT_DIR $CFDEM_LIB_DIR $CFDEM_USER_LIB_DIR $CFDEM_APP_DIR $CFDEM_USER_APP_DIR";
  298.                   foamClean=$WM_PROJECT_DIR/bin/foamCleanPath;
  299.                   cleaned=$($foamClean "$PATH" "$cfdemDirs") && PATH="$cleaned";
  300.                   cleaned=$($foamClean "$LD_LIBRARY_PATH" "$cfdemDirs") && LD_LIBRARY_PATH="$cleaned";
  301.                   unset $(env | grep "CFDEM_" |awk -F'=' '{print $1}');
  302.                   unalias $(env | grep "cfdem" |awk -F'=' '{print $1}');
  303.                   unset foamClean cleaned; }
  304.  
  305. export -f cfdemUnsetEnv
  306.  
  307. # check if the run directory exists
  308. if [ -d "$CFDEM_PROJECT_USER_DIR" ]; then
  309.     :
  310. else
  311. # echo "make new dirs $CFDEM_PROJECT_USER_DIR ? (y/n)"
  312. # read YN
  313. # if [ $YN == "y" ]; then
  314.             mkdir -p $CFDEM_PROJECT_USER_DIR
  315.             cd $CFDEM_PROJECT_USER_DIR
  316.             mkdir run
  317.             mkdir -p log/logFilesCFDEM-$CFDEM_VERSION-$WM_PROJECT_VERSION
  318.             mkdir -p applications/solvers
  319.             mkdir -p $CFDEM_LIB_DIR
  320.             mkdir -p $CFDEM_USER_LIB_DIR
  321.             mkdir -p $CFDEM_APP_DIR
  322.             mkdir -p $CFDEM_USER_APP_DIR
  323. #       else
  324. #            echo "aborted by user."
  325. #            #exit
  326. #        fi
  327. # fi
  328.  
  329. # detect OF version
  330. if [[ $WM_PROJECT_VERSION == 5.* ]]; then
  331.     export CFDEM_WM_PROJECT_VERSION=50
  332. elif [[ $WM_PROJECT_VERSION == 4.* ]]; then
  333.     export CFDEM_WM_PROJECT_VERSION=40
  334.     cfdemecho "************************************"
  335.     cfdemecho "WARNING from your CFDEM code!"
  336.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  337.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  338.     cfdemecho "************************************"
  339.     sleep 1.5
  340. elif [[ $WM_PROJECT_VERSION == 3.0.* ]]; then
  341.     export CFDEM_WM_PROJECT_VERSION=30
  342.     cfdemecho "************************************"
  343.     cfdemecho "WARNING from your CFDEM code!"
  344.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  345.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  346.     cfdemecho "************************************"
  347.     sleep 1.5
  348. elif [[ $WM_PROJECT_VERSION == v1606+ ]]; then
  349.     export CFDEM_WM_PROJECT_VERSION=1606
  350.     cfdemecho "************************************"
  351.     cfdemecho "WARNING from your CFDEM code!"
  352.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  353.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  354.     cfdemecho "************************************"
  355.     sleep 1.5
  356. elif [[ $WM_PROJECT_VERSION == v1612+ ]]; then
  357.     export CFDEM_WM_PROJECT_VERSION=1612
  358.     cfdemecho "************************************"
  359.     cfdemecho "WARNING from your CFDEM code!"
  360.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  361.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  362.     cfdemecho "************************************"
  363.     sleep 1.5
  364. elif [[ $WM_PROJECT_VERSION == v1706 ]]; then
  365.     export CFDEM_WM_PROJECT_VERSION=1706
  366.     cfdemecho "************************************"
  367.     cfdemecho "WARNING from your CFDEM code!"
  368.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  369.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  370.     cfdemecho "************************************"
  371.     sleep 1.5
  372. elif [[ $WM_PROJECT_VERSION == 2.4.* ]]; then
  373.     export CFDEM_WM_PROJECT_VERSION=24
  374.     cfdemecho "************************************"
  375.     cfdemecho "WARNING from your CFDEM code!"
  376.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  377.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  378.     cfdemecho "************************************"
  379.     sleep 1.5
  380. elif [[ $WM_PROJECT_VERSION == "3.2" && $WM_FORK == "extend" ]]; then
  381.     export CFDEM_WM_PROJECT_VERSION=132
  382.     cfdemecho "************************************"
  383.     cfdemecho "WARNING from your CFDEM code!"
  384.     cfdemecho "WARNING: Coupling with your OpenFOAM(R) version is not officially supported!"
  385.     cfdemecho "In doubt switch to OpenFOAM(R) 5.x."
  386.     cfdemecho "************************************"
  387.     sleep 1.5
  388. else
  389.     clear
  390.     cfdemecho "************************************"
  391.     cfdemecho "ERROR from your CFDEM code!"
  392.     cfdemecho "ERROR: your OpenFOAM(R) version is not supported!"
  393.     cfdemecho "Please use a version that is supported, i.e., see the bashrc file in the source directory!"
  394.     cfdemecho "************************************"
  395.     sleep 1.5
  396. fi
  397.  
  398. cfdemecho "************************************"
  399.  
  400. unset addPath addLDLib cfdemecho setVar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement