# IT4Innovations
# LK 22
easyblock = 'CMakeMake'

name = 'DualSPHysics'
version = '5.0.175'
versionsuffix = '-CUDA-%(cudaver)s'

homepage = 'https://dual.sphysics.org/'

description = """DualSPHysics is based on the Smoothed Particle Hydrodynamics model named SPHysics.

 The code is developed to study free-surface flow phenomena where Eulerian methods
 can be difficult to apply, such as waves or impact of dam-breaks on off-shore
 structures. DualSPHysics is a set of C++, CUDA and Java codes designed to deal
 with real-life engineering problems."""

toolchain = {'name': 'GCC', 'version': '11.2.0'}

source_urls = ['https://github.com/DualSPHysics/DualSPHysics/archive/refs/tags/']
sources = ['v%(version)s.tar.gz']
patches = ['%(name)s-%(version)s.patch']
checksums = [
    'd65bb7b8b4a21582091a534142348e46cff0a288a97ef86643bc2dde15637575',  # v5.0.175.tar.gz
    'b2fad86d99e31fe2e1b5c65bab60a4f14362401b6de00a395b3a1bd13f608366',  # DualSPHysics-5.0.175.patch
]

srcdir = 'src/source'

builddependencies = [
    ('CUDAcore', '11.6.0', '', True),
    ('CMake', '3.21.1'),
]

separate_build_dir = True

buildopts = " && chmod +x %(builddir)s/%(name)s-%(version)s/bin/linux/*_linux64"

install_cmd = "mkdir -p %(installdir)s/bin && "
install_cmd += "cp -r %(builddir)s/%(name)s-%(version)s/bin/linux/* %(installdir)s/bin && "
install_cmd += "cp -r %(builddir)s/%(name)s-%(version)s/src/lib/linux_gcc %(installdir)s/lib"

local_bins = ['GenCase', 'PartVTK', 'IsoSurface', 'MeasureTool', 'GenCase_MkWord',
              'DualSPHysics4.0_LiquidGas', 'DualSPHysics4.0_LiquidGasCPU', 'DualSPHysics5.0',
              'DualSPHysics5.0CPU', 'DualSPHysics5.0_NNewtonian', 'DualSPHysics5.0_NNewtonianCPU']


sanity_check_paths = {
    'files': ['bin/%s_linux64' % x for x in local_bins],
    'dirs': ["lib"],
}

sanity_check_commands = ['%s_linux64 -h' % x for x in local_bins]


moduleclass = 'cae'
