Skip to content

Commit

Permalink
up test discr tests for mDot #2139
Browse files Browse the repository at this point in the history
add header to stl for conversion

test not passing yet
/cc @prudhomm

[ci skip]
  • Loading branch information
thomas-saigre committed Jul 17, 2023
1 parent 2d63c33 commit b75c52b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/pyfeelpp/feelpp/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def download(data,worldComm):
"""Download remote data file"""
rd = RemoteData(data,worldComm)
if rd.canDownload():
d=Environment.downloadsRepository()
d = Environment.downloadsRepository()
return rd.download( d )
else:
raise RuntimeError("Remote Data " + data + " cannot be downloaded")
Expand Down Expand Up @@ -174,10 +174,10 @@ def functionSpace( mesh, space="Pch", order=1, worldscomm=None):
"""create a function space
"""
if worldscomm is None:
worldscomm=Environment.worldsComm(1)
key="{}({},{},{})".format(space,mesh.dimension(),order,mesh.order())
worldscomm = Environment.worldsComm(1)
key = "{}({},{},{})".format(space, mesh.dimension(), order, mesh.order())
if key not in _spaces:
raise RuntimeError('FunctionSpace '+key+' not existing in dictionary')
raise RuntimeError(f'FunctionSpace {key} not existing in dictionary')
return _spaces[key]( mesh=mesh, worldsComm=worldscomm )


Expand Down
1 change: 1 addition & 0 deletions python/pyfeelpp/feelpp/discr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <feel/feelpython/pybind11/pybind11.h>
#include <feel/feelpython/pybind11/eigen.h>
#include <feel/feelpython/pybind11/stl_bind.h>
#include <feel/feelpython/pybind11/stl.h>
#include <feel/feeldiscr/pch.hpp>
#include <feel/feeldiscr/pchv.hpp>
#include <feel/feeldiscr/pdh.hpp>
Expand Down
42 changes: 42 additions & 0 deletions python/pyfeelpp/tests/test_discr.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,42 @@ def run_element(m, geo):
print("norm(vv_petsc-v_petsc)={}, vv.l2={}, v.l2={}".format(l2_w, vv.l2Norm(), v.l2Norm()))
assert abs(l2_w) < 1e-12

def run_element_alg(m, geo):
mesh_name, dim, e_meas, e_s_1, e_s_2, e_s_bdy=geo

m2d = feelpp.load(m, mesh_name, 0.1)

Xh = feelpp.functionSpace(mesh=m2d)

if feelpp.Environment.isMasterRank():
print("Xh basisname: ", Xh.basisName())
print("Xh nDof: ", Xh.nDof())
print("Xh nLocalDof: ", Xh.nLocalDof())
print("Xh nLocalDofWithGhost: ", Xh.nLocalDofWithGhost())
print("Xh nLocalDofWithoutGhost: ", Xh.nLocalDofWithoutGhost())

m3 = Xh.mesh()

assert m3 == m2d

b = feelpp.backend(worldcomm=feelpp.Environment.worldCommPtr())
v = b.newVector(dm=Xh.mapPtr())

# test constant
v.setConstant(1.0)
# create u which use the same memory storage as v
u = Xh.element(v)

us = Xh.newVectors(3)
for ui in us:
ui.setConstant(1.0)

r = u.mDot(us)
assert r.shape == (3,)
for i in range(3):
assert( r[i] == us[i].sum() )


geo_cases=[(2, feelpp.create_rectangle),
(3, feelpp.create_box)]

Expand All @@ -143,3 +179,9 @@ def test_element(dim,geo,init_feelpp):
feelpp.Environment.changeRepository(
directory="pyfeelpp-tests/discr/test_{}d_element".format(dim))
run_element( feelpp.mesh(dim=dim, realdim=dim), geo(filename="boxelement" if dim==3 else "rectelement") )

@pytest.mark.parametrize("dim,geo", geo_cases)
def test_element_alg(dim, geo, init_feelpp):
feelpp.Environment.changeRepository(
directory="pyfeelpp-tests/discr/test_{}d_element".format(dim))
run_element_alg( feelpp.mesh(dim=dim, realdim=dim), geo(filename="boxelement" if dim==3 else "rectelement") )

0 comments on commit b75c52b

Please sign in to comment.