Lines Matching refs:honee
18 PetscErrorCode UpdateBoundaryValues(Honee honee, Vec Q_loc, PetscReal t) { in UpdateBoundaryValues() argument
20 if (honee->time_bc_set != t) { in UpdateBoundaryValues()
21 PetscCall(DMPlexInsertBoundaryValues(honee->dm, PETSC_TRUE, Q_loc, t, NULL, NULL, NULL)); in UpdateBoundaryValues()
22 honee->time_bc_set = t; in UpdateBoundaryValues()
31 Honee honee = *(Honee *)user_data; in RHS_NS() local
32 Ceed ceed = honee->ceed; in RHS_NS()
34 Vec Q_loc = honee->Q_loc, R; in RHS_NS()
39 PetscCall(UpdateBoundaryValues(honee, Q_loc, t)); in RHS_NS()
40 if (honee->phys->solution_time_label) in RHS_NS()
41 …PetscCallCeed(ceed, CeedOperatorSetContextDouble(honee->op_rhs_ctx->op, honee->phys->solution_time… in RHS_NS()
43 if (honee->phys->timestep_size_label) in RHS_NS()
44 …PetscCallCeed(ceed, CeedOperatorSetContextDouble(honee->op_rhs_ctx->op, honee->phys->timestep_size… in RHS_NS()
46 PetscCall(DMGetNamedGlobalVector(honee->dm, "RHS Residual", &R)); in RHS_NS()
47 PetscCall(DMGlobalToLocal(honee->dm, Q, INSERT_VALUES, Q_loc)); in RHS_NS()
48 …if (honee->app_ctx->divFdiffproj_method != DIV_DIFF_FLUX_PROJ_NONE) PetscCall(DivDiffFluxProjectio… in RHS_NS()
49 PetscCall(ApplyCeedOperatorLocalToGlobal(Q_loc, R, honee->op_rhs_ctx)); in RHS_NS()
52 PetscCall(VecReadPetscToCeed(Q_loc, &q_mem_type, honee->q_ceed)); in RHS_NS()
59 PetscCall(KSPGetPC(honee->mass_ksp, &pc)); in RHS_NS()
60 PetscCall(PetscObjectTypeCompare((PetscObject)honee->mass_ksp, KSPPREONLY, &ispreonly)); in RHS_NS()
63 else PetscCall(KSPSolve(honee->mass_ksp, R, G)); in RHS_NS()
65 PetscCall(VecReadCeedToPetsc(honee->q_ceed, q_mem_type, Q_loc)); in RHS_NS()
67 PetscCall(DMRestoreNamedGlobalVector(honee->dm, "RHS Residual", &R)); in RHS_NS()
117 Honee honee = *(Honee *)user_data; in IFunction_NS() local
118 Ceed ceed = honee->ceed; in IFunction_NS()
120 Vec Q_loc = honee->Q_loc, Q_dot_loc = honee->Q_dot_loc, G_loc; in IFunction_NS()
124 PetscCall(DMGlobalToLocalBegin(honee->dm, Q_dot, INSERT_VALUES, Q_dot_loc)); in IFunction_NS()
125 PetscCall(DMGetNamedLocalVector(honee->dm, "ResidualLocal", &G_loc)); in IFunction_NS()
128 PetscCall(UpdateBoundaryValues(honee, Q_loc, t)); in IFunction_NS()
129 …if (honee->phys->solution_time_label) PetscCallCeed(ceed, CeedOperatorSetContextDouble(honee->op_i… in IFunction_NS()
131 …if (honee->phys->timestep_size_label) PetscCallCeed(ceed, CeedOperatorSetContextDouble(honee->op_i… in IFunction_NS()
134 PetscCall(DMGlobalToLocalBegin(honee->dm, Q, INSERT_VALUES, Q_loc)); in IFunction_NS()
135 PetscCall(DMGlobalToLocalEnd(honee->dm, Q, INSERT_VALUES, Q_loc)); in IFunction_NS()
136 …if (honee->app_ctx->divFdiffproj_method != DIV_DIFF_FLUX_PROJ_NONE) PetscCall(DivDiffFluxProjectio… in IFunction_NS()
137 PetscCall(DMGlobalToLocalEnd(honee->dm, Q_dot, INSERT_VALUES, Q_dot_loc)); in IFunction_NS()
140 PetscCall(VecReadPetscToCeed(Q_loc, &q_mem_type, honee->q_ceed)); in IFunction_NS()
141 PetscCall(VecReadPetscToCeed(Q_dot_loc, &q_dot_mem_type, honee->q_dot_ceed)); in IFunction_NS()
142 PetscCall(VecPetscToCeed(G_loc, &g_mem_type, honee->g_ceed)); in IFunction_NS()
147 …PetscCallCeed(honee->ceed, CeedOperatorApply(honee->op_ifunction, honee->q_ceed, honee->g_ceed, CE… in IFunction_NS()
152 PetscCall(VecReadCeedToPetsc(honee->q_ceed, q_mem_type, Q_loc)); in IFunction_NS()
153 PetscCall(VecReadCeedToPetsc(honee->q_dot_ceed, q_dot_mem_type, Q_dot_loc)); in IFunction_NS()
154 PetscCall(VecCeedToPetsc(honee->g_ceed, g_mem_type, G_loc)); in IFunction_NS()
156 if (honee->app_ctx->sgs_model_type == SGS_MODEL_DATA_DRIVEN) { in IFunction_NS()
157 PetscCall(SgsDDApplyIFunction(honee, Q_loc, G_loc)); in IFunction_NS()
162 PetscCall(DMLocalToGlobal(honee->dm, G_loc, ADD_VALUES, G)); in IFunction_NS()
165 PetscCall(DMRestoreNamedLocalVector(honee->dm, "ResidualLocal", &G_loc)); in IFunction_NS()
170 Honee honee = *(Honee *)user_data; in FormIJacobian_NS() local
179 PetscCall(MatCeedSetContextReal(honee->mat_ijacobian, "ijacobian time shift", shift)); in FormIJacobian_NS()
184 } else PetscCall(MatCeedAssembleCOO(honee->mat_ijacobian, J)); in FormIJacobian_NS()
190 PetscCall(MatCeedAssembleCOO(honee->mat_ijacobian, J_pre)); in FormIJacobian_NS()
195 PetscErrorCode WriteOutput(Honee honee, Vec Q, PetscInt step_no, PetscScalar time) { in WriteOutput() argument
201 if (honee->app_ctx->checkpoint_vtk) { in WriteOutput()
203 PetscCall(DMGetLocalVector(honee->dm, &Q_loc)); in WriteOutput()
206 PetscCall(DMGlobalToLocal(honee->dm, Q, INSERT_VALUES, Q_loc)); in WriteOutput()
209 …PetscCall(PetscSNPrintf(file_path, sizeof file_path, "%s/ns-%03" PetscInt_FMT ".vtu", honee->app_c… in WriteOutput()
214 if (honee->dm_viz) { in WriteOutput()
219 PetscCall(DMGetGlobalVector(honee->dm_viz, &Q_refined)); in WriteOutput()
220 PetscCall(DMGetLocalVector(honee->dm_viz, &Q_refined_loc)); in WriteOutput()
223 PetscCall(MatInterpolate(honee->interp_viz, Q, Q_refined)); in WriteOutput()
225 PetscCall(DMGlobalToLocal(honee->dm_viz, Q_refined, INSERT_VALUES, Q_refined_loc)); in WriteOutput()
227 …efined, sizeof file_path_refined, "%s/nsrefined-%03" PetscInt_FMT ".vtu", honee->app_ctx->output_d… in WriteOutput()
232 PetscCall(DMRestoreLocalVector(honee->dm_viz, &Q_refined_loc)); in WriteOutput()
233 PetscCall(DMRestoreGlobalVector(honee->dm_viz, &Q_refined)); in WriteOutput()
236 PetscCall(DMRestoreLocalVector(honee->dm, &Q_loc)); in WriteOutput()
240 if (honee->app_ctx->add_stepnum2bin) { in WriteOutput()
241 …intf(file_path, sizeof file_path, "%s/ns-solution-%" PetscInt_FMT ".bin", honee->app_ctx->output_d… in WriteOutput()
243 …PetscCall(PetscSNPrintf(file_path, sizeof file_path, "%s/ns-solution.bin", honee->app_ctx->output_… in WriteOutput()
245 PetscCall(PetscViewerBinaryOpen(honee->comm, file_path, FILE_MODE_WRITE, &viewer)); in WriteOutput()
247 time /= honee->units->second; // Dimensionalize time back in WriteOutput()
255 Honee honee = ctx; in TSMonitor_WallForce() local
257 PetscInt num_wall = honee->app_ctx->wall_forces.num_wall, dim = 3; in TSMonitor_WallForce()
258 const PetscInt *walls = honee->app_ctx->wall_forces.walls; in TSMonitor_WallForce()
259 PetscViewer viewer = honee->app_ctx->wall_forces.viewer; in TSMonitor_WallForce()
260 PetscViewerFormat format = honee->app_ctx->wall_forces.viewer_format; in TSMonitor_WallForce()
266 PetscCall(DMGetNamedLocalVector(honee->dm, "ResidualLocal", &G_loc)); in TSMonitor_WallForce()
268 PetscCall(Surface_Forces_NS(honee->dm, G_loc, num_wall, walls, reaction_force)); in TSMonitor_WallForce()
269 PetscCall(DMRestoreNamedLocalVector(honee->dm, "ResidualLocal", &G_loc)); in TSMonitor_WallForce()
274 if (format == PETSC_VIEWER_ASCII_CSV && !honee->app_ctx->wall_forces.header_written) { in TSMonitor_WallForce()
276 honee->app_ctx->wall_forces.header_written = PETSC_TRUE; in TSMonitor_WallForce()
296 Honee honee = ctx; in TSMonitor_NS() local
300 …if (honee->app_ctx->checkpoint_interval <= 0 || step_no % honee->app_ctx->checkpoint_interval != 0… in TSMonitor_NS()
301 (honee->app_ctx->cont_steps == step_no && step_no != 0)) { in TSMonitor_NS()
305 PetscCall(WriteOutput(honee, Q, step_no, time)); in TSMonitor_NS()
310 Honee honee; in TSPostStep_CheckStep() local
316 PetscCall(TSGetApplicationContext(ts, &honee)); in TSPostStep_CheckStep()
319 if (step % honee->app_ctx->check_step_interval) PetscFunctionReturn(PETSC_SUCCESS); in TSPostStep_CheckStep()
329 Honee honee; in TSPostStep_MaxWallTime() local
336 PetscCall(TSGetApplicationContext(ts, &honee)); in TSPostStep_MaxWallTime()
338 if (step % honee->max_wall_time_interval) PetscFunctionReturn(PETSC_SUCCESS); in TSPostStep_MaxWallTime()
341 …if (rank == 0) is_wall_time_exceeded = time(NULL) > honee->max_wall_time ? PETSC_TRUE : PETSC_FALS… in TSPostStep_MaxWallTime()
360 Honee honee; in TSPostStep_Honee() local
363 PetscCall(TSGetApplicationContext(ts, &honee)); in TSPostStep_Honee()
364 if (honee->max_wall_time > 0) PetscCall(TSPostStep_MaxWallTime(ts)); in TSPostStep_Honee()
365 if (honee->app_ctx->sgs_train_enable) PetscCall(TSPostStep_SGS_DD_Training(ts)); in TSPostStep_Honee()
366 if (honee->app_ctx->check_step_interval > 0) PetscCall(TSPostStep_CheckStep(ts)); in TSPostStep_Honee()
410 PetscErrorCode TSSolve_NS(DM dm, Honee honee, AppCtx app_ctx, Physics phys, ProblemData problem, Ve… in TSSolve_NS() argument
411 MPI_Comm comm = honee->comm; in TSSolve_NS()
418 PetscCall(TSSetApplicationContext(*ts, honee)); in TSSolve_NS()
421 if (honee->op_ifunction) { in TSSolve_NS()
422 PetscCall(TSSetIFunction(*ts, NULL, IFunction_NS, &honee)); in TSSolve_NS()
424 PetscCall(TSSetRHSFunction(*ts, NULL, RHS_NS, &honee)); in TSSolve_NS()
426 if (honee->mat_ijacobian) { in TSSolve_NS()
427 PetscCall(DMTSSetIJacobian(dm, FormIJacobian_NS, &honee)); in TSSolve_NS()
430 PetscCheck(honee->op_rhs_ctx, comm, PETSC_ERR_ARG_NULL, "Problem does not provide RHSFunction"); in TSSolve_NS()
433 PetscCall(TSSetRHSFunction(*ts, NULL, RHS_NS, &honee)); in TSSolve_NS()
435 PetscCall(TSSetMaxTime(*ts, 500. * honee->units->second)); in TSSolve_NS()
438 PetscCall(TSSetTimeStep(*ts, 1.e-2 * honee->units->second)); in TSSolve_NS()
440 …PetscCall(TSAdaptSetStepLimits(adapt, 1.e-12 * honee->units->second, 1.e2 * honee->units->second)); in TSSolve_NS()
442 if (honee->mat_ijacobian) { in TSSolve_NS()
450 … PetscCall(CreateSolveOperatorsFromMatCeed(ksp, honee->mat_ijacobian, PETSC_FALSE, &Amat, &Pmat)); in TSSolve_NS()
451 PetscCall(TSSetIJacobian(*ts, honee->mat_ijacobian, Pmat, NULL, NULL)); in TSSolve_NS()
456 honee->time_bc_set = -1.0; // require all BCs be updated in TSSolve_NS()
458 PetscCall(TSSetTime(*ts, app_ctx->cont_time * honee->units->second)); in TSSolve_NS()
473 if (honee->set_poststep) PetscCall(TSSetPostStep(*ts, TSPostStep_Honee)); in TSSolve_NS()
474 if (app_ctx->test_type == TESTTYPE_NONE) PetscCall(TSMonitorSet(*ts, TSMonitor_NS, honee, NULL)); in TSSolve_NS()
475 if (app_ctx->wall_forces.viewer) PetscCall(TSMonitorSet(*ts, TSMonitor_WallForce, honee, NULL)); in TSSolve_NS()
495 …if (app_ctx->sgs_train_enable) PetscCall(TSMonitorSet(*ts, TSMonitor_SGS_DD_Training, honee, NULL)… in TSSolve_NS()
497 …if (app_ctx->test_type == TESTTYPE_NONE) PetscCall(PrintRunInfo(honee, honee->phys, problem, *ts)); in TSSolve_NS()
498 …if (honee->mass_ksp) PetscCall(KSPViewFromOptions(honee->mass_ksp, NULL, "-ksp_view_pre_ts_solve")… in TSSolve_NS()
545 if (honee->app_ctx->checkpoint_interval > 0 || honee->app_ctx->checkpoint_interval == -1) { in TSSolve_NS()
546 PetscCall(WriteOutput(honee, Q, step_no, final_time)); in TSSolve_NS()