xref: /honee/include/bc_definition.h (revision 77aa5ad7c9c7ea06edea746b0c60eea6fdad3cd2)
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>
6487a3b6eSJames Wright #include <petsc.h>
7487a3b6eSJames Wright 
8487a3b6eSJames Wright typedef struct _p_BCDefinition *BCDefinition;
9*77aa5ad7SJames Wright 
10*77aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionCreateQFunction)(BCDefinition bc_def, CeedQFunction *qf);
11*77aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionAddIFunctionOperator)(BCDefinition bc_def, DMLabel orientation_label, PetscInt orientation, CeedQFunction qf,
12*77aa5ad7SJames Wright                                                            CeedOperator op, CeedOperator *sub_op);
13*77aa5ad7SJames Wright typedef PetscErrorCode (*BCDefinitionAddIJacobianOperator)(BCDefinition bc_def, CeedOperator sub_op_ifunction, DMLabel orientation_label,
14*77aa5ad7SJames Wright                                                            PetscInt orientation, CeedQFunction qf, CeedOperator op);
15*77aa5ad7SJames Wright 
16487a3b6eSJames Wright struct _p_BCDefinition {
17487a3b6eSJames Wright   char *name;
1809240e0aSJames Wright   DM    dm;
19487a3b6eSJames Wright 
20487a3b6eSJames Wright   // Boundary ID information
21487a3b6eSJames Wright   PetscInt num_label_values, *label_values, dm_field;
22487a3b6eSJames Wright 
23487a3b6eSJames Wright   // Essential Boundary information
24487a3b6eSJames Wright   PetscInt num_essential_comps, *essential_comps;
252e678684SJames Wright 
262e678684SJames Wright   void                            *ctx;
272e678684SJames Wright   PetscCtxDestroyFn               *DestroyCtx;
28*77aa5ad7SJames Wright   BCDefinitionCreateQFunction      CreateIFunctionQF, CreateIJacobianQF;
29*77aa5ad7SJames Wright   BCDefinitionAddIFunctionOperator AddIFunctionOperator;
30*77aa5ad7SJames Wright   BCDefinitionAddIJacobianOperator AddIJacobianOperator;
31487a3b6eSJames Wright };
32487a3b6eSJames Wright 
33487a3b6eSJames Wright /**
34487a3b6eSJames Wright    @brief Creates a `BCDefinition` from an array of integers in an option in the database
35487a3b6eSJames Wright 
36487a3b6eSJames Wright    Must be between `PetscOptionsBegin()` and `PetscOptionsEnd()`.
37487a3b6eSJames Wright 
38487a3b6eSJames Wright    @param[in]  opt    The option one is seeking
39487a3b6eSJames Wright    @param[in]  text   Short string describing option
40487a3b6eSJames Wright    @param[in]  man    Manual page for the option
41487a3b6eSJames Wright    @param[in]  name   String that sets the name of the `BCDefinition`
42487a3b6eSJames Wright    @param[out] bc_def Resulting `BCDefinition`, `NULL` if option is not set
43487a3b6eSJames Wright    @param[out] set    `PETSC_TRUE` if found, else `PETSC_FALSE`
44487a3b6eSJames Wright **/
45487a3b6eSJames Wright #define PetscOptionsBCDefinition(opt, text, man, name, bc_def, set) \
46487a3b6eSJames Wright   PetscOptionsBCDefinition_Private(PetscOptionsObject, opt, text, man, name, bc_def, set)
47ddf6e248SJames Wright PetscErrorCode PetscOptionsBCDefinition_Private(PetscOptionItems PetscOptionsObject, const char opt[], const char text[], const char man[],
48487a3b6eSJames Wright                                                 const char name[], BCDefinition *bc_def, PetscBool *set);
49487a3b6eSJames Wright 
50487a3b6eSJames Wright PetscErrorCode BCDefinitionCreate(const char *name, PetscInt num_label_values, PetscInt label_values[], BCDefinition *bc_def);
51487a3b6eSJames Wright PetscErrorCode BCDefinitionGetInfo(BCDefinition bc_def, const char *name[], PetscInt *num_label_values, const PetscInt *label_values[]);
52487a3b6eSJames Wright PetscErrorCode BCDefinitionDestroy(BCDefinition *bc_def);
53487a3b6eSJames Wright 
54487a3b6eSJames Wright PetscErrorCode BCDefinitionSetEssential(BCDefinition bc_def, PetscInt num_essential_comps, PetscInt essential_comps[]);
55487a3b6eSJames Wright PetscErrorCode BCDefinitionGetEssential(BCDefinition bc_def, PetscInt *num_essential_comps, const PetscInt *essential_comps[]);
5609240e0aSJames Wright 
5709240e0aSJames Wright PetscErrorCode BCDefinitionSetDM(BCDefinition bc_def, DM dm);
5809240e0aSJames Wright PetscErrorCode BCDefinitionGetDM(BCDefinition bc_def, DM *dm);
592e678684SJames Wright 
602e678684SJames Wright PetscErrorCode BCDefinitionSetContext(BCDefinition bc_def, PetscCtxDestroyFn *destroy_ctx, void *ctx);
612e678684SJames Wright PetscErrorCode BCDefinitionGetContext(BCDefinition bc_def, void *ctx);
62*77aa5ad7SJames Wright 
63*77aa5ad7SJames Wright PetscErrorCode BCDefinitionSetIFunction(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIFunctionOperator add_op);
64*77aa5ad7SJames Wright PetscErrorCode BCDefinitionSetIJacobian(BCDefinition bc_def, BCDefinitionCreateQFunction create_qf, BCDefinitionAddIJacobianOperator add_op);
65*77aa5ad7SJames Wright PetscErrorCode BCDefinitionAddOperators(BCDefinition bc_def, CeedOperator op_ifunction, CeedOperator op_ijacobian);
66