dealii: formatting

This commit is contained in:
Denis Davydov 2016-05-26 20:54:38 +02:00
parent 0036483ded
commit 040c122719

View file

@ -25,8 +25,10 @@
from spack import * from spack import *
import sys import sys
class Dealii(Package): class Dealii(Package):
"""C++ software library providing well-documented tools to build finite element codes for a broad variety of PDEs.""" """C++ software library providing well-documented tools to build finite
element codes for a broad variety of PDEs."""
homepage = "https://www.dealii.org" homepage = "https://www.dealii.org"
url = "https://github.com/dealii/dealii/releases/download/v8.4.0/dealii-8.4.0.tar.gz" url = "https://github.com/dealii/dealii/releases/download/v8.4.0/dealii-8.4.0.tar.gz"
@ -36,7 +38,7 @@ class Dealii(Package):
variant('mpi', default=True, description='Compile with MPI') variant('mpi', default=True, description='Compile with MPI')
variant('arpack', default=True, description='Compile with Arpack and PArpack (only with MPI)') variant('arpack', default=True, description='Compile with Arpack and PArpack (only with MPI)')
variant('doc', default=False, description='Compile with documentation') variant('doc', default=False, description='Compile with documentation')
variant('gsl' , default=True, description='Compile with GSL') variant('gsl', default=True, description='Compile with GSL')
variant('hdf5', default=True, description='Compile with HDF5 (only with MPI)') variant('hdf5', default=True, description='Compile with HDF5 (only with MPI)')
variant('metis', default=True, description='Compile with Metis') variant('metis', default=True, description='Compile with Metis')
variant('netcdf', default=True, description='Compile with Netcdf (only with MPI)') variant('netcdf', default=True, description='Compile with Netcdf (only with MPI)')
@ -47,39 +49,40 @@ class Dealii(Package):
variant('trilinos', default=True, description='Compile with Trilinos (only with MPI)') variant('trilinos', default=True, description='Compile with Trilinos (only with MPI)')
# required dependencies, light version # required dependencies, light version
depends_on ("blas") depends_on("blas")
# Boost 1.58 is blacklisted, see https://github.com/dealii/dealii/issues/1591 # Boost 1.58 is blacklisted, see
# require at least 1.59 # https://github.com/dealii/dealii/issues/1591
depends_on ("boost@1.59.0:+thread+system+serialization+iostreams", when='~mpi') # Require at least 1.59
depends_on ("boost@1.59.0:+mpi+thread+system+serialization+iostreams", when='+mpi') depends_on("boost@1.59.0:+thread+system+serialization+iostreams", when='~mpi') # NOQA: ignore=E501
depends_on ("bzip2") depends_on("boost@1.59.0:+mpi+thread+system+serialization+iostreams", when='+mpi') # NOQA: ignore=E501
depends_on ("cmake") depends_on("bzip2")
depends_on ("lapack") depends_on("cmake")
depends_on ("muparser") depends_on("lapack")
depends_on ("suite-sparse") depends_on("muparser")
depends_on ("tbb") depends_on("suite-sparse")
depends_on ("zlib") depends_on("tbb")
depends_on("zlib")
# optional dependencies # optional dependencies
depends_on ("mpi", when="+mpi") depends_on("mpi", when="+mpi")
depends_on ("arpack-ng+mpi", when='+arpack+mpi') depends_on("arpack-ng+mpi", when='+arpack+mpi')
depends_on ("doxygen+graphviz", when='+doc') depends_on("doxygen+graphviz", when='+doc')
depends_on ("graphviz", when='+doc') depends_on("graphviz", when='+doc')
depends_on ("gsl", when='@8.5.0:+gsl') depends_on("gsl", when='@8.5.0:+gsl')
depends_on ("gsl", when='@dev+gsl') depends_on("gsl", when='@dev+gsl')
depends_on ("hdf5+mpi", when='+hdf5+mpi') depends_on("hdf5+mpi", when='+hdf5+mpi')
depends_on ("metis@5:", when='+metis') depends_on("metis@5:", when='+metis')
depends_on ("netcdf+mpi", when="+netcdf+mpi") depends_on("netcdf+mpi", when="+netcdf+mpi")
depends_on ("netcdf-cxx", when='+netcdf+mpi') depends_on("netcdf-cxx", when='+netcdf+mpi')
depends_on ("oce", when='+oce') depends_on("oce", when='+oce')
depends_on ("p4est", when='+p4est+mpi') depends_on("p4est", when='+p4est+mpi')
depends_on ("petsc+mpi", when='+petsc+mpi') depends_on("petsc+mpi", when='+petsc+mpi')
depends_on ("slepc", when='+slepc+petsc+mpi') depends_on("slepc", when='+slepc+petsc+mpi')
depends_on ("trilinos", when='+trilinos+mpi') depends_on("trilinos", when='+trilinos+mpi')
# developer dependnecies # developer dependnecies
depends_on ("numdiff", when='@dev') depends_on("numdiff", when='@dev')
depends_on ("astyle@2.04", when='@dev') depends_on("astyle@2.04", when='@dev')
def install(self, spec, prefix): def install(self, spec, prefix):
options = [] options = []
@ -97,9 +100,9 @@ def install(self, spec, prefix):
'-DDEAL_II_WITH_THREADS:BOOL=ON', '-DDEAL_II_WITH_THREADS:BOOL=ON',
'-DBOOST_DIR=%s' % spec['boost'].prefix, '-DBOOST_DIR=%s' % spec['boost'].prefix,
'-DBZIP2_DIR=%s' % spec['bzip2'].prefix, '-DBZIP2_DIR=%s' % spec['bzip2'].prefix,
# CMake's FindBlas/Lapack may pickup system's blas/lapack instead of Spack's. # CMake's FindBlas/Lapack may pickup system's blas/lapack instead
# Be more specific to avoid this. # of Spack's. Be more specific to avoid this.
# Note that both lapack and blas are provided in -DLAPACK_XYZ variables # Note that both lapack and blas are provided in -DLAPACK_XYZ.
'-DLAPACK_FOUND=true', '-DLAPACK_FOUND=true',
'-DLAPACK_INCLUDE_DIRS=%s;%s' % '-DLAPACK_INCLUDE_DIRS=%s;%s' %
(spec['lapack'].prefix.include, (spec['lapack'].prefix.include,
@ -107,7 +110,7 @@ def install(self, spec, prefix):
'-DLAPACK_LIBRARIES=%s;%s' % '-DLAPACK_LIBRARIES=%s;%s' %
(spec['lapack'].lapack_shared_lib, (spec['lapack'].lapack_shared_lib,
spec['blas'].blas_shared_lib), spec['blas'].blas_shared_lib),
'-DMUPARSER_DIR=%s ' % spec['muparser'].prefix, '-DMUPARSER_DIR=%s' % spec['muparser'].prefix,
'-DUMFPACK_DIR=%s' % spec['suite-sparse'].prefix, '-DUMFPACK_DIR=%s' % spec['suite-sparse'].prefix,
'-DTBB_DIR=%s' % spec['tbb'].prefix, '-DTBB_DIR=%s' % spec['tbb'].prefix,
'-DZLIB_DIR=%s' % spec['zlib'].prefix '-DZLIB_DIR=%s' % spec['zlib'].prefix
@ -126,24 +129,25 @@ def install(self, spec, prefix):
'-DDEAL_II_WITH_MPI:BOOL=OFF', '-DDEAL_II_WITH_MPI:BOOL=OFF',
]) ])
# Optional dependencies for which librariy names are the same as CMake variables # Optional dependencies for which librariy names are the same as CMake
for library in ('gsl','hdf5','p4est','petsc','slepc','trilinos','metis'): # variables:
for library in ('gsl', 'hdf5', 'p4est', 'petsc', 'slepc', 'trilinos', 'metis'): # NOQA: ignore=E501
if library in spec: if library in spec:
options.extend([ options.extend([
'-D{library}_DIR={value}'.format(library=library.upper(), value=spec[library].prefix), '-D%s_DIR=%s' % (library.upper(), spec[library].prefix),
'-DDEAL_II_WITH_{library}:BOOL=ON'.format(library=library.upper()) '-DDEAL_II_WITH_%s:BOOL=ON' % library.upper()
]) ])
else: else:
options.extend([ options.extend([
'-DDEAL_II_WITH_{library}:BOOL=OFF'.format(library=library.upper()) '-DDEAL_II_WITH_%s:BOOL=OFF' % library.upper()
]) ])
# doxygen # doxygen
options.extend([ options.extend([
'-DDEAL_II_COMPONENT_DOCUMENTATION=%s' % ('ON' if '+doc' in spec else 'OFF'), '-DDEAL_II_COMPONENT_DOCUMENTATION=%s' %
('ON' if '+doc' in spec else 'OFF'),
]) ])
# arpack # arpack
if '+arpack' in spec: if '+arpack' in spec:
options.extend([ options.extend([
@ -161,8 +165,10 @@ def install(self, spec, prefix):
options.extend([ options.extend([
'-DNETCDF_FOUND=true', '-DNETCDF_FOUND=true',
'-DNETCDF_LIBRARIES=%s;%s' % '-DNETCDF_LIBRARIES=%s;%s' %
(join_path(spec['netcdf-cxx'].prefix.lib,'libnetcdf_c++.%s' % dsuf), (join_path(spec['netcdf-cxx'].prefix.lib,
join_path(spec['netcdf'].prefix.lib,'libnetcdf.%s' % dsuf)), 'libnetcdf_c++.%s' % dsuf),
join_path(spec['netcdf'].prefix.lib,
'libnetcdf.%s' % dsuf)),
'-DNETCDF_INCLUDE_DIRS=%s;%s' % '-DNETCDF_INCLUDE_DIRS=%s;%s' %
(spec['netcdf-cxx'].prefix.include, (spec['netcdf-cxx'].prefix.include,
spec['netcdf'].prefix.include), spec['netcdf'].prefix.include),
@ -201,7 +207,7 @@ def install(self, spec, prefix):
with working_dir('examples/step-3'): with working_dir('examples/step-3'):
cmake('.') cmake('.')
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
# An example which uses Metis + PETSc # An example which uses Metis + PETSc
# FIXME: switch step-18 to MPI # FIXME: switch step-18 to MPI
@ -214,7 +220,7 @@ def install(self, spec, prefix):
if '^petsc' in spec and '^metis' in spec: if '^petsc' in spec and '^metis' in spec:
cmake('.') cmake('.')
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
# take step-40 which can use both PETSc and Trilinos # take step-40 which can use both PETSc and Trilinos
# FIXME: switch step-40 to MPI run # FIXME: switch step-40 to MPI run
@ -223,43 +229,49 @@ def install(self, spec, prefix):
print('========== Step-40 PETSc ============') print('========== Step-40 PETSc ============')
print('=====================================') print('=====================================')
# list the number of cycles to speed up # list the number of cycles to speed up
filter_file(r'(const unsigned int n_cycles = 8;)', ('const unsigned int n_cycles = 2;'), 'step-40.cc') filter_file(r'(const unsigned int n_cycles = 8;)',
('const unsigned int n_cycles = 2;'), 'step-40.cc')
cmake('.') cmake('.')
if '^petsc' in spec: if '^petsc' in spec:
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
print('=====================================') print('=====================================')
print('========= Step-40 Trilinos ==========') print('========= Step-40 Trilinos ==========')
print('=====================================') print('=====================================')
# change Linear Algebra to Trilinos # change Linear Algebra to Trilinos
filter_file(r'(\/\/ #define FORCE_USE_OF_TRILINOS.*)', ('#define FORCE_USE_OF_TRILINOS'), 'step-40.cc') filter_file(r'(\/\/ #define FORCE_USE_OF_TRILINOS.*)',
('#define FORCE_USE_OF_TRILINOS'), 'step-40.cc')
if '^trilinos+hypre' in spec: if '^trilinos+hypre' in spec:
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
print('=====================================') print('=====================================')
print('=== Step-40 Trilinos SuperluDist ====') print('=== Step-40 Trilinos SuperluDist ====')
print('=====================================') print('=====================================')
# change to direct solvers # change to direct solvers
filter_file(r'(LA::SolverCG solver\(solver_control\);)', ('TrilinosWrappers::SolverDirect::AdditionalData data(false,"Amesos_Superludist"); TrilinosWrappers::SolverDirect solver(solver_control,data);'), 'step-40.cc') filter_file(r'(LA::SolverCG solver\(solver_control\);)', ('TrilinosWrappers::SolverDirect::AdditionalData data(false,"Amesos_Superludist"); TrilinosWrappers::SolverDirect solver(solver_control,data);'), 'step-40.cc') # NOQA: ignore=E501
filter_file(r'(LA::MPI::PreconditionAMG preconditioner;)', (''), 'step-40.cc') filter_file(r'(LA::MPI::PreconditionAMG preconditioner;)',
filter_file(r'(LA::MPI::PreconditionAMG::AdditionalData data;)', (''), 'step-40.cc') (''), 'step-40.cc')
filter_file(r'(preconditioner.initialize\(system_matrix, data\);)', (''), 'step-40.cc') filter_file(r'(LA::MPI::PreconditionAMG::AdditionalData data;)',
filter_file(r'(solver\.solve \(system_matrix, completely_distributed_solution, system_rhs,)', ('solver.solve (system_matrix, completely_distributed_solution, system_rhs);'), 'step-40.cc') (''), 'step-40.cc')
filter_file(r'(preconditioner.initialize\(system_matrix, data\);)',
(''), 'step-40.cc')
filter_file(r'(solver\.solve \(system_matrix, completely_distributed_solution, system_rhs,)', ('solver.solve (system_matrix, completely_distributed_solution, system_rhs);'), 'step-40.cc') # NOQA: ignore=E501
filter_file(r'(preconditioner\);)', (''), 'step-40.cc') filter_file(r'(preconditioner\);)', (''), 'step-40.cc')
if '^trilinos+superlu-dist' in spec: if '^trilinos+superlu-dist' in spec:
make('release') make('release')
make('run',paralle=False) make('run', paralle=False)
print('=====================================') print('=====================================')
print('====== Step-40 Trilinos MUMPS =======') print('====== Step-40 Trilinos MUMPS =======')
print('=====================================') print('=====================================')
# switch to Mumps # switch to Mumps
filter_file(r'(Amesos_Superludist)', ('Amesos_Mumps'), 'step-40.cc') filter_file(r'(Amesos_Superludist)',
('Amesos_Mumps'), 'step-40.cc')
if '^trilinos+mumps' in spec: if '^trilinos+mumps' in spec:
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
print('=====================================') print('=====================================')
print('============ Step-36 ================') print('============ Step-36 ================')
@ -268,7 +280,7 @@ def install(self, spec, prefix):
if 'slepc' in spec: if 'slepc' in spec:
cmake('.') cmake('.')
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
print('=====================================') print('=====================================')
print('============ Step-54 ================') print('============ Step-54 ================')
@ -277,7 +289,7 @@ def install(self, spec, prefix):
if 'oce' in spec: if 'oce' in spec:
cmake('.') cmake('.')
make('release') make('release')
make('run',parallel=False) make('run', parallel=False)
def setup_environment(self, spack_env, env): def setup_environment(self, spack_env, env):
env.set('DEAL_II_DIR', self.prefix) env.set('DEAL_II_DIR', self.prefix)