Open e-moral-sanchez opened 2 weeks ago
Can you please share the generated Python code in the __psydac__
directory?
The file dependencies_hcvpx9db.py
in __psydac__
directory is:
# Not supported in Python:
# re
def assemble_vector_hcvpx9db(global_test_basis_v_0_1 : "float64[:,:,:,:]", global_test_basis_v_0_2 : "float64[:,:,:,:]", global_test_basis_v_0_3 : "float64[:,:,:,:]", global_test_basis_v_1_1 : "float64[:,:,:,:]", global_test_basis_v_1_2 : "float64[:,:,:,:]", global_test_basis_v_1_3 : "float64[:,:,:,:]", global_test_basis_v_2_1 : "float64[:,:,:,:]", global_test_basis_v_2_2 : "float64[:,:,:,:]", global_test_basis_v_2_3 : "float64[:,:,:,:]", global_span_v_0_1 : "int64[:]", global_span_v_0_2 : "int64[:]", global_span_v_0_3 : "int64[:]", global_span_v_1_1 : "int64[:]", global_span_v_1_2 : "int64[:]", global_span_v_1_3 : "int64[:]", global_span_v_2_1 : "int64[:]", global_span_v_2_2 : "int64[:]", global_span_v_2_3 : "int64[:]", global_x1 : "float64[:,:]", global_x2 : "float64[:,:]", global_x3 : "float64[:,:]", test_v_0_p1 : "int64", test_v_0_p2 : "int64", test_v_0_p3 : "int64", test_v_1_p1 : "int64", test_v_1_p2 : "int64", test_v_1_p3 : "int64", test_v_2_p1 : "int64", test_v_2_p2 : "int64", test_v_2_p3 : "int64", n_element_1 : "int64", n_element_2 : "int64", n_element_3 : "int64", k1 : "int64", k2 : "int64", k3 : "int64", pad1 : "int64", pad2 : "int64", pad3 : "int64", g_vec_v_2_hcvpx9db : "complex[:,:,:]"):
from numpy import array, zeros, zeros_like, floor
local_x1 = zeros_like(global_x1[0,:])
local_x2 = zeros_like(global_x2[0,:])
local_x3 = zeros_like(global_x3[0,:])
l_vec_v_2_hcvpx9db = zeros((2, 2, 1), dtype='complex')
for i_element_1 in range(0, n_element_1, 1):
local_x1[:] = global_x1[i_element_1,:]
span_v_0_1 = global_span_v_0_1[i_element_1]
span_v_1_1 = global_span_v_1_1[i_element_1]
span_v_2_1 = global_span_v_2_1[i_element_1]
for i_element_2 in range(0, n_element_2, 1):
local_x2[:] = global_x2[i_element_2,:]
span_v_0_2 = global_span_v_0_2[i_element_2]
span_v_1_2 = global_span_v_1_2[i_element_2]
span_v_2_2 = global_span_v_2_2[i_element_2]
for i_element_3 in range(0, n_element_3, 1):
local_x3[:] = global_x3[i_element_3,:]
span_v_0_3 = global_span_v_0_3[i_element_3]
span_v_1_3 = global_span_v_1_3[i_element_3]
span_v_2_3 = global_span_v_2_3[i_element_3]
for i_basis_1 in range(0, 1 + test_v_2_p1, 1):
for i_basis_2 in range(0, 1 + test_v_2_p2, 1):
for i_basis_3 in range(0, 1 + test_v_2_p3, 1):
contribution_v_2_hcvpx9db = 0j
for i_quad_1 in range(0, 2, 1):
x1 = local_x1[i_quad_1]
v_2_1 = global_test_basis_v_2_1[i_element_1,i_basis_1,0,i_quad_1]
v_2_1_x1 = global_test_basis_v_2_1[i_element_1,i_basis_1,1,i_quad_1]
for i_quad_2 in range(0, 2, 1):
x2 = local_x2[i_quad_2]
v_2_2 = global_test_basis_v_2_2[i_element_2,i_basis_2,0,i_quad_2]
v_2_2_x2 = global_test_basis_v_2_2[i_element_2,i_basis_2,1,i_quad_2]
for i_quad_3 in range(0, 2, 1):
x3 = local_x3[i_quad_3]
v_2_3 = global_test_basis_v_2_3[i_element_3,i_basis_3,0,i_quad_3]
v_2_3_x3 = global_test_basis_v_2_3[i_element_3,i_basis_3,1,i_quad_3]
v_2 = v_2_1*v_2_2*v_2_3
v_2_x3 = v_2_1*v_2_2*v_2_3_x3
v_2_x2 = v_2_1*v_2_2_x2*v_2_3
v_2_x1 = v_2_1_x1*v_2_2*v_2_3
contribution_v_2_hcvpx9db += v_2*re(x2)
l_vec_v_2_hcvpx9db[i_basis_1,i_basis_2,i_basis_3] = contribution_v_2_hcvpx9db
g_vec_v_2_hcvpx9db[pad1 + span_v_2_1 - test_v_2_p1:1 + pad1 + span_v_2_1,pad2 + span_v_2_2 - test_v_2_p2:1 + pad2 + span_v_2_2,pad3 + span_v_2_3 - test_v_2_p3:1 + pad3 + span_v_2_3] += l_vec_v_2_hcvpx9db[:,:,:]
return
Indeed, it appears that Psydac does not know how to map SymPy's re
function to the method .real
which is native for Python scalar numeric types, and also available in NumPy arrays.
In other words, re(x2)
should be replaced with x2.real
in the code snippet above.
The generated code does not work well when using
Sympy
functionsre
andim
. There are two issues:re
andim
.Minimal example that crashes:
Error: