Actual source code: plexcgns.c

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

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

  6:   Collective

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

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

 16:   Level: beginner

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

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

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

 38:   Collective

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

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

 48:   Level: beginner

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

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

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