Lines Matching +full:- +full:- +full:prefix

1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
4 // SPDX-License-Identifier: BSD-2-Clause
8 /// Functions for setting up and performing spanwise-statistics collection
30 user->spanstats.num_comp_stats = TURB_NUM_COMPONENTS; in CreateStatsDM()
34 MPI_Comm comm = PetscObjectComm((PetscObject)user->dm); in CreateStatsDM()
38 if (stage_stats_setup == -1) PetscCall(PetscLogStageRegister("Stats Setup", &stage_stats_setup)); in CreateStatsDM()
42 PetscCall(DMGetBoundingBox(user->dm, domain_min, domain_max)); in CreateStatsDM()
43 user->spanstats.span_width = domain_max[2] - domain_min[2]; in CreateStatsDM()
52 PetscCall(DMPlexGetIsoperiodicFaceSF(user->dm, &num_isoperiodicface, &isoperiodicface)); in CreateStatsDM()
56 PetscInt nleaves, isoperiodicface_index = -1; in CreateStatsDM()
59 …PetscCall(PetscOptionsGetInt(NULL, NULL, "-ts_monitor_turbulence_spanstats_isoperiodic_facesf", &i… in CreateStatsDM()
60 …isoperiodicface_index = isoperiodicface_index == -1 ? num_isoperiodicface - 1 : isoperiodicface_in… in CreateStatsDM()
63 PetscCall(DMCreateLabel(user->dm, "Periodic Face")); in CreateStatsDM()
64 PetscCall(DMGetLabel(user->dm, "Periodic Face", &label)); in CreateStatsDM()
70 PetscCall(DMGetLabel(user->dm, "Face Sets", &label)); in CreateStatsDM()
73 PetscCall(DMPlexLabelComplete(user->dm, label)); in CreateStatsDM()
74 … PetscCall(DMPlexFilter(user->dm, label, 1, PETSC_FALSE, PETSC_FALSE, NULL, &user->spanstats.dm)); in CreateStatsDM()
75 …PetscCall(DMSetCoordinateDisc(user->spanstats.dm, NULL, PETSC_TRUE)); // Ensure that a coordinate… in CreateStatsDM()
77 PetscCall(DMPlexDistribute(user->spanstats.dm, 0, NULL, &parent_distributed_dm)); in CreateStatsDM()
80 PetscCall(DMDestroy(&user->spanstats.dm)); in CreateStatsDM()
81 user->spanstats.dm = parent_distributed_dm; in CreateStatsDM()
88 PetscCall(DMPlexIsSimplex(user->spanstats.dm, &is_simplex)); in CreateStatsDM()
89 …m, PETSC_ERR_ARG_WRONGSTATE, "Spanwise Statistics is not implemented for non-tensor product grids"… in CreateStatsDM()
92 PetscCall(PetscObjectSetName((PetscObject)user->spanstats.dm, "Spanwise_Stats")); in CreateStatsDM()
93 PetscCall(DMSetOptionsPrefix(user->spanstats.dm, "turbulence_spanstats_")); in CreateStatsDM()
94 PetscCall(DMSetFromOptions(user->spanstats.dm)); in CreateStatsDM()
95 PetscCall(DMViewFromOptions(user->spanstats.dm, NULL, "-dm_view")); in CreateStatsDM()
98 …l(DMSetupByOrder_FEM(PETSC_TRUE, PETSC_TRUE, user->app_ctx->degree, 1, user->app_ctx->q_extra, 1, … in CreateStatsDM()
99 user->spanstats.dm)); in CreateStatsDM()
102 PetscCall(DMGetLocalSection(user->spanstats.dm, &section)); in CreateStatsDM()
131 /** @brief Create CeedElemRestriction for collocated data in component-major order.
132 a. Sets the strides of the restriction to component-major order
186 DM dm = user->spanstats.dm; in SpanStatsSetupDataCreate()
187 CeedInt num_comp_x, num_comp_stats = user->spanstats.num_comp_stats; in SpanStatsSetupDataCreate()
195 …Create(ceed, dm, domain_label, label_value, height, dm_field, &(*stats_data)->elem_restr_parent_st… in SpanStatsSetupDataCreate()
196 …CoordinateCreate(ceed, dm, domain_label, label_value, height, &(*stats_data)->elem_restr_parent_x)… in SpanStatsSetupDataCreate()
197 …PetscCallCeed(ceed, CeedElemRestrictionGetNumComponents((*stats_data)->elem_restr_parent_x, &num_c… in SpanStatsSetupDataCreate()
198 …lCeed(ceed, CeedElemRestrictionCreateVector((*stats_data)->elem_restr_parent_x, &(*stats_data)->x_… in SpanStatsSetupDataCreate()
203 …sisFromPlex(ceed, dm_coord, domain_label, label_value, height, dm_field, &(*stats_data)->basis_x)); in SpanStatsSetupDataCreate()
204 …BasisFromPlex(ceed, dm, domain_label, label_value, height, dm_field, &(*stats_data)->basis_stats)); in SpanStatsSetupDataCreate()
207 …eElemRestrColloc_CompMajor(ceed, num_comp_stats, (*stats_data)->basis_stats, (*stats_data)->elem_r… in SpanStatsSetupDataCreate()
208 &(*stats_data)->elem_restr_parent_colloc)); in SpanStatsSetupDataCreate()
209 …PetscCall(CreateElemRestrColloc_CompMajor(ceed, num_comp_stats, ceed_data->basis_q, ceed_data->ele… in SpanStatsSetupDataCreate()
210 &(*stats_data)->elem_restr_child_colloc)); in SpanStatsSetupDataCreate()
212 { // -- Copy DM coordinates into CeedVector in SpanStatsSetupDataCreate()
221 PetscCall(VecScale(X_loc, problem->dm_scale)); in SpanStatsSetupDataCreate()
222 PetscCall(VecCopyPetscToCeed(X_loc, (*stats_data)->x_coord)); in SpanStatsSetupDataCreate()
230 PetscCall(CeedElemRestrictionGetCeed(data->elem_restr_parent_x, &ceed)); in SpanStatsSetupDataDestroy()
231 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&data->elem_restr_parent_x)); in SpanStatsSetupDataDestroy()
232 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&data->elem_restr_parent_stats)); in SpanStatsSetupDataDestroy()
233 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&data->elem_restr_parent_colloc)); in SpanStatsSetupDataDestroy()
234 PetscCallCeed(ceed, CeedElemRestrictionDestroy(&data->elem_restr_child_colloc)); in SpanStatsSetupDataDestroy()
236 PetscCallCeed(ceed, CeedBasisDestroy(&data->basis_x)); in SpanStatsSetupDataDestroy()
237 PetscCallCeed(ceed, CeedBasisDestroy(&data->basis_stats)); in SpanStatsSetupDataDestroy()
239 PetscCallCeed(ceed, CeedVectorDestroy(&data->x_coord)); in SpanStatsSetupDataDestroy()
247 // Create PetscSF for child-to-parent communication
257 PetscCallCeed(ceed, CeedBasisGetNumComponents(ceed_data->basis_x, &num_comp_x)); in CreateStatsSF()
258 …const PetscInt num_comp_sf = num_comp_x - 1; // Number of coord components used in the creation o… in CreateStatsSF()
261 …etscCall(GetQuadratureCoords(ceed, childdm, ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data in CreateStatsSF()
262 …ll(GetQuadratureCoords(ceed, parentdm, stats_data->elem_restr_parent_x, stats_data->basis_x, stats… in CreateStatsSF()
284 …FromCoordinates(*statssf, parent_num_qpnts, child_num_qpnts, num_comp_sf, 1e-12, parent_coords, ch… in CreateStatsSF()
288 PetscCall(PetscSFViewFromOptions(*statssf, NULL, "-spanstats_sf_view")); in CreateStatsSF()
299 CeedInt q_data_size, num_comp_stats = user->spanstats.num_comp_stats; in SetupL2ProjectionStats()
306 // -- Create Operator for RHS of L^2 projection of statistics in SetupL2ProjectionStats()
312 …PetscCallCeed(ceed, CeedOperatorSetField(op_proj_rhs, "input", stats_data->elem_restr_parent_collo… in SetupL2ProjectionStats()
313 …d, CeedOperatorSetField(op_proj_rhs, "output", stats_data->elem_restr_parent_stats, stats_data->ba… in SetupL2ProjectionStats()
315 …scCall(OperatorApplyContextCreate(NULL, user->spanstats.dm, ceed, op_proj_rhs, NULL, NULL, NULL, N… in SetupL2ProjectionStats()
316 …peratorCreateLocalVecs(op_proj_rhs, DMReturnVecType(user->spanstats.dm), PETSC_COMM_SELF, &user->s… in SetupL2ProjectionStats()
317 …ll(QDataGet(ceed, user->spanstats.dm, domain_label, label_value, stats_data->elem_restr_parent_x, … in SetupL2ProjectionStats()
323 …lCeed(ceed, CeedOperatorSetField(op_mass, "u", stats_data->elem_restr_parent_stats, stats_data->ba… in SetupL2ProjectionStats()
325 …lCeed(ceed, CeedOperatorSetField(op_mass, "v", stats_data->elem_restr_parent_stats, stats_data->ba… in SetupL2ProjectionStats()
331 PetscCall(MatCreateCeed(user->spanstats.dm, user->spanstats.dm, op_mass, NULL, &mat_mass)); in SetupL2ProjectionStats()
333 PetscCall(KSPCreate(PetscObjectComm((PetscObject)user->spanstats.dm), &ksp)); in SetupL2ProjectionStats()
342 PetscCall(KSPSetTolerances(ksp, 1e-10, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT)); in SetupL2ProjectionStats()
345 user->spanstats.ksp = ksp; in SetupL2ProjectionStats()
361 …CeedInt num_comp_stats = user->spanstats.num_comp_stats, num_comp_x = problem- in CreateStatisticCollectionOperator()
369 PetscCallCeed(ceed, CeedBasisGetNumComponents(ceed_data->basis_q, &num_comp_q)); in CreateStatisticCollectionOperator()
372 switch (user->phys->state_var) { in CreateStatisticCollectionOperator()
384 if (user->spanstats.do_mms_test) { in CreateStatisticCollectionOperator()
391 …PetscCallCeed(ceed, CeedQFunctionContextGetData(problem->apply_vol_rhs.qfunction_context, CEED_MEM… in CreateStatisticCollectionOperator()
392 collect_ctx->gas = *newtonian_ig_ctx; in CreateStatisticCollectionOperator()
394 PetscCallCeed(ceed, CeedQFunctionContextCreate(user->ceed, &collect_context)); in CreateStatisticCollectionOperator()
404 …PetscCallCeed(ceed, CeedQFunctionContextRestoreData(problem->apply_vol_rhs.qfunction_context, &new… in CreateStatisticCollectionOperator()
410 …PetscCallCeed(ceed, CeedQFunctionAddInput(qf_stats_collect, "q_data", problem->q_data_size_vol, CE… in CreateStatisticCollectionOperator()
415 …eed(ceed, CeedOperatorSetField(op_stats_collect, "q", ceed_data->elem_restr_q, ceed_data->basis_q,… in CreateStatisticCollectionOperator()
416 …peratorSetField(op_stats_collect, "q_data", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data in CreateStatisticCollectionOperator()
417 …CeedOperatorSetField(op_stats_collect, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data in CreateStatisticCollectionOperator()
418 …PetscCallCeed(ceed, CeedOperatorSetField(op_stats_collect, "v", stats_data->elem_restr_child_collo… in CreateStatisticCollectionOperator()
420 …PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_stats_collect, "solution time", &user->spa… in CreateStatisticCollectionOperator()
421 …PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_stats_collect, "previous time", &user->spa… in CreateStatisticCollectionOperator()
423 …PetscCall(OperatorApplyContextCreate(user->dm, user->spanstats.dm, user->ceed, op_stats_collect, u… in CreateStatisticCollectionOperator()
424 &user->spanstats.op_stats_collect_ctx)); in CreateStatisticCollectionOperator()
426 …PetscCall(CeedOperatorCreateLocalVecs(op_stats_collect, DMReturnVecType(user->spanstats.dm), PETSC… in CreateStatisticCollectionOperator()
427 &user->spanstats.Child_Stats_loc)); in CreateStatisticCollectionOperator()
428 PetscCall(VecZeroEntries(user->spanstats.Child_Stats_loc)); in CreateStatisticCollectionOperator()
437 CeedInt num_comp_stats = user->spanstats.num_comp_stats, num_comp_x, q_data_size; in SetupMMSErrorChecking()
447 …ll(QDataGet(ceed, user->spanstats.dm, domain_label, label_value, stats_data->elem_restr_parent_x, … in SetupMMSErrorChecking()
449 PetscCallCeed(ceed, CeedBasisGetNumComponents(stats_data->basis_x, &num_comp_x)); in SetupMMSErrorChecking()
458 …Ceed(ceed, CeedOperatorSetField(op_error, "q", stats_data->elem_restr_parent_stats, stats_data->ba… in SetupMMSErrorChecking()
460 …d, CeedOperatorSetField(op_error, "x", stats_data->elem_restr_parent_x, stats_data->basis_x, stats… in SetupMMSErrorChecking()
461 …Ceed(ceed, CeedOperatorSetField(op_error, "v", stats_data->elem_restr_parent_stats, stats_data->ba… in SetupMMSErrorChecking()
463 …PetscCallCeed(ceed, CeedElemRestrictionCreateVector(stats_data->elem_restr_parent_stats, &x_ceed, … in SetupMMSErrorChecking()
464 …PetscCallCeed(ceed, CeedElemRestrictionCreateVector(stats_data->elem_restr_parent_stats, &y_ceed, … in SetupMMSErrorChecking()
465 …PetscCall(OperatorApplyContextCreate(user->spanstats.dm, user->spanstats.dm, user->ceed, op_error,… in SetupMMSErrorChecking()
466 &user->spanstats.mms_error_ctx)); in SetupMMSErrorChecking()
484 if (stage_stats_setup == -1) PetscCall(PetscLogStageRegister("Stats Setup", &stage_stats_setup)); in TurbulenceStatisticsSetup()
488 PetscCall(CreateStatsDM(user, problem, user->app_ctx->degree)); in TurbulenceStatisticsSetup()
494 …PetscCall(CreateStatsSF(ceed, ceed_data, stats_data, user->dm, user->spanstats.dm, &user->spanstat… in TurbulenceStatisticsSetup()
502 …PetscCall(PetscOptionsGetBool(NULL, NULL, "-ts_monitor_turbulence_spanstats_mms", &user->spanstats… in TurbulenceStatisticsSetup()
503 if (user->spanstats.do_mms_test) { in TurbulenceStatisticsSetup()
507 { // Setup stats viewer with prefix in TurbulenceStatisticsSetup()
509 PetscCall(PetscViewerGetType(user->app_ctx->turb_spanstats_viewer, &viewer_type)); in TurbulenceStatisticsSetup()
510 …PetscCall(PetscOptionsSetValue(NULL, "-ts_monitor_turbulence_spanstats_viewer_type", viewer_type)); in TurbulenceStatisticsSetup()
512 …PetscCall(PetscViewerSetOptionsPrefix(user->app_ctx->turb_spanstats_viewer, "ts_monitor_turbulence… in TurbulenceStatisticsSetup()
513 PetscCall(PetscViewerSetFromOptions(user->app_ctx->turb_spanstats_viewer)); in TurbulenceStatisticsSetup()
523 SpanStatsData user_stats = user->spanstats; in CollectStatistics()
528 …if (stage_stats_collect == -1) PetscCall(PetscLogStageRegister("Stats Collect", &stage_stats_colle… in CollectStatistics()
531 PetscCall(UpdateBoundaryValues(user, user->Q_loc, solution_time)); in CollectStatistics()
532 …PetscCallCeed(user->ceed, CeedOperatorSetContextDouble(user_stats.op_stats_collect_ctx->op, user_s… in CollectStatistics()
533 PetscCall(DMGlobalToLocal(user->dm, Q, INSERT_VALUES, user->Q_loc)); in CollectStatistics()
534 …PetscCall(ApplyAddCeedOperatorLocalToLocal(user->Q_loc, user_stats.Child_Stats_loc, user_stats.op_… in CollectStatistics()
536 …PetscCallCeed(user->ceed, CeedOperatorSetContextDouble(user_stats.op_stats_collect_ctx->op, user_s… in CollectStatistics()
544 SpanStatsData user_stats = user->spanstats; in ProcessStatistics()
553 …if (stage_stats_process == -1) PetscCall(PetscLogStageRegister("Stats Process", &stage_stats_proce… in ProcessStatistics()
576 PetscReal summing_duration = solution_time - user->app_ctx->cont_time; in ProcessStatistics()
595 …PetscInt collect_interval = user->app_ctx->turb_spanstats_collect_interval, viewer_interval = user in TSMonitor_TurbulenceStatistics()
600 if (steps == user->app_ctx->cont_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSMonitor_TurbulenceStatistics()
602 …PetscBool run_processing_and_viewer = (steps % viewer_interval == 0 && viewer_interval != -1) || r… in TSMonitor_TurbulenceStatistics()
608 PetscCall(DMSetOutputSequenceNumber(user->spanstats.dm, steps, solution_time)); in TSMonitor_TurbulenceStatistics()
609 PetscCall(DMGetGlobalVector(user->spanstats.dm, &stats)); in TSMonitor_TurbulenceStatistics()
611 if (user->app_ctx->test_type == TESTTYPE_NONE) { in TSMonitor_TurbulenceStatistics()
612 …PetscCall(PetscViewerPushFormat(user->app_ctx->turb_spanstats_viewer, user->app_ctx->turb_spanstat… in TSMonitor_TurbulenceStatistics()
613 PetscCall(VecView(stats, user->app_ctx->turb_spanstats_viewer)); in TSMonitor_TurbulenceStatistics()
614 PetscCall(PetscViewerPopFormat(user->app_ctx->turb_spanstats_viewer)); in TSMonitor_TurbulenceStatistics()
616 if (user->app_ctx->test_type == TESTTYPE_TURB_SPANSTATS && reason != TS_CONVERGED_ITERATING) { in TSMonitor_TurbulenceStatistics()
617 PetscCall(RegressionTest(user->app_ctx, stats)); in TSMonitor_TurbulenceStatistics()
619 if (user->spanstats.do_mms_test && reason != TS_CONVERGED_ITERATING) { in TSMonitor_TurbulenceStatistics()
622 PetscCall(ApplyCeedOperatorGlobalToGlobal(stats, error, user->spanstats.mms_error_ctx)); in TSMonitor_TurbulenceStatistics()
628 PetscCall(DMRestoreGlobalVector(user->spanstats.dm, &stats)); in TSMonitor_TurbulenceStatistics()
636 PetscCall(VecDestroy(&user->spanstats.Child_Stats_loc)); in TurbulenceStatisticsDestroy()
637 PetscCall(VecDestroy(&user->spanstats.Parent_Stats_loc)); in TurbulenceStatisticsDestroy()
639 PetscCall(OperatorApplyContextDestroy(user->spanstats.op_stats_collect_ctx)); in TurbulenceStatisticsDestroy()
640 PetscCall(OperatorApplyContextDestroy(user->spanstats.op_proj_rhs_ctx)); in TurbulenceStatisticsDestroy()
641 PetscCall(OperatorApplyContextDestroy(user->spanstats.mms_error_ctx)); in TurbulenceStatisticsDestroy()
643 PetscCall(KSPDestroy(&user->spanstats.ksp)); in TurbulenceStatisticsDestroy()
644 PetscCall(PetscSFDestroy(&user->spanstats.sf)); in TurbulenceStatisticsDestroy()
645 PetscCall(DMDestroy(&user->spanstats.dm)); in TurbulenceStatisticsDestroy()