Date: 2025-03-29T05:58:21+00:00

Actual source code: plexcgns.c

      1: #define PETSCDM_DLL
      2: #include <petsc/private/dmpleximpl.h>

      4: /*@C
      5:   DMPlexCreateCGNSFromFile - Create a `DMPLEX` mesh from a CGNS file.

      7:   Collective

      9:   Input Parameters:
     10: + comm        - The MPI communicator
     11: . filename    - The name of the CGNS file
     12: - interpolate - Create faces and edges in the mesh

     14:   Output Parameter:
     15: . dm - The `DM` object representing the mesh

     17:   Level: beginner

     19:   Note:
     20:   https://cgns.github.io

     22: .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateCGNS()`, `DMPlexCreateExodus()`
     23: @*/
     24: PetscErrorCode DMPlexCreateCGNSFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
     25: {
     26:   PetscFunctionBegin;
     27:   PetscAssertPointer(filename, 2);
     28: #if defined(PETSC_HAVE_CGNS)
     29:   PetscCall(DMPlexCreateCGNSFromFile_Internal(comm, filename, interpolate, dm));
     30: #else
     31:   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --with-cgns-dir");
     32: #endif
     33:   PetscFunctionReturn(PETSC_SUCCESS);
     34: }

     36: /*@
     37:   DMPlexCreateCGNS - Create a `DMPLEX` mesh from a CGNS file ID.

     39:   Collective

     41:   Input Parameters:
     42: + comm        - The MPI communicator
     43: . cgid        - The CG id associated with a file and obtained using cg_open
     44: - interpolate - Create faces and edges in the mesh

     46:   Output Parameter:
     47: . dm - The `DM` object representing the mesh

     49:   Level: beginner

     51:   Note:
     52:   https://cgns.github.io

     54: .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateExodus()`
     55: @*/
     56: PetscErrorCode DMPlexCreateCGNS(MPI_Comm comm, PetscInt cgid, PetscBool interpolate, DM *dm)
     57: {
     58:   PetscFunctionBegin;
     59: #if defined(PETSC_HAVE_CGNS)
     60:   {
     61:     PetscBool use_parallel_viewer = PETSC_FALSE;

     63:     PetscCall(PetscOptionsGetBool(NULL, NULL, "-dm_plex_cgns_parallel", &use_parallel_viewer, NULL));
     64:     if (use_parallel_viewer) PetscCall(DMPlexCreateCGNS_Internal_Parallel(comm, cgid, interpolate, dm));
     65:     else PetscCall(DMPlexCreateCGNS_Internal_Serial(comm, cgid, interpolate, dm));
     66:   }
     67: #else
     68:   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --download-cgns");
     69: #endif
     70:   PetscFunctionReturn(PETSC_SUCCESS);
     71: }