xref: /petsc/src/dm/impls/plex/plexcgns.c (revision 07c2e4feb6773e78bda63e3a89d5b841667f9670)
1af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h> /*I   "petscdmplex.h"   I*/
2e1b39ce3SMatthew G. Knepley 
344cd5272SMichael Lange /*@C
460225df5SJacob Faibussowitsch   DMPlexCreateCGNSFromFile - Create a `DMPLEX` mesh from a CGNS file.
544cd5272SMichael Lange 
6d083f849SBarry Smith   Collective
744cd5272SMichael Lange 
844cd5272SMichael Lange   Input Parameters:
944cd5272SMichael Lange + comm        - The MPI communicator
1044cd5272SMichael Lange . filename    - The name of the CGNS file
1144cd5272SMichael Lange - interpolate - Create faces and edges in the mesh
1244cd5272SMichael Lange 
1344cd5272SMichael Lange   Output Parameter:
14a1cb98faSBarry Smith . dm - The `DM` object representing the mesh
1544cd5272SMichael Lange 
1644cd5272SMichael Lange   Level: beginner
1744cd5272SMichael Lange 
18a1cb98faSBarry Smith   Note:
19a1cb98faSBarry Smith   https://cgns.github.io
20a1cb98faSBarry Smith 
211cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateCGNS()`, `DMPlexCreateExodus()`
2244cd5272SMichael Lange @*/
DMPlexCreateCGNSFromFile(MPI_Comm comm,const char filename[],PetscBool interpolate,DM * dm)23d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexCreateCGNSFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
24d71ae5a4SJacob Faibussowitsch {
2544cd5272SMichael Lange   PetscFunctionBegin;
264f572ea9SToby Isaac   PetscAssertPointer(filename, 2);
2744cd5272SMichael Lange #if defined(PETSC_HAVE_CGNS)
285f34f2dcSJed Brown   PetscCall(DMPlexCreateCGNSFromFile_Internal(comm, filename, interpolate, dm));
2944cd5272SMichael Lange #else
3044cd5272SMichael Lange   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --with-cgns-dir");
3144cd5272SMichael Lange #endif
323ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
3344cd5272SMichael Lange }
3444cd5272SMichael Lange 
35e1b39ce3SMatthew G. Knepley /*@
36a1cb98faSBarry Smith   DMPlexCreateCGNS - Create a `DMPLEX` mesh from a CGNS file ID.
37e1b39ce3SMatthew G. Knepley 
38d083f849SBarry Smith   Collective
39e1b39ce3SMatthew G. Knepley 
40e1b39ce3SMatthew G. Knepley   Input Parameters:
41e1b39ce3SMatthew G. Knepley + comm        - The MPI communicator
42e1b39ce3SMatthew G. Knepley . cgid        - The CG id associated with a file and obtained using cg_open
43e1b39ce3SMatthew G. Knepley - interpolate - Create faces and edges in the mesh
44e1b39ce3SMatthew G. Knepley 
45e1b39ce3SMatthew G. Knepley   Output Parameter:
46a1cb98faSBarry Smith . dm - The `DM` object representing the mesh
47e1b39ce3SMatthew G. Knepley 
48e1b39ce3SMatthew G. Knepley   Level: beginner
49e1b39ce3SMatthew G. Knepley 
50a1cb98faSBarry Smith   Note:
51a1cb98faSBarry Smith   https://cgns.github.io
52a1cb98faSBarry Smith 
531cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateExodus()`
54e1b39ce3SMatthew G. Knepley @*/
DMPlexCreateCGNS(MPI_Comm comm,PetscInt cgid,PetscBool interpolate,DM * dm)55d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexCreateCGNS(MPI_Comm comm, PetscInt cgid, PetscBool interpolate, DM *dm)
56d71ae5a4SJacob Faibussowitsch {
57e1b39ce3SMatthew G. Knepley   PetscFunctionBegin;
58e1b39ce3SMatthew G. Knepley #if defined(PETSC_HAVE_CGNS)
59*472b9844SJames Wright   {
60*472b9844SJames Wright     PetscBool use_parallel_viewer = PETSC_FALSE;
61*472b9844SJames Wright 
62*472b9844SJames Wright     PetscCall(PetscOptionsGetBool(NULL, NULL, "-dm_plex_cgns_parallel", &use_parallel_viewer, NULL));
63*472b9844SJames Wright     if (use_parallel_viewer) PetscCall(DMPlexCreateCGNS_Internal_Parallel(comm, cgid, interpolate, dm));
64*472b9844SJames Wright     else PetscCall(DMPlexCreateCGNS_Internal_Serial(comm, cgid, interpolate, dm));
65*472b9844SJames Wright   }
66e1b39ce3SMatthew G. Knepley #else
675f34f2dcSJed Brown   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --download-cgns");
68e1b39ce3SMatthew G. Knepley #endif
693ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
70e1b39ce3SMatthew G. Knepley }
71