diff --git a/psydac/api/ast/tests/poisson.py b/psydac/api/ast/tests/poisson.py index b5a418d37..d669986c0 100644 --- a/psydac/api/ast/tests/poisson.py +++ b/psydac/api/ast/tests/poisson.py @@ -1,19 +1,18 @@ # -*- coding: UTF-8 -*- - +import os from sympy import symbols -from sympy import sin,pi +from sympy import sin, pi from sympde.calculus import grad, dot - from sympde.topology import ScalarFunctionSpace -from sympde.topology import elements_of,LogicalExpr +from sympde.topology import elements_of, LogicalExpr from sympde.topology import Square -from sympde.topology import IdentityMapping,Mapping ,PolarMapping +from sympde.topology import Mapping, IdentityMapping, PolarMapping from sympde.expr import integral from sympde.expr import LinearForm from sympde.expr import BilinearForm -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr.evaluation import TerminalExpr from psydac.api.ast.fem import AST @@ -21,7 +20,6 @@ from psydac.api.discretization import discretize from psydac.api.printing.pycode import pycode -import os # ... try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] @@ -32,6 +30,7 @@ mesh_dir = os.path.join(base_dir, 'mesh') filename = os.path.join(mesh_dir, 'identity_2d.h5') + def test_codegen(): domain = Square() M = Mapping('M',2) @@ -51,22 +50,22 @@ def test_codegen(): Vh = discretize(V, domain_h) error = u - sin(pi*x)*sin(pi*y) - l2norm = LogicalExpr(M, Norm(error, domain, kind='l2')) - h1norm = LogicalExpr(M, Norm(error, domain, kind='h1')) + l2norm = LogicalExpr(M, Norm(error, domain, kind='l2')) + h1norm = LogicalExpr(M, SemiNorm(error, domain, kind='h1')) ast_b = AST(b, TerminalExpr(b)[0],[Vh, Vh]) - ast_b = parse(ast_b.expr, settings={'dim':2,'nderiv':1,'mapping':M,'target':domain.logical_domain}) + ast_b = parse(ast_b.expr, settings={'dim':2, 'nderiv':1, 'mapping':M, 'target':domain.logical_domain}) print(pycode(ast_b)) print('==============================================================================================================') ast_l = AST(l, TerminalExpr(l)[0], Vh) - ast_l = parse(ast_l.expr, settings={'dim':2,'nderiv':1,'mapping':M,'target':domain.logical_domain}) + ast_l = parse(ast_l.expr, settings={'dim':2, 'nderiv':1, 'mapping':M, 'target':domain.logical_domain}) print(pycode(ast_l)) print('==============================================================================================================') ast_l2norm = AST(l2norm, TerminalExpr(l2norm)[0], Vh) - ast_l2norm = parse(ast_l2norm.expr, settings={'dim':2,'nderiv':1,'mapping':M, 'target':domain.logical_domain}) + ast_l2norm = parse(ast_l2norm.expr, settings={'dim':2, 'nderiv':1, 'mapping':M, 'target':domain.logical_domain}) print(pycode(ast_l2norm)) -test_codegen() +test_codegen() diff --git a/psydac/api/ast/tests/system_1.py b/psydac/api/ast/tests/system_1.py index 5789e625f..8f9433b1c 100644 --- a/psydac/api/ast/tests/system_1.py +++ b/psydac/api/ast/tests/system_1.py @@ -1,4 +1,5 @@ # -*- coding: UTF-8 -*- +import os from sympy import pi, sin, Tuple, Matrix @@ -10,8 +11,7 @@ from sympde.expr import integral from sympde.expr import LinearForm from sympde.expr import BilinearForm -from sympde.expr import Norm - +from sympde.expr import Norm, SemiNorm from sympde.expr.evaluation import TerminalExpr from psydac.api.ast.fem import AST @@ -20,7 +20,6 @@ from psydac.api.printing.pycode import pycode -import os # ... try: mesh_dir = os.environ['PSYDAC_MESH_DIR'] @@ -39,7 +38,7 @@ def test_codegen(): x,y = domain.coordinates - f = Tuple(2*pi**2*sin(pi*x)*sin(pi*y), + f = Tuple(2*pi**2*sin(pi*x)*sin(pi*y), 2*pi**2*sin(pi*x)*sin(pi*y)) Fe = Tuple(sin(pi*x)*sin(pi*y), sin(pi*x)*sin(pi*y)) @@ -50,12 +49,12 @@ def test_codegen(): int_0 = lambda expr: integral(domain , expr) - b = BilinearForm((u,v), int_0(inner(grad(v), grad(u)))) + b = BilinearForm((u, v), int_0(inner(grad(v), grad(u)))) l = LinearForm(v, int_0(dot(f, v))) error = Matrix([F[0]-Fe[0], F[1]-Fe[1]]) - l2norm_F = Norm(error, domain, kind='l2') - h1norm_F = Norm(error, domain, kind='h1') + l2norm_F = Norm(error, domain, kind='l2') + h1norm_F = SemiNorm(error, domain, kind='h1') # Create computational domain from topological domain domain_h = discretize(domain, filename=filename) @@ -64,17 +63,16 @@ def test_codegen(): Vh = discretize(V, domain_h) print('============================================BilinearForm=========================================') - ast_b = AST(b, TerminalExpr(b)[0], [Vh, Vh]) - stmt_b = parse(ast_b.expr, settings={'dim':2,'nderiv':1, 'mapping':Vh.symbolic_mapping}) + ast_b = AST(b, TerminalExpr(b)[0], [Vh, Vh]) + stmt_b = parse(ast_b.expr, settings={'dim':2, 'nderiv':1, 'mapping':Vh.symbolic_mapping}) print(pycode(stmt_b)) print('============================================LinearForm===========================================') - ast_l = AST(l, TerminalExpr(l)[0], Vh) - stmt_l = parse(ast_l.expr, settings={'dim':2,'nderiv':1, 'mapping':Vh.symbolic_mapping}) + ast_l = AST(l, TerminalExpr(l)[0], Vh) + stmt_l = parse(ast_l.expr, settings={'dim':2, 'nderiv':1, 'mapping':Vh.symbolic_mapping}) print(pycode(stmt_l)) - print('============================================Norm===========================================') + print('============================================SemiNorm===========================================') ast_norm = AST(h1norm_F, TerminalExpr(h1norm_F)[0], Vh) - stmt_n = parse(ast_norm.expr, settings={'dim':2,'nderiv':1, 'mapping':Vh.symbolic_mapping}) + stmt_n = parse(ast_norm.expr, settings={'dim':2, 'nderiv':1, 'mapping':Vh.symbolic_mapping}) print(pycode(stmt_n)) - diff --git a/psydac/api/discretization.py b/psydac/api/discretization.py index accb814c0..e097d4621 100644 --- a/psydac/api/discretization.py +++ b/psydac/api/discretization.py @@ -3,6 +3,7 @@ # TODO: - init_fem is called whenever we call discretize. we should check that # nderiv has not been changed. shall we add nquads too? import os + from sympy import Expr as sym_Expr import numpy as np @@ -11,7 +12,7 @@ from sympde.expr import LinearForm as sym_LinearForm from sympde.expr import Functional as sym_Functional from sympde.expr import Equation as sym_Equation -from sympde.expr import Norm as sym_Norm +from sympde.expr import Norm as sym_Norm, SemiNorm as sym_SemiNorm from sympde.expr import TerminalExpr from sympde.topology import BasicFunctionSpace @@ -39,9 +40,8 @@ from psydac.fem.vector import ProductFemSpace, VectorFemSpace from psydac.cad.geometry import Geometry from psydac.mapping.discrete import NurbsMapping - -from psydac.linalg.stencil import StencilVectorSpace -from psydac.linalg.block import BlockVectorSpace +from psydac.linalg.stencil import StencilVectorSpace +from psydac.linalg.block import BlockVectorSpace __all__ = ('discretize', 'discretize_derham', 'reduce_space_degrees', 'discretize_space', 'discretize_domain') @@ -445,7 +445,7 @@ def discretize(a, *args, **kwargs): kwargs['symbolic_mapping'] = mapping if isinstance(a, sym_BasicForm): - if isinstance(a, sym_Norm): + if isinstance(a, (sym_Norm, sym_SemiNorm)): kernel_expr = TerminalExpr(a, domain) if not mapping is None: kernel_expr = tuple(LogicalExpr(i, domain) for i in kernel_expr) diff --git a/psydac/api/fem.py b/psydac/api/fem.py index 8cb856a55..098b80904 100644 --- a/psydac/api/fem.py +++ b/psydac/api/fem.py @@ -10,6 +10,7 @@ from sympde.expr import LinearForm as sym_LinearForm from sympde.expr import Functional as sym_Functional from sympde.expr import Norm as sym_Norm +from sympde.expr import SemiNorm as sym_SemiNorm from sympde.topology import Boundary, Interface from sympde.topology import VectorFunctionSpace from sympde.topology import ProductSpace @@ -1525,7 +1526,7 @@ def assemble(self, **kwargs): Example -------------- - n = Norm(1.0j*v, domain, kind='l2') + n = SemiNorm(1.0j*v, domain, kind='l2') nh = discretize(n, domain_h, Vh , **kwargs) fh = FemField(Vh) fh.coeffs[:] = 1 @@ -1555,7 +1556,7 @@ def assemble(self, **kwargs): args += (v, ) v = self._func(*args) - if isinstance(self.expr, sym_Norm): + if isinstance(self.expr, (sym_Norm, sym_SemiNorm)): if not( self.comm is None ): v = self.comm.allreduce(sendobj=v) diff --git a/psydac/api/tests/test_2d_biharmonic.py b/psydac/api/tests/test_2d_biharmonic.py index fe259a06f..7a15bd7c3 100644 --- a/psydac/api/tests/test_2d_biharmonic.py +++ b/psydac/api/tests/test_2d_biharmonic.py @@ -13,7 +13,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -74,9 +74,9 @@ def run_biharmonic_2d_dir(solution, f, dir_zero_boundary, ncells, degree, backen # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') - h2norm = Norm(error, domain, kind='h2') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') + h2norm = SemiNorm(error, domain, kind='h2') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_complex.py b/psydac/api/tests/test_2d_complex.py index e678471c4..57e6a37db 100644 --- a/psydac/api/tests/test_2d_complex.py +++ b/psydac/api/tests/test_2d_complex.py @@ -17,7 +17,7 @@ from sympde.topology import Domain, Square from sympde.topology import IdentityMapping, AffineMapping, PolarMapping from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -87,9 +87,9 @@ def run_biharmonic_2d_dir(solution, f, dir_zero_boundary, ncells=None, degree=No # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') - h2norm = Norm(error, domain, kind='h2') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') + h2norm = SemiNorm(error, domain, kind='h2') #+++++++++++++++++++++++++++++++ # 2. Discretization @@ -170,8 +170,8 @@ def run_poisson_2d(solution, f, domain, ncells=None, degree=None, filename=None, equation = find(u, forall=v, lhs=1j*a(u,v), rhs=1j*l(v), bc=bc) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization @@ -223,8 +223,8 @@ def run_helmholtz_2d(solution, kappa, e_w_0, dx_e_w_0, domain, ncells=None, degr equation = find(u, forall=v, lhs=a(u,v), rhs=l(v)) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_laplace.py b/psydac/api/tests/test_2d_laplace.py index b59cdcc1d..1a7b781e3 100644 --- a/psydac/api/tests/test_2d_laplace.py +++ b/psydac/api/tests/test_2d_laplace.py @@ -13,7 +13,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -78,8 +78,8 @@ def run_laplace_2d(solution, f, dir_zero_boundary, dir_nonzero_boundary, # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_mapping_biharmonic.py b/psydac/api/tests/test_2d_mapping_biharmonic.py index cb5e9ebae..cd4df2c3e 100644 --- a/psydac/api/tests/test_2d_mapping_biharmonic.py +++ b/psydac/api/tests/test_2d_mapping_biharmonic.py @@ -29,7 +29,7 @@ from sympde.topology import Domain,Square from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -100,9 +100,9 @@ def run_biharmonic_2d_dir(filename, solution, f, dir_zero_boundary, # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') - h2norm = Norm(error, domain, kind='h2') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') + h2norm = SemiNorm(error, domain, kind='h2') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_mapping_laplace.py b/psydac/api/tests/test_2d_mapping_laplace.py index 7b0b3d529..616bcf6b6 100644 --- a/psydac/api/tests/test_2d_mapping_laplace.py +++ b/psydac/api/tests/test_2d_mapping_laplace.py @@ -29,7 +29,7 @@ from sympde.topology import Domain,Square from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -101,8 +101,8 @@ def run_laplace_2d(filename, solution, f, dir_zero_boundary, # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_mapping_poisson.py b/psydac/api/tests/test_2d_mapping_poisson.py index ed9f3c0a6..ab734f451 100644 --- a/psydac/api/tests/test_2d_mapping_poisson.py +++ b/psydac/api/tests/test_2d_mapping_poisson.py @@ -29,7 +29,7 @@ from sympde.topology import Domain from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -106,8 +106,8 @@ def run_poisson_2d(filename, solution, f, dir_zero_boundary, # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_multipatch_mapping_poisson.py b/psydac/api/tests/test_2d_multipatch_mapping_poisson.py index 5b32bd1fa..1c9677e2d 100644 --- a/psydac/api/tests/test_2d_multipatch_mapping_poisson.py +++ b/psydac/api/tests/test_2d_multipatch_mapping_poisson.py @@ -16,7 +16,7 @@ from sympde.topology import IdentityMapping, PolarMapping, AffineMapping from sympde.expr.expr import LinearForm, BilinearForm from sympde.expr.expr import integral -from sympde.expr.expr import Norm +from sympde.expr.expr import Norm, SemiNorm from sympde.expr.equation import find, EssentialBC from psydac.api.discretization import discretize @@ -76,8 +76,8 @@ def run_poisson_2d(solution, f, domain, ncells=None, degree=None, filename=None, equation = find(u, forall=v, lhs=a(u,v), rhs=l(v)) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_multipatch_poisson.py b/psydac/api/tests/test_2d_multipatch_poisson.py index d8b276403..2ecf457ac 100644 --- a/psydac/api/tests/test_2d_multipatch_poisson.py +++ b/psydac/api/tests/test_2d_multipatch_poisson.py @@ -11,7 +11,7 @@ from sympde.topology import IdentityMapping, AffineMapping from sympde.expr.expr import LinearForm, BilinearForm from sympde.expr.expr import integral -from sympde.expr.expr import Norm +from sympde.expr.expr import Norm, SemiNorm from sympde.expr.equation import find, EssentialBC from psydac.api.discretization import discretize @@ -53,8 +53,8 @@ def run_poisson_2d(solution, f, domain, ncells, degree): equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_2d_navier_stokes.py b/psydac/api/tests/test_2d_navier_stokes.py index 296caf612..992b9dbdc 100644 --- a/psydac/api/tests/test_2d_navier_stokes.py +++ b/psydac/api/tests/test_2d_navier_stokes.py @@ -126,7 +126,7 @@ def run_time_dependent_navier_stokes_2d(filename, dt_h, nt, newton_tol=1e-4, max # Define (abstract) norms l2norm_du = Norm(Matrix([du[0],du[1]]), domain, kind='l2') - l2norm_dp = Norm(dp , domain, kind='l2') + l2norm_dp = Norm(dp, domain, kind='l2') # ... create the computational domain from a topological domain domain_h = discretize(domain, filename=filename) @@ -262,11 +262,11 @@ def run_steady_state_navier_stokes_2d(domain, f, ue, pe, *, ncells, degree, mult equation = find((du, dp), forall=(v, q), lhs=a((du, dp), (v, q)), rhs=l(v, q), bc=bc) # Define (abstract) norms - l2norm_u = Norm(Matrix([u[0]-ue[0],u[1]-ue[1]]), domain, kind='l2') - l2norm_p = Norm(p-pe , domain, kind='l2') + l2norm_u = Norm(Matrix([u[0]-ue[0], u[1]-ue[1]]), domain, kind='l2') + l2norm_p = Norm(p - pe, domain, kind='l2') l2norm_du = Norm(Matrix([du[0],du[1]]), domain, kind='l2') - l2norm_dp = Norm(dp , domain, kind='l2') + l2norm_dp = Norm(dp, domain, kind='l2') # ... create the computational domain from a topological domain domain_h = discretize(domain, ncells=ncells, comm=comm) diff --git a/psydac/api/tests/test_2d_poisson.py b/psydac/api/tests/test_2d_poisson.py index 100db499f..ec3afd18a 100644 --- a/psydac/api/tests/test_2d_poisson.py +++ b/psydac/api/tests/test_2d_poisson.py @@ -13,7 +13,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -83,8 +83,8 @@ def run_poisson_2d(solution, f, dir_zero_boundary, dir_nonzero_boundary, # Error norms error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_api_2d_fields.py b/psydac/api/tests/test_api_2d_fields.py index 54c0989f2..9946af354 100644 --- a/psydac/api/tests/test_api_2d_fields.py +++ b/psydac/api/tests/test_api_2d_fields.py @@ -355,4 +355,4 @@ def teardown_module(): def teardown_function(): from sympy.core import cache - cache.clear_cache() \ No newline at end of file + cache.clear_cache() 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 4da037c3b..98efa61f7 100644 --- a/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py +++ b/psydac/api/tests/test_api_2d_scalar_analytical_mapping.py @@ -8,7 +8,7 @@ from sympde.topology import PolarMapping from sympde.expr.expr import LinearForm, BilinearForm from sympde.expr.expr import integral -from sympde.expr.expr import Norm +from sympde.expr.expr import Norm, SemiNorm from sympde.expr.equation import find, EssentialBC from psydac.api.discretization import discretize @@ -33,8 +33,8 @@ def run_poisson_2d(solution, f, domain, ncells, degree, comm=None): equation = find(u, forall=v, lhs=a(u,v), rhs=l(v), bc=bc) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') #+++++++++++++++++++++++++++++++ # 2. Discretization diff --git a/psydac/api/tests/test_api_2d_system.py b/psydac/api/tests/test_api_2d_system.py index c98043125..a1bc48c38 100644 --- a/psydac/api/tests/test_api_2d_system.py +++ b/psydac/api/tests/test_api_2d_system.py @@ -11,7 +11,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.fem.basic import FemField @@ -49,12 +49,12 @@ def run_system_1_2d_dir(Fe, Ge, f0, f1, ncells, degree): l = LinearForm((v,q), l0(v) + l1(q)) error = Matrix([F[0]-Fe[0], F[1]-Fe[1]]) - l2norm_F = Norm(error, domain, kind='l2') - h1norm_F = Norm(error, domain, kind='h1') + l2norm_F = Norm(error, domain, kind='l2') + h1norm_F = SemiNorm(error, domain, kind='h1') error = G-Ge - l2norm_G = Norm(error, domain, kind='l2') - h1norm_G = Norm(error, domain, kind='h1') + l2norm_G = Norm(error, domain, kind='l2') + h1norm_G = SemiNorm(error, domain, kind='h1') bc = EssentialBC(u, 0, domain.boundary) equation = find([u,p], forall=[v,q], lhs=a((u,p),(v,q)), rhs=l(v,q), bc=bc) diff --git a/psydac/api/tests/test_api_2d_vector.py b/psydac/api/tests/test_api_2d_vector.py index 6f9e1163c..7b8449b87 100644 --- a/psydac/api/tests/test_api_2d_vector.py +++ b/psydac/api/tests/test_api_2d_vector.py @@ -8,7 +8,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -35,8 +35,8 @@ def run_vector_poisson_2d_dir(solution, f, ncells, degree): l = LinearForm(v, int_0(expr)) error = Matrix([u[0]-solution[0], u[1]-solution[1]]) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) diff --git a/psydac/api/tests/test_api_2d_vector_mapping.py b/psydac/api/tests/test_api_2d_vector_mapping.py index 34deebe40..69c308cfb 100644 --- a/psydac/api/tests/test_api_2d_vector_mapping.py +++ b/psydac/api/tests/test_api_2d_vector_mapping.py @@ -10,7 +10,7 @@ from sympde.topology import Domain from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -47,8 +47,8 @@ def run_vector_poisson_2d_dir(filename, solution, f): l = LinearForm(v, int_0(expr)) error = Matrix([u[0]-solution[0], u[1]-solution[1]]) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) 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 d35b1bc2e..5188de2a7 100644 --- a/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py +++ b/psydac/api/tests/test_api_2d_vector_multipatch_mapping.py @@ -10,7 +10,7 @@ from sympde.topology import Domain from sympde.topology import Union from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from sympde.calculus import minus, plus @@ -62,8 +62,8 @@ def run_vector_poisson_2d_dir(filename, solution, f): l = LinearForm(v, int_0(expr)) error = Matrix([0, u[1]-solution[1]]) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) diff --git a/psydac/api/tests/test_api_3d_scalar.py b/psydac/api/tests/test_api_3d_scalar.py index 4394fa50e..6760b4352 100644 --- a/psydac/api/tests/test_api_3d_scalar.py +++ b/psydac/api/tests/test_api_3d_scalar.py @@ -11,7 +11,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -38,8 +38,8 @@ def run_poisson_3d_dir(solution, f, ncells, degree, comm=None): l = LinearForm(v, int_0(expr)) error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) @@ -113,8 +113,8 @@ def run_poisson_3d_dirneu(solution, f, boundary, ncells, degree, comm=None): l = LinearForm(v, expr) error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') B_dirichlet = domain.boundary.complement(B_neumann) bc = EssentialBC(u, 0, B_dirichlet) diff --git a/psydac/api/tests/test_api_3d_scalar_mapping.py b/psydac/api/tests/test_api_3d_scalar_mapping.py index 708ca4e56..2aa9e9219 100644 --- a/psydac/api/tests/test_api_3d_scalar_mapping.py +++ b/psydac/api/tests/test_api_3d_scalar_mapping.py @@ -12,7 +12,7 @@ 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 Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -49,8 +49,8 @@ def run_poisson_3d_dir(filename, solution, f, comm=None): l = LinearForm(v, int_0(expr)) error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) @@ -124,8 +124,8 @@ def run_poisson_3d_dirneu(filename, solution, f, boundary, comm=None): l = LinearForm(v, expr) error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') B_dirichlet = domain.boundary.complement(B_neumann) bc = EssentialBC(u, 0, B_dirichlet) @@ -196,8 +196,8 @@ def run_laplace_3d_neu(filename, solution, f, comm=None): l = LinearForm(v, expr) error = u - solution - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + l2norm = Norm(error, domain, kind='l2') + h1norm = SemiNorm(error, domain, kind='h1') equation = find(u, forall=v, lhs=a(u,v), rhs=l(v)) # ... diff --git a/psydac/api/tests/test_api_3d_vector.py b/psydac/api/tests/test_api_3d_vector.py index 92470862d..f2171a37d 100644 --- a/psydac/api/tests/test_api_3d_vector.py +++ b/psydac/api/tests/test_api_3d_vector.py @@ -8,7 +8,7 @@ from sympde.topology import element_of from sympde.topology import Cube from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -35,8 +35,8 @@ def run_vector_poisson_3d_dir(solution, f, ncells, degree): l = LinearForm(v, int_0(expr)) error = Matrix([u[0]-solution[0], u[1]-solution[1], u[2]-solution[2]]) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) diff --git a/psydac/api/tests/test_api_3d_vector_mapping.py b/psydac/api/tests/test_api_3d_vector_mapping.py index b3b04a0b3..706070e28 100644 --- a/psydac/api/tests/test_api_3d_vector_mapping.py +++ b/psydac/api/tests/test_api_3d_vector_mapping.py @@ -9,7 +9,7 @@ from sympde.topology import element_of from sympde.topology import Domain from sympde.expr import BilinearForm, LinearForm, integral -from sympde.expr import Norm +from sympde.expr import Norm, SemiNorm from sympde.expr import find, EssentialBC from psydac.api.discretization import discretize @@ -46,8 +46,8 @@ def run_vector_poisson_3d_dir(filename, solution, f): l = LinearForm(v, int_0(expr)) error = Matrix([u[0]-solution[0], u[1]-solution[1], u[2]-solution[2]]) - l2norm = Norm(error, domain, kind='l2') - h1norm = Norm(error, domain, kind='h1') + 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) diff --git a/psydac/api/tests/test_assembly.py b/psydac/api/tests/test_assembly.py index 6891b2e66..9a87516a8 100644 --- a/psydac/api/tests/test_assembly.py +++ b/psydac/api/tests/test_assembly.py @@ -294,7 +294,7 @@ def test_assemble_complex_parallel(backend): ar = BilinearForm((u, v), integral(domain, gr * u * v)) lc = LinearForm(v, integral(domain, gc * v)) lr = LinearForm(v, integral(domain, gr * v)) - nr = Norm(1.0*v, domain, kind='l2') + nr = Norm(1.0 *v, domain, kind='l2') nc = Norm(1.0j*v, domain, kind='l2') ncells = (5, 5) diff --git a/pyproject.toml b/pyproject.toml index 50b051a68..b68b6f592 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ 'pyevtk', # Our packages from PyPi - 'sympde == 0.18.0', + 'sympde == 0.18.1', 'pyccel == 1.8.1', 'gelato == 0.12',