1 // Copyright (c) 2017-2022, 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 11 #ifndef libceed_petsc_examples_utils_h 12 #define libceed_petsc_examples_utils_h 13 14 #include <ceed.h> 15 #include <petsc.h> 16 17 #include "structs.h" 18 #if PETSC_VERSION_LT(3, 21, 0) 19 #define DMSetCoordinateDisc(a, b, c) DMProjectCoordinates(a, b) 20 #endif 21 22 CeedMemType MemTypeP2C(PetscMemType mtype); 23 PetscErrorCode VecP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 24 PetscErrorCode VecC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 25 PetscErrorCode VecReadP2C(Vec X_petsc, PetscMemType *mem_type, CeedVector x_ceed); 26 PetscErrorCode VecReadC2P(CeedVector x_ceed, PetscMemType mem_type, Vec X_petsc); 27 PetscErrorCode Kershaw(DM dm_orig, PetscScalar eps); 28 PetscErrorCode SetupDMByDegree(DM dm, PetscInt p_degree, PetscInt q_extra, PetscInt num_comp_u, PetscInt topo_dim, bool enforce_bc); 29 PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height, DMLabel domain_label, CeedInt value, CeedElemRestriction *elem_restr); 30 CeedElemTopology ElemTopologyP2C(DMPolytopeType cell_type); 31 PetscErrorCode DMFieldToDSField(DM dm, DMLabel domain_label, PetscInt dm_field, PetscInt *ds_field); 32 PetscErrorCode BasisCreateFromTabulation(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, PetscInt face, PetscFE fe, 33 PetscTabulation basis_tabulation, PetscQuadrature quadrature, CeedBasis *basis); 34 PetscErrorCode CreateBasisFromPlex(Ceed ceed, DM dm, DMLabel domain_label, CeedInt label_value, CeedInt height, CeedInt dm_field, BPData bp_data, 35 CeedBasis *basis); 36 PetscErrorCode CreateDistributedDM(RunParams rp, DM *dm); 37 38 #endif // libceed_petsc_examples_utils_h 39