diff --git a/INFOS.py b/INFOS.py
index 20ace7f..0b9b760 100755
--- a/INFOS.py
+++ b/INFOS.py
@@ -1,52 +1,54 @@
#!/usr/bin/env python3
"""Defines the information to be used throughout the builds."""
# -*- mode:python; coding: utf-8 -*-
from collections import namedtuple
import versioneer
TamaasInfo = namedtuple('TamaasInfo',
['version',
'authors',
'maintainer',
'email',
'copyright',
- 'description'])
+ 'description',
+ 'license'])
TAMAAS_INFOS = TamaasInfo(
version=versioneer.get_version(),
authors=([
u'Lucas Frérot',
'Guillaume Anciaux',
'Valentine Rey',
'Son Pham-Ba',
u'Jean-François Molinari'
]),
maintainer=u'Lucas Frérot',
email='lucas.frerot@imtek.uni-freiburg.de',
copyright=(
u"Copyright (©) 2016-2022 EPFL "
u"(École Polytechnique Fédérale de Lausanne), "
u"Laboratory (LSMS - Laboratoire de Simulation en "
u"Mécanique des Solides)"
),
description='A high-performance library for periodic rough surface contact',
+ license="SPDX-License-Identifier: AGPL-3.0-or-later",
)
def main():
import argparse
parser = argparse.ArgumentParser(description="Print Tamaas info")
parser.add_argument("--version", action="store_true")
args = parser.parse_args()
if args.version:
print(TAMAAS_INFOS.version)
if __name__ == "__main__":
main()
diff --git a/python/SConscript b/python/SConscript
index 120b39c..8ac818a 100644
--- a/python/SConscript
+++ b/python/SConscript
@@ -1,176 +1,176 @@
# -*- mode:python; coding: utf-8 -*-
# vim: set ft=python:
#
# Copyright (©) 2016-2022 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
from __future__ import print_function
from SCons.Script import Import, Split, Copy, Dir
Import('main_env')
# Pybind11 wrapper
env_pybind = main_env.Clone(SHLIBPREFIX='')
# Remove pedantic warnings
cxx_flags = env_pybind['CXXFLAGS']
try:
del cxx_flags[cxx_flags.index('-pedantic')]
except ValueError:
pass
env_pybind.Tool(pybind11)
pybind_sources = Split("""
tamaas_module.cpp
wrap/core.cpp
wrap/percolation.cpp
wrap/surface.cpp
wrap/model.cpp
wrap/solvers.cpp
wrap/compute.cpp
wrap/mpi.cpp
wrap/test_features.cpp
""")
# Setting paths to find libTamaas
env_pybind.AppendUnique(LIBPATH=['../src'])
# Link against a static libTamaas
if env_pybind['build_static_lib']:
env_pybind.PrependUnique(LIBS=['Tamaas']) # keep other libs for link
env_pybind['RPATH'] = "" # no need for rpath w/ static lib
# Link against a dynamic libTamaas
else:
env_pybind.AppendUnique(RPATH=[
"'$$$$ORIGIN/../../src'", # path to lib in build_dir
"'$$$$ORIGIN/../../..'", # path to lib in install prefix
])
env_pybind['LIBS'] = ['Tamaas'] # discard other libs for link
# Building the pybind library
tamaas_wrap = env_pybind.Pybind11Module(
target='tamaas/_tamaas',
source=pybind_sources,
)
# For some reason link happens too early
Import('libTamaas')
env_pybind.Depends(tamaas_wrap, libTamaas)
# Copying the __init__.py file with extra python classes
copy_env = env_pybind.Clone()
# Copying additional python files
python_files = """
__main__.py
compute.py
utils.py
dumpers/__init__.py
dumpers/_helper.py
nonlinear_solvers/__init__.py
""".split()
targets = [tamaas_wrap]
targets += [
copy_env.Command(copy_env.File(f, 'tamaas'),
copy_env.File(f, '#python/tamaas'),
Copy("$TARGET", "$SOURCE"))
for f in python_files
]
dist_files = """
MANIFEST.in
pypi.md
setup.py
""".split()
# pyproject.toml causes issues with develop mode
dist_files.append("pyproject.toml")
targets += [
copy_env.Command(copy_env.File(f, ''),
copy_env.File(f, '#python'),
Copy("$TARGET", "$SOURCE"))
for f in dist_files
]
subst_env = env_pybind.Clone(
SUBST_DICT={
'@version@': '$version',
'@authors@': str(copy_env['authors']),
'@author_list@': ', '.join(copy_env['authors']),
'@email@': '$email',
'@description@': '$description',
- # TODO change when issue with unicode fixed
- # '@copyright@': '$copyright',
- # '@maintainer@': '$maintainer',
+ '@copyright@': '$copyright',
+ '@maintainer@': '$maintainer',
+ '@license@': '$license',
}
)
subst_env.Tool('textfile')
targets.append(subst_env.Substfile('tamaas/__init__.py.in'))
targets.append(subst_env.Substfile('setup.cfg.in'))
# Defining alias for python builds
main_env.Alias('build-python', targets)
# Checking if we can use pip to install (more convenient for end-user)
install_env = main_env.Clone()
conf = Configure(install_env,
custom_tests={'CheckPythonModule': CheckPythonModule})
has_pip = conf.CheckPythonModule('pip')
install_env = conf.Finish()
# Current build directory
install_env['PYDIR'] = Dir('.')
# Setting command line for installation
if has_pip:
install_env['PYINSTALLCOM'] = '${py_exec} -m pip install -U $PYOPTIONS .'
install_env['PYDEVELOPCOM'] = \
'${py_exec} -m pip install $PYOPTIONS -e .[all]'
else:
install_env['PYINSTALLCOM'] = '${py_exec} setup.py install $PYOPTIONS'
install_env['PYDEVELOPCOM'] = '${py_exec} setup.py develop $PYOPTIONS'
install_env['py_version'] = get_python_version(install_env)
install_env.PrependENVPath(
'PYTHONPATH',
install_env.subst('${prefix}/lib/python${py_version}/site-packages'))
# Specify install target
PYOPTIONS = ['${"" if verbose else "-q"}']
python_install = install_env.Command(
'.python_install_phony',
targets, install_env['PYINSTALLCOM'],
PYOPTIONS=['--prefix', '${prefix}'] + PYOPTIONS,
chdir=install_env['PYDIR'])
python_install_dev = install_env.Command(
'.python_install_local_phony',
targets, install_env['PYDEVELOPCOM'],
# Temporary fix for https://github.com/pypa/pip/issues/7953
PYOPTIONS=['--prefix=$$HOME/.local/'] + PYOPTIONS,
chdir=install_env['PYDIR'])
# Defining aliases
main_env.Alias('install-python', python_install)
main_env.Alias('dev', python_install_dev)
diff --git a/python/tamaas/__init__.py.in b/python/tamaas/__init__.py.in
index 2e97725..f218d49 100644
--- a/python/tamaas/__init__.py.in
+++ b/python/tamaas/__init__.py.in
@@ -1,61 +1,58 @@
# -*- mode:python; coding: utf-8 -*-
#
# Copyright (©) 2016-2022 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
"""
@description@
See __author__, __license__, __copyright__ for extra information about Tamaas.
- User documentation: https://tamaas.readthedocs.io
- Bug Tracker: https://gitlab.com/tamaas/tamaas/-/issues
- Source Code: https://gitlab.com/tamaas/tamaas
"""
__author__ = @authors@
-# TODO Change copyright when is issue with unicode is found
-__copyright__ = u"Copyright (©) 2016-2022 EPFL " \
- + u"(École Polytechnique Fédérale de Lausanne), " \
- + u"Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)"
-__license__ = "SPDX-License-Identifier: AGPL-3.0-or-later"
-__maintainer__ = "Lucas Frérot"
+__copyright__ = "@copyright@"
+__license__ = "@license@"
+__maintainer__ = "@maintainer@"
__email__ = "@email@"
try:
from ._tamaas import model_type, TamaasInfo
from ._tamaas import _type_traits as __tt
type_traits = {
model_type.basic_1d: __tt.basic_1d,
model_type.basic_2d: __tt.basic_2d,
model_type.surface_1d: __tt.surface_1d,
model_type.surface_2d: __tt.surface_2d,
model_type.volume_1d: __tt.volume_1d,
model_type.volume_2d: __tt.volume_2d,
}
del __tt
from ._tamaas import * # noqa
__version__ = TamaasInfo.version
except ImportError as e:
print("Error trying to import _tamaas:\n{}".format(e))
raise e
diff --git a/src/core/cuda/cufft_engine.hh b/src/core/cuda/cufft_engine.hh
index ae38341..0d05f2f 100644
--- a/src/core/cuda/cufft_engine.hh
+++ b/src/core/cuda/cufft_engine.hh
@@ -1,133 +1,133 @@
/*
* SPDX-License-Indentifier: AGPL-3.0-or-later
*
* Copyright (©) 2016-2022 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*
*/
/* -------------------------------------------------------------------------- */
#ifndef CUFFT_ENGINE_H
#define CUFFT_ENGINE_H
/* -------------------------------------------------------------------------- */
#include "fft_engine.hh"
#include
/* -------------------------------------------------------------------------- */
namespace cufft {
struct plan {
cufftHandle _plan;
plan() = default;
plan(plan&& o) noexcept : _plan(o._plan) {}
plan& operator=(plan&& o) noexcept {
_plan = o._plan;
return *this;
}
/// Destroy plan
~plan() noexcept { cufftDestroy(_plan); }
/// For seamless use with fftw api
operator cufftHandle() const { return _plan; }
};
} // namespace cufft
namespace tamaas {
class CuFFTEngine : public FFTEngine {
private:
using plan_t = std::pair;
/// Perform forward (R2C) transform
template
void forwardImpl(const Grid& real,
GridHermitian& spectral);
/// Perform backward (C2R) transform
template
void backwardImpl(Grid& real,
const GridHermitian& spectral);
/// Return the plans pair for a given transform signature
plan_t& getPlans(key_t key);
public:
/// Initialize with flags
explicit CuFFTEngine(unsigned int flags = FFTW_ESTIMATE) noexcept
: _flags(flags), plans() {}
void forward(const Grid& real,
GridHermitian& spectral) override {
forwardImpl(real, spectral);
}
void forward(const Grid& real,
GridHermitian& spectral) override {
forwardImpl(real, spectral);
}
void backward(Grid& real,
GridHermitian& spectral) override {
backwardImpl(real, spectral);
}
void backward(Grid& real,
GridHermitian& spectral) override {
backwardImpl(real, spectral);
}
unsigned int flags() const { return _flags; }
/// Cast to FFTW complex type
static auto cast(Complex* data) {
return reinterpret_cast(data);
}
static auto cast(const Complex* data) {
return const_cast(
reinterpret_cast(data));
}
protected:
unsigned int _flags; ///< FFTW flags
std::map plans; ///< plans corresponding to signatures
};
/* -------------------------------------------------------------------------- */
template
void CuFFTEngine::forwardImpl(const Grid& real,
GridHermitian& spectral) {
auto& plans = getPlans(make_key(real, spectral));
if (cufftExecD2Z(plans.first, const_cast(real.getInternalData()),
cast(spectral.getInternalData())) != CUFFT_SUCCESS)
TAMAAS_EXCEPTION("Forward transform fail");
- cudaDeviceSynchronize(); ///< TODO ask the SCITAS guys
+ cudaDeviceSynchronize();
}
template
void CuFFTEngine::backwardImpl(Grid& real,
const GridHermitian& spectral) {
auto& plans = getPlans(make_key(real, spectral));
if (cufftExecZ2D(plans.second, cast(spectral.getInternalData()),
real.getInternalData()) != CUFFT_SUCCESS)
TAMAAS_EXCEPTION("Backward transform fail");
- cudaDeviceSynchronize(); ///< TODO ask the SCITAS guys
+ cudaDeviceSynchronize();
// Normalize
real *= (1. / real.getNbPoints());
}
} // namespace tamaas
#endif