1d21efd2eSMatthew G. Knepley static const char help[] = "Tests for determining whether a new finite element works"; 2d21efd2eSMatthew G. Knepley 3d21efd2eSMatthew G. Knepley /* 4d21efd2eSMatthew G. Knepley Use -interpolation_view and -l2_projection_view to look at the interpolants. 5d21efd2eSMatthew G. Knepley */ 6d21efd2eSMatthew G. Knepley 7d21efd2eSMatthew G. Knepley #include <petscdmplex.h> 8d21efd2eSMatthew G. Knepley #include <petscfe.h> 9d21efd2eSMatthew G. Knepley #include <petscds.h> 10d21efd2eSMatthew G. Knepley #include <petscsnes.h> 11d21efd2eSMatthew G. Knepley 12d21efd2eSMatthew G. Knepley static void constant(PetscInt dim, PetscInt Nf, PetscInt NfAux, 13d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 14d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 15d21efd2eSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 16d21efd2eSMatthew G. Knepley { 17d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 18d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) f0[c] += 5.; 19d21efd2eSMatthew G. Knepley } 20d21efd2eSMatthew G. Knepley 21d21efd2eSMatthew G. Knepley static void linear(PetscInt dim, PetscInt Nf, PetscInt NfAux, 22d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 23d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 24d21efd2eSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 25d21efd2eSMatthew G. Knepley { 26d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 27d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) f0[c] += 5.*x[c]; 28d21efd2eSMatthew G. Knepley } 29d21efd2eSMatthew G. Knepley 30d21efd2eSMatthew G. Knepley static void quadratic(PetscInt dim, PetscInt Nf, PetscInt NfAux, 31d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 32d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 33d21efd2eSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 34d21efd2eSMatthew G. Knepley { 35d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 36d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) f0[c] += 5.*x[c]*x[c]; 37d21efd2eSMatthew G. Knepley } 38d21efd2eSMatthew G. Knepley 39d21efd2eSMatthew G. Knepley static void trig(PetscInt dim, PetscInt Nf, PetscInt NfAux, 40d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 41d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 42d21efd2eSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 43d21efd2eSMatthew G. Knepley { 44d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 45d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) f0[c] += PetscCosReal(2.*PETSC_PI*x[c]); 46d21efd2eSMatthew G. Knepley } 47d21efd2eSMatthew G. Knepley 48e239af90SMatthew G. Knepley /* 49e239af90SMatthew G. Knepley The prime basis for the Wheeler-Yotov-Xue prism. 50e239af90SMatthew G. Knepley */ 51e239af90SMatthew G. Knepley static void prime(PetscInt dim, PetscInt Nf, PetscInt NfAux, 52e239af90SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 53e239af90SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 54e239af90SMatthew G. Knepley PetscReal t, const PetscReal X[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 55e239af90SMatthew G. Knepley { 56e239af90SMatthew G. Knepley PetscReal x = X[0], y = X[1], z = X[2], b = 1 + x + y + z; 57e239af90SMatthew G. Knepley f0[0] += b + 2.0*x*z + 2.0*y*z + x*y + x*x; 58e239af90SMatthew G. Knepley f0[1] += b + 2.0*x*z + 2.0*y*z + x*y + y*y; 59e239af90SMatthew G. Knepley f0[2] += b - 3.0*x*z - 3.0*y*z - 2.0*z*z; 60e239af90SMatthew G. Knepley } 61e239af90SMatthew G. Knepley 62e239af90SMatthew G. Knepley static const char *names[] = {"constant", "linear", "quadratic", "trig", "prime"}; 63e239af90SMatthew G. Knepley static PetscPointFunc functions[] = { constant, linear, quadratic, trig, prime }; 64d21efd2eSMatthew G. Knepley 65d21efd2eSMatthew G. Knepley typedef struct { 66d21efd2eSMatthew G. Knepley PetscPointFunc exactSol; 67e239af90SMatthew G. Knepley PetscReal shear,flatten; 68d21efd2eSMatthew G. Knepley } AppCtx; 69d21efd2eSMatthew G. Knepley 70d21efd2eSMatthew G. Knepley static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) 71d21efd2eSMatthew G. Knepley { 72d21efd2eSMatthew G. Knepley char name[PETSC_MAX_PATH_LEN] = "constant"; 73dd39110bSPierre Jolivet PetscInt Nfunc = PETSC_STATIC_ARRAY_LENGTH(names), i; 74d21efd2eSMatthew G. Knepley 75d21efd2eSMatthew G. Knepley PetscFunctionBeginUser; 76d21efd2eSMatthew G. Knepley options->exactSol = NULL; 77e239af90SMatthew G. Knepley options->shear = 0.; 78e239af90SMatthew G. Knepley options->flatten = 1.; 79d21efd2eSMatthew G. Knepley 80d0609cedSBarry Smith PetscOptionsBegin(comm, "", "FE Test Options", "PETSCFE"); 819566063dSJacob Faibussowitsch PetscCall(PetscOptionsString("-func", "Function to project into space", "", name, name, PETSC_MAX_PATH_LEN, NULL)); 829566063dSJacob Faibussowitsch PetscCall(PetscOptionsReal("-shear", "Factor by which to shear along the x-direction", "", options->shear, &(options->shear), NULL)); 839566063dSJacob Faibussowitsch PetscCall(PetscOptionsReal("-flatten", "Factor by which to flatten", "", options->flatten, &(options->flatten), NULL)); 84d0609cedSBarry Smith PetscOptionsEnd(); 85d21efd2eSMatthew G. Knepley 86d21efd2eSMatthew G. Knepley for (i = 0; i < Nfunc; ++i) { 87d21efd2eSMatthew G. Knepley PetscBool flg; 88d21efd2eSMatthew G. Knepley 899566063dSJacob Faibussowitsch PetscCall(PetscStrcmp(name, names[i], &flg)); 90d21efd2eSMatthew G. Knepley if (flg) {options->exactSol = functions[i]; break;} 91d21efd2eSMatthew G. Knepley } 92e239af90SMatthew G. Knepley PetscCheck(options->exactSol, comm, PETSC_ERR_ARG_WRONG, "Invalid test function %s", name); 93d21efd2eSMatthew G. Knepley PetscFunctionReturn(0); 94d21efd2eSMatthew G. Knepley } 95d21efd2eSMatthew G. Knepley 96d21efd2eSMatthew G. Knepley /* The exact solution is the negative of the f0 contribution */ 97d21efd2eSMatthew G. Knepley static PetscErrorCode exactSolution(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx) 98d21efd2eSMatthew G. Knepley { 99d21efd2eSMatthew G. Knepley AppCtx *user = (AppCtx *) ctx; 100e239af90SMatthew G. Knepley PetscInt uOff[2] = {0, Nc}; 101d21efd2eSMatthew G. Knepley 102d21efd2eSMatthew G. Knepley user->exactSol(dim, 1, 0, uOff, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, time, x, 0, NULL, u); 103d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) u[c] *= -1.; 104d21efd2eSMatthew G. Knepley return 0; 105d21efd2eSMatthew G. Knepley } 106d21efd2eSMatthew G. Knepley 107d21efd2eSMatthew G. Knepley static void f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 108d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 109d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110d21efd2eSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]) 111d21efd2eSMatthew G. Knepley { 112d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 113d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) f0[c] += u[c]; 114d21efd2eSMatthew G. Knepley } 115d21efd2eSMatthew G. Knepley 116d21efd2eSMatthew G. Knepley static void g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 117d21efd2eSMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 118d21efd2eSMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 119d21efd2eSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 120d21efd2eSMatthew G. Knepley { 121d21efd2eSMatthew G. Knepley const PetscInt Nc = uOff[1] - uOff[0]; 122d21efd2eSMatthew G. Knepley for (PetscInt c = 0; c < Nc; ++c) g0[c*Nc+c] = 1.0; 123d21efd2eSMatthew G. Knepley } 124d21efd2eSMatthew G. Knepley 125d21efd2eSMatthew G. Knepley static PetscErrorCode SetupProblem(DM dm, AppCtx *user) 126d21efd2eSMatthew G. Knepley { 127d21efd2eSMatthew G. Knepley PetscDS ds; 128d21efd2eSMatthew G. Knepley PetscWeakForm wf; 129d21efd2eSMatthew G. Knepley 130d21efd2eSMatthew G. Knepley PetscFunctionBeginUser; 1319566063dSJacob Faibussowitsch PetscCall(DMGetDS(dm, &ds)); 1329566063dSJacob Faibussowitsch PetscCall(PetscDSGetWeakForm(ds, &wf)); 1339566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(wf, NULL, 0, 0, 0, 0, f0, 0, NULL)); 1349566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(wf, NULL, 0, 0, 0, 1, user->exactSol, 0, NULL)); 1359566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexJacobian(wf, NULL, 0, 0, 0, 0, 0, g0, 0, NULL, 0, NULL, 0, NULL)); 1369566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolution(ds, 0, exactSolution, user)); 137d21efd2eSMatthew G. Knepley PetscFunctionReturn(0); 138d21efd2eSMatthew G. Knepley } 139d21efd2eSMatthew G. Knepley 140d21efd2eSMatthew G. Knepley static PetscErrorCode SetupDiscretization(DM dm, const char name[], AppCtx *user) 141d21efd2eSMatthew G. Knepley { 142d21efd2eSMatthew G. Knepley DM cdm = dm; 143d21efd2eSMatthew G. Knepley PetscFE fe; 144d21efd2eSMatthew G. Knepley char prefix[PETSC_MAX_PATH_LEN]; 145d21efd2eSMatthew G. Knepley 146d21efd2eSMatthew G. Knepley PetscFunctionBeginUser; 147*63a3b9bcSJacob Faibussowitsch if (name) PetscCall(PetscSNPrintf(prefix, sizeof(prefix), "%s_", name)); 1489566063dSJacob Faibussowitsch PetscCall(DMCreateFEDefault(dm, 1, name ? prefix : NULL, -1, &fe)); 1499566063dSJacob Faibussowitsch PetscCall(PetscObjectSetName((PetscObject) fe, name ? name : "Solution")); 150d21efd2eSMatthew G. Knepley /* Set discretization and boundary conditions for each mesh */ 1519566063dSJacob Faibussowitsch PetscCall(DMSetField(dm, 0, NULL, (PetscObject) fe)); 1529566063dSJacob Faibussowitsch PetscCall(DMCreateDS(dm)); 1539566063dSJacob Faibussowitsch PetscCall(SetupProblem(dm, user)); 154d21efd2eSMatthew G. Knepley while (cdm) { 1559566063dSJacob Faibussowitsch PetscCall(DMCopyDisc(dm, cdm)); 1569566063dSJacob Faibussowitsch PetscCall(DMGetCoarseDM(cdm, &cdm)); 157d21efd2eSMatthew G. Knepley } 1589566063dSJacob Faibussowitsch PetscCall(PetscFEDestroy(&fe)); 159d21efd2eSMatthew G. Knepley PetscFunctionReturn(0); 160d21efd2eSMatthew G. Knepley } 161d21efd2eSMatthew G. Knepley 162d21efd2eSMatthew G. Knepley /* This test tells us whether the given function is contained in the approximation space */ 163d21efd2eSMatthew G. Knepley static PetscErrorCode CheckInterpolation(DM dm, AppCtx *user) 164d21efd2eSMatthew G. Knepley { 165d21efd2eSMatthew G. Knepley PetscSimplePointFunc exactSol[1]; 166d21efd2eSMatthew G. Knepley void *exactCtx[1]; 167d21efd2eSMatthew G. Knepley PetscDS ds; 168d21efd2eSMatthew G. Knepley Vec u; 169d21efd2eSMatthew G. Knepley PetscReal error, tol = PETSC_SMALL; 170d21efd2eSMatthew G. Knepley MPI_Comm comm; 171d21efd2eSMatthew G. Knepley 172d21efd2eSMatthew G. Knepley PetscFunctionBeginUser; 1739566063dSJacob Faibussowitsch PetscCall(PetscObjectGetComm((PetscObject) dm, &comm)); 1749566063dSJacob Faibussowitsch PetscCall(DMGetDS(dm, &ds)); 1759566063dSJacob Faibussowitsch PetscCall(DMGetGlobalVector(dm, &u)); 1769566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolution(ds, 0, &exactSol[0], &exactCtx[0])); 1779566063dSJacob Faibussowitsch PetscCall(DMProjectFunction(dm, 0.0, exactSol, exactCtx, INSERT_ALL_VALUES, u)); 1789566063dSJacob Faibussowitsch PetscCall(VecViewFromOptions(u, NULL, "-interpolation_view")); 1799566063dSJacob Faibussowitsch PetscCall(DMComputeL2Diff(dm, 0.0, exactSol, exactCtx, u, &error)); 1809566063dSJacob Faibussowitsch PetscCall(DMRestoreGlobalVector(dm, &u)); 1819566063dSJacob Faibussowitsch if (error > tol) PetscCall(PetscPrintf(comm, "Interpolation tests FAIL at tolerance %g error %g\n", (double) tol, (double) error)); 1829566063dSJacob Faibussowitsch else PetscCall(PetscPrintf(comm, "Interpolation tests pass at tolerance %g\n", (double) tol)); 183d21efd2eSMatthew G. Knepley PetscFunctionReturn(0); 184d21efd2eSMatthew G. Knepley } 185d21efd2eSMatthew G. Knepley 186d21efd2eSMatthew G. Knepley /* This test tells us whether the element is unisolvent (the mass matrix has full rank), and what rate of convergence we achieve */ 187d21efd2eSMatthew G. Knepley static PetscErrorCode CheckL2Projection(DM dm, AppCtx *user) 188d21efd2eSMatthew G. Knepley { 189d21efd2eSMatthew G. Knepley PetscSimplePointFunc exactSol[1]; 190d21efd2eSMatthew G. Knepley void *exactCtx[1]; 191d21efd2eSMatthew G. Knepley SNES snes; 192d21efd2eSMatthew G. Knepley PetscDS ds; 193d21efd2eSMatthew G. Knepley Vec u; 194d21efd2eSMatthew G. Knepley PetscReal error, tol = PETSC_SMALL; 195d21efd2eSMatthew G. Knepley MPI_Comm comm; 196d21efd2eSMatthew G. Knepley 197d21efd2eSMatthew G. Knepley PetscFunctionBeginUser; 1989566063dSJacob Faibussowitsch PetscCall(PetscObjectGetComm((PetscObject) dm, &comm)); 1999566063dSJacob Faibussowitsch PetscCall(DMGetDS(dm, &ds)); 2009566063dSJacob Faibussowitsch PetscCall(DMGetGlobalVector(dm, &u)); 2019566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolution(ds, 0, &exactSol[0], &exactCtx[0])); 2029566063dSJacob Faibussowitsch PetscCall(SNESCreate(comm, &snes)); 2039566063dSJacob Faibussowitsch PetscCall(SNESSetDM(snes, dm)); 2049566063dSJacob Faibussowitsch PetscCall(VecSet(u, 0.0)); 2059566063dSJacob Faibussowitsch PetscCall(PetscObjectSetName((PetscObject) u, "solution")); 2069566063dSJacob Faibussowitsch PetscCall(DMPlexSetSNESLocalFEM(dm, user, user, user)); 2079566063dSJacob Faibussowitsch PetscCall(SNESSetFromOptions(snes)); 2089566063dSJacob Faibussowitsch PetscCall(DMSNESCheckFromOptions(snes, u)); 2099566063dSJacob Faibussowitsch PetscCall(SNESSolve(snes, NULL, u)); 2109566063dSJacob Faibussowitsch PetscCall(SNESDestroy(&snes)); 2119566063dSJacob Faibussowitsch PetscCall(VecViewFromOptions(u, NULL, "-l2_projection_view")); 2129566063dSJacob Faibussowitsch PetscCall(DMComputeL2Diff(dm, 0.0, exactSol, exactCtx, u, &error)); 2139566063dSJacob Faibussowitsch PetscCall(DMRestoreGlobalVector(dm, &u)); 2149566063dSJacob Faibussowitsch if (error > tol) PetscCall(PetscPrintf(comm, "L2 projection tests FAIL at tolerance %g error %g\n", (double) tol, (double) error)); 2159566063dSJacob Faibussowitsch else PetscCall(PetscPrintf(comm, "L2 projection tests pass at tolerance %g\n", (double) tol)); 216d21efd2eSMatthew G. Knepley PetscFunctionReturn(0); 217d21efd2eSMatthew G. Knepley } 218d21efd2eSMatthew G. Knepley 219e239af90SMatthew G. Knepley /* Distorts the mesh by shearing in the x-direction and flattening, factors provided in the options. */ 220e239af90SMatthew G. Knepley static PetscErrorCode DistortMesh(DM dm, AppCtx *user) 221e239af90SMatthew G. Knepley { 222e239af90SMatthew G. Knepley Vec coordinates; 223e239af90SMatthew G. Knepley PetscScalar *ca; 224e239af90SMatthew G. Knepley PetscInt dE, n, i; 225e239af90SMatthew G. Knepley 226e239af90SMatthew G. Knepley PetscFunctionBeginUser; 2279566063dSJacob Faibussowitsch PetscCall(DMGetCoordinateDim(dm, &dE)); 2289566063dSJacob Faibussowitsch PetscCall(DMGetCoordinates(dm, &coordinates)); 2299566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(coordinates, &n)); 2309566063dSJacob Faibussowitsch PetscCall(VecGetArray(coordinates, &ca)); 231e239af90SMatthew G. Knepley for (i = 0; i < (n/dE); ++i) { 232e239af90SMatthew G. Knepley ca[i*dE+0] += user->shear*ca[i*dE+0]; 233e239af90SMatthew G. Knepley ca[i*dE+1] *= user->flatten; 234e239af90SMatthew G. Knepley } 2359566063dSJacob Faibussowitsch PetscCall(VecRestoreArray(coordinates, &ca)); 236e239af90SMatthew G. Knepley PetscFunctionReturn(0); 237e239af90SMatthew G. Knepley } 238e239af90SMatthew G. Knepley 239d21efd2eSMatthew G. Knepley int main(int argc, char **argv) 240d21efd2eSMatthew G. Knepley { 241d21efd2eSMatthew G. Knepley DM dm; 242d21efd2eSMatthew G. Knepley AppCtx user; 243d21efd2eSMatthew G. Knepley PetscMPIInt size; 244d21efd2eSMatthew G. Knepley 2459566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 2469566063dSJacob Faibussowitsch PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size)); 247e239af90SMatthew G. Knepley PetscCheck(size == 1, PETSC_COMM_WORLD, PETSC_ERR_SUP, "This is a uniprocessor example only."); 2489566063dSJacob Faibussowitsch PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); 2499566063dSJacob Faibussowitsch PetscCall(DMCreate(PETSC_COMM_WORLD, &dm)); 2509566063dSJacob Faibussowitsch PetscCall(DMSetType(dm, DMPLEX)); 2519566063dSJacob Faibussowitsch PetscCall(DMSetFromOptions(dm)); 2529566063dSJacob Faibussowitsch PetscCall(DistortMesh(dm,&user)); 2539566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); 2549566063dSJacob Faibussowitsch PetscCall(SetupDiscretization(dm, NULL, &user)); 255d21efd2eSMatthew G. Knepley 2569566063dSJacob Faibussowitsch PetscCall(CheckInterpolation(dm, &user)); 2579566063dSJacob Faibussowitsch PetscCall(CheckL2Projection(dm, &user)); 258d21efd2eSMatthew G. Knepley 2599566063dSJacob Faibussowitsch PetscCall(DMDestroy(&dm)); 2609566063dSJacob Faibussowitsch PetscCall(PetscFinalize()); 261b122ec5aSJacob Faibussowitsch return 0; 262d21efd2eSMatthew G. Knepley } 263d21efd2eSMatthew G. Knepley 264d21efd2eSMatthew G. Knepley /*TEST 265d21efd2eSMatthew G. Knepley 266d21efd2eSMatthew G. Knepley testset: 267d21efd2eSMatthew G. Knepley args: -dm_plex_reference_cell_domain -dm_plex_cell triangle -petscspace_degree 1\ 268d21efd2eSMatthew G. Knepley -snes_error_if_not_converged -ksp_error_if_not_converged -pc_type lu 269d21efd2eSMatthew G. Knepley 270d21efd2eSMatthew G. Knepley test: 271d21efd2eSMatthew G. Knepley suffix: p1_0 272d21efd2eSMatthew G. Knepley args: -func {{constant linear}} 273d21efd2eSMatthew G. Knepley 274d21efd2eSMatthew G. Knepley # Using -dm_refine 2 -convest_num_refine 4 gives convergence rate 2.0 275d21efd2eSMatthew G. Knepley test: 276d21efd2eSMatthew G. Knepley suffix: p1_1 277d21efd2eSMatthew G. Knepley args: -func {{quadratic trig}} \ 278d21efd2eSMatthew G. Knepley -snes_convergence_estimate -convest_num_refine 2 279d21efd2eSMatthew G. Knepley 280d21efd2eSMatthew G. Knepley testset: 281e239af90SMatthew G. Knepley requires: !complex double 282d21efd2eSMatthew G. Knepley args: -dm_plex_reference_cell_domain -dm_plex_cell triangular_prism \ 283d21efd2eSMatthew G. Knepley -petscspace_type sum \ 284d21efd2eSMatthew G. Knepley -petscspace_variables 3 \ 285d21efd2eSMatthew G. Knepley -petscspace_components 3 \ 286d21efd2eSMatthew G. Knepley -petscspace_sum_spaces 2 \ 287d21efd2eSMatthew G. Knepley -petscspace_sum_concatenate false \ 288d21efd2eSMatthew G. Knepley -sumcomp_0_petscspace_variables 3 \ 289d21efd2eSMatthew G. Knepley -sumcomp_0_petscspace_components 3 \ 290d21efd2eSMatthew G. Knepley -sumcomp_0_petscspace_degree 1 \ 291d21efd2eSMatthew G. Knepley -sumcomp_1_petscspace_variables 3 \ 292d21efd2eSMatthew G. Knepley -sumcomp_1_petscspace_components 3 \ 293d21efd2eSMatthew G. Knepley -sumcomp_1_petscspace_type wxy \ 294d21efd2eSMatthew G. Knepley -petscdualspace_form_degree 0 \ 295d21efd2eSMatthew G. Knepley -petscdualspace_order 1 \ 296d21efd2eSMatthew G. Knepley -petscdualspace_components 3 \ 297d21efd2eSMatthew G. Knepley -snes_error_if_not_converged -ksp_error_if_not_converged -pc_type lu 298d21efd2eSMatthew G. Knepley 299d21efd2eSMatthew G. Knepley test: 300d21efd2eSMatthew G. Knepley suffix: wxy_0 301d21efd2eSMatthew G. Knepley args: -func constant 302d21efd2eSMatthew G. Knepley 303d21efd2eSMatthew G. Knepley test: 304d21efd2eSMatthew G. Knepley suffix: wxy_1 305d21efd2eSMatthew G. Knepley args: -func linear 306d21efd2eSMatthew G. Knepley 307e239af90SMatthew G. Knepley test: 308e239af90SMatthew G. Knepley suffix: wxy_2 309e239af90SMatthew G. Knepley args: -func prime 310e239af90SMatthew G. Knepley 311e239af90SMatthew G. Knepley test: 312e239af90SMatthew G. Knepley suffix: wxy_3 313e239af90SMatthew G. Knepley args: -func linear -shear 1 -flatten 1e-5 314e239af90SMatthew G. Knepley 315d21efd2eSMatthew G. Knepley TEST*/ 316