xref: /honee/include/bc_definition.h (revision 2e678684359fe84b9aa1ee98600bc5e49a7b4181)
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;
9487a3b6eSJames Wright struct _p_BCDefinition {
10487a3b6eSJames Wright   char *name;
1109240e0aSJames Wright   DM    dm;
12487a3b6eSJames Wright 
13487a3b6eSJames Wright   // Boundary ID information
14487a3b6eSJames Wright   PetscInt num_label_values, *label_values, dm_field;
15487a3b6eSJames Wright 
16487a3b6eSJames Wright   // Essential Boundary information
17487a3b6eSJames Wright   PetscInt num_essential_comps, *essential_comps;
18*2e678684SJames Wright 
19*2e678684SJames Wright   void              *ctx;
20*2e678684SJames Wright   PetscCtxDestroyFn *DestroyCtx;
21487a3b6eSJames Wright };
22487a3b6eSJames Wright 
23487a3b6eSJames Wright /**
24487a3b6eSJames Wright    @brief Creates a `BCDefinition` from an array of integers in an option in the database
25487a3b6eSJames Wright 
26487a3b6eSJames Wright    Must be between `PetscOptionsBegin()` and `PetscOptionsEnd()`.
27487a3b6eSJames Wright 
28487a3b6eSJames Wright    @param[in]  opt    The option one is seeking
29487a3b6eSJames Wright    @param[in]  text   Short string describing option
30487a3b6eSJames Wright    @param[in]  man    Manual page for the option
31487a3b6eSJames Wright    @param[in]  name   String that sets the name of the `BCDefinition`
32487a3b6eSJames Wright    @param[out] bc_def Resulting `BCDefinition`, `NULL` if option is not set
33487a3b6eSJames Wright    @param[out] set    `PETSC_TRUE` if found, else `PETSC_FALSE`
34487a3b6eSJames Wright **/
35487a3b6eSJames Wright #define PetscOptionsBCDefinition(opt, text, man, name, bc_def, set) \
36487a3b6eSJames Wright   PetscOptionsBCDefinition_Private(PetscOptionsObject, opt, text, man, name, bc_def, set)
37ddf6e248SJames Wright PetscErrorCode PetscOptionsBCDefinition_Private(PetscOptionItems PetscOptionsObject, const char opt[], const char text[], const char man[],
38487a3b6eSJames Wright                                                 const char name[], BCDefinition *bc_def, PetscBool *set);
39487a3b6eSJames Wright 
40487a3b6eSJames Wright PetscErrorCode BCDefinitionCreate(const char *name, PetscInt num_label_values, PetscInt label_values[], BCDefinition *bc_def);
41487a3b6eSJames Wright PetscErrorCode BCDefinitionGetInfo(BCDefinition bc_def, const char *name[], PetscInt *num_label_values, const PetscInt *label_values[]);
42487a3b6eSJames Wright PetscErrorCode BCDefinitionDestroy(BCDefinition *bc_def);
43487a3b6eSJames Wright 
44487a3b6eSJames Wright PetscErrorCode BCDefinitionSetEssential(BCDefinition bc_def, PetscInt num_essential_comps, PetscInt essential_comps[]);
45487a3b6eSJames Wright PetscErrorCode BCDefinitionGetEssential(BCDefinition bc_def, PetscInt *num_essential_comps, const PetscInt *essential_comps[]);
4609240e0aSJames Wright 
4709240e0aSJames Wright PetscErrorCode BCDefinitionSetDM(BCDefinition bc_def, DM dm);
4809240e0aSJames Wright PetscErrorCode BCDefinitionGetDM(BCDefinition bc_def, DM *dm);
49*2e678684SJames Wright 
50*2e678684SJames Wright PetscErrorCode BCDefinitionSetContext(BCDefinition bc_def, PetscCtxDestroyFn *destroy_ctx, void *ctx);
51*2e678684SJames Wright PetscErrorCode BCDefinitionGetContext(BCDefinition bc_def, void *ctx);
52