xref: /petsc/src/dm/dt/interface/dtds.c (revision 4cd1e0867dca220c4eb2b6465af42ed6fac87a5d)
1af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/
22764a2aaSMatthew G. Knepley 
32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0;
42764a2aaSMatthew G. Knepley 
52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList              = NULL;
62764a2aaSMatthew G. Knepley PetscBool         PetscDSRegisterAllCalled = PETSC_FALSE;
72764a2aaSMatthew G. Knepley 
82764a2aaSMatthew G. Knepley #undef __FUNCT__
92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister"
102764a2aaSMatthew G. Knepley /*@C
112764a2aaSMatthew G. Knepley   PetscDSRegister - Adds a new PetscDS implementation
122764a2aaSMatthew G. Knepley 
132764a2aaSMatthew G. Knepley   Not Collective
142764a2aaSMatthew G. Knepley 
152764a2aaSMatthew G. Knepley   Input Parameters:
162764a2aaSMatthew G. Knepley + name        - The name of a new user-defined creation routine
172764a2aaSMatthew G. Knepley - create_func - The creation routine itself
182764a2aaSMatthew G. Knepley 
192764a2aaSMatthew G. Knepley   Notes:
202764a2aaSMatthew G. Knepley   PetscDSRegister() may be called multiple times to add several user-defined PetscDSs
212764a2aaSMatthew G. Knepley 
222764a2aaSMatthew G. Knepley   Sample usage:
232764a2aaSMatthew G. Knepley .vb
242764a2aaSMatthew G. Knepley     PetscDSRegister("my_ds", MyPetscDSCreate);
252764a2aaSMatthew G. Knepley .ve
262764a2aaSMatthew G. Knepley 
272764a2aaSMatthew G. Knepley   Then, your PetscDS type can be chosen with the procedural interface via
282764a2aaSMatthew G. Knepley .vb
292764a2aaSMatthew G. Knepley     PetscDSCreate(MPI_Comm, PetscDS *);
302764a2aaSMatthew G. Knepley     PetscDSSetType(PetscDS, "my_ds");
312764a2aaSMatthew G. Knepley .ve
322764a2aaSMatthew G. Knepley    or at runtime via the option
332764a2aaSMatthew G. Knepley .vb
342764a2aaSMatthew G. Knepley     -petscds_type my_ds
352764a2aaSMatthew G. Knepley .ve
362764a2aaSMatthew G. Knepley 
372764a2aaSMatthew G. Knepley   Level: advanced
382764a2aaSMatthew G. Knepley 
392764a2aaSMatthew G. Knepley .keywords: PetscDS, register
402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy()
412764a2aaSMatthew G. Knepley 
422764a2aaSMatthew G. Knepley @*/
432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS))
442764a2aaSMatthew G. Knepley {
452764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
462764a2aaSMatthew G. Knepley 
472764a2aaSMatthew G. Knepley   PetscFunctionBegin;
482764a2aaSMatthew G. Knepley   ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr);
492764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
502764a2aaSMatthew G. Knepley }
512764a2aaSMatthew G. Knepley 
522764a2aaSMatthew G. Knepley #undef __FUNCT__
532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType"
542764a2aaSMatthew G. Knepley /*@C
552764a2aaSMatthew G. Knepley   PetscDSSetType - Builds a particular PetscDS
562764a2aaSMatthew G. Knepley 
572764a2aaSMatthew G. Knepley   Collective on PetscDS
582764a2aaSMatthew G. Knepley 
592764a2aaSMatthew G. Knepley   Input Parameters:
602764a2aaSMatthew G. Knepley + prob - The PetscDS object
612764a2aaSMatthew G. Knepley - name - The kind of system
622764a2aaSMatthew G. Knepley 
632764a2aaSMatthew G. Knepley   Options Database Key:
642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types
652764a2aaSMatthew G. Knepley 
662764a2aaSMatthew G. Knepley   Level: intermediate
672764a2aaSMatthew G. Knepley 
682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type
692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate()
702764a2aaSMatthew G. Knepley @*/
712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name)
722764a2aaSMatthew G. Knepley {
732764a2aaSMatthew G. Knepley   PetscErrorCode (*r)(PetscDS);
742764a2aaSMatthew G. Knepley   PetscBool      match;
752764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
762764a2aaSMatthew G. Knepley 
772764a2aaSMatthew G. Knepley   PetscFunctionBegin;
782764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
792764a2aaSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr);
802764a2aaSMatthew G. Knepley   if (match) PetscFunctionReturn(0);
812764a2aaSMatthew G. Knepley 
820f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
832764a2aaSMatthew G. Knepley   ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr);
842764a2aaSMatthew G. Knepley   if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name);
852764a2aaSMatthew G. Knepley 
862764a2aaSMatthew G. Knepley   if (prob->ops->destroy) {
872764a2aaSMatthew G. Knepley     ierr             = (*prob->ops->destroy)(prob);CHKERRQ(ierr);
882764a2aaSMatthew G. Knepley     prob->ops->destroy = NULL;
892764a2aaSMatthew G. Knepley   }
902764a2aaSMatthew G. Knepley   ierr = (*r)(prob);CHKERRQ(ierr);
912764a2aaSMatthew G. Knepley   ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr);
922764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
932764a2aaSMatthew G. Knepley }
942764a2aaSMatthew G. Knepley 
952764a2aaSMatthew G. Knepley #undef __FUNCT__
962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetType"
972764a2aaSMatthew G. Knepley /*@C
982764a2aaSMatthew G. Knepley   PetscDSGetType - Gets the PetscDS type name (as a string) from the object.
992764a2aaSMatthew G. Knepley 
1002764a2aaSMatthew G. Knepley   Not Collective
1012764a2aaSMatthew G. Knepley 
1022764a2aaSMatthew G. Knepley   Input Parameter:
1032764a2aaSMatthew G. Knepley . prob  - The PetscDS
1042764a2aaSMatthew G. Knepley 
1052764a2aaSMatthew G. Knepley   Output Parameter:
1062764a2aaSMatthew G. Knepley . name - The PetscDS type name
1072764a2aaSMatthew G. Knepley 
1082764a2aaSMatthew G. Knepley   Level: intermediate
1092764a2aaSMatthew G. Knepley 
1102764a2aaSMatthew G. Knepley .keywords: PetscDS, get, type, name
1112764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate()
1122764a2aaSMatthew G. Knepley @*/
1132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name)
1142764a2aaSMatthew G. Knepley {
1152764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
1162764a2aaSMatthew G. Knepley 
1172764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1182764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
119c959eef4SJed Brown   PetscValidPointer(name, 2);
1200f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
1212764a2aaSMatthew G. Knepley   *name = ((PetscObject) prob)->type_name;
1222764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
1232764a2aaSMatthew G. Knepley }
1242764a2aaSMatthew G. Knepley 
1252764a2aaSMatthew G. Knepley #undef __FUNCT__
1267d8a60eaSMatthew G. Knepley #define __FUNCT__ "PetscDSView_Ascii"
1277d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer)
1287d8a60eaSMatthew G. Knepley {
1297d8a60eaSMatthew G. Knepley   PetscViewerFormat format;
1307d8a60eaSMatthew G. Knepley   PetscInt          f;
1317d8a60eaSMatthew G. Knepley   PetscErrorCode    ierr;
1327d8a60eaSMatthew G. Knepley 
1337d8a60eaSMatthew G. Knepley   PetscFunctionBegin;
1347d8a60eaSMatthew G. Knepley   ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr);
1357d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr);
1367d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
1377d8a60eaSMatthew G. Knepley   for (f = 0; f < prob->Nf; ++f) {
1387d8a60eaSMatthew G. Knepley     PetscObject  obj;
1397d8a60eaSMatthew G. Knepley     PetscClassId id;
1407d8a60eaSMatthew G. Knepley     const char  *name;
1417d8a60eaSMatthew G. Knepley     PetscInt     Nc;
1427d8a60eaSMatthew G. Knepley 
1437d8a60eaSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr);
1447d8a60eaSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
1457d8a60eaSMatthew G. Knepley     ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr);
1467d8a60eaSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr);
1477d8a60eaSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {
1487d8a60eaSMatthew G. Knepley       ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr);
1497d8a60eaSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr);
1507d8a60eaSMatthew G. Knepley     } else if (id == PETSCFV_CLASSID) {
1517d8a60eaSMatthew G. Knepley       ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr);
1527d8a60eaSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr);
1537d8a60eaSMatthew G. Knepley     }
1547d8a60eaSMatthew G. Knepley     else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
1557d8a60eaSMatthew G. Knepley     if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%d components", Nc);CHKERRQ(ierr);}
1567d8a60eaSMatthew G. Knepley     else        {ierr = PetscViewerASCIIPrintf(viewer, "%d component ", Nc);CHKERRQ(ierr);}
157249df284SMatthew G. Knepley     if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);}
158249df284SMatthew G. Knepley     else                   {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);}
159a6cbbb48SMatthew G. Knepley     if (prob->adjacency[f*2+0]) {
160a6cbbb48SMatthew G. Knepley       if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);}
161a6cbbb48SMatthew G. Knepley       else                        {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);}
162a6cbbb48SMatthew G. Knepley     } else {
163a6cbbb48SMatthew G. Knepley       if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);}
164a6cbbb48SMatthew G. Knepley       else                        {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);}
165a6cbbb48SMatthew G. Knepley     }
1667d8a60eaSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr);
1677d8a60eaSMatthew G. Knepley     if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
1687d8a60eaSMatthew G. Knepley       if (id == PETSCFE_CLASSID)      {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);}
1697d8a60eaSMatthew G. Knepley       else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);}
1707d8a60eaSMatthew G. Knepley     }
1717d8a60eaSMatthew G. Knepley   }
1727d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
1737d8a60eaSMatthew G. Knepley   PetscFunctionReturn(0);
1747d8a60eaSMatthew G. Knepley }
1757d8a60eaSMatthew G. Knepley 
1767d8a60eaSMatthew G. Knepley #undef __FUNCT__
1772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView"
1782764a2aaSMatthew G. Knepley /*@C
1792764a2aaSMatthew G. Knepley   PetscDSView - Views a PetscDS
1802764a2aaSMatthew G. Knepley 
1812764a2aaSMatthew G. Knepley   Collective on PetscDS
1822764a2aaSMatthew G. Knepley 
1832764a2aaSMatthew G. Knepley   Input Parameter:
1842764a2aaSMatthew G. Knepley + prob - the PetscDS object to view
1852764a2aaSMatthew G. Knepley - v  - the viewer
1862764a2aaSMatthew G. Knepley 
1872764a2aaSMatthew G. Knepley   Level: developer
1882764a2aaSMatthew G. Knepley 
1892764a2aaSMatthew G. Knepley .seealso PetscDSDestroy()
1902764a2aaSMatthew G. Knepley @*/
1912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v)
1922764a2aaSMatthew G. Knepley {
1937d8a60eaSMatthew G. Knepley   PetscBool      iascii;
1942764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
1952764a2aaSMatthew G. Knepley 
1962764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1972764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1982764a2aaSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);}
1997d8a60eaSMatthew G. Knepley   else    {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);}
2007d8a60eaSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr);
2017d8a60eaSMatthew G. Knepley   if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);}
2022764a2aaSMatthew G. Knepley   if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);}
2032764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2042764a2aaSMatthew G. Knepley }
2052764a2aaSMatthew G. Knepley 
2062764a2aaSMatthew G. Knepley #undef __FUNCT__
2072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions"
2082764a2aaSMatthew G. Knepley /*@
2092764a2aaSMatthew G. Knepley   PetscDSSetFromOptions - sets parameters in a PetscDS from the options database
2102764a2aaSMatthew G. Knepley 
2112764a2aaSMatthew G. Knepley   Collective on PetscDS
2122764a2aaSMatthew G. Knepley 
2132764a2aaSMatthew G. Knepley   Input Parameter:
2142764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for
2152764a2aaSMatthew G. Knepley 
2162764a2aaSMatthew G. Knepley   Options Database:
2172764a2aaSMatthew G. Knepley 
2182764a2aaSMatthew G. Knepley   Level: developer
2192764a2aaSMatthew G. Knepley 
2202764a2aaSMatthew G. Knepley .seealso PetscDSView()
2212764a2aaSMatthew G. Knepley @*/
2222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob)
2232764a2aaSMatthew G. Knepley {
2242764a2aaSMatthew G. Knepley   const char    *defaultType;
2252764a2aaSMatthew G. Knepley   char           name[256];
2262764a2aaSMatthew G. Knepley   PetscBool      flg;
2272764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2282764a2aaSMatthew G. Knepley 
2292764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2302764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2312764a2aaSMatthew G. Knepley   if (!((PetscObject) prob)->type_name) {
2322764a2aaSMatthew G. Knepley     defaultType = PETSCDSBASIC;
2332764a2aaSMatthew G. Knepley   } else {
2342764a2aaSMatthew G. Knepley     defaultType = ((PetscObject) prob)->type_name;
2352764a2aaSMatthew G. Knepley   }
2360f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
2372764a2aaSMatthew G. Knepley 
2382764a2aaSMatthew G. Knepley   ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr);
2392764a2aaSMatthew G. Knepley   ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr);
2402764a2aaSMatthew G. Knepley   if (flg) {
2412764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, name);CHKERRQ(ierr);
2422764a2aaSMatthew G. Knepley   } else if (!((PetscObject) prob)->type_name) {
2432764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr);
2442764a2aaSMatthew G. Knepley   }
2452764a2aaSMatthew G. Knepley   if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);}
2462764a2aaSMatthew G. Knepley   /* process any options handlers added with PetscObjectAddOptionsHandler() */
2470633abcbSJed Brown   ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr);
2482764a2aaSMatthew G. Knepley   ierr = PetscOptionsEnd();CHKERRQ(ierr);
2492764a2aaSMatthew G. Knepley   ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);
2502764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2512764a2aaSMatthew G. Knepley }
2522764a2aaSMatthew G. Knepley 
2532764a2aaSMatthew G. Knepley #undef __FUNCT__
2542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp"
2552764a2aaSMatthew G. Knepley /*@C
2562764a2aaSMatthew G. Knepley   PetscDSSetUp - Construct data structures for the PetscDS
2572764a2aaSMatthew G. Knepley 
2582764a2aaSMatthew G. Knepley   Collective on PetscDS
2592764a2aaSMatthew G. Knepley 
2602764a2aaSMatthew G. Knepley   Input Parameter:
2612764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup
2622764a2aaSMatthew G. Knepley 
2632764a2aaSMatthew G. Knepley   Level: developer
2642764a2aaSMatthew G. Knepley 
2652764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy()
2662764a2aaSMatthew G. Knepley @*/
2672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob)
2682764a2aaSMatthew G. Knepley {
2692764a2aaSMatthew G. Knepley   const PetscInt Nf = prob->Nf;
2702764a2aaSMatthew G. Knepley   PetscInt       dim, work, NcMax = 0, NqMax = 0, f;
2712764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2722764a2aaSMatthew G. Knepley 
2732764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2742764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2752764a2aaSMatthew G. Knepley   if (prob->setup) PetscFunctionReturn(0);
2762764a2aaSMatthew G. Knepley   /* Calculate sizes */
2772764a2aaSMatthew G. Knepley   ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr);
2782764a2aaSMatthew G. Knepley   prob->totDim = prob->totDimBd = prob->totComp = 0;
279194d53e6SMatthew G. Knepley   ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr);
2802764a2aaSMatthew G. Knepley   ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr);
2812764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
2822764a2aaSMatthew G. Knepley     PetscFE         feBd = (PetscFE) prob->discBd[f];
2839de99aefSMatthew G. Knepley     PetscObject     obj;
2849de99aefSMatthew G. Knepley     PetscClassId    id;
2852764a2aaSMatthew G. Knepley     PetscQuadrature q;
2869de99aefSMatthew G. Knepley     PetscInt        Nq = 0, Nb, Nc;
2872764a2aaSMatthew G. Knepley 
2889de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr);
2899de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
2909de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {
2919de99aefSMatthew G. Knepley       PetscFE fe = (PetscFE) obj;
2929de99aefSMatthew G. Knepley 
2932764a2aaSMatthew G. Knepley       ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr);
2942764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
2952764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
2962764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
2979de99aefSMatthew G. Knepley     } else if (id == PETSCFV_CLASSID) {
2989de99aefSMatthew G. Knepley       PetscFV fv = (PetscFV) obj;
2999de99aefSMatthew G. Knepley 
3009de99aefSMatthew G. Knepley       ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr);
3019de99aefSMatthew G. Knepley       Nb   = 1;
3029de99aefSMatthew G. Knepley       ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr);
3036c1a3d01SMatthew G. Knepley       ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
304abac5ca0SMatthew G. Knepley     } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
305194d53e6SMatthew G. Knepley     prob->off[f+1]    = Nc     + prob->off[f];
306194d53e6SMatthew G. Knepley     prob->offDer[f+1] = Nc*dim + prob->offDer[f];
3079de99aefSMatthew G. Knepley     if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);}
3082764a2aaSMatthew G. Knepley     NqMax          = PetscMax(NqMax, Nq);
3092764a2aaSMatthew G. Knepley     NcMax          = PetscMax(NcMax, Nc);
3102764a2aaSMatthew G. Knepley     prob->totDim  += Nb*Nc;
3112764a2aaSMatthew G. Knepley     prob->totComp += Nc;
3122764a2aaSMatthew G. Knepley     if (feBd) {
3132764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr);
3142764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr);
3152764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr);
3162764a2aaSMatthew G. Knepley       prob->totDimBd += Nb*Nc;
317194d53e6SMatthew G. Knepley       prob->offBd[f+1]    = Nc     + prob->offBd[f];
318194d53e6SMatthew G. Knepley       prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f];
3192764a2aaSMatthew G. Knepley     }
3202764a2aaSMatthew G. Knepley   }
3212764a2aaSMatthew G. Knepley   work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim));
3222764a2aaSMatthew G. Knepley   /* Allocate works space */
3232764a2aaSMatthew G. Knepley   ierr = PetscMalloc5(prob->totComp,&prob->u,prob->totComp,&prob->u_t,prob->totComp*dim,&prob->u_x,dim,&prob->x,work,&prob->refSpaceDer);CHKERRQ(ierr);
3242764a2aaSMatthew G. Knepley   ierr = PetscMalloc6(NqMax*NcMax,&prob->f0,NqMax*NcMax*dim,&prob->f1,NqMax*NcMax*NcMax,&prob->g0,NqMax*NcMax*NcMax*dim,&prob->g1,NqMax*NcMax*NcMax*dim,&prob->g2,NqMax*NcMax*NcMax*dim*dim,&prob->g3);CHKERRQ(ierr);
3252764a2aaSMatthew G. Knepley   if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);}
3262764a2aaSMatthew G. Knepley   prob->setup = PETSC_TRUE;
3272764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3282764a2aaSMatthew G. Knepley }
3292764a2aaSMatthew G. Knepley 
3302764a2aaSMatthew G. Knepley #undef __FUNCT__
3312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static"
3322764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob)
3332764a2aaSMatthew G. Knepley {
3342764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3352764a2aaSMatthew G. Knepley 
3362764a2aaSMatthew G. Knepley   PetscFunctionBegin;
337194d53e6SMatthew G. Knepley   ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr);
3382764a2aaSMatthew G. Knepley   ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr);
3392764a2aaSMatthew G. Knepley   ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr);
3402764a2aaSMatthew G. Knepley   ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr);
3412764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3422764a2aaSMatthew G. Knepley }
3432764a2aaSMatthew G. Knepley 
3442764a2aaSMatthew G. Knepley #undef __FUNCT__
3452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static"
3462764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew)
3472764a2aaSMatthew G. Knepley {
3482764a2aaSMatthew G. Knepley   PetscObject      *tmpd, *tmpdbd;
349a6cbbb48SMatthew G. Knepley   PetscBool        *tmpi, *tmpa;
3502aa1fc23SMatthew G. Knepley   PetscPointFunc   *tmpobj, *tmpf;
351b7e05686SMatthew G. Knepley   PetscPointJac    *tmpg, *tmpgp, *tmpgt;
3522aa1fc23SMatthew G. Knepley   PetscBdPointFunc *tmpfbd;
3532aa1fc23SMatthew G. Knepley   PetscBdPointJac  *tmpgbd;
354194d53e6SMatthew G. Knepley   PetscRiemannFunc *tmpr;
3550c2f2876SMatthew G. Knepley   void            **tmpctx;
356a6cbbb48SMatthew G. Knepley   PetscInt          Nf = prob->Nf, f, i;
3572764a2aaSMatthew G. Knepley   PetscErrorCode    ierr;
3582764a2aaSMatthew G. Knepley 
3592764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3602764a2aaSMatthew G. Knepley   if (Nf >= NfNew) PetscFunctionReturn(0);
3612764a2aaSMatthew G. Knepley   prob->setup = PETSC_FALSE;
3622764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr);
363a6cbbb48SMatthew G. Knepley   ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr);
364a6cbbb48SMatthew G. Knepley   for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpdbd[f] = prob->discBd[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];}
365a6cbbb48SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr);
366a6cbbb48SMatthew G. Knepley     tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;}
367a6cbbb48SMatthew G. Knepley   ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr);
3682764a2aaSMatthew G. Knepley   prob->Nf        = NfNew;
3692764a2aaSMatthew G. Knepley   prob->disc      = tmpd;
370a6cbbb48SMatthew G. Knepley   prob->discBd    = tmpdbd;
371249df284SMatthew G. Knepley   prob->implicit  = tmpi;
372a6cbbb48SMatthew G. Knepley   prob->adjacency = tmpa;
373b7e05686SMatthew G. Knepley   ierr = PetscCalloc7(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew*NfNew*4, &tmpgp, NfNew*NfNew*4, &tmpgt, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr);
3742764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f];
3752764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f];
3762764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f];
377475e0ac9SMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f];
3780c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f];
3790c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f];
3802764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL;
3812764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL;
3822764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL;
383475e0ac9SMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL;
384b7e05686SMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL;
3850c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL;
3860c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL;
387b7e05686SMatthew G. Knepley   ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr);
3882764a2aaSMatthew G. Knepley   prob->obj = tmpobj;
3892764a2aaSMatthew G. Knepley   prob->f   = tmpf;
3902764a2aaSMatthew G. Knepley   prob->g   = tmpg;
391475e0ac9SMatthew G. Knepley   prob->gp  = tmpgp;
392b7e05686SMatthew G. Knepley   prob->gt  = tmpgt;
3930c2f2876SMatthew G. Knepley   prob->r   = tmpr;
3940c2f2876SMatthew G. Knepley   prob->ctx = tmpctx;
3952764a2aaSMatthew G. Knepley   ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr);
3962764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f];
3972764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f];
3982764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL;
3992764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL;
4002764a2aaSMatthew G. Knepley   ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr);
4012764a2aaSMatthew G. Knepley   prob->fBd = tmpfbd;
4022764a2aaSMatthew G. Knepley   prob->gBd = tmpgbd;
4032764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4042764a2aaSMatthew G. Knepley }
4052764a2aaSMatthew G. Knepley 
4062764a2aaSMatthew G. Knepley #undef __FUNCT__
4072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy"
4082764a2aaSMatthew G. Knepley /*@
4092764a2aaSMatthew G. Knepley   PetscDSDestroy - Destroys a PetscDS object
4102764a2aaSMatthew G. Knepley 
4112764a2aaSMatthew G. Knepley   Collective on PetscDS
4122764a2aaSMatthew G. Knepley 
4132764a2aaSMatthew G. Knepley   Input Parameter:
4142764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy
4152764a2aaSMatthew G. Knepley 
4162764a2aaSMatthew G. Knepley   Level: developer
4172764a2aaSMatthew G. Knepley 
4182764a2aaSMatthew G. Knepley .seealso PetscDSView()
4192764a2aaSMatthew G. Knepley @*/
4202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob)
4212764a2aaSMatthew G. Knepley {
4222764a2aaSMatthew G. Knepley   PetscInt       f;
4232764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4242764a2aaSMatthew G. Knepley 
4252764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4262764a2aaSMatthew G. Knepley   if (!*prob) PetscFunctionReturn(0);
4272764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1);
4282764a2aaSMatthew G. Knepley 
4292764a2aaSMatthew G. Knepley   if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);}
4302764a2aaSMatthew G. Knepley   ((PetscObject) (*prob))->refct = 0;
4312764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr);
4322764a2aaSMatthew G. Knepley   for (f = 0; f < (*prob)->Nf; ++f) {
4332764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr);
4342764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr);
4352764a2aaSMatthew G. Knepley   }
436a6cbbb48SMatthew G. Knepley   ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr);
437b7e05686SMatthew G. Knepley   ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr);
4382764a2aaSMatthew G. Knepley   ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr);
4392764a2aaSMatthew G. Knepley   if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);}
4402764a2aaSMatthew G. Knepley   ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr);
4412764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4422764a2aaSMatthew G. Knepley }
4432764a2aaSMatthew G. Knepley 
4442764a2aaSMatthew G. Knepley #undef __FUNCT__
4452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate"
4462764a2aaSMatthew G. Knepley /*@
4472764a2aaSMatthew G. Knepley   PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType().
4482764a2aaSMatthew G. Knepley 
4492764a2aaSMatthew G. Knepley   Collective on MPI_Comm
4502764a2aaSMatthew G. Knepley 
4512764a2aaSMatthew G. Knepley   Input Parameter:
4522764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object
4532764a2aaSMatthew G. Knepley 
4542764a2aaSMatthew G. Knepley   Output Parameter:
4552764a2aaSMatthew G. Knepley . prob - The PetscDS object
4562764a2aaSMatthew G. Knepley 
4572764a2aaSMatthew G. Knepley   Level: beginner
4582764a2aaSMatthew G. Knepley 
4592764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC
4602764a2aaSMatthew G. Knepley @*/
4612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob)
4622764a2aaSMatthew G. Knepley {
4632764a2aaSMatthew G. Knepley   PetscDS   p;
4642764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4652764a2aaSMatthew G. Knepley 
4662764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4672764a2aaSMatthew G. Knepley   PetscValidPointer(prob, 2);
4682764a2aaSMatthew G. Knepley   *prob  = NULL;
4692764a2aaSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
4702764a2aaSMatthew G. Knepley 
47173107ff1SLisandro Dalcin   ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr);
4722764a2aaSMatthew G. Knepley 
4732764a2aaSMatthew G. Knepley   p->Nf    = 0;
4742764a2aaSMatthew G. Knepley   p->setup = PETSC_FALSE;
4752764a2aaSMatthew G. Knepley 
4762764a2aaSMatthew G. Knepley   *prob = p;
4772764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4782764a2aaSMatthew G. Knepley }
4792764a2aaSMatthew G. Knepley 
4802764a2aaSMatthew G. Knepley #undef __FUNCT__
4812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields"
482bc4ae4beSMatthew G. Knepley /*@
483bc4ae4beSMatthew G. Knepley   PetscDSGetNumFields - Returns the number of fields in the DS
484bc4ae4beSMatthew G. Knepley 
485bc4ae4beSMatthew G. Knepley   Not collective
486bc4ae4beSMatthew G. Knepley 
487bc4ae4beSMatthew G. Knepley   Input Parameter:
488bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
489bc4ae4beSMatthew G. Knepley 
490bc4ae4beSMatthew G. Knepley   Output Parameter:
491bc4ae4beSMatthew G. Knepley . Nf - The number of fields
492bc4ae4beSMatthew G. Knepley 
493bc4ae4beSMatthew G. Knepley   Level: beginner
494bc4ae4beSMatthew G. Knepley 
495bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate()
496bc4ae4beSMatthew G. Knepley @*/
4972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf)
4982764a2aaSMatthew G. Knepley {
4992764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5002764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5012764a2aaSMatthew G. Knepley   PetscValidPointer(Nf, 2);
5022764a2aaSMatthew G. Knepley   *Nf = prob->Nf;
5032764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5042764a2aaSMatthew G. Knepley }
5052764a2aaSMatthew G. Knepley 
5062764a2aaSMatthew G. Knepley #undef __FUNCT__
5072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension"
508bc4ae4beSMatthew G. Knepley /*@
509bc4ae4beSMatthew G. Knepley   PetscDSGetSpatialDimension - Returns the spatial dimension of the DS
510bc4ae4beSMatthew G. Knepley 
511bc4ae4beSMatthew G. Knepley   Not collective
512bc4ae4beSMatthew G. Knepley 
513bc4ae4beSMatthew G. Knepley   Input Parameter:
514bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
515bc4ae4beSMatthew G. Knepley 
516bc4ae4beSMatthew G. Knepley   Output Parameter:
517bc4ae4beSMatthew G. Knepley . dim - The spatial dimension
518bc4ae4beSMatthew G. Knepley 
519bc4ae4beSMatthew G. Knepley   Level: beginner
520bc4ae4beSMatthew G. Knepley 
521bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
522bc4ae4beSMatthew G. Knepley @*/
5232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim)
5242764a2aaSMatthew G. Knepley {
5252764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5262764a2aaSMatthew G. Knepley 
5272764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5282764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5292764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5302764a2aaSMatthew G. Knepley   *dim = 0;
5319de99aefSMatthew G. Knepley   if (prob->Nf) {
5329de99aefSMatthew G. Knepley     PetscObject  obj;
5339de99aefSMatthew G. Knepley     PetscClassId id;
5349de99aefSMatthew G. Knepley 
5359de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr);
5369de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
5379de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);}
5389de99aefSMatthew G. Knepley     else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);}
5399de99aefSMatthew G. Knepley     else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0);
5409de99aefSMatthew G. Knepley   }
5412764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5422764a2aaSMatthew G. Knepley }
5432764a2aaSMatthew G. Knepley 
5442764a2aaSMatthew G. Knepley #undef __FUNCT__
5452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension"
546bc4ae4beSMatthew G. Knepley /*@
547bc4ae4beSMatthew G. Knepley   PetscDSGetTotalDimension - Returns the total size of the approximation space for this system
548bc4ae4beSMatthew G. Knepley 
549bc4ae4beSMatthew G. Knepley   Not collective
550bc4ae4beSMatthew G. Knepley 
551bc4ae4beSMatthew G. Knepley   Input Parameter:
552bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
553bc4ae4beSMatthew G. Knepley 
554bc4ae4beSMatthew G. Knepley   Output Parameter:
555bc4ae4beSMatthew G. Knepley . dim - The total problem dimension
556bc4ae4beSMatthew G. Knepley 
557bc4ae4beSMatthew G. Knepley   Level: beginner
558bc4ae4beSMatthew G. Knepley 
559bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
560bc4ae4beSMatthew G. Knepley @*/
5612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim)
5622764a2aaSMatthew G. Knepley {
5632764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5642764a2aaSMatthew G. Knepley 
5652764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5662764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5672764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
5682764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5692764a2aaSMatthew G. Knepley   *dim = prob->totDim;
5702764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5712764a2aaSMatthew G. Knepley }
5722764a2aaSMatthew G. Knepley 
5732764a2aaSMatthew G. Knepley #undef __FUNCT__
5742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension"
575bc4ae4beSMatthew G. Knepley /*@
576c3ac4435SMatthew G. Knepley   PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system
577bc4ae4beSMatthew G. Knepley 
578bc4ae4beSMatthew G. Knepley   Not collective
579bc4ae4beSMatthew G. Knepley 
580bc4ae4beSMatthew G. Knepley   Input Parameter:
581bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
582bc4ae4beSMatthew G. Knepley 
583bc4ae4beSMatthew G. Knepley   Output Parameter:
584bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension
585bc4ae4beSMatthew G. Knepley 
586bc4ae4beSMatthew G. Knepley   Level: beginner
587bc4ae4beSMatthew G. Knepley 
588bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
589bc4ae4beSMatthew G. Knepley @*/
5902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim)
5912764a2aaSMatthew G. Knepley {
5922764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5932764a2aaSMatthew G. Knepley 
5942764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5952764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5962764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
5972764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5982764a2aaSMatthew G. Knepley   *dim = prob->totDimBd;
5992764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6002764a2aaSMatthew G. Knepley }
6012764a2aaSMatthew G. Knepley 
6022764a2aaSMatthew G. Knepley #undef __FUNCT__
6032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents"
604bc4ae4beSMatthew G. Knepley /*@
605bc4ae4beSMatthew G. Knepley   PetscDSGetTotalComponents - Returns the total number of components in this system
606bc4ae4beSMatthew G. Knepley 
607bc4ae4beSMatthew G. Knepley   Not collective
608bc4ae4beSMatthew G. Knepley 
609bc4ae4beSMatthew G. Knepley   Input Parameter:
610bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
611bc4ae4beSMatthew G. Knepley 
612bc4ae4beSMatthew G. Knepley   Output Parameter:
613bc4ae4beSMatthew G. Knepley . dim - The total number of components
614bc4ae4beSMatthew G. Knepley 
615bc4ae4beSMatthew G. Knepley   Level: beginner
616bc4ae4beSMatthew G. Knepley 
617bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
618bc4ae4beSMatthew G. Knepley @*/
6192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc)
6202764a2aaSMatthew G. Knepley {
6212764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6222764a2aaSMatthew G. Knepley 
6232764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6242764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6252764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
6262764a2aaSMatthew G. Knepley   PetscValidPointer(Nc, 2);
6272764a2aaSMatthew G. Knepley   *Nc = prob->totComp;
6282764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6292764a2aaSMatthew G. Knepley }
6302764a2aaSMatthew G. Knepley 
6312764a2aaSMatthew G. Knepley #undef __FUNCT__
6322764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization"
633bc4ae4beSMatthew G. Knepley /*@
634bc4ae4beSMatthew G. Knepley   PetscDSGetDiscretization - Returns the discretization object for the given field
635bc4ae4beSMatthew G. Knepley 
636bc4ae4beSMatthew G. Knepley   Not collective
637bc4ae4beSMatthew G. Knepley 
638bc4ae4beSMatthew G. Knepley   Input Parameters:
639bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
640bc4ae4beSMatthew G. Knepley - f - The field number
641bc4ae4beSMatthew G. Knepley 
642bc4ae4beSMatthew G. Knepley   Output Parameter:
643bc4ae4beSMatthew G. Knepley . disc - The discretization object
644bc4ae4beSMatthew G. Knepley 
645bc4ae4beSMatthew G. Knepley   Level: beginner
646bc4ae4beSMatthew G. Knepley 
647bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
648bc4ae4beSMatthew G. Knepley @*/
6492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
6502764a2aaSMatthew G. Knepley {
6512764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6522764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6532764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
6542764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
6552764a2aaSMatthew G. Knepley   *disc = prob->disc[f];
6562764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6572764a2aaSMatthew G. Knepley }
6582764a2aaSMatthew G. Knepley 
6592764a2aaSMatthew G. Knepley #undef __FUNCT__
6602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization"
661bc4ae4beSMatthew G. Knepley /*@
662bc4ae4beSMatthew G. Knepley   PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field
663bc4ae4beSMatthew G. Knepley 
664bc4ae4beSMatthew G. Knepley   Not collective
665bc4ae4beSMatthew G. Knepley 
666bc4ae4beSMatthew G. Knepley   Input Parameters:
667bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
668bc4ae4beSMatthew G. Knepley - f - The field number
669bc4ae4beSMatthew G. Knepley 
670bc4ae4beSMatthew G. Knepley   Output Parameter:
671bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object
672bc4ae4beSMatthew G. Knepley 
673bc4ae4beSMatthew G. Knepley   Level: beginner
674bc4ae4beSMatthew G. Knepley 
675bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
676bc4ae4beSMatthew G. Knepley @*/
6772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
6782764a2aaSMatthew G. Knepley {
6792764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6802764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6812764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
6822764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
6832764a2aaSMatthew G. Knepley   *disc = prob->discBd[f];
6842764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6852764a2aaSMatthew G. Knepley }
6862764a2aaSMatthew G. Knepley 
6872764a2aaSMatthew G. Knepley #undef __FUNCT__
6882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization"
689bc4ae4beSMatthew G. Knepley /*@
690bc4ae4beSMatthew G. Knepley   PetscDSSetDiscretization - Sets the discretization object for the given field
691bc4ae4beSMatthew G. Knepley 
692bc4ae4beSMatthew G. Knepley   Not collective
693bc4ae4beSMatthew G. Knepley 
694bc4ae4beSMatthew G. Knepley   Input Parameters:
695bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
696bc4ae4beSMatthew G. Knepley . f - The field number
697bc4ae4beSMatthew G. Knepley - disc - The discretization object
698bc4ae4beSMatthew G. Knepley 
699bc4ae4beSMatthew G. Knepley   Level: beginner
700bc4ae4beSMatthew G. Knepley 
701bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
702bc4ae4beSMatthew G. Knepley @*/
7032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
7042764a2aaSMatthew G. Knepley {
7052764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7062764a2aaSMatthew G. Knepley 
7072764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7082764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7092764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
7102764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7112764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7122764a2aaSMatthew G. Knepley   if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);}
7132764a2aaSMatthew G. Knepley   prob->disc[f] = disc;
7142764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
715249df284SMatthew G. Knepley   {
716249df284SMatthew G. Knepley     PetscClassId id;
717249df284SMatthew G. Knepley 
718249df284SMatthew G. Knepley     ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr);
719a6cbbb48SMatthew G. Knepley     if (id == PETSCFV_CLASSID) {
720a6cbbb48SMatthew G. Knepley       prob->implicit[f]      = PETSC_FALSE;
721a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+0] = PETSC_TRUE;
722a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+1] = PETSC_FALSE;
723a6cbbb48SMatthew G. Knepley     }
724249df284SMatthew G. Knepley   }
7252764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7262764a2aaSMatthew G. Knepley }
7272764a2aaSMatthew G. Knepley 
7282764a2aaSMatthew G. Knepley #undef __FUNCT__
7292764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization"
730bc4ae4beSMatthew G. Knepley /*@
731bc4ae4beSMatthew G. Knepley   PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field
732bc4ae4beSMatthew G. Knepley 
733bc4ae4beSMatthew G. Knepley   Not collective
734bc4ae4beSMatthew G. Knepley 
735bc4ae4beSMatthew G. Knepley   Input Parameters:
736bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
737bc4ae4beSMatthew G. Knepley . f - The field number
738bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
739bc4ae4beSMatthew G. Knepley 
740bc4ae4beSMatthew G. Knepley   Level: beginner
741bc4ae4beSMatthew G. Knepley 
742bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
743bc4ae4beSMatthew G. Knepley @*/
7442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
7452764a2aaSMatthew G. Knepley {
7462764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7472764a2aaSMatthew G. Knepley 
7482764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7492764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7502764a2aaSMatthew G. Knepley   if (disc) PetscValidPointer(disc, 3);
7512764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7522764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7532764a2aaSMatthew G. Knepley   if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);}
7542764a2aaSMatthew G. Knepley   prob->discBd[f] = disc;
7552764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
7562764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7572764a2aaSMatthew G. Knepley }
7582764a2aaSMatthew G. Knepley 
7592764a2aaSMatthew G. Knepley #undef __FUNCT__
7602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization"
761bc4ae4beSMatthew G. Knepley /*@
762bc4ae4beSMatthew G. Knepley   PetscDSAddDiscretization - Adds a discretization object
763bc4ae4beSMatthew G. Knepley 
764bc4ae4beSMatthew G. Knepley   Not collective
765bc4ae4beSMatthew G. Knepley 
766bc4ae4beSMatthew G. Knepley   Input Parameters:
767bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
768bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
769bc4ae4beSMatthew G. Knepley 
770bc4ae4beSMatthew G. Knepley   Level: beginner
771bc4ae4beSMatthew G. Knepley 
772bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
773bc4ae4beSMatthew G. Knepley @*/
7742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc)
7752764a2aaSMatthew G. Knepley {
7762764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7772764a2aaSMatthew G. Knepley 
7782764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7792764a2aaSMatthew G. Knepley   ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
7802764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7812764a2aaSMatthew G. Knepley }
7822764a2aaSMatthew G. Knepley 
7832764a2aaSMatthew G. Knepley #undef __FUNCT__
7842764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization"
785bc4ae4beSMatthew G. Knepley /*@
786bc4ae4beSMatthew G. Knepley   PetscDSAddBdDiscretization - Adds a boundary discretization object
787bc4ae4beSMatthew G. Knepley 
788bc4ae4beSMatthew G. Knepley   Not collective
789bc4ae4beSMatthew G. Knepley 
790bc4ae4beSMatthew G. Knepley   Input Parameters:
791bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
792bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
793bc4ae4beSMatthew G. Knepley 
794bc4ae4beSMatthew G. Knepley   Level: beginner
795bc4ae4beSMatthew G. Knepley 
796bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
797bc4ae4beSMatthew G. Knepley @*/
7982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc)
7992764a2aaSMatthew G. Knepley {
8002764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8012764a2aaSMatthew G. Knepley 
8022764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8032764a2aaSMatthew G. Knepley   ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
8042764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8052764a2aaSMatthew G. Knepley }
8062764a2aaSMatthew G. Knepley 
8072764a2aaSMatthew G. Knepley #undef __FUNCT__
808249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit"
809249df284SMatthew G. Knepley /*@
810249df284SMatthew G. Knepley   PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX
811249df284SMatthew G. Knepley 
812249df284SMatthew G. Knepley   Not collective
813249df284SMatthew G. Knepley 
814249df284SMatthew G. Knepley   Input Parameters:
815249df284SMatthew G. Knepley + prob - The PetscDS object
816249df284SMatthew G. Knepley - f - The field number
817249df284SMatthew G. Knepley 
818249df284SMatthew G. Knepley   Output Parameter:
819249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field
820249df284SMatthew G. Knepley 
821249df284SMatthew G. Knepley   Level: developer
822249df284SMatthew G. Knepley 
823249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
824249df284SMatthew G. Knepley @*/
825249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit)
826249df284SMatthew G. Knepley {
827249df284SMatthew G. Knepley   PetscFunctionBegin;
828249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
829249df284SMatthew G. Knepley   PetscValidPointer(implicit, 3);
830249df284SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
831249df284SMatthew G. Knepley   *implicit = prob->implicit[f];
832249df284SMatthew G. Knepley   PetscFunctionReturn(0);
833249df284SMatthew G. Knepley }
834249df284SMatthew G. Knepley 
835249df284SMatthew G. Knepley #undef __FUNCT__
836249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit"
837249df284SMatthew G. Knepley /*@
838249df284SMatthew G. Knepley   PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX
839249df284SMatthew G. Knepley 
840249df284SMatthew G. Knepley   Not collective
841249df284SMatthew G. Knepley 
842249df284SMatthew G. Knepley   Input Parameters:
843249df284SMatthew G. Knepley + prob - The PetscDS object
844249df284SMatthew G. Knepley . f - The field number
845249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field
846249df284SMatthew G. Knepley 
847249df284SMatthew G. Knepley   Level: developer
848249df284SMatthew G. Knepley 
849249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
850249df284SMatthew G. Knepley @*/
851249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit)
852249df284SMatthew G. Knepley {
853249df284SMatthew G. Knepley   PetscFunctionBegin;
854249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
855249df284SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
856249df284SMatthew G. Knepley   prob->implicit[f] = implicit;
857249df284SMatthew G. Knepley   PetscFunctionReturn(0);
858249df284SMatthew G. Knepley }
859249df284SMatthew G. Knepley 
860249df284SMatthew G. Knepley #undef __FUNCT__
861a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency"
862a6cbbb48SMatthew G. Knepley /*@
863a6cbbb48SMatthew G. Knepley   PetscDSGetAdjacency - Returns the flags for determining variable influence
864a6cbbb48SMatthew G. Knepley 
865a6cbbb48SMatthew G. Knepley   Not collective
866a6cbbb48SMatthew G. Knepley 
867a6cbbb48SMatthew G. Knepley   Input Parameters:
868a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
869a6cbbb48SMatthew G. Knepley - f - The field number
870a6cbbb48SMatthew G. Knepley 
871a6cbbb48SMatthew G. Knepley   Output Parameter:
872a6cbbb48SMatthew G. Knepley + useCone    - Flag for variable influence starting with the cone operation
873a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
874a6cbbb48SMatthew G. Knepley 
875a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
876a6cbbb48SMatthew G. Knepley 
877a6cbbb48SMatthew G. Knepley   Level: developer
878a6cbbb48SMatthew G. Knepley 
879a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
880a6cbbb48SMatthew G. Knepley @*/
881a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure)
882a6cbbb48SMatthew G. Knepley {
883a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
884a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
885a6cbbb48SMatthew G. Knepley   PetscValidPointer(useCone, 3);
886a6cbbb48SMatthew G. Knepley   PetscValidPointer(useClosure, 4);
887a6cbbb48SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
888a6cbbb48SMatthew G. Knepley   *useCone    = prob->adjacency[f*2+0];
889a6cbbb48SMatthew G. Knepley   *useClosure = prob->adjacency[f*2+1];
890a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
891a6cbbb48SMatthew G. Knepley }
892a6cbbb48SMatthew G. Knepley 
893a6cbbb48SMatthew G. Knepley #undef __FUNCT__
894a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency"
895a6cbbb48SMatthew G. Knepley /*@
896a6cbbb48SMatthew G. Knepley   PetscDSSetAdjacency - Set the flags for determining variable influence
897a6cbbb48SMatthew G. Knepley 
898a6cbbb48SMatthew G. Knepley   Not collective
899a6cbbb48SMatthew G. Knepley 
900a6cbbb48SMatthew G. Knepley   Input Parameters:
901a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
902a6cbbb48SMatthew G. Knepley . f - The field number
903a6cbbb48SMatthew G. Knepley . useCone    - Flag for variable influence starting with the cone operation
904a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
905a6cbbb48SMatthew G. Knepley 
906a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
907a6cbbb48SMatthew G. Knepley 
908a6cbbb48SMatthew G. Knepley   Level: developer
909a6cbbb48SMatthew G. Knepley 
910a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
911a6cbbb48SMatthew G. Knepley @*/
912a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure)
913a6cbbb48SMatthew G. Knepley {
914a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
915a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
916a6cbbb48SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
917a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+0] = useCone;
918a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+1] = useClosure;
919a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
920a6cbbb48SMatthew G. Knepley }
921a6cbbb48SMatthew G. Knepley 
922a6cbbb48SMatthew G. Knepley #undef __FUNCT__
9232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective"
9242764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f,
92530b9ff8bSMatthew G. Knepley                                    void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
926194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
927194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
92830b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], PetscScalar obj[]))
9292764a2aaSMatthew G. Knepley {
9302764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9312764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9322764a2aaSMatthew G. Knepley   PetscValidPointer(obj, 2);
9332764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
9342764a2aaSMatthew G. Knepley   *obj = prob->obj[f];
9352764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9362764a2aaSMatthew G. Knepley }
9372764a2aaSMatthew G. Knepley 
9382764a2aaSMatthew G. Knepley #undef __FUNCT__
9392764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective"
9402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f,
94130b9ff8bSMatthew G. Knepley                                    void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
942194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
943194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
94430b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], PetscScalar obj[]))
9452764a2aaSMatthew G. Knepley {
9462764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9472764a2aaSMatthew G. Knepley 
9482764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9492764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
950de716cbcSToby Isaac   if (obj) PetscValidFunction(obj, 2);
9512764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
9522764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
9532764a2aaSMatthew G. Knepley   prob->obj[f] = obj;
9542764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9552764a2aaSMatthew G. Knepley }
9562764a2aaSMatthew G. Knepley 
9572764a2aaSMatthew G. Knepley #undef __FUNCT__
9582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual"
959194d53e6SMatthew G. Knepley /*@C
960194d53e6SMatthew G. Knepley   PetscDSGetResidual - Get the pointwise residual function for a given test field
961194d53e6SMatthew G. Knepley 
962194d53e6SMatthew G. Knepley   Not collective
963194d53e6SMatthew G. Knepley 
964194d53e6SMatthew G. Knepley   Input Parameters:
965194d53e6SMatthew G. Knepley + prob - The PetscDS
966194d53e6SMatthew G. Knepley - f    - The test field number
967194d53e6SMatthew G. Knepley 
968194d53e6SMatthew G. Knepley   Output Parameters:
969194d53e6SMatthew G. Knepley + f0 - integrand for the test function term
970194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
971194d53e6SMatthew G. Knepley 
972194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
973194d53e6SMatthew G. Knepley 
974194d53e6SMatthew G. Knepley   \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t)
975194d53e6SMatthew G. Knepley 
976194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
977194d53e6SMatthew G. Knepley 
97830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
979194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
980194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
98130b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar f0[])
982194d53e6SMatthew G. Knepley 
983194d53e6SMatthew G. Knepley + dim - the spatial dimension
984194d53e6SMatthew G. Knepley . Nf - the number of fields
985194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
986194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
987194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
988194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
989194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
990194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
991194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
992194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
993194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
994194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
995194d53e6SMatthew G. Knepley . t - current time
996194d53e6SMatthew G. Knepley . x - coordinates of the current point
997194d53e6SMatthew G. Knepley - f0 - output values at the current point
998194d53e6SMatthew G. Knepley 
999194d53e6SMatthew G. Knepley   Level: intermediate
1000194d53e6SMatthew G. Knepley 
1001194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual()
1002194d53e6SMatthew G. Knepley @*/
10032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f,
100430b9ff8bSMatthew G. Knepley                                   void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1005194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1006194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
100730b9ff8bSMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar f0[]),
100830b9ff8bSMatthew G. Knepley                                   void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1009194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1010194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
101130b9ff8bSMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar f1[]))
10122764a2aaSMatthew G. Knepley {
10132764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10142764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
10152764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
10162764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];}
10172764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];}
10182764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10192764a2aaSMatthew G. Knepley }
10202764a2aaSMatthew G. Knepley 
10212764a2aaSMatthew G. Knepley #undef __FUNCT__
10222764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual"
1023194d53e6SMatthew G. Knepley /*@C
1024194d53e6SMatthew G. Knepley   PetscDSSetResidual - Set the pointwise residual function for a given test field
1025194d53e6SMatthew G. Knepley 
1026194d53e6SMatthew G. Knepley   Not collective
1027194d53e6SMatthew G. Knepley 
1028194d53e6SMatthew G. Knepley   Input Parameters:
1029194d53e6SMatthew G. Knepley + prob - The PetscDS
1030194d53e6SMatthew G. Knepley . f    - The test field number
1031194d53e6SMatthew G. Knepley . f0 - integrand for the test function term
1032194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
1033194d53e6SMatthew G. Knepley 
1034194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1035194d53e6SMatthew G. Knepley 
1036194d53e6SMatthew G. Knepley   \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t)
1037194d53e6SMatthew G. Knepley 
1038194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1039194d53e6SMatthew G. Knepley 
104030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1041194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1042194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
104330b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar f0[])
1044194d53e6SMatthew G. Knepley 
1045194d53e6SMatthew G. Knepley + dim - the spatial dimension
1046194d53e6SMatthew G. Knepley . Nf - the number of fields
1047194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1048194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1049194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1050194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1051194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1052194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1053194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1054194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1055194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1056194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1057194d53e6SMatthew G. Knepley . t - current time
1058194d53e6SMatthew G. Knepley . x - coordinates of the current point
1059194d53e6SMatthew G. Knepley - f0 - output values at the current point
1060194d53e6SMatthew G. Knepley 
1061194d53e6SMatthew G. Knepley   Level: intermediate
1062194d53e6SMatthew G. Knepley 
1063194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual()
1064194d53e6SMatthew G. Knepley @*/
10652764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f,
106630b9ff8bSMatthew G. Knepley                                   void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1067194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1068194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
106930b9ff8bSMatthew G. Knepley                                              PetscReal t, const PetscReal x[], PetscScalar f0[]),
107030b9ff8bSMatthew G. Knepley                                   void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1071194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1072194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
107330b9ff8bSMatthew G. Knepley                                              PetscReal t, const PetscReal x[], PetscScalar f1[]))
10742764a2aaSMatthew G. Knepley {
10752764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
10762764a2aaSMatthew G. Knepley 
10772764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10782764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1079f866a1d0SMatthew G. Knepley   if (f0) PetscValidFunction(f0, 3);
1080f866a1d0SMatthew G. Knepley   if (f1) PetscValidFunction(f1, 4);
10812764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
10822764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
10832764a2aaSMatthew G. Knepley   prob->f[f*2+0] = f0;
10842764a2aaSMatthew G. Knepley   prob->f[f*2+1] = f1;
10852764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10862764a2aaSMatthew G. Knepley }
10872764a2aaSMatthew G. Knepley 
10882764a2aaSMatthew G. Knepley #undef __FUNCT__
10893e75805dSMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobian"
10903e75805dSMatthew G. Knepley /*@C
10913e75805dSMatthew G. Knepley   PetscDSHasJacobian - Signals that Jacobian functions have been set
10923e75805dSMatthew G. Knepley 
10933e75805dSMatthew G. Knepley   Not collective
10943e75805dSMatthew G. Knepley 
10953e75805dSMatthew G. Knepley   Input Parameter:
10963e75805dSMatthew G. Knepley . prob - The PetscDS
10973e75805dSMatthew G. Knepley 
10983e75805dSMatthew G. Knepley   Output Parameter:
10993e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set
11003e75805dSMatthew G. Knepley 
11013e75805dSMatthew G. Knepley   Level: intermediate
11023e75805dSMatthew G. Knepley 
11033e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian()
11043e75805dSMatthew G. Knepley @*/
11053e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac)
11063e75805dSMatthew G. Knepley {
11073e75805dSMatthew G. Knepley   PetscInt f, g, h;
11083e75805dSMatthew G. Knepley 
11093e75805dSMatthew G. Knepley   PetscFunctionBegin;
11103e75805dSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
11113e75805dSMatthew G. Knepley   *hasJac = PETSC_FALSE;
11123e75805dSMatthew G. Knepley   for (f = 0; f < prob->Nf; ++f) {
11133e75805dSMatthew G. Knepley     for (g = 0; g < prob->Nf; ++g) {
11143e75805dSMatthew G. Knepley       for (h = 0; h < 4; ++h) {
11153e75805dSMatthew G. Knepley         if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE;
11163e75805dSMatthew G. Knepley       }
11173e75805dSMatthew G. Knepley     }
11183e75805dSMatthew G. Knepley   }
11193e75805dSMatthew G. Knepley   PetscFunctionReturn(0);
11203e75805dSMatthew G. Knepley }
11213e75805dSMatthew G. Knepley 
11223e75805dSMatthew G. Knepley #undef __FUNCT__
11232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian"
1124194d53e6SMatthew G. Knepley /*@C
1125194d53e6SMatthew G. Knepley   PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field
1126194d53e6SMatthew G. Knepley 
1127194d53e6SMatthew G. Knepley   Not collective
1128194d53e6SMatthew G. Knepley 
1129194d53e6SMatthew G. Knepley   Input Parameters:
1130194d53e6SMatthew G. Knepley + prob - The PetscDS
1131194d53e6SMatthew G. Knepley . f    - The test field number
1132194d53e6SMatthew G. Knepley - g    - The field number
1133194d53e6SMatthew G. Knepley 
1134194d53e6SMatthew G. Knepley   Output Parameters:
1135194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1136194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1137194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1138194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1139194d53e6SMatthew G. Knepley 
1140194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1141194d53e6SMatthew G. Knepley 
1142194d53e6SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1143194d53e6SMatthew G. Knepley 
1144194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1145194d53e6SMatthew G. Knepley 
114630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1147194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1148194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
114930b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[])
1150194d53e6SMatthew G. Knepley 
1151194d53e6SMatthew G. Knepley + dim - the spatial dimension
1152194d53e6SMatthew G. Knepley . Nf - the number of fields
1153194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1154194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1155194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1156194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1157194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1158194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1159194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1160194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1161194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1162194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1163194d53e6SMatthew G. Knepley . t - current time
11642aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1165194d53e6SMatthew G. Knepley . x - coordinates of the current point
1166194d53e6SMatthew G. Knepley - g0 - output values at the current point
1167194d53e6SMatthew G. Knepley 
1168194d53e6SMatthew G. Knepley   Level: intermediate
1169194d53e6SMatthew G. Knepley 
1170194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian()
1171194d53e6SMatthew G. Knepley @*/
11722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g,
117330b9ff8bSMatthew G. Knepley                                   void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1174194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1175194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11762aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
117730b9ff8bSMatthew G. Knepley                                   void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1178194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1179194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11802aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
118130b9ff8bSMatthew G. Knepley                                   void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1182194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1183194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11842aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
118530b9ff8bSMatthew G. Knepley                                   void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1186194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1187194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11882aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
11892764a2aaSMatthew G. Knepley {
11902764a2aaSMatthew G. Knepley   PetscFunctionBegin;
11912764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
11922764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
11932764a2aaSMatthew G. Knepley   if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf);
11942764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];}
11952764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];}
11962764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];}
11972764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];}
11982764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
11992764a2aaSMatthew G. Knepley }
12002764a2aaSMatthew G. Knepley 
12012764a2aaSMatthew G. Knepley #undef __FUNCT__
12022764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian"
1203194d53e6SMatthew G. Knepley /*@C
1204194d53e6SMatthew G. Knepley   PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields
1205194d53e6SMatthew G. Knepley 
1206194d53e6SMatthew G. Knepley   Not collective
1207194d53e6SMatthew G. Knepley 
1208194d53e6SMatthew G. Knepley   Input Parameters:
1209194d53e6SMatthew G. Knepley + prob - The PetscDS
1210194d53e6SMatthew G. Knepley . f    - The test field number
1211194d53e6SMatthew G. Knepley . g    - The field number
1212194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
1213194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1214194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1215194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1216194d53e6SMatthew G. Knepley 
1217194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1218194d53e6SMatthew G. Knepley 
1219194d53e6SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1220194d53e6SMatthew G. Knepley 
1221194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1222194d53e6SMatthew G. Knepley 
122330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1224194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1225194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
122630b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar g0[])
1227194d53e6SMatthew G. Knepley 
1228194d53e6SMatthew G. Knepley + dim - the spatial dimension
1229194d53e6SMatthew G. Knepley . Nf - the number of fields
1230194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1231194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1232194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1233194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1234194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1235194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1236194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1237194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1238194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1239194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1240194d53e6SMatthew G. Knepley . t - current time
12412aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1242194d53e6SMatthew G. Knepley . x - coordinates of the current point
1243194d53e6SMatthew G. Knepley - g0 - output values at the current point
1244194d53e6SMatthew G. Knepley 
1245194d53e6SMatthew G. Knepley   Level: intermediate
1246194d53e6SMatthew G. Knepley 
1247194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian()
1248194d53e6SMatthew G. Knepley @*/
12492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g,
125030b9ff8bSMatthew G. Knepley                                   void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1251194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1252194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
125330b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
125430b9ff8bSMatthew G. Knepley                                   void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1255194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1256194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
125730b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
125830b9ff8bSMatthew G. Knepley                                   void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1259194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1260194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
126130b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
126230b9ff8bSMatthew G. Knepley                                   void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1263194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1264194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
126530b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
12662764a2aaSMatthew G. Knepley {
12672764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
12682764a2aaSMatthew G. Knepley 
12692764a2aaSMatthew G. Knepley   PetscFunctionBegin;
12702764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
12712764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
12722764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
12732764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
12742764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
12752764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
12762764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
12772764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
12782764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+0] = g0;
12792764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+1] = g1;
12802764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+2] = g2;
12812764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+3] = g3;
12822764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
12832764a2aaSMatthew G. Knepley }
12842764a2aaSMatthew G. Knepley 
12852764a2aaSMatthew G. Knepley #undef __FUNCT__
1286475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobianPreconditioner"
1287475e0ac9SMatthew G. Knepley /*@C
1288475e0ac9SMatthew G. Knepley   PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set
1289475e0ac9SMatthew G. Knepley 
1290475e0ac9SMatthew G. Knepley   Not collective
1291475e0ac9SMatthew G. Knepley 
1292475e0ac9SMatthew G. Knepley   Input Parameter:
1293475e0ac9SMatthew G. Knepley . prob - The PetscDS
1294475e0ac9SMatthew G. Knepley 
1295475e0ac9SMatthew G. Knepley   Output Parameter:
1296475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set
1297475e0ac9SMatthew G. Knepley 
1298475e0ac9SMatthew G. Knepley   Level: intermediate
1299475e0ac9SMatthew G. Knepley 
1300475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian()
1301475e0ac9SMatthew G. Knepley @*/
1302475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre)
1303475e0ac9SMatthew G. Knepley {
1304475e0ac9SMatthew G. Knepley   PetscInt f, g, h;
1305475e0ac9SMatthew G. Knepley 
1306475e0ac9SMatthew G. Knepley   PetscFunctionBegin;
1307475e0ac9SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1308475e0ac9SMatthew G. Knepley   *hasJacPre = PETSC_FALSE;
1309475e0ac9SMatthew G. Knepley   for (f = 0; f < prob->Nf; ++f) {
1310475e0ac9SMatthew G. Knepley     for (g = 0; g < prob->Nf; ++g) {
1311475e0ac9SMatthew G. Knepley       for (h = 0; h < 4; ++h) {
1312475e0ac9SMatthew G. Knepley         if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE;
1313475e0ac9SMatthew G. Knepley       }
1314475e0ac9SMatthew G. Knepley     }
1315475e0ac9SMatthew G. Knepley   }
1316475e0ac9SMatthew G. Knepley   PetscFunctionReturn(0);
1317475e0ac9SMatthew G. Knepley }
1318475e0ac9SMatthew G. Knepley 
1319475e0ac9SMatthew G. Knepley #undef __FUNCT__
1320475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobianPreconditioner"
1321475e0ac9SMatthew G. Knepley /*@C
1322475e0ac9SMatthew G. Knepley   PetscDSGetJacobianPreconditioner - Get the pointwise Jacobian preconditioner function for given test and basis field. If this is missing, the system matrix is used to build the preconditioner.
1323475e0ac9SMatthew G. Knepley 
1324475e0ac9SMatthew G. Knepley   Not collective
1325475e0ac9SMatthew G. Knepley 
1326475e0ac9SMatthew G. Knepley   Input Parameters:
1327475e0ac9SMatthew G. Knepley + prob - The PetscDS
1328475e0ac9SMatthew G. Knepley . f    - The test field number
1329475e0ac9SMatthew G. Knepley - g    - The field number
1330475e0ac9SMatthew G. Knepley 
1331475e0ac9SMatthew G. Knepley   Output Parameters:
1332475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term
1333475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1334475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1335475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1336475e0ac9SMatthew G. Knepley 
1337475e0ac9SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1338475e0ac9SMatthew G. Knepley 
1339475e0ac9SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1340475e0ac9SMatthew G. Knepley 
1341475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1342475e0ac9SMatthew G. Knepley 
1343475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1344475e0ac9SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1345475e0ac9SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1346475e0ac9SMatthew G. Knepley $    PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[])
1347475e0ac9SMatthew G. Knepley 
1348475e0ac9SMatthew G. Knepley + dim - the spatial dimension
1349475e0ac9SMatthew G. Knepley . Nf - the number of fields
1350475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1351475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1352475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point
1353475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1354475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1355475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1356475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1357475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1358475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1359475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1360475e0ac9SMatthew G. Knepley . t - current time
1361475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1362475e0ac9SMatthew G. Knepley . x - coordinates of the current point
1363475e0ac9SMatthew G. Knepley - g0 - output values at the current point
1364475e0ac9SMatthew G. Knepley 
1365475e0ac9SMatthew G. Knepley   Level: intermediate
1366475e0ac9SMatthew G. Knepley 
1367475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian()
1368475e0ac9SMatthew G. Knepley @*/
1369475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g,
1370475e0ac9SMatthew G. Knepley                                   void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1371475e0ac9SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1372475e0ac9SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1373475e0ac9SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
1374475e0ac9SMatthew G. Knepley                                   void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1375475e0ac9SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1376475e0ac9SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1377475e0ac9SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
1378475e0ac9SMatthew G. Knepley                                   void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1379475e0ac9SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1380475e0ac9SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1381475e0ac9SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
1382475e0ac9SMatthew G. Knepley                                   void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1383475e0ac9SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1384475e0ac9SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1385475e0ac9SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
1386475e0ac9SMatthew G. Knepley {
1387475e0ac9SMatthew G. Knepley   PetscFunctionBegin;
1388475e0ac9SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1389475e0ac9SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
1390475e0ac9SMatthew G. Knepley   if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf);
1391475e0ac9SMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];}
1392475e0ac9SMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];}
1393475e0ac9SMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];}
1394475e0ac9SMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];}
1395475e0ac9SMatthew G. Knepley   PetscFunctionReturn(0);
1396475e0ac9SMatthew G. Knepley }
1397475e0ac9SMatthew G. Knepley 
1398475e0ac9SMatthew G. Knepley #undef __FUNCT__
1399475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobianPreconditioner"
1400475e0ac9SMatthew G. Knepley /*@C
1401475e0ac9SMatthew G. Knepley   PetscDSSetJacobianPreconditioner - Set the pointwise Jacobian preconditioner function for given test and basis fields. If this is missing, the system matrix is used to build the preconditioner.
1402475e0ac9SMatthew G. Knepley 
1403475e0ac9SMatthew G. Knepley   Not collective
1404475e0ac9SMatthew G. Knepley 
1405475e0ac9SMatthew G. Knepley   Input Parameters:
1406475e0ac9SMatthew G. Knepley + prob - The PetscDS
1407475e0ac9SMatthew G. Knepley . f    - The test field number
1408475e0ac9SMatthew G. Knepley . g    - The field number
1409475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term
1410475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1411475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1412475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1413475e0ac9SMatthew G. Knepley 
1414475e0ac9SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1415475e0ac9SMatthew G. Knepley 
1416475e0ac9SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1417475e0ac9SMatthew G. Knepley 
1418475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1419475e0ac9SMatthew G. Knepley 
1420475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1421475e0ac9SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1422475e0ac9SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1423475e0ac9SMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar g0[])
1424475e0ac9SMatthew G. Knepley 
1425475e0ac9SMatthew G. Knepley + dim - the spatial dimension
1426475e0ac9SMatthew G. Knepley . Nf - the number of fields
1427475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1428475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1429475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point
1430475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1431475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1432475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1433475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1434475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1435475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1436475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1437475e0ac9SMatthew G. Knepley . t - current time
1438475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1439475e0ac9SMatthew G. Knepley . x - coordinates of the current point
1440475e0ac9SMatthew G. Knepley - g0 - output values at the current point
1441475e0ac9SMatthew G. Knepley 
1442475e0ac9SMatthew G. Knepley   Level: intermediate
1443475e0ac9SMatthew G. Knepley 
1444475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian()
1445475e0ac9SMatthew G. Knepley @*/
1446475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g,
1447475e0ac9SMatthew G. Knepley                                   void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1448475e0ac9SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1449475e0ac9SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1450475e0ac9SMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
1451475e0ac9SMatthew G. Knepley                                   void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1452475e0ac9SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1453475e0ac9SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1454475e0ac9SMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
1455475e0ac9SMatthew G. Knepley                                   void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1456475e0ac9SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1457475e0ac9SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1458475e0ac9SMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
1459475e0ac9SMatthew G. Knepley                                   void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1460475e0ac9SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1461475e0ac9SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1462475e0ac9SMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
1463475e0ac9SMatthew G. Knepley {
1464475e0ac9SMatthew G. Knepley   PetscErrorCode ierr;
1465475e0ac9SMatthew G. Knepley 
1466475e0ac9SMatthew G. Knepley   PetscFunctionBegin;
1467475e0ac9SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1468475e0ac9SMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
1469475e0ac9SMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
1470475e0ac9SMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
1471475e0ac9SMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
1472475e0ac9SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
1473475e0ac9SMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
1474475e0ac9SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
1475475e0ac9SMatthew G. Knepley   prob->gp[(f*prob->Nf + g)*4+0] = g0;
1476475e0ac9SMatthew G. Knepley   prob->gp[(f*prob->Nf + g)*4+1] = g1;
1477475e0ac9SMatthew G. Knepley   prob->gp[(f*prob->Nf + g)*4+2] = g2;
1478475e0ac9SMatthew G. Knepley   prob->gp[(f*prob->Nf + g)*4+3] = g3;
1479475e0ac9SMatthew G. Knepley   PetscFunctionReturn(0);
1480475e0ac9SMatthew G. Knepley }
1481475e0ac9SMatthew G. Knepley 
1482475e0ac9SMatthew G. Knepley #undef __FUNCT__
1483b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSHasDynamicJacobian"
1484b7e05686SMatthew G. Knepley /*@C
1485b7e05686SMatthew G. Knepley   PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set
1486b7e05686SMatthew G. Knepley 
1487b7e05686SMatthew G. Knepley   Not collective
1488b7e05686SMatthew G. Knepley 
1489b7e05686SMatthew G. Knepley   Input Parameter:
1490b7e05686SMatthew G. Knepley . prob - The PetscDS
1491b7e05686SMatthew G. Knepley 
1492b7e05686SMatthew G. Knepley   Output Parameter:
1493b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set
1494b7e05686SMatthew G. Knepley 
1495b7e05686SMatthew G. Knepley   Level: intermediate
1496b7e05686SMatthew G. Knepley 
1497b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian()
1498b7e05686SMatthew G. Knepley @*/
1499b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac)
1500b7e05686SMatthew G. Knepley {
1501b7e05686SMatthew G. Knepley   PetscInt f, g, h;
1502b7e05686SMatthew G. Knepley 
1503b7e05686SMatthew G. Knepley   PetscFunctionBegin;
1504b7e05686SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1505b7e05686SMatthew G. Knepley   *hasDynJac = PETSC_FALSE;
1506b7e05686SMatthew G. Knepley   for (f = 0; f < prob->Nf; ++f) {
1507b7e05686SMatthew G. Knepley     for (g = 0; g < prob->Nf; ++g) {
1508b7e05686SMatthew G. Knepley       for (h = 0; h < 4; ++h) {
1509b7e05686SMatthew G. Knepley         if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE;
1510b7e05686SMatthew G. Knepley       }
1511b7e05686SMatthew G. Knepley     }
1512b7e05686SMatthew G. Knepley   }
1513b7e05686SMatthew G. Knepley   PetscFunctionReturn(0);
1514b7e05686SMatthew G. Knepley }
1515b7e05686SMatthew G. Knepley 
1516b7e05686SMatthew G. Knepley #undef __FUNCT__
1517b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSGetDynamicJacobian"
1518b7e05686SMatthew G. Knepley /*@C
1519b7e05686SMatthew G. Knepley   PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field
1520b7e05686SMatthew G. Knepley 
1521b7e05686SMatthew G. Knepley   Not collective
1522b7e05686SMatthew G. Knepley 
1523b7e05686SMatthew G. Knepley   Input Parameters:
1524b7e05686SMatthew G. Knepley + prob - The PetscDS
1525b7e05686SMatthew G. Knepley . f    - The test field number
1526b7e05686SMatthew G. Knepley - g    - The field number
1527b7e05686SMatthew G. Knepley 
1528b7e05686SMatthew G. Knepley   Output Parameters:
1529b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term
1530b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1531b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1532b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1533b7e05686SMatthew G. Knepley 
1534b7e05686SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1535b7e05686SMatthew G. Knepley 
1536b7e05686SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1537b7e05686SMatthew G. Knepley 
1538b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1539b7e05686SMatthew G. Knepley 
1540b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1541b7e05686SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1542b7e05686SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1543b7e05686SMatthew G. Knepley $    PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[])
1544b7e05686SMatthew G. Knepley 
1545b7e05686SMatthew G. Knepley + dim - the spatial dimension
1546b7e05686SMatthew G. Knepley . Nf - the number of fields
1547b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1548b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1549b7e05686SMatthew G. Knepley . u - each field evaluated at the current point
1550b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1551b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1552b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1553b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1554b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1555b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1556b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1557b7e05686SMatthew G. Knepley . t - current time
1558b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1559b7e05686SMatthew G. Knepley . x - coordinates of the current point
1560b7e05686SMatthew G. Knepley - g0 - output values at the current point
1561b7e05686SMatthew G. Knepley 
1562b7e05686SMatthew G. Knepley   Level: intermediate
1563b7e05686SMatthew G. Knepley 
1564b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian()
1565b7e05686SMatthew G. Knepley @*/
1566b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g,
1567b7e05686SMatthew G. Knepley                                          void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1568b7e05686SMatthew G. Knepley                                                      const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1569b7e05686SMatthew G. Knepley                                                      const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1570b7e05686SMatthew G. Knepley                                                      PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
1571b7e05686SMatthew G. Knepley                                          void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1572b7e05686SMatthew G. Knepley                                                      const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1573b7e05686SMatthew G. Knepley                                                      const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1574b7e05686SMatthew G. Knepley                                                      PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
1575b7e05686SMatthew G. Knepley                                          void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1576b7e05686SMatthew G. Knepley                                                      const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1577b7e05686SMatthew G. Knepley                                                      const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1578b7e05686SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
1579b7e05686SMatthew G. Knepley                                          void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1580b7e05686SMatthew G. Knepley                                                      const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1581b7e05686SMatthew G. Knepley                                                      const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1582b7e05686SMatthew G. Knepley                                                      PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
1583b7e05686SMatthew G. Knepley {
1584b7e05686SMatthew G. Knepley   PetscFunctionBegin;
1585b7e05686SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1586b7e05686SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
1587b7e05686SMatthew G. Knepley   if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf);
1588b7e05686SMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];}
1589b7e05686SMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];}
1590b7e05686SMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];}
1591b7e05686SMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];}
1592b7e05686SMatthew G. Knepley   PetscFunctionReturn(0);
1593b7e05686SMatthew G. Knepley }
1594b7e05686SMatthew G. Knepley 
1595b7e05686SMatthew G. Knepley #undef __FUNCT__
1596b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSSetDynamicJacobian"
1597b7e05686SMatthew G. Knepley /*@C
1598b7e05686SMatthew G. Knepley   PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields
1599b7e05686SMatthew G. Knepley 
1600b7e05686SMatthew G. Knepley   Not collective
1601b7e05686SMatthew G. Knepley 
1602b7e05686SMatthew G. Knepley   Input Parameters:
1603b7e05686SMatthew G. Knepley + prob - The PetscDS
1604b7e05686SMatthew G. Knepley . f    - The test field number
1605b7e05686SMatthew G. Knepley . g    - The field number
1606b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term
1607b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1608b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1609b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1610b7e05686SMatthew G. Knepley 
1611b7e05686SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1612b7e05686SMatthew G. Knepley 
1613b7e05686SMatthew G. Knepley   \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi
1614b7e05686SMatthew G. Knepley 
1615b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1616b7e05686SMatthew G. Knepley 
1617b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1618b7e05686SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1619b7e05686SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1620b7e05686SMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar g0[])
1621b7e05686SMatthew G. Knepley 
1622b7e05686SMatthew G. Knepley + dim - the spatial dimension
1623b7e05686SMatthew G. Knepley . Nf - the number of fields
1624b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1625b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1626b7e05686SMatthew G. Knepley . u - each field evaluated at the current point
1627b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1628b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1629b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1630b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1631b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1632b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1633b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1634b7e05686SMatthew G. Knepley . t - current time
1635b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1636b7e05686SMatthew G. Knepley . x - coordinates of the current point
1637b7e05686SMatthew G. Knepley - g0 - output values at the current point
1638b7e05686SMatthew G. Knepley 
1639b7e05686SMatthew G. Knepley   Level: intermediate
1640b7e05686SMatthew G. Knepley 
1641b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian()
1642b7e05686SMatthew G. Knepley @*/
1643b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g,
1644b7e05686SMatthew G. Knepley                                          void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1645b7e05686SMatthew G. Knepley                                                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1646b7e05686SMatthew G. Knepley                                                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1647b7e05686SMatthew G. Knepley                                                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
1648b7e05686SMatthew G. Knepley                                          void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1649b7e05686SMatthew G. Knepley                                                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1650b7e05686SMatthew G. Knepley                                                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1651b7e05686SMatthew G. Knepley                                                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
1652b7e05686SMatthew G. Knepley                                          void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1653b7e05686SMatthew G. Knepley                                                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1654b7e05686SMatthew G. Knepley                                                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1655b7e05686SMatthew G. Knepley                                                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
1656b7e05686SMatthew G. Knepley                                          void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1657b7e05686SMatthew G. Knepley                                                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1658b7e05686SMatthew G. Knepley                                                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1659b7e05686SMatthew G. Knepley                                                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
1660b7e05686SMatthew G. Knepley {
1661b7e05686SMatthew G. Knepley   PetscErrorCode ierr;
1662b7e05686SMatthew G. Knepley 
1663b7e05686SMatthew G. Knepley   PetscFunctionBegin;
1664b7e05686SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1665b7e05686SMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
1666b7e05686SMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
1667b7e05686SMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
1668b7e05686SMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
1669b7e05686SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
1670b7e05686SMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
1671b7e05686SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
1672b7e05686SMatthew G. Knepley   prob->gt[(f*prob->Nf + g)*4+0] = g0;
1673b7e05686SMatthew G. Knepley   prob->gt[(f*prob->Nf + g)*4+1] = g1;
1674b7e05686SMatthew G. Knepley   prob->gt[(f*prob->Nf + g)*4+2] = g2;
1675b7e05686SMatthew G. Knepley   prob->gt[(f*prob->Nf + g)*4+3] = g3;
1676b7e05686SMatthew G. Knepley   PetscFunctionReturn(0);
1677b7e05686SMatthew G. Knepley }
1678b7e05686SMatthew G. Knepley 
1679b7e05686SMatthew G. Knepley #undef __FUNCT__
16800c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver"
16810c2f2876SMatthew G. Knepley /*@C
16820c2f2876SMatthew G. Knepley   PetscDSGetRiemannSolver - Returns the Riemann solver for the given field
16830c2f2876SMatthew G. Knepley 
16840c2f2876SMatthew G. Knepley   Not collective
16850c2f2876SMatthew G. Knepley 
16860c2f2876SMatthew G. Knepley   Input Arguments:
16870c2f2876SMatthew G. Knepley + prob - The PetscDS object
16880c2f2876SMatthew G. Knepley - f    - The field number
16890c2f2876SMatthew G. Knepley 
16900c2f2876SMatthew G. Knepley   Output Argument:
16910c2f2876SMatthew G. Knepley . r    - Riemann solver
16920c2f2876SMatthew G. Knepley 
16930c2f2876SMatthew G. Knepley   Calling sequence for r:
16940c2f2876SMatthew G. Knepley 
16955db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
16960c2f2876SMatthew G. Knepley 
16975db36cf9SMatthew G. Knepley + dim  - The spatial dimension
16985db36cf9SMatthew G. Knepley . Nf   - The number of fields
16995db36cf9SMatthew G. Knepley . x    - The coordinates at a point on the interface
17000c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
17010c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
17020c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
17030c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
17040c2f2876SMatthew G. Knepley - ctx  - optional user context
17050c2f2876SMatthew G. Knepley 
17060c2f2876SMatthew G. Knepley   Level: intermediate
17070c2f2876SMatthew G. Knepley 
17080c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver()
17090c2f2876SMatthew G. Knepley @*/
17100c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f,
17115db36cf9SMatthew G. Knepley                                        void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
17120c2f2876SMatthew G. Knepley {
17130c2f2876SMatthew G. Knepley   PetscFunctionBegin;
17140c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17150c2f2876SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
17160c2f2876SMatthew G. Knepley   PetscValidPointer(r, 3);
17170c2f2876SMatthew G. Knepley   *r = prob->r[f];
17180c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
17190c2f2876SMatthew G. Knepley }
17200c2f2876SMatthew G. Knepley 
17210c2f2876SMatthew G. Knepley #undef __FUNCT__
17220c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver"
17230c2f2876SMatthew G. Knepley /*@C
17240c2f2876SMatthew G. Knepley   PetscDSSetRiemannSolver - Sets the Riemann solver for the given field
17250c2f2876SMatthew G. Knepley 
17260c2f2876SMatthew G. Knepley   Not collective
17270c2f2876SMatthew G. Knepley 
17280c2f2876SMatthew G. Knepley   Input Arguments:
17290c2f2876SMatthew G. Knepley + prob - The PetscDS object
17300c2f2876SMatthew G. Knepley . f    - The field number
17310c2f2876SMatthew G. Knepley - r    - Riemann solver
17320c2f2876SMatthew G. Knepley 
17330c2f2876SMatthew G. Knepley   Calling sequence for r:
17340c2f2876SMatthew G. Knepley 
17355db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
17360c2f2876SMatthew G. Knepley 
17375db36cf9SMatthew G. Knepley + dim  - The spatial dimension
17385db36cf9SMatthew G. Knepley . Nf   - The number of fields
17395db36cf9SMatthew G. Knepley . x    - The coordinates at a point on the interface
17400c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
17410c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
17420c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
17430c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
17440c2f2876SMatthew G. Knepley - ctx  - optional user context
17450c2f2876SMatthew G. Knepley 
17460c2f2876SMatthew G. Knepley   Level: intermediate
17470c2f2876SMatthew G. Knepley 
17480c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver()
17490c2f2876SMatthew G. Knepley @*/
17500c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f,
17515db36cf9SMatthew G. Knepley                                        void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
17520c2f2876SMatthew G. Knepley {
17530c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
17540c2f2876SMatthew G. Knepley 
17550c2f2876SMatthew G. Knepley   PetscFunctionBegin;
17560c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1757de716cbcSToby Isaac   if (r) PetscValidFunction(r, 3);
17580c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
17590c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
17600c2f2876SMatthew G. Knepley   prob->r[f] = r;
17610c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
17620c2f2876SMatthew G. Knepley }
17630c2f2876SMatthew G. Knepley 
17640c2f2876SMatthew G. Knepley #undef __FUNCT__
17650c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext"
17660c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx)
17670c2f2876SMatthew G. Knepley {
17680c2f2876SMatthew G. Knepley   PetscFunctionBegin;
17690c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17700c2f2876SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
17710c2f2876SMatthew G. Knepley   PetscValidPointer(ctx, 3);
17720c2f2876SMatthew G. Knepley   *ctx = prob->ctx[f];
17730c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
17740c2f2876SMatthew G. Knepley }
17750c2f2876SMatthew G. Knepley 
17760c2f2876SMatthew G. Knepley #undef __FUNCT__
17770c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext"
17780c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx)
17790c2f2876SMatthew G. Knepley {
17800c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
17810c2f2876SMatthew G. Knepley 
17820c2f2876SMatthew G. Knepley   PetscFunctionBegin;
17830c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17840c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
17850c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
17860c2f2876SMatthew G. Knepley   prob->ctx[f] = ctx;
17870c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
17880c2f2876SMatthew G. Knepley }
17890c2f2876SMatthew G. Knepley 
17900c2f2876SMatthew G. Knepley #undef __FUNCT__
17912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual"
1792194d53e6SMatthew G. Knepley /*@C
1793194d53e6SMatthew G. Knepley   PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field
1794194d53e6SMatthew G. Knepley 
1795194d53e6SMatthew G. Knepley   Not collective
1796194d53e6SMatthew G. Knepley 
1797194d53e6SMatthew G. Knepley   Input Parameters:
1798194d53e6SMatthew G. Knepley + prob - The PetscDS
1799194d53e6SMatthew G. Knepley - f    - The test field number
1800194d53e6SMatthew G. Knepley 
1801194d53e6SMatthew G. Knepley   Output Parameters:
1802194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term
1803194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1804194d53e6SMatthew G. Knepley 
1805194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1806194d53e6SMatthew G. Knepley 
1807194d53e6SMatthew G. Knepley   \int_\Gamma \phi {\vec f}_0(u, u_t, \nabla u, x, t) \cdot \hat n + \nabla\phi \cdot {\overleftrightarrow f}_1(u, u_t, \nabla u, x, t) \cdot \hat n
1808194d53e6SMatthew G. Knepley 
1809194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1810194d53e6SMatthew G. Knepley 
181130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1812194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1813194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
181430b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1815194d53e6SMatthew G. Knepley 
1816194d53e6SMatthew G. Knepley + dim - the spatial dimension
1817194d53e6SMatthew G. Knepley . Nf - the number of fields
1818194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1819194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1820194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1821194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1822194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1823194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1824194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1825194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1826194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1827194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1828194d53e6SMatthew G. Knepley . t - current time
1829194d53e6SMatthew G. Knepley . x - coordinates of the current point
1830194d53e6SMatthew G. Knepley . n - unit normal at the current point
1831194d53e6SMatthew G. Knepley - f0 - output values at the current point
1832194d53e6SMatthew G. Knepley 
1833194d53e6SMatthew G. Knepley   Level: intermediate
1834194d53e6SMatthew G. Knepley 
1835194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual()
1836194d53e6SMatthew G. Knepley @*/
18372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f,
183830b9ff8bSMatthew G. Knepley                                     void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1839194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1840194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
184130b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
184230b9ff8bSMatthew G. Knepley                                     void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1843194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1844194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
184530b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
18462764a2aaSMatthew G. Knepley {
18472764a2aaSMatthew G. Knepley   PetscFunctionBegin;
18482764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
18492764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
18502764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];}
18512764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];}
18522764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
18532764a2aaSMatthew G. Knepley }
18542764a2aaSMatthew G. Knepley 
18552764a2aaSMatthew G. Knepley #undef __FUNCT__
18562764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual"
1857194d53e6SMatthew G. Knepley /*@C
1858194d53e6SMatthew G. Knepley   PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field
1859194d53e6SMatthew G. Knepley 
1860194d53e6SMatthew G. Knepley   Not collective
1861194d53e6SMatthew G. Knepley 
1862194d53e6SMatthew G. Knepley   Input Parameters:
1863194d53e6SMatthew G. Knepley + prob - The PetscDS
1864194d53e6SMatthew G. Knepley . f    - The test field number
1865194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term
1866194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1867194d53e6SMatthew G. Knepley 
1868194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1869194d53e6SMatthew G. Knepley 
1870194d53e6SMatthew G. Knepley   \int_\Gamma \phi {\vec f}_0(u, u_t, \nabla u, x, t) \cdot \hat n + \nabla\phi \cdot {\overleftrightarrow f}_1(u, u_t, \nabla u, x, t) \cdot \hat n
1871194d53e6SMatthew G. Knepley 
1872194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1873194d53e6SMatthew G. Knepley 
187430b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1875194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1876194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
187730b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1878194d53e6SMatthew G. Knepley 
1879194d53e6SMatthew G. Knepley + dim - the spatial dimension
1880194d53e6SMatthew G. Knepley . Nf - the number of fields
1881194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1882194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1883194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1884194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1885194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1886194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1887194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1888194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1889194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1890194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1891194d53e6SMatthew G. Knepley . t - current time
1892194d53e6SMatthew G. Knepley . x - coordinates of the current point
1893194d53e6SMatthew G. Knepley . n - unit normal at the current point
1894194d53e6SMatthew G. Knepley - f0 - output values at the current point
1895194d53e6SMatthew G. Knepley 
1896194d53e6SMatthew G. Knepley   Level: intermediate
1897194d53e6SMatthew G. Knepley 
1898194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual()
1899194d53e6SMatthew G. Knepley @*/
19002764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f,
190130b9ff8bSMatthew G. Knepley                                     void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1902194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1903194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
190430b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
190530b9ff8bSMatthew G. Knepley                                     void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1906194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1907194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
190830b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
19092764a2aaSMatthew G. Knepley {
19102764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19112764a2aaSMatthew G. Knepley 
19122764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19132764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19142764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
19152764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
19162764a2aaSMatthew G. Knepley   if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;}
19172764a2aaSMatthew G. Knepley   if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;}
19182764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19192764a2aaSMatthew G. Knepley }
19202764a2aaSMatthew G. Knepley 
19212764a2aaSMatthew G. Knepley #undef __FUNCT__
19222764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian"
1923194d53e6SMatthew G. Knepley /*@C
1924194d53e6SMatthew G. Knepley   PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field
1925194d53e6SMatthew G. Knepley 
1926194d53e6SMatthew G. Knepley   Not collective
1927194d53e6SMatthew G. Knepley 
1928194d53e6SMatthew G. Knepley   Input Parameters:
1929194d53e6SMatthew G. Knepley + prob - The PetscDS
1930194d53e6SMatthew G. Knepley . f    - The test field number
1931194d53e6SMatthew G. Knepley - g    - The field number
1932194d53e6SMatthew G. Knepley 
1933194d53e6SMatthew G. Knepley   Output Parameters:
1934194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1935194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1936194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1937194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1938194d53e6SMatthew G. Knepley 
1939194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1940194d53e6SMatthew G. Knepley 
1941194d53e6SMatthew G. Knepley   \int_\Gamma \phi {\vec g}_0(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \cdot \hat n \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \hat n \cdot \nabla \psi
1942194d53e6SMatthew G. Knepley 
1943194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1944194d53e6SMatthew G. Knepley 
194530b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1946194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1947194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
194830b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
1949194d53e6SMatthew G. Knepley 
1950194d53e6SMatthew G. Knepley + dim - the spatial dimension
1951194d53e6SMatthew G. Knepley . Nf - the number of fields
1952194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1953194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1954194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1955194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1956194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1957194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1958194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1959194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1960194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1961194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1962194d53e6SMatthew G. Knepley . t - current time
19632aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1964194d53e6SMatthew G. Knepley . x - coordinates of the current point
1965194d53e6SMatthew G. Knepley . n - normal at the current point
1966194d53e6SMatthew G. Knepley - g0 - output values at the current point
1967194d53e6SMatthew G. Knepley 
1968194d53e6SMatthew G. Knepley   Level: intermediate
1969194d53e6SMatthew G. Knepley 
1970194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian()
1971194d53e6SMatthew G. Knepley @*/
19722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
197330b9ff8bSMatthew G. Knepley                                     void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1974194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1975194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
19762aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
197730b9ff8bSMatthew G. Knepley                                     void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1978194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1979194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
19802aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
198130b9ff8bSMatthew G. Knepley                                     void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1982194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1983194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
19842aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
198530b9ff8bSMatthew G. Knepley                                     void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1986194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1987194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
19882aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
19892764a2aaSMatthew G. Knepley {
19902764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19912764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19922764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
19932764a2aaSMatthew G. Knepley   if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf);
19942764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];}
19952764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];}
19962764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];}
19972764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];}
19982764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19992764a2aaSMatthew G. Knepley }
20002764a2aaSMatthew G. Knepley 
20012764a2aaSMatthew G. Knepley #undef __FUNCT__
20022764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian"
2003194d53e6SMatthew G. Knepley /*@C
2004194d53e6SMatthew G. Knepley   PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field
2005194d53e6SMatthew G. Knepley 
2006194d53e6SMatthew G. Knepley   Not collective
2007194d53e6SMatthew G. Knepley 
2008194d53e6SMatthew G. Knepley   Input Parameters:
2009194d53e6SMatthew G. Knepley + prob - The PetscDS
2010194d53e6SMatthew G. Knepley . f    - The test field number
2011194d53e6SMatthew G. Knepley . g    - The field number
2012194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
2013194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
2014194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
2015194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
2016194d53e6SMatthew G. Knepley 
2017194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
2018194d53e6SMatthew G. Knepley 
2019194d53e6SMatthew G. Knepley   \int_\Gamma \phi {\vec g}_0(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \cdot \hat n \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \hat n \cdot \nabla \psi
2020194d53e6SMatthew G. Knepley 
2021194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
2022194d53e6SMatthew G. Knepley 
202330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
2024194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
2025194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
202630b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
2027194d53e6SMatthew G. Knepley 
2028194d53e6SMatthew G. Knepley + dim - the spatial dimension
2029194d53e6SMatthew G. Knepley . Nf - the number of fields
2030194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
2031194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
2032194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
2033194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
2034194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
2035194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
2036194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
2037194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
2038194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
2039194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
2040194d53e6SMatthew G. Knepley . t - current time
20412aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
2042194d53e6SMatthew G. Knepley . x - coordinates of the current point
2043194d53e6SMatthew G. Knepley . n - normal at the current point
2044194d53e6SMatthew G. Knepley - g0 - output values at the current point
2045194d53e6SMatthew G. Knepley 
2046194d53e6SMatthew G. Knepley   Level: intermediate
2047194d53e6SMatthew G. Knepley 
2048194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian()
2049194d53e6SMatthew G. Knepley @*/
20502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
205130b9ff8bSMatthew G. Knepley                                     void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
2052194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
2053194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
20542aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
205530b9ff8bSMatthew G. Knepley                                     void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
2056194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
2057194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
20582aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
205930b9ff8bSMatthew G. Knepley                                     void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
2060194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
2061194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
20622aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
206330b9ff8bSMatthew G. Knepley                                     void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
2064194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
2065194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
20662aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
20672764a2aaSMatthew G. Knepley {
20682764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
20692764a2aaSMatthew G. Knepley 
20702764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20712764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
20722764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
20732764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
20742764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
20752764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
20762764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
20772764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
20782764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
20792764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+0] = g0;
20802764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+1] = g1;
20812764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+2] = g2;
20822764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+3] = g3;
20832764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20842764a2aaSMatthew G. Knepley }
20852764a2aaSMatthew G. Knepley 
20862764a2aaSMatthew G. Knepley #undef __FUNCT__
2087*4cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldIndex"
2088*4cd1e086SMatthew G. Knepley /*@
2089*4cd1e086SMatthew G. Knepley   PetscDSGetFieldIndex - Returns the index of the given field
2090*4cd1e086SMatthew G. Knepley 
2091*4cd1e086SMatthew G. Knepley   Not collective
2092*4cd1e086SMatthew G. Knepley 
2093*4cd1e086SMatthew G. Knepley   Input Parameters:
2094*4cd1e086SMatthew G. Knepley + prob - The PetscDS object
2095*4cd1e086SMatthew G. Knepley - disc - The discretization object
2096*4cd1e086SMatthew G. Knepley 
2097*4cd1e086SMatthew G. Knepley   Output Parameter:
2098*4cd1e086SMatthew G. Knepley . f - The field number
2099*4cd1e086SMatthew G. Knepley 
2100*4cd1e086SMatthew G. Knepley   Level: beginner
2101*4cd1e086SMatthew G. Knepley 
2102*4cd1e086SMatthew G. Knepley .seealso: PetscGetDiscretization(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2103*4cd1e086SMatthew G. Knepley @*/
2104*4cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f)
2105*4cd1e086SMatthew G. Knepley {
2106*4cd1e086SMatthew G. Knepley   PetscInt       g;
2107*4cd1e086SMatthew G. Knepley   PetscErrorCode ierr;
2108*4cd1e086SMatthew G. Knepley 
2109*4cd1e086SMatthew G. Knepley   PetscFunctionBegin;
2110*4cd1e086SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2111*4cd1e086SMatthew G. Knepley   PetscValidPointer(f, 3);
2112*4cd1e086SMatthew G. Knepley   *f = -1;
2113*4cd1e086SMatthew G. Knepley   for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;}
2114*4cd1e086SMatthew G. Knepley   if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS.");
2115*4cd1e086SMatthew G. Knepley   *f = g;
2116*4cd1e086SMatthew G. Knepley   PetscFunctionReturn(0);
2117*4cd1e086SMatthew G. Knepley }
2118*4cd1e086SMatthew G. Knepley 
2119*4cd1e086SMatthew G. Knepley #undef __FUNCT__
2120*4cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldSize"
2121*4cd1e086SMatthew G. Knepley /*@
2122*4cd1e086SMatthew G. Knepley   PetscDSGetFieldSize - Returns the size of the given field in the full space basis
2123*4cd1e086SMatthew G. Knepley 
2124*4cd1e086SMatthew G. Knepley   Not collective
2125*4cd1e086SMatthew G. Knepley 
2126*4cd1e086SMatthew G. Knepley   Input Parameters:
2127*4cd1e086SMatthew G. Knepley + prob - The PetscDS object
2128*4cd1e086SMatthew G. Knepley - f - The field number
2129*4cd1e086SMatthew G. Knepley 
2130*4cd1e086SMatthew G. Knepley   Output Parameter:
2131*4cd1e086SMatthew G. Knepley . size - The size
2132*4cd1e086SMatthew G. Knepley 
2133*4cd1e086SMatthew G. Knepley   Level: beginner
2134*4cd1e086SMatthew G. Knepley 
2135*4cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2136*4cd1e086SMatthew G. Knepley @*/
2137*4cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size)
2138*4cd1e086SMatthew G. Knepley {
2139*4cd1e086SMatthew G. Knepley   PetscClassId   id;
2140*4cd1e086SMatthew G. Knepley   PetscInt       Nb, Nc;
2141*4cd1e086SMatthew G. Knepley   PetscErrorCode ierr;
2142*4cd1e086SMatthew G. Knepley 
2143*4cd1e086SMatthew G. Knepley   PetscFunctionBegin;
2144*4cd1e086SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2145*4cd1e086SMatthew G. Knepley   PetscValidPointer(size, 3);
2146*4cd1e086SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
2147*4cd1e086SMatthew G. Knepley   *size = 0;
2148*4cd1e086SMatthew G. Knepley   ierr = PetscObjectGetClassId(prob->disc[f], &id);CHKERRQ(ierr);
2149*4cd1e086SMatthew G. Knepley   if (id == PETSCFE_CLASSID)      {
2150*4cd1e086SMatthew G. Knepley     PetscFE fe = (PetscFE) prob->disc[f];
2151*4cd1e086SMatthew G. Knepley 
2152*4cd1e086SMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
2153*4cd1e086SMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
2154*4cd1e086SMatthew G. Knepley   } else if (id == PETSCFV_CLASSID) {
2155*4cd1e086SMatthew G. Knepley     PetscFV fv = (PetscFV) prob->disc[f];
2156*4cd1e086SMatthew G. Knepley 
2157*4cd1e086SMatthew G. Knepley     Nb   = 1;
2158*4cd1e086SMatthew G. Knepley     ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr);
2159*4cd1e086SMatthew G. Knepley   } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
2160*4cd1e086SMatthew G. Knepley   *size = Nb*Nc;
2161*4cd1e086SMatthew G. Knepley   PetscFunctionReturn(0);
2162*4cd1e086SMatthew G. Knepley }
2163*4cd1e086SMatthew G. Knepley 
2164*4cd1e086SMatthew G. Knepley #undef __FUNCT__
21652764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset"
2166bc4ae4beSMatthew G. Knepley /*@
2167bc4ae4beSMatthew G. Knepley   PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis
2168bc4ae4beSMatthew G. Knepley 
2169bc4ae4beSMatthew G. Knepley   Not collective
2170bc4ae4beSMatthew G. Knepley 
2171bc4ae4beSMatthew G. Knepley   Input Parameters:
2172bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
2173bc4ae4beSMatthew G. Knepley - f - The field number
2174bc4ae4beSMatthew G. Knepley 
2175bc4ae4beSMatthew G. Knepley   Output Parameter:
2176bc4ae4beSMatthew G. Knepley . off - The offset
2177bc4ae4beSMatthew G. Knepley 
2178bc4ae4beSMatthew G. Knepley   Level: beginner
2179bc4ae4beSMatthew G. Knepley 
2180*4cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2181bc4ae4beSMatthew G. Knepley @*/
21822764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
21832764a2aaSMatthew G. Knepley {
2184*4cd1e086SMatthew G. Knepley   PetscInt       size, g;
21852764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
21862764a2aaSMatthew G. Knepley 
21872764a2aaSMatthew G. Knepley   PetscFunctionBegin;
21882764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
21892764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
21902764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
21912764a2aaSMatthew G. Knepley   *off = 0;
21922764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
2193*4cd1e086SMatthew G. Knepley     ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr);
2194*4cd1e086SMatthew G. Knepley     *off += size;
21952764a2aaSMatthew G. Knepley   }
21962764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
21972764a2aaSMatthew G. Knepley }
21982764a2aaSMatthew G. Knepley 
21992764a2aaSMatthew G. Knepley #undef __FUNCT__
22002764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset"
2201bc4ae4beSMatthew G. Knepley /*@
2202c3ac4435SMatthew G. Knepley   PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis
2203bc4ae4beSMatthew G. Knepley 
2204bc4ae4beSMatthew G. Knepley   Not collective
2205bc4ae4beSMatthew G. Knepley 
2206bc4ae4beSMatthew G. Knepley   Input Parameters:
2207bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
2208bc4ae4beSMatthew G. Knepley - f - The field number
2209bc4ae4beSMatthew G. Knepley 
2210bc4ae4beSMatthew G. Knepley   Output Parameter:
2211bc4ae4beSMatthew G. Knepley . off - The boundary offset
2212bc4ae4beSMatthew G. Knepley 
2213bc4ae4beSMatthew G. Knepley   Level: beginner
2214bc4ae4beSMatthew G. Knepley 
2215bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2216bc4ae4beSMatthew G. Knepley @*/
22172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
22182764a2aaSMatthew G. Knepley {
22192764a2aaSMatthew G. Knepley   PetscInt       g;
22202764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
22212764a2aaSMatthew G. Knepley 
22222764a2aaSMatthew G. Knepley   PetscFunctionBegin;
22232764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
22242764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
22252764a2aaSMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
22262764a2aaSMatthew G. Knepley   *off = 0;
22272764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
22282764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->discBd[g];
22292764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
22302764a2aaSMatthew G. Knepley 
22312764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
22322764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
22332764a2aaSMatthew G. Knepley     *off += Nb*Nc;
22346ce16762SMatthew G. Knepley   }
22356ce16762SMatthew G. Knepley   PetscFunctionReturn(0);
22366ce16762SMatthew G. Knepley }
22376ce16762SMatthew G. Knepley 
22386ce16762SMatthew G. Knepley #undef __FUNCT__
22396ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset"
22406ce16762SMatthew G. Knepley /*@
22416ce16762SMatthew G. Knepley   PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point
22426ce16762SMatthew G. Knepley 
22436ce16762SMatthew G. Knepley   Not collective
22446ce16762SMatthew G. Knepley 
22456ce16762SMatthew G. Knepley   Input Parameters:
22466ce16762SMatthew G. Knepley + prob - The PetscDS object
22476ce16762SMatthew G. Knepley - f - The field number
22486ce16762SMatthew G. Knepley 
22496ce16762SMatthew G. Knepley   Output Parameter:
22506ce16762SMatthew G. Knepley . off - The offset
22516ce16762SMatthew G. Knepley 
22526ce16762SMatthew G. Knepley   Level: beginner
22536ce16762SMatthew G. Knepley 
22546ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
22556ce16762SMatthew G. Knepley @*/
22566ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off)
22576ce16762SMatthew G. Knepley {
22586ce16762SMatthew G. Knepley   PetscInt       g;
22596ce16762SMatthew G. Knepley   PetscErrorCode ierr;
22606ce16762SMatthew G. Knepley 
22616ce16762SMatthew G. Knepley   PetscFunctionBegin;
22626ce16762SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
22636ce16762SMatthew G. Knepley   PetscValidPointer(off, 3);
22646ce16762SMatthew G. Knepley   if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf);
22656ce16762SMatthew G. Knepley   *off = 0;
22666ce16762SMatthew G. Knepley   for (g = 0; g < f; ++g) {
22676ce16762SMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
22686ce16762SMatthew G. Knepley     PetscInt Nc;
22696ce16762SMatthew G. Knepley 
22706ce16762SMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
22716ce16762SMatthew G. Knepley     *off += Nc;
22722764a2aaSMatthew G. Knepley   }
22732764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
22742764a2aaSMatthew G. Knepley }
22752764a2aaSMatthew G. Knepley 
22762764a2aaSMatthew G. Knepley #undef __FUNCT__
2277194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets"
2278194d53e6SMatthew G. Knepley /*@
2279194d53e6SMatthew G. Knepley   PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point
2280194d53e6SMatthew G. Knepley 
2281194d53e6SMatthew G. Knepley   Not collective
2282194d53e6SMatthew G. Knepley 
2283194d53e6SMatthew G. Knepley   Input Parameter:
2284194d53e6SMatthew G. Knepley . prob - The PetscDS object
2285194d53e6SMatthew G. Knepley 
2286194d53e6SMatthew G. Knepley   Output Parameter:
2287194d53e6SMatthew G. Knepley . offsets - The offsets
2288194d53e6SMatthew G. Knepley 
2289194d53e6SMatthew G. Knepley   Level: beginner
2290194d53e6SMatthew G. Knepley 
2291194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2292194d53e6SMatthew G. Knepley @*/
2293194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[])
2294194d53e6SMatthew G. Knepley {
2295194d53e6SMatthew G. Knepley   PetscFunctionBegin;
2296194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2297194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
2298194d53e6SMatthew G. Knepley   *offsets = prob->off;
2299194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
2300194d53e6SMatthew G. Knepley }
2301194d53e6SMatthew G. Knepley 
2302194d53e6SMatthew G. Knepley #undef __FUNCT__
2303194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets"
2304194d53e6SMatthew G. Knepley /*@
2305194d53e6SMatthew G. Knepley   PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point
2306194d53e6SMatthew G. Knepley 
2307194d53e6SMatthew G. Knepley   Not collective
2308194d53e6SMatthew G. Knepley 
2309194d53e6SMatthew G. Knepley   Input Parameter:
2310194d53e6SMatthew G. Knepley . prob - The PetscDS object
2311194d53e6SMatthew G. Knepley 
2312194d53e6SMatthew G. Knepley   Output Parameter:
2313194d53e6SMatthew G. Knepley . offsets - The offsets
2314194d53e6SMatthew G. Knepley 
2315194d53e6SMatthew G. Knepley   Level: beginner
2316194d53e6SMatthew G. Knepley 
2317194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2318194d53e6SMatthew G. Knepley @*/
2319194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
2320194d53e6SMatthew G. Knepley {
2321194d53e6SMatthew G. Knepley   PetscFunctionBegin;
2322194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2323194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
2324194d53e6SMatthew G. Knepley   *offsets = prob->offDer;
2325194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
2326194d53e6SMatthew G. Knepley }
2327194d53e6SMatthew G. Knepley 
2328194d53e6SMatthew G. Knepley #undef __FUNCT__
2329194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets"
2330194d53e6SMatthew G. Knepley /*@
2331194d53e6SMatthew G. Knepley   PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point
2332194d53e6SMatthew G. Knepley 
2333194d53e6SMatthew G. Knepley   Not collective
2334194d53e6SMatthew G. Knepley 
2335194d53e6SMatthew G. Knepley   Input Parameter:
2336194d53e6SMatthew G. Knepley . prob - The PetscDS object
2337194d53e6SMatthew G. Knepley 
2338194d53e6SMatthew G. Knepley   Output Parameter:
2339194d53e6SMatthew G. Knepley . offsets - The offsets
2340194d53e6SMatthew G. Knepley 
2341194d53e6SMatthew G. Knepley   Level: beginner
2342194d53e6SMatthew G. Knepley 
2343194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2344194d53e6SMatthew G. Knepley @*/
2345194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[])
2346194d53e6SMatthew G. Knepley {
2347194d53e6SMatthew G. Knepley   PetscFunctionBegin;
2348194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2349194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
2350194d53e6SMatthew G. Knepley   *offsets = prob->offBd;
2351194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
2352194d53e6SMatthew G. Knepley }
2353194d53e6SMatthew G. Knepley 
2354194d53e6SMatthew G. Knepley #undef __FUNCT__
2355194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets"
2356194d53e6SMatthew G. Knepley /*@
2357194d53e6SMatthew G. Knepley   PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point
2358194d53e6SMatthew G. Knepley 
2359194d53e6SMatthew G. Knepley   Not collective
2360194d53e6SMatthew G. Knepley 
2361194d53e6SMatthew G. Knepley   Input Parameter:
2362194d53e6SMatthew G. Knepley . prob - The PetscDS object
2363194d53e6SMatthew G. Knepley 
2364194d53e6SMatthew G. Knepley   Output Parameter:
2365194d53e6SMatthew G. Knepley . offsets - The offsets
2366194d53e6SMatthew G. Knepley 
2367194d53e6SMatthew G. Knepley   Level: beginner
2368194d53e6SMatthew G. Knepley 
2369194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
2370194d53e6SMatthew G. Knepley @*/
2371194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
2372194d53e6SMatthew G. Knepley {
2373194d53e6SMatthew G. Knepley   PetscFunctionBegin;
2374194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2375194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
2376194d53e6SMatthew G. Knepley   *offsets = prob->offDerBd;
2377194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
2378194d53e6SMatthew G. Knepley }
2379194d53e6SMatthew G. Knepley 
2380194d53e6SMatthew G. Knepley #undef __FUNCT__
23812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation"
238268c9edb9SMatthew G. Knepley /*@C
238368c9edb9SMatthew G. Knepley   PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization
238468c9edb9SMatthew G. Knepley 
238568c9edb9SMatthew G. Knepley   Not collective
238668c9edb9SMatthew G. Knepley 
238768c9edb9SMatthew G. Knepley   Input Parameter:
238868c9edb9SMatthew G. Knepley . prob - The PetscDS object
238968c9edb9SMatthew G. Knepley 
239068c9edb9SMatthew G. Knepley   Output Parameters:
239168c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
239268c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
239368c9edb9SMatthew G. Knepley 
239468c9edb9SMatthew G. Knepley   Level: intermediate
239568c9edb9SMatthew G. Knepley 
239668c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate()
239768c9edb9SMatthew G. Knepley @*/
23982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
23992764a2aaSMatthew G. Knepley {
24002764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
24012764a2aaSMatthew G. Knepley 
24022764a2aaSMatthew G. Knepley   PetscFunctionBegin;
24032764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
24042764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
24052764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basis;}
24062764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;}
24072764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
24082764a2aaSMatthew G. Knepley }
24092764a2aaSMatthew G. Knepley 
24102764a2aaSMatthew G. Knepley #undef __FUNCT__
24112764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation"
241268c9edb9SMatthew G. Knepley /*@C
241368c9edb9SMatthew G. Knepley   PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization
241468c9edb9SMatthew G. Knepley 
241568c9edb9SMatthew G. Knepley   Not collective
241668c9edb9SMatthew G. Knepley 
241768c9edb9SMatthew G. Knepley   Input Parameter:
241868c9edb9SMatthew G. Knepley . prob - The PetscDS object
241968c9edb9SMatthew G. Knepley 
242068c9edb9SMatthew G. Knepley   Output Parameters:
242168c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
242268c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
242368c9edb9SMatthew G. Knepley 
242468c9edb9SMatthew G. Knepley   Level: intermediate
242568c9edb9SMatthew G. Knepley 
242668c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate()
242768c9edb9SMatthew G. Knepley @*/
24282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
24292764a2aaSMatthew G. Knepley {
24302764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
24312764a2aaSMatthew G. Knepley 
24322764a2aaSMatthew G. Knepley   PetscFunctionBegin;
24332764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
24342764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
24352764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basisBd;}
24362764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;}
24372764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
24382764a2aaSMatthew G. Knepley }
24392764a2aaSMatthew G. Knepley 
24402764a2aaSMatthew G. Knepley #undef __FUNCT__
24412764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays"
24422764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x)
24432764a2aaSMatthew G. Knepley {
24442764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
24452764a2aaSMatthew G. Knepley 
24462764a2aaSMatthew G. Knepley   PetscFunctionBegin;
24472764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
24482764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
24492764a2aaSMatthew G. Knepley   if (u)   {PetscValidPointer(u, 2);   *u   = prob->u;}
24502764a2aaSMatthew G. Knepley   if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;}
24512764a2aaSMatthew G. Knepley   if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;}
24522764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
24532764a2aaSMatthew G. Knepley }
24542764a2aaSMatthew G. Knepley 
24552764a2aaSMatthew G. Knepley #undef __FUNCT__
24562764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays"
24572764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3)
24582764a2aaSMatthew G. Knepley {
24592764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
24602764a2aaSMatthew G. Knepley 
24612764a2aaSMatthew G. Knepley   PetscFunctionBegin;
24622764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
24632764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
24642764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;}
24652764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;}
24662764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;}
24672764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;}
24682764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;}
24692764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;}
24702764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
24712764a2aaSMatthew G. Knepley }
24722764a2aaSMatthew G. Knepley 
24732764a2aaSMatthew G. Knepley #undef __FUNCT__
24742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays"
24752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer)
24762764a2aaSMatthew G. Knepley {
24772764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
24782764a2aaSMatthew G. Knepley 
24792764a2aaSMatthew G. Knepley   PetscFunctionBegin;
24802764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
24812764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
24822764a2aaSMatthew G. Knepley   if (x)           {PetscValidPointer(x, 2);           *x           = prob->x;}
24832764a2aaSMatthew G. Knepley   if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;}
24842764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
24852764a2aaSMatthew G. Knepley }
24862764a2aaSMatthew G. Knepley 
24872764a2aaSMatthew G. Knepley #undef __FUNCT__
2488da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations"
2489da51fcedSMatthew G. Knepley /*@
2490da51fcedSMatthew G. Knepley   PetscDSCopyEquations - Copy all pointwise function pointers to the new problem
2491da51fcedSMatthew G. Knepley 
2492da51fcedSMatthew G. Knepley   Not collective
2493da51fcedSMatthew G. Knepley 
2494da51fcedSMatthew G. Knepley   Input Parameter:
2495da51fcedSMatthew G. Knepley . prob - The PetscDS object
2496da51fcedSMatthew G. Knepley 
2497da51fcedSMatthew G. Knepley   Output Parameter:
2498da51fcedSMatthew G. Knepley . newprob - The PetscDS copy
2499da51fcedSMatthew G. Knepley 
2500da51fcedSMatthew G. Knepley   Level: intermediate
2501da51fcedSMatthew G. Knepley 
2502da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate()
2503da51fcedSMatthew G. Knepley @*/
2504da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob)
2505da51fcedSMatthew G. Knepley {
2506da51fcedSMatthew G. Knepley   PetscInt       Nf, Ng, f, g;
2507da51fcedSMatthew G. Knepley   PetscErrorCode ierr;
2508da51fcedSMatthew G. Knepley 
2509da51fcedSMatthew G. Knepley   PetscFunctionBegin;
2510da51fcedSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2511da51fcedSMatthew G. Knepley   PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2);
2512da51fcedSMatthew G. Knepley   ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr);
2513da51fcedSMatthew G. Knepley   ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr);
2514da51fcedSMatthew G. Knepley   if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr);
2515da51fcedSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
2516da51fcedSMatthew G. Knepley     PetscPointFunc   obj;
2517da51fcedSMatthew G. Knepley     PetscPointFunc   f0, f1;
2518da51fcedSMatthew G. Knepley     PetscPointJac    g0, g1, g2, g3;
2519da51fcedSMatthew G. Knepley     PetscBdPointFunc f0Bd, f1Bd;
2520da51fcedSMatthew G. Knepley     PetscBdPointJac  g0Bd, g1Bd, g2Bd, g3Bd;
2521da51fcedSMatthew G. Knepley     PetscRiemannFunc r;
2522da51fcedSMatthew G. Knepley 
2523da51fcedSMatthew G. Knepley     ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr);
2524da51fcedSMatthew G. Knepley     ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr);
2525da51fcedSMatthew G. Knepley     ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr);
2526da51fcedSMatthew G. Knepley     ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr);
2527da51fcedSMatthew G. Knepley     ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr);
2528da51fcedSMatthew G. Knepley     ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr);
2529da51fcedSMatthew G. Knepley     ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr);
2530da51fcedSMatthew G. Knepley     ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr);
2531da51fcedSMatthew G. Knepley     for (g = 0; g < Nf; ++g) {
2532da51fcedSMatthew G. Knepley       ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr);
2533da51fcedSMatthew G. Knepley       ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr);
2534da51fcedSMatthew G. Knepley       ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr);
2535da51fcedSMatthew G. Knepley       ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr);
2536da51fcedSMatthew G. Knepley     }
2537da51fcedSMatthew G. Knepley   }
2538da51fcedSMatthew G. Knepley   PetscFunctionReturn(0);
2539da51fcedSMatthew G. Knepley }
2540da51fcedSMatthew G. Knepley 
2541da51fcedSMatthew G. Knepley #undef __FUNCT__
25422764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic"
2543bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob)
25442764a2aaSMatthew G. Knepley {
25452764a2aaSMatthew G. Knepley   PetscFunctionBegin;
25462764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
25472764a2aaSMatthew G. Knepley }
25482764a2aaSMatthew G. Knepley 
25492764a2aaSMatthew G. Knepley #undef __FUNCT__
25502764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic"
2551bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob)
25522764a2aaSMatthew G. Knepley {
25532764a2aaSMatthew G. Knepley   PetscFunctionBegin;
25542764a2aaSMatthew G. Knepley   prob->ops->setfromoptions = NULL;
25552764a2aaSMatthew G. Knepley   prob->ops->setup          = NULL;
25562764a2aaSMatthew G. Knepley   prob->ops->view           = NULL;
25572764a2aaSMatthew G. Knepley   prob->ops->destroy        = PetscDSDestroy_Basic;
25582764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
25592764a2aaSMatthew G. Knepley }
25602764a2aaSMatthew G. Knepley 
25612764a2aaSMatthew G. Knepley /*MC
25622764a2aaSMatthew G. Knepley   PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions
25632764a2aaSMatthew G. Knepley 
25642764a2aaSMatthew G. Knepley   Level: intermediate
25652764a2aaSMatthew G. Knepley 
25662764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType()
25672764a2aaSMatthew G. Knepley M*/
25682764a2aaSMatthew G. Knepley 
25692764a2aaSMatthew G. Knepley #undef __FUNCT__
25702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic"
25712764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob)
25722764a2aaSMatthew G. Knepley {
25732764a2aaSMatthew G. Knepley   PetscDS_Basic *b;
25742764a2aaSMatthew G. Knepley   PetscErrorCode      ierr;
25752764a2aaSMatthew G. Knepley 
25762764a2aaSMatthew G. Knepley   PetscFunctionBegin;
25772764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1);
25782764a2aaSMatthew G. Knepley   ierr       = PetscNewLog(prob, &b);CHKERRQ(ierr);
25792764a2aaSMatthew G. Knepley   prob->data = b;
25802764a2aaSMatthew G. Knepley 
25812764a2aaSMatthew G. Knepley   ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr);
25822764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
25832764a2aaSMatthew G. Knepley }
2584