1dc936754SJeremy L Thompson // Copyright (c) 2017-2024, 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 1636c6cbc8SJames Wright PetscErrorCode AddBCSubOperator(Ceed ceed, DM dm, CeedData ceed_data, DMLabel domain_label, PetscInt label_value, CeedInt height, CeedInt Q_sur, 172b916ea7SJeremy L Thompson CeedInt q_data_size_sur, CeedInt jac_data_size_sur, CeedQFunction qf_apply_bc, CeedQFunction qf_apply_bc_jacobian, 18368c645fSJames Wright CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 1915c18037SJames Wright CeedVector q_data_sur, jac_data_sur = NULL; 202b916ea7SJeremy L Thompson CeedOperator op_setup_sur, op_apply_bc, op_apply_bc_jacobian = NULL; 2115c18037SJames Wright CeedElemRestriction elem_restr_x_sur, elem_restr_q_sur, elem_restr_qd_i_sur, elem_restr_jd_i_sur = NULL; 2215c18037SJames Wright CeedInt num_qpts_sur, dm_field = 0; 23368c645fSJames Wright 2406f41313SJames Wright PetscFunctionBeginUser; 25368c645fSJames Wright // --- Get number of quadrature points for the boundaries 26b4c37c5cSJames Wright PetscCallCeed(ceed, CeedBasisGetNumQuadraturePoints(ceed_data->basis_q_sur, &num_qpts_sur)); 27368c645fSJames Wright 28368c645fSJames Wright // ---- CEED Restriction 2915c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionCreate(ceed, dm, domain_label, label_value, height, dm_field, &elem_restr_q_sur)); 3015c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionCoordinateCreate(ceed, dm, domain_label, label_value, height, &elem_restr_x_sur)); 3115c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, q_data_size_sur, &elem_restr_qd_i_sur)); 32368c645fSJames Wright if (jac_data_size_sur > 0) { 33368c645fSJames Wright // State-dependent data will be passed from residual to Jacobian. This will be collocated. 3415c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, jac_data_size_sur, &elem_restr_jd_i_sur)); 35b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i_sur, &jac_data_sur, NULL)); 36368c645fSJames Wright } 37368c645fSJames Wright 38368c645fSJames Wright // ---- CEED Vector 39defe8520SJames Wright CeedInt loc_num_elem_sur; 40b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionGetNumElements(elem_restr_q_sur, &loc_num_elem_sur)); 41b4c37c5cSJames Wright PetscCallCeed(ceed, CeedVectorCreate(ceed, q_data_size_sur * loc_num_elem_sur * num_qpts_sur, &q_data_sur)); 42368c645fSJames Wright 43368c645fSJames Wright // ---- CEED Operator 44368c645fSJames Wright // ----- CEED Operator for Setup (geometric factors) 45b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_sur, NULL, NULL, &op_setup_sur)); 46b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "dx", elem_restr_x_sur, ceed_data->basis_x_sur, CEED_VECTOR_ACTIVE)); 47b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x_sur, CEED_VECTOR_NONE)); 4858e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 49368c645fSJames Wright 50368c645fSJames Wright // ----- CEED Operator for Physics 51b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc, NULL, NULL, &op_apply_bc)); 52b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 53b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "Grad_q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 5458e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, q_data_sur)); 55b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 56b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 57b4c37c5cSJames Wright if (elem_restr_jd_i_sur) 5858e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_NONE, jac_data_sur)); 59368c645fSJames Wright 60368c645fSJames Wright if (qf_apply_bc_jacobian) { 61b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc_jacobian, NULL, NULL, &op_apply_bc_jacobian)); 62b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 63b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "Grad_dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 6458e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, q_data_sur)); 65b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 6658e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_NONE, jac_data_sur)); 67b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 68368c645fSJames Wright } 69368c645fSJames Wright 70368c645fSJames Wright // ----- Apply CEED operator for Setup 71b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorApply(op_setup_sur, ceed_data->x_coord, q_data_sur, CEED_REQUEST_IMMEDIATE)); 72368c645fSJames Wright 73368c645fSJames Wright // ----- Apply Sub-Operator for Physics 74b4c37c5cSJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_bc)); 75b4c37c5cSJames Wright if (op_apply_bc_jacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_bc_jacobian)); 76368c645fSJames Wright 77368c645fSJames Wright // ----- Cleanup 78b4c37c5cSJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&q_data_sur)); 79b4c37c5cSJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data_sur)); 80b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_q_sur)); 81b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_x_sur)); 82b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_qd_i_sur)); 83b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i_sur)); 84b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_setup_sur)); 85b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc)); 86b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc_jacobian)); 87d949ddfcSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 88368c645fSJames Wright } 89368c645fSJames Wright 90a515125bSLeila Ghaffari // Utility function to create CEED Composite Operator for the entire domain 912b916ea7SJeremy L Thompson PetscErrorCode CreateOperatorForDomain(Ceed ceed, DM dm, SimpleBC bc, CeedData ceed_data, Physics phys, CeedOperator op_apply_vol, 922b916ea7SJeremy L Thompson CeedOperator op_apply_ijacobian_vol, CeedInt height, CeedInt P_sur, CeedInt Q_sur, CeedInt q_data_size_sur, 932b916ea7SJeremy L Thompson CeedInt jac_data_size_sur, CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 94a515125bSLeila Ghaffari DMLabel domain_label; 95a515125bSLeila Ghaffari 9606f41313SJames Wright PetscFunctionBeginUser; 97a515125bSLeila Ghaffari // Create Composite Operaters 98b4c37c5cSJames Wright PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply)); 99b4c37c5cSJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply_ijacobian)); 100a515125bSLeila Ghaffari 101a515125bSLeila Ghaffari // --Apply Sub-Operator for the volume 102b4c37c5cSJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_vol)); 103b4c37c5cSJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_ijacobian_vol)); 104a515125bSLeila Ghaffari 105a515125bSLeila Ghaffari // -- Create Sub-Operator for in/outflow BCs 1062b916ea7SJeremy L Thompson PetscCall(DMGetLabel(dm, "Face Sets", &domain_label)); 107a515125bSLeila Ghaffari 108002797a3SLeila Ghaffari // --- Create Sub-Operator for inflow boundaries 109002797a3SLeila Ghaffari for (CeedInt i = 0; i < bc->num_inflow; i++) { 1102b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->inflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1112b916ea7SJeremy L Thompson ceed_data->qf_apply_inflow, ceed_data->qf_apply_inflow_jacobian, op_apply, op_apply_ijacobian)); 112a515125bSLeila Ghaffari } 113002797a3SLeila Ghaffari // --- Create Sub-Operator for outflow boundaries 114002797a3SLeila Ghaffari for (CeedInt i = 0; i < bc->num_outflow; i++) { 1152b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->outflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1162b916ea7SJeremy L Thompson ceed_data->qf_apply_outflow, ceed_data->qf_apply_outflow_jacobian, op_apply, op_apply_ijacobian)); 1172556a851SJed Brown } 118df55ba5fSJames Wright // --- Create Sub-Operator for freestream boundaries 119df55ba5fSJames Wright for (CeedInt i = 0; i < bc->num_freestream; i++) { 1202b916ea7SJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->freestreams[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1212b916ea7SJeremy L Thompson ceed_data->qf_apply_freestream, ceed_data->qf_apply_freestream_jacobian, op_apply, op_apply_ijacobian)); 122002797a3SLeila Ghaffari } 1239ed3d70dSJames Wright // --- Create Sub-Operator for slip boundaries 1249ed3d70dSJames Wright for (CeedInt i = 0; i < bc->num_slip; i++) { 1259ed3d70dSJames Wright PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->slips[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1269ed3d70dSJames Wright ceed_data->qf_apply_slip, ceed_data->qf_apply_slip_jacobian, op_apply, op_apply_ijacobian)); 1279ed3d70dSJames Wright } 12892ada588SJames Wright 12992ada588SJames Wright // ----- Get Context Labels for Operator 130b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "solution time", &phys->solution_time_label)); 131b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "timestep size", &phys->timestep_size_label)); 132d949ddfcSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 133a515125bSLeila Ghaffari } 134a515125bSLeila Ghaffari 1352b916ea7SJeremy L Thompson PetscErrorCode SetupBCQFunctions(Ceed ceed, PetscInt dim_sur, PetscInt num_comp_x, PetscInt num_comp_q, PetscInt q_data_size_sur, 1362b916ea7SJeremy L Thompson PetscInt jac_data_size_sur, ProblemQFunctionSpec apply_bc, ProblemQFunctionSpec apply_bc_jacobian, 13725988f00SJames Wright CeedQFunction *qf_apply_bc, CeedQFunction *qf_apply_bc_jacobian) { 13825988f00SJames Wright PetscFunctionBeginUser; 13925988f00SJames Wright if (apply_bc.qfunction) { 140b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc.qfunction, apply_bc.qfunction_loc, qf_apply_bc)); 141b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc, apply_bc.qfunction_context)); 142ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(*qf_apply_bc, 0)); 143b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "q", num_comp_q, CEED_EVAL_INTERP)); 144b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "Grad_q", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 145b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 146b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "x", num_comp_x, CEED_EVAL_INTERP)); 147b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "v", num_comp_q, CEED_EVAL_INTERP)); 148b4c37c5cSJames Wright if (jac_data_size_sur) PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 14925988f00SJames Wright } 15025988f00SJames Wright if (apply_bc_jacobian.qfunction) { 151b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc_jacobian.qfunction, apply_bc_jacobian.qfunction_loc, qf_apply_bc_jacobian)); 152b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc_jacobian, apply_bc_jacobian.qfunction_context)); 153ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(*qf_apply_bc_jacobian, 0)); 154b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "dq", num_comp_q, CEED_EVAL_INTERP)); 155b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "Grad_dq", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 156b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 157b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "x", num_comp_x, CEED_EVAL_INTERP)); 158b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 159b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc_jacobian, "v", num_comp_q, CEED_EVAL_INTERP)); 16025988f00SJames Wright } 161d949ddfcSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 16225988f00SJames Wright } 16325988f00SJames Wright 1642b916ea7SJeremy L Thompson PetscErrorCode SetupLibceed(Ceed ceed, CeedData ceed_data, DM dm, User user, AppCtx app_ctx, ProblemData *problem, SimpleBC bc) { 165a515125bSLeila Ghaffari PetscFunctionBeginUser; 166a515125bSLeila Ghaffari // ***************************************************************************** 167a515125bSLeila Ghaffari // Set up CEED objects for the interior domain (volume) 168a515125bSLeila Ghaffari // ***************************************************************************** 169a515125bSLeila Ghaffari const PetscInt num_comp_q = 5; 17094a7b3d2SKenneth E. Jansen const CeedInt dim = problem->dim, num_comp_x = problem->dim, q_data_size_vol = problem->q_data_size_vol; 17194a7b3d2SKenneth E. Jansen CeedInt jac_data_size_vol = num_comp_q + 6 + 3; 17294a7b3d2SKenneth E. Jansen 1737d8a615bSJames Wright if (problem->apply_vol_ifunction.qfunction && problem->uses_newtonian) { 17494a7b3d2SKenneth E. Jansen NewtonianIdealGasContext gas; 17594a7b3d2SKenneth E. Jansen PetscCallCeed(ceed, CeedQFunctionContextGetDataRead(problem->apply_vol_ifunction.qfunction_context, CEED_MEM_HOST, &gas)); 17694a7b3d2SKenneth E. Jansen jac_data_size_vol += (gas->idl_enable ? 1 : 0); 17794a7b3d2SKenneth E. Jansen PetscCallCeed(ceed, CeedQFunctionContextRestoreDataRead(problem->apply_vol_ifunction.qfunction_context, &gas)); 17894a7b3d2SKenneth E. Jansen } 17994a7b3d2SKenneth E. Jansen 180752f40e3SJed Brown CeedElemRestriction elem_restr_jd_i; 181752f40e3SJed Brown CeedVector jac_data; 18267263decSKenneth E. Jansen CeedInt num_qpts; 18315c18037SJames Wright DMLabel domain_label = NULL; 18415c18037SJames Wright PetscInt label_value = 0, height = 0, dm_field = 0; 185a515125bSLeila Ghaffari 186a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 187a515125bSLeila Ghaffari // CEED Bases 188a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 18967263decSKenneth E. Jansen DM dm_coord; 19067263decSKenneth E. Jansen PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 19167263decSKenneth E. Jansen 19215c18037SJames Wright PetscCall(CreateBasisFromPlex(ceed, dm, domain_label, label_value, height, dm_field, &ceed_data->basis_q)); 19315c18037SJames Wright PetscCall(CreateBasisFromPlex(ceed, dm_coord, domain_label, label_value, height, dm_field, &ceed_data->basis_x)); 194b4c37c5cSJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x, ceed_data->basis_q, &ceed_data->basis_xc)); 195b4c37c5cSJames Wright PetscCallCeed(ceed, CeedBasisGetNumQuadraturePoints(ceed_data->basis_q, &num_qpts)); 196a515125bSLeila Ghaffari 197a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 198a515125bSLeila Ghaffari // CEED Restrictions 199a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 200a515125bSLeila Ghaffari // -- Create restriction 20115c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionCreate(ceed, dm, domain_label, label_value, height, 0, &ceed_data->elem_restr_q)); 20215c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionCoordinateCreate(ceed, dm, domain_label, label_value, height, &ceed_data->elem_restr_x)); 20315c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, q_data_size_vol, &ceed_data->elem_restr_qd_i)); 20415c18037SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, jac_data_size_vol, &elem_restr_jd_i)); 205a515125bSLeila Ghaffari // -- Create E vectors 206b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_ceed, NULL)); 207b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_dot_ceed, NULL)); 208b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->g_ceed, NULL)); 209a515125bSLeila Ghaffari 210a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 211a515125bSLeila Ghaffari // CEED QFunctions 212a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 213a515125bSLeila Ghaffari // -- Create QFunction for quadrature data 214b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_vol.qfunction, problem->setup_vol.qfunction_loc, &ceed_data->qf_setup_vol)); 21515a3537eSJed Brown if (problem->setup_vol.qfunction_context) { 216b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_vol, problem->setup_vol.qfunction_context)); 21715a3537eSJed Brown } 218ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(ceed_data->qf_setup_vol, 0)); 219b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 220b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "weight", 1, CEED_EVAL_WEIGHT)); 221b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 222a515125bSLeila Ghaffari 223a515125bSLeila Ghaffari // -- Create QFunction for ICs 224b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->ics.qfunction, problem->ics.qfunction_loc, &ceed_data->qf_ics)); 225b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ics, problem->ics.qfunction_context)); 226ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(ceed_data->qf_ics, 0)); 227b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "x", num_comp_x, CEED_EVAL_INTERP)); 228b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 229b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ics, "q0", num_comp_q, CEED_EVAL_NONE)); 230a515125bSLeila Ghaffari 231a515125bSLeila Ghaffari // -- Create QFunction for RHS 2329785fe93SJed Brown if (problem->apply_vol_rhs.qfunction) { 233b4c37c5cSJames Wright PetscCallCeed( 234b4c37c5cSJames Wright ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_rhs.qfunction, problem->apply_vol_rhs.qfunction_loc, &ceed_data->qf_rhs_vol)); 235b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_rhs_vol, problem->apply_vol_rhs.qfunction_context)); 236ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(ceed_data->qf_rhs_vol, 0)); 237b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 238b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 239b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 240b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 241b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 242b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 243a515125bSLeila Ghaffari } 244a515125bSLeila Ghaffari 245a515125bSLeila Ghaffari // -- Create QFunction for IFunction 2469785fe93SJed Brown if (problem->apply_vol_ifunction.qfunction) { 247b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ifunction.qfunction, problem->apply_vol_ifunction.qfunction_loc, 248b4c37c5cSJames Wright &ceed_data->qf_ifunction_vol)); 249b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ifunction_vol, problem->apply_vol_ifunction.qfunction_context)); 250ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(ceed_data->qf_ifunction_vol, 0)); 251b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 252b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 253b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q dot", num_comp_q, CEED_EVAL_INTERP)); 254b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 255b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 256b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 257b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 258b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 259a515125bSLeila Ghaffari } 260a515125bSLeila Ghaffari 261f0b65372SJed Brown CeedQFunction qf_ijacobian_vol = NULL; 262f0b65372SJed Brown if (problem->apply_vol_ijacobian.qfunction) { 263b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ijacobian.qfunction, problem->apply_vol_ijacobian.qfunction_loc, 264b4c37c5cSJames Wright &qf_ijacobian_vol)); 265b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(qf_ijacobian_vol, problem->apply_vol_ijacobian.qfunction_context)); 266ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(qf_ijacobian_vol, 0)); 267b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "dq", num_comp_q, CEED_EVAL_INTERP)); 268b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "Grad_dq", num_comp_q * dim, CEED_EVAL_GRAD)); 269b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 270b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 271b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 272b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 273f0b65372SJed Brown } 274f0b65372SJed Brown 275a515125bSLeila Ghaffari // --------------------------------------------------------------------------- 276a515125bSLeila Ghaffari // Element coordinates 277a515125bSLeila Ghaffari // --------------------------------------------------------------------------- 278a515125bSLeila Ghaffari // -- Create CEED vector 279b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_x, &ceed_data->x_coord, NULL)); 280a515125bSLeila Ghaffari 281a515125bSLeila Ghaffari // -- Copy PETSc vector in CEED vector 282a515125bSLeila Ghaffari Vec X_loc; 283cac8aa24SJed Brown { 284cac8aa24SJed Brown DM cdm; 2852b916ea7SJeremy L Thompson PetscCall(DMGetCellCoordinateDM(dm, &cdm)); 2862b916ea7SJeremy L Thompson if (cdm) { 2872b916ea7SJeremy L Thompson PetscCall(DMGetCellCoordinatesLocal(dm, &X_loc)); 2882b916ea7SJeremy L Thompson } else { 2892b916ea7SJeremy L Thompson PetscCall(DMGetCoordinatesLocal(dm, &X_loc)); 290cac8aa24SJed Brown } 2912b916ea7SJeremy L Thompson } 2922b916ea7SJeremy L Thompson PetscCall(VecScale(X_loc, problem->dm_scale)); 293a7dac1d5SJames Wright PetscCall(VecCopyPetscToCeed(X_loc, ceed_data->x_coord)); 294a515125bSLeila Ghaffari 295a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 296a515125bSLeila Ghaffari // CEED vectors 297a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 298a515125bSLeila Ghaffari // -- Create CEED vector for geometric data 299b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_qd_i, &ceed_data->q_data, NULL)); 300b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i, &jac_data, NULL)); 3010b0430b7SJames Wright 302a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 303a515125bSLeila Ghaffari // CEED Operators 304a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 305a515125bSLeila Ghaffari // -- Create CEED operator for quadrature data 306b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_vol, NULL, NULL, &ceed_data->op_setup_vol)); 307b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "dx", ceed_data->elem_restr_x, ceed_data->basis_x, CEED_VECTOR_ACTIVE)); 308b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x, CEED_VECTOR_NONE)); 30958e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 310a515125bSLeila Ghaffari 311a515125bSLeila Ghaffari // -- Create CEED operator for ICs 3128f18bb8bSJames Wright CeedOperator op_ics; 313b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ics, NULL, NULL, &op_ics)); 314b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "x", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 315b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "dx", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 31658e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "q0", ceed_data->elem_restr_q, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 317b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_ics, "evaluation time", &user->phys->ics_time_label)); 3188f18bb8bSJames Wright PetscCall(OperatorApplyContextCreate(NULL, dm, user->ceed, op_ics, ceed_data->x_coord, NULL, NULL, user->Q_loc, &ceed_data->op_ics_ctx)); 319b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ics)); 320a515125bSLeila Ghaffari 321a515125bSLeila Ghaffari // Create CEED operator for RHS 322a515125bSLeila Ghaffari if (ceed_data->qf_rhs_vol) { 323a515125bSLeila Ghaffari CeedOperator op; 324b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_rhs_vol, NULL, NULL, &op)); 325b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 326b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 32758e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 328b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 329b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 330b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 331a515125bSLeila Ghaffari user->op_rhs_vol = op; 332a515125bSLeila Ghaffari } 333a515125bSLeila Ghaffari 334a515125bSLeila Ghaffari // -- CEED operator for IFunction 335a515125bSLeila Ghaffari if (ceed_data->qf_ifunction_vol) { 336a515125bSLeila Ghaffari CeedOperator op; 337b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ifunction_vol, NULL, NULL, &op)); 338b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 339b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 340b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q dot", ceed_data->elem_restr_q, ceed_data->basis_q, user->q_dot_ceed)); 34158e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 342b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 343b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 344b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 34558e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_NONE, jac_data)); 346752f40e3SJed Brown 347a515125bSLeila Ghaffari user->op_ifunction_vol = op; 348a515125bSLeila Ghaffari } 349a515125bSLeila Ghaffari 350f0b65372SJed Brown CeedOperator op_ijacobian_vol = NULL; 351f0b65372SJed Brown if (qf_ijacobian_vol) { 352f0b65372SJed Brown CeedOperator op; 353b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_ijacobian_vol, NULL, NULL, &op)); 354b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 355b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 35658e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 35758e1cbfdSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_NONE, jac_data)); 358b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 359b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 360f0b65372SJed Brown op_ijacobian_vol = op; 361b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionDestroy(&qf_ijacobian_vol)); 362f0b65372SJed Brown } 363f0b65372SJed Brown 364a515125bSLeila Ghaffari // ***************************************************************************** 365a515125bSLeila Ghaffari // Set up CEED objects for the exterior domain (surface) 366a515125bSLeila Ghaffari // ***************************************************************************** 36715c18037SJames Wright height = 1; 36815c18037SJames Wright CeedInt dim_sur = dim - height, P_sur = app_ctx->degree + 1, Q_sur = P_sur + app_ctx->q_extra; 3692b916ea7SJeremy L Thompson const CeedInt q_data_size_sur = problem->q_data_size_sur, jac_data_size_sur = problem->jac_data_size_sur; 370a515125bSLeila Ghaffari 371a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 372a515125bSLeila Ghaffari // CEED Bases 373a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 37467263decSKenneth E. Jansen 37567263decSKenneth E. Jansen DMLabel label = 0; 37667263decSKenneth E. Jansen PetscInt face_id = 0; 37767263decSKenneth E. Jansen PetscInt field = 0; // Still want the normal, default field 37867263decSKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm, label, face_id, height, field, &ceed_data->basis_q_sur)); 37967263decSKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm_coord, label, face_id, height, field, &ceed_data->basis_x_sur)); 380b4c37c5cSJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x_sur, ceed_data->basis_q_sur, &ceed_data->basis_xc_sur)); 381a515125bSLeila Ghaffari 382a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 383a515125bSLeila Ghaffari // CEED QFunctions 384a515125bSLeila Ghaffari // ----------------------------------------------------------------------------- 385a515125bSLeila Ghaffari // -- Create QFunction for quadrature data 386b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_sur.qfunction, problem->setup_sur.qfunction_loc, &ceed_data->qf_setup_sur)); 38715a3537eSJed Brown if (problem->setup_sur.qfunction_context) { 388b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_sur, problem->setup_sur.qfunction_context)); 38915a3537eSJed Brown } 390ebfabadfSJames Wright PetscCallCeed(ceed, CeedQFunctionSetUserFlopsEstimate(ceed_data->qf_setup_sur, 0)); 391b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "dx", num_comp_x * dim_sur, CEED_EVAL_GRAD)); 392b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "weight", 1, CEED_EVAL_WEIGHT)); 393b4c37c5cSJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_sur, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 394a515125bSLeila Ghaffari 3952b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_inflow, 3962b916ea7SJeremy L Thompson problem->apply_inflow_jacobian, &ceed_data->qf_apply_inflow, &ceed_data->qf_apply_inflow_jacobian)); 3972b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_outflow, 3982b916ea7SJeremy L Thompson problem->apply_outflow_jacobian, &ceed_data->qf_apply_outflow, &ceed_data->qf_apply_outflow_jacobian)); 3992b916ea7SJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_freestream, 4002b916ea7SJeremy L Thompson problem->apply_freestream_jacobian, &ceed_data->qf_apply_freestream, &ceed_data->qf_apply_freestream_jacobian)); 4019ed3d70dSJames Wright PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_slip, 4029ed3d70dSJames Wright problem->apply_slip_jacobian, &ceed_data->qf_apply_slip, &ceed_data->qf_apply_slip_jacobian)); 403a515125bSLeila Ghaffari 404a515125bSLeila Ghaffari // ***************************************************************************** 405a515125bSLeila Ghaffari // CEED Operator Apply 406a515125bSLeila Ghaffari // ***************************************************************************** 407a515125bSLeila Ghaffari // -- Apply CEED Operator for the geometric data 408b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorApply(ceed_data->op_setup_vol, ceed_data->x_coord, ceed_data->q_data, CEED_REQUEST_IMMEDIATE)); 409a515125bSLeila Ghaffari 410a515125bSLeila Ghaffari // -- Create and apply CEED Composite Operator for the entire domain 411a515125bSLeila Ghaffari if (!user->phys->implicit) { // RHS 412da5fe0e4SJames Wright CeedOperator op_rhs; 413da5fe0e4SJames 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, 414da5fe0e4SJames Wright NULL)); 415da5fe0e4SJames Wright PetscCall(OperatorApplyContextCreate(dm, dm, ceed, op_rhs, user->q_ceed, user->g_ceed, user->Q_loc, NULL, &user->op_rhs_ctx)); 416b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_rhs)); 417*c2376cc9SJames Wright PetscCheck(app_ctx->sgs_model_type == SGS_MODEL_NONE, user->comm, PETSC_ERR_SUP, "SGS modeling not implemented for explicit timestepping"); 418a515125bSLeila Ghaffari } else { // IFunction 419ebfabadfSJames Wright CeedOperator op_ijacobian = NULL; 420ebfabadfSJames Wright 4212b916ea7SJeremy L Thompson PetscCall(CreateOperatorForDomain(ceed, dm, bc, ceed_data, user->phys, user->op_ifunction_vol, op_ijacobian_vol, height, P_sur, Q_sur, 422ebfabadfSJames Wright q_data_size_sur, jac_data_size_sur, &user->op_ifunction, op_ijacobian_vol ? &op_ijacobian : NULL)); 423ebfabadfSJames Wright if (op_ijacobian) { 424ebfabadfSJames Wright PetscCall(MatCeedCreate(user->dm, user->dm, op_ijacobian, NULL, &user->mat_ijacobian)); 425ebfabadfSJames Wright PetscCall(MatCeedSetLocalVectors(user->mat_ijacobian, user->Q_dot_loc, NULL)); 426ebfabadfSJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_ijacobian, "ijacobian time shift", &user->phys->ijacobian_time_shift_label)); 427ebfabadfSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ijacobian)); 428f0b65372SJed Brown } 429ad494f68SJames Wright if (app_ctx->sgs_model_type == SGS_MODEL_DATA_DRIVEN) PetscCall(SgsDDSetup(ceed, user, ceed_data, problem)); 4306d0190e2SJames Wright } 43191933550SJames Wright 432*c2376cc9SJames Wright if (problem->use_strong_bc_ceed) PetscCall(SetupStrongBC_Ceed(ceed, ceed_data, dm, user, problem, bc)); 43391933550SJames Wright if (app_ctx->turb_spanstats_enable) PetscCall(TurbulenceStatisticsSetup(ceed, user, ceed_data, problem)); 434aa0b7f76SJames Wright if (app_ctx->diff_filter_monitor && !user->diff_filter) PetscCall(DifferentialFilterSetup(ceed, user, ceed_data, problem)); 4351c17f66aSJames Wright if (app_ctx->sgs_train_enable) PetscCall(SGS_DD_TrainingSetup(ceed, user, ceed_data, problem)); 43691933550SJames Wright 437b4c37c5cSJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i)); 438b4c37c5cSJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ijacobian_vol)); 439b4c37c5cSJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data)); 440d949ddfcSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 441a515125bSLeila Ghaffari } 442