Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
os.path.join(file_dir, "test-qfunctions.h:setup_mass_2d"))
qf_setup_tet.add_input("weights", 1, libceed.EVAL_WEIGHT)
qf_setup_tet.add_input("dx", dim*dim, libceed.EVAL_GRAD)
qf_setup_tet.add_output("rho", 1, libceed.EVAL_NONE)
qf_mass_tet = ceed.QFunction(1, qfs.apply_mass,
os.path.join(file_dir, "test-qfunctions.h:apply_mass"))
qf_mass_tet.add_input("rho", 1, libceed.EVAL_NONE)
qf_mass_tet.add_input("u", 1, libceed.EVAL_INTERP)
qf_mass_tet.add_output("v", 1, libceed.EVAL_INTERP)
# Operators
op_setup_tet = ceed.Operator(qf_setup_tet)
op_setup_tet.set_field("weights", rxi_tet, bx_tet, libceed.VECTOR_NONE)
op_setup_tet.set_field("dx", rx_tet, bx_tet, libceed.VECTOR_ACTIVE)
op_setup_tet.set_field("rho", rui_tet, libceed.BASIS_COLLOCATED,
qdata_tet)
op_mass_tet = ceed.Operator(qf_mass_tet)
op_mass_tet.set_field("rho", rui_tet, libceed.BASIS_COLLOCATED, qdata_tet)
op_mass_tet.set_field("u", ru_tet, bu_tet, libceed.VECTOR_ACTIVE)
op_mass_tet.set_field("v", ru_tet, bu_tet, libceed.VECTOR_ACTIVE)
## ------------------------- Hex Elements -------------------------
# Restrictions
indx_hex = np.zeros(nelem_hex*p_hex*p_hex, dtype="int32")
for i in range(nelem_hex):
col = i % nx_hex;
row = i // nx_hex;
offset = (nx_tet*2+1)*(ny_tet*2)*(1+row)+col*2
os.path.join(file_dir, "test-qfunctions.h:setup_mass"))
qf_setup.add_input("weights", 1, libceed.EVAL_WEIGHT)
qf_setup.add_input("dx", 1, libceed.EVAL_GRAD)
qf_setup.add_output("rho", 1, libceed.EVAL_NONE)
qf_mass = ceed.QFunction(1, qfs.apply_mass,
os.path.join(file_dir, "test-qfunctions.h:apply_mass"))
qf_mass.add_input("rho", 1, libceed.EVAL_NONE)
qf_mass.add_input("u", 1, libceed.EVAL_INTERP)
qf_mass.add_output("v", 1, libceed.EVAL_INTERP)
# Operators
op_setup = ceed.Operator(qf_setup)
op_setup.set_field("weights", rxi, bx, libceed.VECTOR_NONE)
op_setup.set_field("dx", rx, bx, libceed.VECTOR_ACTIVE)
op_setup.set_field("rho", rui, libceed.BASIS_COLLOCATED,
libceed.VECTOR_ACTIVE)
op_mass = ceed.Operator(qf_mass)
op_mass.set_field("rho", rui, libceed.BASIS_COLLOCATED, qdata)
op_mass.set_field("u", ru, bu, libceed.VECTOR_ACTIVE)
op_mass.set_field("v", ru, bu, libceed.VECTOR_ACTIVE)
# Setup
op_setup.apply(x, qdata)
# Apply mass matrix
u.set_value(0)
op_mass.apply(u, v)
# Check
v_array = v.get_array_read()