/// @file /// Test collocated grad in multiple dimensions /// \test Test collocated grad in multiple dimensions #include #include static CeedScalar Eval(CeedInt dim, const CeedScalar x[]) { CeedScalar result = tanh(x[0] + 0.1); if (dim > 1) result += atan(x[1] + 0.2); if (dim > 2) result += exp(-(x[2] + 0.3)*(x[2] + 0.3)); return result; } static CeedScalar GetTolerance(CeedScalarType scalar_type, int dim) { CeedScalar tol; if (scalar_type == CEED_SCALAR_FP32) { if (dim == 3) tol = 1.e-3; else tol = 1.e-4; } else { tol = 1.e-11; } return tol; } int main(int argc, char **argv) { Ceed ceed; CeedInit(argv[1], &ceed); for (CeedInt dim=1; dim<=3; dim++) { CeedVector X, X_q, U, U_q, ones, grad_T_ones; CeedBasis basis_x_lobatto, basis_u_gauss; CeedInt P = 8, Q = 8, P_dim = CeedIntPow(P, dim), Qdim_ = CeedIntPow(Q, dim), X_dim = CeedIntPow(2, dim); CeedScalar x[X_dim*dim], u[P_dim]; const CeedScalar *x_q, *u_q, *grad_t_ones_array; CeedScalar sum_1 = 0, sum_2 = 0; for (CeedInt d=0; d tol) // LCOV_EXCL_START printf("[%d] %f != %f\n", dim, sum_1, sum_2); // LCOV_EXCL_STOP CeedVectorDestroy(&X); CeedVectorDestroy(&X_q); CeedVectorDestroy(&U); CeedVectorDestroy(&U_q); CeedVectorDestroy(&ones); CeedVectorDestroy(&grad_T_ones); CeedBasisDestroy(&basis_x_lobatto); CeedBasisDestroy(&basis_u_gauss); } CeedDestroy(&ceed); return 0; }