13157dc65SMatthew G. Knepley static char help[] = "Testing integrators on the simple harmonic oscillator\n"; 2c4762a1bSJed Brown 33157dc65SMatthew G. Knepley /* 43157dc65SMatthew G. Knepley In order to check long time behavior, you can give 53157dc65SMatthew G. Knepley 63157dc65SMatthew G. Knepley -ts_max_steps 10000 -ts_max_time 10.0 -output_step 1000 73157dc65SMatthew G. Knepley 83157dc65SMatthew G. Knepley To look at the long time behavior for different integrators, we can use the nergy monitor. Below we see that Euler is almost 100 times worse at conserving energy than the symplectic integrator of the same order. 93157dc65SMatthew G. Knepley 103157dc65SMatthew G. Knepley make -f ./gmakefile test search="dm_impls_swarm_tests-ex4_bsi_1" 113157dc65SMatthew G. Knepley EXTRA_OPTIONS="-ts_max_steps 10000 -ts_max_time 10.0 -output_step 1000 -ts_type euler" | grep error 123157dc65SMatthew G. Knepley 133157dc65SMatthew G. Knepley energy/exact energy 398.236 / 396.608 (0.4104399231) 143157dc65SMatthew G. Knepley energy/exact energy 1579.52 / 1573.06 (0.4104399231) 153157dc65SMatthew G. Knepley energy/exact energy 397.421 / 396.608 (0.2050098479) 163157dc65SMatthew G. Knepley energy/exact energy 1576.29 / 1573.06 (0.2050098479) 173157dc65SMatthew G. Knepley energy/exact energy 397.014 / 396.608 (0.1024524454) 183157dc65SMatthew G. Knepley energy/exact energy 1574.68 / 1573.06 (0.1024524454) 193157dc65SMatthew G. Knepley 203157dc65SMatthew G. Knepley make -f ./gmakefile test search="dm_impls_swarm_tests-ex4_bsi_1" 213157dc65SMatthew G. Knepley EXTRA_OPTIONS="-ts_max_steps 10000 -ts_max_time 10.0 -output_step 1000" | grep error 223157dc65SMatthew G. Knepley 233157dc65SMatthew G. Knepley energy/exact energy 396.579 / 396.608 (0.0074080434) 243157dc65SMatthew G. Knepley energy/exact energy 1572.95 / 1573.06 (0.0074080434) 253157dc65SMatthew G. Knepley energy/exact energy 396.593 / 396.608 (0.0037040885) 263157dc65SMatthew G. Knepley energy/exact energy 1573.01 / 1573.06 (0.0037040886) 273157dc65SMatthew G. Knepley energy/exact energy 396.601 / 396.608 (0.0018520613) 283157dc65SMatthew G. Knepley energy/exact energy 1573.04 / 1573.06 (0.0018520613) 293157dc65SMatthew G. Knepley 303157dc65SMatthew G. Knepley We can look at third order integrators in the same way, but we need to use more steps. 313157dc65SMatthew G. Knepley 323157dc65SMatthew G. Knepley make -f ./gmakefile test search="dm_impls_swarm_tests-ex4_bsi_1" 333157dc65SMatthew G. Knepley EXTRA_OPTIONS="-ts_max_steps 1000000 -ts_max_time 1000.0 -output_step 100000 -ts_type rk -ts_adapt_type none" | grep error 343157dc65SMatthew G. Knepley 353157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000013981) 363157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000013981) 373157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000001747) 383157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000001748) 393157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000000218) 403157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000000218) 413157dc65SMatthew G. Knepley 423157dc65SMatthew G. Knepley make -f ./gmakefile test search="dm_impls_swarm_tests-ex4_bsi_3" 433157dc65SMatthew G. Knepley EXTRA_OPTIONS="-ts_max_steps 1000000 -ts_max_time 1000.0 -output_step 100000 -ts_adapt_type none" | grep error 443157dc65SMatthew G. Knepley 453157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000000007) 463157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000000007) 473157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000000001) 483157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000000001) 493157dc65SMatthew G. Knepley energy/exact energy 396.608 / 396.608 (0.0000000000) 503157dc65SMatthew G. Knepley energy/exact energy 1573.06 / 1573.06 (0.0000000000) 513157dc65SMatthew G. Knepley */ 523157dc65SMatthew G. Knepley 53c4762a1bSJed Brown #include <petscts.h> 543157dc65SMatthew G. Knepley #include <petscdmplex.h> 553157dc65SMatthew G. Knepley #include <petscdmswarm.h> 563157dc65SMatthew G. Knepley #include <petsc/private/dmpleximpl.h> /* For norm and dot */ 57c4762a1bSJed Brown 58c4762a1bSJed Brown typedef struct { 59c4762a1bSJed Brown PetscReal omega; /* Oscillation frequency omega */ 60c4762a1bSJed Brown PetscBool error; /* Flag for printing the error */ 61c4762a1bSJed Brown PetscInt ostep; /* print the energy at each ostep time steps */ 62c4762a1bSJed Brown } AppCtx; 63c4762a1bSJed Brown 64d71ae5a4SJacob Faibussowitsch static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) 65d71ae5a4SJacob Faibussowitsch { 66c4762a1bSJed Brown PetscFunctionBeginUser; 67c4762a1bSJed Brown options->omega = 64.0; 683157dc65SMatthew G. Knepley options->error = PETSC_FALSE; 69c4762a1bSJed Brown options->ostep = 100; 70c4762a1bSJed Brown 71d0609cedSBarry Smith PetscOptionsBegin(comm, "", "Harmonic Oscillator Options", "DMSWARM"); 72*f3fa974cSJacob Faibussowitsch PetscCall(PetscOptionsReal("-omega", "Oscillator frequency", "ex4.c", options->omega, &options->omega, NULL)); 733157dc65SMatthew G. Knepley PetscCall(PetscOptionsBool("-error", "Flag to print the error", "ex4.c", options->error, &options->error, NULL)); 74*f3fa974cSJacob Faibussowitsch PetscCall(PetscOptionsInt("-output_step", "Number of time steps between output", "ex4.c", options->ostep, &options->ostep, NULL)); 75d0609cedSBarry Smith PetscOptionsEnd(); 76c4762a1bSJed Brown PetscFunctionReturn(0); 77c4762a1bSJed Brown } 78c4762a1bSJed Brown 79d71ae5a4SJacob Faibussowitsch static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm) 80d71ae5a4SJacob Faibussowitsch { 81c4762a1bSJed Brown PetscFunctionBeginUser; 829566063dSJacob Faibussowitsch PetscCall(DMCreate(comm, dm)); 839566063dSJacob Faibussowitsch PetscCall(DMSetType(*dm, DMPLEX)); 849566063dSJacob Faibussowitsch PetscCall(DMSetFromOptions(*dm)); 859566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view")); 86c4762a1bSJed Brown PetscFunctionReturn(0); 87c4762a1bSJed Brown } 88c4762a1bSJed Brown 89d71ae5a4SJacob Faibussowitsch static PetscErrorCode CreateSwarm(DM dm, AppCtx *user, DM *sw) 90d71ae5a4SJacob Faibussowitsch { 913157dc65SMatthew G. Knepley PetscReal v0[1] = {0.}; // Initialize velocities to 0 923157dc65SMatthew G. Knepley PetscInt dim; 93c4762a1bSJed Brown 94c4762a1bSJed Brown PetscFunctionBeginUser; 959566063dSJacob Faibussowitsch PetscCall(DMGetDimension(dm, &dim)); 969566063dSJacob Faibussowitsch PetscCall(DMCreate(PetscObjectComm((PetscObject)dm), sw)); 979566063dSJacob Faibussowitsch PetscCall(DMSetType(*sw, DMSWARM)); 989566063dSJacob Faibussowitsch PetscCall(DMSetDimension(*sw, dim)); 999566063dSJacob Faibussowitsch PetscCall(DMSwarmSetType(*sw, DMSWARM_PIC)); 1009566063dSJacob Faibussowitsch PetscCall(DMSwarmSetCellDM(*sw, dm)); 1013157dc65SMatthew G. Knepley PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "w_q", 1, PETSC_SCALAR)); 1023157dc65SMatthew G. Knepley PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "velocity", dim, PETSC_REAL)); 1033157dc65SMatthew G. Knepley PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "species", 1, PETSC_INT)); 1043157dc65SMatthew G. Knepley PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "initCoordinates", dim, PETSC_REAL)); 1059566063dSJacob Faibussowitsch PetscCall(DMSwarmFinalizeFieldRegister(*sw)); 1063157dc65SMatthew G. Knepley PetscCall(DMSwarmComputeLocalSizeFromOptions(*sw)); 1073157dc65SMatthew G. Knepley PetscCall(DMSwarmInitializeCoordinates(*sw)); 1083157dc65SMatthew G. Knepley PetscCall(DMSwarmInitializeVelocitiesFromOptions(*sw, v0)); 1099566063dSJacob Faibussowitsch PetscCall(DMSetFromOptions(*sw)); 1103157dc65SMatthew G. Knepley PetscCall(DMSetApplicationContext(*sw, user)); 1119566063dSJacob Faibussowitsch PetscCall(PetscObjectSetName((PetscObject)*sw, "Particles")); 1129566063dSJacob Faibussowitsch PetscCall(DMViewFromOptions(*sw, NULL, "-sw_view")); 1133157dc65SMatthew G. Knepley { 1143157dc65SMatthew G. Knepley Vec gc, gc0; 1153157dc65SMatthew G. Knepley 1163157dc65SMatthew G. Knepley PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, DMSwarmPICField_coor, &gc)); 1173157dc65SMatthew G. Knepley PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, "initCoordinates", &gc0)); 1183157dc65SMatthew G. Knepley PetscCall(VecCopy(gc, gc0)); 1193157dc65SMatthew G. Knepley PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, DMSwarmPICField_coor, &gc)); 1203157dc65SMatthew G. Knepley PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, "initCoordinates", &gc0)); 1213157dc65SMatthew G. Knepley } 122c4762a1bSJed Brown PetscFunctionReturn(0); 123c4762a1bSJed Brown } 124c4762a1bSJed Brown 125d71ae5a4SJacob Faibussowitsch static PetscErrorCode RHSFunction(TS ts, PetscReal t, Vec U, Vec G, void *ctx) 126d71ae5a4SJacob Faibussowitsch { 1273157dc65SMatthew G. Knepley const PetscReal omega = ((AppCtx *)ctx)->omega; 1283157dc65SMatthew G. Knepley DM sw; 129c4762a1bSJed Brown const PetscScalar *u; 1303157dc65SMatthew G. Knepley PetscScalar *g; 1313157dc65SMatthew G. Knepley PetscInt dim, d, Np, p; 132c4762a1bSJed Brown 133c4762a1bSJed Brown PetscFunctionBeginUser; 1343157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 1353157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 1369566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(U, &Np)); 1373157dc65SMatthew G. Knepley PetscCall(VecGetArray(G, &g)); 1383157dc65SMatthew G. Knepley PetscCall(VecGetArrayRead(U, &u)); 1393157dc65SMatthew G. Knepley Np /= 2 * dim; 140c4762a1bSJed Brown for (p = 0; p < Np; ++p) { 1413157dc65SMatthew G. Knepley for (d = 0; d < dim; ++d) { 1423157dc65SMatthew G. Knepley g[(p * 2 + 0) * dim + d] = u[(p * 2 + 1) * dim + d]; 1433157dc65SMatthew G. Knepley g[(p * 2 + 1) * dim + d] = -PetscSqr(omega) * u[(p * 2 + 0) * dim + d]; 1443157dc65SMatthew G. Knepley } 145c4762a1bSJed Brown } 1469566063dSJacob Faibussowitsch PetscCall(VecRestoreArrayRead(U, &u)); 1473157dc65SMatthew G. Knepley PetscCall(VecRestoreArray(G, &g)); 148c4762a1bSJed Brown PetscFunctionReturn(0); 149c4762a1bSJed Brown } 150c4762a1bSJed Brown 1513157dc65SMatthew G. Knepley /* J_{ij} = dF_i/dx_j 1523157dc65SMatthew G. Knepley J_p = ( 0 1) 1533157dc65SMatthew G. Knepley (-w^2 0) 1543157dc65SMatthew G. Knepley */ 155d71ae5a4SJacob Faibussowitsch static PetscErrorCode RHSJacobian(TS ts, PetscReal t, Vec U, Mat J, Mat P, void *ctx) 156d71ae5a4SJacob Faibussowitsch { 1573157dc65SMatthew G. Knepley PetscScalar vals[4] = {0., 1., -PetscSqr(((AppCtx *)ctx)->omega), 0.}; 1583157dc65SMatthew G. Knepley DM sw; 1593157dc65SMatthew G. Knepley PetscInt dim, d, Np, p, rStart; 160c4762a1bSJed Brown 161c4762a1bSJed Brown PetscFunctionBeginUser; 1623157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 1633157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 1649566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(U, &Np)); 1653157dc65SMatthew G. Knepley PetscCall(MatGetOwnershipRange(J, &rStart, NULL)); 1663157dc65SMatthew G. Knepley Np /= 2 * dim; 167c4762a1bSJed Brown for (p = 0; p < Np; ++p) { 1683157dc65SMatthew G. Knepley for (d = 0; d < dim; ++d) { 1693157dc65SMatthew G. Knepley const PetscInt rows[2] = {(p * 2 + 0) * dim + d + rStart, (p * 2 + 1) * dim + d + rStart}; 1703157dc65SMatthew G. Knepley PetscCall(MatSetValues(J, 2, rows, 2, rows, vals, INSERT_VALUES)); 171c4762a1bSJed Brown } 1723157dc65SMatthew G. Knepley } 1733157dc65SMatthew G. Knepley PetscCall(MatAssemblyBegin(J, MAT_FINAL_ASSEMBLY)); 1743157dc65SMatthew G. Knepley PetscCall(MatAssemblyEnd(J, MAT_FINAL_ASSEMBLY)); 175c4762a1bSJed Brown PetscFunctionReturn(0); 176c4762a1bSJed Brown } 177c4762a1bSJed Brown 178d71ae5a4SJacob Faibussowitsch static PetscErrorCode RHSFunctionX(TS ts, PetscReal t, Vec V, Vec Xres, void *ctx) 179d71ae5a4SJacob Faibussowitsch { 18040be0ff1SMatthew G. Knepley const PetscScalar *v; 18140be0ff1SMatthew G. Knepley PetscScalar *xres; 18240be0ff1SMatthew G. Knepley PetscInt Np, p; 18340be0ff1SMatthew G. Knepley 18440be0ff1SMatthew G. Knepley PetscFunctionBeginUser; 1859566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(Xres, &Np)); 1863157dc65SMatthew G. Knepley PetscCall(VecGetArrayRead(V, &v)); 1873157dc65SMatthew G. Knepley PetscCall(VecGetArray(Xres, &xres)); 1883157dc65SMatthew G. Knepley for (p = 0; p < Np; ++p) xres[p] = v[p]; 1899566063dSJacob Faibussowitsch PetscCall(VecRestoreArrayRead(V, &v)); 1909566063dSJacob Faibussowitsch PetscCall(VecRestoreArray(Xres, &xres)); 19140be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 19240be0ff1SMatthew G. Knepley } 19340be0ff1SMatthew G. Knepley 194d71ae5a4SJacob Faibussowitsch static PetscErrorCode RHSFunctionV(TS ts, PetscReal t, Vec X, Vec Vres, void *ctx) 195d71ae5a4SJacob Faibussowitsch { 1963157dc65SMatthew G. Knepley const PetscReal omega = ((AppCtx *)ctx)->omega; 19740be0ff1SMatthew G. Knepley const PetscScalar *x; 19840be0ff1SMatthew G. Knepley PetscScalar *vres; 19940be0ff1SMatthew G. Knepley PetscInt Np, p; 20040be0ff1SMatthew G. Knepley 20140be0ff1SMatthew G. Knepley PetscFunctionBeginUser; 2029566063dSJacob Faibussowitsch PetscCall(VecGetArray(Vres, &vres)); 2039566063dSJacob Faibussowitsch PetscCall(VecGetArrayRead(X, &x)); 2049566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(Vres, &Np)); 2053157dc65SMatthew G. Knepley for (p = 0; p < Np; ++p) vres[p] = -PetscSqr(omega) * x[p]; 2069566063dSJacob Faibussowitsch PetscCall(VecRestoreArrayRead(X, &x)); 2079566063dSJacob Faibussowitsch PetscCall(VecRestoreArray(Vres, &vres)); 20840be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 20940be0ff1SMatthew G. Knepley } 21040be0ff1SMatthew G. Knepley 211d71ae5a4SJacob Faibussowitsch PetscErrorCode RHSJacobianS(TS ts, PetscReal t, Vec U, Mat S, void *ctx) 212d71ae5a4SJacob Faibussowitsch { 2133157dc65SMatthew G. Knepley PetscScalar vals[4] = {0., 1., -1., 0.}; 2143157dc65SMatthew G. Knepley DM sw; 2153157dc65SMatthew G. Knepley PetscInt dim, d, Np, p, rStart; 21640be0ff1SMatthew G. Knepley 21740be0ff1SMatthew G. Knepley PetscFunctionBeginUser; 2183157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 2193157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 2203157dc65SMatthew G. Knepley PetscCall(VecGetLocalSize(U, &Np)); 2213157dc65SMatthew G. Knepley PetscCall(MatGetOwnershipRange(S, &rStart, NULL)); 2223157dc65SMatthew G. Knepley Np /= 2 * dim; 2233157dc65SMatthew G. Knepley for (p = 0; p < Np; ++p) { 2243157dc65SMatthew G. Knepley for (d = 0; d < dim; ++d) { 2253157dc65SMatthew G. Knepley const PetscInt rows[2] = {(p * 2 + 0) * dim + d + rStart, (p * 2 + 1) * dim + d + rStart}; 2263157dc65SMatthew G. Knepley PetscCall(MatSetValues(S, 2, rows, 2, rows, vals, INSERT_VALUES)); 2273157dc65SMatthew G. Knepley } 2283157dc65SMatthew G. Knepley } 2293157dc65SMatthew G. Knepley PetscCall(MatAssemblyBegin(S, MAT_FINAL_ASSEMBLY)); 2303157dc65SMatthew G. Knepley PetscCall(MatAssemblyEnd(S, MAT_FINAL_ASSEMBLY)); 2313157dc65SMatthew G. Knepley PetscFunctionReturn(0); 2323157dc65SMatthew G. Knepley } 2333157dc65SMatthew G. Knepley 234d71ae5a4SJacob Faibussowitsch PetscErrorCode RHSObjectiveF(TS ts, PetscReal t, Vec U, PetscScalar *F, void *ctx) 235d71ae5a4SJacob Faibussowitsch { 2363157dc65SMatthew G. Knepley const PetscReal omega = ((AppCtx *)ctx)->omega; 2373157dc65SMatthew G. Knepley DM sw; 2383157dc65SMatthew G. Knepley const PetscScalar *u; 2393157dc65SMatthew G. Knepley PetscInt dim, Np, p; 2403157dc65SMatthew G. Knepley 2413157dc65SMatthew G. Knepley PetscFunctionBeginUser; 2423157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 2433157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 2443157dc65SMatthew G. Knepley PetscCall(VecGetArrayRead(U, &u)); 2453157dc65SMatthew G. Knepley PetscCall(VecGetLocalSize(U, &Np)); 2463157dc65SMatthew G. Knepley Np /= 2 * dim; 2473157dc65SMatthew G. Knepley for (p = 0; p < Np; ++p) { 2483157dc65SMatthew G. Knepley const PetscReal x2 = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 0) * dim], &u[(p * 2 + 0) * dim]); 2493157dc65SMatthew G. Knepley const PetscReal v2 = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 1) * dim], &u[(p * 2 + 1) * dim]); 2503157dc65SMatthew G. Knepley const PetscReal E = 0.5 * (v2 + PetscSqr(omega) * x2); 2513157dc65SMatthew G. Knepley 2523157dc65SMatthew G. Knepley *F += E; 2533157dc65SMatthew G. Knepley } 2543157dc65SMatthew G. Knepley PetscCall(VecRestoreArrayRead(U, &u)); 2553157dc65SMatthew G. Knepley PetscFunctionReturn(0); 2563157dc65SMatthew G. Knepley } 2573157dc65SMatthew G. Knepley 2583157dc65SMatthew G. Knepley /* dF/dx = omega^2 x dF/dv = v */ 259d71ae5a4SJacob Faibussowitsch PetscErrorCode RHSFunctionG(TS ts, PetscReal t, Vec U, Vec G, void *ctx) 260d71ae5a4SJacob Faibussowitsch { 2613157dc65SMatthew G. Knepley const PetscReal omega = ((AppCtx *)ctx)->omega; 2623157dc65SMatthew G. Knepley DM sw; 2633157dc65SMatthew G. Knepley const PetscScalar *u; 2643157dc65SMatthew G. Knepley PetscScalar *g; 2653157dc65SMatthew G. Knepley PetscInt dim, d, Np, p; 2663157dc65SMatthew G. Knepley 2673157dc65SMatthew G. Knepley PetscFunctionBeginUser; 2683157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 2693157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 2709566063dSJacob Faibussowitsch PetscCall(VecGetArray(G, &g)); 2719566063dSJacob Faibussowitsch PetscCall(VecGetArrayRead(U, &u)); 2729566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(U, &Np)); 2733157dc65SMatthew G. Knepley Np /= 2 * dim; 27440be0ff1SMatthew G. Knepley for (p = 0; p < Np; ++p) { 2753157dc65SMatthew G. Knepley for (d = 0; d < dim; ++d) { 2763157dc65SMatthew G. Knepley g[(p * 2 + 0) * dim + d] = PetscSqr(omega) * u[(p * 2 + 0) * dim + d]; 2773157dc65SMatthew G. Knepley g[(p * 2 + 1) * dim + d] = u[(p * 2 + 1) * dim + d]; 2783157dc65SMatthew G. Knepley } 27940be0ff1SMatthew G. Knepley } 2809566063dSJacob Faibussowitsch PetscCall(VecRestoreArrayRead(U, &u)); 2819566063dSJacob Faibussowitsch PetscCall(VecRestoreArray(G, &g)); 28240be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 28340be0ff1SMatthew G. Knepley } 28440be0ff1SMatthew G. Knepley 285d71ae5a4SJacob Faibussowitsch static PetscErrorCode CreateSolution(TS ts) 286d71ae5a4SJacob Faibussowitsch { 2873157dc65SMatthew G. Knepley DM sw; 2883157dc65SMatthew G. Knepley Vec u; 2893157dc65SMatthew G. Knepley PetscInt dim, Np; 29040be0ff1SMatthew G. Knepley 2913157dc65SMatthew G. Knepley PetscFunctionBegin; 2923157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 2933157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 2943157dc65SMatthew G. Knepley PetscCall(DMSwarmGetLocalSize(sw, &Np)); 2953157dc65SMatthew G. Knepley PetscCall(VecCreate(PETSC_COMM_WORLD, &u)); 2963157dc65SMatthew G. Knepley PetscCall(VecSetBlockSize(u, dim)); 2973157dc65SMatthew G. Knepley PetscCall(VecSetSizes(u, 2 * Np * dim, PETSC_DECIDE)); 2983157dc65SMatthew G. Knepley PetscCall(VecSetUp(u)); 2993157dc65SMatthew G. Knepley PetscCall(TSSetSolution(ts, u)); 3003157dc65SMatthew G. Knepley PetscCall(VecDestroy(&u)); 30140be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 30240be0ff1SMatthew G. Knepley } 303db4653c2SDaniel Finn 304d71ae5a4SJacob Faibussowitsch static PetscErrorCode SetProblem(TS ts) 305d71ae5a4SJacob Faibussowitsch { 3063157dc65SMatthew G. Knepley AppCtx *user; 3073157dc65SMatthew G. Knepley DM sw; 30840be0ff1SMatthew G. Knepley 3093157dc65SMatthew G. Knepley PetscFunctionBegin; 3103157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 3113157dc65SMatthew G. Knepley PetscCall(DMGetApplicationContext(sw, (void **)&user)); 3123157dc65SMatthew G. Knepley // Define unified system for (X, V) 3133157dc65SMatthew G. Knepley { 3143157dc65SMatthew G. Knepley Mat J; 3153157dc65SMatthew G. Knepley PetscInt dim, Np; 3163157dc65SMatthew G. Knepley 3173157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 3183157dc65SMatthew G. Knepley PetscCall(DMSwarmGetLocalSize(sw, &Np)); 3193157dc65SMatthew G. Knepley PetscCall(MatCreate(PETSC_COMM_WORLD, &J)); 3203157dc65SMatthew G. Knepley PetscCall(MatSetSizes(J, 2 * Np * dim, 2 * Np * dim, PETSC_DECIDE, PETSC_DECIDE)); 3213157dc65SMatthew G. Knepley PetscCall(MatSetBlockSize(J, 2 * dim)); 3223157dc65SMatthew G. Knepley PetscCall(MatSetFromOptions(J)); 3233157dc65SMatthew G. Knepley PetscCall(MatSetUp(J)); 3243157dc65SMatthew G. Knepley PetscCall(TSSetRHSFunction(ts, NULL, RHSFunction, user)); 3253157dc65SMatthew G. Knepley PetscCall(TSSetRHSJacobian(ts, J, J, RHSJacobian, user)); 3263157dc65SMatthew G. Knepley PetscCall(MatDestroy(&J)); 32740be0ff1SMatthew G. Knepley } 3283157dc65SMatthew G. Knepley // Define split system for X and V 3293157dc65SMatthew G. Knepley { 3303157dc65SMatthew G. Knepley IS isx, isv, istmp; 3313157dc65SMatthew G. Knepley const PetscInt *idx; 3323157dc65SMatthew G. Knepley PetscInt dim, Np; 3333157dc65SMatthew G. Knepley 3343157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 3353157dc65SMatthew G. Knepley PetscCall(DMSwarmGetLocalSize(sw, &Np)); 3363157dc65SMatthew G. Knepley PetscCall(ISCreateStride(PETSC_COMM_SELF, Np, 0, 2, &istmp)); 3373157dc65SMatthew G. Knepley PetscCall(ISGetIndices(istmp, &idx)); 3383157dc65SMatthew G. Knepley PetscCall(ISCreateBlock(PETSC_COMM_SELF, dim, Np, idx, PETSC_COPY_VALUES, &isx)); 3393157dc65SMatthew G. Knepley PetscCall(ISRestoreIndices(istmp, &idx)); 3403157dc65SMatthew G. Knepley PetscCall(ISDestroy(&istmp)); 3413157dc65SMatthew G. Knepley PetscCall(ISCreateStride(PETSC_COMM_SELF, Np, 1, 2, &istmp)); 3423157dc65SMatthew G. Knepley PetscCall(ISGetIndices(istmp, &idx)); 3433157dc65SMatthew G. Knepley PetscCall(ISCreateBlock(PETSC_COMM_SELF, dim, Np, idx, PETSC_COPY_VALUES, &isv)); 3443157dc65SMatthew G. Knepley PetscCall(ISRestoreIndices(istmp, &idx)); 3453157dc65SMatthew G. Knepley PetscCall(ISDestroy(&istmp)); 3463157dc65SMatthew G. Knepley PetscCall(TSRHSSplitSetIS(ts, "position", isx)); 3473157dc65SMatthew G. Knepley PetscCall(TSRHSSplitSetIS(ts, "momentum", isv)); 3483157dc65SMatthew G. Knepley PetscCall(ISDestroy(&isx)); 3493157dc65SMatthew G. Knepley PetscCall(ISDestroy(&isv)); 3503157dc65SMatthew G. Knepley PetscCall(TSRHSSplitSetRHSFunction(ts, "position", NULL, RHSFunctionX, user)); 3513157dc65SMatthew G. Knepley PetscCall(TSRHSSplitSetRHSFunction(ts, "momentum", NULL, RHSFunctionV, user)); 3523157dc65SMatthew G. Knepley } 3533157dc65SMatthew G. Knepley // Define symplectic formulation U_t = S . G, where G = grad F 354d71ae5a4SJacob Faibussowitsch { 355d71ae5a4SJacob Faibussowitsch PetscCall(TSDiscGradSetFormulation(ts, RHSJacobianS, RHSObjectiveF, RHSFunctionG, user)); 356d71ae5a4SJacob Faibussowitsch } 35740be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 35840be0ff1SMatthew G. Knepley } 35940be0ff1SMatthew G. Knepley 360d71ae5a4SJacob Faibussowitsch static PetscErrorCode InitializeSolve(TS ts, Vec u) 361d71ae5a4SJacob Faibussowitsch { 3623157dc65SMatthew G. Knepley DM sw; 3633157dc65SMatthew G. Knepley Vec gc, gc0; 3643157dc65SMatthew G. Knepley IS isx, isv; 3653157dc65SMatthew G. Knepley AppCtx *user; 36640be0ff1SMatthew G. Knepley 36740be0ff1SMatthew G. Knepley PetscFunctionBeginUser; 3683157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 3693157dc65SMatthew G. Knepley PetscCall(DMGetApplicationContext(sw, &user)); 3703157dc65SMatthew G. Knepley { 3713157dc65SMatthew G. Knepley PetscReal v0[1] = {1.}; 372db4653c2SDaniel Finn 3733157dc65SMatthew G. Knepley PetscCall(DMSwarmInitializeCoordinates(sw)); 3743157dc65SMatthew G. Knepley PetscCall(DMSwarmInitializeVelocitiesFromOptions(sw, v0)); 3753157dc65SMatthew G. Knepley PetscCall(SetProblem(ts)); 3763157dc65SMatthew G. Knepley } 3773157dc65SMatthew G. Knepley PetscCall(TSRHSSplitGetIS(ts, "position", &isx)); 3783157dc65SMatthew G. Knepley PetscCall(TSRHSSplitGetIS(ts, "momentum", &isv)); 3793157dc65SMatthew G. Knepley PetscCall(DMSwarmCreateGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); 3803157dc65SMatthew G. Knepley PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "initCoordinates", &gc0)); 3813157dc65SMatthew G. Knepley PetscCall(VecCopy(gc, gc0)); 3823157dc65SMatthew G. Knepley PetscCall(VecISCopy(u, isx, SCATTER_FORWARD, gc)); 3833157dc65SMatthew G. Knepley PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); 3843157dc65SMatthew G. Knepley PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "initCoordinates", &gc0)); 3853157dc65SMatthew G. Knepley PetscCall(VecISSet(u, isv, 0.)); 3863157dc65SMatthew G. Knepley PetscFunctionReturn(0); 3873157dc65SMatthew G. Knepley } 3883157dc65SMatthew G. Knepley 389d71ae5a4SJacob Faibussowitsch static PetscErrorCode ComputeError(TS ts, Vec U, Vec E) 390d71ae5a4SJacob Faibussowitsch { 3913157dc65SMatthew G. Knepley MPI_Comm comm; 3923157dc65SMatthew G. Knepley DM sw; 3933157dc65SMatthew G. Knepley AppCtx *user; 3943157dc65SMatthew G. Knepley const PetscScalar *u; 3953157dc65SMatthew G. Knepley const PetscReal *coords; 3963157dc65SMatthew G. Knepley PetscScalar *e; 3973157dc65SMatthew G. Knepley PetscReal t; 3983157dc65SMatthew G. Knepley PetscInt dim, d, Np, p; 3993157dc65SMatthew G. Knepley 4003157dc65SMatthew G. Knepley PetscFunctionBeginUser; 4013157dc65SMatthew G. Knepley PetscCall(PetscObjectGetComm((PetscObject)ts, &comm)); 4023157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 4033157dc65SMatthew G. Knepley PetscCall(DMGetApplicationContext(sw, &user)); 4043157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 4053157dc65SMatthew G. Knepley PetscCall(TSGetSolveTime(ts, &t)); 4063157dc65SMatthew G. Knepley PetscCall(VecGetArray(E, &e)); 4079566063dSJacob Faibussowitsch PetscCall(VecGetArrayRead(U, &u)); 4089566063dSJacob Faibussowitsch PetscCall(VecGetLocalSize(U, &Np)); 4093157dc65SMatthew G. Knepley PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); 4103157dc65SMatthew G. Knepley Np /= 2 * dim; 41140be0ff1SMatthew G. Knepley for (p = 0; p < Np; ++p) { 4123157dc65SMatthew G. Knepley const PetscReal omega = user->omega; 4133157dc65SMatthew G. Knepley const PetscReal ct = PetscCosReal(omega * t); 4143157dc65SMatthew G. Knepley const PetscReal st = PetscSinReal(omega * t); 4153157dc65SMatthew G. Knepley const PetscReal x0 = DMPlex_NormD_Internal(dim, &coords[p * dim]); 4163157dc65SMatthew G. Knepley const PetscReal ex = x0 * ct; 4173157dc65SMatthew G. Knepley const PetscReal ev = -x0 * omega * st; 4183157dc65SMatthew G. Knepley const PetscReal x = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 0) * dim], &coords[p * dim]) / x0; 4193157dc65SMatthew G. Knepley const PetscReal v = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 1) * dim], &coords[p * dim]) / x0; 4203157dc65SMatthew G. Knepley 4213157dc65SMatthew G. Knepley if (user->error) { 4223157dc65SMatthew G. Knepley const PetscReal en = 0.5 * (v * v + PetscSqr(omega) * x * x); 4233157dc65SMatthew G. Knepley const PetscReal exen = 0.5 * PetscSqr(omega * x0); 42463a3b9bcSJacob Faibussowitsch PetscCall(PetscPrintf(comm, "p%" PetscInt_FMT " error [%.2g %.2g] sol [%.6lf %.6lf] exact [%.6lf %.6lf] energy/exact energy %g / %g (%.10lf%%)\n", p, (double)PetscAbsReal(x - ex), (double)PetscAbsReal(v - ev), (double)x, (double)v, (double)ex, (double)ev, (double)en, (double)exen, (double)(PetscAbsReal(exen - en) * 100. / exen))); 4253157dc65SMatthew G. Knepley } 4263157dc65SMatthew G. Knepley for (d = 0; d < dim; ++d) { 4273157dc65SMatthew G. Knepley e[(p * 2 + 0) * dim + d] = u[(p * 2 + 0) * dim + d] - coords[p * dim + d] * ct; 4283157dc65SMatthew G. Knepley e[(p * 2 + 1) * dim + d] = u[(p * 2 + 1) * dim + d] + coords[p * dim + d] * omega * st; 4293157dc65SMatthew G. Knepley } 4303157dc65SMatthew G. Knepley } 4313157dc65SMatthew G. Knepley PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); 4323157dc65SMatthew G. Knepley PetscCall(VecRestoreArrayRead(U, &u)); 4333157dc65SMatthew G. Knepley PetscCall(VecRestoreArray(E, &e)); 4343157dc65SMatthew G. Knepley PetscFunctionReturn(0); 4353157dc65SMatthew G. Knepley } 4363157dc65SMatthew G. Knepley 437d71ae5a4SJacob Faibussowitsch static PetscErrorCode EnergyMonitor(TS ts, PetscInt step, PetscReal t, Vec U, void *ctx) 438d71ae5a4SJacob Faibussowitsch { 4393157dc65SMatthew G. Knepley const PetscReal omega = ((AppCtx *)ctx)->omega; 4403157dc65SMatthew G. Knepley const PetscInt ostep = ((AppCtx *)ctx)->ostep; 4413157dc65SMatthew G. Knepley DM sw; 4423157dc65SMatthew G. Knepley const PetscScalar *u; 4433157dc65SMatthew G. Knepley PetscReal dt; 4443157dc65SMatthew G. Knepley PetscInt dim, Np, p; 4453157dc65SMatthew G. Knepley MPI_Comm comm; 4463157dc65SMatthew G. Knepley 4473157dc65SMatthew G. Knepley PetscFunctionBeginUser; 4483157dc65SMatthew G. Knepley if (step % ostep == 0) { 4493157dc65SMatthew G. Knepley PetscCall(PetscObjectGetComm((PetscObject)ts, &comm)); 4503157dc65SMatthew G. Knepley PetscCall(TSGetDM(ts, &sw)); 4513157dc65SMatthew G. Knepley PetscCall(TSGetTimeStep(ts, &dt)); 4523157dc65SMatthew G. Knepley PetscCall(DMGetDimension(sw, &dim)); 4533157dc65SMatthew G. Knepley PetscCall(VecGetArrayRead(U, &u)); 4543157dc65SMatthew G. Knepley PetscCall(VecGetLocalSize(U, &Np)); 4553157dc65SMatthew G. Knepley Np /= 2 * dim; 4563157dc65SMatthew G. Knepley if (!step) PetscCall(PetscPrintf(comm, "Time Step Part Energy Mod Energy\n")); 4573157dc65SMatthew G. Knepley for (p = 0; p < Np; ++p) { 4583157dc65SMatthew G. Knepley const PetscReal x2 = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 0) * dim], &u[(p * 2 + 0) * dim]); 4593157dc65SMatthew G. Knepley const PetscReal v2 = DMPlex_DotRealD_Internal(dim, &u[(p * 2 + 1) * dim], &u[(p * 2 + 1) * dim]); 4603157dc65SMatthew G. Knepley const PetscReal E = 0.5 * (v2 + PetscSqr(omega) * x2); 4613157dc65SMatthew G. Knepley const PetscReal mE = 0.5 * (v2 + PetscSqr(omega) * x2 - PetscSqr(omega) * dt * PetscSqrtReal(x2 * v2)); 4623157dc65SMatthew G. Knepley 46363a3b9bcSJacob Faibussowitsch PetscCall(PetscPrintf(comm, "%.6lf %4" PetscInt_FMT " %4" PetscInt_FMT " %10.4lf %10.4lf\n", (double)t, step, p, (double)E, (double)mE)); 46440be0ff1SMatthew G. Knepley } 4659566063dSJacob Faibussowitsch PetscCall(VecRestoreArrayRead(U, &u)); 4663157dc65SMatthew G. Knepley } 46740be0ff1SMatthew G. Knepley PetscFunctionReturn(0); 46840be0ff1SMatthew G. Knepley } 46940be0ff1SMatthew G. Knepley 470d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv) 471d71ae5a4SJacob Faibussowitsch { 4723157dc65SMatthew G. Knepley DM dm, sw; 4733157dc65SMatthew G. Knepley TS ts; 4743157dc65SMatthew G. Knepley Vec u; 475c4762a1bSJed Brown AppCtx user; 476c4762a1bSJed Brown 477327415f7SBarry Smith PetscFunctionBeginUser; 4789566063dSJacob Faibussowitsch PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 4793157dc65SMatthew G. Knepley PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); 4803157dc65SMatthew G. Knepley PetscCall(CreateMesh(PETSC_COMM_WORLD, &user, &dm)); 4813157dc65SMatthew G. Knepley PetscCall(CreateSwarm(dm, &user, &sw)); 4829566063dSJacob Faibussowitsch PetscCall(DMSetApplicationContext(sw, &user)); 483c4762a1bSJed Brown 4843157dc65SMatthew G. Knepley PetscCall(TSCreate(PETSC_COMM_WORLD, &ts)); 4859566063dSJacob Faibussowitsch PetscCall(TSSetProblemType(ts, TS_NONLINEAR)); 4869566063dSJacob Faibussowitsch PetscCall(TSSetDM(ts, sw)); 4879566063dSJacob Faibussowitsch PetscCall(TSSetMaxTime(ts, 0.1)); 4889566063dSJacob Faibussowitsch PetscCall(TSSetTimeStep(ts, 0.00001)); 4899566063dSJacob Faibussowitsch PetscCall(TSSetMaxSteps(ts, 100)); 4909566063dSJacob Faibussowitsch PetscCall(TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP)); 4913157dc65SMatthew G. Knepley PetscCall(TSMonitorSet(ts, EnergyMonitor, &user, NULL)); 4929566063dSJacob Faibussowitsch PetscCall(TSSetFromOptions(ts)); 4939566063dSJacob Faibussowitsch PetscCall(TSSetComputeInitialCondition(ts, InitializeSolve)); 4949566063dSJacob Faibussowitsch PetscCall(TSSetComputeExactError(ts, ComputeError)); 49540be0ff1SMatthew G. Knepley 4963157dc65SMatthew G. Knepley PetscCall(CreateSolution(ts)); 4973157dc65SMatthew G. Knepley PetscCall(TSGetSolution(ts, &u)); 4989566063dSJacob Faibussowitsch PetscCall(TSComputeInitialCondition(ts, u)); 4993157dc65SMatthew G. Knepley PetscCall(TSSolve(ts, NULL)); 500c4762a1bSJed Brown 5019566063dSJacob Faibussowitsch PetscCall(TSDestroy(&ts)); 5029566063dSJacob Faibussowitsch PetscCall(DMDestroy(&sw)); 5039566063dSJacob Faibussowitsch PetscCall(DMDestroy(&dm)); 5049566063dSJacob Faibussowitsch PetscCall(PetscFinalize()); 505b122ec5aSJacob Faibussowitsch return 0; 506c4762a1bSJed Brown } 507c4762a1bSJed Brown 508c4762a1bSJed Brown /*TEST 509c4762a1bSJed Brown 510c4762a1bSJed Brown build: 511c4762a1bSJed Brown requires: triangle !single !complex 51240be0ff1SMatthew G. Knepley 5133157dc65SMatthew G. Knepley testset: 5143157dc65SMatthew G. Knepley args: -dm_plex_dim 1 -dm_plex_box_faces 1 -dm_plex_box_lower -1 -dm_plex_box_upper 1 \ 5153157dc65SMatthew G. Knepley -dm_swarm_num_particles 2 -dm_swarm_coordinate_density constant \ 5163157dc65SMatthew G. Knepley -ts_type basicsymplectic -ts_convergence_estimate -convest_num_refine 2 \ 5173157dc65SMatthew G. Knepley -dm_view -output_step 50 -error 518c4762a1bSJed Brown test: 5193157dc65SMatthew G. Knepley suffix: bsi_1 5203157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 1 5213157dc65SMatthew G. Knepley test: 5223157dc65SMatthew G. Knepley suffix: bsi_2 5233157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 2 5243157dc65SMatthew G. Knepley test: 5253157dc65SMatthew G. Knepley suffix: bsi_3 5263157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 3 5273157dc65SMatthew G. Knepley test: 5283157dc65SMatthew G. Knepley suffix: bsi_4 5293157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 4 -ts_dt 0.0001 53040be0ff1SMatthew G. Knepley 5313157dc65SMatthew G. Knepley testset: 5323157dc65SMatthew G. Knepley args: -dm_plex_dim 2 -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -dm_plex_box_lower -1,-1 -dm_plex_box_upper 1,1 \ 5333157dc65SMatthew G. Knepley -dm_swarm_num_particles 2 -dm_swarm_coordinate_density constant \ 5343157dc65SMatthew G. Knepley -ts_type basicsymplectic -ts_convergence_estimate -convest_num_refine 2 \ 5353157dc65SMatthew G. Knepley -dm_view -output_step 50 -error 536c4762a1bSJed Brown test: 5373157dc65SMatthew G. Knepley suffix: bsi_2d_1 5383157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 1 5393157dc65SMatthew G. Knepley test: 5403157dc65SMatthew G. Knepley suffix: bsi_2d_2 5413157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 2 5423157dc65SMatthew G. Knepley test: 5433157dc65SMatthew G. Knepley suffix: bsi_2d_3 5443157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 3 5453157dc65SMatthew G. Knepley test: 5463157dc65SMatthew G. Knepley suffix: bsi_2d_4 5473157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 4 -ts_dt 0.0001 54840be0ff1SMatthew G. Knepley 5493157dc65SMatthew G. Knepley testset: 5503157dc65SMatthew G. Knepley args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -dm_plex_box_lower -1,-1,-1 -dm_plex_box_upper 1,1,1 \ 5513157dc65SMatthew G. Knepley -dm_swarm_num_particles 2 -dm_swarm_coordinate_density constant \ 5523157dc65SMatthew G. Knepley -ts_type basicsymplectic -ts_convergence_estimate -convest_num_refine 2 \ 5533157dc65SMatthew G. Knepley -dm_view -output_step 50 -error 554c4762a1bSJed Brown test: 5553157dc65SMatthew G. Knepley suffix: bsi_3d_1 5563157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 1 5573157dc65SMatthew G. Knepley test: 5583157dc65SMatthew G. Knepley suffix: bsi_3d_2 5593157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 2 5603157dc65SMatthew G. Knepley test: 5613157dc65SMatthew G. Knepley suffix: bsi_3d_3 5623157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 3 5633157dc65SMatthew G. Knepley test: 5643157dc65SMatthew G. Knepley suffix: bsi_3d_4 5653157dc65SMatthew G. Knepley args: -ts_basicsymplectic_type 4 -ts_dt 0.0001 56640be0ff1SMatthew G. Knepley 5673157dc65SMatthew G. Knepley testset: 5683157dc65SMatthew G. Knepley args: -dm_swarm_num_particles 2 -dm_swarm_coordinate_density constant \ 5693157dc65SMatthew G. Knepley -ts_type theta -ts_theta_theta 0.5 -ts_convergence_estimate -convest_num_refine 2 \ 5703157dc65SMatthew G. Knepley -mat_type baij -ksp_error_if_not_converged -pc_type lu \ 5713157dc65SMatthew G. Knepley -dm_view -output_step 50 -error 57240be0ff1SMatthew G. Knepley test: 5733157dc65SMatthew G. Knepley suffix: im_1d 5743157dc65SMatthew G. Knepley args: -dm_plex_dim 1 -dm_plex_box_faces 1 -dm_plex_box_lower -1 -dm_plex_box_upper 1 5753157dc65SMatthew G. Knepley test: 5763157dc65SMatthew G. Knepley suffix: im_2d 5773157dc65SMatthew G. Knepley args: -dm_plex_dim 2 -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -dm_plex_box_lower -1,-1 -dm_plex_box_upper 1,1 5783157dc65SMatthew G. Knepley test: 5793157dc65SMatthew G. Knepley suffix: im_3d 5803157dc65SMatthew G. Knepley args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 1,1,1 -dm_plex_box_lower -1,-1,-1 -dm_plex_box_upper 1,1,1 58140be0ff1SMatthew G. Knepley 5823157dc65SMatthew G. Knepley testset: 5833157dc65SMatthew G. Knepley args: -dm_swarm_num_particles 2 -dm_swarm_coordinate_density constant \ 5843157dc65SMatthew G. Knepley -ts_type discgrad -ts_discgrad_gonzalez -ts_convergence_estimate -convest_num_refine 2 \ 5853157dc65SMatthew G. Knepley -mat_type baij -ksp_error_if_not_converged -pc_type lu \ 5863157dc65SMatthew G. Knepley -dm_view -output_step 50 -error 58740be0ff1SMatthew G. Knepley test: 5883157dc65SMatthew G. Knepley suffix: dg_1d 5893157dc65SMatthew G. Knepley args: -dm_plex_dim 1 -dm_plex_box_faces 1 -dm_plex_box_lower -1 -dm_plex_box_upper 1 590db4653c2SDaniel Finn test: 5913157dc65SMatthew G. Knepley suffix: dg_2d 5923157dc65SMatthew G. Knepley args: -dm_plex_dim 2 -dm_plex_simplex 0 -dm_plex_box_faces 1,1 -dm_plex_box_lower -1,-1 -dm_plex_box_upper 1,1 5933157dc65SMatthew G. Knepley test: 5943157dc65SMatthew G. Knepley suffix: dg_3d 5953157dc65SMatthew G. Knepley args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 1,1,1 -dm_plex_box_lower -1,-1,-1 -dm_plex_box_upper 1,1,1 596c4762a1bSJed Brown 597c4762a1bSJed Brown TEST*/ 598