Nicolas, > I am trying to understand how the class IDs of a DM field are set
Class ID’s are unique (internal) identifiers that every type of object of a petsc-created class shares to identify them. This is especially useful when these objects are passed around semi-opaquely by casting to PetscObject. Think of it as similar to c++ typeid https://en.cppreference.com/w/cpp/language/typeid <https://en.cppreference.com/w/cpp/language/typeid> > ierr = PetscFECreateDefault(PetscObjectComm((PetscObject) dmGrad), dim, > coordDim, PETSC_TRUE, NULL, -1, &feGrad);CHKERRQ(ierr); > ierr = PetscDSSetDiscretization(probGrad, f, (PetscObject) > feGrad);CHKERRQ(ierr); > ierr = PetscFEDestroy(&feGrad);CHKERRQ(ierr); > > Yet, when I call DMPlexComputeGradientClementInterpolant, I get the following > error: > [0]PETSC ERROR: Unknown discretization type for field 0 This function walks through all of the fields you have added to the DM and performs a sanity check (using the classics) to determine whether they are all the correct object. It seems like you’ve missed a step here. Have you called DMAddField()/DMSetField() to associate your PetscFE with your plex? Note that > ierr = PetscFECreateDefault(PetscObjectComm((PetscObject) dmGrad), dim, > coordDim, PETSC_TRUE, NULL, -1, &feGrad);CHKERRQ(ierr); Does not directly tie the feGrad to your dmGrad, rather just gives it the same MPI_Comm. Best regards, Jacob Faibussowitsch (Jacob Fai - booss - oh - vitch) Cell: (312) 694-3391 > On Dec 11, 2020, at 11:02, Nicolas Barral <[email protected]> > wrote: > > Hi all (and probably more specifically Matt ?) > > I am trying to understand how the class IDs of a DM field are set, and can't > find it in the documentation. > > A little background, I am mimicking > SNES/utils/dmadapt.c/DMAdaptorAdapt_Sequence_Private for a specific case (I'm > trying to build the same kind of metric from a single sensor field, without > all the SNES layer). > > I need to compute the gradient of the sensor field, using > DMPlexComputeGradientClementInterpolant, for which I create a DM, to which I > associate a PetscFE, a DS, like in existing code: > > PetscFE feGrad > PetscDS probGrad > > ierr = PetscFECreateDefault(PetscObjectComm((PetscObject) dmGrad), dim, > coordDim, PETSC_TRUE, NULL, -1, &feGrad);CHKERRQ(ierr); > ierr = PetscDSSetDiscretization(probGrad, f, (PetscObject) > feGrad);CHKERRQ(ierr); > ierr = PetscFEDestroy(&feGrad);CHKERRQ(ierr); > > Yet, when I call DMPlexComputeGradientClementInterpolant, I get the following > error: > [0]PETSC ERROR: Unknown discretization type for field 0 > > I don't fully understand what all these objects are (FE, DS and Field), and > how they are related, where would that be documented ? > And what else do I need to do to make my example work ? > > Thanks > > -- > Nicolas
