CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   ParaView/ParaFoam in OpenFoam 1.5 dev (http://www.cfd-online.com/Forums/openfoam-paraview/72454-paraview-parafoam-openfoam-1-5-dev.html)

titio February 5, 2010 14:12

ParaView/ParaFoam in OpenFoam 1.5 dev
 
Hi foamers,

I am having difficulties in using paraview/parafoam in OpenFoam 1.5 - dev in Ubuntu 8.1. Until now, I tried to recompile paraview and the PV3FoamReader utility following the instructions available in the OpenFoam main site and other information available at the forum

However, I was unable of installing paraview, and consequently parafoam. What should I do? I am planing to download paraview, install it, and then change the configuration files of PV3FoamReader to be able to use paraFoam.
Can I do this? Is there a better option?

Regards,

António Martins

rieuk February 25, 2010 12:06

Hey Antonio, did you end up getting paraFoam to work? I'm interested in the solution too...the buildParaView3.3-svc doesn't work in OF-1.5-dev which is very annoying.

gwierink February 27, 2010 15:02

Hi James,

I got it to work too with OpenFoam-1.5-dev (Ubuntu 9.10 x86_64). It turned out, at least in my case, that buildParaViewFunctions in $HOME/OpenFOAM/OpenFOAM-1.5-dev/bin/tools/ contained some error(s). I replaced it with buildParaViewFunctions from OpenFOAM-1.5 and it worked :D. The working buildParaViewFunctions looks like:

Code:

#---------------------------------*- sh -*-------------------------------------
# =========                |
# \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
#  \\    /  O peration    |
#  \\  /    A nd          | Copyright (C) 1991-2008 OpenCFD Ltd.
#    \\/    M anipulation  |
#------------------------------------------------------------------------------
# License
#    This file is part of OpenFOAM.
#
#    OpenFOAM is free software; you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by the
#    Free Software Foundation; either version 2 of the License, or (at your
#    option) any later version.
#
#    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
#    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#    for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with OpenFOAM; if not, write to the Free Software Foundation,
#    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
#    buildParaViewFunctions
#
# Description
#    ParaView build/install helper functions
#
#------------------------------------------------------------------------------

addCMakeVariable ()
{
    while [ -n "$1" ]
    do
        CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
        shift
    done
}


initialiseVariables ()
{
    unset CMAKE_VARIABLES OBJ_ADD

    if [ "$VERBOSE" = ON ]; then
        addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE"
    fi
    addCMakeVariable "VTK_USE_TK=FALSE"
}


addMpiSupport ()
{
    [ "$INCLUDE_MPI" = ON ] || return

    MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
    MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
    MPI_RUN=$MPI_ARCH_PATH/bin/mpirun

    OBJ_ADD="$OBJ_ADD-mpi"
    addCMakeVariable "VTK_USE_MPI=ON"
    addCMakeVariable "PARAVIEW_USE_MPI=ON"
    addCMakeVariable "MPI_INCLUDE_PATH=$MPI_INCLUDE_PATH"
    addCMakeVariable "MPI_LIBRARY=$MPI_LIBRARY"
    addCMakeVariable "VTK_MPIRUN_EXE=$MPI_RUN"
    addCMakeVariable "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
}


addPythonSupport ()
{
    [ "$INCLUDE_PYTHON" = ON ] || return

    WHICH_PYTHON=`which python`
    if [ -n "$WHICH_PYTHON" ]; then
        OBJ_ADD="$OBJ_ADD-py"

        if [ -n "$PYTHON_LIBRARY" ]; then
            # check $PYTHON_LIBRARY if it has been set
            if [ ! -e "$PYTHON_LIBRARY" ]; then
                echo "*** Error: libpython not found at location specified " \
                    "by PYTHON_LIBRARY: $PYTHON_LIBRARY"
                echo "    Please set the variable PYTHON_LIBRARY to the full"
                echo "    path to (and including) libpython, or deactivate"
                echo "    python support by setting INCLUDE_PYTHON=OFF"
                exit 1
            fi
        else
            # Try to obtain $PYTHON_LIBRARY if not set
            # - assumes dynamically linked
            PYTHON_LIBRARY=`ldd $WHICH_PYTHON | \
                sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p'`
        fi

        if [ ! -n "$PYTHON_LIBRARY" ]; then
            echo "*** Error: Unable to determine path to python library."
            echo "    Please set the variable PYTHON_LIBRARY to the full"
            echo "    path to (and including) libpython, or deactivate"
            echo "    python support by setting INCLUDE_PYTHON=OFF"
            exit 1
        fi
        PYTHON_MAJOR_VERSION=`echo $PYTHON_LIBRARY | \
            sed 's/.*libpython\(.*\)\.so.*/\1/'`
        PYTHON_INCLUDE_DIR=/usr/include/python$PYTHON_MAJOR_VERSION

        addCMakeVariable "PARAVIEW_ENABLE_PYTHON=ON"
        addCMakeVariable "PYTHON_INCLUDE_PATH=$PYTHON_INCLUDE_DIR"
        addCMakeVariable "PYTHON_LIBRARY=$PYTHON_LIBRARY"
    else
        echo "*** Error: python not installed"
        echo "***        De-activate python support by setting " \
            "INCLUDE_PYTHON=OFF"
        exit 1
    fi
}


addMesaSupport ()
{
    [ "$INCLUDE_MESA" = ON ] || return

    MESA_INCLUDE_DIR=/usr/include/GL
    MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so

    if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]; then
        OBJ_ADD="$OBJ_ADD-mesa"
        addCMakeVariable "VTK_OPENGL_HAS_OSMESA=ON"
        addCMakeVariable "OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR"
        addCMakeVariable "OSMESA_LIBRARY=$MESA_LIBRARY"
    else
        echo "*** Error: no MESA information found"
        exit 1
    fi
}


buildParaView ()
{
    # set general options
    addCMakeVariable "BUILD_SHARED_LIBS:BOOL=ON"
    addCMakeVariable "CMAKE_BUILD_TYPE:STRING=Release"

    # set paraview environment
    unset PARAVIEW_SRC_DIR
    for i in $PWD $WM_THIRD_PARTY_DIR
    do
      if [ -d $i/$PARAVIEW_SRC ]
      then
          PARAVIEW_SRC_DIR=$i/$PARAVIEW_SRC
          break
      fi
    done

    [ -d "$PARAVIEW_SRC_DIR" ] || {
      echo "did not find $PARAVIEW_SRC in these directories:"
      echo "  PWD=$PWD"
      echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
      echo "abort build"
      exit 1
    }

    # PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_OPTIONS/obj$OBJ_ADD
    PARAVIEW_OBJ_DIR=$PARAVIEW_SRC_DIR/platforms/$WM_ARCH$WM_COMPILER

    # provide a shortcut for repeated builds - use with caution
    if [ "$CMAKE_SKIP" = YES ]
    then

      # change to build folder
      cd $PARAVIEW_OBJ_DIR || exit 1

    else

      # remove existing build folder if present
      if [ -e "$PARAVIEW_OBJ_DIR" ]; then
          rm -rf $PARAVIEW_OBJ_DIR
      fi

      # create paraview build folder
      mkdir -p $PARAVIEW_OBJ_DIR
      cd $PARAVIEW_OBJ_DIR

      echo "Building $PARAVIEW_SRC"
      echo "    MPI support    : $INCLUDE_MPI"
      echo "    Python support : $INCLUDE_PYTHON"
      echo "    MESA support  : $INCLUDE_MESA"
      echo "    Source        : $PARAVIEW_SRC_DIR"
      echo "    Target        : $PARAVIEW_OBJ_DIR"

      # make paraview
      cmake \
          -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \
          $CMAKE_VARIABLES \
          $PARAVIEW_SRC_DIR
    fi

    if [ -r /proc/cpuinfo ]; then
        WM_NCOMPPROCS=`egrep "^processor" /proc/cpuinfo | wc -l`

        if [ $WM_NCOMPPROCS -gt 8 ]; then
            WM_NCOMPPROCS=8
        fi

        make -j $WM_NCOMPPROCS
    else
        make
    fi
}


installParaView ()
{
    if [ -e "$PARAVIEW_OBJ_DIR/bin/paraview" ]; then
        echo "    Build complete"

        cd $PARAVIEW_OBJ_DIR

        # Replace PARAVIEW_SRC_DIR path with ParaView_INST_DIR
        # environment variables
        echo "    Replacing path hard links"
        find . -iname \*.cmake -execdir sed -i \
            "s,$PARAVIEW_SRC_DIR,\$ENV{ParaView_INST_DIR},g" {} ';' \
            -print

        # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH
        # environment variables
        if [ "$INCLUDE_MPI" = ON ]; then
            find . -iname \*.cmake -execdir sed -i \
                "s,$MPI_ARCH_PATH,\$ENV{MPI_ARCH_PATH},g" {} ';' \
                -print
        fi

        # Replace local CMAKE_HOME path with CMAKE_HOME
        # environment variables
        find . -iname '*cmake*' -execdir sed -i \
            "s,$CMAKE_HOME,\$ENV{CMAKE_HOME},g" {} ';' \
            -print

        # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR
        # environment variables
        find . -iname '*cmake*' -execdir sed -i \
            "s,$WM_COMPILER_DIR,\$ENV{WM_COMPILER_DIR},g" {} ';' \
            -print

        # create a softlink to the $PARAVIEW_OBJ_DIR/bin folder
        # - workaround for chosen install location
        echo "    Creating paraview $PARAVIEW_MAJOR_VERSION soft link to /bin"
        (  mkdir lib && cd lib && ln -s ../bin \
            paraview-$PARAVIEW_MAJOR_VERSION  )

        # info on symlinks to screen
        echo ""
        echo "    ---"
        echo "    Installation complete"
        echo "    Set environment variables:"
        echo "    - ParaView_INST_DIR to $PARAVIEW_SRC_DIR"
        echo "    - ParaView_DIR to $PARAVIEW_OBJ_DIR"
        echo "    - PV_PLUGIN_PATH to $FOAM_LIBBIN"
        echo "    Add $PARAVIEW_OBJ_DIR/bin to PATH"
        # echo "  Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
        echo "    ---"
    fi
}


# for good measure - clear a few variables before using any of the functions

unset VERBOSE INCLUDE_MPI INCLUDE_PYTHON INCLUDE_MESA PYTHON_LIBRARY
unset CMAKE_VARIABLES OBJ_ADD
unset CMAKE_SKIP


# ----------------------------------------------------------------- end-of-file



All times are GMT -4. The time now is 09:12.