xref: /honee/include/bc_definition.h (revision 2e678684359fe84b9aa1ee98600bc5e49a7b4181)
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 struct _p_BCDefinition {
10   char *name;
11   DM    dm;
12 
13   // Boundary ID information
14   PetscInt num_label_values, *label_values, dm_field;
15 
16   // Essential Boundary information
17   PetscInt num_essential_comps, *essential_comps;
18 
19   void              *ctx;
20   PetscCtxDestroyFn *DestroyCtx;
21 };
22 
23 /**
24    @brief Creates a `BCDefinition` from an array of integers in an option in the database
25 
26    Must be between `PetscOptionsBegin()` and `PetscOptionsEnd()`.
27 
28    @param[in]  opt    The option one is seeking
29    @param[in]  text   Short string describing option
30    @param[in]  man    Manual page for the option
31    @param[in]  name   String that sets the name of the `BCDefinition`
32    @param[out] bc_def Resulting `BCDefinition`, `NULL` if option is not set
33    @param[out] set    `PETSC_TRUE` if found, else `PETSC_FALSE`
34 **/
35 #define PetscOptionsBCDefinition(opt, text, man, name, bc_def, set) \
36   PetscOptionsBCDefinition_Private(PetscOptionsObject, opt, text, man, name, bc_def, set)
37 PetscErrorCode PetscOptionsBCDefinition_Private(PetscOptionItems PetscOptionsObject, const char opt[], const char text[], const char man[],
38                                                 const char name[], BCDefinition *bc_def, PetscBool *set);
39 
40 PetscErrorCode BCDefinitionCreate(const char *name, PetscInt num_label_values, PetscInt label_values[], BCDefinition *bc_def);
41 PetscErrorCode BCDefinitionGetInfo(BCDefinition bc_def, const char *name[], PetscInt *num_label_values, const PetscInt *label_values[]);
42 PetscErrorCode BCDefinitionDestroy(BCDefinition *bc_def);
43 
44 PetscErrorCode BCDefinitionSetEssential(BCDefinition bc_def, PetscInt num_essential_comps, PetscInt essential_comps[]);
45 PetscErrorCode BCDefinitionGetEssential(BCDefinition bc_def, PetscInt *num_essential_comps, const PetscInt *essential_comps[]);
46 
47 PetscErrorCode BCDefinitionSetDM(BCDefinition bc_def, DM dm);
48 PetscErrorCode BCDefinitionGetDM(BCDefinition bc_def, DM *dm);
49 
50 PetscErrorCode BCDefinitionSetContext(BCDefinition bc_def, PetscCtxDestroyFn *destroy_ctx, void *ctx);
51 PetscErrorCode BCDefinitionGetContext(BCDefinition bc_def, void *ctx);
52