1727da7e7SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2727da7e7SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3a515125bSLeila Ghaffari // 4727da7e7SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5a515125bSLeila Ghaffari // 6727da7e7SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7a515125bSLeila Ghaffari 8a515125bSLeila Ghaffari /// @file 9a515125bSLeila Ghaffari /// Setup libCEED for Navier-Stokes example using PETSc 10a515125bSLeila Ghaffari 11e419654dSJeremy L Thompson #include <ceed.h> 12e419654dSJeremy L Thompson #include <petscdmplex.h> 13e419654dSJeremy L Thompson 14a515125bSLeila Ghaffari #include "../navierstokes.h" 15a515125bSLeila Ghaffari 16a515125bSLeila Ghaffari // Utility function - essential BC dofs are encoded in closure indices as -(i+1). 172b916ea7SJeremy L Thompson PetscInt Involute(PetscInt i) { return i >= 0 ? i : -(i + 1); } 18a515125bSLeila Ghaffari 19a515125bSLeila Ghaffari // Utility function to create local CEED restriction 202b916ea7SJeremy L Thompson PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr) { 216b1ccf21SJeremy L Thompson PetscInt num_elem, elem_size, num_dof, num_comp, *elem_restr_offsets; 226b1ccf21SJeremy L Thompson 23a515125bSLeila Ghaffari PetscFunctionBeginUser; 242b916ea7SJeremy L Thompson PetscCall(DMPlexGetLocalOffsets(dm, domain_label, value, height, 0, &num_elem, &elem_size, &num_comp, &num_dof, &elem_restr_offsets)); 25a515125bSLeila Ghaffari 262b916ea7SJeremy L Thompson CeedElemRestrictionCreate(ceed, num_elem, elem_size, num_comp, 1, num_dof, CEED_MEM_HOST, CEED_COPY_VALUES, elem_restr_offsets, elem_restr); 272b916ea7SJeremy L Thompson PetscCall(PetscFree(elem_restr_offsets)); 28a515125bSLeila Ghaffari 29a515125bSLeila Ghaffari PetscFunctionReturn(0); 30a515125bSLeila Ghaffari } 31a515125bSLeila Ghaffari 32a515125bSLeila Ghaffari // Utility function to get Ceed Restriction for each domain 332b916ea7SJeremy L Thompson PetscErrorCode GetRestrictionForDomain(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, PetscInt value, CeedInt Q, CeedInt q_data_size, 342b916ea7SJeremy L Thompson CeedElemRestriction *elem_restr_q, CeedElemRestriction *elem_restr_x, CeedElemRestriction *elem_restr_qd_i) { 35a515125bSLeila Ghaffari DM dm_coord; 36a515125bSLeila Ghaffari CeedInt dim, loc_num_elem; 37a515125bSLeila Ghaffari CeedInt Q_dim; 38395c96d3SJed Brown CeedElemRestriction elem_restr_tmp; 39a515125bSLeila Ghaffari PetscFunctionBeginUser; 40a515125bSLeila Ghaffari 412b916ea7SJeremy L Thompson PetscCall(DMGetDimension(dm, &dim)); 42a515125bSLeila Ghaffari dim -= height; 43a515125bSLeila Ghaffari Q_dim = CeedIntPow(Q, dim); 442b916ea7SJeremy L Thompson PetscCall(CreateRestrictionFromPlex(ceed, dm, height, domain_label, value, &elem_restr_tmp)); 45395c96d3SJed Brown if (elem_restr_q) *elem_restr_q = elem_restr_tmp; 46395c96d3SJed Brown if (elem_restr_x) { 472b916ea7SJeremy L Thompson PetscCall(DMGetCellCoordinateDM(dm, &dm_coord)); 48cac8aa24SJed Brown if (!dm_coord) { 492b916ea7SJeremy L Thompson PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 50cac8aa24SJed Brown } 512b916ea7SJeremy L Thompson PetscCall(DMPlexSetClosurePermutationTensor(dm_coord, PETSC_DETERMINE, NULL)); 522b916ea7SJeremy L Thompson PetscCall(CreateRestrictionFromPlex(ceed, dm_coord, height, domain_label, value, elem_restr_x)); 53395c96d3SJed Brown } 54395c96d3SJed Brown if (elem_restr_qd_i) { 55395c96d3SJed Brown CeedElemRestrictionGetNumElements(elem_restr_tmp, &loc_num_elem); 562b916ea7SJeremy L Thompson CeedElemRestrictionCreateStrided(ceed, loc_num_elem, Q_dim, q_data_size, q_data_size * loc_num_elem * Q_dim, CEED_STRIDES_BACKEND, 572b916ea7SJeremy L Thompson elem_restr_qd_i); 58395c96d3SJed Brown } 59395c96d3SJed Brown if (!elem_restr_q) CeedElemRestrictionDestroy(&elem_restr_tmp); 60a515125bSLeila Ghaffari PetscFunctionReturn(0); 61a515125bSLeila Ghaffari } 62a515125bSLeila Ghaffari 632b916ea7SJeremy L Thompson PetscErrorCode AddBCSubOperator(Ceed ceed, DM dm, CeedData ceed_data, DMLabel domain_label, PetscInt value, CeedInt height, CeedInt Q_sur, 642b916ea7SJeremy L Thompson CeedInt q_data_size_sur, CeedInt jac_data_size_sur, CeedQFunction qf_apply_bc, CeedQFunction qf_apply_bc_jacobian, 65368c645fSJames Wright CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 66368c645fSJames Wright CeedVector q_data_sur, jac_data_sur; 672b916ea7SJeremy L Thompson CeedOperator op_setup_sur, op_apply_bc, op_apply_bc_jacobian = NULL; 682b916ea7SJeremy L Thompson CeedElemRestriction elem_restr_x_sur, elem_restr_q_sur, elem_restr_qd_i_sur, elem_restr_jd_i_sur; 69368c645fSJames Wright CeedInt num_qpts_sur; 70368c645fSJames Wright PetscFunctionBeginUser; 71368c645fSJames Wright 72368c645fSJames Wright // --- Get number of quadrature points for the boundaries 73368c645fSJames Wright CeedBasisGetNumQuadraturePoints(ceed_data->basis_q_sur, &num_qpts_sur); 74368c645fSJames Wright 75368c645fSJames Wright // ---- CEED Restriction 762b916ea7SJeremy L Thompson PetscCall(GetRestrictionForDomain(ceed, dm, height, domain_label, value, Q_sur, q_data_size_sur, &elem_restr_q_sur, &elem_restr_x_sur, 772b916ea7SJeremy L Thompson &elem_restr_qd_i_sur)); 78368c645fSJames Wright if (jac_data_size_sur > 0) { 79368c645fSJames Wright // State-dependent data will be passed from residual to Jacobian. This will be collocated. 802b916ea7SJeremy L Thompson PetscCall(GetRestrictionForDomain(ceed, dm, height, domain_label, value, Q_sur, jac_data_size_sur, NULL, NULL, &elem_restr_jd_i_sur)); 81368c645fSJames Wright CeedElemRestrictionCreateVector(elem_restr_jd_i_sur, &jac_data_sur, NULL); 82368c645fSJames Wright } else { 83368c645fSJames Wright elem_restr_jd_i_sur = NULL; 84368c645fSJames Wright jac_data_sur = NULL; 85368c645fSJames Wright } 86368c645fSJames Wright 87368c645fSJames Wright // ---- CEED Vector 88368c645fSJames Wright PetscInt loc_num_elem_sur; 89368c645fSJames Wright CeedElemRestrictionGetNumElements(elem_restr_q_sur, &loc_num_elem_sur); 902b916ea7SJeremy L Thompson CeedVectorCreate(ceed, q_data_size_sur * loc_num_elem_sur * num_qpts_sur, &q_data_sur); 91368c645fSJames Wright 92368c645fSJames Wright // ---- CEED Operator 93368c645fSJames Wright // ----- CEED Operator for Setup (geometric factors) 94368c645fSJames Wright CeedOperatorCreate(ceed, ceed_data->qf_setup_sur, NULL, NULL, &op_setup_sur); 952b916ea7SJeremy L Thompson CeedOperatorSetField(op_setup_sur, "dx", elem_restr_x_sur, ceed_data->basis_x_sur, CEED_VECTOR_ACTIVE); 962b916ea7SJeremy L Thompson CeedOperatorSetField(op_setup_sur, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x_sur, CEED_VECTOR_NONE); 972b916ea7SJeremy L Thompson CeedOperatorSetField(op_setup_sur, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE); 98368c645fSJames Wright 99368c645fSJames Wright // ----- CEED Operator for Physics 100368c645fSJames Wright CeedOperatorCreate(ceed, qf_apply_bc, NULL, NULL, &op_apply_bc); 1012b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc, "q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 1022b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc, "Grad_q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 1032b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, q_data_sur); 1042b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord); 1052b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 1062b916ea7SJeremy L Thompson if (elem_restr_jd_i_sur) CeedOperatorSetField(op_apply_bc, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_COLLOCATED, jac_data_sur); 107368c645fSJames Wright 108368c645fSJames Wright if (qf_apply_bc_jacobian) { 1092b916ea7SJeremy L Thompson CeedOperatorCreate(ceed, qf_apply_bc_jacobian, NULL, NULL, &op_apply_bc_jacobian); 1102b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 1112b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "Grad_dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 1122b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_COLLOCATED, q_data_sur); 1132b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord); 1142b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_COLLOCATED, jac_data_sur); 1152b916ea7SJeremy L Thompson CeedOperatorSetField(op_apply_bc_jacobian, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE); 116368c645fSJames Wright } 117368c645fSJames Wright 118368c645fSJames Wright // ----- Apply CEED operator for Setup 1192b916ea7SJeremy L Thompson CeedOperatorApply(op_setup_sur, ceed_data->x_coord, q_data_sur, CEED_REQUEST_IMMEDIATE); 120368c645fSJames Wright 121368c645fSJames Wright // ----- Apply Sub-Operator for Physics 122368c645fSJames Wright CeedCompositeOperatorAddSub(*op_apply, op_apply_bc); 1232b916ea7SJeremy L Thompson if (op_apply_bc_jacobian) CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_bc_jacobian); 124368c645fSJames Wright 125368c645fSJames Wright // ----- Cleanup 126368c645fSJames Wright CeedVectorDestroy(&q_data_sur); 127368c645fSJames Wright CeedVectorDestroy(&jac_data_sur); 128368c645fSJames Wright CeedElemRestrictionDestroy(&elem_restr_q_sur); 129368c645fSJames Wright CeedElemRestrictionDestroy(&elem_restr_x_sur); 130368c645fSJames Wright CeedElemRestrictionDestroy(&elem_restr_qd_i_sur); 131368c645fSJames Wright CeedElemRestrictionDestroy(&elem_restr_jd_i_sur); 132368c645fSJames Wright CeedOperatorDestroy(&op_setup_sur); 133368c645fSJames Wright CeedOperatorDestroy(&op_apply_bc); 134368c645fSJames Wright CeedOperatorDestroy(&op_apply_bc_jacobian); 135368c645fSJames Wright 136368c645fSJames Wright PetscFunctionReturn(0); 137368c645fSJames Wright } 138368c645fSJames Wright 139a515125bSLeila Ghaffari // Utility function to create CEED Composite Operator for the entire domain 1402b916ea7SJeremy L Thompson PetscErrorCode CreateOperatorForDomain(Ceed ceed, DM dm, SimpleBC bc, CeedData ceed_data, Physics phys, CeedOperator op_apply_vol, 1412b916ea7SJeremy L Thompson CeedOperator op_apply_ijacobian_vol, CeedInt height, CeedInt P_sur, CeedInt Q_sur, CeedInt q_data_size_sur, 1422b916ea7SJeremy L Thompson CeedInt jac_data_size_sur, CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 143a515125bSLeila Ghaffari DMLabel domain_label; 144a515125bSLeila Ghaffari PetscFunctionBeginUser; 145a515125bSLeila Ghaffari 146a515125bSLeila Ghaffari // Create Composite Operaters 147a515125bSLeila Ghaffari CeedCompositeOperatorCreate(ceed, op_apply); 1482b916ea7SJeremy L Thompson if (op_apply_ijacobian) CeedCompositeOperatorCreate(ceed, op_apply_ijacobian); 149a515125bSLeila Ghaffari 150a515125bSLeila Ghaffari // --Apply Sub-Operator for the volume 151a515125bSLeila Ghaffari CeedCompositeOperatorAddSub(*op_apply, op_apply_vol); 1522b916ea7SJeremy L Thompson if (op_apply_ijacobian) CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_ijacobian_vol); 153a515125bSLeila Ghaffari 154a515125bSLeila Ghaffari // -- Create Sub-Operator for in/outflow BCs 155bb8a0c61SJames Wright if (phys->has_neumann || 1) { 156a515125bSLeila Ghaffari // --- Setup 1572b916ea7SJeremy L Thompson PetscCall(DMGetLabel(dm, "Face Sets", &domain_label)); 158a515125bSLeila Ghaffari 159002797a3SLeila Ghaffari // --- Create Sub-Operator for inflow boundaries 160002797a3SLeila Ghaffari for (CeedInt i = 0; i < bc->num_inflow; i++) { 1612b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->inflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1622b916ea7SJeremy L Thompson ceed_data->qf_apply_inflow, ceed_data->qf_apply_inflow_jacobian, op_apply, op_apply_ijacobian)); 163a515125bSLeila Ghaffari } 164002797a3SLeila Ghaffari // --- Create Sub-Operator for outflow boundaries 165002797a3SLeila Ghaffari for (CeedInt i = 0; i < bc->num_outflow; i++) { 1662b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->outflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1672b916ea7SJeremy L Thompson ceed_data->qf_apply_outflow, ceed_data->qf_apply_outflow_jacobian, op_apply, op_apply_ijacobian)); 1682556a851SJed Brown } 169df55ba5fSJames Wright // --- Create Sub-Operator for freestream boundaries 170df55ba5fSJames Wright for (CeedInt i = 0; i < bc->num_freestream; i++) { 1712b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->freestreams[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1722b916ea7SJeremy L Thompson ceed_data->qf_apply_freestream, ceed_data->qf_apply_freestream_jacobian, op_apply, op_apply_ijacobian)); 173002797a3SLeila Ghaffari } 174002797a3SLeila Ghaffari } 17592ada588SJames Wright 17692ada588SJames Wright // ----- Get Context Labels for Operator 177a5f46a7bSJeremy L Thompson CeedOperatorGetContextFieldLabel(*op_apply, "solution time", &phys->solution_time_label); 178a5f46a7bSJeremy L Thompson CeedOperatorGetContextFieldLabel(*op_apply, "timestep size", &phys->timestep_size_label); 17992ada588SJames Wright 180a515125bSLeila Ghaffari PetscFunctionReturn(0); 181a515125bSLeila Ghaffari } 182a515125bSLeila Ghaffari 1832b916ea7SJeremy L Thompson PetscErrorCode SetupBCQFunctions(Ceed ceed, PetscInt dim_sur, PetscInt num_comp_x, PetscInt num_comp_q, PetscInt q_data_size_sur, 1842b916ea7SJeremy L Thompson PetscInt jac_data_size_sur, ProblemQFunctionSpec apply_bc, ProblemQFunctionSpec apply_bc_jacobian, 18525988f00SJames Wright CeedQFunction *qf_apply_bc, CeedQFunction *qf_apply_bc_jacobian) { 18625988f00SJames Wright PetscFunctionBeginUser; 18725988f00SJames Wright 18825988f00SJames Wright if (apply_bc.qfunction) { 18925988f00SJames Wright CeedQFunctionCreateInterior(ceed, 1, apply_bc.qfunction, apply_bc.qfunction_loc, qf_apply_bc); 19025988f00SJames Wright CeedQFunctionSetContext(*qf_apply_bc, apply_bc.qfunction_context); 19125988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc, "q", num_comp_q, CEED_EVAL_INTERP); 19225988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc, "Grad_q", num_comp_q * dim_sur, CEED_EVAL_GRAD); 19325988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc, "surface qdata", q_data_size_sur, CEED_EVAL_NONE); 19425988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc, "x", num_comp_x, CEED_EVAL_INTERP); 19525988f00SJames Wright CeedQFunctionAddOutput(*qf_apply_bc, "v", num_comp_q, CEED_EVAL_INTERP); 1962b916ea7SJeremy L Thompson if (jac_data_size_sur) CeedQFunctionAddOutput(*qf_apply_bc, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE); 19725988f00SJames Wright } 19825988f00SJames Wright if (apply_bc_jacobian.qfunction) { 1992b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, apply_bc_jacobian.qfunction, apply_bc_jacobian.qfunction_loc, qf_apply_bc_jacobian); 20025988f00SJames Wright CeedQFunctionSetContext(*qf_apply_bc_jacobian, apply_bc_jacobian.qfunction_context); 20125988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc_jacobian, "dq", num_comp_q, CEED_EVAL_INTERP); 20225988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc_jacobian, "Grad_dq", num_comp_q * dim_sur, CEED_EVAL_GRAD); 20325988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface qdata", q_data_size_sur, CEED_EVAL_NONE); 20425988f00SJames Wright CeedQFunctionAddInput(*qf_apply_bc_jacobian, "x", num_comp_x, CEED_EVAL_INTERP); 2052b916ea7SJeremy L Thompson CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE); 20625988f00SJames Wright CeedQFunctionAddOutput(*qf_apply_bc_jacobian, "v", num_comp_q, CEED_EVAL_INTERP); 20725988f00SJames Wright } 20825988f00SJames Wright PetscFunctionReturn(0); 20925988f00SJames Wright } 21025988f00SJames Wright 2112b916ea7SJeremy L Thompson PetscErrorCode SetupLibceed(Ceed ceed, CeedData ceed_data, DM dm, User user, AppCtx app_ctx, ProblemData *problem, SimpleBC bc) { 212a515125bSLeila Ghaffari PetscFunctionBeginUser; 213a515125bSLeila Ghaffari 214a515125bSLeila Ghaffari // ***************************************************************************** 215a515125bSLeila Ghaffari // Set up CEED objects for the interior domain (volume) 216a515125bSLeila Ghaffari // ***************************************************************************** 217a515125bSLeila Ghaffari const PetscInt num_comp_q = 5; 2182b916ea7SJeremy L Thompson 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, 2192b916ea7SJeremy L Thompson P = app_ctx->degree + 1, Q = P + app_ctx->q_extra; 220752f40e3SJed Brown CeedElemRestriction elem_restr_jd_i; 221752f40e3SJed Brown CeedVector jac_data; 222a515125bSLeila Ghaffari 223a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 224a515125bSLeila Ghaffari // CEED Bases 225a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 2262b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim, num_comp_q, P, Q, CEED_GAUSS, &ceed_data->basis_q); 2272b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim, num_comp_x, 2, Q, CEED_GAUSS, &ceed_data->basis_x); 2282b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim, num_comp_x, 2, P, CEED_GAUSS_LOBATTO, &ceed_data->basis_xc); 229a515125bSLeila Ghaffari 230a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 231a515125bSLeila Ghaffari // CEED Restrictions 232a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 233a515125bSLeila Ghaffari // -- Create restriction 2342b916ea7SJeremy L Thompson PetscCall(GetRestrictionForDomain(ceed, dm, 0, 0, 0, Q, q_data_size_vol, &ceed_data->elem_restr_q, &ceed_data->elem_restr_x, 2352b916ea7SJeremy L Thompson &ceed_data->elem_restr_qd_i)); 236752f40e3SJed Brown 2372b916ea7SJeremy L Thompson PetscCall(GetRestrictionForDomain(ceed, dm, 0, 0, 0, Q, jac_data_size_vol, NULL, NULL, &elem_restr_jd_i)); 238a515125bSLeila Ghaffari // -- Create E vectors 239a515125bSLeila Ghaffari CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_ceed, NULL); 2402b916ea7SJeremy L Thompson CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_dot_ceed, NULL); 241a515125bSLeila Ghaffari CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->g_ceed, NULL); 242a515125bSLeila Ghaffari 243a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 244a515125bSLeila Ghaffari // CEED QFunctions 245a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 246a515125bSLeila Ghaffari // -- Create QFunction for quadrature data 2472b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->setup_vol.qfunction, problem->setup_vol.qfunction_loc, &ceed_data->qf_setup_vol); 24815a3537eSJed Brown if (problem->setup_vol.qfunction_context) { 2492b916ea7SJeremy L Thompson CeedQFunctionSetContext(ceed_data->qf_setup_vol, problem->setup_vol.qfunction_context); 25015a3537eSJed Brown } 2512b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_setup_vol, "dx", num_comp_x * dim, CEED_EVAL_GRAD); 252a515125bSLeila Ghaffari CeedQFunctionAddInput(ceed_data->qf_setup_vol, "weight", 1, CEED_EVAL_WEIGHT); 2532b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_setup_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE); 254a515125bSLeila Ghaffari 255a515125bSLeila Ghaffari // -- Create QFunction for ICs 2562b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->ics.qfunction, problem->ics.qfunction_loc, &ceed_data->qf_ics); 25715a3537eSJed Brown CeedQFunctionSetContext(ceed_data->qf_ics, problem->ics.qfunction_context); 258a515125bSLeila Ghaffari CeedQFunctionAddInput(ceed_data->qf_ics, "x", num_comp_x, CEED_EVAL_INTERP); 2592b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ics, "qdata", q_data_size_vol, CEED_EVAL_NONE); 260a515125bSLeila Ghaffari CeedQFunctionAddOutput(ceed_data->qf_ics, "q0", num_comp_q, CEED_EVAL_NONE); 261a515125bSLeila Ghaffari 262a515125bSLeila Ghaffari // -- Create QFunction for RHS 2639785fe93SJed Brown if (problem->apply_vol_rhs.qfunction) { 2642b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_rhs.qfunction, problem->apply_vol_rhs.qfunction_loc, &ceed_data->qf_rhs_vol); 2652b916ea7SJeremy L Thompson CeedQFunctionSetContext(ceed_data->qf_rhs_vol, problem->apply_vol_rhs.qfunction_context); 266a515125bSLeila Ghaffari CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "q", num_comp_q, CEED_EVAL_INTERP); 2672b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD); 2682b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE); 269a515125bSLeila Ghaffari CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "x", num_comp_x, CEED_EVAL_INTERP); 2702b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "v", num_comp_q, CEED_EVAL_INTERP); 2712b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD); 272a515125bSLeila Ghaffari } 273a515125bSLeila Ghaffari 274a515125bSLeila Ghaffari // -- Create QFunction for IFunction 2759785fe93SJed Brown if (problem->apply_vol_ifunction.qfunction) { 2762b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ifunction.qfunction, problem->apply_vol_ifunction.qfunction_loc, 2772b916ea7SJeremy L Thompson &ceed_data->qf_ifunction_vol); 2782b916ea7SJeremy L Thompson CeedQFunctionSetContext(ceed_data->qf_ifunction_vol, problem->apply_vol_ifunction.qfunction_context); 2792b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q", num_comp_q, CEED_EVAL_INTERP); 2802b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD); 2812b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q dot", num_comp_q, CEED_EVAL_INTERP); 2822b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE); 2832b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "x", num_comp_x, CEED_EVAL_INTERP); 2842b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "v", num_comp_q, CEED_EVAL_INTERP); 2852b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD); 2862b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE); 287a515125bSLeila Ghaffari } 288a515125bSLeila Ghaffari 289f0b65372SJed Brown CeedQFunction qf_ijacobian_vol = NULL; 290f0b65372SJed Brown if (problem->apply_vol_ijacobian.qfunction) { 2912b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ijacobian.qfunction, problem->apply_vol_ijacobian.qfunction_loc, &qf_ijacobian_vol); 2922b916ea7SJeremy L Thompson CeedQFunctionSetContext(qf_ijacobian_vol, problem->apply_vol_ijacobian.qfunction_context); 2932b916ea7SJeremy L Thompson CeedQFunctionAddInput(qf_ijacobian_vol, "dq", num_comp_q, CEED_EVAL_INTERP); 2942b916ea7SJeremy L Thompson CeedQFunctionAddInput(qf_ijacobian_vol, "Grad_dq", num_comp_q * dim, CEED_EVAL_GRAD); 2952b916ea7SJeremy L Thompson CeedQFunctionAddInput(qf_ijacobian_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE); 2962b916ea7SJeremy L Thompson CeedQFunctionAddInput(qf_ijacobian_vol, "x", num_comp_x, CEED_EVAL_INTERP); 2972b916ea7SJeremy L Thompson CeedQFunctionAddInput(qf_ijacobian_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE); 2982b916ea7SJeremy L Thompson CeedQFunctionAddOutput(qf_ijacobian_vol, "v", num_comp_q, CEED_EVAL_INTERP); 2992b916ea7SJeremy L Thompson CeedQFunctionAddOutput(qf_ijacobian_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD); 300f0b65372SJed Brown } 301f0b65372SJed Brown 302a515125bSLeila Ghaffari // --------------------------------------------------------------------------- 303a515125bSLeila Ghaffari // Element coordinates 304a515125bSLeila Ghaffari // --------------------------------------------------------------------------- 305a515125bSLeila Ghaffari // -- Create CEED vector 3062b916ea7SJeremy L Thompson CeedElemRestrictionCreateVector(ceed_data->elem_restr_x, &ceed_data->x_coord, NULL); 307a515125bSLeila Ghaffari 308a515125bSLeila Ghaffari // -- Copy PETSc vector in CEED vector 309a515125bSLeila Ghaffari Vec X_loc; 310cac8aa24SJed Brown { 311cac8aa24SJed Brown DM cdm; 3122b916ea7SJeremy L Thompson PetscCall(DMGetCellCoordinateDM(dm, &cdm)); 3132b916ea7SJeremy L Thompson if (cdm) { 3142b916ea7SJeremy L Thompson PetscCall(DMGetCellCoordinatesLocal(dm, &X_loc)); 3152b916ea7SJeremy L Thompson } else { 3162b916ea7SJeremy L Thompson PetscCall(DMGetCoordinatesLocal(dm, &X_loc)); 317cac8aa24SJed Brown } 3182b916ea7SJeremy L Thompson } 3192b916ea7SJeremy L Thompson PetscCall(VecScale(X_loc, problem->dm_scale)); 320502d3feeSJames Wright PetscCall(VecCopyP2C(X_loc, ceed_data->x_coord)); 321a515125bSLeila Ghaffari 322a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 323a515125bSLeila Ghaffari // CEED vectors 324a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 325a515125bSLeila Ghaffari // -- Create CEED vector for geometric data 3260b0430b7SJames Wright CeedElemRestrictionCreateVector(ceed_data->elem_restr_qd_i, &ceed_data->q_data, NULL); 327752f40e3SJed Brown CeedElemRestrictionCreateVector(elem_restr_jd_i, &jac_data, NULL); 3280b0430b7SJames Wright 329a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 330a515125bSLeila Ghaffari // CEED Operators 331a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 332a515125bSLeila Ghaffari // -- Create CEED operator for quadrature data 3332b916ea7SJeremy L Thompson CeedOperatorCreate(ceed, ceed_data->qf_setup_vol, NULL, NULL, &ceed_data->op_setup_vol); 3342b916ea7SJeremy L Thompson CeedOperatorSetField(ceed_data->op_setup_vol, "dx", ceed_data->elem_restr_x, ceed_data->basis_x, CEED_VECTOR_ACTIVE); 3352b916ea7SJeremy L Thompson CeedOperatorSetField(ceed_data->op_setup_vol, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x, CEED_VECTOR_NONE); 3362b916ea7SJeremy L Thompson CeedOperatorSetField(ceed_data->op_setup_vol, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE); 337a515125bSLeila Ghaffari 338a515125bSLeila Ghaffari // -- Create CEED operator for ICs 3398f18bb8bSJames Wright CeedOperator op_ics; 3408f18bb8bSJames Wright CeedOperatorCreate(ceed, ceed_data->qf_ics, NULL, NULL, &op_ics); 3418f18bb8bSJames Wright CeedOperatorSetField(op_ics, "x", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE); 3428f18bb8bSJames Wright CeedOperatorSetField(op_ics, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data); 3438f18bb8bSJames Wright CeedOperatorSetField(op_ics, "q0", ceed_data->elem_restr_q, CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE); 3448f18bb8bSJames Wright CeedOperatorGetContextFieldLabel(op_ics, "evaluation time", &user->phys->ics_time_label); 3458f18bb8bSJames Wright PetscCall(OperatorApplyContextCreate(NULL, dm, user->ceed, op_ics, ceed_data->x_coord, NULL, NULL, user->Q_loc, &ceed_data->op_ics_ctx)); 3468f18bb8bSJames Wright CeedOperatorDestroy(&op_ics); 347a515125bSLeila Ghaffari 348a515125bSLeila Ghaffari // Create CEED operator for RHS 349a515125bSLeila Ghaffari if (ceed_data->qf_rhs_vol) { 350a515125bSLeila Ghaffari CeedOperator op; 351a515125bSLeila Ghaffari CeedOperatorCreate(ceed, ceed_data->qf_rhs_vol, NULL, NULL, &op); 3522b916ea7SJeremy L Thompson CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3532b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3542b916ea7SJeremy L Thompson CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data); 3552b916ea7SJeremy L Thompson CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord); 3562b916ea7SJeremy L Thompson CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3572b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 358a515125bSLeila Ghaffari user->op_rhs_vol = op; 359a515125bSLeila Ghaffari } 360a515125bSLeila Ghaffari 361a515125bSLeila Ghaffari // -- CEED operator for IFunction 362a515125bSLeila Ghaffari if (ceed_data->qf_ifunction_vol) { 363a515125bSLeila Ghaffari CeedOperator op; 364a515125bSLeila Ghaffari CeedOperatorCreate(ceed, ceed_data->qf_ifunction_vol, NULL, NULL, &op); 3652b916ea7SJeremy L Thompson CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3662b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3672b916ea7SJeremy L Thompson CeedOperatorSetField(op, "q dot", ceed_data->elem_restr_q, ceed_data->basis_q, user->q_dot_ceed); 3682b916ea7SJeremy L Thompson CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data); 3692b916ea7SJeremy L Thompson CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord); 3702b916ea7SJeremy L Thompson CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3712b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3722b916ea7SJeremy L Thompson CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_COLLOCATED, jac_data); 373752f40e3SJed Brown 374a515125bSLeila Ghaffari user->op_ifunction_vol = op; 375a515125bSLeila Ghaffari } 376a515125bSLeila Ghaffari 377f0b65372SJed Brown CeedOperator op_ijacobian_vol = NULL; 378f0b65372SJed Brown if (qf_ijacobian_vol) { 379f0b65372SJed Brown CeedOperator op; 380f0b65372SJed Brown CeedOperatorCreate(ceed, qf_ijacobian_vol, NULL, NULL, &op); 3812b916ea7SJeremy L Thompson CeedOperatorSetField(op, "dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3822b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3832b916ea7SJeremy L Thompson CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data); 3842b916ea7SJeremy L Thompson CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord); 3852b916ea7SJeremy L Thompson CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_COLLOCATED, jac_data); 3862b916ea7SJeremy L Thompson CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 3872b916ea7SJeremy L Thompson CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE); 388f0b65372SJed Brown op_ijacobian_vol = op; 389f0b65372SJed Brown CeedQFunctionDestroy(&qf_ijacobian_vol); 390f0b65372SJed Brown } 391f0b65372SJed Brown 392a515125bSLeila Ghaffari // ***************************************************************************** 393a515125bSLeila Ghaffari // Set up CEED objects for the exterior domain (surface) 394a515125bSLeila Ghaffari // ***************************************************************************** 3952b916ea7SJeremy L Thompson CeedInt height = 1, dim_sur = dim - height, P_sur = app_ctx->degree + 1, Q_sur = P_sur + app_ctx->q_extra; 3962b916ea7SJeremy L Thompson const CeedInt q_data_size_sur = problem->q_data_size_sur, jac_data_size_sur = problem->jac_data_size_sur; 397a515125bSLeila Ghaffari 398a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 399a515125bSLeila Ghaffari // CEED Bases 400a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 4012b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim_sur, num_comp_q, P_sur, Q_sur, CEED_GAUSS, &ceed_data->basis_q_sur); 4022b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim_sur, num_comp_x, 2, Q_sur, CEED_GAUSS, &ceed_data->basis_x_sur); 4032b916ea7SJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, dim_sur, num_comp_x, 2, P_sur, CEED_GAUSS_LOBATTO, &ceed_data->basis_xc_sur); 404a515125bSLeila Ghaffari 405a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 406a515125bSLeila Ghaffari // CEED QFunctions 407a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 408a515125bSLeila Ghaffari // -- Create QFunction for quadrature data 4092b916ea7SJeremy L Thompson CeedQFunctionCreateInterior(ceed, 1, problem->setup_sur.qfunction, problem->setup_sur.qfunction_loc, &ceed_data->qf_setup_sur); 41015a3537eSJed Brown if (problem->setup_sur.qfunction_context) { 4112b916ea7SJeremy L Thompson CeedQFunctionSetContext(ceed_data->qf_setup_sur, problem->setup_sur.qfunction_context); 41215a3537eSJed Brown } 4132b916ea7SJeremy L Thompson CeedQFunctionAddInput(ceed_data->qf_setup_sur, "dx", num_comp_x * dim_sur, CEED_EVAL_GRAD); 414a515125bSLeila Ghaffari CeedQFunctionAddInput(ceed_data->qf_setup_sur, "weight", 1, CEED_EVAL_WEIGHT); 4152b916ea7SJeremy L Thompson CeedQFunctionAddOutput(ceed_data->qf_setup_sur, "surface qdata", q_data_size_sur, CEED_EVAL_NONE); 416a515125bSLeila Ghaffari 4172b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_inflow, 4182b916ea7SJeremy L Thompson problem->apply_inflow_jacobian, &ceed_data->qf_apply_inflow, &ceed_data->qf_apply_inflow_jacobian)); 4192b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_outflow, 4202b916ea7SJeremy L Thompson problem->apply_outflow_jacobian, &ceed_data->qf_apply_outflow, &ceed_data->qf_apply_outflow_jacobian)); 4212b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_freestream, 4222b916ea7SJeremy L Thompson problem->apply_freestream_jacobian, &ceed_data->qf_apply_freestream, &ceed_data->qf_apply_freestream_jacobian)); 423a515125bSLeila Ghaffari 424a515125bSLeila Ghaffari // ***************************************************************************** 425a515125bSLeila Ghaffari // CEED Operator Apply 426a515125bSLeila Ghaffari // ***************************************************************************** 427a515125bSLeila Ghaffari // -- Apply CEED Operator for the geometric data 4282b916ea7SJeremy L Thompson CeedOperatorApply(ceed_data->op_setup_vol, ceed_data->x_coord, ceed_data->q_data, CEED_REQUEST_IMMEDIATE); 429a515125bSLeila Ghaffari 430a515125bSLeila Ghaffari // -- Create and apply CEED Composite Operator for the entire domain 431a515125bSLeila Ghaffari if (!user->phys->implicit) { // RHS 432*da5fe0e4SJames Wright CeedOperator op_rhs; 433*da5fe0e4SJames 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, 434*da5fe0e4SJames Wright NULL)); 435*da5fe0e4SJames Wright PetscCall(OperatorApplyContextCreate(dm, dm, ceed, op_rhs, user->q_ceed, user->g_ceed, user->Q_loc, NULL, &user->op_rhs_ctx)); 436*da5fe0e4SJames Wright CeedOperatorDestroy(&op_rhs); 437a515125bSLeila Ghaffari } else { // IFunction 4382b916ea7SJeremy L Thompson PetscCall(CreateOperatorForDomain(ceed, dm, bc, ceed_data, user->phys, user->op_ifunction_vol, op_ijacobian_vol, height, P_sur, Q_sur, 4392b916ea7SJeremy L Thompson q_data_size_sur, jac_data_size_sur, &user->op_ifunction, op_ijacobian_vol ? &user->op_ijacobian : NULL)); 440f0b65372SJed Brown if (user->op_ijacobian) { 441a5f46a7bSJeremy L Thompson CeedOperatorGetContextFieldLabel(user->op_ijacobian, "ijacobian time shift", &user->phys->ijacobian_time_shift_label); 442f0b65372SJed Brown } 44391933550SJames Wright if (problem->use_strong_bc_ceed) PetscCall(SetupStrongBC_Ceed(ceed, ceed_data, dm, user, problem, bc, Q_sur, q_data_size_sur)); 44491933550SJames Wright if (app_ctx->sgs_model_type == SGS_MODEL_DATA_DRIVEN) PetscCall(SGS_DD_ModelSetup(ceed, user, ceed_data, problem)); 4456d0190e2SJames Wright } 44691933550SJames Wright 44791933550SJames Wright if (app_ctx->turb_spanstats_enable) PetscCall(TurbulenceStatisticsSetup(ceed, user, ceed_data, problem)); 44891933550SJames Wright 449752f40e3SJed Brown CeedElemRestrictionDestroy(&elem_restr_jd_i); 450e22e0f1cSLeila Ghaffari CeedOperatorDestroy(&op_ijacobian_vol); 451752f40e3SJed Brown CeedVectorDestroy(&jac_data); 452a515125bSLeila Ghaffari PetscFunctionReturn(0); 453a515125bSLeila Ghaffari } 454