xref: /libCEED/examples/petsc/include/petscutils.h (revision 5aed82e4fa97acf4ba24a7f10a35f5303a6798e0)
1*5aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
298285ab4SZach Atkins // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
398285ab4SZach Atkins //
498285ab4SZach Atkins // SPDX-License-Identifier: BSD-2-Clause
598285ab4SZach Atkins //
698285ab4SZach Atkins // This file is part of CEED:  http://github.com/ceed
798285ab4SZach Atkins 
898285ab4SZach Atkins /// @file
998285ab4SZach Atkins /// Utility functions for using PETSc with libCEED
1024a65d3dSJeremy L Thompson #pragma once
11e83e87a5Sjeremylt 
12e83e87a5Sjeremylt #include <ceed.h>
13e83e87a5Sjeremylt #include <petsc.h>
142b730f8bSJeremy L Thompson 
15de1229c5Srezgarshakeri #include "structs.h"
1649a40c8aSKenneth E. Jansen #if PETSC_VERSION_LT(3, 21, 0)
1749a40c8aSKenneth E. Jansen #define DMSetCoordinateDisc(a, b, c) DMProjectCoordinates(a, b)
1849a40c8aSKenneth E. Jansen #endif
19e83e87a5Sjeremylt 
20e83e87a5Sjeremylt CeedMemType      MemTypeP2C(PetscMemType mtype);
21b6972d74SZach Atkins PetscErrorCode   VecP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed);
22b6972d74SZach Atkins PetscErrorCode   VecC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc);
23b6972d74SZach Atkins PetscErrorCode   VecReadP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed);
24b6972d74SZach Atkins PetscErrorCode   VecReadC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc);
259b072555Sjeremylt PetscErrorCode   Kershaw(DM dm_orig, PetscScalar eps);
262b730f8bSJeremy L Thompson PetscErrorCode   SetupDMByDegree(DM dm, PetscInt p_degree, PetscInt q_extra, PetscInt num_comp_u, PetscInt topo_dim, bool enforce_bc);
272b730f8bSJeremy L Thompson PetscErrorCode   CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr);
28de1229c5Srezgarshakeri CeedElemTopology ElemTopologyP2C(DMPolytopeType cell_type);
292b730f8bSJeremy L Thompson PetscErrorCode   DMFieldToDSField(DM dm, DMLabel domain_label, PetscInt dm_field, PetscInt *ds_field);
302b730f8bSJeremy L Thompson PetscErrorCode   BasisCreateFromTabulation(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, PetscInt face, PetscFE fe,
312b730f8bSJeremy L Thompson                                            PetscTabulation basis_tabulation, PetscQuadrature quadrature, CeedBasis *basis);
322b730f8bSJeremy L Thompson PetscErrorCode   CreateBasisFromPlex(Ceed ceed, DM dm, DMLabel domain_label, CeedInt label_value, CeedInt height, CeedInt dm_field, BPData bp_data,
33f755c37aSrezgarshakeri                                      CeedBasis *basis);
34de1229c5Srezgarshakeri PetscErrorCode   CreateDistributedDM(RunParams rp, DM *dm);
35