1 // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 /// @file 9 /// Utility functions for using PETSc with libCEED 10 #pragma once 11 12 #include <ceed.h> 13 #include <petsc.h> 14 15 #include "structs.h" 16 #if PETSC_VERSION_LT(3, 21, 0) 17 #define DMSetCoordinateDisc(a, b, c) DMProjectCoordinates(a, b) 18 #endif 19 20 CeedMemType MemTypeP2C(PetscMemType mtype); 21 PetscErrorCode VecP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 22 PetscErrorCode VecC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 23 PetscErrorCode VecReadP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 24 PetscErrorCode VecReadC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 25 PetscErrorCode Kershaw(DM dm_orig, PetscScalar eps); 26 PetscErrorCode SetupDMByDegree(DM dm, PetscInt p_degree, PetscInt q_extra, PetscInt num_comp_u, PetscInt topo_dim, bool enforce_bc); 27 PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr); 28 CeedElemTopology ElemTopologyP2C(DMPolytopeType cell_type); 29 PetscErrorCode DMFieldToDSField(DM dm, DMLabel domain_label, PetscInt dm_field, PetscInt *ds_field); 30 PetscErrorCode BasisCreateFromTabulation(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, PetscInt face, PetscFE fe, 31 PetscTabulation basis_tabulation, PetscQuadrature quadrature, CeedBasis *basis); 32 PetscErrorCode CreateBasisFromPlex(Ceed ceed, DM dm, DMLabel domain_label, CeedInt label_value, CeedInt height, CeedInt dm_field, BPData bp_data, 33 CeedBasis *basis); 34 PetscErrorCode CreateDistributedDM(RunParams rp, DM *dm); 35