From 051952a7d37bc679ff2b03b73e867df22851ce6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 12:02:26 +0200 Subject: [PATCH 01/19] Install sympde, pyccel and gelato from PyPi. --- .travis.yml | 11 +---------- requirements.txt | 10 ++++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 066eb8b57..92451cff7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,20 +24,11 @@ before_install: - h5pcc -showconfig -echo || true - export CC="mpicc" HDF5_MPI="ON" HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi - python -m pip install --upgrade pip - - python -m pip install -r requirements.txt - python -m pip uninstall -y psydac - python -m pip uninstall -y sympde - python -m pip uninstall -y gelato - python -m pip uninstall -y pyccel - - wget https://raw.githubusercontent.com/pyccel/pyccel/master/requirements.txt -O requirements_pyccel.txt - - python -m pip install -r requirements_pyccel.txt - - python -m pip install git+https://github.com/pyccel/pyccel@master - - wget https://raw.githubusercontent.com/pyccel/sympde/master/requirements.txt -O requirements_sympde.txt - - python -m pip install -r requirements_sympde.txt - - python -m pip install git+https://github.com/pyccel/sympde@master - - wget https://raw.githubusercontent.com/pyccel/gelato/master/requirements.txt -O requirements_gelato.txt - - python -m pip install -r requirements_gelato.txt - - python -m pip install git+https://github.com/pyccel/gelato@master + - python -m pip install -r requirements.txt # command to install project install: diff --git a/requirements.txt b/requirements.txt index 94b6fe43a..63d968116 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# Packages from PyPi +# Third-party packages from PyPi numpy>=1.13, <1.16 scipy>=0.18 matplotlib @@ -9,6 +9,11 @@ pytest pyyaml yamlloader +# Our packages from PyPi +sympde +pyccel +gelato + # h5py must be built from source using MPI compiler # and linked to parallel HDF5 library. To do so set # @@ -20,6 +25,3 @@ yamlloader # Igakit https://bitbucket.org/dalcinl/igakit/get/default.tar.gz - -# In addition, PSYDAC depends on "sympde" and "pyccel" libraries, -# to be installed manually from their git repositories. From eccb4af70c6052f7542b293dba7192c7cadbe90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 14:41:23 +0200 Subject: [PATCH 02/19] Move dependencies list from 'requirements.txt' to 'setup.py'. --- .travis.yml | 2 +- requirements.txt | 18 +----------------- setup.py | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92451cff7..c8b08933b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,8 @@ before_install: - python -m pip install --upgrade pip - python -m pip uninstall -y psydac - python -m pip uninstall -y sympde - - python -m pip uninstall -y gelato - python -m pip uninstall -y pyccel + - python -m pip uninstall -y gelato - python -m pip install -r requirements.txt # command to install project diff --git a/requirements.txt b/requirements.txt index 63d968116..cc01fdf87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,19 +1,3 @@ -# Third-party packages from PyPi -numpy>=1.13, <1.16 -scipy>=0.18 -matplotlib -mpi4py -h5py -sympy>=1.3 -pytest -pyyaml -yamlloader - -# Our packages from PyPi -sympde -pyccel -gelato - # h5py must be built from source using MPI compiler # and linked to parallel HDF5 library. To do so set # @@ -23,5 +7,5 @@ gelato # --no-binary h5py -# Igakit +# Igakit (TODO: remove library dependency) https://bitbucket.org/dalcinl/igakit/get/default.tar.gz diff --git a/setup.py b/setup.py index b97b27f58..89f115062 100644 --- a/setup.py +++ b/setup.py @@ -36,12 +36,29 @@ # ... # ... -install_requires = ['numpy', 'scipy'] +install_requires = [ + + # Third-party packages from PyPi + 'numpy>=1.13', + 'scipy>=0.18', + 'sympy>=1.2', + 'matplotlib', + 'mpi4py', + 'pytest', + 'pyyaml', + 'yamlloader', + + # Our packages from PyPi + 'sympde', + 'pyccel', + 'gelato', +] + dependency_links = [] # ... -# ... bspline extension +# ... bspline extension (TODO: remove Fortran files from library) bsp_ext = Extension(name = 'psydac.core.bsp', sources = ['psydac/core/external/bspline.F90', 'psydac/core/external/pppack.F90', From 3e9a833958629f41036f3f61a77ee3dc06737e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 16:23:30 +0200 Subject: [PATCH 03/19] Move library version to separate file. NOTE: psydac now provides version to user: In [1]: import psydac; psydac.__version__ Out[1]: '0.1' --- psydac/__init__.py | 5 +++-- psydac/version.py | 1 + setup.py | 12 ++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 psydac/version.py diff --git a/psydac/__init__.py b/psydac/__init__.py index c498e6668..36d218598 100644 --- a/psydac/__init__.py +++ b/psydac/__init__.py @@ -1,8 +1,9 @@ # -*- coding: UTF-8 -*- -__version__ = "0.1" -__all__ = ['api', 'cad', 'core', 'ddm', 'feec', 'fem', +__all__ = ['__version__', 'api', 'cad', 'core', 'ddm', 'feec', 'fem', 'linalg', 'mapping', 'utilities'] +from psydac.version import __version__ + from psydac import api from psydac import cad from psydac import core diff --git a/psydac/version.py b/psydac/version.py new file mode 100644 index 000000000..a4e2017f0 --- /dev/null +++ b/psydac/version.py @@ -0,0 +1 @@ +__version__ = "0.1" diff --git a/setup.py b/setup.py index 89f115062..a451a9508 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,19 @@ # -*- coding: UTF-8 -*- #! /usr/bin/python -import sys -import os +from pathlib import Path from setuptools import find_packages from numpy.distutils.core import setup from numpy.distutils.core import Extension -import psydac + +# ... +# Read library version into '__version__' variable +path = Path(__file__).parent / 'psydac' / 'version.py' +exec(path.read_text()) +# ... NAME = 'psydac' -VERSION = psydac.__version__ +VERSION = __version__ AUTHOR = 'Ahmed Ratnani, Jalal Lakhlili, Yaman Güçlü' EMAIL = 'ratnaniahmed@gmail.com' URL = 'http://www.ahmed.ratnani.org' From 8121f2a478592d2d391fb05ceb74281c52809f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 19:22:05 +0200 Subject: [PATCH 04/19] Add missing line (h5py) to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index cc01fdf87..e1f43e2cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ # HDF5_MPI="ON" # HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi # +h5py --no-binary h5py # Igakit (TODO: remove library dependency) From 745150810ba310bf469424871746f1e6ce3e1775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 19:39:29 +0200 Subject: [PATCH 05/19] Add h5py's dependencies (numpy & mpi4py) to 'requirements.txt'. --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index e1f43e2cc..21d9600a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,8 @@ # HDF5_MPI="ON" # HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi # +numpy>=1.13 +mpi4py h5py --no-binary h5py From 16399667e7571c4db79f13dd67be89bb94c19779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 30 Aug 2019 19:41:18 +0200 Subject: [PATCH 06/19] Add h5py to install_requires in setup.py. --- setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a451a9508..8d6b9ffff 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,6 @@ 'scipy>=0.18', 'sympy>=1.2', 'matplotlib', - 'mpi4py', 'pytest', 'pyyaml', 'yamlloader', @@ -56,6 +55,14 @@ 'sympde', 'pyccel', 'gelato', + + # In addition, we depend on mpi4py and h5py (MPI version). + # Since h5py must be built from source, we run the commands + # + # python3 -m pip install requirements.txt + # python3 -m pip install . + 'mpi4py', + 'h5py', ] dependency_links = [] From 75972cd7bf4e1c194b001cf02a4d0427316bb297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 4 Oct 2019 13:40:02 +0200 Subject: [PATCH 07/19] Use PyYAML's SafeLoader to avoid runtime deprecation warning. --- psydac/cad/geometry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psydac/cad/geometry.py b/psydac/cad/geometry.py index dbdf4f10b..bbccfab39 100644 --- a/psydac/cad/geometry.py +++ b/psydac/cad/geometry.py @@ -161,7 +161,7 @@ def read( self, filename, comm=MPI.COMM_WORLD ): kwargs = {} h5 = h5py.File( filename, mode='r', **kwargs ) - yml = yaml.load( h5['geometry.yml'][()] ) + yml = yaml.load( h5['geometry.yml'][()], Loader=yaml.SafeLoader ) ldim = yml['ldim'] pdim = yml['pdim'] From 4bfba3533c25b701e09703ab94357c271210da91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 4 Oct 2019 13:48:55 +0200 Subject: [PATCH 08/19] Use Scipy's CSC matrix format to avoid runtime SparseEfficiencyWarning. --- .../api/tests/test_api_1d_compatible_spaces.py | 2 +- .../api/tests/test_api_2d_compatible_spaces.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/psydac/api/tests/test_api_1d_compatible_spaces.py b/psydac/api/tests/test_api_1d_compatible_spaces.py index 9c8d83ab2..1384e6050 100644 --- a/psydac/api/tests/test_api_1d_compatible_spaces.py +++ b/psydac/api/tests/test_api_1d_compatible_spaces.py @@ -76,7 +76,7 @@ def run_system_1_1d_dir(f0, sol, ncells, degree): ah.assemble() - M = ah.linear_system.lhs.tosparse() + M = ah.linear_system.lhs.tosparse().tocsc() rhs = ah.linear_system.rhs.toarray() sol = spsolve(M, rhs) diff --git a/psydac/api/tests/test_api_2d_compatible_spaces.py b/psydac/api/tests/test_api_2d_compatible_spaces.py index 154745f41..5a219d1e2 100644 --- a/psydac/api/tests/test_api_2d_compatible_spaces.py +++ b/psydac/api/tests/test_api_2d_compatible_spaces.py @@ -83,7 +83,7 @@ def run_system_1_2d_dir(f0, sol, ncells, degree): # ... ah.assemble() - M = ah.linear_system.lhs.tosparse() + M = ah.linear_system.lhs.tosparse().tocsc() rhs = ah.linear_system.rhs.toarray() x = spsolve(M, rhs) # ... @@ -194,6 +194,13 @@ def run_system_2_2d_dir(f1, f2,u1, u2, ncells, degree): # SERIAL TESTS ############################################################################### +def test_api_system_1_2d_dir_1(): + from sympy.abc import x,y + + f0 = -2*(2*pi)**2*sin(2*pi*x)*sin(2*pi*y) + u = sin(2*pi*x)*sin(2*pi*y) + x = run_system_1_2d_dir(f0,u, ncells=[10,10], degree=[2,2]) + #============================================================================== def test_api_system_2_2d_dir_1(): from sympy.abc import x,y @@ -206,11 +213,3 @@ def test_api_system_2_2d_dir_1(): p = sin(2*pi*x) - sin(2*pi*y) x = run_system_2_2d_dir(f1, f2, u1, u2, ncells=[2**3,2**3], degree=[2,2]) - -def test_api_system_1_2d_dir_1(): - from sympy.abc import x,y - - f0 = -2*(2*pi)**2*sin(2*pi*x)*sin(2*pi*y) - u = sin(2*pi*x)*sin(2*pi*y) - x = run_system_1_2d_dir(f0,u, ncells=[10,10], degree=[2,2]) - From 040d2998ec26cabcae8fc4cf07a960d4b4eb68f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 4 Oct 2019 13:58:33 +0200 Subject: [PATCH 09/19] Do not use Numpy's Matrix to avoid runtime PendingDeprecationWarning. --- psydac/api/tests/test_api_glt_2d_scalar.py | 4 ++-- psydac/api/tests/test_api_glt_2d_scalar_mapping.py | 2 +- psydac/api/tests/test_api_glt_2d_vector.py | 2 +- psydac/api/tests/utils.py | 2 +- psydac/feec/utilities.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/psydac/api/tests/test_api_glt_2d_scalar.py b/psydac/api/tests/test_api_glt_2d_scalar.py index 1a6d5caf5..668f7a737 100644 --- a/psydac/api/tests/test_api_glt_2d_scalar.py +++ b/psydac/api/tests/test_api_glt_2d_scalar.py @@ -72,7 +72,7 @@ def run_poisson_2d_dir(ncells, degree, comm=None): # ... # ... use eigenvalue solver - M = ah.assemble().tosparse().todense() + M = ah.assemble().toarray() w, v = eig_solver(M) eig = w.real eig.sort() @@ -193,7 +193,7 @@ def run_variable_coeff_2d_dir(ncells, degree, comm=None): # ... # ... use eigenvalue solver - M = ah.assemble(c=0.2).tosparse().todense() + M = ah.assemble(c=0.2).toarray() w, v = eig_solver(M) eig = w.real eig.sort() diff --git a/psydac/api/tests/test_api_glt_2d_scalar_mapping.py b/psydac/api/tests/test_api_glt_2d_scalar_mapping.py index 8c071f5ca..b557d86c6 100644 --- a/psydac/api/tests/test_api_glt_2d_scalar_mapping.py +++ b/psydac/api/tests/test_api_glt_2d_scalar_mapping.py @@ -91,7 +91,7 @@ def run_poisson_2d_dir(filename, comm=None): # ... # ... use eigenvalue solver - M = ah.assemble().tosparse().todense() + M = ah.assemble().toarray() w, v = eig_solver(M) eig = w.real eig.sort() diff --git a/psydac/api/tests/test_api_glt_2d_vector.py b/psydac/api/tests/test_api_glt_2d_vector.py index 648527797..93c610614 100644 --- a/psydac/api/tests/test_api_glt_2d_vector.py +++ b/psydac/api/tests/test_api_glt_2d_vector.py @@ -73,7 +73,7 @@ def run_vector_poisson_2d_dir(ncells, degree): # ... # ... use eigenvalue solver - M = ah.assemble().tosparse().todense() + M = ah.assemble().toarray() w, v = eig_solver(M) eig = w.real eig.sort() diff --git a/psydac/api/tests/utils.py b/psydac/api/tests/utils.py index c6f7ece41..9c644b856 100644 --- a/psydac/api/tests/utils.py +++ b/psydac/api/tests/utils.py @@ -20,7 +20,7 @@ def assert_identical_coo(A, B): assert(allclose(A.col, B.col)) assert(allclose(A.data, B.data)) -# assert(allclose(A.todense(), B.todense())) +# assert(allclose(A.toarray(), B.toarray())) else: raise TypeError('Wrong types for entries') diff --git a/psydac/feec/utilities.py b/psydac/feec/utilities.py index b6c8706fd..d4916ee60 100644 --- a/psydac/feec/utilities.py +++ b/psydac/feec/utilities.py @@ -33,9 +33,9 @@ def solve(self, rhs, out=None): return out def toarray(self): - M1 = self.args[0].todense() + M1 = self.args[0].toarray() for M2 in self.args[1:]: - M1 = np.kron(M1, M2.todense()) + M1 = np.kron(M1, M2.toarray()) return M1 From a54ce92efca03337fa7912bccfff8943045cab51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Tue, 8 Oct 2019 16:37:26 +0200 Subject: [PATCH 10/19] Download Igakit from 'master' branch. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 21d9600a6..dd1b21e3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ h5py --no-binary h5py # Igakit (TODO: remove library dependency) -https://bitbucket.org/dalcinl/igakit/get/default.tar.gz +https://bitbucket.org/dalcinl/igakit/get/master.tar.gz From d3657c0dc9694554fa126be7a1dc723dddbdd421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Wed, 9 Oct 2019 10:43:44 +0200 Subject: [PATCH 11/19] Require numpy>=1.16 and avoid deprecation warning. --- psydac/linalg/tests/test_stencil_matrix.py | 2 +- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/psydac/linalg/tests/test_stencil_matrix.py b/psydac/linalg/tests/test_stencil_matrix.py index 384afa04b..86c9825bf 100644 --- a/psydac/linalg/tests/test_stencil_matrix.py +++ b/psydac/linalg/tests/test_stencil_matrix.py @@ -621,7 +621,7 @@ def test_stencil_matrix_2d_parallel_transpose( n1, n2, p1, p2, P1, P2, reorder ) #... Ts_exact = Ts_exact.tocsr() for i, j in zip(*Ts_exact.nonzero()): - i1, i2 = np.unravel_index( i, dims=[n1, n2], order='C' ) + i1, i2 = np.unravel_index( i, shape=[n1, n2], order='C' ) if not (s1 <= i1 <= e1 and s2 <= i2 <= e2): Ts_exact[i, j] = 0.0 Ts_exact = Ts_exact.tocoo() diff --git a/requirements.txt b/requirements.txt index dd1b21e3f..1543c677a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ # HDF5_MPI="ON" # HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi # -numpy>=1.13 +numpy>=1.16 mpi4py h5py --no-binary h5py diff --git a/setup.py b/setup.py index 8d6b9ffff..65cacc864 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ install_requires = [ # Third-party packages from PyPi - 'numpy>=1.13', + 'numpy>=1.16', 'scipy>=0.18', 'sympy>=1.2', 'matplotlib', From 92de6481e9317fa402e4582f0c7786a60469ab9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Wed, 9 Oct 2019 10:47:32 +0200 Subject: [PATCH 12/19] Print complete list of installed Python packages. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c8b08933b..11db5fef7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ before_install: # command to install project install: - python -m pip install . + - python -m pip freeze before_script: - mkdir pytest From eca7f7c0f3ecec4ae19b9f662253524644263b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Wed, 9 Oct 2019 10:56:38 +0200 Subject: [PATCH 13/19] Remove obsolete files in root directory. --- TODO.rst | 2 +- run_tests.sh | 4 ---- setup.cfg | 17 ----------------- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100755 run_tests.sh delete mode 100644 setup.cfg diff --git a/TODO.rst b/TODO.rst index 497033ab3..7119d5764 100644 --- a/TODO.rst +++ b/TODO.rst @@ -50,7 +50,7 @@ API - add other solvers to the solver_driver (only cg is available now) -- remove psydac/run_tests.sh. however, we need to clear the cache of sympy after 1d, 2d and 3d tests, otherwise pytest will crash. +- however, we need to clear the cache of sympy after 1d, 2d and 3d tests, otherwise pytest will crash. - add sympde and pyccel install procedure; maybe wget to download the requierements files as requirements_pyccel.txt etc then call pip3 diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 2777d3c28..000000000 --- a/run_tests.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -python3 -m pytest --pyargs spl/api/tests/ -m "not parallel" -mpirun -np 2 python3 -m pytest --pyargs spl/api/tests/ -m "parallel" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index fc404b260..000000000 --- a/setup.cfg +++ /dev/null @@ -1,17 +0,0 @@ -[config_fc] -fcompiler=gnu95 -#f90flags=-g3 -O0 -fcheck=all -Wall -Wextra -#noopt=True -#noarch=True - -[build] -#debug = 0 - -[install] -optimize = 1 - -[sdist] -force_manifest = 1 - -[nosetests] -where = test From 441a74479d840488c6a5311977149416bdb5dfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Wed, 9 Oct 2019 17:49:30 +0200 Subject: [PATCH 14/19] Remove unused imports from API tests. --- .../tests/test_api_1d_compatible_spaces.py | 38 ++++---------- .../tests/test_api_2d_compatible_spaces.py | 34 ++++--------- psydac/api/tests/test_api_2d_scalar.py | 29 ++++------- .../api/tests/test_api_2d_scalar_mapping.py | 36 ++++--------- psydac/api/tests/test_api_2d_system.py | 22 +++----- psydac/api/tests/test_api_2d_vector.py | 30 ++++------- psydac/api/tests/test_api_3d_scalar.py | 27 ++++------ .../api/tests/test_api_3d_scalar_mapping.py | 36 ++++--------- psydac/api/tests/test_api_3d_vector.py | 27 ++++------ .../api/tests/test_api_3d_vector_mapping.py | 24 +++------ psydac/api/tests/test_api_expr_2d_scalar.py | 33 +++--------- psydac/api/tests/test_api_feec_2d.py | 51 ++++++------------- .../tests/test_api_glt_2d_scalar_mapping.py | 40 +++------------ psydac/api/tests/test_api_glt_2d_vector.py | 29 +++-------- 14 files changed, 132 insertions(+), 324 deletions(-) diff --git a/psydac/api/tests/test_api_1d_compatible_spaces.py b/psydac/api/tests/test_api_1d_compatible_spaces.py index 1384e6050..3c199fa3c 100644 --- a/psydac/api/tests/test_api_1d_compatible_spaces.py +++ b/psydac/api/tests/test_api_1d_compatible_spaces.py @@ -1,37 +1,21 @@ # -*- coding: UTF-8 -*- -from sympy import pi, cos, sin, Tuple, Matrix +from sympy import pi, sin +from scipy.sparse.linalg import spsolve -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace +from sympde.calculus import dot, div +from sympde.topology import ScalarFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm -from sympde.expr import integral -from sympde.expr import Norm, TerminalExpr -from sympde.expr import find, EssentialBC - - -from psydac.fem.basic import FemField -from psydac.fem.vector import VectorFemField -from psydac.api.discretization import discretize - -from numpy import linspace, zeros, allclose -from mpi4py import MPI -import pytest +from sympde.topology import Line +from sympde.expr import BilinearForm, LinearForm +from sympde.expr import integral +from sympde.expr import Norm +from sympde.expr import find -from scipy.sparse.linalg import cg, gmres -from scipy import linalg -from scipy.sparse.linalg import spsolve +from psydac.fem.basic import FemField +from psydac.api.discretization import discretize -import matplotlib.pyplot as plt #============================================================================== def run_system_1_1d_dir(f0, sol, ncells, degree): diff --git a/psydac/api/tests/test_api_2d_compatible_spaces.py b/psydac/api/tests/test_api_2d_compatible_spaces.py index 5a219d1e2..cc8199395 100644 --- a/psydac/api/tests/test_api_2d_compatible_spaces.py +++ b/psydac/api/tests/test_api_2d_compatible_spaces.py @@ -1,39 +1,23 @@ # -*- coding: UTF-8 -*- -from sympy import pi, cos, sin, Tuple, Matrix +import numpy as np +from sympy import pi, cos, sin, Matrix +from scipy import linalg +from scipy.sparse.linalg import spsolve -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) +from sympde.calculus import grad, dot, inner, div from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union +from sympde.topology import Square from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm, TerminalExpr +from sympde.expr import Norm from sympde.expr import find, EssentialBC - -from psydac.fem.basic import FemField -from psydac.fem.vector import VectorFemField +from psydac.fem.basic import FemField +from psydac.fem.vector import VectorFemField from psydac.api.discretization import discretize -from numpy import linspace, zeros, allclose -import numpy as np -from mpi4py import MPI -import pytest - -from scipy.sparse.linalg import cg, gmres -from scipy.sparse.linalg import spsolve -from scipy import linalg - -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d import Axes3D -from matplotlib import animation #============================================================================== def run_system_1_2d_dir(f0, sol, ncells, degree): diff --git a/psydac/api/tests/test_api_2d_scalar.py b/psydac/api/tests/test_api_2d_scalar.py index 95cb3b718..01ea0e0bb 100644 --- a/psydac/api/tests/test_api_2d_scalar.py +++ b/psydac/api/tests/test_api_2d_scalar.py @@ -1,31 +1,24 @@ # -*- coding: UTF-8 -*- +from mpi4py import MPI from sympy import pi, cos, sin from sympy.utilities.lambdify import implemented_function +import pytest -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +from sympde.calculus import grad, dot +from sympde.calculus import laplace +from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 +from sympde.topology import NormalVector +from sympde.topology import Square from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find, EssentialBC -from psydac.fem.basic import FemField +from psydac.fem.basic import FemField from psydac.api.discretization import discretize -from numpy import linspace, zeros, allclose -from mpi4py import MPI -import pytest - - #============================================================================== def run_poisson_2d_dir(solution, f, ncells, degree, comm=None): diff --git a/psydac/api/tests/test_api_2d_scalar_mapping.py b/psydac/api/tests/test_api_2d_scalar_mapping.py index 6c73888b5..69ba30c5d 100644 --- a/psydac/api/tests/test_api_2d_scalar_mapping.py +++ b/psydac/api/tests/test_api_2d_scalar_mapping.py @@ -1,40 +1,24 @@ # -*- coding: UTF-8 -*- +from mpi4py import MPI from sympy import pi, cos, sin -from sympy import S -from sympy import Tuple -from sympy import Matrix - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +import pytest +import os + +from sympde.calculus import grad, dot +from sympde.calculus import laplace +from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of -from sympde.topology import Unknown -from sympde.topology import InteriorDomain, Union -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 +from sympde.topology import NormalVector +from sympde.topology import Domain from sympde.topology import Union -from sympde.topology import Mapping from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm from sympde.expr import find, EssentialBC -from psydac.fem.basic import FemField -from psydac.fem.vector import ProductFemSpace, VectorFemField +from psydac.fem.basic import FemField from psydac.api.discretization import discretize -from psydac.mapping.discrete import SplineMapping - -from numpy import linspace, zeros, allclose -from mpi4py import MPI -import pytest - -import os - # ... get the mesh directory try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] diff --git a/psydac/api/tests/test_api_2d_system.py b/psydac/api/tests/test_api_2d_system.py index 880537398..29cdf30be 100644 --- a/psydac/api/tests/test_api_2d_system.py +++ b/psydac/api/tests/test_api_2d_system.py @@ -1,31 +1,23 @@ # -*- coding: UTF-8 -*- +from mpi4py import MPI from sympy import pi, cos, sin, Tuple, Matrix +import numpy as np +import pytest -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union +from sympde.topology import Square from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm from sympde.expr import find, EssentialBC -from psydac.fem.basic import FemField -from psydac.fem.vector import VectorFemField +from psydac.fem.basic import FemField +from psydac.fem.vector import VectorFemField from psydac.api.discretization import discretize -from numpy import linspace, zeros, allclose -import numpy as np -from mpi4py import MPI -import pytest - #============================================================================== def run_system_1_2d_dir(Fe, Ge, f0, f1, ncells, degree): diff --git a/psydac/api/tests/test_api_2d_vector.py b/psydac/api/tests/test_api_2d_vector.py index 21dd23690..efc785a91 100644 --- a/psydac/api/tests/test_api_2d_vector.py +++ b/psydac/api/tests/test_api_2d_vector.py @@ -1,28 +1,18 @@ # -*- coding: UTF-8 -*- from sympy import Tuple, Matrix -from sympy import pi, cos, sin - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace -from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC - -from psydac.fem.vector import VectorFemField -from psydac.api.discretization import discretize +from sympy import pi, sin -from numpy import linspace, zeros, allclose +from sympde.calculus import grad, dot, inner +from sympde.topology import VectorFunctionSpace +from sympde.topology import element_of +from sympde.topology import Square +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find, EssentialBC +from psydac.fem.vector import VectorFemField +from psydac.api.discretization import discretize #============================================================================== def run_vector_poisson_2d_dir(solution, f, ncells, degree): diff --git a/psydac/api/tests/test_api_3d_scalar.py b/psydac/api/tests/test_api_3d_scalar.py index 2f4a629f9..b4f017a98 100644 --- a/psydac/api/tests/test_api_3d_scalar.py +++ b/psydac/api/tests/test_api_3d_scalar.py @@ -1,29 +1,22 @@ # -*- coding: UTF-8 -*- +from mpi4py import MPI from sympy import pi, cos, sin +import pytest -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +from sympde.calculus import grad, dot +from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 +from sympde.topology import NormalVector +from sympde.topology import Cube from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find, EssentialBC -from psydac.fem.basic import FemField +from psydac.fem.basic import FemField from psydac.api.discretization import discretize -from numpy import linspace, zeros, allclose -from mpi4py import MPI -import pytest - #============================================================================== def run_poisson_3d_dir(solution, f, ncells, degree, comm=None): diff --git a/psydac/api/tests/test_api_3d_scalar_mapping.py b/psydac/api/tests/test_api_3d_scalar_mapping.py index 48a780c1a..5ea919656 100644 --- a/psydac/api/tests/test_api_3d_scalar_mapping.py +++ b/psydac/api/tests/test_api_3d_scalar_mapping.py @@ -1,40 +1,24 @@ # -*- coding: UTF-8 -*- +from mpi4py import MPI from sympy import pi, cos, sin -from sympy import S -from sympy import Tuple -from sympy import Matrix - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) +import pytest +import os + +from sympde.calculus import grad, dot from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of -from sympde.topology import Unknown -from sympde.topology import InteriorDomain, Union -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 +from sympde.topology import NormalVector from sympde.topology import Union -from sympde.topology import Mapping from sympde.topology import Domain -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find, EssentialBC -from psydac.fem.basic import FemField +from psydac.fem.basic import FemField from psydac.api.discretization import discretize -from psydac.mapping.discrete import SplineMapping - -from numpy import linspace, zeros, allclose -from mpi4py import MPI -import pytest - -import os - # ... get the mesh directory try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] diff --git a/psydac/api/tests/test_api_3d_vector.py b/psydac/api/tests/test_api_3d_vector.py index 878f511a1..aa14bc10e 100644 --- a/psydac/api/tests/test_api_3d_vector.py +++ b/psydac/api/tests/test_api_3d_vector.py @@ -1,28 +1,19 @@ # -*- coding: UTF-8 -*- from sympy import Tuple, Matrix -from sympy import pi, cos, sin +from sympy import pi, sin -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace +from sympde.calculus import grad, dot, inner +from sympde.topology import VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC - -from psydac.fem.vector import VectorFemField -from psydac.api.discretization import discretize - -from numpy import linspace, zeros, allclose +from sympde.topology import Cube +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find, EssentialBC +from psydac.fem.vector import VectorFemField +from psydac.api.discretization import discretize #============================================================================== def run_vector_poisson_3d_dir(solution, f, ncells, degree): diff --git a/psydac/api/tests/test_api_3d_vector_mapping.py b/psydac/api/tests/test_api_3d_vector_mapping.py index eeda248fb..4880e985c 100644 --- a/psydac/api/tests/test_api_3d_vector_mapping.py +++ b/psydac/api/tests/test_api_3d_vector_mapping.py @@ -1,30 +1,20 @@ # -*- coding: UTF-8 -*- +import os from sympy import Tuple, Matrix -from sympy import pi, cos, sin - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +from sympy import pi, sin + +from sympde.calculus import grad, dot, inner +from sympde.topology import VectorFunctionSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union +from sympde.topology import Domain from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm from sympde.expr import find, EssentialBC -from psydac.fem.vector import VectorFemField +from psydac.fem.vector import VectorFemField from psydac.api.discretization import discretize -from numpy import linspace, zeros, allclose - -import os - # ... get the mesh directory try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] diff --git a/psydac/api/tests/test_api_expr_2d_scalar.py b/psydac/api/tests/test_api_expr_2d_scalar.py index b88da5720..48f6180b9 100644 --- a/psydac/api/tests/test_api_expr_2d_scalar.py +++ b/psydac/api/tests/test_api_expr_2d_scalar.py @@ -1,36 +1,17 @@ # -*- coding: UTF-8 -*- -from sympy import pi, cos, sin -from sympy.utilities.lambdify import implemented_function +from mpi4py import MPI +from sympy import pi +import numpy as np -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +from sympde.calculus import dot, div +from sympde.topology import VectorFunctionSpace from sympde.topology import element_of +from sympde.topology import Square -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC - -from gelato.expr import GltExpr - -from psydac.fem.basic import FemField -from psydac.fem.vector import VectorFemField +from psydac.fem.vector import VectorFemField from psydac.api.discretization import discretize -import numpy as np -from scipy.linalg import eig as eig_solver -from mpi4py import MPI -import pytest - - #============================================================================== def run_poisson_2d_dir(ncells, degree, comm=None): diff --git a/psydac/api/tests/test_api_feec_2d.py b/psydac/api/tests/test_api_feec_2d.py index c426b0568..33b52e329 100644 --- a/psydac/api/tests/test_api_feec_2d.py +++ b/psydac/api/tests/test_api_feec_2d.py @@ -1,43 +1,24 @@ # -*- coding: UTF-8 -*- -from sympy import Tuple, Matrix - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace, Derham -from sympde.topology import ScalarField, VectorField -from sympde.topology import ProductSpace -from sympde.topology import ScalarTestFunction -from sympde.topology import VectorTestFunction -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm, TerminalExpr -from sympde.expr import find, EssentialBC - - -from psydac.fem.basic import FemField -from psydac.fem.vector import VectorFemField -from psydac.api.discretization import discretize -from psydac.fem.vector import ProductFemSpace -from psydac.feec.utilities import Interpolation, interpolation_matrices -from psydac.feec.derivatives import Grad, Curl, Div -from numpy import linspace, zeros, allclose -import numpy as np from mpi4py import MPI -import pytest - -from scipy.sparse.linalg import cg, gmres from scipy.sparse.linalg import spsolve -from scipy import linalg +import numpy as np +#import matplotlib.pyplot as plt +#from mpl_toolkits.mplot3d import Axes3D + +from sympde.calculus import dot, div +from sympde.topology import Derham +from sympde.topology import ScalarField +from sympde.topology import ProductSpace +from sympde.topology import ScalarTestFunction, VectorTestFunction +from sympde.topology import Square +from sympde.expr import BilinearForm, LinearForm, integral +from sympde.expr import Norm +from sympde.expr import find + +from psydac.fem.basic import FemField +from psydac.api.discretization import discretize -import matplotlib.pyplot as plt -from mpl_toolkits.mplot3d import Axes3D -from matplotlib import animation #============================================================================== def run_system_1_2d_dir(f0, sol, ncells, degree): diff --git a/psydac/api/tests/test_api_glt_2d_scalar_mapping.py b/psydac/api/tests/test_api_glt_2d_scalar_mapping.py index b557d86c6..f66c6a2b3 100644 --- a/psydac/api/tests/test_api_glt_2d_scalar_mapping.py +++ b/psydac/api/tests/test_api_glt_2d_scalar_mapping.py @@ -1,43 +1,19 @@ # -*- coding: UTF-8 -*- -from sympy import pi, cos, sin -from sympy import S -from sympy import Tuple -from sympy import Matrix - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +import os +import numpy as np +from scipy.linalg import eig as eig_solver + +from sympde.calculus import grad, dot +from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of -from sympde.topology import Unknown -from sympde.topology import InteriorDomain, Union -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.topology import Mapping -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC +from sympde.topology import Domain +from sympde.expr import BilinearForm, integral from gelato.expr import GltExpr -from psydac.fem.basic import FemField -from psydac.fem.vector import ProductFemSpace, VectorFemField from psydac.api.discretization import discretize -from psydac.mapping.discrete import SplineMapping - -import numpy as np -from scipy.linalg import eig as eig_solver -from mpi4py import MPI -import pytest - -import os - # ... get the mesh directory try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] diff --git a/psydac/api/tests/test_api_glt_2d_vector.py b/psydac/api/tests/test_api_glt_2d_vector.py index 93c610614..a11991fbd 100644 --- a/psydac/api/tests/test_api_glt_2d_vector.py +++ b/psydac/api/tests/test_api_glt_2d_vector.py @@ -1,33 +1,18 @@ # -*- coding: UTF-8 -*- -from sympy import Tuple, Matrix -from sympy import pi, cos, sin - -from sympde.core import Constant -from sympde.calculus import grad, dot, inner, cross, rot, curl, div -from sympde.calculus import laplace, hessian -from sympde.topology import (dx, dy, dz) -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import ProductSpace +import numpy as np +from scipy.linalg import eig as eig_solver + +from sympde.calculus import grad, inner +from sympde.topology import VectorFunctionSpace from sympde.topology import element_of -from sympde.topology import Boundary, NormalVector, TangentVector -from sympde.topology import Domain, Line, Square, Cube -from sympde.topology import Trace, trace_0, trace_1 -from sympde.topology import Union -from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm -from sympde.expr import find, EssentialBC +from sympde.topology import Square +from sympde.expr import BilinearForm, integral from gelato.expr import GltExpr -from psydac.fem.vector import VectorFemField from psydac.api.discretization import discretize -import numpy as np -from scipy.linalg import eig as eig_solver -from mpi4py import MPI -import pytest - #============================================================================== def run_vector_poisson_2d_dir(ncells, degree): From aac876a21612934bea3411bda3dbda392e487d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Mon, 14 Oct 2019 19:07:02 +0200 Subject: [PATCH 15/19] Whenever possible, use 'element_of' instead of class constructors. In addition, if 'EvalQuadratureMapping' is called on a vector function space of 'undefined' kind, we create a temporary scalar function space of 'H1' kind and assume that all vector components belong to this space. --- psydac/api/ast/evaluation.py | 34 +++++++++++++++++++++------- psydac/api/ast/fem.py | 9 ++++---- psydac/api/ast/utilities.py | 3 ++- psydac/api/tests/test_api_feec_2d.py | 9 ++++---- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/psydac/api/ast/evaluation.py b/psydac/api/ast/evaluation.py index e70012448..3a82d20a0 100644 --- a/psydac/api/ast/evaluation.py +++ b/psydac/api/ast/evaluation.py @@ -7,7 +7,10 @@ from sympde.topology import ScalarField from sympde.topology import VectorField from sympde.topology import SymbolicExpr -from sympde.topology.space import ScalarTestFunction +from sympde.topology.space import element_of +from sympde.topology.space import ScalarFunctionSpace +from sympde.topology.space import VectorFunctionSpace +from sympde.topology.datatype import dtype_space_registry from sympde.topology.derivatives import _logical_partial_derivatives from pyccel.ast.core import IndexedVariable @@ -35,6 +38,21 @@ def __new__(cls, space, mapping, discrete_boundary=None, name=None, if not isinstance(mapping, Mapping): raise TypeError('> Expecting a Mapping object') + #..................................................................... + # If vector space is of undefined type, we assume that each component + # lives in H1; otherwise we raise an error. TODO: improve! + if isinstance(space, VectorFunctionSpace): + if space.kind == dtype_space_registry['undefined']: + space = ScalarFunctionSpace( + name = space.name, + domain = space.domain, + kind = 'H1' + ) + else: + msg = 'Cannot evaluate vector spaces of kind {}'.format(space.kind) + raise NotImplementedError(msg) + #..................................................................... + obj = SplBasic.__new__(cls, mapping, name=name, prefix='eval_mapping', mapping=mapping, is_rational_mapping=is_rational_mapping) @@ -173,7 +191,7 @@ def _initialize(self): weights_elements = [] if self.is_rational_mapping: # TODO check if 'w' exist already - weights_pts = ScalarField(self.space, name='w') + weights_pts = element_of(self.space, name='w') weights_elements = [weights_pts] @@ -217,7 +235,7 @@ def _initialize(self): # ... # ... - Nj = ScalarTestFunction(space, name='Nj') + Nj = element_of(space, name='Nj') body = [] init_basis = OrderedDict() updates = [] @@ -364,7 +382,7 @@ def _initialize(self): # ... # ... - Nj = ScalarTestFunction(space, name='Nj') + Nj = element_of(space, name='Nj') body = [] init_basis = OrderedDict() init_map = OrderedDict() @@ -503,7 +521,7 @@ def _initialize(self): # ... # ... - Nj = VectorField(space, name='Nj') + Nj = VectorField(space, name='Nj') # TODO: use 'element_of' body = [] init_basis = OrderedDict() init_map = OrderedDict() @@ -666,7 +684,7 @@ def _initialize(self): # ... # ... - Nj = ScalarTestFunction(space, name='Nj') + Nj = element_of(space, name='Nj') init_basis = OrderedDict() init_map = OrderedDict() @@ -860,7 +878,7 @@ def _initialize(self): weights_elements = [] if self.is_rational_mapping: # TODO check if 'w' exist already - weights_pts = ScalarField(self.space, name='w') + weights_pts = element_of(self.space, name='w') weights_elements = [weights_pts] @@ -905,7 +923,7 @@ def _initialize(self): # ... # ... - Nj = ScalarTestFunction(space, name='Nj') + Nj = element_of(space, name='Nj') body = [] init_basis = OrderedDict() atomic_exprs = self.elements + weights_elements diff --git a/psydac/api/ast/fem.py b/psydac/api/ast/fem.py index 56540ac5a..03bb31326 100644 --- a/psydac/api/ast/fem.py +++ b/psydac/api/ast/fem.py @@ -39,6 +39,7 @@ from sympde.topology.space import ProductSpace from sympde.topology.space import ScalarTestFunction from sympde.topology.space import VectorTestFunction +from sympde.topology.space import element_of from sympde.topology.space import IndexedTestTrial from sympde.topology.derivatives import _partial_derivatives from sympde.topology.derivatives import _logical_partial_derivatives @@ -617,13 +618,11 @@ def _initialize(self): if is_bilinear or is_linear: test_function = self.weak_form.test_functions if not isinstance(test_function, (tuple, Tuple)): - test_function = [test_function] - test_function = Tuple(*test_function) + test_function = Tuple(test_function) elif is_function: - test_function = ScalarTestFunction(self.weak_form.space, name='Nj') - test_function = [test_function] - test_function = Tuple(*test_function) + test_function = element_of(self.weak_form.space, name='Nj') + test_function = Tuple(test_function) # creation of symbolic vars if is_bilinear: diff --git a/psydac/api/ast/utilities.py b/psydac/api/ast/utilities.py index b0575685d..e6af6f014 100644 --- a/psydac/api/ast/utilities.py +++ b/psydac/api/ast/utilities.py @@ -12,6 +12,7 @@ from sympde.topology.space import ScalarTestFunction from sympde.topology.space import VectorTestFunction from sympde.topology.space import IndexedTestTrial +from sympde.topology.space import element_of from sympde.topology import ScalarField from sympde.topology import VectorField, IndexedVectorField from sympde.topology import Mapping @@ -462,7 +463,7 @@ def rationalize_eval_mapping(mapping, nderiv, space, indices_quad): # ... weights and their derivatives # TODO check if 'w' exist already - weights = ScalarField(space, name='w') + weights = element_of(space, name='w') weights_elements = [weights] if nderiv > 0: diff --git a/psydac/api/tests/test_api_feec_2d.py b/psydac/api/tests/test_api_feec_2d.py index 33b52e329..1f5ecf963 100644 --- a/psydac/api/tests/test_api_feec_2d.py +++ b/psydac/api/tests/test_api_feec_2d.py @@ -8,9 +8,8 @@ from sympde.calculus import dot, div from sympde.topology import Derham -from sympde.topology import ScalarField from sympde.topology import ProductSpace -from sympde.topology import ScalarTestFunction, VectorTestFunction +from sympde.topology import element_of, elements_of from sympde.topology import Square from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm @@ -31,10 +30,10 @@ def run_system_1_2d_dir(f0, sol, ncells, degree): L2 = derham.V2 X = ProductSpace(Hdiv, L2) - F = ScalarField(L2, name='F') + p, q = elements_of(Hdiv, names='p, q') + u, v = elements_of( L2, names='u, v') - p,q = [VectorTestFunction(Hdiv, name=i) for i in ['p', 'q']] - u,v = [ScalarTestFunction(L2, name=i) for i in ['u', 'v']] + F = element_of(L2, name='F') int_0 = lambda expr: integral(domain , expr) From a05e69f340ac570dcaf5d0b13fd13e1736e634ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Tue, 15 Oct 2019 18:10:41 +0200 Subject: [PATCH 16/19] Remove HDF5 files generated by unit tests. --- psydac/cad/tests/test_geometry.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/psydac/cad/tests/test_geometry.py b/psydac/cad/tests/test_geometry.py index 40690cd8e..1ac0b17c9 100644 --- a/psydac/cad/tests/test_geometry.py +++ b/psydac/cad/tests/test_geometry.py @@ -154,9 +154,24 @@ def test_geometry_1(): #============================================================================== def teardown_module(): + import os from sympy import cache cache.clear_cache() + # Remove HDF5 files generated by Geometry.export() + filenames = [ + 'geo.h5', + 'geo_0.h5', + 'geo_1.h5', + 'quart_circle.h5', + 'quart_circle_0.h5', + 'quart_circle_1.h5', + 'circle.h5' + ] + for fname in filenames: + if os.path.exists(fname): + os.remove(fname) + def teardown_function(): from sympy import cache cache.clear_cache() From ffe53ad85bda7e33987cb42d7b603dbc54ccf217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Tue, 15 Oct 2019 18:16:08 +0200 Subject: [PATCH 17/19] Move DDM non-unit test to examples directory. --- .../poisson_2d_jacobi_iteration}/plot_cart_poisson.py | 0 .../poisson_2d_jacobi_iteration}/test_cart_poisson.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {psydac/ddm => examples/poisson_2d_jacobi_iteration}/plot_cart_poisson.py (100%) rename {psydac/ddm => examples/poisson_2d_jacobi_iteration}/test_cart_poisson.py (100%) diff --git a/psydac/ddm/plot_cart_poisson.py b/examples/poisson_2d_jacobi_iteration/plot_cart_poisson.py similarity index 100% rename from psydac/ddm/plot_cart_poisson.py rename to examples/poisson_2d_jacobi_iteration/plot_cart_poisson.py diff --git a/psydac/ddm/test_cart_poisson.py b/examples/poisson_2d_jacobi_iteration/test_cart_poisson.py similarity index 100% rename from psydac/ddm/test_cart_poisson.py rename to examples/poisson_2d_jacobi_iteration/test_cart_poisson.py From 27221e2b53a49f9f2345e702a54db4a1a231d443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Thu, 31 Oct 2019 18:36:58 +0100 Subject: [PATCH 18/19] [codacy] Avoid usage of 'exec' statement. --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 65cacc864..701b70881 100644 --- a/setup.py +++ b/setup.py @@ -2,18 +2,21 @@ #! /usr/bin/python from pathlib import Path +from importlib import util from setuptools import find_packages from numpy.distutils.core import setup from numpy.distutils.core import Extension # ... -# Read library version into '__version__' variable +# Load module 'psydac.version' without running file 'psydac.__init__' path = Path(__file__).parent / 'psydac' / 'version.py' -exec(path.read_text()) +spec = util.spec_from_file_location('version', str(path)) +mod = util.module_from_spec(spec) +spec.loader.exec_module(mod) # ... NAME = 'psydac' -VERSION = __version__ +VERSION = mod.__version__ AUTHOR = 'Ahmed Ratnani, Jalal Lakhlili, Yaman Güçlü' EMAIL = 'ratnaniahmed@gmail.com' URL = 'http://www.ahmed.ratnani.org' From d0f8017c3d2df9ede56e3775100773e97f2d5841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaman=20G=C3=BC=C3=A7l=C3=BC?= Date: Thu, 31 Oct 2019 18:37:24 +0100 Subject: [PATCH 19/19] [codacy] Remove unnecessary import. --- psydac/api/tests/test_api_2d_compatible_spaces.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/psydac/api/tests/test_api_2d_compatible_spaces.py b/psydac/api/tests/test_api_2d_compatible_spaces.py index cc8199395..9c8607e04 100644 --- a/psydac/api/tests/test_api_2d_compatible_spaces.py +++ b/psydac/api/tests/test_api_2d_compatible_spaces.py @@ -188,8 +188,7 @@ def test_api_system_1_2d_dir_1(): #============================================================================== def test_api_system_2_2d_dir_1(): from sympy.abc import x,y - from sympy import cos - + f1 = -x**2*(x - 1)**2*(24*y - 12) - 4*y*(x**2 + 4*x*(x - 1) + (x - 1)**2)*(2*y**2 - 3*y + 1) - 2*pi*cos(2*pi*x) f2 = 4*x*(2*x**2 - 3*x + 1)*(y**2 + 4*y*(y - 1) + (y - 1)**2) + y**2*(24*x - 12)*(y - 1)**2 + 2*pi*cos(2*pi*y) u1 = x**2*(-x + 1)**2*(4*y**3 - 6*y**2 + 2*y)