1f7325489SJames Wright // Copyright (c) 2017-2023, Lawrence Livermore National Security, LLC and other CEED contributors. 2f7325489SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3f7325489SJames Wright // 4f7325489SJames Wright // SPDX-License-Identifier: BSD-2-Clause 5f7325489SJames Wright // 6f7325489SJames Wright // This file is part of CEED: http://github.com/ceed 7f7325489SJames Wright 8f7325489SJames Wright #ifndef petsc_ops_h 9f7325489SJames Wright #define petsc_ops_h 10f7325489SJames Wright 11f7325489SJames Wright #include <ceed.h> 12f7325489SJames Wright #include <petscdm.h> 13*3170c09fSJames Wright #include <petscksp.h> 14f7325489SJames Wright 15f7325489SJames Wright typedef struct OperatorApplyContext_ *OperatorApplyContext; 16f7325489SJames Wright struct OperatorApplyContext_ { 17f7325489SJames Wright DM dm_x, dm_y; 18f7325489SJames Wright Vec X_loc, Y_loc; 19f7325489SJames Wright CeedVector x_ceed, y_ceed; 20f7325489SJames Wright CeedOperator op; 21f7325489SJames Wright Ceed ceed; 22f7325489SJames Wright }; 23f7325489SJames Wright 24f7325489SJames Wright PetscErrorCode OperatorApplyContextCreate(DM dm_x, DM dm_y, Ceed ceed, CeedOperator op_apply, CeedVector x_ceed, CeedVector y_ceed, Vec X_loc, 25f7325489SJames Wright Vec Y_loc, OperatorApplyContext *op_apply_ctx); 26f7325489SJames Wright PetscErrorCode OperatorApplyContextDestroy(OperatorApplyContext op_apply_ctx); 27bb1c79bdSJames Wright PetscErrorCode CreateMatShell_Ceed(OperatorApplyContext ctx, Mat *mat); 28f7325489SJames Wright 2954ae1419SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type); 3054ae1419SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type); 3154ae1419SJames Wright 32f7325489SJames Wright PetscErrorCode VecP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 33f7325489SJames Wright PetscErrorCode VecC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 34f7325489SJames Wright PetscErrorCode VecReadP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 35f7325489SJames Wright PetscErrorCode VecReadC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 36f7325489SJames Wright PetscErrorCode VecCopyP2C(Vec X_petsc, CeedVector x_ceed); 376cbc221eSJames Wright PetscErrorCode CeedOperatorCreateLocalVecs(CeedOperator op, VecType vec_type, MPI_Comm comm, Vec *input, Vec *output); 386cbc221eSJames Wright VecType DMReturnVecType(DM dm); 39f7325489SJames Wright 40f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToGlobal(Vec X, Vec Y, OperatorApplyContext ctx); 41f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToLocal(Vec X, Vec Y_loc, OperatorApplyContext ctx); 42f7325489SJames Wright PetscErrorCode ApplyCeedOperatorLocalToGlobal(Vec X_loc, Vec Y, OperatorApplyContext ctx); 435ce09d65SJames Wright PetscErrorCode ApplyCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx); 44f7325489SJames Wright PetscErrorCode ApplyAddCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx); 45f7325489SJames Wright 46ef3cb7e0SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type); 47ef3cb7e0SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type); 48*3170c09fSJames Wright 49*3170c09fSJames Wright PetscErrorCode CreateSolveOperatorsFromMatCeed(KSP ksp, Mat mat_ceed, PetscBool assemble, Mat *Amat, Mat *Pmat); 50*3170c09fSJames Wright PetscErrorCode KSPSetFromOptions_WithMatCeed(KSP ksp, Mat mat_ceed); 51f7325489SJames Wright #endif // petsc_ops_h 52