/// @file /// Test creation, action, and destruction for mass matrix operator with multigrid level, tensor basis /// \test Test creation, action, and destruction for mass matrix operator with multigrid level, tensor basis #include #include #include #include "t502-operator.h" int main(int argc, char **argv) { Ceed ceed; CeedElemRestriction Erestrictx, Erestrictui, ErestrictuCoarse, ErestrictuFine; CeedBasis bx, bu; CeedQFunction qf_setup, qf_mass; CeedOperator op_setup, op_massCoarse, op_massFine, op_prolong, op_restrict; CeedVector qdata, X, Ucoarse, Ufine, Vcoarse, Vfine, PMultFine; const CeedScalar *hv; CeedInt nelem = 15, Pcoarse = 3, Pfine = 5, Q = 8, ncomp = 2; CeedInt Nx = nelem+1, NuCoarse = nelem*(Pcoarse-1)+1, NuFine = nelem*(Pfine-1)+1; CeedInt induCoarse[nelem*Pcoarse], induFine[nelem*Pfine], indx[nelem*2]; CeedScalar x[Nx]; CeedScalar sum; CeedInit(argv[1], &ceed); for (CeedInt i=0; i1e-10) // LCOV_EXCL_START printf("Computed Area Coarse Grid: %f != True Area: 1.0\n", sum); // LCOV_EXCL_STOP CeedVectorRestoreArrayRead(Vcoarse, &hv); // Prolong coarse u CeedVectorCreate(ceed, ncomp*NuFine, &Ufine); CeedOperatorApply(op_prolong, Ucoarse, Ufine, CEED_REQUEST_IMMEDIATE); // Fine problem CeedVectorCreate(ceed, ncomp*NuFine, &Vfine); CeedOperatorApply(op_massFine, Ufine, Vfine, CEED_REQUEST_IMMEDIATE); // Check output CeedVectorGetArrayRead(Vfine, CEED_MEM_HOST, &hv); sum = 0.; for (CeedInt i=0; i1e-10) // LCOV_EXCL_START printf("Computed Area Fine Grid: %f != True Area: 1.0\n", sum); // LCOV_EXCL_STOP CeedVectorRestoreArrayRead(Vfine, &hv); // Restrict state to coarse grid CeedOperatorApply(op_restrict, Vfine, Vcoarse, CEED_REQUEST_IMMEDIATE); // Check output CeedVectorGetArrayRead(Vcoarse, CEED_MEM_HOST, &hv); sum = 0.; for (CeedInt i=0; i1e-10) // LCOV_EXCL_START printf("Computed Area Coarse Grid: %f != True Area: 1.0\n", sum); // LCOV_EXCL_STOP CeedVectorRestoreArrayRead(Vcoarse, &hv); // Cleanup CeedQFunctionDestroy(&qf_setup); CeedQFunctionDestroy(&qf_mass); CeedOperatorDestroy(&op_setup); CeedOperatorDestroy(&op_massCoarse); CeedOperatorDestroy(&op_massFine); CeedOperatorDestroy(&op_prolong); CeedOperatorDestroy(&op_restrict); CeedElemRestrictionDestroy(&ErestrictuCoarse); CeedElemRestrictionDestroy(&ErestrictuFine); CeedElemRestrictionDestroy(&Erestrictx); CeedElemRestrictionDestroy(&Erestrictui); CeedBasisDestroy(&bu); CeedBasisDestroy(&bx); CeedVectorDestroy(&X); CeedVectorDestroy(&Ucoarse); CeedVectorDestroy(&Ufine); CeedVectorDestroy(&Vcoarse); CeedVectorDestroy(&Vfine); CeedVectorDestroy(&PMultFine); CeedVectorDestroy(&qdata); CeedDestroy(&ceed); return 0; }