1ae2b091fSJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors. 2ae2b091fSJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause 3487a3b6eSJames Wright #pragma once 4487a3b6eSJames Wright 5487a3b6eSJames Wright #include <ceed.h> 696f347c2SJames Wright #include <petsc/private/petscimpl.h> 7*0bf21536SJames Wright #include <petscdm.h> 8487a3b6eSJames Wright 9487a3b6eSJames Wright typedef struct _p_BCDefinition *BCDefinition; 1077aa5ad7SJames Wright 1177aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionCreateQFunction)(BCDefinition bc_def, CeedQFunction *qf); 1277aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionAddIFunctionOperator)(BCDefinition bc_def, DMLabel orientation_label, PetscInt orientation, CeedQFunction qf, 1377aa5ad7SJames Wright CeedOperator op, CeedOperator *sub_op); 1477aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionAddIJacobianOperator)(BCDefinition bc_def, CeedOperator sub_op_ifunction, DMLabel orientation_label, 1577aa5ad7SJames Wright PetscInt orientation, CeedQFunction qf, CeedOperator op); 1677aa5ad7SJames Wright 1796f347c2SJames Wright typedef struct _BCDefinitionOps *BCDefinitionOps; 1896f347c2SJames Wright struct _BCDefinitionOps {}; 1996f347c2SJames Wright 20487a3b6eSJames Wright struct _p_BCDefinition { 2196f347c2SJames Wright PETSCHEADER(struct _BCDefinitionOps); 22487a3b6eSJames Wright char *name; 2309240e0aSJames Wright DM dm; 24487a3b6eSJames Wright 25487a3b6eSJames Wright // Boundary ID information 26487a3b6eSJames Wright PetscInt num_label_values, *label_values, dm_field; 27487a3b6eSJames Wright 28487a3b6eSJames Wright // Essential Boundary information 29487a3b6eSJames Wright PetscInt num_essential_comps, *essential_comps; 302e678684SJames Wright 312e678684SJames Wright void *ctx; 322e678684SJames Wright PetscCtxDestroyFn *DestroyCtx; 3377aa5ad7SJames Wright BCDefinitionCreateQFunction CreateIFunctionQF, CreateIJacobianQF; 3477aa5ad7SJames Wright BCDefinitionAddIFunctionOperator AddIFunctionOperator; 3577aa5ad7SJames Wright BCDefinitionAddIJacobianOperator AddIJacobianOperator; 36487a3b6eSJames Wright }; 37487a3b6eSJames Wright 38487a3b6eSJames Wright /** 39487a3b6eSJames Wright @brief Creates a `BCDefinition` from an array of integers in an option in the database 40487a3b6eSJames Wright 41487a3b6eSJames Wright Must be between `PetscOptionsBegin()` and `PetscOptionsEnd()`. 42487a3b6eSJames Wright 43487a3b6eSJames Wright @param[in] opt The option one is seeking 44487a3b6eSJames Wright @param[in] text Short string describing option 45487a3b6eSJames Wright @param[in] man Manual page for the option 46487a3b6eSJames Wright @param[in] name String that sets the name of the `BCDefinition` 47487a3b6eSJames Wright @param[out] bc_def Resulting `BCDefinition`, `NULL` if option is not set 48487a3b6eSJames Wright @param[out] set `PETSC_TRUE` if found, else `PETSC_FALSE` 49487a3b6eSJames Wright **/ 50487a3b6eSJames Wright #define PetscOptionsBCDefinition(opt, text, man, name, bc_def, set) \ 51487a3b6eSJames Wright PetscOptionsBCDefinition_Private(PetscOptionsObject, opt, text, man, name, bc_def, set) 52ddf6e248SJames Wright PetscErrorCode PetscOptionsBCDefinition_Private(PetscOptionItems PetscOptionsObject, const char opt[], const char text[], const char man[], 53487a3b6eSJames Wright const char name[], BCDefinition *bc_def, PetscBool *set); 54487a3b6eSJames Wright 5596f347c2SJames Wright PetscErrorCode BCDefinitionCreate(MPI_Comm comm, const char *name, PetscInt num_label_values, PetscInt label_values[], BCDefinition *bc_def); 56487a3b6eSJames Wright PetscErrorCode BCDefinitionGetInfo(BCDefinition bc_def, const char *name[], PetscInt *num_label_values, const PetscInt *label_values[]); 5796f347c2SJames Wright PetscErrorCode BCDefinitionView(BCDefinition bc_def, PetscViewer viewer); 5896f347c2SJames Wright PetscErrorCode BCDefinitionViewFromOptions(BCDefinition bc_def, PetscObject obj, const char name[]); 59487a3b6eSJames Wright PetscErrorCode BCDefinitionDestroy(BCDefinition *bc_def); 60487a3b6eSJames Wright 61487a3b6eSJames Wright PetscErrorCode BCDefinitionSetEssential(BCDefinition bc_def, PetscInt num_essential_comps, PetscInt essential_comps[]); 62487a3b6eSJames Wright PetscErrorCode BCDefinitionGetEssential(BCDefinition bc_def, PetscInt *num_essential_comps, const PetscInt *essential_comps[]); 6309240e0aSJames Wright 6409240e0aSJames Wright PetscErrorCode BCDefinitionSetDM(BCDefinition bc_def, DM dm); 6509240e0aSJames Wright PetscErrorCode BCDefinitionGetDM(BCDefinition bc_def, DM *dm); 662e678684SJames Wright 672e678684SJames Wright PetscErrorCode BCDefinitionSetContext(BCDefinition bc_def, PetscCtxDestroyFn *destroy_ctx, void *ctx); 682e678684SJames Wright PetscErrorCode BCDefinitionGetContext(BCDefinition bc_def, void *ctx); 6977aa5ad7SJames Wright 7077aa5ad7SJames Wright PetscErrorCode BCDefinitionSetIFunction(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIFunctionOperator add_op); 7177aa5ad7SJames Wright PetscErrorCode BCDefinitionSetIJacobian(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIJacobianOperator add_op); 7277aa5ad7SJames Wright PetscErrorCode BCDefinitionAddOperators(BCDefinition bc_def, CeedOperator op_ifunction, CeedOperator op_ijacobian); 73