/// @file /// Test assembly of mass and Poisson operator QFunction /// \test Test assembly of mass and Poisson operator QFunction #include #include #include #include "t532-operator.h" int main(int argc, char **argv) { Ceed ceed; CeedElemRestriction Erestrictx, Erestrictu, Erestrictui, Erestrictqi, Erestrictlini; CeedBasis bx, bu; CeedQFunction qf_setup_mass, qf_setup_diff, qf_apply, qf_apply_lin; CeedOperator op_setup_mass, op_setup_diff, op_apply, op_apply_lin; CeedVector qdata_mass, qdata_diff, X, A, u, v; CeedInt nelem = 6, P = 3, Q = 4, dim = 2; CeedInt nx = 3, ny = 2; CeedInt ndofs = (nx*2+1)*(ny*2+1), nqpts = nelem*Q*Q; CeedInt indx[nelem*P*P]; CeedScalar x[dim*ndofs]; CeedInit(argv[1], &ceed); // DoF Coordinates for (CeedInt i=0; i 1e-14) // LCOV_EXCL_START printf("Error: True operator computed area = %f != 1.0\n", area); // LCOV_EXCL_STOP // Assemble QFunction CeedOperatorLinearAssembleQFunction(op_apply, &A, &Erestrictlini, CEED_REQUEST_IMMEDIATE); // QFunction - apply assembled CeedQFunctionCreateInterior(ceed, 1, apply_lin, apply_lin_loc, &qf_apply_lin); CeedQFunctionAddInput(qf_apply_lin, "du", dim, CEED_EVAL_GRAD); CeedQFunctionAddInput(qf_apply_lin, "qdata", (dim+1)*(dim+1), CEED_EVAL_NONE); CeedQFunctionAddInput(qf_apply_lin, "u", 1, CEED_EVAL_INTERP); CeedQFunctionAddOutput(qf_apply_lin, "v", 1, CEED_EVAL_INTERP); CeedQFunctionAddOutput(qf_apply_lin, "dv", dim, CEED_EVAL_GRAD); // Operator - apply assembled CeedOperatorCreate(ceed, qf_apply_lin, CEED_QFUNCTION_NONE, CEED_QFUNCTION_NONE, &op_apply_lin); CeedOperatorSetField(op_apply_lin, "du", Erestrictu, bu, CEED_VECTOR_ACTIVE); CeedOperatorSetField(op_apply_lin, "qdata", Erestrictlini, CEED_BASIS_COLLOCATED, A); CeedOperatorSetField(op_apply_lin, "u", Erestrictu, bu, CEED_VECTOR_ACTIVE); CeedOperatorSetField(op_apply_lin, "v", Erestrictu, bu, CEED_VECTOR_ACTIVE); CeedOperatorSetField(op_apply_lin, "dv", Erestrictu, bu, CEED_VECTOR_ACTIVE); // Apply assembled QFunction operator CeedVectorSetValue(v, 0.0); CeedOperatorApply(op_apply_lin, u, v, CEED_REQUEST_IMMEDIATE); // Check output area = 0.0; CeedVectorGetArrayRead(v, CEED_MEM_HOST, &vv); for (CeedInt i=0; i 1e-14) // LCOV_EXCL_START printf("Error: Assembled operator computed area = %f != 1.0\n", area); // LCOV_EXCL_STOP // Cleanup CeedQFunctionDestroy(&qf_setup_mass); CeedQFunctionDestroy(&qf_setup_diff); CeedQFunctionDestroy(&qf_apply); CeedQFunctionDestroy(&qf_apply_lin); CeedOperatorDestroy(&op_setup_mass); CeedOperatorDestroy(&op_setup_diff); CeedOperatorDestroy(&op_apply); CeedOperatorDestroy(&op_apply_lin); CeedElemRestrictionDestroy(&Erestrictu); CeedElemRestrictionDestroy(&Erestrictx); CeedElemRestrictionDestroy(&Erestrictui); CeedElemRestrictionDestroy(&Erestrictqi); CeedElemRestrictionDestroy(&Erestrictlini); CeedBasisDestroy(&bu); CeedBasisDestroy(&bx); CeedVectorDestroy(&X); CeedVectorDestroy(&A); CeedVectorDestroy(&qdata_mass); CeedVectorDestroy(&qdata_diff); CeedVectorDestroy(&u); CeedVectorDestroy(&v); CeedDestroy(&ceed); return 0; }