[petsc-dev] New Object and Function Development

Brandon Denton bldenton at buffalo.edu
Thu Jan 19 10:45:34 CST 2023


Good Morning,

For the past few years, I have been working to integrate CAD into PETSc.
Over this time, I've worked with Dr. Knepley to enable PETSc to open and
utilize STEP, IGES, EGADS and EGADSlite files. We've also worked to expose
the geometry's parameters (Control Points, Weights) as well as their
gradients for direct manipulation through PETSc allowing numerical
optimization of the geometry underpinning the domain's discretization
(mesh).

I'm currently trying to make this functionality usable through PETSc only
functions (wrapper functions) so users don't have to learn the underlying
CAD library. To achieve this, I need to do the following things in PETSc.

   1. Create a new PETSc object which is typedef of the underlying
   library's object. Where/what file should I include this typedef?
      - I currently defined it in the petscsystypes.h with the following
      code.

#if defined(PETSC_HAVE_EGADS)

#include <egads.h>

#include <egads_lite.h>

typedef ego PetscGeom;

#endif


   - This appears to work but I know it is not a final solution because on
   updating PETSc I get warnings saying that a few defined variables are being
   redefined by other header files. How do I properly incorporate this into
   PETSc as part of an optional capability?

2. Create wrapper functions where I need to return information back to the
main code? I currently have defined the wrapper function signatures in
plexdmplex.h as:


   - PETSC_EXTERN PetscErrorCode DMPlexGetGeomModelBodies(DM, PetscGeom *,
   PetscInt); // EGADS

In my main code, I use the following. After completion, I would
like DMPlexGetGeomModelBodies() to return the PetscGeom object which is
usually an array of 'ego' objects and the number of objects in the array of
the 'ego' objects.

PetscGeom  *newBodies = NULL;

PetscInt   numBodies = 0;

PetscCall(DMPlexGetGeomModelBodies(dmNozzle, &newBodies, numBodies));

PetscCall(PetscPrintf(PETSC_COMM_SELF, "    Nb = %d  ||  numBodies = %d
\n", Nb, numBodies));


I'm fairly certain I'm getting tripped up on how to properly pass these
objects between my main code and the new PETSc functions I'm trying to
develop. Any assistance/direction/insights you could provide is greatly
appreciated.

Thank you
Brandon Denton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20230119/228cbbde/attachment.html>


More information about the petsc-dev mailing list