Name: openfoam Version: 13 Release: 1%{?dist} Summary: Open source CFD (Computational Fluid Dynamics) toolbox License: GPL-3.0-or-later URL: https://openfoam.org/ Source0: https://github.com/OpenFOAM/OpenFOAM-%{version}/archive/refs/tags/version-%{version}.tar.gz#/OpenFOAM-%{version}.tar.gz Source1: https://github.com/OpenFOAM/ThirdParty-%{version}/archive/refs/tags/version-%{version}.tar.gz#/ThirdParty-%{version}.tar.gz BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires: flex BuildRequires: zlib-devel BuildRequires: openmpi-devel BuildRequires: boost-devel BuildRequires: CGAL-devel BuildRequires: fftw-devel BuildRequires: scotch-devel BuildRequires: metis-devel BuildRequires: readline-devel BuildRequires: ncurses-devel Requires: openmpi Requires: environment-modules # Filter private libraries %global __provides_exclude_from ^%{_libdir}/openfoam/.*\\.so.*$ %global __requires_exclude ^(libOpenFOAM|libfiniteVolume|libmeshTools|libtriSurface|libfileFormats|libgenericPatchFields|liblagrangian|libconversion|libsampling|libsurfMesh).*\\.so.*$ %description OpenFOAM is a free, open source CFD software package developed by OpenFOAM Foundation. It 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. %prep %setup -q -n OpenFOAM-%{version}-version-%{version} -a 1 # Move ThirdParty to expected location mv ThirdParty-%{version}-version-%{version} ../ThirdParty-%{version} %build # Source OpenFOAM environment export FOAM_INST_DIR=$(cd .. && pwd) export WM_PROJECT_DIR=$(pwd) # Configure for system installation sed -i "s|WM_PROJECT_INST_DIR=\$FOAM_INST_DIR|WM_PROJECT_INST_DIR=%{_libdir}|" etc/bashrc sed -i "s|export WM_PROJECT_USER_DIR=.*|export WM_PROJECT_USER_DIR=\$HOME/OpenFOAM/\$USER-\$WM_PROJECT_VERSION|" etc/bashrc # Use system MPI sed -i "s|export WM_MPLIB=SYSTEMOPENMPI|export WM_MPLIB=OPENMPI|" etc/config.sh/mpi || true sed -i "s|WM_MPLIB=SYSTEMOPENMPI|WM_MPLIB=OPENMPI|" etc/bashrc || true # Set compiler flags export FOAM_EXTRA_CFLAGS="%{optflags}" export FOAM_EXTRA_CXXFLAGS="%{optflags}" # Set number of build processes export WM_NCOMPPROCS="%{?_smp_mflags}" # Load MPI module %_openmpi_load # Source the environment source etc/bashrc # Build OpenFOAM ./Allwmake -j -s -q 2>&1 | tee build.log || ./Allwmake -j 2>&1 | tee build-verbose.log %_openmpi_unload %install # Create installation directory install -dm 0755 %{buildroot}%{_libdir}/openfoam-%{version} # Copy the built files cp -a platforms %{buildroot}%{_libdir}/openfoam-%{version}/ cp -a etc %{buildroot}%{_libdir}/openfoam-%{version}/ cp -a bin %{buildroot}%{_libdir}/openfoam-%{version}/ cp -a applications %{buildroot}%{_libdir}/openfoam-%{version}/ cp -a tutorials %{buildroot}%{_libdir}/openfoam-%{version}/ # Create environment module file install -dm 0755 %{buildroot}%{_datadir}/modulefiles/openfoam cat > %{buildroot}%{_datadir}/modulefiles/openfoam/%{version} <<'EOF' #%%Module1.0 proc ModulesHelp { } { puts stderr "OpenFOAM %{version} - CFD Toolbox" } module-whatis "OpenFOAM %{version} - Open source CFD toolbox" module load mpi/openmpi-%{_arch} setenv FOAM_INST_DIR %{_libdir} setenv WM_PROJECT_DIR %{_libdir}/openfoam-%{version} setenv WM_PROJECT OpenFOAM setenv WM_PROJECT_VERSION %{version} prepend-path PATH %{_libdir}/openfoam-%{version}/platforms/linux64GccDPInt32Opt/bin prepend-path LD_LIBRARY_PATH %{_libdir}/openfoam-%{version}/platforms/linux64GccDPInt32Opt/lib EOF # Create wrapper script install -dm 0755 %{buildroot}%{_sysconfdir}/profile.d cat > %{buildroot}%{_sysconfdir}/profile.d/openfoam-%{version}.sh <<'EOF' #!/bin/bash # OpenFOAM %{version} environment setup export FOAM_INST_DIR=%{_libdir} export WM_PROJECT_DIR=%{_libdir}/openfoam-%{version} if [ -f $WM_PROJECT_DIR/etc/bashrc ]; then source $WM_PROJECT_DIR/etc/bashrc fi EOF %files %doc README.md %license COPYING %config(noreplace) %{_sysconfdir}/profile.d/openfoam-%{version}.sh %{_libdir}/openfoam-%{version}/ %{_datadir}/modulefiles/openfoam/%{version} %changelog * Mon Oct 27 2025 Your Name - 13-1 - Initial OpenFOAM 13 package for COPR