1 // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors. 2 // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause 3 #pragma once 4 5 #include <ceed.h> 6 #include <petsc.h> 7 8 typedef struct _p_BCDefinition *BCDefinition; 9 10 typedef PetscErrorCode (*BCDefinitionCreateQFunction)(BCDefinition bc_def, CeedQFunction *qf); 11 typedef PetscErrorCode (*BCDefinitionAddIFunctionOperator)(BCDefinition bc_def, DMLabel orientation_label, PetscInt orientation, CeedQFunction qf, 12 CeedOperator op, CeedOperator *sub_op); 13 typedef PetscErrorCode (*BCDefinitionAddIJacobianOperator)(BCDefinition bc_def, CeedOperator sub_op_ifunction, DMLabel orientation_label, 14 PetscInt orientation, CeedQFunction qf, CeedOperator op); 15 16 struct _p_BCDefinition { 17 char *name; 18 DM dm; 19 20 // Boundary ID information 21 PetscInt num_label_values, *label_values, dm_field; 22 23 // Essential Boundary information 24 PetscInt num_essential_comps, *essential_comps; 25 26 void *ctx; 27 PetscCtxDestroyFn *DestroyCtx; 28 BCDefinitionCreateQFunction CreateIFunctionQF, CreateIJacobianQF; 29 BCDefinitionAddIFunctionOperator AddIFunctionOperator; 30 BCDefinitionAddIJacobianOperator AddIJacobianOperator; 31 }; 32 33 /** 34 @brief Creates a `BCDefinition` from an array of integers in an option in the database 35 36 Must be between `PetscOptionsBegin()` and `PetscOptionsEnd()`. 37 38 @param[in] opt The option one is seeking 39 @param[in] text Short string describing option 40 @param[in] man Manual page for the option 41 @param[in] name String that sets the name of the `BCDefinition` 42 @param[out] bc_def Resulting `BCDefinition`, `NULL` if option is not set 43 @param[out] set `PETSC_TRUE` if found, else `PETSC_FALSE` 44 **/ 45 #define PetscOptionsBCDefinition(opt, text, man, name, bc_def, set) \ 46 PetscOptionsBCDefinition_Private(PetscOptionsObject, opt, text, man, name, bc_def, set) 47 PetscErrorCode PetscOptionsBCDefinition_Private(PetscOptionItems PetscOptionsObject, const char opt[], const char text[], const char man[], 48 const char name[], BCDefinition *bc_def, PetscBool *set); 49 50 PetscErrorCode BCDefinitionCreate(const char *name, PetscInt num_label_values, PetscInt label_values[], BCDefinition *bc_def); 51 PetscErrorCode BCDefinitionGetInfo(BCDefinition bc_def, const char *name[], PetscInt *num_label_values, const PetscInt *label_values[]); 52 PetscErrorCode BCDefinitionDestroy(BCDefinition *bc_def); 53 54 PetscErrorCode BCDefinitionSetEssential(BCDefinition bc_def, PetscInt num_essential_comps, PetscInt essential_comps[]); 55 PetscErrorCode BCDefinitionGetEssential(BCDefinition bc_def, PetscInt *num_essential_comps, const PetscInt *essential_comps[]); 56 57 PetscErrorCode BCDefinitionSetDM(BCDefinition bc_def, DM dm); 58 PetscErrorCode BCDefinitionGetDM(BCDefinition bc_def, DM *dm); 59 60 PetscErrorCode BCDefinitionSetContext(BCDefinition bc_def, PetscCtxDestroyFn *destroy_ctx, void *ctx); 61 PetscErrorCode BCDefinitionGetContext(BCDefinition bc_def, void *ctx); 62 63 PetscErrorCode BCDefinitionSetIFunction(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIFunctionOperator add_op); 64 PetscErrorCode BCDefinitionSetIJacobian(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIJacobianOperator add_op); 65 PetscErrorCode BCDefinitionAddOperators(BCDefinition bc_def, CeedOperator op_ifunction, CeedOperator op_ijacobian); 66