Hi Brandon,

On Thu, 25 May 2023 at 14:53, Brandon Denton <blden...@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

Reply via email to