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) { 19bb85d312SJames Wright CeedVector q_data_sur, jac_data_sur = NULL; 202b730f8bSJeremy L Thompson CeedOperator op_setup_sur, op_apply_bc, op_apply_bc_jacobian = NULL; 21bb85d312SJames Wright CeedElemRestriction elem_restr_x_sur, elem_restr_q_sur, elem_restr_qd_i_sur, elem_restr_jd_i_sur = NULL; 22bb85d312SJames Wright CeedInt num_qpts_sur, dm_field = 0; 239eb9c072SJames Wright 24f17d818dSJames 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 29bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionCreate(ceed, dm, domain_label, label_value, height, dm_field, &elem_restr_q_sur)); 30bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionCoordinateCreate(ceed, dm, domain_label, label_value, height, &elem_restr_x_sur)); 31bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, q_data_size_sur, &elem_restr_qd_i_sur)); 329eb9c072SJames Wright if (jac_data_size_sur > 0) { 339eb9c072SJames Wright // State-dependent data will be passed from residual to Jacobian. This will be collocated. 34bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, jac_data_size_sur, &elem_restr_jd_i_sur)); 35a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i_sur, &jac_data_sur, NULL)); 369eb9c072SJames Wright } 379eb9c072SJames Wright 389eb9c072SJames Wright // ---- CEED Vector 39457e73b2SJames Wright CeedInt loc_num_elem_sur; 40a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionGetNumElements(elem_restr_q_sur, &loc_num_elem_sur)); 41a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorCreate(ceed, q_data_size_sur * loc_num_elem_sur * num_qpts_sur, &q_data_sur)); 429eb9c072SJames Wright 439eb9c072SJames Wright // ---- CEED Operator 449eb9c072SJames Wright // ----- CEED Operator for Setup (geometric factors) 45a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_sur, NULL, NULL, &op_setup_sur)); 46a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "dx", elem_restr_x_sur, ceed_data->basis_x_sur, CEED_VECTOR_ACTIVE)); 47a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x_sur, CEED_VECTOR_NONE)); 48356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_setup_sur, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 499eb9c072SJames Wright 509eb9c072SJames Wright // ----- CEED Operator for Physics 51a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc, NULL, NULL, &op_apply_bc)); 52a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 53a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "Grad_q", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 54356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, q_data_sur)); 55a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 56a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 57a424bcd0SJames Wright if (elem_restr_jd_i_sur) 58356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_NONE, jac_data_sur)); 599eb9c072SJames Wright 609eb9c072SJames Wright if (qf_apply_bc_jacobian) { 61a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc_jacobian, NULL, NULL, &op_apply_bc_jacobian)); 62a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 63a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "Grad_dq", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 64356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, q_data_sur)); 65a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "x", elem_restr_x_sur, ceed_data->basis_x_sur, ceed_data->x_coord)); 66356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_NONE, jac_data_sur)); 67a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc_jacobian, "v", elem_restr_q_sur, ceed_data->basis_q_sur, CEED_VECTOR_ACTIVE)); 689eb9c072SJames Wright } 699eb9c072SJames Wright 709eb9c072SJames Wright // ----- Apply CEED operator for Setup 71a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorApply(op_setup_sur, ceed_data->x_coord, q_data_sur, CEED_REQUEST_IMMEDIATE)); 729eb9c072SJames Wright 739eb9c072SJames Wright // ----- Apply Sub-Operator for Physics 74a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_bc)); 75a424bcd0SJames Wright if (op_apply_bc_jacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_bc_jacobian)); 769eb9c072SJames Wright 779eb9c072SJames Wright // ----- Cleanup 78a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&q_data_sur)); 79a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data_sur)); 80a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_q_sur)); 81a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_x_sur)); 82a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_qd_i_sur)); 83a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i_sur)); 84a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_setup_sur)); 85a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc)); 86a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_apply_bc_jacobian)); 87ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 889eb9c072SJames Wright } 899eb9c072SJames Wright 9077841947SLeila Ghaffari // Utility function to create CEED Composite Operator for the entire domain 912b730f8bSJeremy L Thompson PetscErrorCode CreateOperatorForDomain(Ceed ceed, DM dm, SimpleBC bc, CeedData ceed_data, Physics phys, CeedOperator op_apply_vol, 922b730f8bSJeremy L Thompson CeedOperator op_apply_ijacobian_vol, CeedInt height, CeedInt P_sur, CeedInt Q_sur, CeedInt q_data_size_sur, 932b730f8bSJeremy L Thompson CeedInt jac_data_size_sur, CeedOperator *op_apply, CeedOperator *op_apply_ijacobian) { 9477841947SLeila Ghaffari DMLabel domain_label; 9577841947SLeila Ghaffari 96f17d818dSJames Wright PetscFunctionBeginUser; 9777841947SLeila Ghaffari // Create Composite Operaters 98a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply)); 99a424bcd0SJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorCreate(ceed, op_apply_ijacobian)); 10077841947SLeila Ghaffari 10177841947SLeila Ghaffari // --Apply Sub-Operator for the volume 102a424bcd0SJames Wright PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply, op_apply_vol)); 103a424bcd0SJames Wright if (op_apply_ijacobian) PetscCallCeed(ceed, CeedCompositeOperatorAddSub(*op_apply_ijacobian, op_apply_ijacobian_vol)); 10477841947SLeila Ghaffari 10577841947SLeila Ghaffari // -- Create Sub-Operator for in/outflow BCs 1062b730f8bSJeremy L Thompson PetscCall(DMGetLabel(dm, "Face Sets", &domain_label)); 10777841947SLeila Ghaffari 1082fe7aee7SLeila Ghaffari // --- Create Sub-Operator for inflow boundaries 1092fe7aee7SLeila Ghaffari for (CeedInt i = 0; i < bc->num_inflow; i++) { 1102b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->inflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1112b730f8bSJeremy L Thompson ceed_data->qf_apply_inflow, ceed_data->qf_apply_inflow_jacobian, op_apply, op_apply_ijacobian)); 11277841947SLeila Ghaffari } 1132fe7aee7SLeila Ghaffari // --- Create Sub-Operator for outflow boundaries 1142fe7aee7SLeila Ghaffari for (CeedInt i = 0; i < bc->num_outflow; i++) { 1152b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->outflows[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1162b730f8bSJeremy L Thompson ceed_data->qf_apply_outflow, ceed_data->qf_apply_outflow_jacobian, op_apply, op_apply_ijacobian)); 11739c69132SJed Brown } 118f4ca79c2SJames Wright // --- Create Sub-Operator for freestream boundaries 119f4ca79c2SJames Wright for (CeedInt i = 0; i < bc->num_freestream; i++) { 1202b730f8bSJeremy L Thompson PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->freestreams[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 1212b730f8bSJeremy L Thompson ceed_data->qf_apply_freestream, ceed_data->qf_apply_freestream_jacobian, op_apply, op_apply_ijacobian)); 1222fe7aee7SLeila Ghaffari } 123*9f844368SJames Wright // --- Create Sub-Operator for slip boundaries 124*9f844368SJames Wright for (CeedInt i = 0; i < bc->num_slip; i++) { 125*9f844368SJames Wright PetscCall(AddBCSubOperator(ceed, dm, ceed_data, domain_label, bc->slips[i], height, Q_sur, q_data_size_sur, jac_data_size_sur, 126*9f844368SJames Wright ceed_data->qf_apply_slip, ceed_data->qf_apply_slip_jacobian, op_apply, op_apply_ijacobian)); 127*9f844368SJames Wright } 12811436a05SJames Wright 12911436a05SJames Wright // ----- Get Context Labels for Operator 130a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "solution time", &phys->solution_time_label)); 131a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(*op_apply, "timestep size", &phys->timestep_size_label)); 132ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 13377841947SLeila Ghaffari } 13477841947SLeila Ghaffari 1352b730f8bSJeremy L Thompson PetscErrorCode SetupBCQFunctions(Ceed ceed, PetscInt dim_sur, PetscInt num_comp_x, PetscInt num_comp_q, PetscInt q_data_size_sur, 1362b730f8bSJeremy L Thompson PetscInt jac_data_size_sur, ProblemQFunctionSpec apply_bc, ProblemQFunctionSpec apply_bc_jacobian, 1375b881d11SJames Wright CeedQFunction *qf_apply_bc, CeedQFunction *qf_apply_bc_jacobian) { 1385b881d11SJames Wright PetscFunctionBeginUser; 1395b881d11SJames Wright if (apply_bc.qfunction) { 140a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc.qfunction, apply_bc.qfunction_loc, qf_apply_bc)); 141a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc, apply_bc.qfunction_context)); 142a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "q", num_comp_q, CEED_EVAL_INTERP)); 143a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "Grad_q", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 144a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 145a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc, "x", num_comp_x, CEED_EVAL_INTERP)); 146a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "v", num_comp_q, CEED_EVAL_INTERP)); 147a424bcd0SJames Wright if (jac_data_size_sur) PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 1485b881d11SJames Wright } 1495b881d11SJames Wright if (apply_bc_jacobian.qfunction) { 150a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, apply_bc_jacobian.qfunction, apply_bc_jacobian.qfunction_loc, qf_apply_bc_jacobian)); 151a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(*qf_apply_bc_jacobian, apply_bc_jacobian.qfunction_context)); 152a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "dq", num_comp_q, CEED_EVAL_INTERP)); 153a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "Grad_dq", num_comp_q * dim_sur, CEED_EVAL_GRAD)); 154a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 155a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "x", num_comp_x, CEED_EVAL_INTERP)); 156a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(*qf_apply_bc_jacobian, "surface jacobian data", jac_data_size_sur, CEED_EVAL_NONE)); 157a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(*qf_apply_bc_jacobian, "v", num_comp_q, CEED_EVAL_INTERP)); 1585b881d11SJames Wright } 159ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 1605b881d11SJames Wright } 1615b881d11SJames Wright 1622b730f8bSJeremy L Thompson PetscErrorCode SetupLibceed(Ceed ceed, CeedData ceed_data, DM dm, User user, AppCtx app_ctx, ProblemData *problem, SimpleBC bc) { 16377841947SLeila Ghaffari PetscFunctionBeginUser; 16477841947SLeila Ghaffari // ***************************************************************************** 16577841947SLeila Ghaffari // Set up CEED objects for the interior domain (volume) 16677841947SLeila Ghaffari // ***************************************************************************** 16777841947SLeila Ghaffari const PetscInt num_comp_q = 5; 1681d2a9659SKenneth E. Jansen const CeedInt dim = problem->dim, num_comp_x = problem->dim, q_data_size_vol = problem->q_data_size_vol; 1691d2a9659SKenneth E. Jansen CeedInt jac_data_size_vol = num_comp_q + 6 + 3; 1701d2a9659SKenneth E. Jansen 171752a08a7SJames Wright if (problem->apply_vol_ifunction.qfunction && problem->uses_newtonian) { 1721d2a9659SKenneth E. Jansen NewtonianIdealGasContext gas; 1731d2a9659SKenneth E. Jansen PetscCallCeed(ceed, CeedQFunctionContextGetDataRead(problem->apply_vol_ifunction.qfunction_context, CEED_MEM_HOST, &gas)); 1741d2a9659SKenneth E. Jansen jac_data_size_vol += (gas->idl_enable ? 1 : 0); 1751d2a9659SKenneth E. Jansen PetscCallCeed(ceed, CeedQFunctionContextRestoreDataRead(problem->apply_vol_ifunction.qfunction_context, &gas)); 1761d2a9659SKenneth E. Jansen } 1771d2a9659SKenneth E. Jansen 178a3ae0734SJed Brown CeedElemRestriction elem_restr_jd_i; 179a3ae0734SJed Brown CeedVector jac_data; 1800814d5a7SKenneth E. Jansen CeedInt num_qpts; 181bb85d312SJames Wright DMLabel domain_label = NULL; 182bb85d312SJames Wright PetscInt label_value = 0, height = 0, dm_field = 0; 18377841947SLeila Ghaffari 18477841947SLeila Ghaffari // ----------------------------------------------------------------------------- 18577841947SLeila Ghaffari // CEED Bases 18677841947SLeila Ghaffari // ----------------------------------------------------------------------------- 1870814d5a7SKenneth E. Jansen DM dm_coord; 1880814d5a7SKenneth E. Jansen PetscCall(DMGetCoordinateDM(dm, &dm_coord)); 1890814d5a7SKenneth E. Jansen 190bb85d312SJames Wright PetscCall(CreateBasisFromPlex(ceed, dm, domain_label, label_value, height, dm_field, &ceed_data->basis_q)); 191bb85d312SJames Wright PetscCall(CreateBasisFromPlex(ceed, dm_coord, domain_label, label_value, height, dm_field, &ceed_data->basis_x)); 192a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x, ceed_data->basis_q, &ceed_data->basis_xc)); 193a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisGetNumQuadraturePoints(ceed_data->basis_q, &num_qpts)); 19477841947SLeila Ghaffari 19577841947SLeila Ghaffari // ----------------------------------------------------------------------------- 19677841947SLeila Ghaffari // CEED Restrictions 19777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 19877841947SLeila Ghaffari // -- Create restriction 199bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionCreate(ceed, dm, domain_label, label_value, height, 0, &ceed_data->elem_restr_q)); 200bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionCoordinateCreate(ceed, dm, domain_label, label_value, height, &ceed_data->elem_restr_x)); 201bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, q_data_size_vol, &ceed_data->elem_restr_qd_i)); 202bb85d312SJames Wright PetscCall(DMPlexCeedElemRestrictionQDataCreate(ceed, dm, domain_label, label_value, height, jac_data_size_vol, &elem_restr_jd_i)); 20377841947SLeila Ghaffari // -- Create E vectors 204a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_ceed, NULL)); 205a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->q_dot_ceed, NULL)); 206a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_q, &user->g_ceed, NULL)); 20777841947SLeila Ghaffari 20877841947SLeila Ghaffari // ----------------------------------------------------------------------------- 20977841947SLeila Ghaffari // CEED QFunctions 21077841947SLeila Ghaffari // ----------------------------------------------------------------------------- 21177841947SLeila Ghaffari // -- Create QFunction for quadrature data 212a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_vol.qfunction, problem->setup_vol.qfunction_loc, &ceed_data->qf_setup_vol)); 213841e4c73SJed Brown if (problem->setup_vol.qfunction_context) { 214a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_vol, problem->setup_vol.qfunction_context)); 215841e4c73SJed Brown } 216a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 217a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_vol, "weight", 1, CEED_EVAL_WEIGHT)); 218a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 21977841947SLeila Ghaffari 22077841947SLeila Ghaffari // -- Create QFunction for ICs 221a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->ics.qfunction, problem->ics.qfunction_loc, &ceed_data->qf_ics)); 222a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ics, problem->ics.qfunction_context)); 223a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "x", num_comp_x, CEED_EVAL_INTERP)); 224a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ics, "dx", num_comp_x * dim, CEED_EVAL_GRAD)); 225a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ics, "q0", num_comp_q, CEED_EVAL_NONE)); 22677841947SLeila Ghaffari 22777841947SLeila Ghaffari // -- Create QFunction for RHS 22891e5af17SJed Brown if (problem->apply_vol_rhs.qfunction) { 229a424bcd0SJames Wright PetscCallCeed( 230a424bcd0SJames Wright ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_rhs.qfunction, problem->apply_vol_rhs.qfunction_loc, &ceed_data->qf_rhs_vol)); 231a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_rhs_vol, problem->apply_vol_rhs.qfunction_context)); 232a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 233a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 234a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 235a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_rhs_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 236a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 237a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_rhs_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 23877841947SLeila Ghaffari } 23977841947SLeila Ghaffari 24077841947SLeila Ghaffari // -- Create QFunction for IFunction 24191e5af17SJed Brown if (problem->apply_vol_ifunction.qfunction) { 242a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ifunction.qfunction, problem->apply_vol_ifunction.qfunction_loc, 243a424bcd0SJames Wright &ceed_data->qf_ifunction_vol)); 244a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_ifunction_vol, problem->apply_vol_ifunction.qfunction_context)); 245a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q", num_comp_q, CEED_EVAL_INTERP)); 246a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "Grad_q", num_comp_q * dim, CEED_EVAL_GRAD)); 247a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "q dot", num_comp_q, CEED_EVAL_INTERP)); 248a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 249a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_ifunction_vol, "x", num_comp_x, CEED_EVAL_INTERP)); 250a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 251a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 252a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_ifunction_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 25377841947SLeila Ghaffari } 25477841947SLeila Ghaffari 255e334ad8fSJed Brown CeedQFunction qf_ijacobian_vol = NULL; 256e334ad8fSJed Brown if (problem->apply_vol_ijacobian.qfunction) { 257a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->apply_vol_ijacobian.qfunction, problem->apply_vol_ijacobian.qfunction_loc, 258a424bcd0SJames Wright &qf_ijacobian_vol)); 259a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(qf_ijacobian_vol, problem->apply_vol_ijacobian.qfunction_context)); 260a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "dq", num_comp_q, CEED_EVAL_INTERP)); 261a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "Grad_dq", num_comp_q * dim, CEED_EVAL_GRAD)); 262a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "qdata", q_data_size_vol, CEED_EVAL_NONE)); 263a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(qf_ijacobian_vol, "jac_data", jac_data_size_vol, CEED_EVAL_NONE)); 264a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "v", num_comp_q, CEED_EVAL_INTERP)); 265a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(qf_ijacobian_vol, "Grad_v", num_comp_q * dim, CEED_EVAL_GRAD)); 266e334ad8fSJed Brown } 267e334ad8fSJed Brown 26877841947SLeila Ghaffari // --------------------------------------------------------------------------- 26977841947SLeila Ghaffari // Element coordinates 27077841947SLeila Ghaffari // --------------------------------------------------------------------------- 27177841947SLeila Ghaffari // -- Create CEED vector 272a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_x, &ceed_data->x_coord, NULL)); 27377841947SLeila Ghaffari 27477841947SLeila Ghaffari // -- Copy PETSc vector in CEED vector 27577841947SLeila Ghaffari Vec X_loc; 2763796c488SJed Brown { 2773796c488SJed Brown DM cdm; 2782b730f8bSJeremy L Thompson PetscCall(DMGetCellCoordinateDM(dm, &cdm)); 2792b730f8bSJeremy L Thompson if (cdm) { 2802b730f8bSJeremy L Thompson PetscCall(DMGetCellCoordinatesLocal(dm, &X_loc)); 2812b730f8bSJeremy L Thompson } else { 2822b730f8bSJeremy L Thompson PetscCall(DMGetCoordinatesLocal(dm, &X_loc)); 2833796c488SJed Brown } 2842b730f8bSJeremy L Thompson } 2852b730f8bSJeremy L Thompson PetscCall(VecScale(X_loc, problem->dm_scale)); 286fe69b334SJames Wright PetscCall(VecCopyP2C(X_loc, ceed_data->x_coord)); 28777841947SLeila Ghaffari 28877841947SLeila Ghaffari // ----------------------------------------------------------------------------- 28977841947SLeila Ghaffari // CEED vectors 29077841947SLeila Ghaffari // ----------------------------------------------------------------------------- 29177841947SLeila Ghaffari // -- Create CEED vector for geometric data 292a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(ceed_data->elem_restr_qd_i, &ceed_data->q_data, NULL)); 293a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionCreateVector(elem_restr_jd_i, &jac_data, NULL)); 294d52d2babSJames Wright 29577841947SLeila Ghaffari // ----------------------------------------------------------------------------- 29677841947SLeila Ghaffari // CEED Operators 29777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 29877841947SLeila Ghaffari // -- Create CEED operator for quadrature data 299a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_setup_vol, NULL, NULL, &ceed_data->op_setup_vol)); 300a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "dx", ceed_data->elem_restr_x, ceed_data->basis_x, CEED_VECTOR_ACTIVE)); 301a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "weight", CEED_ELEMRESTRICTION_NONE, ceed_data->basis_x, CEED_VECTOR_NONE)); 302356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(ceed_data->op_setup_vol, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 30377841947SLeila Ghaffari 30477841947SLeila Ghaffari // -- Create CEED operator for ICs 3055263e9c6SJames Wright CeedOperator op_ics; 306a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ics, NULL, NULL, &op_ics)); 307a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "x", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 308a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "dx", ceed_data->elem_restr_x, ceed_data->basis_xc, CEED_VECTOR_ACTIVE)); 309356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op_ics, "q0", ceed_data->elem_restr_q, CEED_BASIS_NONE, CEED_VECTOR_ACTIVE)); 310a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(op_ics, "evaluation time", &user->phys->ics_time_label)); 3115263e9c6SJames Wright PetscCall(OperatorApplyContextCreate(NULL, dm, user->ceed, op_ics, ceed_data->x_coord, NULL, NULL, user->Q_loc, &ceed_data->op_ics_ctx)); 312a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ics)); 31377841947SLeila Ghaffari 31477841947SLeila Ghaffari // Create CEED operator for RHS 31577841947SLeila Ghaffari if (ceed_data->qf_rhs_vol) { 31677841947SLeila Ghaffari CeedOperator op; 317a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_rhs_vol, NULL, NULL, &op)); 318a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 319a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 320356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 321a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 322a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 323a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 32477841947SLeila Ghaffari user->op_rhs_vol = op; 32577841947SLeila Ghaffari } 32677841947SLeila Ghaffari 32777841947SLeila Ghaffari // -- CEED operator for IFunction 32877841947SLeila Ghaffari if (ceed_data->qf_ifunction_vol) { 32977841947SLeila Ghaffari CeedOperator op; 330a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, ceed_data->qf_ifunction_vol, NULL, NULL, &op)); 331a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 332a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_q", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 333a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "q dot", ceed_data->elem_restr_q, ceed_data->basis_q, user->q_dot_ceed)); 334356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 335a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "x", ceed_data->elem_restr_x, ceed_data->basis_x, ceed_data->x_coord)); 336a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 337a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 338356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_NONE, jac_data)); 339a3ae0734SJed Brown 34077841947SLeila Ghaffari user->op_ifunction_vol = op; 34177841947SLeila Ghaffari } 34277841947SLeila Ghaffari 343e334ad8fSJed Brown CeedOperator op_ijacobian_vol = NULL; 344e334ad8fSJed Brown if (qf_ijacobian_vol) { 345e334ad8fSJed Brown CeedOperator op; 346a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_ijacobian_vol, NULL, NULL, &op)); 347a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 348a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_dq", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 349356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_NONE, ceed_data->q_data)); 350356036faSJeremy L Thompson PetscCallCeed(ceed, CeedOperatorSetField(op, "jac_data", elem_restr_jd_i, CEED_BASIS_NONE, jac_data)); 351a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 352a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorSetField(op, "Grad_v", ceed_data->elem_restr_q, ceed_data->basis_q, CEED_VECTOR_ACTIVE)); 353e334ad8fSJed Brown op_ijacobian_vol = op; 354a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionDestroy(&qf_ijacobian_vol)); 355e334ad8fSJed Brown } 356e334ad8fSJed Brown 35777841947SLeila Ghaffari // ***************************************************************************** 35877841947SLeila Ghaffari // Set up CEED objects for the exterior domain (surface) 35977841947SLeila Ghaffari // ***************************************************************************** 360bb85d312SJames Wright height = 1; 361bb85d312SJames Wright CeedInt dim_sur = dim - height, P_sur = app_ctx->degree + 1, Q_sur = P_sur + app_ctx->q_extra; 3622b730f8bSJeremy L Thompson const CeedInt q_data_size_sur = problem->q_data_size_sur, jac_data_size_sur = problem->jac_data_size_sur; 36377841947SLeila Ghaffari 36477841947SLeila Ghaffari // ----------------------------------------------------------------------------- 36577841947SLeila Ghaffari // CEED Bases 36677841947SLeila Ghaffari // ----------------------------------------------------------------------------- 3670814d5a7SKenneth E. Jansen 3680814d5a7SKenneth E. Jansen DMLabel label = 0; 3690814d5a7SKenneth E. Jansen PetscInt face_id = 0; 3700814d5a7SKenneth E. Jansen PetscInt field = 0; // Still want the normal, default field 3710814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm, label, face_id, height, field, &ceed_data->basis_q_sur)); 3720814d5a7SKenneth E. Jansen PetscCall(CreateBasisFromPlex(ceed, dm_coord, label, face_id, height, field, &ceed_data->basis_x_sur)); 373a424bcd0SJames Wright PetscCallCeed(ceed, CeedBasisCreateProjection(ceed_data->basis_x_sur, ceed_data->basis_q_sur, &ceed_data->basis_xc_sur)); 37477841947SLeila Ghaffari 37577841947SLeila Ghaffari // ----------------------------------------------------------------------------- 37677841947SLeila Ghaffari // CEED QFunctions 37777841947SLeila Ghaffari // ----------------------------------------------------------------------------- 37877841947SLeila Ghaffari // -- Create QFunction for quadrature data 379a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionCreateInterior(ceed, 1, problem->setup_sur.qfunction, problem->setup_sur.qfunction_loc, &ceed_data->qf_setup_sur)); 380841e4c73SJed Brown if (problem->setup_sur.qfunction_context) { 381a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionSetContext(ceed_data->qf_setup_sur, problem->setup_sur.qfunction_context)); 382841e4c73SJed Brown } 383a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "dx", num_comp_x * dim_sur, CEED_EVAL_GRAD)); 384a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddInput(ceed_data->qf_setup_sur, "weight", 1, CEED_EVAL_WEIGHT)); 385a424bcd0SJames Wright PetscCallCeed(ceed, CeedQFunctionAddOutput(ceed_data->qf_setup_sur, "surface qdata", q_data_size_sur, CEED_EVAL_NONE)); 38677841947SLeila Ghaffari 3872b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_inflow, 3882b730f8bSJeremy L Thompson problem->apply_inflow_jacobian, &ceed_data->qf_apply_inflow, &ceed_data->qf_apply_inflow_jacobian)); 3892b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_outflow, 3902b730f8bSJeremy L Thompson problem->apply_outflow_jacobian, &ceed_data->qf_apply_outflow, &ceed_data->qf_apply_outflow_jacobian)); 3912b730f8bSJeremy L Thompson PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_freestream, 3922b730f8bSJeremy L Thompson problem->apply_freestream_jacobian, &ceed_data->qf_apply_freestream, &ceed_data->qf_apply_freestream_jacobian)); 393*9f844368SJames Wright PetscCall(SetupBCQFunctions(ceed, dim_sur, num_comp_x, num_comp_q, q_data_size_sur, jac_data_size_sur, problem->apply_slip, 394*9f844368SJames Wright problem->apply_slip_jacobian, &ceed_data->qf_apply_slip, &ceed_data->qf_apply_slip_jacobian)); 39577841947SLeila Ghaffari 39677841947SLeila Ghaffari // ***************************************************************************** 39777841947SLeila Ghaffari // CEED Operator Apply 39877841947SLeila Ghaffari // ***************************************************************************** 39977841947SLeila Ghaffari // -- Apply CEED Operator for the geometric data 400a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorApply(ceed_data->op_setup_vol, ceed_data->x_coord, ceed_data->q_data, CEED_REQUEST_IMMEDIATE)); 40177841947SLeila Ghaffari 40277841947SLeila Ghaffari // -- Create and apply CEED Composite Operator for the entire domain 40377841947SLeila Ghaffari if (!user->phys->implicit) { // RHS 4049ad5e8e4SJames Wright CeedOperator op_rhs; 4059ad5e8e4SJames 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, 4069ad5e8e4SJames Wright NULL)); 4079ad5e8e4SJames Wright PetscCall(OperatorApplyContextCreate(dm, dm, ceed, op_rhs, user->q_ceed, user->g_ceed, user->Q_loc, NULL, &user->op_rhs_ctx)); 408a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_rhs)); 40977841947SLeila Ghaffari } else { // IFunction 4102b730f8bSJeremy L Thompson PetscCall(CreateOperatorForDomain(ceed, dm, bc, ceed_data, user->phys, user->op_ifunction_vol, op_ijacobian_vol, height, P_sur, Q_sur, 4112b730f8bSJeremy L Thompson q_data_size_sur, jac_data_size_sur, &user->op_ifunction, op_ijacobian_vol ? &user->op_ijacobian : NULL)); 412e334ad8fSJed Brown if (user->op_ijacobian) { 413a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorGetContextFieldLabel(user->op_ijacobian, "ijacobian time shift", &user->phys->ijacobian_time_shift_label)); 414e334ad8fSJed Brown } 41566170c20SJames Wright if (problem->use_strong_bc_ceed) PetscCall(SetupStrongBC_Ceed(ceed, ceed_data, dm, user, problem, bc)); 4168f5ab23bSJames Wright if (app_ctx->sgs_model_type == SGS_MODEL_DATA_DRIVEN) PetscCall(SgsDDSetup(ceed, user, ceed_data, problem)); 417dada6cc0SJames Wright } 418f5452247SJames Wright 419f5452247SJames Wright if (app_ctx->turb_spanstats_enable) PetscCall(TurbulenceStatisticsSetup(ceed, user, ceed_data, problem)); 420ee3b213aSJames Wright if (app_ctx->diff_filter_monitor && !user->diff_filter) PetscCall(DifferentialFilterSetup(ceed, user, ceed_data, problem)); 42128134cfaSJames Wright if (app_ctx->sgs_train_enable) PetscCall(SGS_DD_TrainingSetup(ceed, user, ceed_data, problem)); 422f5452247SJames Wright 423a424bcd0SJames Wright PetscCallCeed(ceed, CeedElemRestrictionDestroy(&elem_restr_jd_i)); 424a424bcd0SJames Wright PetscCallCeed(ceed, CeedOperatorDestroy(&op_ijacobian_vol)); 425a424bcd0SJames Wright PetscCallCeed(ceed, CeedVectorDestroy(&jac_data)); 426ee4ca9cbSJames Wright PetscFunctionReturn(PETSC_SUCCESS); 42777841947SLeila Ghaffari } 428