Skip to content
Snippets Groups Projects
Commit e7e32cc2 authored by Simone Bnà's avatar Simone Bnà Committed by Adam J. Stewart
Browse files

openFOAM-paraview-catalyst (#10129)

* paraview: adding variants to use external packages as internal do not compile

* paraview: add latest paraview version

* catalyst: fixed libvtkexpat undefined reference linking error in Catalyst 5.5

* catalyst: add latest catalyst version

* catalyst: added ParaView_DIR env variable to catalyst module

* add paraview, catalyst patches

- https://gitlab.kitware.com/vtk/vtk-m/merge_requests/1166
- https://gitlab.kitware.com/paraview/paraview/merge_requests/2433
- https://gitlab.kitware.com/paraview/paraview/merge_requests/2436

* - Handle updated library paths for catalyst.

  Versions 5.4 and old places libraries under a paraview subdirectory.
  Eg, "lib/paraview-5.4", they are now placed directly under "lib"

- Minor code style cleanup

* Handle update library and python paths for ParaView-5.5

* catalyst: added ParaView_DIR path to spack_env

* BUG: applied the patch to the extracted catalyst source files

* paraview: added missing self to a member variable

* paraview: added Paraview_DIR to env

* catalyst: added osmesa variant

* of-catalyst: added new package

* add (FOAM,WM)_PROJECT_DIR  also to spack_env environment

* depends on first openfoam release supporting catalyst

* openfoam-com: added missing env variables to module generation

* openfoam: fixed flake8 errors

* of-catalyst: added full variant and openfoam version dependency

* paraview: adding variants to use external packages as internal do not compile

* catalyst: fixed libvtkexpat undefined reference linking error in Catalyst 5.5

* catalyst: added ParaView_DIR env variable to catalyst module

* add paraview, catalyst patches

- https://gitlab.kitware.com/vtk/vtk-m/merge_requests/1166
- https://gitlab.kitware.com/paraview/paraview/merge_requests/2433
- https://gitlab.kitware.com/paraview/paraview/merge_requests/2436

* - Handle updated library paths for catalyst.

  Versions 5.4 and old places libraries under a paraview subdirectory.
  Eg, "lib/paraview-5.4", they are now placed directly under "lib"

- Minor code style cleanup

* Handle update library and python paths for ParaView-5.5

* catalyst: added ParaView_DIR path to spack_env

* BUG: applied the patch to the extracted catalyst source files

* of-catalyst: added new package

* add (FOAM,WM)_PROJECT_DIR  also to spack_env environment

* depends on first openfoam release supporting catalyst

* paraview: added missing self to a member variable

* openfoam-com: added missing env variables to module generation

* openfoam: fixed flake8 errors

* paraview: added Paraview_DIR to env

* catalyst: added osmesa variant

* of-catalyst: added full variant and openfoam version dependency

* paraview-catalyst: use always external expat and netcdf

* of-catalyst: reformatted package description

* paraview-catalyst: removed duplicated function

* catalyst: fixed flake8 error

* of-catalyst: fixed license header

* of-catalyst: minor changes

* of-catalyst: renamed gitrepo with git

* of-catalyst: removed useless gitrepo parameter
parent bdc98040
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
import os
import subprocess
import llnl.util.tty as tty
from spack.patch import absolute_path_for_package
class Catalyst(CMakePackage):
......@@ -33,17 +34,31 @@ class Catalyst(CMakePackage):
variant('python', default=False, description='Enable Python support')
variant('essentials', default=False, description='Enable Essentials support')
variant('extras', default=False, description='Enable Extras support')
variant('rendering', default=False, description='Enable Vtk Rendering support')
variant('rendering', default=False, description='Enable VTK Rendering support')
variant('osmesa', default=True, description='Use offscreen rendering')
depends_on('git')
depends_on('git', type='build')
depends_on('mpi')
depends_on('python@2:2.8', when='+python', type=("build", "link", "run"))
depends_on('python', when='~python', type=("build"))
depends_on('mesa', when='+rendering')
depends_on("libx11", when='+rendering')
depends_on("libxt", when='+rendering')
depends_on('libx11', when='+rendering')
depends_on('libxt', when='+rendering')
depends_on('cmake@3.3:', type='build')
@when('@5.5.0:5.5.2')
def patch(self):
"""Apply the patch (it should be fixed in Paraview 5.6)
at the package dir to the source code in
root_cmakelists_dir."""
patch_name = 'vtkm-catalyst-pv551.patch'
pkg_dir = os.path.dirname(absolute_path_for_package(self))
patch = which("patch", required=True)
with working_dir(self.root_cmakelists_dir):
patch('-s', '-p', '1', '-i',
join_path(pkg_dir, patch_name),
"-d", '.')
def url_for_version(self, version):
"""Handle ParaView version-based custom URLs."""
if version < Version('5.1.0'):
......@@ -53,6 +68,30 @@ def url_for_version(self, version):
else:
return self._urlfmt_xz.format(version.up_to(2), version, '')
@property
def paraview_subdir(self):
"""The paraview subdirectory name as paraview-major.minor"""
return 'paraview-{0}'.format(self.spec.version.up_to(2))
@property
def editions(self):
"""Transcribe spack variants into names of Catalyst Editions"""
selected = ['Base'] # Always required
if '+python' in self.spec:
selected.append('Enable-Python')
if '+essentials' in self.spec:
selected.append('Essentials')
if '+extras' in self.spec:
selected.append('Extras')
if '+rendering' in self.spec:
selected.append('Rendering-Base')
return selected
def do_stage(self, mirror_only=False):
"""Unpacks and expands the fetched tarball.
Then, generate the catalyst source files."""
......@@ -62,38 +101,15 @@ def do_stage(self, mirror_only=False):
paraview_dir = os.path.join(self.stage.path,
'ParaView-v' + str(self.version))
catalyst_script = os.path.join(paraview_dir, 'Catalyst', 'catalyze.py')
editions_dir = os.path.join(paraview_dir, 'Catalyst', 'Editions')
catalyst_source_dir = os.path.abspath(self.root_cmakelists_dir)
command = ['python', catalyst_script,
'-r', paraview_dir]
'-r', paraview_dir,
'-o', catalyst_source_dir]
catalyst_edition = os.path.join(paraview_dir, 'Catalyst',
'Editions', 'Base')
command.append('-i')
command.append(catalyst_edition)
if '+python' in self.spec:
catalyst_edition = os.path.join(paraview_dir, 'Catalyst',
'Editions', 'Enable-Python')
command.append('-i')
command.append(catalyst_edition)
if '+essentials' in self.spec:
catalyst_edition = os.path.join(paraview_dir, 'Catalyst',
'Editions', 'Essentials')
command.append('-i')
command.append(catalyst_edition)
if '+extras' in self.spec:
catalyst_edition = os.path.join(paraview_dir, 'Catalyst',
'Editions', 'Extras')
command.append('-i')
command.append(catalyst_edition)
if '+rendering' in self.spec:
catalyst_edition = os.path.join(paraview_dir, 'Catalyst',
'Editions', 'Rendering-Base')
command.append('-i')
command.append(catalyst_edition)
command.append('-o')
command.append(catalyst_source_dir)
for edition in self.editions:
command.extend(['-i', os.path.join(editions_dir, edition)])
if not os.path.isdir(catalyst_source_dir):
os.mkdir(catalyst_source_dir)
......@@ -104,15 +120,29 @@ def do_stage(self, mirror_only=False):
self.stage.path))
def setup_environment(self, spack_env, run_env):
# paraview 5.5 and later
# - cmake under lib/cmake/paraview-5.5
# - libs under lib
# - python bits under lib/python2.8/site-packages
if os.path.isdir(self.prefix.lib64):
lib_dir = self.prefix.lib64
else:
lib_dir = self.prefix.lib
paraview_version = 'paraview-%s' % self.spec.version.up_to(2)
run_env.prepend_path('LIBRARY_PATH', join_path(lib_dir,
paraview_version))
run_env.prepend_path('LD_LIBRARY_PATH', join_path(lib_dir,
paraview_version))
if self.spec.version <= Version('5.4.1'):
lib_dir = join_path(lib_dir, paraview_subdir)
run_env.set('ParaView_DIR', self.prefix)
run_env.prepend_path('LIBRARY_PATH', lib_dir)
run_env.prepend_path('LD_LIBRARY_PATH', lib_dir)
if '+python' in self.spec:
python_version = self.spec['python'].version.up_to(2)
run_env.prepend_path('PYTHONPATH', join_path(lib_dir,
'python{0}'.format(python_version),
'site-packages'))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
spack_env.set('ParaView_DIR', self.prefix)
@property
def root_cmakelists_dir(self):
......@@ -136,8 +166,24 @@ def build_directory(self):
def cmake_args(self):
"""Populate cmake arguments for Catalyst."""
spec = self.spec
def variant_bool(feature, on='ON', off='OFF'):
"""Ternary for spec variant to ON/OFF string"""
if feature in spec:
return on
return off
def nvariant_bool(feature):
"""Negated ternary for spec variant to OFF/ON string"""
return variant_bool(feature, on='OFF', off='ON')
cmake_args = [
'-DPARAVIEW_GIT_DESCRIBE=v%s' % str(self.version)
'-DPARAVIEW_GIT_DESCRIBE=v%s' % str(self.version),
'-DVTK_USE_SYSTEM_EXPAT:BOOL=ON',
'-DVTK_USE_X:BOOL=%s' % nvariant_bool('+osmesa'),
'-DVTK_USE_OFFSCREEN:BOOL=%s' % variant_bool('+osmesa'),
'-DVTK_OPENGL_HAS_OSMESA:BOOL=%s' % variant_bool('+osmesa')
]
return cmake_args
......
This diff is collapsed.
# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class OfCatalyst(CMakePackage):
"""Of-catalyst is a library for OpenFOAM that provides a runtime-selectable
function object for embedding ParaView Catalyst in-situ visualization
into arbitrary OpenFOAM simulations.
Supports in-situ conversion of the following types:
1) finite volume meshes and fields, single or multi-region;
2) finite area meshes and fields, single region;
3) lagrangian (clouds), single or multiple clouds.
This offering is part of the community repository supported by OpenCFD Ltd,
producer and distributor of the OpenFOAM software via www.openfoam.com,
and owner of the OPENFOAM trademark.
OpenCFD Ltd has been developing and releasing OpenFOAM since its debut
in 2004.
"""
# Currently only via git
homepage = "https://develop.openfoam.com/Community/catalyst"
git = "https://develop.openfoam.com/Community/catalyst.git"
version('develop', branch='develop')
version('1806', tag='v1806')
variant('full', default=False, description='Build against paraview (full) or catalyst (light)')
depends_on('openfoam-com@1806', when='@1806', type=('build', 'link', 'run'))
depends_on('openfoam-com@develop', when='@develop', type=('build', 'link', 'run'))
depends_on('catalyst@5.5:', when='~full')
depends_on('paraview@5.5:+osmesa~qt', when='+full')
root_cmakelists_dir = 'src/catalyst'
def cmake_args(self):
"""Populate cmake arguments for ParaView."""
cmake_args = [
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=%s' % join_path(
self.stage.source_path,
'spack-build')
]
return cmake_args
......@@ -405,16 +405,16 @@ def setup_environment(self, spack_env, run_env):
# Unneeded bits
# -------------
'FOAM_SETTINGS', # Do not use with modules
'FOAM_INST_DIR', # Old
'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)',
# 'FOAM_SETTINGS', # Do not use with modules
# 'FOAM_INST_DIR', # Old
# 'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)',
# 'FOAM_TUTORIALS', # can be useful
'WM_OSTYPE', # Purely optional value
# 'WM_OSTYPE', # Purely optional value
# Third-party cruft - only used for orig compilation
# -----------------
'[A-Z].*_ARCH_PATH',
'(KAHIP|METIS|SCOTCH)_VERSION',
# '(KAHIP|METIS|SCOTCH)_VERSION',
# User-specific
# -------------
......@@ -426,6 +426,7 @@ def setup_environment(self, spack_env, run_env):
])
run_env.extend(mods)
spack_env.extend(mods)
minimal = False
tty.info('OpenFOAM bashrc env: {0}'.format(bashrc))
except Exception:
......@@ -436,8 +437,11 @@ def setup_environment(self, spack_env, run_env):
tty.info('OpenFOAM minimal env {0}'.format(self.prefix))
run_env.set('FOAM_PROJECT_DIR', self.projectdir)
run_env.set('WM_PROJECT_DIR', self.projectdir)
spack_env.set('FOAM_PROJECT_DIR', self.projectdir)
spack_env.set('WM_PROJECT_DIR', self.projectdir)
for d in ['wmake', self.archbin]: # bin added automatically
run_env.prepend_path('PATH', join_path(self.projectdir, d))
spack_env.prepend_path('PATH', join_path(self.projectdir, d))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
"""Location of the OpenFOAM project directory.
......@@ -445,7 +449,7 @@ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
variable since it would mask the normal OpenFOAM cleanup of
previous versions.
"""
spack_env.set('FOAM_PROJECT_DIR', self.projectdir)
self.setup_environment(spack_env, run_env)
@property
def projectdir(self):
......
......@@ -59,7 +59,8 @@ class Paraview(CMakePackage):
depends_on('libpng')
depends_on('libtiff')
depends_on('libxml2')
# depends_on('netcdf')
depends_on('netcdf')
depends_on('expat')
# depends_on('netcdf-cxx')
# depends_on('protobuf') # version mismatches?
# depends_on('sqlite') # external version not supported
......@@ -74,6 +75,9 @@ class Paraview(CMakePackage):
# Broken installation (ui_pqExportStateWizard.h) - fixed in 5.2.0
patch('ui_pqExportStateWizard.patch', when='@:5.1.2')
# Broken vtk-m config. Upstream catalyst changes
patch('vtkm-catalyst-pv551.patch', when='@5.5.0:5.5.2')
def url_for_version(self, version):
"""Handle ParaView version-based custom URLs."""
if version < Version('5.1.0'):
......@@ -81,34 +85,50 @@ def url_for_version(self, version):
else:
return self._urlfmt.format(version.up_to(2), version, '')
@property
def paraview_subdir(self):
"""The paraview subdirectory name as paraview-major.minor"""
return 'paraview-{0}'.format(self.spec.version.up_to(2))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
if os.path.isdir(self.prefix.lib64):
lib_dir = self.prefix.lib64
else:
lib_dir = self.prefix.lib
paraview_version = 'paraview-%s' % self.spec.version.up_to(2)
spack_env.set('ParaView_DIR', self.prefix)
spack_env.set('PARAVIEW_VTK_DIR',
join_path(lib_dir, 'cmake', paraview_version))
join_path(lib_dir, 'cmake', self.paraview_subdir))
def setup_environment(self, spack_env, run_env):
# paraview 5.5 and later
# - cmake under lib/cmake/paraview-5.5
# - libs under lib
# - python bits under lib/python2.8/site-packages
if os.path.isdir(self.prefix.lib64):
lib_dir = self.prefix.lib64
else:
lib_dir = self.prefix.lib
paraview_version = 'paraview-%s' % self.spec.version.up_to(2)
run_env.prepend_path('LIBRARY_PATH', join_path(lib_dir,
paraview_version))
run_env.prepend_path('LD_LIBRARY_PATH', join_path(lib_dir,
paraview_version))
run_env.set('ParaView_DIR', self.prefix)
run_env.set('PARAVIEW_VTK_DIR',
join_path(lib_dir, 'cmake', paraview_version))
join_path(lib_dir, 'cmake', self.paraview_subdir))
if self.spec.version <= Version('5.4.1'):
lib_dir = join_path(lib_dir, self.paraview_subdir)
run_env.prepend_path('LIBRARY_PATH', lib_dir)
run_env.prepend_path('LD_LIBRARY_PATH', lib_dir)
if '+python' in self.spec:
run_env.prepend_path('PYTHONPATH', join_path(lib_dir,
paraview_version))
run_env.prepend_path('PYTHONPATH', join_path(lib_dir,
paraview_version, 'site-packages'))
run_env.prepend_path('PYTHONPATH', join_path(lib_dir,
paraview_version, 'site-packages', 'vtk'))
if self.spec.version <= Version('5.4.1'):
pv_pydir = join_path(lib_dir, 'site-packages')
run_env.prepend_path('PYTHONPATH', pv_pydir)
run_env.prepend_path('PYTHONPATH', join_path(pv_pydir, 'vtk'))
else:
python_version = self.spec['python'].version.up_to(2)
run_env.prepend_path('PYTHONPATH', join_path(lib_dir,
'python{0}'.format(python_version),
'site-packages'))
def cmake_args(self):
"""Populate cmake arguments for ParaView."""
......@@ -139,7 +159,8 @@ def nvariant_bool(feature):
'-DVTK_USE_SYSTEM_HDF5:BOOL=%s' % variant_bool('+hdf5'),
'-DVTK_USE_SYSTEM_JPEG:BOOL=ON',
'-DVTK_USE_SYSTEM_LIBXML2:BOOL=ON',
'-DVTK_USE_SYSTEM_NETCDF:BOOL=OFF',
'-DVTK_USE_SYSTEM_NETCDF:BOOL=ON',
'-DVTK_USE_SYSTEM_EXPAT:BOOL=ON',
'-DVTK_USE_SYSTEM_TIFF:BOOL=ON',
'-DVTK_USE_SYSTEM_ZLIB:BOOL=ON',
]
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment