13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 377841947SLeila Ghaffari // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 577841947SLeila Ghaffari // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 777841947SLeila Ghaffari 877841947SLeila Ghaffari /// @file 977841947SLeila Ghaffari /// Setup libCEED for Navier-Stokes example using PETSc 1077841947SLeila Ghaffari 1149aac155SJeremy L Thompson #include <ceed.h> 1249aac155SJeremy L Thompson #include <petscdmplex.h> 1349aac155SJeremy L Thompson 1477841947SLeila Ghaffari #include "../navierstokes.h" 1577841947SLeila Ghaffari 16431cd09aSJames Wright PetscErrorCode AddBCSubOperator(Ceed ceed, DM dm, CeedData ceed_data, DMLabel domain_label, PetscInt label_value, CeedInt height, CeedInt Q_sur, 172b730f8bSJeremy L Thompson CeedInt q_data_size_sur, CeedInt jac_data_size_sur, CeedQFunction qf_apply_bc, CeedQFunction qf_apply_bc_jacobian, 189eb9c072SJames Wright CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 199eb9c072SJames Wright CeedVector q_data_sur, jac_data_sur; 202b730f8bSJeremy L Thompson CeedOperator op_setup_sur, op_apply_bc, op_apply_bc_jacobian = NULL; 212b730f8bSJeremy L Thompson CeedElemRestriction elem_restr_x_sur, elem_restr_q_sur, elem_restr_qd_i_sur, elem_restr_jd_i_sur; 229eb9c072SJames Wright CeedInt num_qpts_sur; 239eb9c072SJames Wright 24*f17d818dSJames Wright PetscFunctionBeginUser; 259eb9c072SJames Wright // --- Get number of quadrature points for the boundaries 26a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisGetNumQuadraturePoints(ceed_data->basis_q_sur, &num_qpts_sur)); 279eb9c072SJames Wright 289eb9c072SJames Wright // ---- CEED Restriction 290814d5a7SKenneth E. Jansen PetscCall(GetRestrictionForDomain(ceed, dm, height, domain_label, label_value, 0, num_qpts_sur, q_data_size_sur, &elem_restr_q_sur, 300814d5a7SKenneth E. Jansen &elem_restr_x_sur, &elem_restr_qd_i_sur)); 319eb9c072SJames Wright if (jac_data_size_sur > 0) { 329eb9c072SJames Wright // State-dependent data will be passed from residual to Jacobian. This will be collocated. 330814d5a7SKenneth E. Jansen PetscCall( 340814d5a7SKenneth E. Jansen GetRestrictionForDomain(ceed, dm, height, domain_label, label_value, 0, num_qpts_sur, jac_data_size_sur, NULL, NULL, &elem_restr_jd_i_sur)); 35a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i_sur, &jac_data_sur, NULL)); 369eb9c072SJames Wright } else { 379eb9c072SJames Wright elem_restr_jd_i_sur = NULL; 389eb9c072SJames Wright jac_data_sur = NULL; 399eb9c072SJames Wright } 409eb9c072SJames Wright 419eb9c072SJames Wright // ---- CEED Vector 42457e73b2SJames Wright CeedInt loc_num_elem_sur; 43a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionGetNumElements(elem_restr_q_sur, &loc_num_elem_sur)); 44a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorCreate(ceed, q_data_size_sur * loc_num_elem_sur * num_qpts_sur, &q_data_sur)); 459eb9c072SJames Wright 469eb9c072SJames Wright // ---- CEED Operator 479eb9c072SJames Wright // ----- CEED Operator for Setup (geometric factors) 48a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_sur, NULL, NULL, &op_setup_sur)); 49a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "dx", elem_restr_x_sur, ceed_data->basis_x_sur, CEED_VECTOR_ACTIVE)); 50a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x_sur, CEED_VECTOR_NONE)); 51a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE)); 529eb9c072SJames Wright 539eb9c072SJames Wright // ----- CEED Operator for Physics 54a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc, NULL, NULL, &op_apply_bc)); 55a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 56a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "Grad_q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 57a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, q_data_sur)); 58a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 59a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 60a424bcd0SJames Wright if (elem_restr_jd_i_sur) 61a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_COLLOCATED, jac_data_sur)); 629eb9c072SJames Wright 639eb9c072SJames Wright if (qf_apply_bc_jacobian) { 64a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc_jacobian, NULL, NULL, &op_apply_bc_jacobian)); 65a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 66a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "Grad_dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 67a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, q_data_sur)); 68a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 69a424bcd0SJames Wright PetscCallCeed(ceed, 70a424bcd0SJames Wright CeedOperatorSetField(op_apply_bc_jacobian, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_COLLOCATED, jac_data_sur)); 71a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 729eb9c072SJames Wright } 739eb9c072SJames Wright 749eb9c072SJames Wright // ----- Apply CEED operator for Setup 75a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorApply(op_setup_sur, ceed_data->x_coord, q_data_sur, CEED_REQUEST_IMMEDIATE)); 769eb9c072SJames Wright 779eb9c072SJames Wright // ----- Apply Sub-Operator for Physics 78a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_bc)); 79a424bcd0SJames Wright if (op_apply_bc_jacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_bc_jacobian)); 809eb9c072SJames Wright 819eb9c072SJames Wright // ----- Cleanup 82a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&q_data_sur)); 83a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data_sur)); 84a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_q_sur)); 85a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_x_sur)); 86a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_qd_i_sur)); 87a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i_sur)); 88a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_setup_sur)); 89a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc)); 90a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc_jacobian)); 91ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 929eb9c072SJames Wright } 939eb9c072SJames Wright 9477841947SLeila Ghaffari // Utility function to create CEED Composite Operator for the entire domain 952b730f8bSJeremy L Thompson PetscErrorCode CreateOperatorForDomain(Ceed ceed, DM dm, SimpleBC bc, CeedData ceed_data, Physics phys, CeedOperator op_apply_vol, 962b730f8bSJeremy L Thompson CeedOperator op_apply_ijacobian_vol, CeedInt height, CeedInt P_sur, CeedInt Q_sur, CeedInt q_data_size_sur, 972b730f8bSJeremy L Thompson CeedInt jac_data_size_sur, CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 9877841947SLeila Ghaffari DMLabel domain_label; 9977841947SLeila Ghaffari 100*f17d818dSJames Wright PetscFunctionBeginUser; 10177841947SLeila Ghaffari // Create Composite Operaters 102a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply)); 103a424bcd0SJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply_ijacobian)); 10477841947SLeila Ghaffari 10577841947SLeila Ghaffari // --Apply Sub-Operator for the volume 106a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_vol)); 107a424bcd0SJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_ijacobian_vol)); 10877841947SLeila Ghaffari 10977841947SLeila Ghaffari // -- Create Sub-Operator for in/outflow BCs 11088626eedSJames Wright if (phys->has_neumann || 1) { 11177841947SLeila Ghaffari // --- Setup 1122b730f8bSJeremy L Thompson PetscCall(DMGetLabel(dm, "Face Sets", &domain_label)); 11377841947SLeila Ghaffari 1142fe7aee7SLeila Ghaffari // --- Create Sub-Operator for inflow boundaries 1152fe7aee7SLeila Ghaffari for (CeedInt i = 0; i < bc->num_inflow; i++) { 1162b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->inflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1172b730f8bSJeremy L Thompson ceed_data->qf_apply_inflow, ceed_data->qf_apply_inflow_jacobian, op_apply, op_apply_ijacobian)); 11877841947SLeila Ghaffari } 1192fe7aee7SLeila Ghaffari // --- Create Sub-Operator for outflow boundaries 1202fe7aee7SLeila Ghaffari for (CeedInt i = 0; i < bc->num_outflow; i++) { 1212b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->outflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1222b730f8bSJeremy L Thompson ceed_data->qf_apply_outflow, ceed_data->qf_apply_outflow_jacobian, op_apply, op_apply_ijacobian)); 12339c69132SJed Brown } 124f4ca79c2SJames Wright // --- Create Sub-Operator for freestream boundaries 125f4ca79c2SJames Wright for (CeedInt i = 0; i < bc->num_freestream; i++) { 1262b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->freestreams[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1272b730f8bSJeremy L Thompson ceed_data->qf_apply_freestream, ceed_data->qf_apply_freestream_jacobian, op_apply, op_apply_ijacobian)); 1282fe7aee7SLeila Ghaffari } 1292fe7aee7SLeila Ghaffari } 13011436a05SJames Wright 13111436a05SJames Wright // ----- Get Context Labels for Operator 132a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "solution time", &phys->solution_time_label)); 133a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "timestep size", &phys->timestep_size_label)); 134ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 13577841947SLeila Ghaffari } 13677841947SLeila Ghaffari 1372b730f8bSJeremy L Thompson PetscErrorCode SetupBCQFunctions(Ceed ceed, PetscInt dim_sur, PetscInt num_comp_x, PetscInt num_comp_q, PetscInt q_data_size_sur, 1382b730f8bSJeremy L Thompson PetscInt jac_data_size_sur, ProblemQFunctionSpec apply_bc, ProblemQFunctionSpec apply_bc_jacobian, 1395b881d11SJames Wright CeedQFunction *qf_apply_bc, CeedQFunction *qf_apply_bc_jacobian) { 1405b881d11SJames Wright PetscFunctionBeginUser; 1415b881d11SJames Wright if (apply_bc.qfunction) { 142a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc.qfunction, apply_bc.qfunction_loc, qf_apply_bc)); 143a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc, apply_bc.qfunction_context)); 144a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "q", num_comp_q, CEED_EVAL_INTERP)); 145a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "Grad_q", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 146a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 147a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "x", num_comp_x, CEED_EVAL_INTERP)); 148a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "v", num_comp_q, CEED_EVAL_INTERP)); 149a424bcd0SJames Wright if (jac_data_size_sur) PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 1505b881d11SJames Wright } 1515b881d11SJames Wright if (apply_bc_jacobian.qfunction) { 152a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc_jacobian.qfunction, apply_bc_jacobian.qfunction_loc, qf_apply_bc_jacobian)); 153a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc_jacobian, apply_bc_jacobian.qfunction_context)); 154a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "dq", num_comp_q, CEED_EVAL_INTERP)); 155a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "Grad_dq", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 156a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 157a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "x", num_comp_x, CEED_EVAL_INTERP)); 158a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 159a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc_jacobian, "v", num_comp_q, CEED_EVAL_INTERP)); 1605b881d11SJames Wright } 161ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 1625b881d11SJames Wright } 1635b881d11SJames Wright 1642b730f8bSJeremy L Thompson PetscErrorCode SetupLibceed(Ceed ceed, CeedData ceed_data, DM dm, User user, AppCtx app_ctx, ProblemData *problem, SimpleBC bc) { 16577841947SLeila Ghaffari PetscFunctionBeginUser; 16677841947SLeila Ghaffari // ***************************************************************************** 16777841947SLeila Ghaffari // Set up CEED objects for the interior domain (volume) 16877841947SLeila Ghaffari // ***************************************************************************** 16977841947SLeila Ghaffari const PetscInt num_comp_q = 5; 1700814d5a7SKenneth E. Jansen const CeedInt dim = problem->dim, num_comp_x = problem->dim, q_data_size_vol = problem->q_data_size_vol, jac_data_size_vol = num_comp_q + 6 + 3; 171a3ae0734SJed Brown CeedElemRestriction elem_restr_jd_i; 172a3ae0734SJed Brown CeedVector jac_data; 1730814d5a7SKenneth E. Jansen CeedInt num_qpts; 17477841947SLeila Ghaffari 17577841947SLeila Ghaffari // ----------------------------------------------------------------------------- 17677841947SLeila Ghaffari // CEED Bases 17777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 1780814d5a7SKenneth E. Jansen DM dm_coord; 1790814d5a7SKenneth E. Jansen PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 1800814d5a7SKenneth E. Jansen 1810814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm, 0, 0, 0, 0, &ceed_data->basis_q)); 1820814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm_coord, 0, 0, 0, 0, &ceed_data->basis_x)); 183a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x, ceed_data->basis_q, &ceed_data->basis_xc)); 184a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisGetNumQuadraturePoints(ceed_data->basis_q, &num_qpts)); 18577841947SLeila Ghaffari 18677841947SLeila Ghaffari // ----------------------------------------------------------------------------- 18777841947SLeila Ghaffari // CEED Restrictions 18877841947SLeila Ghaffari // ----------------------------------------------------------------------------- 18977841947SLeila Ghaffari // -- Create restriction 1900814d5a7SKenneth E. Jansen PetscCall(GetRestrictionForDomain(ceed, dm, 0, 0, 0, 0, num_qpts, q_data_size_vol, &ceed_data->elem_restr_q, &ceed_data->elem_restr_x, 1912b730f8bSJeremy L Thompson &ceed_data->elem_restr_qd_i)); 192a3ae0734SJed Brown 1930814d5a7SKenneth E. Jansen PetscCall(GetRestrictionForDomain(ceed, dm, 0, 0, 0, 0, num_qpts, jac_data_size_vol, NULL, NULL, &elem_restr_jd_i)); 19477841947SLeila Ghaffari // -- Create E vectors 195a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_ceed, NULL)); 196a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_dot_ceed, NULL)); 197a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->g_ceed, NULL)); 19877841947SLeila Ghaffari 19977841947SLeila Ghaffari // ----------------------------------------------------------------------------- 20077841947SLeila Ghaffari // CEED QFunctions 20177841947SLeila Ghaffari // ----------------------------------------------------------------------------- 20277841947SLeila Ghaffari // -- Create QFunction for quadrature data 203a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_vol.qfunction, problem->setup_vol.qfunction_loc, &ceed_data->qf_setup_vol)); 204841e4c73SJed Brown if (problem->setup_vol.qfunction_context) { 205a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_vol, problem->setup_vol.qfunction_context)); 206841e4c73SJed Brown } 207a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 208a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "weight", 1, CEED_EVAL_WEIGHT)); 209a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 21077841947SLeila Ghaffari 21177841947SLeila Ghaffari // -- Create QFunction for ICs 212a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->ics.qfunction, problem->ics.qfunction_loc, &ceed_data->qf_ics)); 213a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ics, problem->ics.qfunction_context)); 214a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "x", num_comp_x, CEED_EVAL_INTERP)); 215a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 216a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ics, "q0", num_comp_q, CEED_EVAL_NONE)); 21777841947SLeila Ghaffari 21877841947SLeila Ghaffari // -- Create QFunction for RHS 21991e5af17SJed Brown if (problem->apply_vol_rhs.qfunction) { 220a424bcd0SJames Wright PetscCallCeed( 221a424bcd0SJames Wright ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_rhs.qfunction, problem->apply_vol_rhs.qfunction_loc, &ceed_data->qf_rhs_vol)); 222a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_rhs_vol, problem->apply_vol_rhs.qfunction_context)); 223a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 224a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 225a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 226a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 227a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 228a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 22977841947SLeila Ghaffari } 23077841947SLeila Ghaffari 23177841947SLeila Ghaffari // -- Create QFunction for IFunction 23291e5af17SJed Brown if (problem->apply_vol_ifunction.qfunction) { 233a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ifunction.qfunction, problem->apply_vol_ifunction.qfunction_loc, 234a424bcd0SJames Wright &ceed_data->qf_ifunction_vol)); 235a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ifunction_vol, problem->apply_vol_ifunction.qfunction_context)); 236a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 237a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 238a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q dot", num_comp_q, CEED_EVAL_INTERP)); 239a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 240a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 241a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 242a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 243a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 24477841947SLeila Ghaffari } 24577841947SLeila Ghaffari 246e334ad8fSJed Brown CeedQFunction qf_ijacobian_vol = NULL; 247e334ad8fSJed Brown if (problem->apply_vol_ijacobian.qfunction) { 248a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ijacobian.qfunction, problem->apply_vol_ijacobian.qfunction_loc, 249a424bcd0SJames Wright &qf_ijacobian_vol)); 250a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(qf_ijacobian_vol, problem->apply_vol_ijacobian.qfunction_context)); 251a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "dq", num_comp_q, CEED_EVAL_INTERP)); 252a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "Grad_dq", num_comp_q * dim, CEED_EVAL_GRAD)); 253a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 254a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 255a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 256a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 257a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 258e334ad8fSJed Brown } 259e334ad8fSJed Brown 26077841947SLeila Ghaffari // --------------------------------------------------------------------------- 26177841947SLeila Ghaffari // Element coordinates 26277841947SLeila Ghaffari // --------------------------------------------------------------------------- 26377841947SLeila Ghaffari // -- Create CEED vector 264a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_x, &ceed_data->x_coord, NULL)); 26577841947SLeila Ghaffari 26677841947SLeila Ghaffari // -- Copy PETSc vector in CEED vector 26777841947SLeila Ghaffari Vec X_loc; 2683796c488SJed Brown { 2693796c488SJed Brown DM cdm; 2702b730f8bSJeremy L Thompson PetscCall(DMGetCellCoordinateDM(dm, &cdm)); 2712b730f8bSJeremy L Thompson if (cdm) { 2722b730f8bSJeremy L Thompson PetscCall(DMGetCellCoordinatesLocal(dm, &X_loc)); 2732b730f8bSJeremy L Thompson } else { 2742b730f8bSJeremy L Thompson PetscCall(DMGetCoordinatesLocal(dm, &X_loc)); 2753796c488SJed Brown } 2762b730f8bSJeremy L Thompson } 2772b730f8bSJeremy L Thompson PetscCall(VecScale(X_loc, problem->dm_scale)); 278fe69b334SJames Wright PetscCall(VecCopyP2C(X_loc, ceed_data->x_coord)); 27977841947SLeila Ghaffari 28077841947SLeila Ghaffari // ----------------------------------------------------------------------------- 28177841947SLeila Ghaffari // CEED vectors 28277841947SLeila Ghaffari // ----------------------------------------------------------------------------- 28377841947SLeila Ghaffari // -- Create CEED vector for geometric data 284a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_qd_i, &ceed_data->q_data, NULL)); 285a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i, &jac_data, NULL)); 286d52d2babSJames Wright 28777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 28877841947SLeila Ghaffari // CEED Operators 28977841947SLeila Ghaffari // ----------------------------------------------------------------------------- 29077841947SLeila Ghaffari // -- Create CEED operator for quadrature data 291a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_vol, NULL, NULL, &ceed_data->op_setup_vol)); 292a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "dx", ceed_data->elem_restr_x, ceed_data->basis_x, CEED_VECTOR_ACTIVE)); 293a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x, CEED_VECTOR_NONE)); 294a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE)); 29577841947SLeila Ghaffari 29677841947SLeila Ghaffari // -- Create CEED operator for ICs 2975263e9c6SJames Wright CeedOperator op_ics; 298a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ics, NULL, NULL, &op_ics)); 299a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "x", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 300a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "dx", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 301a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "q0", ceed_data->elem_restr_q, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE)); 302a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_ics, "evaluation time", &user->phys->ics_time_label)); 3035263e9c6SJames Wright PetscCall(OperatorApplyContextCreate(NULL, dm, user->ceed, op_ics, ceed_data->x_coord, NULL, NULL, user->Q_loc, &ceed_data->op_ics_ctx)); 304a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ics)); 30577841947SLeila Ghaffari 30677841947SLeila Ghaffari // Create CEED operator for RHS 30777841947SLeila Ghaffari if (ceed_data->qf_rhs_vol) { 30877841947SLeila Ghaffari CeedOperator op; 309a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_rhs_vol, NULL, NULL, &op)); 310a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 311a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 312a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data)); 313a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 314a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 315a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 31677841947SLeila Ghaffari user->op_rhs_vol = op; 31777841947SLeila Ghaffari } 31877841947SLeila Ghaffari 31977841947SLeila Ghaffari // -- CEED operator for IFunction 32077841947SLeila Ghaffari if (ceed_data->qf_ifunction_vol) { 32177841947SLeila Ghaffari CeedOperator op; 322a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ifunction_vol, NULL, NULL, &op)); 323a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 324a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 325a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q dot", ceed_data->elem_restr_q, ceed_data->basis_q, user->q_dot_ceed)); 326a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data)); 327a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 328a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 329a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 330a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_COLLOCATED, jac_data)); 331a3ae0734SJed Brown 33277841947SLeila Ghaffari user->op_ifunction_vol = op; 33377841947SLeila Ghaffari } 33477841947SLeila Ghaffari 335e334ad8fSJed Brown CeedOperator op_ijacobian_vol = NULL; 336e334ad8fSJed Brown if (qf_ijacobian_vol) { 337e334ad8fSJed Brown CeedOperator op; 338a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_ijacobian_vol, NULL, NULL, &op)); 339a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 340a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 341a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data)); 342a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 343a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_COLLOCATED, jac_data)); 344a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 345a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 346e334ad8fSJed Brown op_ijacobian_vol = op; 347a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionDestroy(&qf_ijacobian_vol)); 348e334ad8fSJed Brown } 349e334ad8fSJed Brown 35077841947SLeila Ghaffari // ***************************************************************************** 35177841947SLeila Ghaffari // Set up CEED objects for the exterior domain (surface) 35277841947SLeila Ghaffari // ***************************************************************************** 3532b730f8bSJeremy L Thompson CeedInt height = 1, dim_sur = dim - height, P_sur = app_ctx->degree + 1, Q_sur = P_sur + app_ctx->q_extra; 3542b730f8bSJeremy L Thompson const CeedInt q_data_size_sur = problem->q_data_size_sur, jac_data_size_sur = problem->jac_data_size_sur; 35577841947SLeila Ghaffari 35677841947SLeila Ghaffari // ----------------------------------------------------------------------------- 35777841947SLeila Ghaffari // CEED Bases 35877841947SLeila Ghaffari // ----------------------------------------------------------------------------- 3590814d5a7SKenneth E. Jansen 3600814d5a7SKenneth E. Jansen DMLabel label = 0; 3610814d5a7SKenneth E. Jansen PetscInt face_id = 0; 3620814d5a7SKenneth E. Jansen PetscInt field = 0; // Still want the normal, default field 3630814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm, label, face_id, height, field, &ceed_data->basis_q_sur)); 3640814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm_coord, label, face_id, height, field, &ceed_data->basis_x_sur)); 365a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x_sur, ceed_data->basis_q_sur, &ceed_data->basis_xc_sur)); 36677841947SLeila Ghaffari 36777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 36877841947SLeila Ghaffari // CEED QFunctions 36977841947SLeila Ghaffari // ----------------------------------------------------------------------------- 37077841947SLeila Ghaffari // -- Create QFunction for quadrature data 371a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_sur.qfunction, problem->setup_sur.qfunction_loc, &ceed_data->qf_setup_sur)); 372841e4c73SJed Brown if (problem->setup_sur.qfunction_context) { 373a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_sur, problem->setup_sur.qfunction_context)); 374841e4c73SJed Brown } 375a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "dx", num_comp_x * dim_sur, CEED_EVAL_GRAD)); 376a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "weight", 1, CEED_EVAL_WEIGHT)); 377a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_sur, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 37877841947SLeila Ghaffari 3792b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_inflow, 3802b730f8bSJeremy L Thompson problem->apply_inflow_jacobian, &ceed_data->qf_apply_inflow, &ceed_data->qf_apply_inflow_jacobian)); 3812b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_outflow, 3822b730f8bSJeremy L Thompson problem->apply_outflow_jacobian, &ceed_data->qf_apply_outflow, &ceed_data->qf_apply_outflow_jacobian)); 3832b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_freestream, 3842b730f8bSJeremy L Thompson problem->apply_freestream_jacobian, &ceed_data->qf_apply_freestream, &ceed_data->qf_apply_freestream_jacobian)); 38577841947SLeila Ghaffari 38677841947SLeila Ghaffari // ***************************************************************************** 38777841947SLeila Ghaffari // CEED Operator Apply 38877841947SLeila Ghaffari // ***************************************************************************** 38977841947SLeila Ghaffari // -- Apply CEED Operator for the geometric data 390a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorApply(ceed_data->op_setup_vol, ceed_data->x_coord, ceed_data->q_data, CEED_REQUEST_IMMEDIATE)); 39177841947SLeila Ghaffari 39277841947SLeila Ghaffari // -- Create and apply CEED Composite Operator for the entire domain 39377841947SLeila Ghaffari if (!user->phys->implicit) { // RHS 3949ad5e8e4SJames Wright CeedOperator op_rhs; 3959ad5e8e4SJames Wright PetscCall(CreateOperatorForDomain(ceed, dm, bc, ceed_data, user->phys, user->op_rhs_vol, NULL, height, P_sur, Q_sur, q_data_size_sur, 0, &op_rhs, 3969ad5e8e4SJames Wright NULL)); 3979ad5e8e4SJames Wright PetscCall(OperatorApplyContextCreate(dm, dm, ceed, op_rhs, user->q_ceed, user->g_ceed, user->Q_loc, NULL, &user->op_rhs_ctx)); 398a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_rhs)); 39977841947SLeila Ghaffari } else { // IFunction 4002b730f8bSJeremy L Thompson PetscCall(CreateOperatorForDomain(ceed, dm, bc, ceed_data, user->phys, user->op_ifunction_vol, op_ijacobian_vol, height, P_sur, Q_sur, 4012b730f8bSJeremy L Thompson q_data_size_sur, jac_data_size_sur, &user->op_ifunction, op_ijacobian_vol ? &user->op_ijacobian : NULL)); 402e334ad8fSJed Brown if (user->op_ijacobian) { 403a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(user->op_ijacobian, "ijacobian time shift", &user->phys->ijacobian_time_shift_label)); 404e334ad8fSJed Brown } 40566170c20SJames Wright if (problem->use_strong_bc_ceed) PetscCall(SetupStrongBC_Ceed(ceed, ceed_data, dm, user, problem, bc)); 406cbef7084SJames Wright if (app_ctx->sgs_model_type == SGS_MODEL_DATA_DRIVEN) PetscCall(SgsDDModelSetup(ceed, user, ceed_data, problem)); 407dada6cc0SJames Wright } 408f5452247SJames Wright 409f5452247SJames Wright if (app_ctx->turb_spanstats_enable) PetscCall(TurbulenceStatisticsSetup(ceed, user, ceed_data, problem)); 4104e9802d1SJames Wright if (app_ctx->diff_filter_monitor) PetscCall(DifferentialFilterSetup(ceed, user, ceed_data, problem)); 411f5452247SJames Wright 412a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i)); 413a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ijacobian_vol)); 414a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data)); 415ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 41677841947SLeila Ghaffari } 417