Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_402(ceed_resource, capsys):
ceed = libceed.Ceed(ceed_resource)
file_dir = os.path.dirname(os.path.abspath(__file__))
qfs = load_qfs_so()
qf_setup = ceed.QFunction(1, qfs.setup_mass,
os.path.join(file_dir, "test-qfunctions.h:setup_mass"))
qf_setup.add_input("w", 1, libceed.EVAL_WEIGHT)
qf_setup.add_input("dx", 1, libceed.EVAL_GRAD)
qf_setup.add_output("qdata", 1, libceed.EVAL_NONE)
qf_mass = ceed.QFunction(1, qfs.apply_mass,
os.path.join(file_dir, "t400-qfunction.h:apply_mass"))
qf_mass.add_input("qdata", 1, libceed.EVAL_NONE)
qf_mass.add_input("u", 1, libceed.EVAL_INTERP)
qf_mass.add_output("v", 1, libceed.EVAL_INTERP)
print(qf_setup)
print(qf_mass)
stdout, stderr = capsys.readouterr()
with open(os.path.abspath("./output/test_402.out")) as output_file:
true_output = output_file.read()
def test_400(ceed_resource):
ceed = libceed.Ceed(ceed_resource)
file_dir = os.path.dirname(os.path.abspath(__file__))
qfs = load_qfs_so()
qf_setup = ceed.QFunction(1, qfs.setup_mass,
os.path.join(file_dir, "test-qfunctions.h:setup_mass"))
qf_setup.add_input("w", 1, libceed.EVAL_WEIGHT)
qf_setup.add_input("dx", 1, libceed.EVAL_GRAD)
qf_setup.add_output("qdata", 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("qdata", 1, libceed.EVAL_NONE)
qf_mass.add_input("u", 1, libceed.EVAL_INTERP)
qf_mass.add_output("v", 1, libceed.EVAL_INTERP)
q = 8
w_array = np.zeros(q, dtype="float64")
u_array = np.zeros(q, dtype="float64")
v_true = np.zeros(q, dtype="float64")
for i in range(q):
x = 2.*i/(q-1) - 1
for j in range(p):
indu[p*i+j] = i*(p-1) + j
ru = ceed.ElemRestriction(nelem, p, nu, 2, indu, cmode=libceed.USE_POINTER)
rui = ceed.IdentityElemRestriction(nelem, q, q*nelem, 1)
# Bases
bx = ceed.BasisTensorH1Lagrange(1, 1, 2, q, libceed.GAUSS)
bu = ceed.BasisTensorH1Lagrange(1, 2, p, q, libceed.GAUSS)
# QFunctions
file_dir = os.path.dirname(os.path.abspath(__file__))
qfs = load_qfs_so()
qf_setup = ceed.QFunction(1, qfs.setup_mass,
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_two,
os.path.join(file_dir, "test-qfunctions.h:apply_mass_two"))
qf_mass.add_input("rho", 1, libceed.EVAL_NONE)
qf_mass.add_input("u", 2, libceed.EVAL_INTERP)
qf_mass.add_output("v", 2, 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)
for j in range(p):
indu[p*i+j] = i*(p-1) + j
ru = ceed.ElemRestriction(nelem, p, nu, 1, indu, cmode=libceed.USE_POINTER)
rui = ceed.IdentityElemRestriction(nelem, q, q*nelem, 1)
# Bases
bx = ceed.BasisTensorH1Lagrange(1, 1, 2, q, libceed.GAUSS)
bu = ceed.BasisTensorH1Lagrange(1, 1, p, q, libceed.GAUSS)
# QFunctions
file_dir = os.path.dirname(os.path.abspath(__file__))
qfs = load_qfs_so()
qf_setup = ceed.QFunction(1, qfs.setup_mass,
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)