[petsc-dev] Get DMLabel "name" from DMLabel Object
Lawrence Mitchell
wence at gmx.li
Thu May 25 09:16:19 CDT 2023
Hi Brandon,
On Thu, 25 May 2023 at 14:53, Brandon Denton <bldenton at buffalo.edu> wrote:
>
> Good Morning,
>
> Is there a way to get the given "name" of a label if you have the DMLabel Object?
>
> For instance, in my code I have a DM with a set of labels with given names (i.e. "boundary", "top", "bottom", etc.). I've gotten the DMLabel Object by calling:
>
> PetscCall(DMGetLabel(dm, "boundary", &boundLabel));
>
> I've passed this object to a function. In the function, I would like to perform an if statement based on the name of the label. Is there a way to get the STRING name of the DMLabel from its object?
The labels are PetscObjects, and all PetscObjects have an (optional)
name. In the case of named labels in DMs, this name is the name of the
label.
So
const char *name = NULL;
PetscObjectGetName((PetscObject)label, &name);
will give you the label's name.
Lawrence
More information about the petsc-dev
mailing list