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 # Extract in parent directory without auto-cd cd %{_builddir} rm -rf OpenFOAM-%{version} ThirdParty-%{version} tar -xzf %{SOURCE0} tar -xzf %{SOURCE1} # Rename to expected names mv OpenFOAM-%{version}-version-%{version} OpenFOAM-%{version} mv ThirdParty-%{version}-version-%{version} ThirdParty-%{version} cd OpenFOAM-%{version} %build # Change to the renamed directory cd %{_builddir}/OpenFOAM-%{version} # Source OpenFOAM environment export FOAM_INST_DIR=$(cd .. && pwd) export WM_PROJECT_DIR=$(pwd) # Don't modify etc/bashrc yet - we need to source it first for the build # We'll configure the installed version in %install # 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 (ignore return code from bashrc's function context issues) source etc/bashrc || true # After sourcing, override to use system libraries instead of building ThirdParty versions export SCOTCH_TYPE=system export METIS_TYPE=system export PARMETIS_TYPE=none # Build OpenFOAM ./Allwmake -j -s -q 2>&1 | tee build.log || ./Allwmake -j 2>&1 | tee build-verbose.log %_openmpi_unload %install # Change to the build directory cd %{_builddir}/OpenFOAM-%{version} # 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}/ # Now configure the installed bashrc for system installation sed -i "s|WM_PROJECT_INST_DIR=\$FOAM_INST_DIR|WM_PROJECT_INST_DIR=%{_libdir}|" %{buildroot}%{_libdir}/openfoam-%{version}/etc/bashrc sed -i "s|export WM_PROJECT_USER_DIR=.*|export WM_PROJECT_USER_DIR=\$HOME/OpenFOAM/\$USER-\$WM_PROJECT_VERSION|" %{buildroot}%{_libdir}/openfoam-%{version}/etc/bashrc # 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