xref: /petsc/src/dm/dt/interface/dtds.c (revision da51fced148f26845f2c876b23b86c4051a8c7ad)
1af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/
22764a2aaSMatthew G. Knepley 
32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0;
42764a2aaSMatthew G. Knepley 
52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList              = NULL;
62764a2aaSMatthew G. Knepley PetscBool         PetscDSRegisterAllCalled = PETSC_FALSE;
72764a2aaSMatthew G. Knepley 
82764a2aaSMatthew G. Knepley #undef __FUNCT__
92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister"
102764a2aaSMatthew G. Knepley /*@C
112764a2aaSMatthew G. Knepley   PetscDSRegister - Adds a new PetscDS implementation
122764a2aaSMatthew G. Knepley 
132764a2aaSMatthew G. Knepley   Not Collective
142764a2aaSMatthew G. Knepley 
152764a2aaSMatthew G. Knepley   Input Parameters:
162764a2aaSMatthew G. Knepley + name        - The name of a new user-defined creation routine
172764a2aaSMatthew G. Knepley - create_func - The creation routine itself
182764a2aaSMatthew G. Knepley 
192764a2aaSMatthew G. Knepley   Notes:
202764a2aaSMatthew G. Knepley   PetscDSRegister() may be called multiple times to add several user-defined PetscDSs
212764a2aaSMatthew G. Knepley 
222764a2aaSMatthew G. Knepley   Sample usage:
232764a2aaSMatthew G. Knepley .vb
242764a2aaSMatthew G. Knepley     PetscDSRegister("my_ds", MyPetscDSCreate);
252764a2aaSMatthew G. Knepley .ve
262764a2aaSMatthew G. Knepley 
272764a2aaSMatthew G. Knepley   Then, your PetscDS type can be chosen with the procedural interface via
282764a2aaSMatthew G. Knepley .vb
292764a2aaSMatthew G. Knepley     PetscDSCreate(MPI_Comm, PetscDS *);
302764a2aaSMatthew G. Knepley     PetscDSSetType(PetscDS, "my_ds");
312764a2aaSMatthew G. Knepley .ve
322764a2aaSMatthew G. Knepley    or at runtime via the option
332764a2aaSMatthew G. Knepley .vb
342764a2aaSMatthew G. Knepley     -petscds_type my_ds
352764a2aaSMatthew G. Knepley .ve
362764a2aaSMatthew G. Knepley 
372764a2aaSMatthew G. Knepley   Level: advanced
382764a2aaSMatthew G. Knepley 
392764a2aaSMatthew G. Knepley .keywords: PetscDS, register
402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy()
412764a2aaSMatthew G. Knepley 
422764a2aaSMatthew G. Knepley @*/
432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS))
442764a2aaSMatthew G. Knepley {
452764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
462764a2aaSMatthew G. Knepley 
472764a2aaSMatthew G. Knepley   PetscFunctionBegin;
482764a2aaSMatthew G. Knepley   ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr);
492764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
502764a2aaSMatthew G. Knepley }
512764a2aaSMatthew G. Knepley 
522764a2aaSMatthew G. Knepley #undef __FUNCT__
532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType"
542764a2aaSMatthew G. Knepley /*@C
552764a2aaSMatthew G. Knepley   PetscDSSetType - Builds a particular PetscDS
562764a2aaSMatthew G. Knepley 
572764a2aaSMatthew G. Knepley   Collective on PetscDS
582764a2aaSMatthew G. Knepley 
592764a2aaSMatthew G. Knepley   Input Parameters:
602764a2aaSMatthew G. Knepley + prob - The PetscDS object
612764a2aaSMatthew G. Knepley - name - The kind of system
622764a2aaSMatthew G. Knepley 
632764a2aaSMatthew G. Knepley   Options Database Key:
642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types
652764a2aaSMatthew G. Knepley 
662764a2aaSMatthew G. Knepley   Level: intermediate
672764a2aaSMatthew G. Knepley 
682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type
692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate()
702764a2aaSMatthew G. Knepley @*/
712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name)
722764a2aaSMatthew G. Knepley {
732764a2aaSMatthew G. Knepley   PetscErrorCode (*r)(PetscDS);
742764a2aaSMatthew G. Knepley   PetscBool      match;
752764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
762764a2aaSMatthew G. Knepley 
772764a2aaSMatthew G. Knepley   PetscFunctionBegin;
782764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
792764a2aaSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr);
802764a2aaSMatthew G. Knepley   if (match) PetscFunctionReturn(0);
812764a2aaSMatthew G. Knepley 
820f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
832764a2aaSMatthew G. Knepley   ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr);
842764a2aaSMatthew G. Knepley   if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name);
852764a2aaSMatthew G. Knepley 
862764a2aaSMatthew G. Knepley   if (prob->ops->destroy) {
872764a2aaSMatthew G. Knepley     ierr             = (*prob->ops->destroy)(prob);CHKERRQ(ierr);
882764a2aaSMatthew G. Knepley     prob->ops->destroy = NULL;
892764a2aaSMatthew G. Knepley   }
902764a2aaSMatthew G. Knepley   ierr = (*r)(prob);CHKERRQ(ierr);
912764a2aaSMatthew G. Knepley   ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr);
922764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
932764a2aaSMatthew G. Knepley }
942764a2aaSMatthew G. Knepley 
952764a2aaSMatthew G. Knepley #undef __FUNCT__
962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetType"
972764a2aaSMatthew G. Knepley /*@C
982764a2aaSMatthew G. Knepley   PetscDSGetType - Gets the PetscDS type name (as a string) from the object.
992764a2aaSMatthew G. Knepley 
1002764a2aaSMatthew G. Knepley   Not Collective
1012764a2aaSMatthew G. Knepley 
1022764a2aaSMatthew G. Knepley   Input Parameter:
1032764a2aaSMatthew G. Knepley . prob  - The PetscDS
1042764a2aaSMatthew G. Knepley 
1052764a2aaSMatthew G. Knepley   Output Parameter:
1062764a2aaSMatthew G. Knepley . name - The PetscDS type name
1072764a2aaSMatthew G. Knepley 
1082764a2aaSMatthew G. Knepley   Level: intermediate
1092764a2aaSMatthew G. Knepley 
1102764a2aaSMatthew G. Knepley .keywords: PetscDS, get, type, name
1112764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate()
1122764a2aaSMatthew G. Knepley @*/
1132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name)
1142764a2aaSMatthew G. Knepley {
1152764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
1162764a2aaSMatthew G. Knepley 
1172764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1182764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
119c959eef4SJed Brown   PetscValidPointer(name, 2);
1200f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
1212764a2aaSMatthew G. Knepley   *name = ((PetscObject) prob)->type_name;
1222764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
1232764a2aaSMatthew G. Knepley }
1242764a2aaSMatthew G. Knepley 
1252764a2aaSMatthew G. Knepley #undef __FUNCT__
1267d8a60eaSMatthew G. Knepley #define __FUNCT__ "PetscDSView_Ascii"
1277d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer)
1287d8a60eaSMatthew G. Knepley {
1297d8a60eaSMatthew G. Knepley   PetscViewerFormat format;
1307d8a60eaSMatthew G. Knepley   PetscInt          f;
1317d8a60eaSMatthew G. Knepley   PetscErrorCode    ierr;
1327d8a60eaSMatthew G. Knepley 
1337d8a60eaSMatthew G. Knepley   PetscFunctionBegin;
1347d8a60eaSMatthew G. Knepley   ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr);
1357d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr);
1367d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
1377d8a60eaSMatthew G. Knepley   for (f = 0; f < prob->Nf; ++f) {
1387d8a60eaSMatthew G. Knepley     PetscObject  obj;
1397d8a60eaSMatthew G. Knepley     PetscClassId id;
1407d8a60eaSMatthew G. Knepley     const char  *name;
1417d8a60eaSMatthew G. Knepley     PetscInt     Nc;
1427d8a60eaSMatthew G. Knepley 
1437d8a60eaSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr);
1447d8a60eaSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
1457d8a60eaSMatthew G. Knepley     ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr);
1467d8a60eaSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr);
1477d8a60eaSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {
1487d8a60eaSMatthew G. Knepley       ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr);
1497d8a60eaSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr);
1507d8a60eaSMatthew G. Knepley     } else if (id == PETSCFV_CLASSID) {
1517d8a60eaSMatthew G. Knepley       ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr);
1527d8a60eaSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr);
1537d8a60eaSMatthew G. Knepley     }
1547d8a60eaSMatthew G. Knepley     else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
1557d8a60eaSMatthew G. Knepley     if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%d components", Nc);CHKERRQ(ierr);}
1567d8a60eaSMatthew G. Knepley     else        {ierr = PetscViewerASCIIPrintf(viewer, "%d component ", Nc);CHKERRQ(ierr);}
157249df284SMatthew G. Knepley     if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);}
158249df284SMatthew G. Knepley     else                   {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);}
159a6cbbb48SMatthew G. Knepley     if (prob->adjacency[f*2+0]) {
160a6cbbb48SMatthew G. Knepley       if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);}
161a6cbbb48SMatthew G. Knepley       else                        {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);}
162a6cbbb48SMatthew G. Knepley     } else {
163a6cbbb48SMatthew G. Knepley       if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);}
164a6cbbb48SMatthew G. Knepley       else                        {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);}
165a6cbbb48SMatthew G. Knepley     }
1667d8a60eaSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr);
1677d8a60eaSMatthew G. Knepley     if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
1687d8a60eaSMatthew G. Knepley       if (id == PETSCFE_CLASSID)      {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);}
1697d8a60eaSMatthew G. Knepley       else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);}
1707d8a60eaSMatthew G. Knepley     }
1717d8a60eaSMatthew G. Knepley   }
1727d8a60eaSMatthew G. Knepley   ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
1737d8a60eaSMatthew G. Knepley   PetscFunctionReturn(0);
1747d8a60eaSMatthew G. Knepley }
1757d8a60eaSMatthew G. Knepley 
1767d8a60eaSMatthew G. Knepley #undef __FUNCT__
1772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView"
1782764a2aaSMatthew G. Knepley /*@C
1792764a2aaSMatthew G. Knepley   PetscDSView - Views a PetscDS
1802764a2aaSMatthew G. Knepley 
1812764a2aaSMatthew G. Knepley   Collective on PetscDS
1822764a2aaSMatthew G. Knepley 
1832764a2aaSMatthew G. Knepley   Input Parameter:
1842764a2aaSMatthew G. Knepley + prob - the PetscDS object to view
1852764a2aaSMatthew G. Knepley - v  - the viewer
1862764a2aaSMatthew G. Knepley 
1872764a2aaSMatthew G. Knepley   Level: developer
1882764a2aaSMatthew G. Knepley 
1892764a2aaSMatthew G. Knepley .seealso PetscDSDestroy()
1902764a2aaSMatthew G. Knepley @*/
1912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v)
1922764a2aaSMatthew G. Knepley {
1937d8a60eaSMatthew G. Knepley   PetscBool      iascii;
1942764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
1952764a2aaSMatthew G. Knepley 
1962764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1972764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1982764a2aaSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);}
1997d8a60eaSMatthew G. Knepley   else    {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);}
2007d8a60eaSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr);
2017d8a60eaSMatthew G. Knepley   if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);}
2022764a2aaSMatthew G. Knepley   if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);}
2032764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2042764a2aaSMatthew G. Knepley }
2052764a2aaSMatthew G. Knepley 
2062764a2aaSMatthew G. Knepley #undef __FUNCT__
2072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions"
2082764a2aaSMatthew G. Knepley /*@
2092764a2aaSMatthew G. Knepley   PetscDSSetFromOptions - sets parameters in a PetscDS from the options database
2102764a2aaSMatthew G. Knepley 
2112764a2aaSMatthew G. Knepley   Collective on PetscDS
2122764a2aaSMatthew G. Knepley 
2132764a2aaSMatthew G. Knepley   Input Parameter:
2142764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for
2152764a2aaSMatthew G. Knepley 
2162764a2aaSMatthew G. Knepley   Options Database:
2172764a2aaSMatthew G. Knepley 
2182764a2aaSMatthew G. Knepley   Level: developer
2192764a2aaSMatthew G. Knepley 
2202764a2aaSMatthew G. Knepley .seealso PetscDSView()
2212764a2aaSMatthew G. Knepley @*/
2222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob)
2232764a2aaSMatthew G. Knepley {
2242764a2aaSMatthew G. Knepley   const char    *defaultType;
2252764a2aaSMatthew G. Knepley   char           name[256];
2262764a2aaSMatthew G. Knepley   PetscBool      flg;
2272764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2282764a2aaSMatthew G. Knepley 
2292764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2302764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2312764a2aaSMatthew G. Knepley   if (!((PetscObject) prob)->type_name) {
2322764a2aaSMatthew G. Knepley     defaultType = PETSCDSBASIC;
2332764a2aaSMatthew G. Knepley   } else {
2342764a2aaSMatthew G. Knepley     defaultType = ((PetscObject) prob)->type_name;
2352764a2aaSMatthew G. Knepley   }
2360f51fdf8SToby Isaac   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
2372764a2aaSMatthew G. Knepley 
2382764a2aaSMatthew G. Knepley   ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr);
2392764a2aaSMatthew G. Knepley   ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr);
2402764a2aaSMatthew G. Knepley   if (flg) {
2412764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, name);CHKERRQ(ierr);
2422764a2aaSMatthew G. Knepley   } else if (!((PetscObject) prob)->type_name) {
2432764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr);
2442764a2aaSMatthew G. Knepley   }
2452764a2aaSMatthew G. Knepley   if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);}
2462764a2aaSMatthew G. Knepley   /* process any options handlers added with PetscObjectAddOptionsHandler() */
2472764a2aaSMatthew G. Knepley   ierr = PetscObjectProcessOptionsHandlers((PetscObject) prob);CHKERRQ(ierr);
2482764a2aaSMatthew G. Knepley   ierr = PetscOptionsEnd();CHKERRQ(ierr);
2492764a2aaSMatthew G. Knepley   ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);
2502764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2512764a2aaSMatthew G. Knepley }
2522764a2aaSMatthew G. Knepley 
2532764a2aaSMatthew G. Knepley #undef __FUNCT__
2542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp"
2552764a2aaSMatthew G. Knepley /*@C
2562764a2aaSMatthew G. Knepley   PetscDSSetUp - Construct data structures for the PetscDS
2572764a2aaSMatthew G. Knepley 
2582764a2aaSMatthew G. Knepley   Collective on PetscDS
2592764a2aaSMatthew G. Knepley 
2602764a2aaSMatthew G. Knepley   Input Parameter:
2612764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup
2622764a2aaSMatthew G. Knepley 
2632764a2aaSMatthew G. Knepley   Level: developer
2642764a2aaSMatthew G. Knepley 
2652764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy()
2662764a2aaSMatthew G. Knepley @*/
2672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob)
2682764a2aaSMatthew G. Knepley {
2692764a2aaSMatthew G. Knepley   const PetscInt Nf = prob->Nf;
2702764a2aaSMatthew G. Knepley   PetscInt       dim, work, NcMax = 0, NqMax = 0, f;
2712764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2722764a2aaSMatthew G. Knepley 
2732764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2742764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2752764a2aaSMatthew G. Knepley   if (prob->setup) PetscFunctionReturn(0);
2762764a2aaSMatthew G. Knepley   /* Calculate sizes */
2772764a2aaSMatthew G. Knepley   ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr);
2782764a2aaSMatthew G. Knepley   prob->totDim = prob->totDimBd = prob->totComp = 0;
279194d53e6SMatthew G. Knepley   ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr);
2802764a2aaSMatthew G. Knepley   ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr);
2812764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
2822764a2aaSMatthew G. Knepley     PetscFE         feBd = (PetscFE) prob->discBd[f];
2839de99aefSMatthew G. Knepley     PetscObject     obj;
2849de99aefSMatthew G. Knepley     PetscClassId    id;
2852764a2aaSMatthew G. Knepley     PetscQuadrature q;
2869de99aefSMatthew G. Knepley     PetscInt        Nq = 0, Nb, Nc;
2872764a2aaSMatthew G. Knepley 
2889de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr);
2899de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
2909de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {
2919de99aefSMatthew G. Knepley       PetscFE fe = (PetscFE) obj;
2929de99aefSMatthew G. Knepley 
2932764a2aaSMatthew G. Knepley       ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr);
2942764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
2952764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
2962764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
2979de99aefSMatthew G. Knepley     } else if (id == PETSCFV_CLASSID) {
2989de99aefSMatthew G. Knepley       PetscFV fv = (PetscFV) obj;
2999de99aefSMatthew G. Knepley 
3009de99aefSMatthew G. Knepley       ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr);
3019de99aefSMatthew G. Knepley       Nb   = 1;
3029de99aefSMatthew G. Knepley       ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr);
3036c1a3d01SMatthew G. Knepley       ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
304abac5ca0SMatthew G. Knepley     } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f);
305194d53e6SMatthew G. Knepley     prob->off[f+1]    = Nc     + prob->off[f];
306194d53e6SMatthew G. Knepley     prob->offDer[f+1] = Nc*dim + prob->offDer[f];
3079de99aefSMatthew G. Knepley     if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);}
3082764a2aaSMatthew G. Knepley     NqMax          = PetscMax(NqMax, Nq);
3092764a2aaSMatthew G. Knepley     NcMax          = PetscMax(NcMax, Nc);
3102764a2aaSMatthew G. Knepley     prob->totDim  += Nb*Nc;
3112764a2aaSMatthew G. Knepley     prob->totComp += Nc;
3122764a2aaSMatthew G. Knepley     if (feBd) {
3132764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr);
3142764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr);
3152764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr);
3162764a2aaSMatthew G. Knepley       prob->totDimBd += Nb*Nc;
317194d53e6SMatthew G. Knepley       prob->offBd[f+1]    = Nc     + prob->offBd[f];
318194d53e6SMatthew G. Knepley       prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f];
3192764a2aaSMatthew G. Knepley     }
3202764a2aaSMatthew G. Knepley   }
3212764a2aaSMatthew G. Knepley   work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim));
3222764a2aaSMatthew G. Knepley   /* Allocate works space */
3232764a2aaSMatthew G. Knepley   ierr = PetscMalloc5(prob->totComp,&prob->u,prob->totComp,&prob->u_t,prob->totComp*dim,&prob->u_x,dim,&prob->x,work,&prob->refSpaceDer);CHKERRQ(ierr);
3242764a2aaSMatthew G. Knepley   ierr = PetscMalloc6(NqMax*NcMax,&prob->f0,NqMax*NcMax*dim,&prob->f1,NqMax*NcMax*NcMax,&prob->g0,NqMax*NcMax*NcMax*dim,&prob->g1,NqMax*NcMax*NcMax*dim,&prob->g2,NqMax*NcMax*NcMax*dim*dim,&prob->g3);CHKERRQ(ierr);
3252764a2aaSMatthew G. Knepley   if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);}
3262764a2aaSMatthew G. Knepley   prob->setup = PETSC_TRUE;
3272764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3282764a2aaSMatthew G. Knepley }
3292764a2aaSMatthew G. Knepley 
3302764a2aaSMatthew G. Knepley #undef __FUNCT__
3312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static"
3322764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob)
3332764a2aaSMatthew G. Knepley {
3342764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3352764a2aaSMatthew G. Knepley 
3362764a2aaSMatthew G. Knepley   PetscFunctionBegin;
337194d53e6SMatthew G. Knepley   ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr);
3382764a2aaSMatthew G. Knepley   ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr);
3392764a2aaSMatthew G. Knepley   ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr);
3402764a2aaSMatthew G. Knepley   ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr);
3412764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3422764a2aaSMatthew G. Knepley }
3432764a2aaSMatthew G. Knepley 
3442764a2aaSMatthew G. Knepley #undef __FUNCT__
3452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static"
3462764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew)
3472764a2aaSMatthew G. Knepley {
3482764a2aaSMatthew G. Knepley   PetscObject      *tmpd, *tmpdbd;
349a6cbbb48SMatthew G. Knepley   PetscBool        *tmpi, *tmpa;
3502aa1fc23SMatthew G. Knepley   PetscPointFunc   *tmpobj, *tmpf;
3512aa1fc23SMatthew G. Knepley   PetscPointJac    *tmpg;
3522aa1fc23SMatthew G. Knepley   PetscBdPointFunc *tmpfbd;
3532aa1fc23SMatthew G. Knepley   PetscBdPointJac  *tmpgbd;
354194d53e6SMatthew G. Knepley   PetscRiemannFunc *tmpr;
3550c2f2876SMatthew G. Knepley   void            **tmpctx;
356a6cbbb48SMatthew G. Knepley   PetscInt          Nf = prob->Nf, f, i;
3572764a2aaSMatthew G. Knepley   PetscErrorCode    ierr;
3582764a2aaSMatthew G. Knepley 
3592764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3602764a2aaSMatthew G. Knepley   if (Nf >= NfNew) PetscFunctionReturn(0);
3612764a2aaSMatthew G. Knepley   prob->setup = PETSC_FALSE;
3622764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr);
363a6cbbb48SMatthew G. Knepley   ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr);
364a6cbbb48SMatthew G. Knepley   for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpdbd[f] = prob->discBd[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];}
365a6cbbb48SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr);
366a6cbbb48SMatthew G. Knepley     tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;}
367a6cbbb48SMatthew G. Knepley   ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr);
3682764a2aaSMatthew G. Knepley   prob->Nf        = NfNew;
3692764a2aaSMatthew G. Knepley   prob->disc      = tmpd;
370a6cbbb48SMatthew G. Knepley   prob->discBd    = tmpdbd;
371249df284SMatthew G. Knepley   prob->implicit  = tmpi;
372a6cbbb48SMatthew G. Knepley   prob->adjacency = tmpa;
3730c2f2876SMatthew G. Knepley   ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr);
3742764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f];
3752764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f];
3762764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f];
3770c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f];
3780c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f];
3792764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL;
3802764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL;
3812764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL;
3820c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL;
3830c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL;
3840c2f2876SMatthew G. Knepley   ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr);
3852764a2aaSMatthew G. Knepley   prob->obj = tmpobj;
3862764a2aaSMatthew G. Knepley   prob->f   = tmpf;
3872764a2aaSMatthew G. Knepley   prob->g   = tmpg;
3880c2f2876SMatthew G. Knepley   prob->r   = tmpr;
3890c2f2876SMatthew G. Knepley   prob->ctx = tmpctx;
3902764a2aaSMatthew G. Knepley   ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr);
3912764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f];
3922764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f];
3932764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL;
3942764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL;
3952764a2aaSMatthew G. Knepley   ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr);
3962764a2aaSMatthew G. Knepley   prob->fBd = tmpfbd;
3972764a2aaSMatthew G. Knepley   prob->gBd = tmpgbd;
3982764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3992764a2aaSMatthew G. Knepley }
4002764a2aaSMatthew G. Knepley 
4012764a2aaSMatthew G. Knepley #undef __FUNCT__
4022764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy"
4032764a2aaSMatthew G. Knepley /*@
4042764a2aaSMatthew G. Knepley   PetscDSDestroy - Destroys a PetscDS object
4052764a2aaSMatthew G. Knepley 
4062764a2aaSMatthew G. Knepley   Collective on PetscDS
4072764a2aaSMatthew G. Knepley 
4082764a2aaSMatthew G. Knepley   Input Parameter:
4092764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy
4102764a2aaSMatthew G. Knepley 
4112764a2aaSMatthew G. Knepley   Level: developer
4122764a2aaSMatthew G. Knepley 
4132764a2aaSMatthew G. Knepley .seealso PetscDSView()
4142764a2aaSMatthew G. Knepley @*/
4152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob)
4162764a2aaSMatthew G. Knepley {
4172764a2aaSMatthew G. Knepley   PetscInt       f;
4182764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4192764a2aaSMatthew G. Knepley 
4202764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4212764a2aaSMatthew G. Knepley   if (!*prob) PetscFunctionReturn(0);
4222764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1);
4232764a2aaSMatthew G. Knepley 
4242764a2aaSMatthew G. Knepley   if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);}
4252764a2aaSMatthew G. Knepley   ((PetscObject) (*prob))->refct = 0;
4262764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr);
4272764a2aaSMatthew G. Knepley   for (f = 0; f < (*prob)->Nf; ++f) {
4282764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr);
4292764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr);
4302764a2aaSMatthew G. Knepley   }
431a6cbbb48SMatthew G. Knepley   ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr);
4320c2f2876SMatthew G. Knepley   ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr);
4332764a2aaSMatthew G. Knepley   ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr);
4342764a2aaSMatthew G. Knepley   if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);}
4352764a2aaSMatthew G. Knepley   ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr);
4362764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4372764a2aaSMatthew G. Knepley }
4382764a2aaSMatthew G. Knepley 
4392764a2aaSMatthew G. Knepley #undef __FUNCT__
4402764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate"
4412764a2aaSMatthew G. Knepley /*@
4422764a2aaSMatthew G. Knepley   PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType().
4432764a2aaSMatthew G. Knepley 
4442764a2aaSMatthew G. Knepley   Collective on MPI_Comm
4452764a2aaSMatthew G. Knepley 
4462764a2aaSMatthew G. Knepley   Input Parameter:
4472764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object
4482764a2aaSMatthew G. Knepley 
4492764a2aaSMatthew G. Knepley   Output Parameter:
4502764a2aaSMatthew G. Knepley . prob - The PetscDS object
4512764a2aaSMatthew G. Knepley 
4522764a2aaSMatthew G. Knepley   Level: beginner
4532764a2aaSMatthew G. Knepley 
4542764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC
4552764a2aaSMatthew G. Knepley @*/
4562764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob)
4572764a2aaSMatthew G. Knepley {
4582764a2aaSMatthew G. Knepley   PetscDS   p;
4592764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4602764a2aaSMatthew G. Knepley 
4612764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4622764a2aaSMatthew G. Knepley   PetscValidPointer(prob, 2);
4632764a2aaSMatthew G. Knepley   *prob  = NULL;
4642764a2aaSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
4652764a2aaSMatthew G. Knepley 
46673107ff1SLisandro Dalcin   ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr);
4672764a2aaSMatthew G. Knepley 
4682764a2aaSMatthew G. Knepley   p->Nf    = 0;
4692764a2aaSMatthew G. Knepley   p->setup = PETSC_FALSE;
4702764a2aaSMatthew G. Knepley 
4712764a2aaSMatthew G. Knepley   *prob = p;
4722764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4732764a2aaSMatthew G. Knepley }
4742764a2aaSMatthew G. Knepley 
4752764a2aaSMatthew G. Knepley #undef __FUNCT__
4762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields"
477bc4ae4beSMatthew G. Knepley /*@
478bc4ae4beSMatthew G. Knepley   PetscDSGetNumFields - Returns the number of fields in the DS
479bc4ae4beSMatthew G. Knepley 
480bc4ae4beSMatthew G. Knepley   Not collective
481bc4ae4beSMatthew G. Knepley 
482bc4ae4beSMatthew G. Knepley   Input Parameter:
483bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
484bc4ae4beSMatthew G. Knepley 
485bc4ae4beSMatthew G. Knepley   Output Parameter:
486bc4ae4beSMatthew G. Knepley . Nf - The number of fields
487bc4ae4beSMatthew G. Knepley 
488bc4ae4beSMatthew G. Knepley   Level: beginner
489bc4ae4beSMatthew G. Knepley 
490bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate()
491bc4ae4beSMatthew G. Knepley @*/
4922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf)
4932764a2aaSMatthew G. Knepley {
4942764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4952764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4962764a2aaSMatthew G. Knepley   PetscValidPointer(Nf, 2);
4972764a2aaSMatthew G. Knepley   *Nf = prob->Nf;
4982764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4992764a2aaSMatthew G. Knepley }
5002764a2aaSMatthew G. Knepley 
5012764a2aaSMatthew G. Knepley #undef __FUNCT__
5022764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension"
503bc4ae4beSMatthew G. Knepley /*@
504bc4ae4beSMatthew G. Knepley   PetscDSGetSpatialDimension - Returns the spatial dimension of the DS
505bc4ae4beSMatthew G. Knepley 
506bc4ae4beSMatthew G. Knepley   Not collective
507bc4ae4beSMatthew G. Knepley 
508bc4ae4beSMatthew G. Knepley   Input Parameter:
509bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
510bc4ae4beSMatthew G. Knepley 
511bc4ae4beSMatthew G. Knepley   Output Parameter:
512bc4ae4beSMatthew G. Knepley . dim - The spatial dimension
513bc4ae4beSMatthew G. Knepley 
514bc4ae4beSMatthew G. Knepley   Level: beginner
515bc4ae4beSMatthew G. Knepley 
516bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
517bc4ae4beSMatthew G. Knepley @*/
5182764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim)
5192764a2aaSMatthew G. Knepley {
5202764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5212764a2aaSMatthew G. Knepley 
5222764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5232764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5242764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5252764a2aaSMatthew G. Knepley   *dim = 0;
5269de99aefSMatthew G. Knepley   if (prob->Nf) {
5279de99aefSMatthew G. Knepley     PetscObject  obj;
5289de99aefSMatthew G. Knepley     PetscClassId id;
5299de99aefSMatthew G. Knepley 
5309de99aefSMatthew G. Knepley     ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr);
5319de99aefSMatthew G. Knepley     ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr);
5329de99aefSMatthew G. Knepley     if (id == PETSCFE_CLASSID)      {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);}
5339de99aefSMatthew G. Knepley     else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);}
5349de99aefSMatthew G. Knepley     else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0);
5359de99aefSMatthew G. Knepley   }
5362764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5372764a2aaSMatthew G. Knepley }
5382764a2aaSMatthew G. Knepley 
5392764a2aaSMatthew G. Knepley #undef __FUNCT__
5402764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension"
541bc4ae4beSMatthew G. Knepley /*@
542bc4ae4beSMatthew G. Knepley   PetscDSGetTotalDimension - Returns the total size of the approximation space for this system
543bc4ae4beSMatthew G. Knepley 
544bc4ae4beSMatthew G. Knepley   Not collective
545bc4ae4beSMatthew G. Knepley 
546bc4ae4beSMatthew G. Knepley   Input Parameter:
547bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
548bc4ae4beSMatthew G. Knepley 
549bc4ae4beSMatthew G. Knepley   Output Parameter:
550bc4ae4beSMatthew G. Knepley . dim - The total problem dimension
551bc4ae4beSMatthew G. Knepley 
552bc4ae4beSMatthew G. Knepley   Level: beginner
553bc4ae4beSMatthew G. Knepley 
554bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
555bc4ae4beSMatthew G. Knepley @*/
5562764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim)
5572764a2aaSMatthew G. Knepley {
5582764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5592764a2aaSMatthew G. Knepley 
5602764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5612764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5622764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
5632764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5642764a2aaSMatthew G. Knepley   *dim = prob->totDim;
5652764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5662764a2aaSMatthew G. Knepley }
5672764a2aaSMatthew G. Knepley 
5682764a2aaSMatthew G. Knepley #undef __FUNCT__
5692764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension"
570bc4ae4beSMatthew G. Knepley /*@
571c3ac4435SMatthew G. Knepley   PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system
572bc4ae4beSMatthew G. Knepley 
573bc4ae4beSMatthew G. Knepley   Not collective
574bc4ae4beSMatthew G. Knepley 
575bc4ae4beSMatthew G. Knepley   Input Parameter:
576bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
577bc4ae4beSMatthew G. Knepley 
578bc4ae4beSMatthew G. Knepley   Output Parameter:
579bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension
580bc4ae4beSMatthew G. Knepley 
581bc4ae4beSMatthew G. Knepley   Level: beginner
582bc4ae4beSMatthew G. Knepley 
583bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
584bc4ae4beSMatthew G. Knepley @*/
5852764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim)
5862764a2aaSMatthew G. Knepley {
5872764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5882764a2aaSMatthew G. Knepley 
5892764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5902764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5912764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
5922764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
5932764a2aaSMatthew G. Knepley   *dim = prob->totDimBd;
5942764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5952764a2aaSMatthew G. Knepley }
5962764a2aaSMatthew G. Knepley 
5972764a2aaSMatthew G. Knepley #undef __FUNCT__
5982764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents"
599bc4ae4beSMatthew G. Knepley /*@
600bc4ae4beSMatthew G. Knepley   PetscDSGetTotalComponents - Returns the total number of components in this system
601bc4ae4beSMatthew G. Knepley 
602bc4ae4beSMatthew G. Knepley   Not collective
603bc4ae4beSMatthew G. Knepley 
604bc4ae4beSMatthew G. Knepley   Input Parameter:
605bc4ae4beSMatthew G. Knepley . prob - The PetscDS object
606bc4ae4beSMatthew G. Knepley 
607bc4ae4beSMatthew G. Knepley   Output Parameter:
608bc4ae4beSMatthew G. Knepley . dim - The total number of components
609bc4ae4beSMatthew G. Knepley 
610bc4ae4beSMatthew G. Knepley   Level: beginner
611bc4ae4beSMatthew G. Knepley 
612bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate()
613bc4ae4beSMatthew G. Knepley @*/
6142764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc)
6152764a2aaSMatthew G. Knepley {
6162764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6172764a2aaSMatthew G. Knepley 
6182764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6192764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6202764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
6212764a2aaSMatthew G. Knepley   PetscValidPointer(Nc, 2);
6222764a2aaSMatthew G. Knepley   *Nc = prob->totComp;
6232764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6242764a2aaSMatthew G. Knepley }
6252764a2aaSMatthew G. Knepley 
6262764a2aaSMatthew G. Knepley #undef __FUNCT__
6272764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization"
628bc4ae4beSMatthew G. Knepley /*@
629bc4ae4beSMatthew G. Knepley   PetscDSGetDiscretization - Returns the discretization object for the given field
630bc4ae4beSMatthew G. Knepley 
631bc4ae4beSMatthew G. Knepley   Not collective
632bc4ae4beSMatthew G. Knepley 
633bc4ae4beSMatthew G. Knepley   Input Parameters:
634bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
635bc4ae4beSMatthew G. Knepley - f - The field number
636bc4ae4beSMatthew G. Knepley 
637bc4ae4beSMatthew G. Knepley   Output Parameter:
638bc4ae4beSMatthew G. Knepley . disc - The discretization object
639bc4ae4beSMatthew G. Knepley 
640bc4ae4beSMatthew G. Knepley   Level: beginner
641bc4ae4beSMatthew G. Knepley 
642bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
643bc4ae4beSMatthew G. Knepley @*/
6442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
6452764a2aaSMatthew G. Knepley {
6462764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6472764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6482764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
6492764a2aaSMatthew 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);
6502764a2aaSMatthew G. Knepley   *disc = prob->disc[f];
6512764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6522764a2aaSMatthew G. Knepley }
6532764a2aaSMatthew G. Knepley 
6542764a2aaSMatthew G. Knepley #undef __FUNCT__
6552764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization"
656bc4ae4beSMatthew G. Knepley /*@
657bc4ae4beSMatthew G. Knepley   PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field
658bc4ae4beSMatthew G. Knepley 
659bc4ae4beSMatthew G. Knepley   Not collective
660bc4ae4beSMatthew G. Knepley 
661bc4ae4beSMatthew G. Knepley   Input Parameters:
662bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
663bc4ae4beSMatthew G. Knepley - f - The field number
664bc4ae4beSMatthew G. Knepley 
665bc4ae4beSMatthew G. Knepley   Output Parameter:
666bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object
667bc4ae4beSMatthew G. Knepley 
668bc4ae4beSMatthew G. Knepley   Level: beginner
669bc4ae4beSMatthew G. Knepley 
670bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
671bc4ae4beSMatthew G. Knepley @*/
6722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
6732764a2aaSMatthew G. Knepley {
6742764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6752764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6762764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
6772764a2aaSMatthew 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);
6782764a2aaSMatthew G. Knepley   *disc = prob->discBd[f];
6792764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6802764a2aaSMatthew G. Knepley }
6812764a2aaSMatthew G. Knepley 
6822764a2aaSMatthew G. Knepley #undef __FUNCT__
6832764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization"
684bc4ae4beSMatthew G. Knepley /*@
685bc4ae4beSMatthew G. Knepley   PetscDSSetDiscretization - Sets the discretization object for the given field
686bc4ae4beSMatthew G. Knepley 
687bc4ae4beSMatthew G. Knepley   Not collective
688bc4ae4beSMatthew G. Knepley 
689bc4ae4beSMatthew G. Knepley   Input Parameters:
690bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
691bc4ae4beSMatthew G. Knepley . f - The field number
692bc4ae4beSMatthew G. Knepley - disc - The discretization object
693bc4ae4beSMatthew G. Knepley 
694bc4ae4beSMatthew G. Knepley   Level: beginner
695bc4ae4beSMatthew G. Knepley 
696bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
697bc4ae4beSMatthew G. Knepley @*/
6982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
6992764a2aaSMatthew G. Knepley {
7002764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7012764a2aaSMatthew G. Knepley 
7022764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7032764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7042764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
7052764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7062764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7072764a2aaSMatthew G. Knepley   if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);}
7082764a2aaSMatthew G. Knepley   prob->disc[f] = disc;
7092764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
710249df284SMatthew G. Knepley   {
711249df284SMatthew G. Knepley     PetscClassId id;
712249df284SMatthew G. Knepley 
713249df284SMatthew G. Knepley     ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr);
714a6cbbb48SMatthew G. Knepley     if (id == PETSCFV_CLASSID) {
715a6cbbb48SMatthew G. Knepley       prob->implicit[f]      = PETSC_FALSE;
716a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+0] = PETSC_TRUE;
717a6cbbb48SMatthew G. Knepley       prob->adjacency[f*2+1] = PETSC_FALSE;
718a6cbbb48SMatthew G. Knepley     }
719249df284SMatthew G. Knepley   }
7202764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7212764a2aaSMatthew G. Knepley }
7222764a2aaSMatthew G. Knepley 
7232764a2aaSMatthew G. Knepley #undef __FUNCT__
7242764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization"
725bc4ae4beSMatthew G. Knepley /*@
726bc4ae4beSMatthew G. Knepley   PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field
727bc4ae4beSMatthew G. Knepley 
728bc4ae4beSMatthew G. Knepley   Not collective
729bc4ae4beSMatthew G. Knepley 
730bc4ae4beSMatthew G. Knepley   Input Parameters:
731bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
732bc4ae4beSMatthew G. Knepley . f - The field number
733bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
734bc4ae4beSMatthew G. Knepley 
735bc4ae4beSMatthew G. Knepley   Level: beginner
736bc4ae4beSMatthew G. Knepley 
737bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
738bc4ae4beSMatthew G. Knepley @*/
7392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
7402764a2aaSMatthew G. Knepley {
7412764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7422764a2aaSMatthew G. Knepley 
7432764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7442764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
7452764a2aaSMatthew G. Knepley   if (disc) PetscValidPointer(disc, 3);
7462764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
7472764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
7482764a2aaSMatthew G. Knepley   if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);}
7492764a2aaSMatthew G. Knepley   prob->discBd[f] = disc;
7502764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
7512764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7522764a2aaSMatthew G. Knepley }
7532764a2aaSMatthew G. Knepley 
7542764a2aaSMatthew G. Knepley #undef __FUNCT__
7552764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization"
756bc4ae4beSMatthew G. Knepley /*@
757bc4ae4beSMatthew G. Knepley   PetscDSAddDiscretization - Adds a discretization object
758bc4ae4beSMatthew G. Knepley 
759bc4ae4beSMatthew G. Knepley   Not collective
760bc4ae4beSMatthew G. Knepley 
761bc4ae4beSMatthew G. Knepley   Input Parameters:
762bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
763bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
764bc4ae4beSMatthew G. Knepley 
765bc4ae4beSMatthew G. Knepley   Level: beginner
766bc4ae4beSMatthew G. Knepley 
767bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
768bc4ae4beSMatthew G. Knepley @*/
7692764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc)
7702764a2aaSMatthew G. Knepley {
7712764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7722764a2aaSMatthew G. Knepley 
7732764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7742764a2aaSMatthew G. Knepley   ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
7752764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
7762764a2aaSMatthew G. Knepley }
7772764a2aaSMatthew G. Knepley 
7782764a2aaSMatthew G. Knepley #undef __FUNCT__
7792764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization"
780bc4ae4beSMatthew G. Knepley /*@
781bc4ae4beSMatthew G. Knepley   PetscDSAddBdDiscretization - Adds a boundary discretization object
782bc4ae4beSMatthew G. Knepley 
783bc4ae4beSMatthew G. Knepley   Not collective
784bc4ae4beSMatthew G. Knepley 
785bc4ae4beSMatthew G. Knepley   Input Parameters:
786bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
787bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object
788bc4ae4beSMatthew G. Knepley 
789bc4ae4beSMatthew G. Knepley   Level: beginner
790bc4ae4beSMatthew G. Knepley 
791bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
792bc4ae4beSMatthew G. Knepley @*/
7932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc)
7942764a2aaSMatthew G. Knepley {
7952764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
7962764a2aaSMatthew G. Knepley 
7972764a2aaSMatthew G. Knepley   PetscFunctionBegin;
7982764a2aaSMatthew G. Knepley   ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
7992764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8002764a2aaSMatthew G. Knepley }
8012764a2aaSMatthew G. Knepley 
8022764a2aaSMatthew G. Knepley #undef __FUNCT__
803249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit"
804249df284SMatthew G. Knepley /*@
805249df284SMatthew G. Knepley   PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX
806249df284SMatthew G. Knepley 
807249df284SMatthew G. Knepley   Not collective
808249df284SMatthew G. Knepley 
809249df284SMatthew G. Knepley   Input Parameters:
810249df284SMatthew G. Knepley + prob - The PetscDS object
811249df284SMatthew G. Knepley - f - The field number
812249df284SMatthew G. Knepley 
813249df284SMatthew G. Knepley   Output Parameter:
814249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field
815249df284SMatthew G. Knepley 
816249df284SMatthew G. Knepley   Level: developer
817249df284SMatthew G. Knepley 
818249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
819249df284SMatthew G. Knepley @*/
820249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit)
821249df284SMatthew G. Knepley {
822249df284SMatthew G. Knepley   PetscFunctionBegin;
823249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
824249df284SMatthew G. Knepley   PetscValidPointer(implicit, 3);
825249df284SMatthew 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);
826249df284SMatthew G. Knepley   *implicit = prob->implicit[f];
827249df284SMatthew G. Knepley   PetscFunctionReturn(0);
828249df284SMatthew G. Knepley }
829249df284SMatthew G. Knepley 
830249df284SMatthew G. Knepley #undef __FUNCT__
831249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit"
832249df284SMatthew G. Knepley /*@
833249df284SMatthew G. Knepley   PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX
834249df284SMatthew G. Knepley 
835249df284SMatthew G. Knepley   Not collective
836249df284SMatthew G. Knepley 
837249df284SMatthew G. Knepley   Input Parameters:
838249df284SMatthew G. Knepley + prob - The PetscDS object
839249df284SMatthew G. Knepley . f - The field number
840249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field
841249df284SMatthew G. Knepley 
842249df284SMatthew G. Knepley   Level: developer
843249df284SMatthew G. Knepley 
844249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
845249df284SMatthew G. Knepley @*/
846249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit)
847249df284SMatthew G. Knepley {
848249df284SMatthew G. Knepley   PetscFunctionBegin;
849249df284SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
850249df284SMatthew 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);
851249df284SMatthew G. Knepley   prob->implicit[f] = implicit;
852249df284SMatthew G. Knepley   PetscFunctionReturn(0);
853249df284SMatthew G. Knepley }
854249df284SMatthew G. Knepley 
855249df284SMatthew G. Knepley #undef __FUNCT__
856a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency"
857a6cbbb48SMatthew G. Knepley /*@
858a6cbbb48SMatthew G. Knepley   PetscDSGetAdjacency - Returns the flags for determining variable influence
859a6cbbb48SMatthew G. Knepley 
860a6cbbb48SMatthew G. Knepley   Not collective
861a6cbbb48SMatthew G. Knepley 
862a6cbbb48SMatthew G. Knepley   Input Parameters:
863a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
864a6cbbb48SMatthew G. Knepley - f - The field number
865a6cbbb48SMatthew G. Knepley 
866a6cbbb48SMatthew G. Knepley   Output Parameter:
867a6cbbb48SMatthew G. Knepley + useCone    - Flag for variable influence starting with the cone operation
868a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
869a6cbbb48SMatthew G. Knepley 
870a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
871a6cbbb48SMatthew G. Knepley 
872a6cbbb48SMatthew G. Knepley   Level: developer
873a6cbbb48SMatthew G. Knepley 
874a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
875a6cbbb48SMatthew G. Knepley @*/
876a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure)
877a6cbbb48SMatthew G. Knepley {
878a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
879a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
880a6cbbb48SMatthew G. Knepley   PetscValidPointer(useCone, 3);
881a6cbbb48SMatthew G. Knepley   PetscValidPointer(useClosure, 4);
882a6cbbb48SMatthew 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);
883a6cbbb48SMatthew G. Knepley   *useCone    = prob->adjacency[f*2+0];
884a6cbbb48SMatthew G. Knepley   *useClosure = prob->adjacency[f*2+1];
885a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
886a6cbbb48SMatthew G. Knepley }
887a6cbbb48SMatthew G. Knepley 
888a6cbbb48SMatthew G. Knepley #undef __FUNCT__
889a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency"
890a6cbbb48SMatthew G. Knepley /*@
891a6cbbb48SMatthew G. Knepley   PetscDSSetAdjacency - Set the flags for determining variable influence
892a6cbbb48SMatthew G. Knepley 
893a6cbbb48SMatthew G. Knepley   Not collective
894a6cbbb48SMatthew G. Knepley 
895a6cbbb48SMatthew G. Knepley   Input Parameters:
896a6cbbb48SMatthew G. Knepley + prob - The PetscDS object
897a6cbbb48SMatthew G. Knepley . f - The field number
898a6cbbb48SMatthew G. Knepley . useCone    - Flag for variable influence starting with the cone operation
899a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure
900a6cbbb48SMatthew G. Knepley 
901a6cbbb48SMatthew G. Knepley   Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure()
902a6cbbb48SMatthew G. Knepley 
903a6cbbb48SMatthew G. Knepley   Level: developer
904a6cbbb48SMatthew G. Knepley 
905a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate()
906a6cbbb48SMatthew G. Knepley @*/
907a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure)
908a6cbbb48SMatthew G. Knepley {
909a6cbbb48SMatthew G. Knepley   PetscFunctionBegin;
910a6cbbb48SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
911a6cbbb48SMatthew 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);
912a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+0] = useCone;
913a6cbbb48SMatthew G. Knepley   prob->adjacency[f*2+1] = useClosure;
914a6cbbb48SMatthew G. Knepley   PetscFunctionReturn(0);
915a6cbbb48SMatthew G. Knepley }
916a6cbbb48SMatthew G. Knepley 
917a6cbbb48SMatthew G. Knepley #undef __FUNCT__
9182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective"
9192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f,
92030b9ff8bSMatthew G. Knepley                                    void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
921194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
922194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
92330b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], PetscScalar obj[]))
9242764a2aaSMatthew G. Knepley {
9252764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9262764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9272764a2aaSMatthew G. Knepley   PetscValidPointer(obj, 2);
9282764a2aaSMatthew 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);
9292764a2aaSMatthew G. Knepley   *obj = prob->obj[f];
9302764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9312764a2aaSMatthew G. Knepley }
9322764a2aaSMatthew G. Knepley 
9332764a2aaSMatthew G. Knepley #undef __FUNCT__
9342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective"
9352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f,
93630b9ff8bSMatthew G. Knepley                                    void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
937194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
938194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
93930b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], PetscScalar obj[]))
9402764a2aaSMatthew G. Knepley {
9412764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9422764a2aaSMatthew G. Knepley 
9432764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9442764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9452764a2aaSMatthew G. Knepley   PetscValidFunction(obj, 2);
9462764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
9472764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
9482764a2aaSMatthew G. Knepley   prob->obj[f] = obj;
9492764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9502764a2aaSMatthew G. Knepley }
9512764a2aaSMatthew G. Knepley 
9522764a2aaSMatthew G. Knepley #undef __FUNCT__
9532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual"
954194d53e6SMatthew G. Knepley /*@C
955194d53e6SMatthew G. Knepley   PetscDSGetResidual - Get the pointwise residual function for a given test field
956194d53e6SMatthew G. Knepley 
957194d53e6SMatthew G. Knepley   Not collective
958194d53e6SMatthew G. Knepley 
959194d53e6SMatthew G. Knepley   Input Parameters:
960194d53e6SMatthew G. Knepley + prob - The PetscDS
961194d53e6SMatthew G. Knepley - f    - The test field number
962194d53e6SMatthew G. Knepley 
963194d53e6SMatthew G. Knepley   Output Parameters:
964194d53e6SMatthew G. Knepley + f0 - integrand for the test function term
965194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
966194d53e6SMatthew G. Knepley 
967194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
968194d53e6SMatthew G. Knepley 
969194d53e6SMatthew 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)
970194d53e6SMatthew G. Knepley 
971194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
972194d53e6SMatthew G. Knepley 
97330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
974194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
975194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
97630b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar f0[])
977194d53e6SMatthew G. Knepley 
978194d53e6SMatthew G. Knepley + dim - the spatial dimension
979194d53e6SMatthew G. Knepley . Nf - the number of fields
980194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
981194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
982194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
983194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
984194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
985194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
986194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
987194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
988194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
989194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
990194d53e6SMatthew G. Knepley . t - current time
991194d53e6SMatthew G. Knepley . x - coordinates of the current point
992194d53e6SMatthew G. Knepley - f0 - output values at the current point
993194d53e6SMatthew G. Knepley 
994194d53e6SMatthew G. Knepley   Level: intermediate
995194d53e6SMatthew G. Knepley 
996194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual()
997194d53e6SMatthew G. Knepley @*/
9982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f,
99930b9ff8bSMatthew G. Knepley                                   void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1000194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1001194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
100230b9ff8bSMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar f0[]),
100330b9ff8bSMatthew G. Knepley                                   void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1004194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1005194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
100630b9ff8bSMatthew G. Knepley                                               PetscReal t, const PetscReal x[], PetscScalar f1[]))
10072764a2aaSMatthew G. Knepley {
10082764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10092764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
10102764a2aaSMatthew 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);
10112764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];}
10122764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];}
10132764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10142764a2aaSMatthew G. Knepley }
10152764a2aaSMatthew G. Knepley 
10162764a2aaSMatthew G. Knepley #undef __FUNCT__
10172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual"
1018194d53e6SMatthew G. Knepley /*@C
1019194d53e6SMatthew G. Knepley   PetscDSSetResidual - Set the pointwise residual function for a given test field
1020194d53e6SMatthew G. Knepley 
1021194d53e6SMatthew G. Knepley   Not collective
1022194d53e6SMatthew G. Knepley 
1023194d53e6SMatthew G. Knepley   Input Parameters:
1024194d53e6SMatthew G. Knepley + prob - The PetscDS
1025194d53e6SMatthew G. Knepley . f    - The test field number
1026194d53e6SMatthew G. Knepley . f0 - integrand for the test function term
1027194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term
1028194d53e6SMatthew G. Knepley 
1029194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1030194d53e6SMatthew G. Knepley 
1031194d53e6SMatthew 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)
1032194d53e6SMatthew G. Knepley 
1033194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1034194d53e6SMatthew G. Knepley 
103530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1036194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1037194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
103830b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar f0[])
1039194d53e6SMatthew G. Knepley 
1040194d53e6SMatthew G. Knepley + dim - the spatial dimension
1041194d53e6SMatthew G. Knepley . Nf - the number of fields
1042194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1043194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1044194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1045194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1046194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1047194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1048194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1049194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1050194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1051194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1052194d53e6SMatthew G. Knepley . t - current time
1053194d53e6SMatthew G. Knepley . x - coordinates of the current point
1054194d53e6SMatthew G. Knepley - f0 - output values at the current point
1055194d53e6SMatthew G. Knepley 
1056194d53e6SMatthew G. Knepley   Level: intermediate
1057194d53e6SMatthew G. Knepley 
1058194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual()
1059194d53e6SMatthew G. Knepley @*/
10602764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f,
106130b9ff8bSMatthew G. Knepley                                   void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1062194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1063194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
106430b9ff8bSMatthew G. Knepley                                              PetscReal t, const PetscReal x[], PetscScalar f0[]),
106530b9ff8bSMatthew G. Knepley                                   void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1066194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1067194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
106830b9ff8bSMatthew G. Knepley                                              PetscReal t, const PetscReal x[], PetscScalar f1[]))
10692764a2aaSMatthew G. Knepley {
10702764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
10712764a2aaSMatthew G. Knepley 
10722764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10732764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1074f866a1d0SMatthew G. Knepley   if (f0) PetscValidFunction(f0, 3);
1075f866a1d0SMatthew G. Knepley   if (f1) PetscValidFunction(f1, 4);
10762764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
10772764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
10782764a2aaSMatthew G. Knepley   prob->f[f*2+0] = f0;
10792764a2aaSMatthew G. Knepley   prob->f[f*2+1] = f1;
10802764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10812764a2aaSMatthew G. Knepley }
10822764a2aaSMatthew G. Knepley 
10832764a2aaSMatthew G. Knepley #undef __FUNCT__
10842764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian"
1085194d53e6SMatthew G. Knepley /*@C
1086194d53e6SMatthew G. Knepley   PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field
1087194d53e6SMatthew G. Knepley 
1088194d53e6SMatthew G. Knepley   Not collective
1089194d53e6SMatthew G. Knepley 
1090194d53e6SMatthew G. Knepley   Input Parameters:
1091194d53e6SMatthew G. Knepley + prob - The PetscDS
1092194d53e6SMatthew G. Knepley . f    - The test field number
1093194d53e6SMatthew G. Knepley - g    - The field number
1094194d53e6SMatthew G. Knepley 
1095194d53e6SMatthew G. Knepley   Output Parameters:
1096194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1097194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1098194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1099194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1100194d53e6SMatthew G. Knepley 
1101194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1102194d53e6SMatthew G. Knepley 
1103194d53e6SMatthew 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
1104194d53e6SMatthew G. Knepley 
1105194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1106194d53e6SMatthew G. Knepley 
110730b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1108194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1109194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
111030b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[])
1111194d53e6SMatthew G. Knepley 
1112194d53e6SMatthew G. Knepley + dim - the spatial dimension
1113194d53e6SMatthew G. Knepley . Nf - the number of fields
1114194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1115194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1116194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1117194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1118194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1119194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1120194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1121194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1122194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1123194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1124194d53e6SMatthew G. Knepley . t - current time
11252aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1126194d53e6SMatthew G. Knepley . x - coordinates of the current point
1127194d53e6SMatthew G. Knepley - g0 - output values at the current point
1128194d53e6SMatthew G. Knepley 
1129194d53e6SMatthew G. Knepley   Level: intermediate
1130194d53e6SMatthew G. Knepley 
1131194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian()
1132194d53e6SMatthew G. Knepley @*/
11332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g,
113430b9ff8bSMatthew G. Knepley                                   void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1135194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1136194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11372aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
113830b9ff8bSMatthew G. Knepley                                   void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1139194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1140194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11412aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
114230b9ff8bSMatthew G. Knepley                                   void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1143194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1144194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11452aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
114630b9ff8bSMatthew G. Knepley                                   void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1147194d53e6SMatthew G. Knepley                                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1148194d53e6SMatthew G. Knepley                                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
11492aa1fc23SMatthew G. Knepley                                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
11502764a2aaSMatthew G. Knepley {
11512764a2aaSMatthew G. Knepley   PetscFunctionBegin;
11522764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
11532764a2aaSMatthew 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);
11542764a2aaSMatthew 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);
11552764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];}
11562764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];}
11572764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];}
11582764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];}
11592764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
11602764a2aaSMatthew G. Knepley }
11612764a2aaSMatthew G. Knepley 
11622764a2aaSMatthew G. Knepley #undef __FUNCT__
11632764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian"
1164194d53e6SMatthew G. Knepley /*@C
1165194d53e6SMatthew G. Knepley   PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields
1166194d53e6SMatthew G. Knepley 
1167194d53e6SMatthew G. Knepley   Not collective
1168194d53e6SMatthew G. Knepley 
1169194d53e6SMatthew G. Knepley   Input Parameters:
1170194d53e6SMatthew G. Knepley + prob - The PetscDS
1171194d53e6SMatthew G. Knepley . f    - The test field number
1172194d53e6SMatthew G. Knepley . g    - The field number
1173194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
1174194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1175194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1176194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1177194d53e6SMatthew G. Knepley 
1178194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1179194d53e6SMatthew G. Knepley 
1180194d53e6SMatthew 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
1181194d53e6SMatthew G. Knepley 
1182194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1183194d53e6SMatthew G. Knepley 
118430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1185194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1186194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
118730b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], PetscScalar g0[])
1188194d53e6SMatthew G. Knepley 
1189194d53e6SMatthew G. Knepley + dim - the spatial dimension
1190194d53e6SMatthew G. Knepley . Nf - the number of fields
1191194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1192194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1193194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1194194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1195194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1196194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1197194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1198194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1199194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1200194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1201194d53e6SMatthew G. Knepley . t - current time
12022aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1203194d53e6SMatthew G. Knepley . x - coordinates of the current point
1204194d53e6SMatthew G. Knepley - g0 - output values at the current point
1205194d53e6SMatthew G. Knepley 
1206194d53e6SMatthew G. Knepley   Level: intermediate
1207194d53e6SMatthew G. Knepley 
1208194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian()
1209194d53e6SMatthew G. Knepley @*/
12102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g,
121130b9ff8bSMatthew G. Knepley                                   void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1212194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1213194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
121430b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]),
121530b9ff8bSMatthew G. Knepley                                   void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1216194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1217194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
121830b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]),
121930b9ff8bSMatthew G. Knepley                                   void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1220194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1221194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
122230b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]),
122330b9ff8bSMatthew G. Knepley                                   void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1224194d53e6SMatthew G. Knepley                                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1225194d53e6SMatthew G. Knepley                                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
122630b9ff8bSMatthew G. Knepley                                              PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[]))
12272764a2aaSMatthew G. Knepley {
12282764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
12292764a2aaSMatthew G. Knepley 
12302764a2aaSMatthew G. Knepley   PetscFunctionBegin;
12312764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
12322764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
12332764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
12342764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
12352764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
12362764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
12372764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
12382764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
12392764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+0] = g0;
12402764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+1] = g1;
12412764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+2] = g2;
12422764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+3] = g3;
12432764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
12442764a2aaSMatthew G. Knepley }
12452764a2aaSMatthew G. Knepley 
12462764a2aaSMatthew G. Knepley #undef __FUNCT__
12470c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver"
12480c2f2876SMatthew G. Knepley /*@C
12490c2f2876SMatthew G. Knepley   PetscDSGetRiemannSolver - Returns the Riemann solver for the given field
12500c2f2876SMatthew G. Knepley 
12510c2f2876SMatthew G. Knepley   Not collective
12520c2f2876SMatthew G. Knepley 
12530c2f2876SMatthew G. Knepley   Input Arguments:
12540c2f2876SMatthew G. Knepley + prob - The PetscDS object
12550c2f2876SMatthew G. Knepley - f    - The field number
12560c2f2876SMatthew G. Knepley 
12570c2f2876SMatthew G. Knepley   Output Argument:
12580c2f2876SMatthew G. Knepley . r    - Riemann solver
12590c2f2876SMatthew G. Knepley 
12600c2f2876SMatthew G. Knepley   Calling sequence for r:
12610c2f2876SMatthew G. Knepley 
12625db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
12630c2f2876SMatthew G. Knepley 
12645db36cf9SMatthew G. Knepley + dim  - The spatial dimension
12655db36cf9SMatthew G. Knepley . Nf   - The number of fields
12665db36cf9SMatthew G. Knepley . x    - The coordinates at a point on the interface
12670c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
12680c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
12690c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
12700c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
12710c2f2876SMatthew G. Knepley - ctx  - optional user context
12720c2f2876SMatthew G. Knepley 
12730c2f2876SMatthew G. Knepley   Level: intermediate
12740c2f2876SMatthew G. Knepley 
12750c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver()
12760c2f2876SMatthew G. Knepley @*/
12770c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f,
12785db36cf9SMatthew G. Knepley                                        void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
12790c2f2876SMatthew G. Knepley {
12800c2f2876SMatthew G. Knepley   PetscFunctionBegin;
12810c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
12820c2f2876SMatthew 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);
12830c2f2876SMatthew G. Knepley   PetscValidPointer(r, 3);
12840c2f2876SMatthew G. Knepley   *r = prob->r[f];
12850c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
12860c2f2876SMatthew G. Knepley }
12870c2f2876SMatthew G. Knepley 
12880c2f2876SMatthew G. Knepley #undef __FUNCT__
12890c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver"
12900c2f2876SMatthew G. Knepley /*@C
12910c2f2876SMatthew G. Knepley   PetscDSSetRiemannSolver - Sets the Riemann solver for the given field
12920c2f2876SMatthew G. Knepley 
12930c2f2876SMatthew G. Knepley   Not collective
12940c2f2876SMatthew G. Knepley 
12950c2f2876SMatthew G. Knepley   Input Arguments:
12960c2f2876SMatthew G. Knepley + prob - The PetscDS object
12970c2f2876SMatthew G. Knepley . f    - The field number
12980c2f2876SMatthew G. Knepley - r    - Riemann solver
12990c2f2876SMatthew G. Knepley 
13000c2f2876SMatthew G. Knepley   Calling sequence for r:
13010c2f2876SMatthew G. Knepley 
13025db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
13030c2f2876SMatthew G. Knepley 
13045db36cf9SMatthew G. Knepley + dim  - The spatial dimension
13055db36cf9SMatthew G. Knepley . Nf   - The number of fields
13065db36cf9SMatthew G. Knepley . x    - The coordinates at a point on the interface
13070c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
13080c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
13090c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
13100c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
13110c2f2876SMatthew G. Knepley - ctx  - optional user context
13120c2f2876SMatthew G. Knepley 
13130c2f2876SMatthew G. Knepley   Level: intermediate
13140c2f2876SMatthew G. Knepley 
13150c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver()
13160c2f2876SMatthew G. Knepley @*/
13170c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f,
13185db36cf9SMatthew G. Knepley                                        void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
13190c2f2876SMatthew G. Knepley {
13200c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
13210c2f2876SMatthew G. Knepley 
13220c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13230c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13240c2f2876SMatthew G. Knepley   PetscValidFunction(r, 3);
13250c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
13260c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
13270c2f2876SMatthew G. Knepley   prob->r[f] = r;
13280c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13290c2f2876SMatthew G. Knepley }
13300c2f2876SMatthew G. Knepley 
13310c2f2876SMatthew G. Knepley #undef __FUNCT__
13320c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext"
13330c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx)
13340c2f2876SMatthew G. Knepley {
13350c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13360c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13370c2f2876SMatthew 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);
13380c2f2876SMatthew G. Knepley   PetscValidPointer(ctx, 3);
13390c2f2876SMatthew G. Knepley   *ctx = prob->ctx[f];
13400c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13410c2f2876SMatthew G. Knepley }
13420c2f2876SMatthew G. Knepley 
13430c2f2876SMatthew G. Knepley #undef __FUNCT__
13440c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext"
13450c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx)
13460c2f2876SMatthew G. Knepley {
13470c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
13480c2f2876SMatthew G. Knepley 
13490c2f2876SMatthew G. Knepley   PetscFunctionBegin;
13500c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
13510c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
13520c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
13530c2f2876SMatthew G. Knepley   prob->ctx[f] = ctx;
13540c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
13550c2f2876SMatthew G. Knepley }
13560c2f2876SMatthew G. Knepley 
13570c2f2876SMatthew G. Knepley #undef __FUNCT__
13582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual"
1359194d53e6SMatthew G. Knepley /*@C
1360194d53e6SMatthew G. Knepley   PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field
1361194d53e6SMatthew G. Knepley 
1362194d53e6SMatthew G. Knepley   Not collective
1363194d53e6SMatthew G. Knepley 
1364194d53e6SMatthew G. Knepley   Input Parameters:
1365194d53e6SMatthew G. Knepley + prob - The PetscDS
1366194d53e6SMatthew G. Knepley - f    - The test field number
1367194d53e6SMatthew G. Knepley 
1368194d53e6SMatthew G. Knepley   Output Parameters:
1369194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term
1370194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1371194d53e6SMatthew G. Knepley 
1372194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1373194d53e6SMatthew G. Knepley 
1374194d53e6SMatthew 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
1375194d53e6SMatthew G. Knepley 
1376194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1377194d53e6SMatthew G. Knepley 
137830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1379194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1380194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
138130b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1382194d53e6SMatthew G. Knepley 
1383194d53e6SMatthew G. Knepley + dim - the spatial dimension
1384194d53e6SMatthew G. Knepley . Nf - the number of fields
1385194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1386194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1387194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1388194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1389194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1390194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1391194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1392194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1393194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1394194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1395194d53e6SMatthew G. Knepley . t - current time
1396194d53e6SMatthew G. Knepley . x - coordinates of the current point
1397194d53e6SMatthew G. Knepley . n - unit normal at the current point
1398194d53e6SMatthew G. Knepley - f0 - output values at the current point
1399194d53e6SMatthew G. Knepley 
1400194d53e6SMatthew G. Knepley   Level: intermediate
1401194d53e6SMatthew G. Knepley 
1402194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual()
1403194d53e6SMatthew G. Knepley @*/
14042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f,
140530b9ff8bSMatthew G. Knepley                                     void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1406194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1407194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
140830b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
140930b9ff8bSMatthew G. Knepley                                     void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1410194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1411194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
141230b9ff8bSMatthew G. Knepley                                                 PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
14132764a2aaSMatthew G. Knepley {
14142764a2aaSMatthew G. Knepley   PetscFunctionBegin;
14152764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
14162764a2aaSMatthew 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);
14172764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];}
14182764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];}
14192764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
14202764a2aaSMatthew G. Knepley }
14212764a2aaSMatthew G. Knepley 
14222764a2aaSMatthew G. Knepley #undef __FUNCT__
14232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual"
1424194d53e6SMatthew G. Knepley /*@C
1425194d53e6SMatthew G. Knepley   PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field
1426194d53e6SMatthew G. Knepley 
1427194d53e6SMatthew G. Knepley   Not collective
1428194d53e6SMatthew G. Knepley 
1429194d53e6SMatthew G. Knepley   Input Parameters:
1430194d53e6SMatthew G. Knepley + prob - The PetscDS
1431194d53e6SMatthew G. Knepley . f    - The test field number
1432194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term
1433194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term
1434194d53e6SMatthew G. Knepley 
1435194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1436194d53e6SMatthew G. Knepley 
1437194d53e6SMatthew 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
1438194d53e6SMatthew G. Knepley 
1439194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by:
1440194d53e6SMatthew G. Knepley 
144130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1442194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1443194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
144430b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[])
1445194d53e6SMatthew G. Knepley 
1446194d53e6SMatthew G. Knepley + dim - the spatial dimension
1447194d53e6SMatthew G. Knepley . Nf - the number of fields
1448194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1449194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1450194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1451194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1452194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1453194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1454194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1455194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1456194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1457194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1458194d53e6SMatthew G. Knepley . t - current time
1459194d53e6SMatthew G. Knepley . x - coordinates of the current point
1460194d53e6SMatthew G. Knepley . n - unit normal at the current point
1461194d53e6SMatthew G. Knepley - f0 - output values at the current point
1462194d53e6SMatthew G. Knepley 
1463194d53e6SMatthew G. Knepley   Level: intermediate
1464194d53e6SMatthew G. Knepley 
1465194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual()
1466194d53e6SMatthew G. Knepley @*/
14672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f,
146830b9ff8bSMatthew G. Knepley                                     void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1469194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1470194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
147130b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
147230b9ff8bSMatthew G. Knepley                                     void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1473194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1474194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
147530b9ff8bSMatthew G. Knepley                                                PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
14762764a2aaSMatthew G. Knepley {
14772764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
14782764a2aaSMatthew G. Knepley 
14792764a2aaSMatthew G. Knepley   PetscFunctionBegin;
14802764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
14812764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
14822764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
14832764a2aaSMatthew G. Knepley   if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;}
14842764a2aaSMatthew G. Knepley   if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;}
14852764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
14862764a2aaSMatthew G. Knepley }
14872764a2aaSMatthew G. Knepley 
14882764a2aaSMatthew G. Knepley #undef __FUNCT__
14892764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian"
1490194d53e6SMatthew G. Knepley /*@C
1491194d53e6SMatthew G. Knepley   PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field
1492194d53e6SMatthew G. Knepley 
1493194d53e6SMatthew G. Knepley   Not collective
1494194d53e6SMatthew G. Knepley 
1495194d53e6SMatthew G. Knepley   Input Parameters:
1496194d53e6SMatthew G. Knepley + prob - The PetscDS
1497194d53e6SMatthew G. Knepley . f    - The test field number
1498194d53e6SMatthew G. Knepley - g    - The field number
1499194d53e6SMatthew G. Knepley 
1500194d53e6SMatthew G. Knepley   Output Parameters:
1501194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term
1502194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1503194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1504194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1505194d53e6SMatthew G. Knepley 
1506194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1507194d53e6SMatthew G. Knepley 
1508194d53e6SMatthew 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
1509194d53e6SMatthew G. Knepley 
1510194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1511194d53e6SMatthew G. Knepley 
151230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1513194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1514194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
151530b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
1516194d53e6SMatthew G. Knepley 
1517194d53e6SMatthew G. Knepley + dim - the spatial dimension
1518194d53e6SMatthew G. Knepley . Nf - the number of fields
1519194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1520194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1521194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1522194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1523194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1524194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1525194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1526194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1527194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1528194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1529194d53e6SMatthew G. Knepley . t - current time
15302aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1531194d53e6SMatthew G. Knepley . x - coordinates of the current point
1532194d53e6SMatthew G. Knepley . n - normal at the current point
1533194d53e6SMatthew G. Knepley - g0 - output values at the current point
1534194d53e6SMatthew G. Knepley 
1535194d53e6SMatthew G. Knepley   Level: intermediate
1536194d53e6SMatthew G. Knepley 
1537194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian()
1538194d53e6SMatthew G. Knepley @*/
15392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
154030b9ff8bSMatthew G. Knepley                                     void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1541194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1542194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
15432aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
154430b9ff8bSMatthew G. Knepley                                     void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1545194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1546194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
15472aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
154830b9ff8bSMatthew G. Knepley                                     void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1549194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1550194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
15512aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
155230b9ff8bSMatthew G. Knepley                                     void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1553194d53e6SMatthew G. Knepley                                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1554194d53e6SMatthew G. Knepley                                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
15552aa1fc23SMatthew G. Knepley                                                 PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
15562764a2aaSMatthew G. Knepley {
15572764a2aaSMatthew G. Knepley   PetscFunctionBegin;
15582764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
15592764a2aaSMatthew 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);
15602764a2aaSMatthew 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);
15612764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];}
15622764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];}
15632764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];}
15642764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];}
15652764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
15662764a2aaSMatthew G. Knepley }
15672764a2aaSMatthew G. Knepley 
15682764a2aaSMatthew G. Knepley #undef __FUNCT__
15692764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian"
1570194d53e6SMatthew G. Knepley /*@C
1571194d53e6SMatthew G. Knepley   PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field
1572194d53e6SMatthew G. Knepley 
1573194d53e6SMatthew G. Knepley   Not collective
1574194d53e6SMatthew G. Knepley 
1575194d53e6SMatthew G. Knepley   Input Parameters:
1576194d53e6SMatthew G. Knepley + prob - The PetscDS
1577194d53e6SMatthew G. Knepley . f    - The test field number
1578194d53e6SMatthew G. Knepley . g    - The field number
1579194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term
1580194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term
1581194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term
1582194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term
1583194d53e6SMatthew G. Knepley 
1584194d53e6SMatthew G. Knepley   Note: We are using a first order FEM model for the weak form:
1585194d53e6SMatthew G. Knepley 
1586194d53e6SMatthew 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
1587194d53e6SMatthew G. Knepley 
1588194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by:
1589194d53e6SMatthew G. Knepley 
159030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1591194d53e6SMatthew G. Knepley $    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1592194d53e6SMatthew G. Knepley $    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
159330b9ff8bSMatthew G. Knepley $    PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[])
1594194d53e6SMatthew G. Knepley 
1595194d53e6SMatthew G. Knepley + dim - the spatial dimension
1596194d53e6SMatthew G. Knepley . Nf - the number of fields
1597194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field
1598194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field
1599194d53e6SMatthew G. Knepley . u - each field evaluated at the current point
1600194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point
1601194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point
1602194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field
1603194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field
1604194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point
1605194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point
1606194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point
1607194d53e6SMatthew G. Knepley . t - current time
16082aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t
1609194d53e6SMatthew G. Knepley . x - coordinates of the current point
1610194d53e6SMatthew G. Knepley . n - normal at the current point
1611194d53e6SMatthew G. Knepley - g0 - output values at the current point
1612194d53e6SMatthew G. Knepley 
1613194d53e6SMatthew G. Knepley   Level: intermediate
1614194d53e6SMatthew G. Knepley 
1615194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian()
1616194d53e6SMatthew G. Knepley @*/
16172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
161830b9ff8bSMatthew G. Knepley                                     void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1619194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1620194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
16212aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
162230b9ff8bSMatthew G. Knepley                                     void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1623194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1624194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
16252aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
162630b9ff8bSMatthew G. Knepley                                     void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1627194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1628194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
16292aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
163030b9ff8bSMatthew G. Knepley                                     void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux,
1631194d53e6SMatthew G. Knepley                                                const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
1632194d53e6SMatthew G. Knepley                                                const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
16332aa1fc23SMatthew G. Knepley                                                PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
16342764a2aaSMatthew G. Knepley {
16352764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
16362764a2aaSMatthew G. Knepley 
16372764a2aaSMatthew G. Knepley   PetscFunctionBegin;
16382764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
16392764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
16402764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
16412764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
16422764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
16432764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
16442764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
16452764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
16462764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+0] = g0;
16472764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+1] = g1;
16482764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+2] = g2;
16492764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+3] = g3;
16502764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
16512764a2aaSMatthew G. Knepley }
16522764a2aaSMatthew G. Knepley 
16532764a2aaSMatthew G. Knepley #undef __FUNCT__
16542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset"
1655bc4ae4beSMatthew G. Knepley /*@
1656bc4ae4beSMatthew G. Knepley   PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis
1657bc4ae4beSMatthew G. Knepley 
1658bc4ae4beSMatthew G. Knepley   Not collective
1659bc4ae4beSMatthew G. Knepley 
1660bc4ae4beSMatthew G. Knepley   Input Parameters:
1661bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
1662bc4ae4beSMatthew G. Knepley - f - The field number
1663bc4ae4beSMatthew G. Knepley 
1664bc4ae4beSMatthew G. Knepley   Output Parameter:
1665bc4ae4beSMatthew G. Knepley . off - The offset
1666bc4ae4beSMatthew G. Knepley 
1667bc4ae4beSMatthew G. Knepley   Level: beginner
1668bc4ae4beSMatthew G. Knepley 
1669bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1670bc4ae4beSMatthew G. Knepley @*/
16712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
16722764a2aaSMatthew G. Knepley {
16732764a2aaSMatthew G. Knepley   PetscInt       g;
16742764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
16752764a2aaSMatthew G. Knepley 
16762764a2aaSMatthew G. Knepley   PetscFunctionBegin;
16772764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
16782764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
16792764a2aaSMatthew 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);
16802764a2aaSMatthew G. Knepley   *off = 0;
16812764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
16822764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
16832764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
16842764a2aaSMatthew G. Knepley 
16852764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
16862764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
16872764a2aaSMatthew G. Knepley     *off += Nb*Nc;
16882764a2aaSMatthew G. Knepley   }
16892764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
16902764a2aaSMatthew G. Knepley }
16912764a2aaSMatthew G. Knepley 
16922764a2aaSMatthew G. Knepley #undef __FUNCT__
16932764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset"
1694bc4ae4beSMatthew G. Knepley /*@
1695c3ac4435SMatthew G. Knepley   PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis
1696bc4ae4beSMatthew G. Knepley 
1697bc4ae4beSMatthew G. Knepley   Not collective
1698bc4ae4beSMatthew G. Knepley 
1699bc4ae4beSMatthew G. Knepley   Input Parameters:
1700bc4ae4beSMatthew G. Knepley + prob - The PetscDS object
1701bc4ae4beSMatthew G. Knepley - f - The field number
1702bc4ae4beSMatthew G. Knepley 
1703bc4ae4beSMatthew G. Knepley   Output Parameter:
1704bc4ae4beSMatthew G. Knepley . off - The boundary offset
1705bc4ae4beSMatthew G. Knepley 
1706bc4ae4beSMatthew G. Knepley   Level: beginner
1707bc4ae4beSMatthew G. Knepley 
1708bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1709bc4ae4beSMatthew G. Knepley @*/
17102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
17112764a2aaSMatthew G. Knepley {
17122764a2aaSMatthew G. Knepley   PetscInt       g;
17132764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
17142764a2aaSMatthew G. Knepley 
17152764a2aaSMatthew G. Knepley   PetscFunctionBegin;
17162764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17172764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
17182764a2aaSMatthew 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);
17192764a2aaSMatthew G. Knepley   *off = 0;
17202764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
17212764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->discBd[g];
17222764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
17232764a2aaSMatthew G. Knepley 
17242764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
17252764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
17262764a2aaSMatthew G. Knepley     *off += Nb*Nc;
17276ce16762SMatthew G. Knepley   }
17286ce16762SMatthew G. Knepley   PetscFunctionReturn(0);
17296ce16762SMatthew G. Knepley }
17306ce16762SMatthew G. Knepley 
17316ce16762SMatthew G. Knepley #undef __FUNCT__
17326ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset"
17336ce16762SMatthew G. Knepley /*@
17346ce16762SMatthew G. Knepley   PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point
17356ce16762SMatthew G. Knepley 
17366ce16762SMatthew G. Knepley   Not collective
17376ce16762SMatthew G. Knepley 
17386ce16762SMatthew G. Knepley   Input Parameters:
17396ce16762SMatthew G. Knepley + prob - The PetscDS object
17406ce16762SMatthew G. Knepley - f - The field number
17416ce16762SMatthew G. Knepley 
17426ce16762SMatthew G. Knepley   Output Parameter:
17436ce16762SMatthew G. Knepley . off - The offset
17446ce16762SMatthew G. Knepley 
17456ce16762SMatthew G. Knepley   Level: beginner
17466ce16762SMatthew G. Knepley 
17476ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
17486ce16762SMatthew G. Knepley @*/
17496ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off)
17506ce16762SMatthew G. Knepley {
17516ce16762SMatthew G. Knepley   PetscInt       g;
17526ce16762SMatthew G. Knepley   PetscErrorCode ierr;
17536ce16762SMatthew G. Knepley 
17546ce16762SMatthew G. Knepley   PetscFunctionBegin;
17556ce16762SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
17566ce16762SMatthew G. Knepley   PetscValidPointer(off, 3);
17576ce16762SMatthew 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);
17586ce16762SMatthew G. Knepley   *off = 0;
17596ce16762SMatthew G. Knepley   for (g = 0; g < f; ++g) {
17606ce16762SMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
17616ce16762SMatthew G. Knepley     PetscInt Nc;
17626ce16762SMatthew G. Knepley 
17636ce16762SMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
17646ce16762SMatthew G. Knepley     *off += Nc;
17652764a2aaSMatthew G. Knepley   }
17662764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
17672764a2aaSMatthew G. Knepley }
17682764a2aaSMatthew G. Knepley 
17692764a2aaSMatthew G. Knepley #undef __FUNCT__
1770194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets"
1771194d53e6SMatthew G. Knepley /*@
1772194d53e6SMatthew G. Knepley   PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point
1773194d53e6SMatthew G. Knepley 
1774194d53e6SMatthew G. Knepley   Not collective
1775194d53e6SMatthew G. Knepley 
1776194d53e6SMatthew G. Knepley   Input Parameter:
1777194d53e6SMatthew G. Knepley . prob - The PetscDS object
1778194d53e6SMatthew G. Knepley 
1779194d53e6SMatthew G. Knepley   Output Parameter:
1780194d53e6SMatthew G. Knepley . offsets - The offsets
1781194d53e6SMatthew G. Knepley 
1782194d53e6SMatthew G. Knepley   Level: beginner
1783194d53e6SMatthew G. Knepley 
1784194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1785194d53e6SMatthew G. Knepley @*/
1786194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[])
1787194d53e6SMatthew G. Knepley {
1788194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1789194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1790194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1791194d53e6SMatthew G. Knepley   *offsets = prob->off;
1792194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1793194d53e6SMatthew G. Knepley }
1794194d53e6SMatthew G. Knepley 
1795194d53e6SMatthew G. Knepley #undef __FUNCT__
1796194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets"
1797194d53e6SMatthew G. Knepley /*@
1798194d53e6SMatthew G. Knepley   PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point
1799194d53e6SMatthew G. Knepley 
1800194d53e6SMatthew G. Knepley   Not collective
1801194d53e6SMatthew G. Knepley 
1802194d53e6SMatthew G. Knepley   Input Parameter:
1803194d53e6SMatthew G. Knepley . prob - The PetscDS object
1804194d53e6SMatthew G. Knepley 
1805194d53e6SMatthew G. Knepley   Output Parameter:
1806194d53e6SMatthew G. Knepley . offsets - The offsets
1807194d53e6SMatthew G. Knepley 
1808194d53e6SMatthew G. Knepley   Level: beginner
1809194d53e6SMatthew G. Knepley 
1810194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1811194d53e6SMatthew G. Knepley @*/
1812194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
1813194d53e6SMatthew G. Knepley {
1814194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1815194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1816194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1817194d53e6SMatthew G. Knepley   *offsets = prob->offDer;
1818194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1819194d53e6SMatthew G. Knepley }
1820194d53e6SMatthew G. Knepley 
1821194d53e6SMatthew G. Knepley #undef __FUNCT__
1822194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets"
1823194d53e6SMatthew G. Knepley /*@
1824194d53e6SMatthew G. Knepley   PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point
1825194d53e6SMatthew G. Knepley 
1826194d53e6SMatthew G. Knepley   Not collective
1827194d53e6SMatthew G. Knepley 
1828194d53e6SMatthew G. Knepley   Input Parameter:
1829194d53e6SMatthew G. Knepley . prob - The PetscDS object
1830194d53e6SMatthew G. Knepley 
1831194d53e6SMatthew G. Knepley   Output Parameter:
1832194d53e6SMatthew G. Knepley . offsets - The offsets
1833194d53e6SMatthew G. Knepley 
1834194d53e6SMatthew G. Knepley   Level: beginner
1835194d53e6SMatthew G. Knepley 
1836194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1837194d53e6SMatthew G. Knepley @*/
1838194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[])
1839194d53e6SMatthew G. Knepley {
1840194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1841194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1842194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1843194d53e6SMatthew G. Knepley   *offsets = prob->offBd;
1844194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1845194d53e6SMatthew G. Knepley }
1846194d53e6SMatthew G. Knepley 
1847194d53e6SMatthew G. Knepley #undef __FUNCT__
1848194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets"
1849194d53e6SMatthew G. Knepley /*@
1850194d53e6SMatthew G. Knepley   PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point
1851194d53e6SMatthew G. Knepley 
1852194d53e6SMatthew G. Knepley   Not collective
1853194d53e6SMatthew G. Knepley 
1854194d53e6SMatthew G. Knepley   Input Parameter:
1855194d53e6SMatthew G. Knepley . prob - The PetscDS object
1856194d53e6SMatthew G. Knepley 
1857194d53e6SMatthew G. Knepley   Output Parameter:
1858194d53e6SMatthew G. Knepley . offsets - The offsets
1859194d53e6SMatthew G. Knepley 
1860194d53e6SMatthew G. Knepley   Level: beginner
1861194d53e6SMatthew G. Knepley 
1862194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate()
1863194d53e6SMatthew G. Knepley @*/
1864194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[])
1865194d53e6SMatthew G. Knepley {
1866194d53e6SMatthew G. Knepley   PetscFunctionBegin;
1867194d53e6SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1868194d53e6SMatthew G. Knepley   PetscValidPointer(offsets, 2);
1869194d53e6SMatthew G. Knepley   *offsets = prob->offDerBd;
1870194d53e6SMatthew G. Knepley   PetscFunctionReturn(0);
1871194d53e6SMatthew G. Knepley }
1872194d53e6SMatthew G. Knepley 
1873194d53e6SMatthew G. Knepley #undef __FUNCT__
18742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation"
187568c9edb9SMatthew G. Knepley /*@C
187668c9edb9SMatthew G. Knepley   PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization
187768c9edb9SMatthew G. Knepley 
187868c9edb9SMatthew G. Knepley   Not collective
187968c9edb9SMatthew G. Knepley 
188068c9edb9SMatthew G. Knepley   Input Parameter:
188168c9edb9SMatthew G. Knepley . prob - The PetscDS object
188268c9edb9SMatthew G. Knepley 
188368c9edb9SMatthew G. Knepley   Output Parameters:
188468c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
188568c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
188668c9edb9SMatthew G. Knepley 
188768c9edb9SMatthew G. Knepley   Level: intermediate
188868c9edb9SMatthew G. Knepley 
188968c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate()
189068c9edb9SMatthew G. Knepley @*/
18912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
18922764a2aaSMatthew G. Knepley {
18932764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
18942764a2aaSMatthew G. Knepley 
18952764a2aaSMatthew G. Knepley   PetscFunctionBegin;
18962764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
18972764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
18982764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basis;}
18992764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;}
19002764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19012764a2aaSMatthew G. Knepley }
19022764a2aaSMatthew G. Knepley 
19032764a2aaSMatthew G. Knepley #undef __FUNCT__
19042764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation"
190568c9edb9SMatthew G. Knepley /*@C
190668c9edb9SMatthew G. Knepley   PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization
190768c9edb9SMatthew G. Knepley 
190868c9edb9SMatthew G. Knepley   Not collective
190968c9edb9SMatthew G. Knepley 
191068c9edb9SMatthew G. Knepley   Input Parameter:
191168c9edb9SMatthew G. Knepley . prob - The PetscDS object
191268c9edb9SMatthew G. Knepley 
191368c9edb9SMatthew G. Knepley   Output Parameters:
191468c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points
191568c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points
191668c9edb9SMatthew G. Knepley 
191768c9edb9SMatthew G. Knepley   Level: intermediate
191868c9edb9SMatthew G. Knepley 
191968c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate()
192068c9edb9SMatthew G. Knepley @*/
19212764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
19222764a2aaSMatthew G. Knepley {
19232764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19242764a2aaSMatthew G. Knepley 
19252764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19262764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19272764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19282764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basisBd;}
19292764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;}
19302764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19312764a2aaSMatthew G. Knepley }
19322764a2aaSMatthew G. Knepley 
19332764a2aaSMatthew G. Knepley #undef __FUNCT__
19342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays"
19352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x)
19362764a2aaSMatthew G. Knepley {
19372764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19382764a2aaSMatthew G. Knepley 
19392764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19402764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19412764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19422764a2aaSMatthew G. Knepley   if (u)   {PetscValidPointer(u, 2);   *u   = prob->u;}
19432764a2aaSMatthew G. Knepley   if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;}
19442764a2aaSMatthew G. Knepley   if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;}
19452764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19462764a2aaSMatthew G. Knepley }
19472764a2aaSMatthew G. Knepley 
19482764a2aaSMatthew G. Knepley #undef __FUNCT__
19492764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays"
19502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3)
19512764a2aaSMatthew G. Knepley {
19522764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19532764a2aaSMatthew G. Knepley 
19542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19562764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19572764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;}
19582764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;}
19592764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;}
19602764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;}
19612764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;}
19622764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;}
19632764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19642764a2aaSMatthew G. Knepley }
19652764a2aaSMatthew G. Knepley 
19662764a2aaSMatthew G. Knepley #undef __FUNCT__
19672764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays"
19682764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer)
19692764a2aaSMatthew G. Knepley {
19702764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
19712764a2aaSMatthew G. Knepley 
19722764a2aaSMatthew G. Knepley   PetscFunctionBegin;
19732764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
19742764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
19752764a2aaSMatthew G. Knepley   if (x)           {PetscValidPointer(x, 2);           *x           = prob->x;}
19762764a2aaSMatthew G. Knepley   if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;}
19772764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
19782764a2aaSMatthew G. Knepley }
19792764a2aaSMatthew G. Knepley 
19802764a2aaSMatthew G. Knepley #undef __FUNCT__
1981*da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations"
1982*da51fcedSMatthew G. Knepley /*@
1983*da51fcedSMatthew G. Knepley   PetscDSCopyEquations - Copy all pointwise function pointers to the new problem
1984*da51fcedSMatthew G. Knepley 
1985*da51fcedSMatthew G. Knepley   Not collective
1986*da51fcedSMatthew G. Knepley 
1987*da51fcedSMatthew G. Knepley   Input Parameter:
1988*da51fcedSMatthew G. Knepley . prob - The PetscDS object
1989*da51fcedSMatthew G. Knepley 
1990*da51fcedSMatthew G. Knepley   Output Parameter:
1991*da51fcedSMatthew G. Knepley . newprob - The PetscDS copy
1992*da51fcedSMatthew G. Knepley 
1993*da51fcedSMatthew G. Knepley   Level: intermediate
1994*da51fcedSMatthew G. Knepley 
1995*da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate()
1996*da51fcedSMatthew G. Knepley @*/
1997*da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob)
1998*da51fcedSMatthew G. Knepley {
1999*da51fcedSMatthew G. Knepley   PetscInt       Nf, Ng, f, g;
2000*da51fcedSMatthew G. Knepley   PetscErrorCode ierr;
2001*da51fcedSMatthew G. Knepley 
2002*da51fcedSMatthew G. Knepley   PetscFunctionBegin;
2003*da51fcedSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2004*da51fcedSMatthew G. Knepley   PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2);
2005*da51fcedSMatthew G. Knepley   ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr);
2006*da51fcedSMatthew G. Knepley   ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr);
2007*da51fcedSMatthew G. Knepley   if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr);
2008*da51fcedSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
2009*da51fcedSMatthew G. Knepley     PetscPointFunc   obj;
2010*da51fcedSMatthew G. Knepley     PetscPointFunc   f0, f1;
2011*da51fcedSMatthew G. Knepley     PetscPointJac    g0, g1, g2, g3;
2012*da51fcedSMatthew G. Knepley     PetscBdPointFunc f0Bd, f1Bd;
2013*da51fcedSMatthew G. Knepley     PetscBdPointJac  g0Bd, g1Bd, g2Bd, g3Bd;
2014*da51fcedSMatthew G. Knepley     PetscRiemannFunc r;
2015*da51fcedSMatthew G. Knepley 
2016*da51fcedSMatthew G. Knepley     ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr);
2017*da51fcedSMatthew G. Knepley     ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr);
2018*da51fcedSMatthew G. Knepley     ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr);
2019*da51fcedSMatthew G. Knepley     ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr);
2020*da51fcedSMatthew G. Knepley     ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr);
2021*da51fcedSMatthew G. Knepley     ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr);
2022*da51fcedSMatthew G. Knepley     ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr);
2023*da51fcedSMatthew G. Knepley     ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr);
2024*da51fcedSMatthew G. Knepley     for (g = 0; g < Nf; ++g) {
2025*da51fcedSMatthew G. Knepley       ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr);
2026*da51fcedSMatthew G. Knepley       ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr);
2027*da51fcedSMatthew G. Knepley       ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr);
2028*da51fcedSMatthew G. Knepley       ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr);
2029*da51fcedSMatthew G. Knepley     }
2030*da51fcedSMatthew G. Knepley   }
2031*da51fcedSMatthew G. Knepley   PetscFunctionReturn(0);
2032*da51fcedSMatthew G. Knepley }
2033*da51fcedSMatthew G. Knepley 
2034*da51fcedSMatthew G. Knepley #undef __FUNCT__
20352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic"
2036bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob)
20372764a2aaSMatthew G. Knepley {
20382764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20392764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20402764a2aaSMatthew G. Knepley }
20412764a2aaSMatthew G. Knepley 
20422764a2aaSMatthew G. Knepley #undef __FUNCT__
20432764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic"
2044bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob)
20452764a2aaSMatthew G. Knepley {
20462764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20472764a2aaSMatthew G. Knepley   prob->ops->setfromoptions = NULL;
20482764a2aaSMatthew G. Knepley   prob->ops->setup          = NULL;
20492764a2aaSMatthew G. Knepley   prob->ops->view           = NULL;
20502764a2aaSMatthew G. Knepley   prob->ops->destroy        = PetscDSDestroy_Basic;
20512764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20522764a2aaSMatthew G. Knepley }
20532764a2aaSMatthew G. Knepley 
20542764a2aaSMatthew G. Knepley /*MC
20552764a2aaSMatthew G. Knepley   PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions
20562764a2aaSMatthew G. Knepley 
20572764a2aaSMatthew G. Knepley   Level: intermediate
20582764a2aaSMatthew G. Knepley 
20592764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType()
20602764a2aaSMatthew G. Knepley M*/
20612764a2aaSMatthew G. Knepley 
20622764a2aaSMatthew G. Knepley #undef __FUNCT__
20632764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic"
20642764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob)
20652764a2aaSMatthew G. Knepley {
20662764a2aaSMatthew G. Knepley   PetscDS_Basic *b;
20672764a2aaSMatthew G. Knepley   PetscErrorCode      ierr;
20682764a2aaSMatthew G. Knepley 
20692764a2aaSMatthew G. Knepley   PetscFunctionBegin;
20702764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1);
20712764a2aaSMatthew G. Knepley   ierr       = PetscNewLog(prob, &b);CHKERRQ(ierr);
20722764a2aaSMatthew G. Knepley   prob->data = b;
20732764a2aaSMatthew G. Knepley 
20742764a2aaSMatthew G. Knepley   ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr);
20752764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
20762764a2aaSMatthew G. Knepley }
2077