File openfoam22x.spec of Package openfoam22x

# spec file for package openfoam22x
# Copyright (c) 2013-2014 Armin Wehrfritz
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via

# norootforbuild

%define source_name OpenFOAM
%define openfoam_version 2.2.x
%define openfoam_git_revision 1f35a0f

Summary:       Open source Computational Fluid Dynamics (CFD) toolbox
Name:          openfoam22x
Version:       %{openfoam_version}
Release:       1
License:       GPL-3.0+
Group:         Development/Tools/Other
Provides:      openfoam = %{version}
Source0:       %{source_name}-%{openfoam_version}-git%{openfoam_git_revision}.tar.bz2
Source1:       openfoam22x-rpmlintrc
Patch0:        openfoam-config-openmpi.patch
Patch1:        openfoam-config-install-dir.patch
Patch2:        openfoam-config-scotch.patch
Patch3:        openfoam-config-boost.patch
Patch4:        openfoam-Use-ParaView-builtin-reader-by-default.patch
# Backport corrections from OpenFOAM-2.3.x
Patch5:        openfoam-fieldAverage-Update-to-23x.patch
# Add patch from OpenFOAM-dev (commit 4df8179f3290238ed6f09ff7aaea7970ac1c367d)
Patch6:        openfoam-fieldAverage-Correct-handling-of-resetOnOutput.patch

# 'mpirun' crashes if only 'openmpi' is installed
#Requires:      openmpi
Requires:      openmpi-devel
Requires:      gnuplot
# Put development packages to 'Requires' to compile own libraries, solvers and
# tools in the OpenFOAM environment
Requires:      gcc >= 4.5
Requires:      gcc-c++ >= 4.5
Requires:      flex
Requires:      bison
Requires:      fdupes
Requires:      make
Requires:      ncurses-devel
Requires:      binutils-devel
Requires:      zlib-devel
Requires:      readline-devel
Requires:      libscotch-devel
Requires:      boost-devel
# Requires:      doxygen
# Requires:      graphviz
# Requires:      cmake
# Requires:      gcc-fortran # for cmake?
# Requires:      libqt4-devel

BuildRequires:      openmpi-devel
BuildRequires:      gnuplot
BuildRequires:      gcc >= 4.5
BuildRequires:      gcc-c++ >= 4.5
BuildRequires:      flex
BuildRequires:      bison
BuildRequires:      fdupes
BuildRequires:      make
BuildRequires:      ncurses-devel
BuildRequires:      binutils-devel
BuildRequires:      zlib-devel
BuildRequires:      readline-devel
BuildRequires:      libscotch-devel
BuildRequires:      boost-devel
# BuildRequires:      doxygen
# BuildRequires:      graphviz
# BuildRequires:      cmake
# BuildRequires:      gcc-fortran # for cmake?
# BuildRequires:      libqt4-devel

BuildRoot:     %{_tmppath}/%{name}-%{version}-build

The OpenFOAM(R)  (Open Field Operation and Manipulation) CFD Toolbox is a free,
open source CFD software package which has a large user base across most areas
of engineering and science, from both commercial and academic organisations.
OpenFOAM has an extensive range of features to solve anything from complex fluid
flows involving chemical reactions, turbulence and heat transfer, to solid
dynamics and electromagnetics. It includes tools for meshing, notably
snappyHexMesh, a parallelised mesher for complex CAD geometries, and for pre-
and post-processing. Almost everything (including meshing, and pre- and
post-processing) runs in parallel as standard, enabling users to take full
advantage of computer hardware at their disposal.

By being open, OpenFOAM offers users complete freedom to customise and extend
its existing functionality, either by themselves or through support from
OpenCFD. It follows a highly modular code design in which collections of
functionality (e.g. numerical methods, meshing, physical models, ...) are each
compiled into their own shared library. Executable applications are then created
that are simply linked to the library functionality. OpenFOAM includes over 80
solver applications that simulate specific problems in engineering mechanics and
over 170 utility applications that perform pre- and post-processing tasks, e.g.
meshing, data visualisation, etc.

* Compiled with system openmpi.
* The package installs to: /opt/openfoam/%{source_name}-%{openfoam_version}/
* To set the environment variables for OpenFOAM %{openfoam_version}, add the
  following line to your ~/.bashrc file:
  source /opt/openfoam/%{source_name}-%{openfoam_version}/etc/bashrc

# ThirdParty sources are not needed, use system tools/libs instead
# Unpack OpenFOAM sources
%setup -q -n %{source_name}-%{openfoam_version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1


# Set build architecture
%ifarch i586
 sed -e 's/WM_ARCH_OPTION=64/WM_ARCH_OPTION=32/' -i ./etc/bashrc

# Setup the build environment
export FOAM_INST_DIR=%{_builddir}
[ -f $foamDotFile ] && . $foamDotFile

# Number of parallel builds
[ -z "$RPM_BUILD_NCPUS" ] && \
     RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"

# Build OpenFOAM
# As for the 'openSUSE Build Service' --as-needed is enabled by default, the
# -llibname must be in the right order, otherwise the build will fail due to
# undefined symbols/ reference. To avoid this behaviour set SUSE_ASNEEDED=0.
# SUSE_ASNEEDED=0 is needed in order to build OpenFOAM correctly

./Allwmake 2>&1 | tee buildLogAllwmake
bzip2 buildLogAllwmake

## Clean object and include files
#wclean all

mkdir -p %{buildroot}/opt/openfoam
cp -a %{_builddir}/%{source_name}-%{openfoam_version} \

pushd %{buildroot}
 # Create a sym-link to ensure backwards compatibility
 pushd opt/openfoam/%{source_name}-%{openfoam_version}/etc
  ln -s bashrc %{name}

 # Remove unwanted files
 rm -f opt/openfoam/%{source_name}-%{openfoam_version}/bin/tools/replaceAllShellSun
 rm -f opt/openfoam/%{source_name}-%{openfoam_version}/tutorials/incompressible/shallowWaterFoam/squareBump/.gmtcommands4

 # Permission fixes for system-wide installation
 chmod -R +r opt/
 find opt/openfoam/ -iname *.C -o -iname *.H | xargs -n1 chmod -x

rm -rf %{buildroot}

%dir /opt/openfoam/

openSUSE Build Service is sponsored by