xref: /libCEED/examples/fluids/include/petsc_ops.h (revision 9ba83ac0e4b1fca39d6fa6737a318a9f0cbc172d)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
24021610dSJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
34021610dSJames Wright //
44021610dSJames Wright // SPDX-License-Identifier: BSD-2-Clause
54021610dSJames Wright //
64021610dSJames Wright // This file is part of CEED:  http://github.com/ceed
724a65d3dSJeremy L Thompson #pragma once
84021610dSJames Wright 
94021610dSJames Wright #include <ceed.h>
104021610dSJames Wright #include <petscdm.h>
117f2a9303SJames Wright #include <petscksp.h>
124021610dSJames Wright 
134021610dSJames Wright typedef struct OperatorApplyContext_ *OperatorApplyContext;
144021610dSJames Wright struct OperatorApplyContext_ {
154021610dSJames Wright   DM           dm_x, dm_y;
164021610dSJames Wright   Vec          X_loc, Y_loc;
174021610dSJames Wright   CeedVector   x_ceed, y_ceed;
184021610dSJames Wright   CeedOperator op;
194021610dSJames Wright   Ceed         ceed;
204021610dSJames Wright };
214021610dSJames Wright 
224021610dSJames Wright PetscErrorCode OperatorApplyContextCreate(DM dm_x, DM dm_y, Ceed ceed, CeedOperator op_apply, CeedVector x_ceed, CeedVector y_ceed, Vec X_loc,
234021610dSJames Wright                                           Vec Y_loc, OperatorApplyContext *op_apply_ctx);
244021610dSJames Wright PetscErrorCode OperatorApplyContextDestroy(OperatorApplyContext op_apply_ctx);
254021610dSJames Wright 
26650a5d66SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
27650a5d66SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
28650a5d66SJames Wright 
294210c567SJames Wright PetscErrorCode CeedOperatorCreateLocalVecs(CeedOperator op, VecType vec_type, MPI_Comm comm, Vec *input, Vec *output);
304210c567SJames Wright VecType        DMReturnVecType(DM dm);
314021610dSJames Wright 
324021610dSJames Wright PetscErrorCode ApplyCeedOperatorGlobalToGlobal(Vec X, Vec Y, OperatorApplyContext ctx);
334021610dSJames Wright PetscErrorCode ApplyCeedOperatorGlobalToLocal(Vec X, Vec Y_loc, OperatorApplyContext ctx);
344021610dSJames Wright PetscErrorCode ApplyCeedOperatorLocalToGlobal(Vec X_loc, Vec Y, OperatorApplyContext ctx);
3593567eeaSJames Wright PetscErrorCode ApplyCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx);
364021610dSJames Wright PetscErrorCode ApplyAddCeedOperatorLocalToLocal(Vec X_loc, Vec Y_loc, OperatorApplyContext ctx);
374021610dSJames Wright 
386f7ff1d2SJames Wright PetscErrorCode DMGetLocalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
396f7ff1d2SJames Wright PetscErrorCode DMGetGlobalVectorInfo(DM dm, PetscInt *local_size, PetscInt *global_size, VecType *vec_type);
407f2a9303SJames Wright 
417f2a9303SJames Wright PetscErrorCode CreateSolveOperatorsFromMatCeed(KSP ksp, Mat mat_ceed, PetscBool assemble, Mat *Amat, Mat *Pmat);
427f2a9303SJames Wright PetscErrorCode KSPSetFromOptions_WithMatCeed(KSP ksp, Mat mat_ceed);
43