Closed YohannDudouit closed 5 years ago
This has nothing to do with the delegate but rather your use of the SetBackendFunction function. You didn't set OperatorDestroy correctly. See the example in the Ref backend:
ierr = CeedSetBackendFunction(ceed, "Operator", op, "Destroy",
CeedOperatorDestroy_Ref); CeedChk(ierr);
From the documentation of the function
/**
@brief Set a backend function
@param ceed Ceed for error handling
@param type Type of Ceed object to set function for
@param[out] object Ceed object to set function for
@param fname Name of function to set
@param f Function to set
@return An error code: 0 - success, otherwise - failure
@ref Advanced
**/
'Create' functions are associated with the CEED because the object does not exist prior to creation, but 'Destroy' functions are associated with the object in question (basis, operator, etc). Thus, the call should be done as shown in the Ref backend.
What happend was you overwrote the ElemRestrictionCreateIdentity slot in the Ceed struct because you called the SetBackendFunction incorrectly. I will have to think on how to get the function to raise an error when you use it incorrectly in the way you did. done
I modified PR #172 to prevent this sort of mistaken use of SetBackendFunction.
It is still possible to misuse this function, but it is much harder now. You would have to pass a 'type' and 'object' that do not agree. I don't know how much effort to spend on a backend developer ignoring the documentation that egregiously, but I can think about it if it would be helpful.
Ok, I got confused that the Create
happens at Ceed
level but Destroy
at Operator
level.
It is a easy thing to mix up given how I wrote it, so thanks for catching that.
When I
and calling
CeedElemRestrictionCreateIdentity
The call toceed->ElemRestrictionCreate
callsCeedOperatorDestroy_libparanumal
, removing theCeedSetBackendFunction
solves the problem. I use a delegate as following:The gdb trace: