aboutsummaryrefslogtreecommitdiff
blob: 7b309190770fc8a0d7739e1db10cd4b92185f5fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

PYTHON_COMPAT=( python3_{8..9} )

inherit meson python-single-r1

DESCRIPTION="SU2: An Open-Source Suite for Multiphysics Simulation and Design"
HOMEPAGE="https://su2code.github.io/"
SRC_URI="
	https://github.com/su2code/SU2/archive/v${PV}.tar.gz -> ${P}.tar.gz
	mpp? ( https://github.com/mutationpp/Mutationpp/archive/v1.0.1.tar.gz -> mutationpp-1.0.1.tar.gz )
	test? ( https://github.com/su2code/TestCases/archive/v${PV}.tar.gz -> ${P}-TestCases.tar.gz )
	tutorials? ( https://github.com/su2code/Tutorials/archive/v${PV}.tar.gz -> ${P}-Tutorials.tar.gz )
"

# SU2: LGPL-2.1; cgnslib: ZLIB, TecIO: all-rights-reserved;
# Metis: Apache-2.0; Parmetis: all-rights-reserved, free-noncomm; Mutationpp: LGPL-3.0.
LICENSE="Apache-2.0 LGPL-2.1 LGPL-3 ZLIB all-rights-reserved free-noncomm"
SLOT="0"
KEYWORDS="~amd64"

# cgns, metis, parmetis are bundled;
# omp is disable as it's experimental;
# pastix is disabled as it's require additional external bundled libs;
# autodiff (medi), directdiff (opti) features require additional external bundled libs.
IUSE="cgns mkl +mpi mpp openblas parmetis tecio test tutorials"
RESTRICT="!test? ( test )"
REQUIRED_USE="
	${PYTHON_REQUIRED_USE}
	mkl? ( !openblas )
"

RDEPEND="
	${PYTHON_DEPS}
	mpi? ( virtual/mpi[cxx] )
	mkl? ( sci-libs/mkl )
	openblas? ( sci-libs/openblas )
"
DEPEND="
	${RDEPEND}
	tecio? ( >=dev-libs/boost-1.76.0:= )
"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}/${PN}-7.0.4-unbundle_boost.patch"
	"${FILESDIR}/${PN}-7.1.0-fix-env.patch"
)

DOCS=( "README.md" "SU2_PY/documentation.txt" )

src_unpack() {
	unpack "${P}.tar.gz"
	if use mpp ; then
		einfo "Unpacking mutationpp-1.0.1.tar.gz to /var/tmp/portage/sci-physics/${P}/work/${P}/subprojects/Mutationpp"
		tar -C "${P}"/subprojects/Mutationpp --strip-components=1 -xzf "${DISTDIR}/mutationpp-1.0.1.tar.gz" || die
	fi
	if use test ; then
		einfo "Unpacking ${P}-TestCases.tar.gz to /var/tmp/portage/sci-physics/${P}/work/${P}/TestCases"
		tar -C "${P}"/TestCases --strip-components=1 -xzf "${DISTDIR}/${P}-TestCases.tar.gz" || die
	fi
	if use tutorials ; then
		einfo "Unpacking ${P}-Tutorials.tar.gz to /var/tmp/portage/sci-physics/${P}/work/${P}"
		mkdir "${P}"/Tutorials || die
		tar -C "${P}"/Tutorials --strip-components=1 -xzf "${DISTDIR}/${P}-Tutorials.tar.gz" || die
	fi
}

src_prepare(){
	default
	# boost Geometry requires c++14 since >=boost-1.75
	sed -i -e 's:cpp_std=c++11:cpp_std=c++14:' meson.build || die

	# Force Disable parmetis support in meson.build (configure.ac has optional switch)
	use !parmetis && { sed -i -e "/parmetis/Id" meson.build || die ; }

	# Disable python-wrapper tests
	sed -i "/append(pywrapper_/s/./#&/" TestCases/parallel_regression.py || die

	# Copy absence mesh file
	if use test ; then
		cp "${S}/TestCases/nonequilibrium/viscwedge/viscwedge.su2" "${S}/TestCases/nonequilibrium/axi_visccone/" || die
	fi
}

src_configure() {
	local emesonargs=(
		-Denable-autodiff=false
		-Denable-directdiff=false
		-Denable-pastix=false
		-Denable-pywrapper=false
		-Dwith-omp=false
		$(meson_feature mpi with-mpi)
		$(meson_use cgns enable-cgns)
		$(meson_use mkl enable-mkl)
		$(meson_use mpp enable-mpp)
		$(meson_use openblas enable-openblas)
		$(meson_use tecio enable-tecio)
		$(meson_use test enable-tests)
	)
	meson_src_configure
}

src_test() {
	ln -s ../../${P}-build/SU2_CFD/src/SU2_CFD SU2_PY/SU2_CFD || die
	ln -s ../../${P}-build/SU2_DEF/src/SU2_DEF SU2_PY/SU2_DEF || die
	ln -s ../../${P}-build/SU2_DOT/src/SU2_DOT SU2_PY/SU2_DOT || die
	ln -s ../../${P}-build/SU2_GEO/src/SU2_GEO SU2_PY/SU2_GEO || die
	ln -s ../../${P}-build/SU2_SOL/src/SU2_SOL SU2_PY/SU2_SOL || die

	export SU2_RUN="${S}/SU2_PY"
	export SU2_HOME="${S}"
	export PATH=$PATH:$SU2_RUN
	export PYTHONPATH=$PYTHONPATH:$SU2_RUN

	einfo "Running UnitTests ..."
	../${P}-build/UnitTests/test_driver || die

	pushd TestCases/ || die
	if use mpi ; then
		if use tutorials ; then
			${EPYTHON} tutorials.py || die
		fi
		${EPYTHON} parallel_regression.py || die
	else
		${EPYTHON} serial_regression.py || die
	fi
	popd || die
}

src_install() {
	meson_src_install
	mkdir -p "${D}$(python_get_sitedir)" || die
	mv "${ED}"/usr/bin/{FSI_tools,SU2,SU2_Nastran,*.py} -t "${D}$(python_get_sitedir)" || die
	python_optimize "${D}/$(python_get_sitedir)"

	if use tutorials ; then
		insinto "/usr/share/${P}"
		doins -r Tutorials
	fi
}