File openfoam7.spec of Package openfoam7
#
# spec file for package openfoam30x
#
# Copyright (c) 2015 Armin Wehrfritz, 2016 Torben Hansen
#
# 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 http://bugs.opensuse.org/
#
# norootforbuild
%define source_name OpenFOAM
%define openfoam_version 6
%define openfoam_git_revision
Summary: Open source Computational Fluid Dynamics (CFD) toolbox
Name: openfoam%{openfoam_version}
Version: %{openfoam_version}
Release: 1
License: GPL-3.0+
Group: Development/Tools/Other
Provides: openfoam = %{version}
URL: http://www.openfoam.com/
Source0: %{source_name}-%{openfoam_version}-git%{openfoam_git_revision}.tar.bz2
Source1: openfoam40x-rpmlintrc
Patch0: openfoam-config-install-dir.patch
Patch1: openfoam-config-scotch.patch
# Patch2: openfoam-config-CGAL-boost.patch
Patch3: openfoam-Use-ParaView-builtin-reader-by-default.patch
Patch4: alias.patch
Patch5: lib-scotch.patch
# 'mpirun' crashes if only 'openmpi' is installed
#Requires: openmpi
Requires: openmpi3-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: scotch-devel
Requires: boost-devel
Requires: libcgal-devel
# Requires: doxygen
# Requires: graphviz
# Requires: cmake
# Requires: gcc-fortran # for cmake?
# Requires: libqt4-devel
BuildRequires: openmpi3-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: scotch-devel
BuildRequires: ptscotch-openmpi3-devel
BuildRequires: boost-devel
BuildRequires: libcgal-devel
# BuildRequires: doxygen
# BuildRequires: graphviz
# BuildRequires: cmake
# BuildRequires: gcc-fortran # for cmake?
# BuildRequires: libqt4-devel
BuildRequires: openfoam-selector
Requires(post): openfoam-selector
Requires(preun): openfoam-selector
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
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.
NOTES:
* Compiled with system openmpi.
* The package installs to: /opt/%{source_name}-%{openfoam_version}/
* To set the environment variables for OpenFOAM %{openfoam_version}, add the
following line to your ~/.bashrc file:
source /opt/%{source_name}-%{openfoam_version}/etc/bashrc
%prep
# 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
%build
%if 0%{?suse_version}
if [ -f %{_libdir}/mpi/gcc/openmpi/bin/mpivars.sh ]
then
source %{_libdir}/mpi/gcc/openmpi/bin/mpivars.sh
fi
%endif
mpipath=`which mpirun | sed -s "s?bin/mpirun??g"`
# Set build architecture
%ifarch i586
sed -e 's/WM_ARCH_OPTION=64/WM_ARCH_OPTION=32/' -i ./etc/bashrc
%endif
# Setup the build environment
export FOAM_INST_DIR=%{_builddir}
foamDotFile=$FOAM_INST_DIR/%{source_name}-%{openfoam_version}/etc/bashrc
[ -f $foamDotFile ] && . $foamDotFile
echo here
# Number of parallel builds
[ -z "$RPM_BUILD_NCPUS" ] && \
RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
export WM_NCOMPPROCS=$RPM_BUILD_NCPUS
# 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
export SUSE_ASNEEDED=0
export LINK_FLAGS=-L%{_libdir}/mpi/gcc/openmpi/%{_lib}/
./Allwmake
# 2>&1 | tee buildLogAllwmake
# bzip2 buildLogAllwmake
# DO NOT RUN 'wclean all', OTHERWISE IT IS NOT POSSIBLE TO COMPILE LIBRARIES,
# SOLVERS OR TOOLS IN THE OpenFOAM ENVIRONMENT
## Clean object and include files
#wclean all
%install
mkdir -p %{buildroot}/opt/
cp -a %{_builddir}/%{source_name}-%{openfoam_version} \
%{buildroot}/opt/%{source_name}-%{openfoam_version}
pushd %{buildroot}
# Create a sym-link to ensure backwards compatibility
pushd opt/%{source_name}-%{openfoam_version}/etc
ln -s bashrc %{name}
popd
# Remove unwanted files
rm -f opt/%{source_name}-%{openfoam_version}/bin/tools/replaceAllShellSun
rm -f opt/%{source_name}-%{openfoam_version}/tutorials/incompressible/shallowWaterFoam/squareBump/.gmtcommands4
# Permission fixes for system-wide installation
chmod -R +r opt/
find opt/ -iname *.C -o -iname *.H | xargs -n1 chmod -x
popd
%clean
rm -rf %{buildroot}
%post
/usr/bin/openfoam-selector --register OpenFOAM-%{openfoam_version} --source-dir "/opt/%{source_name}-%{openfoam_version}" --yes
%preun
# Only unregister when uninstalling
if [ "$1" = "0" ]
then
# Deregister default if we are uninstalling it
if [ "$(/usr/bin/openfoam-selector --system --query)" = "OpenFOAM-%{openfoam_version}" ]
then
/usr/bin/openfoam-selector --system --unset --yes
fi
if /usr/bin/openfoam-selector --unregister OpenFOAM-%{openfoam_version} --yes
then
echo "Unregistered OpenFOAM-%{openfoam_version} from openfoam-selector"
else
echo "No OpenFOAM-%{openfoam_version} found to unregister from openfoam-selector"
fi
fi
%files
%defattr(-,root,root)
/opt/%{source_name}-%{openfoam_version}/
%changelog