Dirty script for dirty meshes

If you have a messy polyMesh you might use this script. Modify it to suit your needs.

#!/bin/sh
# dirty script for dirty meshes
# author Bjorn Bergqvist
# http://www.discretizer.se
# removes cells which is/have:
# zeroVolumeCells, skewFaces, underdeterminedCells and lowQualityTetFaces
#
# if you have to type something before OpenFOAM commands
# qsub... or somthing
submit=""

# create a batch file for setSet
createBatchFile() {
  counter=0
  echo "cellSet cellsToKeep new" > $2
  for i in `grep Writing $1 |awk '{ print $NF }'`
    do

      if [ $i == "zeroVolumeCells" ]; then
        echo "cellSet cellsToKeep add cellToCell zeroVolumeCells any" >> $2
        echo `grep $i log.checkMesh`
        counter=$((counter+1)) 
      fi
      if [ $i == "skewFaces" ]; then
        echo "cellSet cellsToKeep add faceToCell skewFaces any" >> $2
        echo `grep $i log.checkMesh`
        counter=$((counter+1)) 
      fi
      if [ $i == "underdeterminedCells" ]; then
        echo "cellSet cellsToKeep add cellToCell underdeterminedCells any" >> $2
        echo `grep $i log.checkMesh`
        counter=$((counter+1)) 
      fi
      if [ $i == "lowQualityTetFaces" ]; then
        echo "cellSet cellsToKeep add faceToCell lowQualityTetFaces any" >> $2
        echo `grep $i log.checkMesh`
        counter=$((counter+1)) 
      fi
    done
    echo "cellSet cellsToKeep invert" >> $2
    echo "cellSet cellsToKeep subset" >> $2
    echo "quit" >> $2
    return $counter
}

logfile=log.txt
echo "" > $logfile

while :
do
  $submit checkMesh -allGeometry -allTopology -latestTime > log.checkMesh
  checkString=`grep 'The mesh has multiple regions' log.checkMesh`
  if [ ! ${#checkString} == 0 ]; then
    echo "multiple regions: splitMeshRegions"
    $submit splitMeshRegions -largestOnly >> $logfile
    $submit subsetMesh -overwrite region0 >> $logfile
    $submit createPatch -overwrite >> $logfile
    echo "rerun checkMesh"
    $submit checkMesh -allGeometry -allTopology -latestTime > log.checkMesh
  fi
  createBatchFile log.checkMesh batchForDeleting
  fileOk=$?
  echo "fileOk $fileOk"
  if [ $fileOk == 0 ]; then
    echo "nothing to do"
    exit 0
  fi
  $submit setSet -latestTime -batch batchForDeleting > $logfile
  $submit subsetMesh cellsToKeep >> $logfile
  $submit createPatch -overwrite >> $logfile
done

Typical output:

<<Writing 4 zero volume cells to set zeroVolumeCells
<<Writing 232 skew faces to set skewFaces
<<Writing 118 faces with low quality or negative volume decomposition tets to set lowQualityTetFaces
<<Writing 3806 under-determined cells to set underdeterminedCells
fileOk 4
multiple regions: splitMeshRegions
rerun checkMesh
<<Writing 114 skew faces to set skewFaces
<<Writing 1732 under-determined cells to set underdeterminedCells
fileOk 2
multiple regions: splitMeshRegions
rerun checkMesh
<<Writing 6 skew faces to set skewFaces
<<Writing 608 under-determined cells to set underdeterminedCells
fileOk 2
multiple regions: splitMeshRegions
rerun checkMesh
<<Writing 247 under-determined cells to set underdeterminedCells
fileOk 1
multiple regions: splitMeshRegions
rerun checkMesh
<<Writing 125 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 72 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 44 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 27 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 20 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 12 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 5 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 3 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 1 under-determined cells to set underdeterminedCells
fileOk 1
<<Writing 1 under-determined cells to set underdeterminedCells
fileOk 1
fileOk 0
nothing to do

Add Numpy to python install

install Numpy numpy-1.8.1.tar.gz download from http://sourceforge.net/projects/numpy
module load python/2.7.6  # build python
use gfortran
python setup.py build –fcompiler=gnu95
checkinstall python setup.py install

Python 3.4

python setup.py clean
module unload python/2.7.6
module load python/3.4.1
python3 setup.py build –fcompiler=gnu95
checkinstall python3 setup.py install

Cantera installation

Download cantera from http://code.google.com/p/cantera

module load scons/2.3.1  # build scons
module load python/2.7.6  # build python
scons build prefix=/opt/cantera/2.0-python-2.7.6
scons test
scons install

module file /etc/modulefiles/cantera/2.0-python-2.7.6

#%Module1.0####################################################################
##
## Discretizer AB modulefile
##
##
## Add directory to the path
prepend-path PATH /opt/cantera/2.0-python-2.7.6/bin
prepend-path PYTHONPATH /opt/cantera/2.0-python-2.7.6/lib/python2.7/site-packages

module load python/2.7.6

Elmer tetgen plugin and more

tetgen plugin in
module load tetgen/1.4.3 qt/4.8.6
export ELMER_HOME=/opt/elmer/7
qmake
make -j4
make install

elmer solvers
#build elmer solvers
export FC=gfortran
export F77=gfortran

#Optimization:
export CFLAGS=”-O3″
export FCFLAGS=”-O3″
export FFLAGS=”-O3″
export CXXFLAGS=”-O3″

export NPROCS=4
#export USE_OWN_MATHLIBS=”yes”
export LIBS=-lpthread
buildtools/compile.sh

mathlibs
export LIBS=-lpthread
./configure –prefix=/opt/elmer/7 –exec-prefix=/opt/elmer/7 –oldincludedir=/opt/elmer/7 –with-mpi=yes –with-mpi-inc-dir=/usr/include/openmpi-x86_64 –with-mpi-lib-dir=/usr/lib64/openmpi/lib/openmpi/

compile elmerfem/fem
module load openfoam/2.3.x
cd fem
./configure –prefix=/opt/elmer/7 –exec-prefix=/opt/elmer/7
compile post
change in configure file: acx_tcltk_tcl_h_locs=”$acx_tcltk_tcl_h_locs /opt/tcltk/8.5.13/include /usr/include /usr/local/include /include /usr/swf/include /sw/include /sw/usr/include /really/weird/place /ok/I/quit”
./configure –prefix=/opt/elmer/7 –exec-prefix=/opt/elmer/7
make -j4;make install

ElmerGUI standalone installation on CentOS

elmergui dir from elmerfem trunk (http://www.csc.fi/english/pages/elmer)
edit ElmerGUI.pri
module load qt/4.8.6 vtk/5.10.1 tbb/3.0-018
qmake
make
make install

module file /etc/modulefiles/elmer/7

#%Module1.0#########################################
##
## Discretizer AB modulefile
##
##
setenv ELMER_HOME /opt/elmer/7
setenv ELMERGUI_HOME /opt/elmer/7/bin
setenv ELMER_POST_HOME /opt/elmer/7/share/elmerpost
prepend-path PATH /opt/elmer/7/bin
prepend-path LD_LIBRARY_PATH /opt/elmer/7/lib

module load qwt/6.0.2 vtk/5.10.1 occ/6.5.4 tbb/3.0-018 openfoam/2.3.x

Elmergui.pri file: ElmerGUI.pri

Tetgen install

Download tetgen1.4.3.tar.gz from http://wias-berlin.de/software/tetgen
make
cp libtet.a and tetgen to lib and bin place

module file /etc/modulefiles/tetgen/1.4.3

#%Module1.0##########################################
##
## Discretizer AB modulefile
##
## Add directory to the path
prepend-path PATH /opt/tetgen/1.4.3/bin
prepend-path LD_LIBRARY_PATH /opt/tetgen/1.4.3/lib

PythonQT 2.1 standalone install on CentOS

Download PythonQt2.1_Qt4.8.zip from http://sourceforge.net/projects/pythonqt
module load cmake/2.8.12.2 qt/4.8.6  # check cmake and qt installations (also python should be loaded?)
cmake . -DCMAKE_INSTALL_PREFIX=/opt/pyqt/2.1
make -j4
make install

module file /etc/modulefiles/pyqt/2.1

#%Module1.0#########################################
##
##  Discretizer AB modulefile
##
##
## Set environment variables
setenv          PYQT4_ROOT_DIR     ”/opt/pyqt/2.1”
prepend-path    LD_LIBRARY_PATH    /opt/pyqt/2.1/lib

VTK 5.10.1 standalone install on CentOS

Download vtk-5.10.1.tar.gz from http://www.vtk.org
module load cmake/2.8.12.2  # (cmake installation)
module load qt/4.8.6   # (qt installation)

cmake -DVTK_USE_QT:BOOL=ON -DVTK_USE_GUISUPPORT:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_INSTALL_PREFIX=/opt/vtk/5.10.1 .
make -j4
make install

module file /etc/modulefiles/vtk/5.10.1

#%Module1.0##########################################
##
##  Discretizer AB modulefile
##
##
## Add directory to the path
prepend-path    PATH    /opt/vtk/5.10.1/bin
prepend-path    LD_LIBRARY_PATH  /opt/vtk/5.10.1/lib/vtk-5.10