diff --git a/psydac/api/tests/test_2d_biharmonic.py b/psydac/api/tests/test_2d_biharmonic.py index 219754ba4..6ce0073ce 100644 --- a/psydac/api/tests/test_2d_biharmonic.py +++ b/psydac/api/tests/test_2d_biharmonic.py @@ -1,8 +1,7 @@ # -*- coding: UTF-8 -*- from mpi4py import MPI -from sympy import pi, cos, sin, symbols -from sympy.utilities.lambdify import implemented_function +from sympy import pi, sin, symbols import pytest from sympde.calculus import grad, dot diff --git a/psydac/api/tests/test_2d_complex.py b/psydac/api/tests/test_2d_complex.py index fccb1a778..b5a3ce37b 100644 --- a/psydac/api/tests/test_2d_complex.py +++ b/psydac/api/tests/test_2d_complex.py @@ -1,16 +1,15 @@ # -*- coding: UTF-8 -*- import os - from collections import OrderedDict from mpi4py import MPI import pytest import numpy as np -from sympy import pi, cos, sin, symbols, conjugate, exp +from sympy import pi, cos, sin, symbols, exp from sympy import Tuple, Matrix from sympy import lambdify -from sympde.calculus import grad, dot, cross, curl +from sympde.calculus import grad, dot, inner, cross, curl from sympde.calculus import minus, plus from sympde.calculus import laplace from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace @@ -18,7 +17,7 @@ from sympde.topology import NormalVector from sympde.topology import Union from sympde.topology import Domain, Square -from sympde.topology import IdentityMapping, AffineMapping, PolarMapping +from sympde.topology import IdentityMapping, PolarMapping from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC @@ -166,12 +165,12 @@ def run_poisson_2d(solution, f, domain, ncells=None, degree=None, filename=None, - 0.5*dot(grad(minus(v)), nn) * minus(u) - 0.5*dot(grad(minus(u)), nn) * minus(v) + kappa *minus(u)*minus(v)\ + 0.5*dot(grad( plus(v)), nn) * plus(u) + 0.5*dot(grad( plus(u)), nn) * plus(v) + kappa * plus(u)* plus(v) - expr = dot(grad(u), grad(v)) + expr = inner(grad(u), grad(v)) a = BilinearForm((u, v), integral(domain, expr) + integral(I, expr_I)) l = LinearForm(v, integral(domain, f*v)) - equation = find(u, forall=v, lhs=1j*a(u,v), rhs=1j*l(v), bc=bc) + equation = find(u, forall=v, lhs=1j*a(u, v), rhs=1j*l(v), bc=bc) l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') @@ -215,7 +214,7 @@ def run_helmholtz_2d(solution, kappa, e_w_0, dx_e_w_0, domain, ncells=None, degr error = u - solution - expr = dot(grad(u),grad(v)) - 2 * kappa ** 2 * u * v + expr = inner(grad(u), grad(v)) - 2 * kappa ** 2 * u * v boundary_expr = - 1j * kappa * u * v x_boundary = Union(domain.get_boundary(axis=0, ext=-1), domain.get_boundary(axis=0, ext=1)) @@ -280,11 +279,11 @@ def run_maxwell_2d(uex, f, alpha, domain, *, ncells=None, degree=None, filename= +k*cross(nn, jump(u))*curl(avr(v))\ +kappa*cross(nn, jump(u))*cross(nn, jump(v)) - expr1 = curl(u)*curl(v) + alpha*dot(u,v) - expr1_b = -cross(nn, v) * curl(u) -k*cross(nn, u) * curl(v) + kappa * cross(nn, u) * cross(nn, v) + expr1 = curl(u) * curl(v) + alpha * inner(u,v) + expr1_b = -cross(nn, v) * curl(u) -k * cross(nn, u) * curl(v) + kappa * cross(nn, u) * cross(nn, v) - expr2 = dot(f,v) - expr2_b = -k*cross(nn, uex)*curl(v) + kappa * cross(nn, uex) * cross(nn, v) + expr2 = inner(f,v) + expr2_b = -k * cross(nn, uex) * curl(v) + kappa * cross(nn, uex) * cross(nn, v) # Bilinear form a: V x V --> R a = BilinearForm((u, v), integral(domain, expr1) + integral(boundary, expr1_b) + integral(I, expr1_I)) @@ -425,8 +424,8 @@ def test_complex_helmholtz_2d(plot_sol=False): if plot_sol: from psydac.fem.plotting_utilities import get_plotting_grid, get_grid_vals - from psydac.fem.plotting_utilities import get_patch_knots_gridlines, my_small_plot - from psydac.feec.pull_push import pull_2d_h1 + from psydac.fem.plotting_utilities import my_small_plot + from psydac.feec.pull_push import pull_2d_h1 Id_mapping = IdentityMapping('M', 2) # print(f'domain.interior = {domain.interior}') @@ -537,9 +536,9 @@ def teardown_function(): else: from psydac.fem.plotting_utilities import get_plotting_grid, get_grid_vals - from psydac.fem.plotting_utilities import get_patch_knots_gridlines, my_small_plot - from psydac.api.tests.build_domain import build_pretzel - from psydac.feec.pull_push import pull_2d_hcurl + from psydac.fem.plotting_utilities import my_small_plot + from psydac.api.tests.build_domain import build_pretzel + from psydac.feec.pull_push import pull_2d_hcurl domain = build_pretzel() x,y = domain.coordinates diff --git a/psydac/api/tests/test_2d_laplace.py b/psydac/api/tests/test_2d_laplace.py index 4ab808a00..981e8147d 100644 --- a/psydac/api/tests/test_2d_laplace.py +++ b/psydac/api/tests/test_2d_laplace.py @@ -5,8 +5,7 @@ from sympy.utilities.lambdify import implemented_function import pytest -from sympde.calculus import grad, dot -from sympde.calculus import laplace +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.topology import NormalVector @@ -58,7 +57,7 @@ def run_laplace_2d(solution, f, dir_zero_boundary, dir_nonzero_boundary, nn = NormalVector('nn') # Bilinear form a: V x V --> R - a = BilinearForm((u, v), integral(domain, dot(grad(u), grad(v)) + u * v)) + a = BilinearForm((u, v), integral(domain, inner(grad(u), grad(v)) + u * v)) # Linear form l: V --> R l0 = LinearForm(v, integral(domain, f * v)) diff --git a/psydac/api/tests/test_2d_mapping_biharmonic.py b/psydac/api/tests/test_2d_mapping_biharmonic.py index 14550f9fb..65b3255e8 100644 --- a/psydac/api/tests/test_2d_mapping_biharmonic.py +++ b/psydac/api/tests/test_2d_mapping_biharmonic.py @@ -14,18 +14,16 @@ # Please note that the logical coordinates (x1, x2) correspond to the polar # coordinates (r, theta), but with reversed order: hence x1=theta and x2=r -from mpi4py import MPI -from sympy import pi, cos, sin, symbols -import pytest import os -import numpy as np + +from sympy import pi, cos, sin, symbols 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 NormalVector -from sympde.topology import Domain,Square +from sympde.topology import Domain from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm diff --git a/psydac/api/tests/test_2d_mapping_laplace.py b/psydac/api/tests/test_2d_mapping_laplace.py index ea156803c..12d3201af 100644 --- a/psydac/api/tests/test_2d_mapping_laplace.py +++ b/psydac/api/tests/test_2d_mapping_laplace.py @@ -14,18 +14,15 @@ # Please note that the logical coordinates (x1, x2) correspond to the polar # coordinates (r, theta), but with reversed order: hence x1=theta and x2=r -from mpi4py import MPI -from sympy import pi, cos, sin, symbols -import pytest import os -import numpy as np -from sympde.calculus import grad, dot -from sympde.calculus import laplace +from sympy import pi, cos, symbols + +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.topology import NormalVector -from sympde.topology import Domain,Square +from sympde.topology import Domain from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm @@ -82,7 +79,7 @@ def run_laplace_2d(filename, solution, f, dir_zero_boundary, nn = NormalVector('nn') # Bilinear form a: V x V --> R - a = BilinearForm((u, v), integral(domain, dot(grad(u), grad(v)) + u * v)) + a = BilinearForm((u, v), integral(domain, inner(grad(u), grad(v)) + u * v)) # Linear form l: V --> R l0 = LinearForm(v, integral(domain, f * v)) diff --git a/psydac/api/tests/test_2d_mapping_poisson.py b/psydac/api/tests/test_2d_mapping_poisson.py index f60d619cb..1ce4855af 100644 --- a/psydac/api/tests/test_2d_mapping_poisson.py +++ b/psydac/api/tests/test_2d_mapping_poisson.py @@ -15,12 +15,13 @@ # coordinates (r, theta), but with reversed order: hence x1=theta and x2=r import os + from mpi4py import MPI from sympy import pi, cos, sin, symbols import pytest import numpy as np -from sympde.calculus import grad, dot +from sympde.calculus import grad, dot, inner from sympde.calculus import laplace from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of @@ -87,7 +88,7 @@ def run_poisson_2d(filename, solution, f, dir_zero_boundary, nn = NormalVector('nn') # Bilinear form a: V x V --> R - a = BilinearForm((u, v), integral(domain, dot(grad(u),grad(v)))) + a = BilinearForm((u, v), integral(domain, inner(grad(u), grad(v)))) # Linear form l: V --> R l0 = LinearForm(v, integral(domain, f * v)) diff --git a/psydac/api/tests/test_2d_navier_stokes.py b/psydac/api/tests/test_2d_navier_stokes.py index 949a80763..e75a6194b 100644 --- a/psydac/api/tests/test_2d_navier_stokes.py +++ b/psydac/api/tests/test_2d_navier_stokes.py @@ -1,19 +1,14 @@ # -*- coding: UTF-8 -*- import os + import pytest import numpy as np -from sympy import pi, cos, sin, sqrt, exp, ImmutableDenseMatrix as Matrix, Tuple, lambdify +from sympy import pi, cos, sin, exp, ImmutableDenseMatrix as Matrix, Tuple from scipy.sparse.linalg import spsolve -from scipy.sparse.linalg import gmres as sp_gmres -from scipy.sparse.linalg import minres as sp_minres -from scipy.sparse.linalg import cg as sp_cg -from scipy.sparse.linalg import bicg as sp_bicg -from scipy.sparse.linalg import bicgstab as sp_bicgstab -from sympde.calculus import grad, dot, inner, div, curl, cross +from sympde.calculus import grad, inner, div from sympde.calculus import Transpose, laplace -from sympde.topology import NormalVector from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of, elements_of @@ -111,16 +106,16 @@ def run_time_dependent_navier_stokes_2d(filename, dt_h, nt, newton_tol=1e-4, max Re = 1e4 Fl = lambda u,p: Re**-1*inner(grad(u), grad(v)) - div(u)*q - p*div(v) + 1e-10*p*q - F = lambda u,p: dot(Transpose(grad(u))*u,v) + Fl(u,p) + F = lambda u,p: inner(Transpose(grad(u))*u,v) + Fl(u,p) - l = LinearForm((v, q), integral(domain, dot(u,v)-dot(u0,v) + dt/2 * (F(u,p) + F(u0,p0)) )) + l = LinearForm((v, q), integral(domain, inner(u,v)-inner(u0,v) + dt/2 * (F(u,p) + F(u0,p0)) )) a = linearize(l, (u,p), trials=(du, dp)) equation = find((du, dp), forall=(v, q), lhs=a((du, dp), (v, q)), rhs=l(v, q), bc=bc) # Use the stokes equation to compute the initial solution a_stokes = BilinearForm(((du,dp),(v, q)), integral(domain, Fl(du,dp)) ) - l_stokes = LinearForm((v, q), integral(domain, dot(v,Tuple(0,0)) )) + l_stokes = LinearForm((v, q), integral(domain, inner(v,Tuple(0,0)) )) equation_stokes = find((du, dp), forall=(v, q), lhs=a_stokes((du, dp), (v, q)), rhs=l_stokes(v, q), bc=bc) @@ -249,12 +244,12 @@ def run_steady_state_navier_stokes_2d(domain, f, ue, pe, *, ncells, degree, mult boundary = Union(*[domain.get_boundary(**kw) for kw in get_boundaries(1,2)]) - a_b = BilinearForm(((u,p),(v, q)), integral(boundary, dot(u,v)) ) - l_b = LinearForm((v, q), integral(boundary, dot(ue, v)) ) + a_b = BilinearForm(((u,p),(v, q)), integral(boundary, inner(u,v)) ) + l_b = LinearForm((v, q), integral(boundary, inner(ue, v)) ) equation_b = find((u, p), forall=(v, q), lhs=a_b((u, p), (v, q)), rhs=l_b(v, q)) - l = LinearForm((v, q), integral(domain, dot(Transpose(grad(u))*u, v) + inner(grad(u), grad(v)) - div(u)*q - p*div(v) - dot(f, v)) ) + l = LinearForm((v, q), integral(domain, inner(Transpose(grad(u))*u, v) + inner(grad(u), grad(v)) - div(u)*q - p*div(v) - inner(f, v)) ) a = linearize(l, (u,p), trials=(du, dp)) bc = EssentialBC(du, 0, boundary) @@ -357,9 +352,6 @@ def test_st_navier_stokes_2d(): assert (ux.diff(x) + uy.diff(y)).simplify() == 0 # ... Compute right-hand side - from sympde.calculus import laplace, grad - from sympde.expr import TerminalExpr - a = TerminalExpr(-mu*laplace(ue), domain) b = TerminalExpr( grad(ue), domain) c = TerminalExpr( grad(pe), domain) @@ -411,9 +403,6 @@ def test_st_navier_stokes_2d_parallel(): assert (ux.diff(x) + uy.diff(y)).simplify() == 0 # ... Compute right-hand side - from sympde.calculus import laplace, grad - from sympde.expr import TerminalExpr - a = TerminalExpr(-mu*laplace(ue), domain) b = TerminalExpr( grad(ue), domain) c = TerminalExpr( grad(pe), domain) diff --git a/psydac/api/tests/test_2d_poisson.py b/psydac/api/tests/test_2d_poisson.py index ab16e6d10..2c3b5f6de 100644 --- a/psydac/api/tests/test_2d_poisson.py +++ b/psydac/api/tests/test_2d_poisson.py @@ -6,7 +6,7 @@ from sympy.utilities.lambdify import implemented_function import pytest -from sympde.calculus import grad, dot +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.topology import NormalVector @@ -63,7 +63,7 @@ def run_poisson_2d(solution, f, dir_zero_boundary, dir_nonzero_boundary, nn = NormalVector('nn') # Bilinear form a: V x V --> R - a = BilinearForm((u, v), integral(domain, dot(grad(u), grad(v)))) + a = BilinearForm((u, v), integral(domain, inner(grad(u), grad(v)))) # Linear form l: V --> R l0 = LinearForm(v, integral(domain, f * v)) diff --git a/psydac/api/tests/test_api_1d_compatible_spaces.py b/psydac/api/tests/test_api_1d_compatible_spaces.py index f2d007762..3ad6885cb 100644 --- a/psydac/api/tests/test_api_1d_compatible_spaces.py +++ b/psydac/api/tests/test_api_1d_compatible_spaces.py @@ -3,7 +3,7 @@ from sympy import pi, sin from scipy.sparse.linalg import spsolve -from sympde.calculus import dot, div +from sympde.calculus import inner, div from sympde.topology import VectorFunctionSpace, ScalarFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of @@ -35,8 +35,8 @@ def run_system_1_1d_dir(f0, sol, ncells, degree): int_0 = lambda expr: integral(domain , expr) - a = BilinearForm(((p,u),(q,v)), int_0(dot(p,q) + div(q)*u + div(p)*v)) - l = LinearForm((q,v), int_0(f0*v)) + a = BilinearForm(((p, u), (q, v)), int_0(inner(p, q) + div(q) * u + div(p) * v)) + l = LinearForm((q, v), int_0(f0 * v)) error = F-sol l2norm_F = Norm(error, domain, kind='l2') diff --git a/psydac/api/tests/test_api_2d_compatible_spaces.py b/psydac/api/tests/test_api_2d_compatible_spaces.py index 81293585f..b13ff1d29 100644 --- a/psydac/api/tests/test_api_2d_compatible_spaces.py +++ b/psydac/api/tests/test_api_2d_compatible_spaces.py @@ -2,15 +2,11 @@ import pytest import numpy as np -from sympy import pi, cos, sin, sqrt, Matrix, Tuple, lambdify +from sympy import pi, cos, sin, Matrix, Tuple, lambdify from scipy.sparse.linalg import spsolve -from scipy.sparse.linalg import gmres as sp_gmres from scipy.sparse.linalg import minres as sp_minres -from scipy.sparse.linalg import cg as sp_cg -from scipy.sparse.linalg import bicg as sp_bicg -from scipy.sparse.linalg import bicgstab as sp_bicgstab -from sympde.calculus import grad, dot, inner, div, curl, cross +from sympde.calculus import grad, inner, div, curl, cross from sympde.topology import NormalVector from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace @@ -34,25 +30,25 @@ def run_poisson_mixed_form_2d_dir(f0, sol, ncells, degree): V2 = ScalarFunctionSpace('V2', domain, kind='L2') X = ProductSpace(V1, V2) - x,y = domain.coordinates + x, y = domain.coordinates F = element_of(V2, name='F') - p,q = [element_of(V1, name=i) for i in ['p', 'q']] - u,v = [element_of(V2, name=i) for i in ['u', 'v']] + p, q = elements_of(V1, names='p, q') + u, v = elements_of(V2, names='u, v') int_0 = lambda expr: integral(domain , expr) - a = BilinearForm(((p,u),(q,v)), int_0(dot(p,q) + div(q)*u + div(p)*v) ) - l = LinearForm((q,v), int_0(f0*v)) + a = BilinearForm(((p, u), (q, v)), int_0(inner(p, q) + div(q) * u + div(p) * v)) + l = LinearForm((q, v), int_0(f0 * v)) # ... error = F-sol l2norm_F = Norm(error, domain, kind='l2') # ... - equation = find([p,u], forall=[q,v], lhs=a((p,u),(q,v)), rhs=l(q,v)) + equation = find((p, u), forall=(q, v), lhs=a((p, u), (q, v)), rhs=l(q, v)) # ... create the computational domain from a topological domain domain_h = discretize(domain, ncells=ncells) @@ -103,7 +99,7 @@ def run_stokes_2d_dir(domain, f, ue, pe, *, homogeneous, ncells, degree, scipy=F int_0 = lambda expr: integral(domain , expr) a = BilinearForm(((u, p), (v, q)), int_0(inner(grad(u), grad(v)) - div(u)*q - p*div(v)) ) - l = LinearForm((v, q), int_0(dot(f, v))) + l = LinearForm((v, q), int_0(inner(f, v))) # Dirichlet boundary conditions are given in the form u = g where g may be # just 0 (hence homogeneous BCs are prescribed) or a symbolic expression @@ -135,8 +131,8 @@ def run_stokes_2d_dir(domain, f, ue, pe, *, homogeneous, ncells, degree, scipy=F b0 = equation_h.linear_system.rhs.toarray() if not homogeneous: - a1 = BilinearForm(((u, p), (v, q)), integral(domain.boundary, dot(u, v))) - l1 = LinearForm((v, q), integral(domain.boundary, dot(ue, v))) + a1 = BilinearForm(((u, p), (v, q)), integral(domain.boundary, inner(u, v))) + l1 = LinearForm((v, q), integral(domain.boundary, inner(ue, v))) a1_h = discretize(a1, domain_h, [Xh, Xh]) l1_h = discretize(l1, domain_h, Xh) @@ -230,7 +226,7 @@ def run_stokes_2d_dir_petsc(domain, f, ue, pe, *, homogeneous, ncells, degree): int_0 = lambda expr: integral(domain , expr) a = BilinearForm(((u, p), (v, q)), int_0(inner(grad(u), grad(v)) - div(u)*q - p*div(v)) ) - l = LinearForm((v, q), int_0(dot(f, v))) + l = LinearForm((v, q), int_0(inner(f, v))) # Dirichlet boundary conditions are given in the form u = g where g may be # just 0 (hence homogeneous BCs are prescribed) or a symbolic expression @@ -271,8 +267,8 @@ def run_stokes_2d_dir_petsc(domain, f, ue, pe, *, homogeneous, ncells, degree): b0 = equation_h.linear_system.rhs.topetsc() if not homogeneous: - a1 = BilinearForm(((u, p), (v, q)), integral(domain.boundary, dot(u, v))) - l1 = LinearForm((v, q), integral(domain.boundary, dot(ue, v))) + a1 = BilinearForm(((u, p), (v, q)), integral(domain.boundary, inner(u, v))) + l1 = LinearForm((v, q), integral(domain.boundary, inner(ue, v))) a1_h = discretize(a1, domain_h, [Xh, Xh]) l1_h = discretize(l1, domain_h, Xh) @@ -360,14 +356,14 @@ def run_maxwell_time_harmonic_2d_dir(uex, f, alpha, ncells, degree): F = element_of(V, name='F') # Bilinear form a: V x V --> R - a = BilinearForm((u, v), integral(domain, curl(u)*curl(v) + alpha*dot(u,v))) + a = BilinearForm((u, v), integral(domain, curl(u)*curl(v) + alpha*inner(u, v))) nn = NormalVector('nn') a_bc = BilinearForm((u, v), integral(domain.boundary, 1e30 * cross(u, nn) * cross(v, nn))) # Linear form l: V --> R - l = LinearForm(v, integral(domain, dot(f,v))) + l = LinearForm(v, integral(domain, inner(f, v))) # l2 error error = Matrix([F[0]-uex[0],F[1]-uex[1]]) diff --git a/psydac/api/tests/test_api_2d_fields.py b/psydac/api/tests/test_api_2d_fields.py index abd7a1d75..b3fcc966e 100644 --- a/psydac/api/tests/test_api_2d_fields.py +++ b/psydac/api/tests/test_api_2d_fields.py @@ -14,18 +14,16 @@ # Please note that the logical coordinates (x1, x2) correspond to the polar # coordinates (r, theta), but with reversed order: hence x1=theta and x2=r -from mpi4py import MPI -from sympy import pi, cos, sin, log, exp, lambdify, symbols -import pytest import os -from sympde.calculus import grad, dot -from sympde.calculus import laplace +import pytest +from sympy import pi, sin, log, exp, lambdify, symbols + +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.topology import NormalVector from sympde.topology import Domain -from sympde.topology import Union from sympde.topology import Square from sympde.expr import linearize from sympde.expr import BilinearForm, LinearForm, integral @@ -201,7 +199,7 @@ def run_non_linear_poisson(filename, comm=None): u = element_of(V, name='u') f = -2.*exp(-u) - l = LinearForm( v, integral(Omega, dot(grad(v), grad(u)) - f*v )) + l = LinearForm( v, integral(Omega, inner(grad(v), grad(u)) - f*v )) du = element_of(V, name='du') dir_boundary = Omega.get_boundary(axis=0, ext=1) diff --git a/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py b/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py index 98efa61f7..5a5c3a51e 100644 --- a/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py +++ b/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py @@ -1,7 +1,6 @@ import numpy as np -from mpi4py import MPI -from sympde.calculus import grad, dot +from sympde.calculus import grad, inner from sympde.topology import ScalarFunctionSpace from sympde.topology import elements_of from sympde.topology import Square @@ -28,7 +27,7 @@ def run_poisson_2d(solution, f, domain, ncells, degree, comm=None): error = u - solution - a = BilinearForm((u,v), integral(domain, dot(grad(u),grad(v)))) + a = BilinearForm((u,v), integral(domain, inner(grad(u), grad(v)))) l = LinearForm(v, integral(domain, f*v)) equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) diff --git a/psydac/api/tests/test_api_2d_system.py b/psydac/api/tests/test_api_2d_system.py index a4d356b9b..c48497fe0 100644 --- a/psydac/api/tests/test_api_2d_system.py +++ b/psydac/api/tests/test_api_2d_system.py @@ -1,11 +1,9 @@ # -*- coding: UTF-8 -*- -from mpi4py import MPI from sympy import pi, cos, sin, Tuple, Matrix import numpy as np -import pytest -from sympde.calculus import grad, dot, inner +from sympde.calculus import grad, inner from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace from sympde.topology import ProductSpace from sympde.topology import element_of @@ -41,11 +39,11 @@ def run_system_1_2d_dir(Fe, Ge, f0, f1, ncells, degree): int_0 = lambda expr: integral(domain , expr) a0 = BilinearForm((v,u), int_0(inner(grad(v), grad(u)))) - a1 = BilinearForm((q,p), int_0(p*q)) + a1 = BilinearForm((q,p), int_0(p * q)) a = BilinearForm(((v,q),(u,p)), a0(v,u) + a1(q,p)) - l0 = LinearForm(v, int_0(dot(f0, v))) - l1 = LinearForm(q, int_0(f1*q)) + l0 = LinearForm(v, int_0(inner(f0, v))) + l1 = LinearForm(q, int_0(f1 * q)) l = LinearForm((v,q), l0(v) + l1(q)) error = Matrix([F[0]-Fe[0], F[1]-Fe[1]]) diff --git a/psydac/api/tests/test_api_2d_vector.py b/psydac/api/tests/test_api_2d_vector.py index b18c94a39..08934658a 100644 --- a/psydac/api/tests/test_api_2d_vector.py +++ b/psydac/api/tests/test_api_2d_vector.py @@ -3,9 +3,9 @@ from sympy import Tuple, Matrix from sympy import pi, sin -from sympde.calculus import grad, dot, inner +from sympde.calculus import grad, inner from sympde.topology import VectorFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Square from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm @@ -21,18 +21,12 @@ def run_vector_poisson_2d_dir(solution, f, ncells, degree): V = VectorFunctionSpace('V', domain) - x,y = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') int_0 = lambda expr: integral(domain , expr) - expr = inner(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) - - expr = dot(f, v) - l = LinearForm(v, int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) + l = LinearForm(v, int_0(inner(f, v))) error = Matrix([u[0]-solution[0], u[1]-solution[1]]) l2norm = Norm(error, domain, kind='l2') diff --git a/psydac/api/tests/test_api_2d_vector_mapping.py b/psydac/api/tests/test_api_2d_vector_mapping.py index d685d7fb4..03adad7e1 100644 --- a/psydac/api/tests/test_api_2d_vector_mapping.py +++ b/psydac/api/tests/test_api_2d_vector_mapping.py @@ -1,14 +1,14 @@ # -*- coding: UTF-8 -*- import os + from sympy import Tuple, Matrix, symbols from sympy import pi, sin -from sympde.calculus import grad, dot, inner +from sympde.calculus import grad, inner from sympde.topology import VectorFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Domain -from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC @@ -34,18 +34,12 @@ def run_vector_poisson_2d_dir(filename, solution, f): V = VectorFunctionSpace('V', domain) - x,y = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') - - int_0 = lambda expr: integral(domain , expr) + u, v = elements_of(V, names='u, v') - expr = inner(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + int_0 = lambda expr: integral(domain, expr) - expr = dot(f, v) - l = LinearForm(v, int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) + l = LinearForm(v, int_0(inner(f, v))) error = Matrix([u[0]-solution[0], u[1]-solution[1]]) l2norm = Norm(error, domain, kind='l2') diff --git a/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py b/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py index a0ea5ba2b..a25495a51 100644 --- a/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py +++ b/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py @@ -1,14 +1,14 @@ # -*- coding: UTF-8 -*- import os + from sympy import Tuple, Matrix, symbols from sympy import pi, sin -from sympde.calculus import grad, dot, inner, Transpose -from sympde.topology import VectorFunctionSpace, ScalarFunctionSpace -from sympde.topology import element_of +from sympde.calculus import grad, inner, Transpose +from sympde.topology import VectorFunctionSpace +from sympde.topology import elements_of from sympde.topology import Domain -from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC @@ -36,10 +36,7 @@ def run_vector_poisson_2d_dir(filename, solution, f): V = VectorFunctionSpace('V', domain) - x,y = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') nn = NormalVector("nn") @@ -50,23 +47,20 @@ def run_vector_poisson_2d_dir(filename, solution, f): avr = lambda u:0.5*plus(u)+0.5*minus(u) jump = lambda u: minus(u)-plus(u) - expr_I = - dot(Transpose(grad(avr(u)))*nn, jump(v)) - dot(Transpose(grad(avr(v)))*nn, jump(u)) + kappa*dot(jump(u), jump(v)) - - int_0 = lambda expr: integral(domain , expr) - int_1 = lambda expr: integral(I , expr) + expr_I = - inner(Transpose(grad(avr(u)))*nn, jump(v)) - inner(Transpose(grad(avr(v)))*nn, jump(u)) + kappa * inner(jump(u), jump(v)) - expr = inner(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr) + int_1(expr_I)) + int_0 = lambda expr: integral(domain, expr) + int_1 = lambda expr: integral(I, expr) - expr = dot(f, v) - l = LinearForm(v, int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v))) + int_1(expr_I)) + l = LinearForm(v, int_0(inner(f, v))) error = Matrix([0, u[1]-solution[1]]) l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') bc = EssentialBC(u, 0, domain.boundary) - equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) + equation = find(u, forall=v, lhs=a(u, v), rhs=l(v), bc=bc) # ... # ... create the computational domain from a topological domain diff --git a/psydac/api/tests/test_api_3d_scalar.py b/psydac/api/tests/test_api_3d_scalar.py index 668a7f674..9e43d3dd6 100644 --- a/psydac/api/tests/test_api_3d_scalar.py +++ b/psydac/api/tests/test_api_3d_scalar.py @@ -4,9 +4,9 @@ from sympy import pi, cos, sin import pytest -from sympde.calculus import grad, dot +from sympde.calculus import grad, dot, inner from sympde.topology import ScalarFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import NormalVector from sympde.topology import Cube from sympde.topology import Union @@ -24,17 +24,14 @@ def run_poisson_3d_dir(solution, f, ncells, degree, comm=None): V = ScalarFunctionSpace('V', domain) - x,y,z = domain.coordinates + u, v = elements_of(V, names='u, v') - v = element_of(V, name='v') - u = element_of(V, name='u') + int_0 = lambda expr: integral(domain, expr) - int_0 = lambda expr: integral(domain , expr) + expr = inner(grad(u), grad(v)) + a = BilinearForm((u, v), int_0(expr)) - expr = dot(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) - - expr = f*v + expr = f * v l = LinearForm(v, int_0(expr)) error = u - solution @@ -90,23 +87,20 @@ def run_poisson_3d_dirneu(solution, f, boundary, ncells, degree, comm=None): else: B_neumann = Union(*B_neumann) - x,y,z = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') nn = NormalVector('nn') - int_0 = lambda expr: integral(domain , expr) - int_1 = lambda expr: integral(B_neumann , expr) + int_0 = lambda expr: integral(domain, expr) + int_1 = lambda expr: integral(B_neumann, expr) - expr = dot(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + expr = inner(grad(u), grad(v)) + a = BilinearForm((u, v), int_0(expr)) - expr = f*v + expr = f * v l0 = LinearForm(v, int_0(expr)) - expr = v*dot(grad(solution), nn) + expr = v * dot(grad(solution), nn) l_B_neumann = LinearForm(v, int_1(expr)) expr = l0(v) + l_B_neumann(v) diff --git a/psydac/api/tests/test_api_3d_scalar_mapping.py b/psydac/api/tests/test_api_3d_scalar_mapping.py index 0d51db13b..685077184 100644 --- a/psydac/api/tests/test_api_3d_scalar_mapping.py +++ b/psydac/api/tests/test_api_3d_scalar_mapping.py @@ -1,13 +1,14 @@ # -*- coding: UTF-8 -*- +import os + from mpi4py import MPI from sympy import pi, cos, sin, symbols import pytest -import os -from sympde.calculus import grad, dot -from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace -from sympde.topology import element_of +from sympde.calculus import grad, dot, inner +from sympde.topology import ScalarFunctionSpace +from sympde.topology import elements_of from sympde.topology import NormalVector from sympde.topology import Union from sympde.topology import Domain @@ -35,25 +36,20 @@ def run_poisson_3d_dir(filename, solution, f, comm=None): V = ScalarFunctionSpace('V', domain) - x,y,z = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') - int_0 = lambda expr: integral(domain , expr) + int_0 = lambda expr: integral(domain, expr) - expr = dot(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) - expr = f*v - l = LinearForm(v, int_0(expr)) + l = LinearForm(v, int_0(f * v)) error = u - solution l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') bc = EssentialBC(u, 0, domain.boundary) - equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) + equation = find(u, forall=v, lhs=a(u, v), rhs=l(v), bc=bc) # ... # ... create the computational domain from a topological domain @@ -101,23 +97,20 @@ def run_poisson_3d_dirneu(filename, solution, f, boundary, comm=None): else: B_neumann = Union(*B_neumann) - x,y,z = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') nn = NormalVector('nn') - int_0 = lambda expr: integral(domain , expr) - int_1 = lambda expr: integral(B_neumann , expr) + int_0 = lambda expr: integral(domain, expr) + int_1 = lambda expr: integral(B_neumann, expr) - expr = dot(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + expr = inner(grad(u), grad(v)) + a = BilinearForm((u, v), int_0(expr)) - expr = f*v + expr = f * v l0 = LinearForm(v, int_0(expr)) - expr = v*dot(grad(solution), nn) + expr = v * dot(grad(solution), nn) l_B_neumann = LinearForm(v, int_1(expr)) expr = l0(v) + l_B_neumann(v) @@ -171,25 +164,20 @@ def run_laplace_3d_neu(filename, solution, f, comm=None): B_neumann = domain.boundary - x,y,z = domain.coordinates - - F = element_of(V, name='F') - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') nn = NormalVector('nn') - int_0 = lambda expr: integral(domain , expr) - int_1 = lambda expr: integral(B_neumann , expr) + int_0 = lambda expr: integral(domain, expr) + int_1 = lambda expr: integral(B_neumann, expr) - expr = dot(grad(v), grad(u)) + v*u - a = BilinearForm((v,u), int_0(expr)) + expr = inner(grad(u), grad(v)) + u * v + a = BilinearForm((u, v), int_0(expr)) - expr = f*v + expr = f * v l0 = LinearForm(v, int_0(expr)) - expr = v*dot(grad(solution), nn) + expr = v * dot(grad(solution), nn) l_B_neumann = LinearForm(v, int_1(expr)) expr = l0(v) + l_B_neumann(v) @@ -199,7 +187,7 @@ def run_laplace_3d_neu(filename, solution, f, comm=None): l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') - equation = find(u, forall=v, lhs=a(u,v), rhs=l(v)) + equation = find(u, forall=v, lhs=a(u, v), rhs=l(v)) # ... # ... create the computational domain from a topological domain diff --git a/psydac/api/tests/test_api_3d_vector.py b/psydac/api/tests/test_api_3d_vector.py index dc55df754..0d50fa256 100644 --- a/psydac/api/tests/test_api_3d_vector.py +++ b/psydac/api/tests/test_api_3d_vector.py @@ -3,9 +3,9 @@ from sympy import Tuple, Matrix from sympy import pi, sin -from sympde.calculus import grad, dot, inner +from sympde.calculus import grad, inner from sympde.topology import VectorFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Cube from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm @@ -20,26 +20,20 @@ def run_vector_poisson_3d_dir(solution, f, ncells, degree): domain = Cube() V = VectorFunctionSpace('V', domain) - - x,y,z = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') int_0 = lambda expr: integral(domain , expr) - expr = inner(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) - expr = dot(f, v) - l = LinearForm(v, int_0(expr)) + l = LinearForm(v, int_0(inner(f, v))) error = Matrix([u[0]-solution[0], u[1]-solution[1], u[2]-solution[2]]) l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') bc = EssentialBC(u, 0, domain.boundary) - equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) + equation = find(u, forall=v, lhs=a(u, v), rhs=l(v), bc=bc) # ... # ... create the computational domain from a topological domain diff --git a/psydac/api/tests/test_api_3d_vector_mapping.py b/psydac/api/tests/test_api_3d_vector_mapping.py index 2889392c4..3c40f5e5f 100644 --- a/psydac/api/tests/test_api_3d_vector_mapping.py +++ b/psydac/api/tests/test_api_3d_vector_mapping.py @@ -1,12 +1,13 @@ # -*- coding: UTF-8 -*- import os + from sympy import Tuple, Matrix, symbols from sympy import pi, sin -from sympde.calculus import grad, dot, inner +from sympde.calculus import grad, inner from sympde.topology import VectorFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Domain from sympde.expr import BilinearForm, LinearForm, integral from sympde.expr import Norm, SemiNorm @@ -31,26 +32,20 @@ def run_vector_poisson_3d_dir(filename, solution, f): domain = Domain.from_file(filename) V = VectorFunctionSpace('V', domain) + u, v = elements_of(V, names='u, v') - x,y,z = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') - - int_0 = lambda expr: integral(domain , expr) + int_0 = lambda expr: integral(domain, expr) - expr = inner(grad(v), grad(u)) - a = BilinearForm((v,u), int_0(expr)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) - expr = dot(f, v) - l = LinearForm(v, int_0(expr)) + l = LinearForm(v, int_0(inner(f, v))) error = Matrix([u[0]-solution[0], u[1]-solution[1], u[2]-solution[2]]) l2norm = Norm(error, domain, kind='l2') h1norm = SemiNorm(error, domain, kind='h1') bc = EssentialBC(u, 0, domain.boundary) - equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) + equation = find(u, forall=v, lhs=a(u, v), rhs=l(v), bc=bc) # ... # ... create the computational domain from a topological domain diff --git a/psydac/api/tests/test_api_expr_2d_scalar.py b/psydac/api/tests/test_api_expr_2d_scalar.py index d714b06a6..9cd35b569 100644 --- a/psydac/api/tests/test_api_expr_2d_scalar.py +++ b/psydac/api/tests/test_api_expr_2d_scalar.py @@ -1,12 +1,10 @@ # -*- coding: UTF-8 -*- import pytest - -from mpi4py import MPI -from sympy import pi import numpy as np +from sympy import pi -from sympde.calculus import dot, div +from sympde.calculus import inner, div from sympde.topology import VectorFunctionSpace from sympde.topology import element_of from sympde.topology import Square, IdentityMapping @@ -19,16 +17,16 @@ def run_poisson_2d_dir(ncells, degree, comm=None): # ... abstract model domain = Square() - mapping = IdentityMapping('M',2) + mapping = IdentityMapping('M', 2) domain = mapping(domain) V = VectorFunctionSpace('V', domain) F = element_of(V, name='F') - x,y = domain.coordinates + x, y = domain.coordinates - expr = x*y+ pi*div(F) + dot(F, F) + expr = x * y + pi * div(F) + inner(F, F) domain_h = discretize(domain, ncells=ncells, comm=comm) # ... diff --git a/psydac/api/tests/test_api_feec_2d.py b/psydac/api/tests/test_api_feec_2d.py index 40b607615..153f8655b 100644 --- a/psydac/api/tests/test_api_feec_2d.py +++ b/psydac/api/tests/test_api_feec_2d.py @@ -192,7 +192,6 @@ def run_maxwell_2d_TE(*, use_spline_mapping, import numpy as np import matplotlib.pyplot as plt from mpi4py import MPI - from scipy.integrate import dblquad from sympde.topology import Domain from sympde.topology import Square @@ -202,7 +201,7 @@ def run_maxwell_2d_TE(*, use_spline_mapping, from sympde.topology import Derham from sympde.topology import elements_of from sympde.topology import NormalVector - from sympde.calculus import dot, cross + from sympde.calculus import inner, cross from sympde.expr import integral from sympde.expr import BilinearForm @@ -279,7 +278,7 @@ class CollelaMapping2D(Mapping): u2, v2 = elements_of(derham.V2, names='u2, v2') # magnetic field Bz # Bilinear forms that correspond to mass matrices for spaces V1 and V2 - a1 = BilinearForm((u1, v1), integral(domain, dot(u1, v1))) + a1 = BilinearForm((u1, v1), integral(domain, inner(u1, v1))) a2 = BilinearForm((u2, v2), integral(domain, u2 * v2)) # Penalization to apply homogeneous Dirichlet BCs (will only be used if domain is not periodic) diff --git a/psydac/api/tests/test_api_feec_3d.py b/psydac/api/tests/test_api_feec_3d.py index d5220b5bc..2d1a58b18 100644 --- a/psydac/api/tests/test_api_feec_3d.py +++ b/psydac/api/tests/test_api_feec_3d.py @@ -1,24 +1,17 @@ # -*- coding: UTF-8 -*- from mpi4py import MPI -import pytest import numpy as np from sympde.topology import Mapping -from sympde.calculus import grad, dot -from sympde.calculus import laplace -from sympde.topology import ScalarFunctionSpace +from sympde.calculus import inner from sympde.topology import elements_of -from sympde.topology import NormalVector from sympde.topology import Cube, Derham -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, integral from psydac.fem.basic import FemField from psydac.api.discretization import discretize -from psydac.feec.pull_push import push_3d_hcurl, push_3d_hdiv +from psydac.feec.pull_push import push_3d_hdiv from psydac.api.settings import PSYDAC_BACKEND_GPYCCEL from psydac.linalg.utilities import array_to_psydac from psydac.linalg.solvers import inverse @@ -101,8 +94,8 @@ def run_maxwell_3d_scipy(logical_domain, mapping, e_ex, b_ex, ncells, degree, pe u3, v3 = elements_of(derham.V3, names='u3, v3') a0 = BilinearForm((u0, v0), integral(domain, u0*v0)) - a1 = BilinearForm((u1, v1), integral(domain, dot(u1, v1))) - a2 = BilinearForm((u2, v2), integral(domain, dot(u2, v2))) + a1 = BilinearForm((u1, v1), integral(domain, inner(u1, v1))) + a2 = BilinearForm((u2, v2), integral(domain, inner(u2, v2))) a3 = BilinearForm((u3, v3), integral(domain, u3*v3)) # Callable mapping @@ -196,8 +189,8 @@ def run_maxwell_3d_stencil(logical_domain, mapping, e_ex, b_ex, ncells, degree, u3, v3 = elements_of(derham.V3, names='u3, v3') a0 = BilinearForm((u0, v0), integral(domain, u0*v0)) - a1 = BilinearForm((u1, v1), integral(domain, dot(u1, v1))) - a2 = BilinearForm((u2, v2), integral(domain, dot(u2, v2))) + a1 = BilinearForm((u1, v1), integral(domain, inner(u1, v1))) + a2 = BilinearForm((u2, v2), integral(domain, inner(u2, v2))) a3 = BilinearForm((u3, v3), integral(domain, u3*v3)) # Callable mapping diff --git a/psydac/api/tests/test_api_glt_2d_scalar.py b/psydac/api/tests/test_api_glt_2d_scalar.py index 984dff853..60c1d23c6 100644 --- a/psydac/api/tests/test_api_glt_2d_scalar.py +++ b/psydac/api/tests/test_api_glt_2d_scalar.py @@ -1,33 +1,23 @@ # -*- coding: UTF-8 -*- -from sympy import pi, cos, sin -from sympy.utilities.lambdify import implemented_function +import pytest +import numpy as np +from sympy import pi, sin +from scipy.linalg import eig as eig_solver 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 dx1, dx2, dx3 -from sympde.topology import ScalarFunctionSpace, 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.calculus import grad, inner +from sympde.topology import dx1, dx2 +from sympde.topology import ScalarFunctionSpace +from sympde.topology import elements_of +from sympde.topology import Square +from sympde.expr import BilinearForm, integral from gelato.expr import GltExpr from psydac.fem.basic import FemField 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): @@ -36,14 +26,11 @@ def run_poisson_2d_dir(ncells, degree, comm=None): V = ScalarFunctionSpace('V', domain) - F = element_of(V, name='F') - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') int_0 = lambda expr: integral(domain , expr) - a = BilinearForm((v,u), int_0(dot(grad(v), grad(u)))) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) glt_a = GltExpr(a) # ... @@ -91,15 +78,12 @@ def run_field_2d_dir(ncells, degree, comm=None): V = ScalarFunctionSpace('V', domain) - F = element_of(V, name='F') - - v = element_of(V, name='v') - u = element_of(V, name='u') + F, u, v = elements_of(V, name='F, u, v') int_0 = lambda expr: integral(domain , expr) - a = BilinearForm((v,u), int_0(dot(grad(v), grad(u)) + F*u*v)) - ae = BilinearForm((v,u), int_0(dot(grad(v), grad(u)) + u*v)) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)) + F * u * v)) + ae = BilinearForm((u, v), int_0(inner(grad(u), grad(v)) + u * v)) glt_a = GltExpr(a) glt_ae = GltExpr(ae) @@ -155,17 +139,14 @@ def run_variable_coeff_2d_dir(ncells, degree, comm=None): V = ScalarFunctionSpace('V', domain) - F = element_of(V, name='F') - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, name='u, v') c = Constant('c', real=True) int_0 = lambda expr: integral(domain , expr) expr = (1 + c*sin(pi*(x+y)))*dx1(u)*dx2(v) + (1 + c*sin(pi*(x-y)))*dx1(u)*dx2(v) - a = BilinearForm((v,u), int_0(expr)) + a = BilinearForm((u, v), int_0(expr)) glt_a = GltExpr(a) # ... 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 84eb845d5..b41ad17c0 100644 --- a/psydac/api/tests/test_api_glt_2d_scalar_mapping.py +++ b/psydac/api/tests/test_api_glt_2d_scalar_mapping.py @@ -1,19 +1,20 @@ # -*- coding: UTF-8 -*- import os + +import pytest import numpy as np from scipy.linalg import eig as eig_solver -from sympde.calculus import grad, dot +from sympde.calculus import grad, inner from sympde.topology import ScalarFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Domain from sympde.expr import BilinearForm, integral from gelato.expr import GltExpr from psydac.api.discretization import discretize -import pytest # ... get the mesh directory try: @@ -33,14 +34,11 @@ def run_poisson_2d_dir(filename, comm=None): V = ScalarFunctionSpace('V', domain) - x,y = domain.coordinates - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') int_0 = lambda expr: integral(domain , expr) - a = BilinearForm((v,u), int_0(dot(grad(v), grad(u)))) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) glt_a = GltExpr(a) # ... diff --git a/psydac/api/tests/test_api_glt_2d_vector.py b/psydac/api/tests/test_api_glt_2d_vector.py index 21839a362..f5c66a472 100644 --- a/psydac/api/tests/test_api_glt_2d_vector.py +++ b/psydac/api/tests/test_api_glt_2d_vector.py @@ -6,7 +6,7 @@ from sympde.calculus import grad, inner from sympde.topology import VectorFunctionSpace -from sympde.topology import element_of +from sympde.topology import elements_of from sympde.topology import Square from sympde.expr import BilinearForm, integral @@ -22,16 +22,11 @@ def run_vector_poisson_2d_dir(ncells, degree): V = VectorFunctionSpace('V', domain) - x,y = domain.coordinates - - F = element_of(V, name='F') - - v = element_of(V, name='v') - u = element_of(V, name='u') + u, v = elements_of(V, names='u, v') int_0 = lambda expr: integral(domain , expr) - a = BilinearForm((v,u), int_0(inner(grad(v), grad(u)))) + a = BilinearForm((u, v), int_0(inner(grad(u), grad(v)))) glt_a = GltExpr(a) # ... diff --git a/psydac/api/tests/test_assembly.py b/psydac/api/tests/test_assembly.py index d00c58840..5ee4f9115 100644 --- a/psydac/api/tests/test_assembly.py +++ b/psydac/api/tests/test_assembly.py @@ -1,7 +1,7 @@ import pytest import numpy as np from mpi4py import MPI -from sympy import pi, sin, cos, tan, atan, atan2, exp, sinh, cosh, tanh, atanh, Tuple, I, sqrt +from sympy import pi, sin, cos, tan, atan, atan2, exp, sinh, cosh, tanh, atanh, I, sqrt from sympde.topology import Line, Square from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace @@ -9,9 +9,8 @@ from sympde.core import Constant from sympde.expr import LinearForm, BilinearForm, Functional, Norm from sympde.expr import integral -from sympde.calculus import Inner +from sympde.calculus import inner -from psydac.linalg.solvers import inverse from psydac.api.discretization import discretize from psydac.fem.basic import FemField from psydac.api.settings import PSYDAC_BACKENDS @@ -455,7 +454,7 @@ def test_non_symmetric_different_space_BilinearForm(backend): u = element_of(X, name='u') w = element_of(V, name='w') - A = BilinearForm((u, w), integral(domain, Inner(u, w))) + A = BilinearForm((u, w), integral(domain, inner(u, w))) ncells = [4, 4] degree = [2, 2] diff --git a/psydac/api/tests/test_build_derham_mapping.py b/psydac/api/tests/test_build_derham_mapping.py index a21f7342d..a9978bec0 100644 --- a/psydac/api/tests/test_build_derham_mapping.py +++ b/psydac/api/tests/test_build_derham_mapping.py @@ -1,3 +1,12 @@ +import os + +import pytest +import numpy as np +from sympy import exp, lambdify + +from sympde.topology.analytical_mapping import IdentityMapping +from sympde.topology import Derham + from psydac.mapping.discrete import SplineMapping from psydac.fem.splines import SplineSpace from psydac.fem.tensor import TensorFemSpace @@ -6,20 +15,10 @@ from psydac.cad.geometry import Geometry from psydac.api.postprocessing import OutputManager, PostProcessManager -from sympde.topology.analytical_mapping import IdentityMapping -from sympde.topology import Cube, Derham - -from sympy import exp, lambdify - -import pytest -import numpy as np -import os - -@pytest.mark.parametrize('degree', [[2], [3]]) -@pytest.mark.parametrize('ncells', [[4], [10]]) @pytest.mark.parametrize('periodic', [[True], [False]]) - +@pytest.mark.parametrize('ncells', [[4], [10]]) +@pytest.mark.parametrize('degree', [[2], [3]]) def test_build_derham_spline_mapping_id_1d(degree, ncells, periodic): p1, = degree @@ -73,10 +72,10 @@ def test_build_derham_spline_mapping_id_1d(degree, ncells, periodic): # snapshots='all', fields=('f')) #Pm.close() -@pytest.mark.parametrize('degree', [[2,2], [3,4]]) -@pytest.mark.parametrize('ncells', [[5,6], [10,10]]) -@pytest.mark.parametrize('periodic', [[True,True], [True,False]]) +@pytest.mark.parametrize('periodic', [[True,True], [True,False]]) +@pytest.mark.parametrize('ncells', [[5,6], [10,10]]) +@pytest.mark.parametrize('degree', [[2,2], [3,4]]) def test_build_derham_spline_mapping_id_2d(degree, ncells, periodic): p1 , p2 = degree @@ -134,10 +133,10 @@ def test_build_derham_spline_mapping_id_2d(degree, ncells, periodic): os.remove("./export_sol.h5") os.remove("./fields_test.0000.vtu") -@pytest.mark.parametrize('degree', [[2,2,2], [2,3,4]]) -@pytest.mark.parametrize('ncells', [[4,6,7], [10,10,10]]) -@pytest.mark.parametrize('periodic', [[True,True,True], [True,False,False]]) +@pytest.mark.parametrize('periodic', [[True,True,True], [True,False,False]]) +@pytest.mark.parametrize('ncells', [[4,6,7], [10,10,10]]) +@pytest.mark.parametrize('degree', [[2,2,2], [2,3,4]]) def test_build_derham_spline_mapping_id_3d(degree, ncells, periodic): p1 , p2, p3 = degree @@ -197,6 +196,7 @@ def test_build_derham_spline_mapping_id_3d(degree, ncells, periodic): os.remove("./export_sol.h5") os.remove("./fields_test.0000.vtu") + if __name__ == '__main__': #test_build_derham_spline_mapping_id_1d([2], [10], [True]) test_build_derham_spline_mapping_id_2d([2,2], [5,10], [True,True]) diff --git a/psydac/api/tests/test_equation.py b/psydac/api/tests/test_equation.py index 74f410cc9..c43b323e7 100644 --- a/psydac/api/tests/test_equation.py +++ b/psydac/api/tests/test_equation.py @@ -1,7 +1,7 @@ import pytest import numpy as np -from sympde.topology import Line, Square +from sympde.topology import Square from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.core import Constant diff --git a/psydac/api/tests/test_postprocessing.py b/psydac/api/tests/test_postprocessing.py index 6847008c0..ef8426a33 100644 --- a/psydac/api/tests/test_postprocessing.py +++ b/psydac/api/tests/test_postprocessing.py @@ -1,9 +1,8 @@ import glob import os -import pytest +import pytest import numpy as np - from mpi4py import MPI from sympde.topology import Square, Cube, ScalarFunctionSpace, VectorFunctionSpace, Domain, Derham, Union @@ -21,7 +20,6 @@ push_3d_hcurl, push_3d_hdiv, push_3d_l2) - from psydac.api.postprocessing import OutputManager, PostProcessManager # Get mesh_directory diff --git a/psydac/api/tests/test_quadorder.py b/psydac/api/tests/test_quadorder.py index 94c916166..d2ee4a731 100644 --- a/psydac/api/tests/test_quadorder.py +++ b/psydac/api/tests/test_quadorder.py @@ -1,6 +1,7 @@ import pytest +import numpy as np -from sympde.topology import Line, Square +from sympde.topology import Square from sympde.topology import ScalarFunctionSpace from sympde.topology import element_of from sympde.core import Constant @@ -8,8 +9,6 @@ from sympde.expr import LinearForm from sympde.expr import integral -import numpy as np - from psydac.api.discretization import discretize from psydac.api.settings import PSYDAC_BACKEND_PYTHON diff --git a/pyproject.toml b/pyproject.toml index 2d42320d2..948c0cb0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ 'pyevtk', # Our packages from PyPi - 'sympde == 0.19.2', + 'sympde @ https://github.com/pyccel/sympde/archive/refs/heads/dot-inner.zip', 'pyccel >= 1.11.2', 'gelato == 0.12',