1*f7325489SJames Wright // Copyright (c) 2017-2023, Lawrence Livermore National Security, LLC and other CEED contributors. 2*f7325489SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3*f7325489SJames Wright // 4*f7325489SJames Wright // SPDX-License-Identifier: BSD-2-Clause 5*f7325489SJames Wright // 6*f7325489SJames Wright // This file is part of CEED: http://github.com/ceed 7*f7325489SJames Wright 8*f7325489SJames Wright #ifndef petsc_ops_h 9*f7325489SJames Wright #define petsc_ops_h 10*f7325489SJames Wright 11*f7325489SJames Wright #include <ceed.h> 12*f7325489SJames Wright #include <petscdm.h> 13*f7325489SJames Wright 14*f7325489SJames Wright typedef struct OperatorApplyContext_ *OperatorApplyContext; 15*f7325489SJames Wright struct OperatorApplyContext_ { 16*f7325489SJames Wright DM dm_x, dm_y; 17*f7325489SJames Wright Vec X_loc, Y_loc; 18*f7325489SJames Wright CeedVector x_ceed, y_ceed; 19*f7325489SJames Wright CeedOperator op; 20*f7325489SJames Wright Ceed ceed; 21*f7325489SJames Wright }; 22*f7325489SJames Wright 23*f7325489SJames Wright PetscErrorCode OperatorApplyContextCreate(DM dm_x, DM dm_y, Ceed ceed, CeedOperator op_apply, CeedVector x_ceed, CeedVector y_ceed, Vec X_loc, 24*f7325489SJames Wright Vec Y_loc, OperatorApplyContext *op_apply_ctx); 25*f7325489SJames Wright PetscErrorCode OperatorApplyContextDestroy(OperatorApplyContext op_apply_ctx); 26*f7325489SJames Wright PetscErrorCode MatGetDiag_Ceed(Mat A, Vec D); 27*f7325489SJames Wright PetscErrorCode MatMult_Ceed(Mat A, Vec X, Vec Y); 28*f7325489SJames Wright 29*f7325489SJames Wright PetscErrorCode VecP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 30*f7325489SJames Wright PetscErrorCode VecC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 31*f7325489SJames Wright PetscErrorCode VecReadP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 32*f7325489SJames Wright PetscErrorCode VecReadC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 33*f7325489SJames Wright PetscErrorCode VecCopyP2C(Vec X_petsc, CeedVector x_ceed); 34*f7325489SJames Wright 35*f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToGlobal(Vec X, Vec Y, OperatorApplyContext ctx); 36*f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToLocal(Vec X, Vec Y_loc, OperatorApplyContext ctx); 37*f7325489SJames Wright PetscErrorCode ApplyCeedOperatorLocalToGlobal(Vec X_loc, Vec Y, OperatorApplyContext ctx); 38*f7325489SJames Wright PetscErrorCode ApplyAddCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx); 39*f7325489SJames Wright 40*f7325489SJames Wright #endif // petsc_ops_h 41