xref: /honee/include/petsc_ops.h (revision 18fb77588857caa2723da956ec9edbb6264c2de7)
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
7*18fb7758SJeremy L Thompson #pragma once
8f7325489SJames Wright 
9f7325489SJames Wright #include <ceed.h>
10f7325489SJames Wright #include <petscdm.h>
113170c09fSJames Wright #include <petscksp.h>
12f7325489SJames Wright 
13f7325489SJames Wright typedef struct OperatorApplyContext_ *OperatorApplyContext;
14f7325489SJames Wright struct OperatorApplyContext_ {
15f7325489SJames Wright   DM           dm_x, dm_y;
16f7325489SJames Wright   Vec          X_loc, Y_loc;
17f7325489SJames Wright   CeedVector   x_ceed, y_ceed;
18f7325489SJames Wright   CeedOperator op;
19f7325489SJames Wright   Ceed         ceed;
20f7325489SJames Wright };
21f7325489SJames Wright 
22f7325489SJames Wright PetscErrorCode OperatorApplyContextCreate(DM dm_x, DM dm_y, Ceed ceed, CeedOperator op_apply, CeedVector x_ceed, CeedVector y_ceed, Vec X_loc,
23f7325489SJames Wright                                           Vec Y_loc, OperatorApplyContext *op_apply_ctx);
24f7325489SJames Wright PetscErrorCode OperatorApplyContextDestroy(OperatorApplyContext op_apply_ctx);
25f7325489SJames Wright 
2654ae1419SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
2754ae1419SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
2854ae1419SJames Wright 
296cbc221eSJames Wright PetscErrorCode CeedOperatorCreateLocalVecs(CeedOperator op, VecType vec_type, MPI_Comm comm, Vec *input, Vec *output);
306cbc221eSJames Wright VecType        DMReturnVecType(DM dm);
31f7325489SJames Wright 
32f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToGlobal(Vec X, Vec Y, OperatorApplyContext ctx);
33f7325489SJames Wright PetscErrorCode ApplyCeedOperatorGlobalToLocal(Vec X, Vec Y_loc, OperatorApplyContext ctx);
34f7325489SJames Wright PetscErrorCode ApplyCeedOperatorLocalToGlobal(Vec X_loc, Vec Y, OperatorApplyContext ctx);
355ce09d65SJames Wright PetscErrorCode ApplyCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx);
36f7325489SJames Wright PetscErrorCode ApplyAddCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx);
37f7325489SJames Wright 
38ef3cb7e0SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
39ef3cb7e0SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
403170c09fSJames Wright 
413170c09fSJames Wright PetscErrorCode CreateSolveOperatorsFromMatCeed(KSP ksp, Mat mat_ceed, PetscBool assemble, Mat *Amat, Mat *Pmat);
423170c09fSJames Wright PetscErrorCode KSPSetFromOptions_WithMatCeed(KSP ksp, Mat mat_ceed);
43