Actual source code: ex2.c
1: const char help[] = "Simple example to get equally space points in high-order elements (and XGC mirror)";
3: #include <petscfe.h>
4: #include <petscdmplex.h>
5: static PetscErrorCode x(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf_dummy, PetscScalar *u, void *actx)
6: {
7: u[0] = x[0];
8: return 0;
9: }
11: int main(int argc, char **argv)
12: {
13: PetscInt dim = 2, cells[] = {1, 1, 1};
14: DM K;
15: PetscReal radius = 2, lo[] = {-radius, -radius, -radius}, hi[] = {radius, radius, radius};
16: DMBoundaryType periodicity[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
17: PetscFE fe;
18: PetscErrorCode (*initu[1])(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar[], void *);
19: Vec X;
22: PetscInitialize(&argc, &argv, NULL, help);
23: PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for PETSCDUALSPACELAGRANGE test", "none");
24: PetscOptionsRangeInt("-dim", "The spatial dimension", "ex1.c", dim, &dim, NULL, 0, 3);
25: PetscOptionsEnd();
27: DMPlexCreateBoxMesh(PETSC_COMM_SELF, dim, PETSC_FALSE, cells, lo, hi, periodicity, PETSC_TRUE, &K);
28: PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, PETSC_FALSE, NULL, PETSC_DECIDE, &fe);
29: DMSetField(K, 0, NULL, (PetscObject)fe);
30: PetscFEDestroy(&fe);
31: DMCreateDS(K);
33: initu[0] = x;
34: DMCreateGlobalVector(K, &X);
35: DMProjectFunction(K, 0.0, initu, NULL, INSERT_ALL_VALUES, X);
36: DMViewFromOptions(K, NULL, "-dual_dm_view");
37: VecViewFromOptions(X, NULL, "-dual_vec_view");
38: DMDestroy(&K);
39: VecDestroy(&X);
40: PetscFinalize();
41: return 0;
42: }
44: /*TEST
46: testset:
47: filter: grep -v DM_
48: diff_args: -j
49: args: -petscspace_degree 4 -petscdualspace_lagrange_node_type equispaced -petscdualspace_lagrange_node_endpoints 1 -dual_dm_view -dual_vec_view
50: test:
51: requires: !single
52: suffix: 0
53: test:
54: requires: !single
55: suffix: 3d
56: args: -dim 3
58: TEST*/