xref: /petsc/src/dm/dt/interface/dtds.c (revision 194d53e678cd88648ac9f86ce37a031fc7391494)
12764a2aaSMatthew G. Knepley #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__ "PetscDSViewFromOptions"
2082764a2aaSMatthew G. Knepley /*
2092764a2aaSMatthew G. Knepley   PetscDSViewFromOptions - Processes command line options to determine if/how a PetscDS is to be viewed.
2102764a2aaSMatthew G. Knepley 
2112764a2aaSMatthew G. Knepley   Collective on PetscDS
2122764a2aaSMatthew G. Knepley 
2132764a2aaSMatthew G. Knepley   Input Parameters:
2142764a2aaSMatthew G. Knepley + prob   - the PetscDS
2152764a2aaSMatthew G. Knepley . prefix - prefix to use for viewing, or NULL to use prefix of 'rnd'
2162764a2aaSMatthew G. Knepley - optionname - option to activate viewing
2172764a2aaSMatthew G. Knepley 
2182764a2aaSMatthew G. Knepley   Level: intermediate
2192764a2aaSMatthew G. Knepley 
2202764a2aaSMatthew G. Knepley .keywords: PetscDS, view, options, database
2212764a2aaSMatthew G. Knepley .seealso: VecViewFromOptions(), MatViewFromOptions()
2222764a2aaSMatthew G. Knepley */
2232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSViewFromOptions(PetscDS prob, const char prefix[], const char optionname[])
2242764a2aaSMatthew G. Knepley {
2252764a2aaSMatthew G. Knepley   PetscViewer       viewer;
2262764a2aaSMatthew G. Knepley   PetscViewerFormat format;
2272764a2aaSMatthew G. Knepley   PetscBool         flg;
2282764a2aaSMatthew G. Knepley   PetscErrorCode    ierr;
2292764a2aaSMatthew G. Knepley 
2302764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2312764a2aaSMatthew G. Knepley   if (prefix) {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);}
2322764a2aaSMatthew G. Knepley   else        {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), ((PetscObject) prob)->prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);}
2332764a2aaSMatthew G. Knepley   if (flg) {
2342764a2aaSMatthew G. Knepley     ierr = PetscViewerPushFormat(viewer, format);CHKERRQ(ierr);
2352764a2aaSMatthew G. Knepley     ierr = PetscDSView(prob, viewer);CHKERRQ(ierr);
2362764a2aaSMatthew G. Knepley     ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr);
2372764a2aaSMatthew G. Knepley     ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
2382764a2aaSMatthew G. Knepley   }
2392764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2402764a2aaSMatthew G. Knepley }
2412764a2aaSMatthew G. Knepley 
2422764a2aaSMatthew G. Knepley #undef __FUNCT__
2432764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions"
2442764a2aaSMatthew G. Knepley /*@
2452764a2aaSMatthew G. Knepley   PetscDSSetFromOptions - sets parameters in a PetscDS from the options database
2462764a2aaSMatthew G. Knepley 
2472764a2aaSMatthew G. Knepley   Collective on PetscDS
2482764a2aaSMatthew G. Knepley 
2492764a2aaSMatthew G. Knepley   Input Parameter:
2502764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for
2512764a2aaSMatthew G. Knepley 
2522764a2aaSMatthew G. Knepley   Options Database:
2532764a2aaSMatthew G. Knepley 
2542764a2aaSMatthew G. Knepley   Level: developer
2552764a2aaSMatthew G. Knepley 
2562764a2aaSMatthew G. Knepley .seealso PetscDSView()
2572764a2aaSMatthew G. Knepley @*/
2582764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob)
2592764a2aaSMatthew G. Knepley {
2602764a2aaSMatthew G. Knepley   const char    *defaultType;
2612764a2aaSMatthew G. Knepley   char           name[256];
2622764a2aaSMatthew G. Knepley   PetscBool      flg;
2632764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2642764a2aaSMatthew G. Knepley 
2652764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2662764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2672764a2aaSMatthew G. Knepley   if (!((PetscObject) prob)->type_name) {
2682764a2aaSMatthew G. Knepley     defaultType = PETSCDSBASIC;
2692764a2aaSMatthew G. Knepley   } else {
2702764a2aaSMatthew G. Knepley     defaultType = ((PetscObject) prob)->type_name;
2712764a2aaSMatthew G. Knepley   }
2720f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
2732764a2aaSMatthew G. Knepley 
2742764a2aaSMatthew G. Knepley   ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr);
2752764a2aaSMatthew G. Knepley   ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr);
2762764a2aaSMatthew G. Knepley   if (flg) {
2772764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, name);CHKERRQ(ierr);
2782764a2aaSMatthew G. Knepley   } else if (!((PetscObject) prob)->type_name) {
2792764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr);
2802764a2aaSMatthew G. Knepley   }
2812764a2aaSMatthew G. Knepley   if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);}
2822764a2aaSMatthew G. Knepley   /* process any options handlers added with PetscObjectAddOptionsHandler() */
2832764a2aaSMatthew G. Knepley   ierr = PetscObjectProcessOptionsHandlers((PetscObject) prob);CHKERRQ(ierr);
2842764a2aaSMatthew G. Knepley   ierr = PetscOptionsEnd();CHKERRQ(ierr);
2852764a2aaSMatthew G. Knepley   ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);
2862764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2872764a2aaSMatthew G. Knepley }
2882764a2aaSMatthew G. Knepley 
2892764a2aaSMatthew G. Knepley #undef __FUNCT__
2902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp"
2912764a2aaSMatthew G. Knepley /*@C
2922764a2aaSMatthew G. Knepley   PetscDSSetUp - Construct data structures for the PetscDS
2932764a2aaSMatthew G. Knepley 
2942764a2aaSMatthew G. Knepley   Collective on PetscDS
2952764a2aaSMatthew G. Knepley 
2962764a2aaSMatthew G. Knepley   Input Parameter:
2972764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup
2982764a2aaSMatthew G. Knepley 
2992764a2aaSMatthew G. Knepley   Level: developer
3002764a2aaSMatthew G. Knepley 
3012764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy()
3022764a2aaSMatthew G. Knepley @*/
3032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob)
3042764a2aaSMatthew G. Knepley {
3052764a2aaSMatthew G. Knepley   const PetscInt Nf = prob->Nf;
3062764a2aaSMatthew G. Knepley   PetscInt       dim, work, NcMax = 0, NqMax = 0, f;
3072764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3082764a2aaSMatthew G. Knepley 
3092764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3102764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
3112764a2aaSMatthew G. Knepley   if (prob->setup) PetscFunctionReturn(0);
3122764a2aaSMatthew G. Knepley   /* Calculate sizes */
3132764a2aaSMatthew G. Knepley   ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr);
3142764a2aaSMatthew G. Knepley   prob->totDim = prob->totDimBd = prob->totComp = 0;
315*194d53e6SMatthew G. Knepley   ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr);
3162764a2aaSMatthew G. Knepley   ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr);
3172764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
3182764a2aaSMatthew G. Knepley     PetscFE         feBd = (PetscFE) prob->discBd[f];
3199de99aefSMatthew G. Knepley     PetscObject     obj;
3209de99aefSMatthew G. Knepley     PetscClassId    id;
3212764a2aaSMatthew G. Knepley     PetscQuadrature q;
3229de99aefSMatthew G. Knepley     PetscInt        Nq = 0, Nb, Nc;
3232764a2aaSMatthew G. Knepley 
3249de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr);
3259de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
3269de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {
3279de99aefSMatthew G. Knepley       PetscFE fe = (PetscFE) obj;
3289de99aefSMatthew G. Knepley 
3292764a2aaSMatthew G. Knepley       ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr);
3302764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
3312764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
3322764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
3339de99aefSMatthew G. Knepley     } else if (id == PETSCFV_CLASSID) {
3349de99aefSMatthew G. Knepley       PetscFV fv = (PetscFV) obj;
3359de99aefSMatthew G. Knepley 
3369de99aefSMatthew G. Knepley       ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr);
3379de99aefSMatthew G. Knepley       Nb   = 1;
3389de99aefSMatthew G. Knepley       ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr);
3396c1a3d01SMatthew G. Knepley       ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
340abac5ca0SMatthew G. Knepley     } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
341*194d53e6SMatthew G. Knepley     prob->off[f+1]    = Nc     + prob->off[f];
342*194d53e6SMatthew G. Knepley     prob->offDer[f+1] = Nc*dim + prob->offDer[f];
3439de99aefSMatthew G. Knepley     if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);}
3442764a2aaSMatthew G. Knepley     NqMax          = PetscMax(NqMax, Nq);
3452764a2aaSMatthew G. Knepley     NcMax          = PetscMax(NcMax, Nc);
3462764a2aaSMatthew G. Knepley     prob->totDim  += Nb*Nc;
3472764a2aaSMatthew G. Knepley     prob->totComp += Nc;
3482764a2aaSMatthew G. Knepley     if (feBd) {
3492764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr);
3502764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr);
3512764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr);
3522764a2aaSMatthew G. Knepley       prob->totDimBd += Nb*Nc;
353*194d53e6SMatthew G. Knepley       prob->offBd[f+1]    = Nc     + prob->offBd[f];
354*194d53e6SMatthew G. Knepley       prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f];
3552764a2aaSMatthew G. Knepley     }
3562764a2aaSMatthew G. Knepley   }
3572764a2aaSMatthew G. Knepley   work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim));
3582764a2aaSMatthew G. Knepley   /* Allocate works space */
3592764a2aaSMatthew 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);
3602764a2aaSMatthew 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);
3612764a2aaSMatthew G. Knepley   if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);}
3622764a2aaSMatthew G. Knepley   prob->setup = PETSC_TRUE;
3632764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3642764a2aaSMatthew G. Knepley }
3652764a2aaSMatthew G. Knepley 
3662764a2aaSMatthew G. Knepley #undef __FUNCT__
3672764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static"
3682764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob)
3692764a2aaSMatthew G. Knepley {
3702764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3712764a2aaSMatthew G. Knepley 
3722764a2aaSMatthew G. Knepley   PetscFunctionBegin;
373*194d53e6SMatthew G. Knepley   ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr);
3742764a2aaSMatthew G. Knepley   ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr);
3752764a2aaSMatthew G. Knepley   ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr);
3762764a2aaSMatthew G. Knepley   ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr);
3772764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3782764a2aaSMatthew G. Knepley }
3792764a2aaSMatthew G. Knepley 
3802764a2aaSMatthew G. Knepley #undef __FUNCT__
3812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static"
3822764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew)
3832764a2aaSMatthew G. Knepley {
3842764a2aaSMatthew G. Knepley   PetscObject      *tmpd, *tmpdbd;
385a6cbbb48SMatthew G. Knepley   PetscBool        *tmpi, *tmpa;
386*194d53e6SMatthew G. Knepley   PetscPointFunc   *tmpobj, *tmpf, *tmpg;
387*194d53e6SMatthew G. Knepley   PetscBdPointFunc *tmpfbd, *tmpgbd;
388*194d53e6SMatthew G. Knepley   PetscRiemannFunc *tmpr;
3890c2f2876SMatthew G. Knepley   void            **tmpctx;
390a6cbbb48SMatthew G. Knepley   PetscInt          Nf = prob->Nf, f, i;
3912764a2aaSMatthew G. Knepley   PetscErrorCode    ierr;
3922764a2aaSMatthew G. Knepley 
3932764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3942764a2aaSMatthew G. Knepley   if (Nf >= NfNew) PetscFunctionReturn(0);
3952764a2aaSMatthew G. Knepley   prob->setup = PETSC_FALSE;
3962764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr);
397a6cbbb48SMatthew G. Knepley   ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr);
398a6cbbb48SMatthew 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];}
399a6cbbb48SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr);
400a6cbbb48SMatthew G. Knepley     tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;}
401a6cbbb48SMatthew G. Knepley   ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr);
4022764a2aaSMatthew G. Knepley   prob->Nf        = NfNew;
4032764a2aaSMatthew G. Knepley   prob->disc      = tmpd;
404a6cbbb48SMatthew G. Knepley   prob->discBd    = tmpdbd;
405249df284SMatthew G. Knepley   prob->implicit  = tmpi;
406a6cbbb48SMatthew G. Knepley   prob->adjacency = tmpa;
4070c2f2876SMatthew G. Knepley   ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr);
4082764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f];
4092764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f];
4102764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f];
4110c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f];
4120c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f];
4132764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL;
4142764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL;
4152764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL;
4160c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL;
4170c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL;
4180c2f2876SMatthew G. Knepley   ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr);
4192764a2aaSMatthew G. Knepley   prob->obj = tmpobj;
4202764a2aaSMatthew G. Knepley   prob->f   = tmpf;
4212764a2aaSMatthew G. Knepley   prob->g   = tmpg;
4220c2f2876SMatthew G. Knepley   prob->r   = tmpr;
4230c2f2876SMatthew G. Knepley   prob->ctx = tmpctx;
4242764a2aaSMatthew G. Knepley   ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr);
4252764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f];
4262764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f];
4272764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL;
4282764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL;
4292764a2aaSMatthew G. Knepley   ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr);
4302764a2aaSMatthew G. Knepley   prob->fBd = tmpfbd;
4312764a2aaSMatthew G. Knepley   prob->gBd = tmpgbd;
4322764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4332764a2aaSMatthew G. Knepley }
4342764a2aaSMatthew G. Knepley 
4352764a2aaSMatthew G. Knepley #undef __FUNCT__
4362764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy"
4372764a2aaSMatthew G. Knepley /*@
4382764a2aaSMatthew G. Knepley   PetscDSDestroy - Destroys a PetscDS object
4392764a2aaSMatthew G. Knepley 
4402764a2aaSMatthew G. Knepley   Collective on PetscDS
4412764a2aaSMatthew G. Knepley 
4422764a2aaSMatthew G. Knepley   Input Parameter:
4432764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy
4442764a2aaSMatthew G. Knepley 
4452764a2aaSMatthew G. Knepley   Level: developer
4462764a2aaSMatthew G. Knepley 
4472764a2aaSMatthew G. Knepley .seealso PetscDSView()
4482764a2aaSMatthew G. Knepley @*/
4492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob)
4502764a2aaSMatthew G. Knepley {
4512764a2aaSMatthew G. Knepley   PetscInt       f;
4522764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4532764a2aaSMatthew G. Knepley 
4542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4552764a2aaSMatthew G. Knepley   if (!*prob) PetscFunctionReturn(0);
4562764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1);
4572764a2aaSMatthew G. Knepley 
4582764a2aaSMatthew G. Knepley   if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);}
4592764a2aaSMatthew G. Knepley   ((PetscObject) (*prob))->refct = 0;
4602764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr);
4612764a2aaSMatthew G. Knepley   for (f = 0; f < (*prob)->Nf; ++f) {
4622764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr);
4632764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr);
4642764a2aaSMatthew G. Knepley   }
465a6cbbb48SMatthew G. Knepley   ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr);
4660c2f2876SMatthew G. Knepley   ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr);
4672764a2aaSMatthew G. Knepley   ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr);
4682764a2aaSMatthew G. Knepley   if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);}
4692764a2aaSMatthew G. Knepley   ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr);
4702764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4712764a2aaSMatthew G. Knepley }
4722764a2aaSMatthew G. Knepley 
4732764a2aaSMatthew G. Knepley #undef __FUNCT__
4742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate"
4752764a2aaSMatthew G. Knepley /*@
4762764a2aaSMatthew G. Knepley   PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType().
4772764a2aaSMatthew G. Knepley 
4782764a2aaSMatthew G. Knepley   Collective on MPI_Comm
4792764a2aaSMatthew G. Knepley 
4802764a2aaSMatthew G. Knepley   Input Parameter:
4812764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object
4822764a2aaSMatthew G. Knepley 
4832764a2aaSMatthew G. Knepley   Output Parameter:
4842764a2aaSMatthew G. Knepley . prob - The PetscDS object
4852764a2aaSMatthew G. Knepley 
4862764a2aaSMatthew G. Knepley   Level: beginner
4872764a2aaSMatthew G. Knepley 
4882764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC
4892764a2aaSMatthew G. Knepley @*/
4902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob)
4912764a2aaSMatthew G. Knepley {
4922764a2aaSMatthew G. Knepley   PetscDS   p;
4932764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4942764a2aaSMatthew G. Knepley 
4952764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4962764a2aaSMatthew G. Knepley   PetscValidPointer(prob, 2);
4972764a2aaSMatthew G. Knepley   *prob  = NULL;
4982764a2aaSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
4992764a2aaSMatthew G. Knepley 
5002764a2aaSMatthew G. Knepley   ierr = PetscHeaderCreate(p, _p_PetscDS, struct _PetscDSOps, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr);
5012764a2aaSMatthew G. Knepley   ierr = PetscMemzero(p->ops, sizeof(struct _PetscDSOps));CHKERRQ(ierr);
5022764a2aaSMatthew G. Knepley 
5032764a2aaSMatthew G. Knepley   p->Nf    = 0;
5042764a2aaSMatthew G. Knepley   p->setup = PETSC_FALSE;
5052764a2aaSMatthew G. Knepley 
5062764a2aaSMatthew G. Knepley   *prob = p;
5072764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5082764a2aaSMatthew G. Knepley }
5092764a2aaSMatthew G. Knepley 
5102764a2aaSMatthew G. Knepley #undef __FUNCT__
5112764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields"
512bc4ae4beSMatthew G. Knepley /*@
513bc4ae4beSMatthew G. Knepley   PetscDSGetNumFields - Returns the number of fields in the DS
514bc4ae4beSMatthew G. Knepley 
515bc4ae4beSMatthew G. Knepley   Not collective
516bc4ae4beSMatthew G. Knepley 
517bc4ae4beSMatthew G. Knepley   Input Parameter:
518bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
519bc4ae4beSMatthew G. Knepley 
520bc4ae4beSMatthew G. Knepley   Output Parameter:
521bc4ae4beSMatthew G. Knepley . Nf - The number of fields
522bc4ae4beSMatthew G. Knepley 
523bc4ae4beSMatthew G. Knepley   Level: beginner
524bc4ae4beSMatthew G. Knepley 
525bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate()
526bc4ae4beSMatthew G. Knepley @*/
5272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf)
5282764a2aaSMatthew G. Knepley {
5292764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5302764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5312764a2aaSMatthew G. Knepley   PetscValidPointer(Nf, 2);
5322764a2aaSMatthew G. Knepley   *Nf = prob->Nf;
5332764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5342764a2aaSMatthew G. Knepley }
5352764a2aaSMatthew G. Knepley 
5362764a2aaSMatthew G. Knepley #undef __FUNCT__
5372764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension"
538bc4ae4beSMatthew G. Knepley /*@
539bc4ae4beSMatthew G. Knepley   PetscDSGetSpatialDimension - Returns the spatial dimension of the DS
540bc4ae4beSMatthew G. Knepley 
541bc4ae4beSMatthew G. Knepley   Not collective
542bc4ae4beSMatthew G. Knepley 
543bc4ae4beSMatthew G. Knepley   Input Parameter:
544bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
545bc4ae4beSMatthew G. Knepley 
546bc4ae4beSMatthew G. Knepley   Output Parameter:
547bc4ae4beSMatthew G. Knepley . dim - The spatial dimension
548bc4ae4beSMatthew G. Knepley 
549bc4ae4beSMatthew G. Knepley   Level: beginner
550bc4ae4beSMatthew G. Knepley 
551bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
552bc4ae4beSMatthew G. Knepley @*/
5532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim)
5542764a2aaSMatthew G. Knepley {
5552764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5562764a2aaSMatthew G. Knepley 
5572764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5582764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5592764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5602764a2aaSMatthew G. Knepley   *dim = 0;
5619de99aefSMatthew G. Knepley   if (prob->Nf) {
5629de99aefSMatthew G. Knepley     PetscObject  obj;
5639de99aefSMatthew G. Knepley     PetscClassId id;
5649de99aefSMatthew G. Knepley 
5659de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr);
5669de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
5679de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);}
5689de99aefSMatthew G. Knepley     else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);}
5699de99aefSMatthew G. Knepley     else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0);
5709de99aefSMatthew G. Knepley   }
5712764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5722764a2aaSMatthew G. Knepley }
5732764a2aaSMatthew G. Knepley 
5742764a2aaSMatthew G. Knepley #undef __FUNCT__
5752764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension"
576bc4ae4beSMatthew G. Knepley /*@
577bc4ae4beSMatthew G. Knepley   PetscDSGetTotalDimension - Returns the total size of the approximation space for this system
578bc4ae4beSMatthew G. Knepley 
579bc4ae4beSMatthew G. Knepley   Not collective
580bc4ae4beSMatthew G. Knepley 
581bc4ae4beSMatthew G. Knepley   Input Parameter:
582bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
583bc4ae4beSMatthew G. Knepley 
584bc4ae4beSMatthew G. Knepley   Output Parameter:
585bc4ae4beSMatthew G. Knepley . dim - The total problem dimension
586bc4ae4beSMatthew G. Knepley 
587bc4ae4beSMatthew G. Knepley   Level: beginner
588bc4ae4beSMatthew G. Knepley 
589bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
590bc4ae4beSMatthew G. Knepley @*/
5912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim)
5922764a2aaSMatthew G. Knepley {
5932764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5942764a2aaSMatthew G. Knepley 
5952764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5962764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5972764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
5982764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5992764a2aaSMatthew G. Knepley   *dim = prob->totDim;
6002764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6012764a2aaSMatthew G. Knepley }
6022764a2aaSMatthew G. Knepley 
6032764a2aaSMatthew G. Knepley #undef __FUNCT__
6042764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension"
605bc4ae4beSMatthew G. Knepley /*@
606c3ac4435SMatthew G. Knepley   PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system
607bc4ae4beSMatthew G. Knepley 
608bc4ae4beSMatthew G. Knepley   Not collective
609bc4ae4beSMatthew G. Knepley 
610bc4ae4beSMatthew G. Knepley   Input Parameter:
611bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
612bc4ae4beSMatthew G. Knepley 
613bc4ae4beSMatthew G. Knepley   Output Parameter:
614bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension
615bc4ae4beSMatthew G. Knepley 
616bc4ae4beSMatthew G. Knepley   Level: beginner
617bc4ae4beSMatthew G. Knepley 
618bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
619bc4ae4beSMatthew G. Knepley @*/
6202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim)
6212764a2aaSMatthew G. Knepley {
6222764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6232764a2aaSMatthew G. Knepley 
6242764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6252764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6262764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
6272764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
6282764a2aaSMatthew G. Knepley   *dim = prob->totDimBd;
6292764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6302764a2aaSMatthew G. Knepley }
6312764a2aaSMatthew G. Knepley 
6322764a2aaSMatthew G. Knepley #undef __FUNCT__
6332764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents"
634bc4ae4beSMatthew G. Knepley /*@
635bc4ae4beSMatthew G. Knepley   PetscDSGetTotalComponents - Returns the total number of components in this system
636bc4ae4beSMatthew G. Knepley 
637bc4ae4beSMatthew G. Knepley   Not collective
638bc4ae4beSMatthew G. Knepley 
639bc4ae4beSMatthew G. Knepley   Input Parameter:
640bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
641bc4ae4beSMatthew G. Knepley 
642bc4ae4beSMatthew G. Knepley   Output Parameter:
643bc4ae4beSMatthew G. Knepley . dim - The total number of components
644bc4ae4beSMatthew G. Knepley 
645bc4ae4beSMatthew G. Knepley   Level: beginner
646bc4ae4beSMatthew G. Knepley 
647bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
648bc4ae4beSMatthew G. Knepley @*/
6492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc)
6502764a2aaSMatthew G. Knepley {
6512764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6522764a2aaSMatthew G. Knepley 
6532764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6542764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6552764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
6562764a2aaSMatthew G. Knepley   PetscValidPointer(Nc, 2);
6572764a2aaSMatthew G. Knepley   *Nc = prob->totComp;
6582764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6592764a2aaSMatthew G. Knepley }
6602764a2aaSMatthew G. Knepley 
6612764a2aaSMatthew G. Knepley #undef __FUNCT__
6622764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization"
663bc4ae4beSMatthew G. Knepley /*@
664bc4ae4beSMatthew G. Knepley   PetscDSGetDiscretization - Returns the discretization object for the given field
665bc4ae4beSMatthew G. Knepley 
666bc4ae4beSMatthew G. Knepley   Not collective
667bc4ae4beSMatthew G. Knepley 
668bc4ae4beSMatthew G. Knepley   Input Parameters:
669bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
670bc4ae4beSMatthew G. Knepley - f - The field number
671bc4ae4beSMatthew G. Knepley 
672bc4ae4beSMatthew G. Knepley   Output Parameter:
673bc4ae4beSMatthew G. Knepley . disc - The discretization object
674bc4ae4beSMatthew G. Knepley 
675bc4ae4beSMatthew G. Knepley   Level: beginner
676bc4ae4beSMatthew G. Knepley 
677bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
678bc4ae4beSMatthew G. Knepley @*/
6792764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
6802764a2aaSMatthew G. Knepley {
6812764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6822764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6832764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
6842764a2aaSMatthew 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);
6852764a2aaSMatthew G. Knepley   *disc = prob->disc[f];
6862764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6872764a2aaSMatthew G. Knepley }
6882764a2aaSMatthew G. Knepley 
6892764a2aaSMatthew G. Knepley #undef __FUNCT__
6902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization"
691bc4ae4beSMatthew G. Knepley /*@
692bc4ae4beSMatthew G. Knepley   PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field
693bc4ae4beSMatthew G. Knepley 
694bc4ae4beSMatthew G. Knepley   Not collective
695bc4ae4beSMatthew G. Knepley 
696bc4ae4beSMatthew G. Knepley   Input Parameters:
697bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
698bc4ae4beSMatthew G. Knepley - f - The field number
699bc4ae4beSMatthew G. Knepley 
700bc4ae4beSMatthew G. Knepley   Output Parameter:
701bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object
702bc4ae4beSMatthew G. Knepley 
703bc4ae4beSMatthew G. Knepley   Level: beginner
704bc4ae4beSMatthew G. Knepley 
705bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
706bc4ae4beSMatthew G. Knepley @*/
7072764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
7082764a2aaSMatthew G. Knepley {
7092764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7102764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7112764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
7122764a2aaSMatthew 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);
7132764a2aaSMatthew G. Knepley   *disc = prob->discBd[f];
7142764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7152764a2aaSMatthew G. Knepley }
7162764a2aaSMatthew G. Knepley 
7172764a2aaSMatthew G. Knepley #undef __FUNCT__
7182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization"
719bc4ae4beSMatthew G. Knepley /*@
720bc4ae4beSMatthew G. Knepley   PetscDSSetDiscretization - Sets the discretization object for the given field
721bc4ae4beSMatthew G. Knepley 
722bc4ae4beSMatthew G. Knepley   Not collective
723bc4ae4beSMatthew G. Knepley 
724bc4ae4beSMatthew G. Knepley   Input Parameters:
725bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
726bc4ae4beSMatthew G. Knepley . f - The field number
727bc4ae4beSMatthew G. Knepley - disc - The discretization object
728bc4ae4beSMatthew G. Knepley 
729bc4ae4beSMatthew G. Knepley   Level: beginner
730bc4ae4beSMatthew G. Knepley 
731bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
732bc4ae4beSMatthew G. Knepley @*/
7332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
7342764a2aaSMatthew G. Knepley {
7352764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7362764a2aaSMatthew G. Knepley 
7372764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7382764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7392764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
7402764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7412764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7422764a2aaSMatthew G. Knepley   if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);}
7432764a2aaSMatthew G. Knepley   prob->disc[f] = disc;
7442764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
745249df284SMatthew G. Knepley   {
746249df284SMatthew G. Knepley     PetscClassId id;
747249df284SMatthew G. Knepley 
748249df284SMatthew G. Knepley     ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr);
749a6cbbb48SMatthew G. Knepley     if (id == PETSCFV_CLASSID) {
750a6cbbb48SMatthew G. Knepley       prob->implicit[f]      = PETSC_FALSE;
751a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+0] = PETSC_TRUE;
752a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+1] = PETSC_FALSE;
753a6cbbb48SMatthew G. Knepley     }
754249df284SMatthew G. Knepley   }
7552764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7562764a2aaSMatthew G. Knepley }
7572764a2aaSMatthew G. Knepley 
7582764a2aaSMatthew G. Knepley #undef __FUNCT__
7592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization"
760bc4ae4beSMatthew G. Knepley /*@
761bc4ae4beSMatthew G. Knepley   PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field
762bc4ae4beSMatthew G. Knepley 
763bc4ae4beSMatthew G. Knepley   Not collective
764bc4ae4beSMatthew G. Knepley 
765bc4ae4beSMatthew G. Knepley   Input Parameters:
766bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
767bc4ae4beSMatthew G. Knepley . f - The field number
768bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
769bc4ae4beSMatthew G. Knepley 
770bc4ae4beSMatthew G. Knepley   Level: beginner
771bc4ae4beSMatthew G. Knepley 
772bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
773bc4ae4beSMatthew G. Knepley @*/
7742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
7752764a2aaSMatthew G. Knepley {
7762764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7772764a2aaSMatthew G. Knepley 
7782764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7792764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7802764a2aaSMatthew G. Knepley   if (disc) PetscValidPointer(disc, 3);
7812764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7822764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7832764a2aaSMatthew G. Knepley   if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);}
7842764a2aaSMatthew G. Knepley   prob->discBd[f] = disc;
7852764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
7862764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7872764a2aaSMatthew G. Knepley }
7882764a2aaSMatthew G. Knepley 
7892764a2aaSMatthew G. Knepley #undef __FUNCT__
7902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization"
791bc4ae4beSMatthew G. Knepley /*@
792bc4ae4beSMatthew G. Knepley   PetscDSAddDiscretization - Adds a discretization object
793bc4ae4beSMatthew G. Knepley 
794bc4ae4beSMatthew G. Knepley   Not collective
795bc4ae4beSMatthew G. Knepley 
796bc4ae4beSMatthew G. Knepley   Input Parameters:
797bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
798bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
799bc4ae4beSMatthew G. Knepley 
800bc4ae4beSMatthew G. Knepley   Level: beginner
801bc4ae4beSMatthew G. Knepley 
802bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
803bc4ae4beSMatthew G. Knepley @*/
8042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc)
8052764a2aaSMatthew G. Knepley {
8062764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8072764a2aaSMatthew G. Knepley 
8082764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8092764a2aaSMatthew G. Knepley   ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
8102764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8112764a2aaSMatthew G. Knepley }
8122764a2aaSMatthew G. Knepley 
8132764a2aaSMatthew G. Knepley #undef __FUNCT__
8142764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization"
815bc4ae4beSMatthew G. Knepley /*@
816bc4ae4beSMatthew G. Knepley   PetscDSAddBdDiscretization - Adds a boundary discretization object
817bc4ae4beSMatthew G. Knepley 
818bc4ae4beSMatthew G. Knepley   Not collective
819bc4ae4beSMatthew G. Knepley 
820bc4ae4beSMatthew G. Knepley   Input Parameters:
821bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
822bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
823bc4ae4beSMatthew G. Knepley 
824bc4ae4beSMatthew G. Knepley   Level: beginner
825bc4ae4beSMatthew G. Knepley 
826bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
827bc4ae4beSMatthew G. Knepley @*/
8282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc)
8292764a2aaSMatthew G. Knepley {
8302764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8312764a2aaSMatthew G. Knepley 
8322764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8332764a2aaSMatthew G. Knepley   ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
8342764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8352764a2aaSMatthew G. Knepley }
8362764a2aaSMatthew G. Knepley 
8372764a2aaSMatthew G. Knepley #undef __FUNCT__
838249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit"
839249df284SMatthew G. Knepley /*@
840249df284SMatthew G. Knepley   PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX
841249df284SMatthew G. Knepley 
842249df284SMatthew G. Knepley   Not collective
843249df284SMatthew G. Knepley 
844249df284SMatthew G. Knepley   Input Parameters:
845249df284SMatthew G. Knepley + prob - The PetscDS object
846249df284SMatthew G. Knepley - f - The field number
847249df284SMatthew G. Knepley 
848249df284SMatthew G. Knepley   Output Parameter:
849249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field
850249df284SMatthew G. Knepley 
851249df284SMatthew G. Knepley   Level: developer
852249df284SMatthew G. Knepley 
853249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
854249df284SMatthew G. Knepley @*/
855249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit)
856249df284SMatthew G. Knepley {
857249df284SMatthew G. Knepley   PetscFunctionBegin;
858249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
859249df284SMatthew G. Knepley   PetscValidPointer(implicit, 3);
860249df284SMatthew 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);
861249df284SMatthew G. Knepley   *implicit = prob->implicit[f];
862249df284SMatthew G. Knepley   PetscFunctionReturn(0);
863249df284SMatthew G. Knepley }
864249df284SMatthew G. Knepley 
865249df284SMatthew G. Knepley #undef __FUNCT__
866249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit"
867249df284SMatthew G. Knepley /*@
868249df284SMatthew G. Knepley   PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX
869249df284SMatthew G. Knepley 
870249df284SMatthew G. Knepley   Not collective
871249df284SMatthew G. Knepley 
872249df284SMatthew G. Knepley   Input Parameters:
873249df284SMatthew G. Knepley + prob - The PetscDS object
874249df284SMatthew G. Knepley . f - The field number
875249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field
876249df284SMatthew G. Knepley 
877249df284SMatthew G. Knepley   Level: developer
878249df284SMatthew G. Knepley 
879249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
880249df284SMatthew G. Knepley @*/
881249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit)
882249df284SMatthew G. Knepley {
883249df284SMatthew G. Knepley   PetscFunctionBegin;
884249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
885249df284SMatthew 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);
886249df284SMatthew G. Knepley   prob->implicit[f] = implicit;
887249df284SMatthew G. Knepley   PetscFunctionReturn(0);
888249df284SMatthew G. Knepley }
889249df284SMatthew G. Knepley 
890249df284SMatthew G. Knepley #undef __FUNCT__
891a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency"
892a6cbbb48SMatthew G. Knepley /*@
893a6cbbb48SMatthew G. Knepley   PetscDSGetAdjacency - Returns the flags for determining variable influence
894a6cbbb48SMatthew G. Knepley 
895a6cbbb48SMatthew G. Knepley   Not collective
896a6cbbb48SMatthew G. Knepley 
897a6cbbb48SMatthew G. Knepley   Input Parameters:
898a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
899a6cbbb48SMatthew G. Knepley - f - The field number
900a6cbbb48SMatthew G. Knepley 
901a6cbbb48SMatthew G. Knepley   Output Parameter:
902a6cbbb48SMatthew G. Knepley + useCone    - Flag for variable influence starting with the cone operation
903a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
904a6cbbb48SMatthew G. Knepley 
905a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
906a6cbbb48SMatthew G. Knepley 
907a6cbbb48SMatthew G. Knepley   Level: developer
908a6cbbb48SMatthew G. Knepley 
909a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
910a6cbbb48SMatthew G. Knepley @*/
911a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure)
912a6cbbb48SMatthew G. Knepley {
913a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
914a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
915a6cbbb48SMatthew G. Knepley   PetscValidPointer(useCone, 3);
916a6cbbb48SMatthew G. Knepley   PetscValidPointer(useClosure, 4);
917a6cbbb48SMatthew 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);
918a6cbbb48SMatthew G. Knepley   *useCone    = prob->adjacency[f*2+0];
919a6cbbb48SMatthew G. Knepley   *useClosure = prob->adjacency[f*2+1];
920a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
921a6cbbb48SMatthew G. Knepley }
922a6cbbb48SMatthew G. Knepley 
923a6cbbb48SMatthew G. Knepley #undef __FUNCT__
924a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency"
925a6cbbb48SMatthew G. Knepley /*@
926a6cbbb48SMatthew G. Knepley   PetscDSSetAdjacency - Set the flags for determining variable influence
927a6cbbb48SMatthew G. Knepley 
928a6cbbb48SMatthew G. Knepley   Not collective
929a6cbbb48SMatthew G. Knepley 
930a6cbbb48SMatthew G. Knepley   Input Parameters:
931a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
932a6cbbb48SMatthew G. Knepley . f - The field number
933a6cbbb48SMatthew G. Knepley . useCone    - Flag for variable influence starting with the cone operation
934a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
935a6cbbb48SMatthew G. Knepley 
936a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
937a6cbbb48SMatthew G. Knepley 
938a6cbbb48SMatthew G. Knepley   Level: developer
939a6cbbb48SMatthew G. Knepley 
940a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
941a6cbbb48SMatthew G. Knepley @*/
942a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure)
943a6cbbb48SMatthew G. Knepley {
944a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
945a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
946a6cbbb48SMatthew 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);
947a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+0] = useCone;
948a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+1] = useClosure;
949a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
950a6cbbb48SMatthew G. Knepley }
951a6cbbb48SMatthew G. Knepley 
952a6cbbb48SMatthew G. Knepley #undef __FUNCT__
9532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective"
9542764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f,
955*194d53e6SMatthew G. Knepley                                    void (**obj)(PetscInt dim, PetscInt Nf,
956*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
957*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
958*194d53e6SMatthew G. Knepley                                                 const PetscReal t, const PetscReal x[], PetscScalar obj[]))
9592764a2aaSMatthew G. Knepley {
9602764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9612764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9622764a2aaSMatthew G. Knepley   PetscValidPointer(obj, 2);
9632764a2aaSMatthew 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);
9642764a2aaSMatthew G. Knepley   *obj = prob->obj[f];
9652764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9662764a2aaSMatthew G. Knepley }
9672764a2aaSMatthew G. Knepley 
9682764a2aaSMatthew G. Knepley #undef __FUNCT__
9692764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective"
9702764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f,
971*194d53e6SMatthew G. Knepley                                    void (*obj)(PetscInt dim, PetscInt Nf,
972*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
973*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
974*194d53e6SMatthew G. Knepley                                                const PetscReal t, const PetscReal x[], PetscScalar obj[]))
9752764a2aaSMatthew G. Knepley {
9762764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9772764a2aaSMatthew G. Knepley 
9782764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9792764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9802764a2aaSMatthew G. Knepley   PetscValidFunction(obj, 2);
9812764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
9822764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
9832764a2aaSMatthew G. Knepley   prob->obj[f] = obj;
9842764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9852764a2aaSMatthew G. Knepley }
9862764a2aaSMatthew G. Knepley 
9872764a2aaSMatthew G. Knepley #undef __FUNCT__
9882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual"
989*194d53e6SMatthew G. Knepley /*@C
990*194d53e6SMatthew G. Knepley   PetscDSGetResidual - Get the pointwise residual function for a given test field
991*194d53e6SMatthew G. Knepley 
992*194d53e6SMatthew G. Knepley   Not collective
993*194d53e6SMatthew G. Knepley 
994*194d53e6SMatthew G. Knepley   Input Parameters:
995*194d53e6SMatthew G. Knepley + prob - The PetscDS
996*194d53e6SMatthew G. Knepley - f    - The test field number
997*194d53e6SMatthew G. Knepley 
998*194d53e6SMatthew G. Knepley   Output Parameters:
999*194d53e6SMatthew G. Knepley + f0 - integrand for the test function term
1000*194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
1001*194d53e6SMatthew G. Knepley 
1002*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1003*194d53e6SMatthew G. Knepley 
1004*194d53e6SMatthew 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)
1005*194d53e6SMatthew G. Knepley 
1006*194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1007*194d53e6SMatthew G. Knepley 
1008*194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf,
1009*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1010*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1011*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], PetscScalar f0[])
1012*194d53e6SMatthew G. Knepley 
1013*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1014*194d53e6SMatthew G. Knepley . Nf - the number of fields
1015*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1016*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1017*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1018*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1019*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1020*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1021*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1022*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1023*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1024*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1025*194d53e6SMatthew G. Knepley . t - current time
1026*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1027*194d53e6SMatthew G. Knepley - f0 - output values at the current point
1028*194d53e6SMatthew G. Knepley 
1029*194d53e6SMatthew G. Knepley   Level: intermediate
1030*194d53e6SMatthew G. Knepley 
1031*194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual()
1032*194d53e6SMatthew G. Knepley @*/
10332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f,
1034*194d53e6SMatthew G. Knepley                                   void (**f0)(PetscInt dim, PetscInt Nf,
1035*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1036*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1037*194d53e6SMatthew G. Knepley                                               const PetscReal t, const PetscReal x[], PetscScalar f0[]),
1038*194d53e6SMatthew G. Knepley                                   void (**f1)(PetscInt dim, PetscInt Nf,
1039*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1040*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1041*194d53e6SMatthew G. Knepley                                               const PetscReal t, const PetscReal x[], PetscScalar f1[]))
10422764a2aaSMatthew G. Knepley {
10432764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10442764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
10452764a2aaSMatthew 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);
10462764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];}
10472764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];}
10482764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10492764a2aaSMatthew G. Knepley }
10502764a2aaSMatthew G. Knepley 
10512764a2aaSMatthew G. Knepley #undef __FUNCT__
10522764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual"
1053*194d53e6SMatthew G. Knepley /*@C
1054*194d53e6SMatthew G. Knepley   PetscDSSetResidual - Set the pointwise residual function for a given test field
1055*194d53e6SMatthew G. Knepley 
1056*194d53e6SMatthew G. Knepley   Not collective
1057*194d53e6SMatthew G. Knepley 
1058*194d53e6SMatthew G. Knepley   Input Parameters:
1059*194d53e6SMatthew G. Knepley + prob - The PetscDS
1060*194d53e6SMatthew G. Knepley . f    - The test field number
1061*194d53e6SMatthew G. Knepley . f0 - integrand for the test function term
1062*194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
1063*194d53e6SMatthew G. Knepley 
1064*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1065*194d53e6SMatthew G. Knepley 
1066*194d53e6SMatthew 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)
1067*194d53e6SMatthew G. Knepley 
1068*194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1069*194d53e6SMatthew G. Knepley 
1070*194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf,
1071*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1072*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1073*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], PetscScalar f0[])
1074*194d53e6SMatthew G. Knepley 
1075*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1076*194d53e6SMatthew G. Knepley . Nf - the number of fields
1077*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1078*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1079*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1080*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1081*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1082*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1083*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1084*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1085*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1086*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1087*194d53e6SMatthew G. Knepley . t - current time
1088*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1089*194d53e6SMatthew G. Knepley - f0 - output values at the current point
1090*194d53e6SMatthew G. Knepley 
1091*194d53e6SMatthew G. Knepley   Level: intermediate
1092*194d53e6SMatthew G. Knepley 
1093*194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual()
1094*194d53e6SMatthew G. Knepley @*/
10952764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f,
1096*194d53e6SMatthew G. Knepley                                   void (*f0)(PetscInt dim, PetscInt Nf,
1097*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1098*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1099*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar f0[]),
1100*194d53e6SMatthew G. Knepley                                   void (*f1)(PetscInt dim, PetscInt Nf,
1101*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1102*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1103*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar f1[]))
11042764a2aaSMatthew G. Knepley {
11052764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
11062764a2aaSMatthew G. Knepley 
11072764a2aaSMatthew G. Knepley   PetscFunctionBegin;
11082764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
11092764a2aaSMatthew G. Knepley   PetscValidFunction(f0, 3);
11102764a2aaSMatthew G. Knepley   PetscValidFunction(f1, 4);
11112764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
11122764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
11132764a2aaSMatthew G. Knepley   prob->f[f*2+0] = f0;
11142764a2aaSMatthew G. Knepley   prob->f[f*2+1] = f1;
11152764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
11162764a2aaSMatthew G. Knepley }
11172764a2aaSMatthew G. Knepley 
11182764a2aaSMatthew G. Knepley #undef __FUNCT__
11192764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian"
1120*194d53e6SMatthew G. Knepley /*@C
1121*194d53e6SMatthew G. Knepley   PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field
1122*194d53e6SMatthew G. Knepley 
1123*194d53e6SMatthew G. Knepley   Not collective
1124*194d53e6SMatthew G. Knepley 
1125*194d53e6SMatthew G. Knepley   Input Parameters:
1126*194d53e6SMatthew G. Knepley + prob - The PetscDS
1127*194d53e6SMatthew G. Knepley . f    - The test field number
1128*194d53e6SMatthew G. Knepley - g    - The field number
1129*194d53e6SMatthew G. Knepley 
1130*194d53e6SMatthew G. Knepley   Output Parameters:
1131*194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1132*194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1133*194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1134*194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1135*194d53e6SMatthew G. Knepley 
1136*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1137*194d53e6SMatthew G. Knepley 
1138*194d53e6SMatthew 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
1139*194d53e6SMatthew G. Knepley 
1140*194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1141*194d53e6SMatthew G. Knepley 
1142*194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf,
1143*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1144*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1145*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], PetscScalar g0[])
1146*194d53e6SMatthew G. Knepley 
1147*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1148*194d53e6SMatthew G. Knepley . Nf - the number of fields
1149*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1150*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1151*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1152*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1153*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1154*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1155*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1156*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1157*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1158*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1159*194d53e6SMatthew G. Knepley . t - current time
1160*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1161*194d53e6SMatthew G. Knepley - g0 - output values at the current point
1162*194d53e6SMatthew G. Knepley 
1163*194d53e6SMatthew G. Knepley   Level: intermediate
1164*194d53e6SMatthew G. Knepley 
1165*194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian()
1166*194d53e6SMatthew G. Knepley @*/
11672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g,
1168*194d53e6SMatthew G. Knepley                                   void (**g0)(PetscInt dim, PetscInt Nf,
1169*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1170*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1171*194d53e6SMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar g0[]),
1172*194d53e6SMatthew G. Knepley                                   void (**g1)(PetscInt dim, PetscInt Nf,
1173*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1174*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1175*194d53e6SMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar g1[]),
1176*194d53e6SMatthew G. Knepley                                   void (**g2)(PetscInt dim, PetscInt Nf,
1177*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1178*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1179*194d53e6SMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar g2[]),
1180*194d53e6SMatthew G. Knepley                                   void (**g3)(PetscInt dim, PetscInt Nf,
1181*194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1182*194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1183*194d53e6SMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar g3[]))
11842764a2aaSMatthew G. Knepley {
11852764a2aaSMatthew G. Knepley   PetscFunctionBegin;
11862764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
11872764a2aaSMatthew 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);
11882764a2aaSMatthew 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);
11892764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];}
11902764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];}
11912764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];}
11922764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];}
11932764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
11942764a2aaSMatthew G. Knepley }
11952764a2aaSMatthew G. Knepley 
11962764a2aaSMatthew G. Knepley #undef __FUNCT__
11972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian"
1198*194d53e6SMatthew G. Knepley /*@C
1199*194d53e6SMatthew G. Knepley   PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields
1200*194d53e6SMatthew G. Knepley 
1201*194d53e6SMatthew G. Knepley   Not collective
1202*194d53e6SMatthew G. Knepley 
1203*194d53e6SMatthew G. Knepley   Input Parameters:
1204*194d53e6SMatthew G. Knepley + prob - The PetscDS
1205*194d53e6SMatthew G. Knepley . f    - The test field number
1206*194d53e6SMatthew G. Knepley . g    - The field number
1207*194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
1208*194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1209*194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1210*194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1211*194d53e6SMatthew G. Knepley 
1212*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1213*194d53e6SMatthew G. Knepley 
1214*194d53e6SMatthew 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
1215*194d53e6SMatthew G. Knepley 
1216*194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1217*194d53e6SMatthew G. Knepley 
1218*194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf,
1219*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1220*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1221*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], PetscScalar g0[])
1222*194d53e6SMatthew G. Knepley 
1223*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1224*194d53e6SMatthew G. Knepley . Nf - the number of fields
1225*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1226*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1227*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1228*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1229*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1230*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1231*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1232*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1233*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1234*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1235*194d53e6SMatthew G. Knepley . t - current time
1236*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1237*194d53e6SMatthew G. Knepley - g0 - output values at the current point
1238*194d53e6SMatthew G. Knepley 
1239*194d53e6SMatthew G. Knepley   Level: intermediate
1240*194d53e6SMatthew G. Knepley 
1241*194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian()
1242*194d53e6SMatthew G. Knepley @*/
12432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g,
1244*194d53e6SMatthew G. Knepley                                   void (*g0)(PetscInt dim, PetscInt Nf,
1245*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1246*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1247*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar g0[]),
1248*194d53e6SMatthew G. Knepley                                   void (*g1)(PetscInt dim, PetscInt Nf,
1249*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1250*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1251*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar g1[]),
1252*194d53e6SMatthew G. Knepley                                   void (*g2)(PetscInt dim, PetscInt Nf,
1253*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1254*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1255*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar g2[]),
1256*194d53e6SMatthew G. Knepley                                   void (*g3)(PetscInt dim, PetscInt Nf,
1257*194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1258*194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1259*194d53e6SMatthew G. Knepley                                              const PetscReal t, const PetscReal x[], PetscScalar g3[]))
12602764a2aaSMatthew G. Knepley {
12612764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
12622764a2aaSMatthew G. Knepley 
12632764a2aaSMatthew G. Knepley   PetscFunctionBegin;
12642764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
12652764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
12662764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
12672764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
12682764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
12692764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
12702764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
12712764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
12722764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+0] = g0;
12732764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+1] = g1;
12742764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+2] = g2;
12752764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+3] = g3;
12762764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
12772764a2aaSMatthew G. Knepley }
12782764a2aaSMatthew G. Knepley 
12792764a2aaSMatthew G. Knepley #undef __FUNCT__
12800c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver"
12810c2f2876SMatthew G. Knepley /*@C
12820c2f2876SMatthew G. Knepley   PetscDSGetRiemannSolver - Returns the Riemann solver for the given field
12830c2f2876SMatthew G. Knepley 
12840c2f2876SMatthew G. Knepley   Not collective
12850c2f2876SMatthew G. Knepley 
12860c2f2876SMatthew G. Knepley   Input Arguments:
12870c2f2876SMatthew G. Knepley + prob - The PetscDS object
12880c2f2876SMatthew G. Knepley - f    - The field number
12890c2f2876SMatthew G. Knepley 
12900c2f2876SMatthew G. Knepley   Output Argument:
12910c2f2876SMatthew G. Knepley . r    - Riemann solver
12920c2f2876SMatthew G. Knepley 
12930c2f2876SMatthew G. Knepley   Calling sequence for r:
12940c2f2876SMatthew G. Knepley 
12950c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
12960c2f2876SMatthew G. Knepley 
12970c2f2876SMatthew G. Knepley + x    - The coordinates at a point on the interface
12980c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
12990c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
13000c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
13010c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
13020c2f2876SMatthew G. Knepley - ctx  - optional user context
13030c2f2876SMatthew G. Knepley 
13040c2f2876SMatthew G. Knepley   Level: intermediate
13050c2f2876SMatthew G. Knepley 
13060c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver()
13070c2f2876SMatthew G. Knepley @*/
13080c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f,
13090c2f2876SMatthew G. Knepley                                        void (**r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
13100c2f2876SMatthew G. Knepley {
13110c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13120c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13130c2f2876SMatthew 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);
13140c2f2876SMatthew G. Knepley   PetscValidPointer(r, 3);
13150c2f2876SMatthew G. Knepley   *r = prob->r[f];
13160c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13170c2f2876SMatthew G. Knepley }
13180c2f2876SMatthew G. Knepley 
13190c2f2876SMatthew G. Knepley #undef __FUNCT__
13200c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver"
13210c2f2876SMatthew G. Knepley /*@C
13220c2f2876SMatthew G. Knepley   PetscDSSetRiemannSolver - Sets the Riemann solver for the given field
13230c2f2876SMatthew G. Knepley 
13240c2f2876SMatthew G. Knepley   Not collective
13250c2f2876SMatthew G. Knepley 
13260c2f2876SMatthew G. Knepley   Input Arguments:
13270c2f2876SMatthew G. Knepley + prob - The PetscDS object
13280c2f2876SMatthew G. Knepley . f    - The field number
13290c2f2876SMatthew G. Knepley - r    - Riemann solver
13300c2f2876SMatthew G. Knepley 
13310c2f2876SMatthew G. Knepley   Calling sequence for r:
13320c2f2876SMatthew G. Knepley 
13330c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
13340c2f2876SMatthew G. Knepley 
13350c2f2876SMatthew G. Knepley + x    - The coordinates at a point on the interface
13360c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
13370c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
13380c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
13390c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
13400c2f2876SMatthew G. Knepley - ctx  - optional user context
13410c2f2876SMatthew G. Knepley 
13420c2f2876SMatthew G. Knepley   Level: intermediate
13430c2f2876SMatthew G. Knepley 
13440c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver()
13450c2f2876SMatthew G. Knepley @*/
13460c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f,
13470c2f2876SMatthew G. Knepley                                        void (*r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
13480c2f2876SMatthew G. Knepley {
13490c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
13500c2f2876SMatthew G. Knepley 
13510c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13520c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13530c2f2876SMatthew G. Knepley   PetscValidFunction(r, 3);
13540c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
13550c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
13560c2f2876SMatthew G. Knepley   prob->r[f] = r;
13570c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13580c2f2876SMatthew G. Knepley }
13590c2f2876SMatthew G. Knepley 
13600c2f2876SMatthew G. Knepley #undef __FUNCT__
13610c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext"
13620c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx)
13630c2f2876SMatthew G. Knepley {
13640c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13650c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13660c2f2876SMatthew 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);
13670c2f2876SMatthew G. Knepley   PetscValidPointer(ctx, 3);
13680c2f2876SMatthew G. Knepley   *ctx = prob->ctx[f];
13690c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13700c2f2876SMatthew G. Knepley }
13710c2f2876SMatthew G. Knepley 
13720c2f2876SMatthew G. Knepley #undef __FUNCT__
13730c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext"
13740c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx)
13750c2f2876SMatthew G. Knepley {
13760c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
13770c2f2876SMatthew G. Knepley 
13780c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13790c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13800c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
13810c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
13820c2f2876SMatthew G. Knepley   prob->ctx[f] = ctx;
13830c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13840c2f2876SMatthew G. Knepley }
13850c2f2876SMatthew G. Knepley 
13860c2f2876SMatthew G. Knepley #undef __FUNCT__
13872764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual"
1388*194d53e6SMatthew G. Knepley /*@C
1389*194d53e6SMatthew G. Knepley   PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field
1390*194d53e6SMatthew G. Knepley 
1391*194d53e6SMatthew G. Knepley   Not collective
1392*194d53e6SMatthew G. Knepley 
1393*194d53e6SMatthew G. Knepley   Input Parameters:
1394*194d53e6SMatthew G. Knepley + prob - The PetscDS
1395*194d53e6SMatthew G. Knepley - f    - The test field number
1396*194d53e6SMatthew G. Knepley 
1397*194d53e6SMatthew G. Knepley   Output Parameters:
1398*194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term
1399*194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1400*194d53e6SMatthew G. Knepley 
1401*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1402*194d53e6SMatthew G. Knepley 
1403*194d53e6SMatthew 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
1404*194d53e6SMatthew G. Knepley 
1405*194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1406*194d53e6SMatthew G. Knepley 
1407*194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf,
1408*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1409*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1410*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1411*194d53e6SMatthew G. Knepley 
1412*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1413*194d53e6SMatthew G. Knepley . Nf - the number of fields
1414*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1415*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1416*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1417*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1418*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1419*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1420*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1421*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1422*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1423*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1424*194d53e6SMatthew G. Knepley . t - current time
1425*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1426*194d53e6SMatthew G. Knepley . n - unit normal at the current point
1427*194d53e6SMatthew G. Knepley - f0 - output values at the current point
1428*194d53e6SMatthew G. Knepley 
1429*194d53e6SMatthew G. Knepley   Level: intermediate
1430*194d53e6SMatthew G. Knepley 
1431*194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual()
1432*194d53e6SMatthew G. Knepley @*/
14332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f,
1434*194d53e6SMatthew G. Knepley                                     void (**f0)(PetscInt dim, PetscInt Nf,
1435*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1436*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1437*194d53e6SMatthew G. Knepley                                                 const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
1438*194d53e6SMatthew G. Knepley                                     void (**f1)(PetscInt dim, PetscInt Nf,
1439*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1440*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1441*194d53e6SMatthew G. Knepley                                                 const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
14422764a2aaSMatthew G. Knepley {
14432764a2aaSMatthew G. Knepley   PetscFunctionBegin;
14442764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
14452764a2aaSMatthew 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);
14462764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];}
14472764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];}
14482764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
14492764a2aaSMatthew G. Knepley }
14502764a2aaSMatthew G. Knepley 
14512764a2aaSMatthew G. Knepley #undef __FUNCT__
14522764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual"
1453*194d53e6SMatthew G. Knepley /*@C
1454*194d53e6SMatthew G. Knepley   PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field
1455*194d53e6SMatthew G. Knepley 
1456*194d53e6SMatthew G. Knepley   Not collective
1457*194d53e6SMatthew G. Knepley 
1458*194d53e6SMatthew G. Knepley   Input Parameters:
1459*194d53e6SMatthew G. Knepley + prob - The PetscDS
1460*194d53e6SMatthew G. Knepley . f    - The test field number
1461*194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term
1462*194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1463*194d53e6SMatthew G. Knepley 
1464*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1465*194d53e6SMatthew G. Knepley 
1466*194d53e6SMatthew 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
1467*194d53e6SMatthew G. Knepley 
1468*194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1469*194d53e6SMatthew G. Knepley 
1470*194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf,
1471*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1472*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1473*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1474*194d53e6SMatthew G. Knepley 
1475*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1476*194d53e6SMatthew G. Knepley . Nf - the number of fields
1477*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1478*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1479*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1480*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1481*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1482*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1483*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1484*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1485*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1486*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1487*194d53e6SMatthew G. Knepley . t - current time
1488*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1489*194d53e6SMatthew G. Knepley . n - unit normal at the current point
1490*194d53e6SMatthew G. Knepley - f0 - output values at the current point
1491*194d53e6SMatthew G. Knepley 
1492*194d53e6SMatthew G. Knepley   Level: intermediate
1493*194d53e6SMatthew G. Knepley 
1494*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual()
1495*194d53e6SMatthew G. Knepley @*/
14962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f,
1497*194d53e6SMatthew G. Knepley                                     void (*f0)(PetscInt dim, PetscInt Nf,
1498*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1499*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1500*194d53e6SMatthew G. Knepley                                                const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
1501*194d53e6SMatthew G. Knepley                                     void (*f1)(PetscInt dim, PetscInt Nf,
1502*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1503*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1504*194d53e6SMatthew G. Knepley                                                const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
15052764a2aaSMatthew G. Knepley {
15062764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
15072764a2aaSMatthew G. Knepley 
15082764a2aaSMatthew G. Knepley   PetscFunctionBegin;
15092764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
15102764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
15112764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
15122764a2aaSMatthew G. Knepley   if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;}
15132764a2aaSMatthew G. Knepley   if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;}
15142764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
15152764a2aaSMatthew G. Knepley }
15162764a2aaSMatthew G. Knepley 
15172764a2aaSMatthew G. Knepley #undef __FUNCT__
15182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian"
1519*194d53e6SMatthew G. Knepley /*@C
1520*194d53e6SMatthew G. Knepley   PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field
1521*194d53e6SMatthew G. Knepley 
1522*194d53e6SMatthew G. Knepley   Not collective
1523*194d53e6SMatthew G. Knepley 
1524*194d53e6SMatthew G. Knepley   Input Parameters:
1525*194d53e6SMatthew G. Knepley + prob - The PetscDS
1526*194d53e6SMatthew G. Knepley . f    - The test field number
1527*194d53e6SMatthew G. Knepley - g    - The field number
1528*194d53e6SMatthew G. Knepley 
1529*194d53e6SMatthew G. Knepley   Output Parameters:
1530*194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1531*194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1532*194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1533*194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1534*194d53e6SMatthew G. Knepley 
1535*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1536*194d53e6SMatthew G. Knepley 
1537*194d53e6SMatthew 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
1538*194d53e6SMatthew G. Knepley 
1539*194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1540*194d53e6SMatthew G. Knepley 
1541*194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf,
1542*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1543*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1544*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
1545*194d53e6SMatthew G. Knepley 
1546*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1547*194d53e6SMatthew G. Knepley . Nf - the number of fields
1548*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1549*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1550*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1551*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1552*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1553*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1554*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1555*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1556*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1557*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1558*194d53e6SMatthew G. Knepley . t - current time
1559*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1560*194d53e6SMatthew G. Knepley . n - normal at the current point
1561*194d53e6SMatthew G. Knepley - g0 - output values at the current point
1562*194d53e6SMatthew G. Knepley 
1563*194d53e6SMatthew G. Knepley   Level: intermediate
1564*194d53e6SMatthew G. Knepley 
1565*194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian()
1566*194d53e6SMatthew G. Knepley @*/
15672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
1568*194d53e6SMatthew G. Knepley                                     void (**g0)(PetscInt dim, PetscInt Nf,
1569*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1570*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1571*194d53e6SMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
1572*194d53e6SMatthew G. Knepley                                     void (**g1)(PetscInt dim, PetscInt Nf,
1573*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1574*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1575*194d53e6SMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
1576*194d53e6SMatthew G. Knepley                                     void (**g2)(PetscInt dim, PetscInt Nf,
1577*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1578*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1579*194d53e6SMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
1580*194d53e6SMatthew G. Knepley                                     void (**g3)(PetscInt dim, PetscInt Nf,
1581*194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1582*194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1583*194d53e6SMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
15842764a2aaSMatthew G. Knepley {
15852764a2aaSMatthew G. Knepley   PetscFunctionBegin;
15862764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
15872764a2aaSMatthew 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);
15882764a2aaSMatthew 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);
15892764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];}
15902764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];}
15912764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];}
15922764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];}
15932764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
15942764a2aaSMatthew G. Knepley }
15952764a2aaSMatthew G. Knepley 
15962764a2aaSMatthew G. Knepley #undef __FUNCT__
15972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian"
1598*194d53e6SMatthew G. Knepley /*@C
1599*194d53e6SMatthew G. Knepley   PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field
1600*194d53e6SMatthew G. Knepley 
1601*194d53e6SMatthew G. Knepley   Not collective
1602*194d53e6SMatthew G. Knepley 
1603*194d53e6SMatthew G. Knepley   Input Parameters:
1604*194d53e6SMatthew G. Knepley + prob - The PetscDS
1605*194d53e6SMatthew G. Knepley . f    - The test field number
1606*194d53e6SMatthew G. Knepley . g    - The field number
1607*194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
1608*194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1609*194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1610*194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1611*194d53e6SMatthew G. Knepley 
1612*194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1613*194d53e6SMatthew G. Knepley 
1614*194d53e6SMatthew 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
1615*194d53e6SMatthew G. Knepley 
1616*194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1617*194d53e6SMatthew G. Knepley 
1618*194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf,
1619*194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1620*194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1621*194d53e6SMatthew G. Knepley $    const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
1622*194d53e6SMatthew G. Knepley 
1623*194d53e6SMatthew G. Knepley + dim - the spatial dimension
1624*194d53e6SMatthew G. Knepley . Nf - the number of fields
1625*194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1626*194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1627*194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1628*194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1629*194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1630*194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1631*194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1632*194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1633*194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1634*194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1635*194d53e6SMatthew G. Knepley . t - current time
1636*194d53e6SMatthew G. Knepley . x - coordinates of the current point
1637*194d53e6SMatthew G. Knepley . n - normal at the current point
1638*194d53e6SMatthew G. Knepley - g0 - output values at the current point
1639*194d53e6SMatthew G. Knepley 
1640*194d53e6SMatthew G. Knepley   Level: intermediate
1641*194d53e6SMatthew G. Knepley 
1642*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian()
1643*194d53e6SMatthew G. Knepley @*/
16442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
1645*194d53e6SMatthew G. Knepley                                     void (*g0)(PetscInt dim, PetscInt Nf,
1646*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1647*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1648*194d53e6SMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
1649*194d53e6SMatthew G. Knepley                                     void (*g1)(PetscInt dim, PetscInt Nf,
1650*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1651*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1652*194d53e6SMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
1653*194d53e6SMatthew G. Knepley                                     void (*g2)(PetscInt dim, PetscInt Nf,
1654*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1655*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1656*194d53e6SMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
1657*194d53e6SMatthew G. Knepley                                     void (*g3)(PetscInt dim, PetscInt Nf,
1658*194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1659*194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
1660*194d53e6SMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
16612764a2aaSMatthew G. Knepley {
16622764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
16632764a2aaSMatthew G. Knepley 
16642764a2aaSMatthew G. Knepley   PetscFunctionBegin;
16652764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
16662764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
16672764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
16682764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
16692764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
16702764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
16712764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
16722764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
16732764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+0] = g0;
16742764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+1] = g1;
16752764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+2] = g2;
16762764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+3] = g3;
16772764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
16782764a2aaSMatthew G. Knepley }
16792764a2aaSMatthew G. Knepley 
16802764a2aaSMatthew G. Knepley #undef __FUNCT__
16812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset"
1682bc4ae4beSMatthew G. Knepley /*@
1683bc4ae4beSMatthew G. Knepley   PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis
1684bc4ae4beSMatthew G. Knepley 
1685bc4ae4beSMatthew G. Knepley   Not collective
1686bc4ae4beSMatthew G. Knepley 
1687bc4ae4beSMatthew G. Knepley   Input Parameters:
1688bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
1689bc4ae4beSMatthew G. Knepley - f - The field number
1690bc4ae4beSMatthew G. Knepley 
1691bc4ae4beSMatthew G. Knepley   Output Parameter:
1692bc4ae4beSMatthew G. Knepley . off - The offset
1693bc4ae4beSMatthew G. Knepley 
1694bc4ae4beSMatthew G. Knepley   Level: beginner
1695bc4ae4beSMatthew G. Knepley 
1696bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1697bc4ae4beSMatthew G. Knepley @*/
16982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
16992764a2aaSMatthew G. Knepley {
17002764a2aaSMatthew G. Knepley   PetscInt       g;
17012764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
17022764a2aaSMatthew G. Knepley 
17032764a2aaSMatthew G. Knepley   PetscFunctionBegin;
17042764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17052764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
17062764a2aaSMatthew 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);
17072764a2aaSMatthew G. Knepley   *off = 0;
17082764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
17092764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
17102764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
17112764a2aaSMatthew G. Knepley 
17122764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
17132764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
17142764a2aaSMatthew G. Knepley     *off += Nb*Nc;
17152764a2aaSMatthew G. Knepley   }
17162764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
17172764a2aaSMatthew G. Knepley }
17182764a2aaSMatthew G. Knepley 
17192764a2aaSMatthew G. Knepley #undef __FUNCT__
17202764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset"
1721bc4ae4beSMatthew G. Knepley /*@
1722c3ac4435SMatthew G. Knepley   PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis
1723bc4ae4beSMatthew G. Knepley 
1724bc4ae4beSMatthew G. Knepley   Not collective
1725bc4ae4beSMatthew G. Knepley 
1726bc4ae4beSMatthew G. Knepley   Input Parameters:
1727bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
1728bc4ae4beSMatthew G. Knepley - f - The field number
1729bc4ae4beSMatthew G. Knepley 
1730bc4ae4beSMatthew G. Knepley   Output Parameter:
1731bc4ae4beSMatthew G. Knepley . off - The boundary offset
1732bc4ae4beSMatthew G. Knepley 
1733bc4ae4beSMatthew G. Knepley   Level: beginner
1734bc4ae4beSMatthew G. Knepley 
1735bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1736bc4ae4beSMatthew G. Knepley @*/
17372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
17382764a2aaSMatthew G. Knepley {
17392764a2aaSMatthew G. Knepley   PetscInt       g;
17402764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
17412764a2aaSMatthew G. Knepley 
17422764a2aaSMatthew G. Knepley   PetscFunctionBegin;
17432764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17442764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
17452764a2aaSMatthew 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);
17462764a2aaSMatthew G. Knepley   *off = 0;
17472764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
17482764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->discBd[g];
17492764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
17502764a2aaSMatthew G. Knepley 
17512764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
17522764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
17532764a2aaSMatthew G. Knepley     *off += Nb*Nc;
17546ce16762SMatthew G. Knepley   }
17556ce16762SMatthew G. Knepley   PetscFunctionReturn(0);
17566ce16762SMatthew G. Knepley }
17576ce16762SMatthew G. Knepley 
17586ce16762SMatthew G. Knepley #undef __FUNCT__
17596ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset"
17606ce16762SMatthew G. Knepley /*@
17616ce16762SMatthew G. Knepley   PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point
17626ce16762SMatthew G. Knepley 
17636ce16762SMatthew G. Knepley   Not collective
17646ce16762SMatthew G. Knepley 
17656ce16762SMatthew G. Knepley   Input Parameters:
17666ce16762SMatthew G. Knepley + prob - The PetscDS object
17676ce16762SMatthew G. Knepley - f - The field number
17686ce16762SMatthew G. Knepley 
17696ce16762SMatthew G. Knepley   Output Parameter:
17706ce16762SMatthew G. Knepley . off - The offset
17716ce16762SMatthew G. Knepley 
17726ce16762SMatthew G. Knepley   Level: beginner
17736ce16762SMatthew G. Knepley 
17746ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
17756ce16762SMatthew G. Knepley @*/
17766ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off)
17776ce16762SMatthew G. Knepley {
17786ce16762SMatthew G. Knepley   PetscInt       g;
17796ce16762SMatthew G. Knepley   PetscErrorCode ierr;
17806ce16762SMatthew G. Knepley 
17816ce16762SMatthew G. Knepley   PetscFunctionBegin;
17826ce16762SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17836ce16762SMatthew G. Knepley   PetscValidPointer(off, 3);
17846ce16762SMatthew 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);
17856ce16762SMatthew G. Knepley   *off = 0;
17866ce16762SMatthew G. Knepley   for (g = 0; g < f; ++g) {
17876ce16762SMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
17886ce16762SMatthew G. Knepley     PetscInt Nc;
17896ce16762SMatthew G. Knepley 
17906ce16762SMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
17916ce16762SMatthew G. Knepley     *off += Nc;
17922764a2aaSMatthew G. Knepley   }
17932764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
17942764a2aaSMatthew G. Knepley }
17952764a2aaSMatthew G. Knepley 
17962764a2aaSMatthew G. Knepley #undef __FUNCT__
1797*194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets"
1798*194d53e6SMatthew G. Knepley /*@
1799*194d53e6SMatthew G. Knepley   PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point
1800*194d53e6SMatthew G. Knepley 
1801*194d53e6SMatthew G. Knepley   Not collective
1802*194d53e6SMatthew G. Knepley 
1803*194d53e6SMatthew G. Knepley   Input Parameter:
1804*194d53e6SMatthew G. Knepley . prob - The PetscDS object
1805*194d53e6SMatthew G. Knepley 
1806*194d53e6SMatthew G. Knepley   Output Parameter:
1807*194d53e6SMatthew G. Knepley . offsets - The offsets
1808*194d53e6SMatthew G. Knepley 
1809*194d53e6SMatthew G. Knepley   Level: beginner
1810*194d53e6SMatthew G. Knepley 
1811*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1812*194d53e6SMatthew G. Knepley @*/
1813*194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[])
1814*194d53e6SMatthew G. Knepley {
1815*194d53e6SMatthew G. Knepley   PetscInt       g;
1816*194d53e6SMatthew G. Knepley   PetscErrorCode ierr;
1817*194d53e6SMatthew G. Knepley 
1818*194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1819*194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1820*194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1821*194d53e6SMatthew G. Knepley   *offsets = prob->off;
1822*194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1823*194d53e6SMatthew G. Knepley }
1824*194d53e6SMatthew G. Knepley 
1825*194d53e6SMatthew G. Knepley #undef __FUNCT__
1826*194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets"
1827*194d53e6SMatthew G. Knepley /*@
1828*194d53e6SMatthew G. Knepley   PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point
1829*194d53e6SMatthew G. Knepley 
1830*194d53e6SMatthew G. Knepley   Not collective
1831*194d53e6SMatthew G. Knepley 
1832*194d53e6SMatthew G. Knepley   Input Parameter:
1833*194d53e6SMatthew G. Knepley . prob - The PetscDS object
1834*194d53e6SMatthew G. Knepley 
1835*194d53e6SMatthew G. Knepley   Output Parameter:
1836*194d53e6SMatthew G. Knepley . offsets - The offsets
1837*194d53e6SMatthew G. Knepley 
1838*194d53e6SMatthew G. Knepley   Level: beginner
1839*194d53e6SMatthew G. Knepley 
1840*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1841*194d53e6SMatthew G. Knepley @*/
1842*194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
1843*194d53e6SMatthew G. Knepley {
1844*194d53e6SMatthew G. Knepley   PetscInt       g;
1845*194d53e6SMatthew G. Knepley   PetscErrorCode ierr;
1846*194d53e6SMatthew G. Knepley 
1847*194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1848*194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1849*194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1850*194d53e6SMatthew G. Knepley   *offsets = prob->offDer;
1851*194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1852*194d53e6SMatthew G. Knepley }
1853*194d53e6SMatthew G. Knepley 
1854*194d53e6SMatthew G. Knepley #undef __FUNCT__
1855*194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets"
1856*194d53e6SMatthew G. Knepley /*@
1857*194d53e6SMatthew G. Knepley   PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point
1858*194d53e6SMatthew G. Knepley 
1859*194d53e6SMatthew G. Knepley   Not collective
1860*194d53e6SMatthew G. Knepley 
1861*194d53e6SMatthew G. Knepley   Input Parameter:
1862*194d53e6SMatthew G. Knepley . prob - The PetscDS object
1863*194d53e6SMatthew G. Knepley 
1864*194d53e6SMatthew G. Knepley   Output Parameter:
1865*194d53e6SMatthew G. Knepley . offsets - The offsets
1866*194d53e6SMatthew G. Knepley 
1867*194d53e6SMatthew G. Knepley   Level: beginner
1868*194d53e6SMatthew G. Knepley 
1869*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1870*194d53e6SMatthew G. Knepley @*/
1871*194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[])
1872*194d53e6SMatthew G. Knepley {
1873*194d53e6SMatthew G. Knepley   PetscInt       g;
1874*194d53e6SMatthew G. Knepley   PetscErrorCode ierr;
1875*194d53e6SMatthew G. Knepley 
1876*194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1877*194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1878*194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1879*194d53e6SMatthew G. Knepley   *offsets = prob->offBd;
1880*194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1881*194d53e6SMatthew G. Knepley }
1882*194d53e6SMatthew G. Knepley 
1883*194d53e6SMatthew G. Knepley #undef __FUNCT__
1884*194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets"
1885*194d53e6SMatthew G. Knepley /*@
1886*194d53e6SMatthew G. Knepley   PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point
1887*194d53e6SMatthew G. Knepley 
1888*194d53e6SMatthew G. Knepley   Not collective
1889*194d53e6SMatthew G. Knepley 
1890*194d53e6SMatthew G. Knepley   Input Parameter:
1891*194d53e6SMatthew G. Knepley . prob - The PetscDS object
1892*194d53e6SMatthew G. Knepley 
1893*194d53e6SMatthew G. Knepley   Output Parameter:
1894*194d53e6SMatthew G. Knepley . offsets - The offsets
1895*194d53e6SMatthew G. Knepley 
1896*194d53e6SMatthew G. Knepley   Level: beginner
1897*194d53e6SMatthew G. Knepley 
1898*194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1899*194d53e6SMatthew G. Knepley @*/
1900*194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
1901*194d53e6SMatthew G. Knepley {
1902*194d53e6SMatthew G. Knepley   PetscInt       g;
1903*194d53e6SMatthew G. Knepley   PetscErrorCode ierr;
1904*194d53e6SMatthew G. Knepley 
1905*194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1906*194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1907*194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1908*194d53e6SMatthew G. Knepley   *offsets = prob->offDerBd;
1909*194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1910*194d53e6SMatthew G. Knepley }
1911*194d53e6SMatthew G. Knepley 
1912*194d53e6SMatthew G. Knepley #undef __FUNCT__
19132764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation"
191468c9edb9SMatthew G. Knepley /*@C
191568c9edb9SMatthew G. Knepley   PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization
191668c9edb9SMatthew G. Knepley 
191768c9edb9SMatthew G. Knepley   Not collective
191868c9edb9SMatthew G. Knepley 
191968c9edb9SMatthew G. Knepley   Input Parameter:
192068c9edb9SMatthew G. Knepley . prob - The PetscDS object
192168c9edb9SMatthew G. Knepley 
192268c9edb9SMatthew G. Knepley   Output Parameters:
192368c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
192468c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
192568c9edb9SMatthew G. Knepley 
192668c9edb9SMatthew G. Knepley   Level: intermediate
192768c9edb9SMatthew G. Knepley 
192868c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate()
192968c9edb9SMatthew G. Knepley @*/
19302764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
19312764a2aaSMatthew G. Knepley {
19322764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19332764a2aaSMatthew G. Knepley 
19342764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19352764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19362764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19372764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basis;}
19382764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;}
19392764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19402764a2aaSMatthew G. Knepley }
19412764a2aaSMatthew G. Knepley 
19422764a2aaSMatthew G. Knepley #undef __FUNCT__
19432764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation"
194468c9edb9SMatthew G. Knepley /*@C
194568c9edb9SMatthew G. Knepley   PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization
194668c9edb9SMatthew G. Knepley 
194768c9edb9SMatthew G. Knepley   Not collective
194868c9edb9SMatthew G. Knepley 
194968c9edb9SMatthew G. Knepley   Input Parameter:
195068c9edb9SMatthew G. Knepley . prob - The PetscDS object
195168c9edb9SMatthew G. Knepley 
195268c9edb9SMatthew G. Knepley   Output Parameters:
195368c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
195468c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
195568c9edb9SMatthew G. Knepley 
195668c9edb9SMatthew G. Knepley   Level: intermediate
195768c9edb9SMatthew G. Knepley 
195868c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate()
195968c9edb9SMatthew G. Knepley @*/
19602764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
19612764a2aaSMatthew G. Knepley {
19622764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19632764a2aaSMatthew G. Knepley 
19642764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19652764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19662764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19672764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basisBd;}
19682764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;}
19692764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19702764a2aaSMatthew G. Knepley }
19712764a2aaSMatthew G. Knepley 
19722764a2aaSMatthew G. Knepley #undef __FUNCT__
19732764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays"
19742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x)
19752764a2aaSMatthew G. Knepley {
19762764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19772764a2aaSMatthew G. Knepley 
19782764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19792764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19802764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19812764a2aaSMatthew G. Knepley   if (u)   {PetscValidPointer(u, 2);   *u   = prob->u;}
19822764a2aaSMatthew G. Knepley   if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;}
19832764a2aaSMatthew G. Knepley   if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;}
19842764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19852764a2aaSMatthew G. Knepley }
19862764a2aaSMatthew G. Knepley 
19872764a2aaSMatthew G. Knepley #undef __FUNCT__
19882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays"
19892764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3)
19902764a2aaSMatthew G. Knepley {
19912764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19922764a2aaSMatthew G. Knepley 
19932764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19942764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19952764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19962764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;}
19972764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;}
19982764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;}
19992764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;}
20002764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;}
20012764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;}
20022764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20032764a2aaSMatthew G. Knepley }
20042764a2aaSMatthew G. Knepley 
20052764a2aaSMatthew G. Knepley #undef __FUNCT__
20062764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays"
20072764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer)
20082764a2aaSMatthew G. Knepley {
20092764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
20102764a2aaSMatthew G. Knepley 
20112764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20122764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
20132764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
20142764a2aaSMatthew G. Knepley   if (x)           {PetscValidPointer(x, 2);           *x           = prob->x;}
20152764a2aaSMatthew G. Knepley   if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;}
20162764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20172764a2aaSMatthew G. Knepley }
20182764a2aaSMatthew G. Knepley 
20192764a2aaSMatthew G. Knepley #undef __FUNCT__
20202764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic"
2021bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob)
20222764a2aaSMatthew G. Knepley {
20232764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20242764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20252764a2aaSMatthew G. Knepley }
20262764a2aaSMatthew G. Knepley 
20272764a2aaSMatthew G. Knepley #undef __FUNCT__
20282764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic"
2029bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob)
20302764a2aaSMatthew G. Knepley {
20312764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20322764a2aaSMatthew G. Knepley   prob->ops->setfromoptions = NULL;
20332764a2aaSMatthew G. Knepley   prob->ops->setup          = NULL;
20342764a2aaSMatthew G. Knepley   prob->ops->view           = NULL;
20352764a2aaSMatthew G. Knepley   prob->ops->destroy        = PetscDSDestroy_Basic;
20362764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20372764a2aaSMatthew G. Knepley }
20382764a2aaSMatthew G. Knepley 
20392764a2aaSMatthew G. Knepley /*MC
20402764a2aaSMatthew G. Knepley   PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions
20412764a2aaSMatthew G. Knepley 
20422764a2aaSMatthew G. Knepley   Level: intermediate
20432764a2aaSMatthew G. Knepley 
20442764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType()
20452764a2aaSMatthew G. Knepley M*/
20462764a2aaSMatthew G. Knepley 
20472764a2aaSMatthew G. Knepley #undef __FUNCT__
20482764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic"
20492764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob)
20502764a2aaSMatthew G. Knepley {
20512764a2aaSMatthew G. Knepley   PetscDS_Basic *b;
20522764a2aaSMatthew G. Knepley   PetscErrorCode      ierr;
20532764a2aaSMatthew G. Knepley 
20542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1);
20562764a2aaSMatthew G. Knepley   ierr       = PetscNewLog(prob, &b);CHKERRQ(ierr);
20572764a2aaSMatthew G. Knepley   prob->data = b;
20582764a2aaSMatthew G. Knepley 
20592764a2aaSMatthew G. Knepley   ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr);
20602764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20612764a2aaSMatthew G. Knepley }
2062