diff --git a/examples/fluids/navierstokes.c b/examples/fluids/navierstokes.c index 919ff16669..6f424034b7 100644 --- a/examples/fluids/navierstokes.c +++ b/examples/fluids/navierstokes.c @@ -229,9 +229,6 @@ int main(int argc, char **argv) { PetscCall(SetupICsFromBinary(comm, app_ctx, Q)); } - // Print problem summary - if (app_ctx->test_type == TESTTYPE_NONE) PetscCall(PrintRunInfo(user, phys_ctx, problem, comm)); - // -- Zero Q_loc PetscCall(VecZeroEntries(user->Q_loc)); @@ -240,7 +237,7 @@ int main(int argc, char **argv) { // --------------------------------------------------------------------------- TS ts; PetscScalar final_time; - PetscCall(TSSolve_NS(dm, user, app_ctx, phys_ctx, &Q, &final_time, &ts)); + PetscCall(TSSolve_NS(dm, user, app_ctx, phys_ctx, problem, &Q, &final_time, &ts)); // --------------------------------------------------------------------------- // Post-processing diff --git a/examples/fluids/navierstokes.h b/examples/fluids/navierstokes.h index f27c410bd1..75dc8a57fd 100644 --- a/examples/fluids/navierstokes.h +++ b/examples/fluids/navierstokes.h @@ -322,7 +322,7 @@ extern PetscErrorCode PRINT_ADVECTION(User user, ProblemData problem, AppCtx app extern PetscErrorCode PRINT_ADVECTION2D(User user, ProblemData problem, AppCtx app_ctx); -PetscErrorCode PrintRunInfo(User user, Physics phys_ctx, ProblemData problem, MPI_Comm comm); +PetscErrorCode PrintRunInfo(User user, Physics phys_ctx, ProblemData problem, TS ts); // ----------------------------------------------------------------------------- // libCEED functions @@ -363,7 +363,7 @@ PetscErrorCode IFunction_NS(TS ts, PetscReal t, Vec Q, Vec Q_dot, Vec G, void *u PetscErrorCode TSMonitor_NS(TS ts, PetscInt step_no, PetscReal time, Vec Q, void *ctx); // TS: Create, setup, and solve -PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q, PetscScalar *f_time, TS *ts); +PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, ProblemData problem, Vec *Q, PetscScalar *f_time, TS *ts); // Update Boundary Values when time has changed PetscErrorCode UpdateBoundaryValues(User user, Vec Q_loc, PetscReal t); diff --git a/examples/fluids/src/misc.c b/examples/fluids/src/misc.c index 5bbdd98379..33066ab152 100644 --- a/examples/fluids/src/misc.c +++ b/examples/fluids/src/misc.c @@ -391,8 +391,10 @@ PetscErrorCode RegisterLogEvents() { } // Print information about the given simulation run -PetscErrorCode PrintRunInfo(User user, Physics phys_ctx, ProblemData problem, MPI_Comm comm) { - Ceed ceed = user->ceed; +PetscErrorCode PrintRunInfo(User user, Physics phys_ctx, ProblemData problem, TS ts) { + Ceed ceed = user->ceed; + MPI_Comm comm = PetscObjectComm((PetscObject)ts); + PetscFunctionBeginUser; // Header and rank char host_name[PETSC_MAX_PATH_LEN]; @@ -421,22 +423,43 @@ PetscErrorCode PrintRunInfo(User user, Physics phys_ctx, ProblemData problem, MP " libCEED Backend MemType : %s\n", used_resource, CeedMemTypes[mem_type_backend])); // PETSc - char box_faces_str[PETSC_MAX_PATH_LEN] = "3,3,3"; + VecType vec_type; + char box_faces_str[PETSC_MAX_PATH_LEN] = "3,3,3"; if (problem->dim == 2) box_faces_str[3] = '\0'; PetscCall(PetscOptionsGetString(NULL, NULL, "-dm_plex_box_faces", box_faces_str, sizeof(box_faces_str), NULL)); - MatType amat_type = user->app_ctx->amat_type, pmat_type; - VecType vec_type; - PetscCall(DMGetMatType(user->dm, &pmat_type)); - if (!amat_type) amat_type = pmat_type; PetscCall(DMGetVecType(user->dm, &vec_type)); PetscCall(PetscPrintf(comm, " PETSc:\n" " Box Faces : %s\n" - " A MatType : %s\n" - " P MatType : %s\n" " DM VecType : %s\n" " Time Stepping Scheme : %s\n", - box_faces_str, amat_type, pmat_type, vec_type, phys_ctx->implicit ? "implicit" : "explicit")); + box_faces_str, vec_type, phys_ctx->implicit ? "implicit" : "explicit")); + { + char pmat_type_str[PETSC_MAX_PATH_LEN]; + MatType amat_type, pmat_type; + Mat Amat, Pmat; + TSIJacobianFn *ijacob_function; + + PetscCall(TSGetIJacobian(ts, &Amat, &Pmat, &ijacob_function, NULL)); + PetscCall(MatGetType(Amat, &amat_type)); + PetscCall(MatGetType(Pmat, &pmat_type)); + + PetscCall(PetscStrncpy(pmat_type_str, pmat_type, sizeof(pmat_type_str))); + if (!strcmp(pmat_type, MATCEED)) { + MatType pmat_coo_type; + char pmat_coo_type_str[PETSC_MAX_PATH_LEN]; + + PetscCall(MatCeedGetCOOMatType(Pmat, &pmat_coo_type)); + PetscCall(PetscSNPrintf(pmat_coo_type_str, sizeof(pmat_coo_type_str), " (COO MatType: %s)", pmat_coo_type)); + PetscCall(PetscStrlcat(pmat_type_str, pmat_coo_type_str, sizeof(pmat_type_str))); + } + if (ijacob_function) { + PetscCall(PetscPrintf(comm, + " IJacobian A MatType : %s\n" + " IJacobian P MatType : %s\n", + amat_type, pmat_type_str)); + } + } if (user->app_ctx->cont_steps) { PetscCall(PetscPrintf(comm, " Continue:\n" diff --git a/examples/fluids/src/petsc_ops.c b/examples/fluids/src/petsc_ops.c index b74c20a73f..398796f33b 100644 --- a/examples/fluids/src/petsc_ops.c +++ b/examples/fluids/src/petsc_ops.c @@ -338,7 +338,7 @@ PetscErrorCode CreateSolveOperatorsFromMatCeed(KSP ksp, Mat mat_ceed, PetscBool PetscCall(KSPGetPC(ksp, &pc)); PetscCall(PCGetType(pc, &pc_type)); - PetscCall(PetscStrcmpAny(pc_type, &use_matceed_pmat, PCJACOBI, PCVPBJACOBI, PCPBJACOBI, "")); + PetscCall(PetscStrcmpAny(pc_type, &use_matceed_pmat, PCNONE, PCJACOBI, PCVPBJACOBI, PCPBJACOBI, "")); } if (use_matceed_pmat) { diff --git a/examples/fluids/src/setupts.c b/examples/fluids/src/setupts.c index 5549c579f2..8ed11e10c0 100644 --- a/examples/fluids/src/setupts.c +++ b/examples/fluids/src/setupts.c @@ -298,7 +298,7 @@ PetscErrorCode TSMonitor_NS(TS ts, PetscInt step_no, PetscReal time, Vec Q, void } // TS: Create, setup, and solve -PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q, PetscScalar *f_time, TS *ts) { +PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, ProblemData problem, Vec *Q, PetscScalar *f_time, TS *ts) { MPI_Comm comm = user->comm; TSAdapt adapt; PetscScalar final_time; @@ -377,6 +377,8 @@ PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q PetscCall(TSMonitorSet(*ts, TSMonitor_SGS_DD_Training, user, NULL)); PetscCall(TSSetPostStep(*ts, TSPostStep_SGS_DD_Training)); } + + if (app_ctx->test_type == TESTTYPE_NONE) PetscCall(PrintRunInfo(user, user->phys, problem, *ts)); // Solve PetscReal start_time; PetscInt start_step;