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 894dcdc3fSMatthew G. Knepley /* A PetscDS (Discrete System) encodes a set of equations posed in a discrete space, which represents a set of 994dcdc3fSMatthew G. Knepley nonlinear continuum equations. The equations can have multiple fields, each field having a different 1094dcdc3fSMatthew G. Knepley discretization. In addition, different pieces of the domain can have different field combinations and equations. 1194dcdc3fSMatthew G. Knepley 1294dcdc3fSMatthew G. Knepley The DS provides the user a description of the approximation space on any given cell. It also gives pointwise 1394dcdc3fSMatthew G. Knepley functions representing the equations. 1494dcdc3fSMatthew G. Knepley 1594dcdc3fSMatthew G. Knepley Each field is associated with a label, marking the cells on which it is supported. Note that a field can be 1694dcdc3fSMatthew G. Knepley supported on the closure of a cell not in the label due to overlap of the boundary of neighboring cells. The DM 1794dcdc3fSMatthew G. Knepley then creates a DS for each set of cells with identical approximation spaces. When assembling, the user asks for 1894dcdc3fSMatthew G. Knepley the space associated with a given cell. DMPlex uses the labels associated with each DS in the default integration loop. 1994dcdc3fSMatthew G. Knepley */ 2094dcdc3fSMatthew G. Knepley 212764a2aaSMatthew G. Knepley /*@C 222764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 232764a2aaSMatthew G. Knepley 242764a2aaSMatthew G. Knepley Not Collective 252764a2aaSMatthew G. Knepley 262764a2aaSMatthew G. Knepley Input Parameters: 272764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 282764a2aaSMatthew G. Knepley - create_func - The creation routine itself 292764a2aaSMatthew G. Knepley 302764a2aaSMatthew G. Knepley Notes: 312764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 322764a2aaSMatthew G. Knepley 332764a2aaSMatthew G. Knepley Sample usage: 342764a2aaSMatthew G. Knepley .vb 352764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 362764a2aaSMatthew G. Knepley .ve 372764a2aaSMatthew G. Knepley 382764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 392764a2aaSMatthew G. Knepley .vb 402764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 412764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 422764a2aaSMatthew G. Knepley .ve 432764a2aaSMatthew G. Knepley or at runtime via the option 442764a2aaSMatthew G. Knepley .vb 452764a2aaSMatthew G. Knepley -petscds_type my_ds 462764a2aaSMatthew G. Knepley .ve 472764a2aaSMatthew G. Knepley 482764a2aaSMatthew G. Knepley Level: advanced 492764a2aaSMatthew G. Knepley 50f5f57ec0SBarry Smith Not available from Fortran 51f5f57ec0SBarry Smith 52db781477SPatrick Sanan .seealso: `PetscDSRegisterAll()`, `PetscDSRegisterDestroy()` 532764a2aaSMatthew G. Knepley 542764a2aaSMatthew G. Knepley @*/ 552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS)) 562764a2aaSMatthew G. Knepley { 572764a2aaSMatthew G. Knepley PetscFunctionBegin; 589566063dSJacob Faibussowitsch PetscCall(PetscFunctionListAdd(&PetscDSList, sname, function)); 592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 602764a2aaSMatthew G. Knepley } 612764a2aaSMatthew G. Knepley 622764a2aaSMatthew G. Knepley /*@C 632764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 642764a2aaSMatthew G. Knepley 65d083f849SBarry Smith Collective on prob 662764a2aaSMatthew G. Knepley 672764a2aaSMatthew G. Knepley Input Parameters: 682764a2aaSMatthew G. Knepley + prob - The PetscDS object 692764a2aaSMatthew G. Knepley - name - The kind of system 702764a2aaSMatthew G. Knepley 712764a2aaSMatthew G. Knepley Options Database Key: 722764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 732764a2aaSMatthew G. Knepley 742764a2aaSMatthew G. Knepley Level: intermediate 752764a2aaSMatthew G. Knepley 76f5f57ec0SBarry Smith Not available from Fortran 77f5f57ec0SBarry Smith 78db781477SPatrick Sanan .seealso: `PetscDSGetType()`, `PetscDSCreate()` 792764a2aaSMatthew G. Knepley @*/ 802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 812764a2aaSMatthew G. Knepley { 822764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 832764a2aaSMatthew G. Knepley PetscBool match; 842764a2aaSMatthew G. Knepley 852764a2aaSMatthew G. Knepley PetscFunctionBegin; 862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 879566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject) prob, name, &match)); 882764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 892764a2aaSMatthew G. Knepley 909566063dSJacob Faibussowitsch PetscCall(PetscDSRegisterAll()); 919566063dSJacob Faibussowitsch PetscCall(PetscFunctionListFind(PetscDSList, name, &r)); 9228b400f6SJacob Faibussowitsch PetscCheck(r,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 932764a2aaSMatthew G. Knepley 94*dbbe0bcdSBarry Smith PetscTryTypeMethod(prob,destroy); 952764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 96*dbbe0bcdSBarry Smith 979566063dSJacob Faibussowitsch PetscCall((*r)(prob)); 989566063dSJacob Faibussowitsch PetscCall(PetscObjectChangeTypeName((PetscObject) prob, name)); 992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1002764a2aaSMatthew G. Knepley } 1012764a2aaSMatthew G. Knepley 1022764a2aaSMatthew G. Knepley /*@C 1032764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 1042764a2aaSMatthew G. Knepley 1052764a2aaSMatthew G. Knepley Not Collective 1062764a2aaSMatthew G. Knepley 1072764a2aaSMatthew G. Knepley Input Parameter: 1082764a2aaSMatthew G. Knepley . prob - The PetscDS 1092764a2aaSMatthew G. Knepley 1102764a2aaSMatthew G. Knepley Output Parameter: 1112764a2aaSMatthew G. Knepley . name - The PetscDS type name 1122764a2aaSMatthew G. Knepley 1132764a2aaSMatthew G. Knepley Level: intermediate 1142764a2aaSMatthew G. Knepley 115f5f57ec0SBarry Smith Not available from Fortran 116f5f57ec0SBarry Smith 117db781477SPatrick Sanan .seealso: `PetscDSSetType()`, `PetscDSCreate()` 1182764a2aaSMatthew G. Knepley @*/ 1192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1202764a2aaSMatthew G. Knepley { 1212764a2aaSMatthew G. Knepley PetscFunctionBegin; 1222764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 123c959eef4SJed Brown PetscValidPointer(name, 2); 1249566063dSJacob Faibussowitsch PetscCall(PetscDSRegisterAll()); 1252764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1272764a2aaSMatthew G. Knepley } 1282764a2aaSMatthew G. Knepley 1295fedec97SMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS ds, PetscViewer viewer) 1307d8a60eaSMatthew G. Knepley { 1317d8a60eaSMatthew G. Knepley PetscViewerFormat format; 13297b6e6e8SMatthew G. Knepley const PetscScalar *constants; 1335fedec97SMatthew G. Knepley PetscInt Nf, numConstants, f; 1347d8a60eaSMatthew G. Knepley 1357d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1369566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 1379566063dSJacob Faibussowitsch PetscCall(PetscViewerGetFormat(viewer, &format)); 13863a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Discrete System with %" PetscInt_FMT " fields\n", Nf)); 1399566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 14063a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " cell total dim %" PetscInt_FMT " total comp %" PetscInt_FMT "\n", ds->totDim, ds->totComp)); 1419566063dSJacob Faibussowitsch if (ds->isCohesive) PetscCall(PetscViewerASCIIPrintf(viewer, " cohesive cell\n")); 1425fedec97SMatthew G. Knepley for (f = 0; f < Nf; ++f) { 14340967b3bSMatthew G. Knepley DSBoundary b; 1447d8a60eaSMatthew G. Knepley PetscObject obj; 1457d8a60eaSMatthew G. Knepley PetscClassId id; 146f35450b9SMatthew G. Knepley PetscQuadrature q; 1477d8a60eaSMatthew G. Knepley const char *name; 148f35450b9SMatthew G. Knepley PetscInt Nc, Nq, Nqc; 1497d8a60eaSMatthew G. Knepley 1509566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(ds, f, &obj)); 1519566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 1529566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName(obj, &name)); 1539566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>")); 1549566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 1557d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1569566063dSJacob Faibussowitsch PetscCall(PetscFEGetNumComponents((PetscFE) obj, &Nc)); 1579566063dSJacob Faibussowitsch PetscCall(PetscFEGetQuadrature((PetscFE) obj, &q)); 1589566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " FEM")); 1597d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1609566063dSJacob Faibussowitsch PetscCall(PetscFVGetNumComponents((PetscFV) obj, &Nc)); 1619566063dSJacob Faibussowitsch PetscCall(PetscFVGetQuadrature((PetscFV) obj, &q)); 1629566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " FVM")); 1637d8a60eaSMatthew G. Knepley } 16463a3b9bcSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %" PetscInt_FMT, f); 16563a3b9bcSJacob Faibussowitsch if (Nc > 1) PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT " components", Nc)); 16663a3b9bcSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT " component ", Nc)); 1679566063dSJacob Faibussowitsch if (ds->implicit[f]) PetscCall(PetscViewerASCIIPrintf(viewer, " (implicit)")); 1689566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " (explicit)")); 1693e60c2a6SMatthew G. Knepley if (q) { 1709566063dSJacob Faibussowitsch PetscCall(PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL)); 17163a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " (Nq %" PetscInt_FMT " Nqc %" PetscInt_FMT ")", Nq, Nqc)); 1723e60c2a6SMatthew G. Knepley } 17363a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT "-jet", ds->jetDegree[f])); 1749566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 1759566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 1769566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 1779566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEView((PetscFE) obj, viewer)); 1789566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVView((PetscFV) obj, viewer)); 1799566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 18040967b3bSMatthew G. Knepley 1815fedec97SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 18206ad1575SMatthew G. Knepley char *name; 18340967b3bSMatthew G. Knepley PetscInt c, i; 18440967b3bSMatthew G. Knepley 18540967b3bSMatthew G. Knepley if (b->field != f) continue; 1869566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 1879566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->lname, DMBoundaryConditionTypes[b->type])); 18845480ffeSMatthew G. Knepley if (!b->Nc) { 1899566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " all components\n")); 19040967b3bSMatthew G. Knepley } else { 1919566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " components: ")); 1929566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 19345480ffeSMatthew G. Knepley for (c = 0; c < b->Nc; ++c) { 1949566063dSJacob Faibussowitsch if (c > 0) PetscCall(PetscViewerASCIIPrintf(viewer, ", ")); 19563a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT, b->comps[c])); 19640967b3bSMatthew G. Knepley } 1979566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 1989566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 19940967b3bSMatthew G. Knepley } 2009566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " values: ")); 2019566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 20245480ffeSMatthew G. Knepley for (i = 0; i < b->Nv; ++i) { 2039566063dSJacob Faibussowitsch if (i > 0) PetscCall(PetscViewerASCIIPrintf(viewer, ", ")); 20463a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT, b->values[i])); 20540967b3bSMatthew G. Knepley } 2069566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 2079566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 2088e0d8d9cSMatthew G. Knepley if (b->func) { 2099566063dSJacob Faibussowitsch PetscCall(PetscDLAddr(b->func, &name)); 2109566063dSJacob Faibussowitsch if (name) PetscCall(PetscViewerASCIIPrintf(viewer, " func: %s\n", name)); 2119566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " func: %p\n", b->func)); 2129566063dSJacob Faibussowitsch PetscCall(PetscFree(name)); 2138e0d8d9cSMatthew G. Knepley } 2148e0d8d9cSMatthew G. Knepley if (b->func_t) { 2159566063dSJacob Faibussowitsch PetscCall(PetscDLAddr(b->func_t, &name)); 2169566063dSJacob Faibussowitsch if (name) PetscCall(PetscViewerASCIIPrintf(viewer, " func_t: %s\n", name)); 2179566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " func_t: %p\n", b->func_t)); 2189566063dSJacob Faibussowitsch PetscCall(PetscFree(name)); 2198e0d8d9cSMatthew G. Knepley } 2209566063dSJacob Faibussowitsch PetscCall(PetscWeakFormView(b->wf, viewer)); 2219566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 22240967b3bSMatthew G. Knepley } 2237d8a60eaSMatthew G. Knepley } 2249566063dSJacob Faibussowitsch PetscCall(PetscDSGetConstants(ds, &numConstants, &constants)); 22597b6e6e8SMatthew G. Knepley if (numConstants) { 22663a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT " constants\n", numConstants)); 2279566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 2289566063dSJacob Faibussowitsch for (f = 0; f < numConstants; ++f) PetscCall(PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]))); 2299566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 23097b6e6e8SMatthew G. Knepley } 2319566063dSJacob Faibussowitsch PetscCall(PetscWeakFormView(ds->wf, viewer)); 2329566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 2337d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 2347d8a60eaSMatthew G. Knepley } 2357d8a60eaSMatthew G. Knepley 2362764a2aaSMatthew G. Knepley /*@C 237fe2efc57SMark PetscDSViewFromOptions - View from Options 238fe2efc57SMark 239fe2efc57SMark Collective on PetscDS 240fe2efc57SMark 241fe2efc57SMark Input Parameters: 242fe2efc57SMark + A - the PetscDS object 243736c3998SJose E. Roman . obj - Optional object 244736c3998SJose E. Roman - name - command line option 245fe2efc57SMark 246fe2efc57SMark Level: intermediate 247db781477SPatrick Sanan .seealso: `PetscDS`, `PetscDSView`, `PetscObjectViewFromOptions()`, `PetscDSCreate()` 248fe2efc57SMark @*/ 249fe2efc57SMark PetscErrorCode PetscDSViewFromOptions(PetscDS A,PetscObject obj,const char name[]) 250fe2efc57SMark { 251fe2efc57SMark PetscFunctionBegin; 252fe2efc57SMark PetscValidHeaderSpecific(A,PETSCDS_CLASSID,1); 2539566063dSJacob Faibussowitsch PetscCall(PetscObjectViewFromOptions((PetscObject)A,obj,name)); 254fe2efc57SMark PetscFunctionReturn(0); 255fe2efc57SMark } 256fe2efc57SMark 257fe2efc57SMark /*@C 2582764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 2592764a2aaSMatthew G. Knepley 260d083f849SBarry Smith Collective on prob 2612764a2aaSMatthew G. Knepley 262d8d19677SJose E. Roman Input Parameters: 2632764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 2642764a2aaSMatthew G. Knepley - v - the viewer 2652764a2aaSMatthew G. Knepley 2662764a2aaSMatthew G. Knepley Level: developer 2672764a2aaSMatthew G. Knepley 268db781477SPatrick Sanan .seealso `PetscDSDestroy()` 2692764a2aaSMatthew G. Knepley @*/ 2702764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2712764a2aaSMatthew G. Knepley { 2727d8a60eaSMatthew G. Knepley PetscBool iascii; 2732764a2aaSMatthew G. Knepley 2742764a2aaSMatthew G. Knepley PetscFunctionBegin; 2752764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2769566063dSJacob Faibussowitsch if (!v) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v)); 2777d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2789566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii)); 2799566063dSJacob Faibussowitsch if (iascii) PetscCall(PetscDSView_Ascii(prob, v)); 280*dbbe0bcdSBarry Smith PetscTryTypeMethod(prob,view, v); 2812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2822764a2aaSMatthew G. Knepley } 2832764a2aaSMatthew G. Knepley 2842764a2aaSMatthew G. Knepley /*@ 2852764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2862764a2aaSMatthew G. Knepley 287d083f849SBarry Smith Collective on prob 2882764a2aaSMatthew G. Knepley 2892764a2aaSMatthew G. Knepley Input Parameter: 2902764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2912764a2aaSMatthew G. Knepley 2922764a2aaSMatthew G. Knepley Options Database: 293147403d9SBarry Smith + -petscds_type <type> - Set the DS type 294147403d9SBarry Smith . -petscds_view <view opt> - View the DS 295147403d9SBarry Smith . -petscds_jac_pre - Turn formation of a separate Jacobian preconditioner on or off 296147403d9SBarry Smith . -bc_<name> <ids> - Specify a list of label ids for a boundary condition 297147403d9SBarry Smith - -bc_<name>_comp <comps> - Specify a list of field components to constrain for a boundary condition 2982764a2aaSMatthew G. Knepley 2992764a2aaSMatthew G. Knepley Level: developer 3002764a2aaSMatthew G. Knepley 301db781477SPatrick Sanan .seealso `PetscDSView()` 3022764a2aaSMatthew G. Knepley @*/ 3032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 3042764a2aaSMatthew G. Knepley { 305f1fd5e65SToby Isaac DSBoundary b; 3062764a2aaSMatthew G. Knepley const char *defaultType; 3072764a2aaSMatthew G. Knepley char name[256]; 3082764a2aaSMatthew G. Knepley PetscBool flg; 3092764a2aaSMatthew G. Knepley 3102764a2aaSMatthew G. Knepley PetscFunctionBegin; 3112764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3122764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3132764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3142764a2aaSMatthew G. Knepley } else { 3152764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3162764a2aaSMatthew G. Knepley } 3179566063dSJacob Faibussowitsch PetscCall(PetscDSRegisterAll()); 3182764a2aaSMatthew G. Knepley 319d0609cedSBarry Smith PetscObjectOptionsBegin((PetscObject) prob); 320f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 321f1fd5e65SToby Isaac char optname[1024]; 322f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 323f1fd5e65SToby Isaac PetscBool flg; 324f1fd5e65SToby Isaac 3259566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name)); 3269566063dSJacob Faibussowitsch PetscCall(PetscMemzero(ids, sizeof(ids))); 3279566063dSJacob Faibussowitsch PetscCall(PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg)); 328f1fd5e65SToby Isaac if (flg) { 32945480ffeSMatthew G. Knepley b->Nv = len; 3309566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 3319566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(len, &b->values)); 3329566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(b->values, ids, len)); 3339566063dSJacob Faibussowitsch PetscCall(PetscWeakFormRewriteKeys(b->wf, b->label, len, b->values)); 334f1fd5e65SToby Isaac } 335e7b0402cSSander Arens len = 1024; 3369566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name)); 3379566063dSJacob Faibussowitsch PetscCall(PetscMemzero(ids, sizeof(ids))); 3389566063dSJacob Faibussowitsch PetscCall(PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg)); 339f1fd5e65SToby Isaac if (flg) { 34045480ffeSMatthew G. Knepley b->Nc = len; 3419566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 3429566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(len, &b->comps)); 3439566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(b->comps, ids, len)); 344f1fd5e65SToby Isaac } 345f1fd5e65SToby Isaac } 3469566063dSJacob Faibussowitsch PetscCall(PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg)); 3472764a2aaSMatthew G. Knepley if (flg) { 3489566063dSJacob Faibussowitsch PetscCall(PetscDSSetType(prob, name)); 3492764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3509566063dSJacob Faibussowitsch PetscCall(PetscDSSetType(prob, defaultType)); 3512764a2aaSMatthew G. Knepley } 3529566063dSJacob Faibussowitsch PetscCall(PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg)); 353*dbbe0bcdSBarry Smith PetscTryTypeMethod(prob,setfromoptions); 3542764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 355*dbbe0bcdSBarry Smith PetscCall(PetscObjectProcessOptionsHandlers((PetscObject) prob,PetscOptionsObject)); 356d0609cedSBarry Smith PetscOptionsEnd(); 3579566063dSJacob Faibussowitsch if (prob->Nf) PetscCall(PetscDSViewFromOptions(prob, NULL, "-petscds_view")); 3582764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3592764a2aaSMatthew G. Knepley } 3602764a2aaSMatthew G. Knepley 3612764a2aaSMatthew G. Knepley /*@C 3622764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3632764a2aaSMatthew G. Knepley 364d083f849SBarry Smith Collective on prob 3652764a2aaSMatthew G. Knepley 3662764a2aaSMatthew G. Knepley Input Parameter: 3672764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3682764a2aaSMatthew G. Knepley 3692764a2aaSMatthew G. Knepley Level: developer 3702764a2aaSMatthew G. Knepley 371db781477SPatrick Sanan .seealso `PetscDSView()`, `PetscDSDestroy()` 3722764a2aaSMatthew G. Knepley @*/ 3732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3742764a2aaSMatthew G. Knepley { 3752764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 376f9244615SMatthew G. Knepley PetscBool hasH = PETSC_FALSE; 3774bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3782764a2aaSMatthew G. Knepley 3792764a2aaSMatthew G. Knepley PetscFunctionBegin; 3802764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3812764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3822764a2aaSMatthew G. Knepley /* Calculate sizes */ 3839566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(prob, &dim)); 3849566063dSJacob Faibussowitsch PetscCall(PetscDSGetCoordinateDimension(prob, &dimEmbed)); 385f744cafaSSander Arens prob->totDim = prob->totComp = 0; 3869566063dSJacob Faibussowitsch PetscCall(PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb)); 3879566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer)); 3889566063dSJacob Faibussowitsch PetscCall(PetscCalloc6(Nf+1,&prob->offCohesive[0],Nf+1,&prob->offCohesive[1],Nf+1,&prob->offCohesive[2],Nf+1,&prob->offDerCohesive[0],Nf+1,&prob->offDerCohesive[1],Nf+1,&prob->offDerCohesive[2])); 3899566063dSJacob Faibussowitsch PetscCall(PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf)); 3902764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3919de99aefSMatthew G. Knepley PetscObject obj; 3929de99aefSMatthew G. Knepley PetscClassId id; 393665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 3949de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3952764a2aaSMatthew G. Knepley 3969566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &obj)); 397f9244615SMatthew G. Knepley if (prob->jetDegree[f] > 1) hasH = PETSC_TRUE; 398665f567fSMatthew G. Knepley if (!obj) { 399665f567fSMatthew G. Knepley /* Empty mesh */ 400665f567fSMatthew G. Knepley Nb = Nc = 0; 401665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 402665f567fSMatthew G. Knepley } else { 4039566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 4049de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 4059de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 4069de99aefSMatthew G. Knepley 4079566063dSJacob Faibussowitsch PetscCall(PetscFEGetQuadrature(fe, &q)); 4089566063dSJacob Faibussowitsch PetscCall(PetscFEGetDimension(fe, &Nb)); 4099566063dSJacob Faibussowitsch PetscCall(PetscFEGetNumComponents(fe, &Nc)); 4109566063dSJacob Faibussowitsch PetscCall(PetscFEGetCellTabulation(fe, prob->jetDegree[f], &prob->T[f])); 4119566063dSJacob Faibussowitsch PetscCall(PetscFEGetFaceTabulation(fe, prob->jetDegree[f], &prob->Tf[f])); 4129de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4139de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4149de99aefSMatthew G. Knepley 4159566063dSJacob Faibussowitsch PetscCall(PetscFVGetQuadrature(fv, &q)); 4169566063dSJacob Faibussowitsch PetscCall(PetscFVGetNumComponents(fv, &Nc)); 4179c3cf19fSMatthew G. Knepley Nb = Nc; 4189566063dSJacob Faibussowitsch PetscCall(PetscFVGetCellTabulation(fv, &prob->T[f])); 4194d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 42063a3b9bcSJacob Faibussowitsch } else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %" PetscInt_FMT, f); 421665f567fSMatthew G. Knepley } 42247e57110SSander Arens prob->Nc[f] = Nc; 42347e57110SSander Arens prob->Nb[f] = Nb; 424194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 425194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 4269ee2af8cSMatthew G. Knepley prob->offCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[0][f]; 4279ee2af8cSMatthew G. Knepley prob->offDerCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[0][f]; 4289ee2af8cSMatthew G. Knepley prob->offCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc) + prob->offCohesive[0][f]; 4299ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc)*dimEmbed + prob->offDerCohesive[0][f]; 4309ee2af8cSMatthew G. Knepley prob->offCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[2][f]; 4319ee2af8cSMatthew G. Knepley prob->offDerCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[2][f]; 4329566063dSJacob Faibussowitsch if (q) PetscCall(PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL)); 4332764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4344bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4352764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4369c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4372764a2aaSMatthew G. Knepley prob->totComp += Nc; 4385fedec97SMatthew G. Knepley /* There are two faces for all fields on a cohesive cell, except for cohesive fields */ 4395fedec97SMatthew G. Knepley if (prob->isCohesive && !prob->cohesive[f]) prob->totDim += Nb; 4402764a2aaSMatthew G. Knepley } 4419ee2af8cSMatthew G. Knepley prob->offCohesive[1][Nf] = prob->offCohesive[0][Nf]; 4429ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][Nf] = prob->offDerCohesive[0][Nf]; 4432764a2aaSMatthew G. Knepley /* Allocate works space */ 4445fedec97SMatthew G. Knepley NsMax = 2; /* A non-cohesive discretizations can be used on a cohesive cell, so we need this extra workspace for all DS */ 4459566063dSJacob Faibussowitsch PetscCall(PetscMalloc3(NsMax*prob->totComp,&prob->u,NsMax*prob->totComp,&prob->u_t,NsMax*prob->totComp*dimEmbed + (hasH ? NsMax*prob->totComp*dimEmbed*dimEmbed : 0),&prob->u_x)); 4469566063dSJacob Faibussowitsch PetscCall(PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal)); 447d0609cedSBarry Smith PetscCall(PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 44827f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 449d0609cedSBarry Smith NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3)); 450*dbbe0bcdSBarry Smith PetscTryTypeMethod(prob,setup); 4512764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4522764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4532764a2aaSMatthew G. Knepley } 4542764a2aaSMatthew G. Knepley 4552764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4562764a2aaSMatthew G. Knepley { 4572764a2aaSMatthew G. Knepley PetscFunctionBegin; 4589566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->Nc,prob->Nb)); 4599566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->off,prob->offDer)); 4609566063dSJacob Faibussowitsch PetscCall(PetscFree6(prob->offCohesive[0],prob->offCohesive[1],prob->offCohesive[2],prob->offDerCohesive[0],prob->offDerCohesive[1],prob->offDerCohesive[2])); 4619566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->T,prob->Tf)); 4629566063dSJacob Faibussowitsch PetscCall(PetscFree3(prob->u,prob->u_t,prob->u_x)); 4639566063dSJacob Faibussowitsch PetscCall(PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal)); 4649566063dSJacob Faibussowitsch PetscCall(PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3)); 4652764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4662764a2aaSMatthew G. Knepley } 4672764a2aaSMatthew G. Knepley 4682764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4692764a2aaSMatthew G. Knepley { 470f744cafaSSander Arens PetscObject *tmpd; 47134aa8a36SMatthew G. Knepley PetscBool *tmpi; 472f9244615SMatthew G. Knepley PetscInt *tmpk; 4735fedec97SMatthew G. Knepley PetscBool *tmpc; 4746528b96dSMatthew G. Knepley PetscPointFunc *tmpup; 475f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 476f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4770c2f2876SMatthew G. Knepley void **tmpctx; 47834aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4792764a2aaSMatthew G. Knepley 4802764a2aaSMatthew G. Knepley PetscFunctionBegin; 4812764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4822764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4839566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyStructs_Static(prob)); 4849566063dSJacob Faibussowitsch PetscCall(PetscMalloc4(NfNew, &tmpd, NfNew, &tmpi, NfNew, &tmpc, NfNew, &tmpk)); 4855fedec97SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f]; tmpc[f] = prob->cohesive[f]; tmpk[f] = prob->jetDegree[f];} 4865fedec97SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE, tmpc[f] = PETSC_FALSE; tmpk[f] = 1;} 4879566063dSJacob Faibussowitsch PetscCall(PetscFree4(prob->disc, prob->implicit, prob->cohesive, prob->jetDegree)); 4889566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(prob->wf, NfNew)); 4892764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4902764a2aaSMatthew G. Knepley prob->disc = tmpd; 491249df284SMatthew G. Knepley prob->implicit = tmpi; 4925fedec97SMatthew G. Knepley prob->cohesive = tmpc; 493f9244615SMatthew G. Knepley prob->jetDegree = tmpk; 4949566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(NfNew, &tmpup, NfNew, &tmpctx)); 49532d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4960c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 49732d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4980c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 4999566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->update, prob->ctx)); 50032d2bbc9SMatthew G. Knepley prob->update = tmpup; 5010c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 5029566063dSJacob Faibussowitsch PetscCall(PetscCalloc4(NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t)); 503c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50495cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 505f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 506f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 507c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 50895cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 509f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 510f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 5119566063dSJacob Faibussowitsch PetscCall(PetscFree4(prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t)); 512c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51395cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 514f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 515f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5172764a2aaSMatthew G. Knepley } 5182764a2aaSMatthew G. Knepley 5192764a2aaSMatthew G. Knepley /*@ 5202764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5212764a2aaSMatthew G. Knepley 522d083f849SBarry Smith Collective on prob 5232764a2aaSMatthew G. Knepley 5242764a2aaSMatthew G. Knepley Input Parameter: 5252764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5262764a2aaSMatthew G. Knepley 5272764a2aaSMatthew G. Knepley Level: developer 5282764a2aaSMatthew G. Knepley 529db781477SPatrick Sanan .seealso `PetscDSView()` 5302764a2aaSMatthew G. Knepley @*/ 5316528b96dSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *ds) 5322764a2aaSMatthew G. Knepley { 5332764a2aaSMatthew G. Knepley PetscInt f; 5342764a2aaSMatthew G. Knepley 5352764a2aaSMatthew G. Knepley PetscFunctionBegin; 5366528b96dSMatthew G. Knepley if (!*ds) PetscFunctionReturn(0); 5376528b96dSMatthew G. Knepley PetscValidHeaderSpecific((*ds), PETSCDS_CLASSID, 1); 5382764a2aaSMatthew G. Knepley 5396528b96dSMatthew G. Knepley if (--((PetscObject)(*ds))->refct > 0) {*ds = NULL; PetscFunctionReturn(0);} 5406528b96dSMatthew G. Knepley ((PetscObject) (*ds))->refct = 0; 5416528b96dSMatthew G. Knepley if ((*ds)->subprobs) { 542df3a45bdSMatthew G. Knepley PetscInt dim, d; 543df3a45bdSMatthew G. Knepley 5449566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(*ds, &dim)); 5459566063dSJacob Faibussowitsch for (d = 0; d < dim; ++d) PetscCall(PetscDSDestroy(&(*ds)->subprobs[d])); 546df3a45bdSMatthew G. Knepley } 5479566063dSJacob Faibussowitsch PetscCall(PetscFree((*ds)->subprobs)); 5489566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyStructs_Static(*ds)); 5496528b96dSMatthew G. Knepley for (f = 0; f < (*ds)->Nf; ++f) { 5509566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference((*ds)->disc[f])); 5512764a2aaSMatthew G. Knepley } 5529566063dSJacob Faibussowitsch PetscCall(PetscFree4((*ds)->disc, (*ds)->implicit, (*ds)->cohesive, (*ds)->jetDegree)); 5539566063dSJacob Faibussowitsch PetscCall(PetscWeakFormDestroy(&(*ds)->wf)); 5549566063dSJacob Faibussowitsch PetscCall(PetscFree2((*ds)->update,(*ds)->ctx)); 5559566063dSJacob Faibussowitsch PetscCall(PetscFree4((*ds)->exactSol,(*ds)->exactCtx,(*ds)->exactSol_t,(*ds)->exactCtx_t)); 556*dbbe0bcdSBarry Smith PetscTryTypeMethod((*ds),destroy); 5579566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyBoundary(*ds)); 5589566063dSJacob Faibussowitsch PetscCall(PetscFree((*ds)->constants)); 5599566063dSJacob Faibussowitsch PetscCall(PetscHeaderDestroy(ds)); 5602764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5612764a2aaSMatthew G. Knepley } 5622764a2aaSMatthew G. Knepley 5632764a2aaSMatthew G. Knepley /*@ 5642764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5652764a2aaSMatthew G. Knepley 566d083f849SBarry Smith Collective 5672764a2aaSMatthew G. Knepley 5682764a2aaSMatthew G. Knepley Input Parameter: 5692764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5702764a2aaSMatthew G. Knepley 5712764a2aaSMatthew G. Knepley Output Parameter: 5726528b96dSMatthew G. Knepley . ds - The PetscDS object 5732764a2aaSMatthew G. Knepley 5742764a2aaSMatthew G. Knepley Level: beginner 5752764a2aaSMatthew G. Knepley 576db781477SPatrick Sanan .seealso: `PetscDSSetType()`, `PETSCDSBASIC` 5772764a2aaSMatthew G. Knepley @*/ 5786528b96dSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *ds) 5792764a2aaSMatthew G. Knepley { 5802764a2aaSMatthew G. Knepley PetscDS p; 5812764a2aaSMatthew G. Knepley 5822764a2aaSMatthew G. Knepley PetscFunctionBegin; 5836528b96dSMatthew G. Knepley PetscValidPointer(ds, 2); 5846528b96dSMatthew G. Knepley *ds = NULL; 5859566063dSJacob Faibussowitsch PetscCall(PetscDSInitializePackage()); 5862764a2aaSMatthew G. Knepley 5879566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView)); 5882764a2aaSMatthew G. Knepley 5892764a2aaSMatthew G. Knepley p->Nf = 0; 5902764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 59197b6e6e8SMatthew G. Knepley p->numConstants = 0; 59297b6e6e8SMatthew G. Knepley p->constants = NULL; 593a859676bSMatthew G. Knepley p->dimEmbed = -1; 59455c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5959566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(comm, &p->wf)); 5962764a2aaSMatthew G. Knepley 5976528b96dSMatthew G. Knepley *ds = p; 5982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5992764a2aaSMatthew G. Knepley } 6002764a2aaSMatthew G. Knepley 601bc4ae4beSMatthew G. Knepley /*@ 602bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 603bc4ae4beSMatthew G. Knepley 604bc4ae4beSMatthew G. Knepley Not collective 605bc4ae4beSMatthew G. Knepley 606bc4ae4beSMatthew G. Knepley Input Parameter: 607bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Output Parameter: 610bc4ae4beSMatthew G. Knepley . Nf - The number of fields 611bc4ae4beSMatthew G. Knepley 612bc4ae4beSMatthew G. Knepley Level: beginner 613bc4ae4beSMatthew G. Knepley 614db781477SPatrick Sanan .seealso: `PetscDSGetSpatialDimension()`, `PetscDSCreate()` 615bc4ae4beSMatthew G. Knepley @*/ 6162764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6172764a2aaSMatthew G. Knepley { 6182764a2aaSMatthew G. Knepley PetscFunctionBegin; 6192764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 620dadcf809SJacob Faibussowitsch PetscValidIntPointer(Nf, 2); 6212764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6232764a2aaSMatthew G. Knepley } 6242764a2aaSMatthew G. Knepley 625bc4ae4beSMatthew G. Knepley /*@ 626a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 627bc4ae4beSMatthew G. Knepley 628bc4ae4beSMatthew G. Knepley Not collective 629bc4ae4beSMatthew G. Knepley 630bc4ae4beSMatthew G. Knepley Input Parameter: 631bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 632bc4ae4beSMatthew G. Knepley 633bc4ae4beSMatthew G. Knepley Output Parameter: 634bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 635bc4ae4beSMatthew G. Knepley 636bc4ae4beSMatthew G. Knepley Level: beginner 637bc4ae4beSMatthew G. Knepley 638db781477SPatrick Sanan .seealso: `PetscDSGetCoordinateDimension()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 639bc4ae4beSMatthew G. Knepley @*/ 6402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6412764a2aaSMatthew G. Knepley { 6422764a2aaSMatthew G. Knepley PetscFunctionBegin; 6432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 644dadcf809SJacob Faibussowitsch PetscValidIntPointer(dim, 2); 6452764a2aaSMatthew G. Knepley *dim = 0; 6469de99aefSMatthew G. Knepley if (prob->Nf) { 6479de99aefSMatthew G. Knepley PetscObject obj; 6489de99aefSMatthew G. Knepley PetscClassId id; 6499de99aefSMatthew G. Knepley 6509566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, 0, &obj)); 651665f567fSMatthew G. Knepley if (obj) { 6529566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 6539566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetSpatialDimension((PetscFE) obj, dim)); 6549566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVGetSpatialDimension((PetscFV) obj, dim)); 65598921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6569de99aefSMatthew G. Knepley } 657665f567fSMatthew G. Knepley } 6582764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6592764a2aaSMatthew G. Knepley } 6602764a2aaSMatthew G. Knepley 661bc4ae4beSMatthew G. Knepley /*@ 662a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 663a859676bSMatthew G. Knepley 664a859676bSMatthew G. Knepley Not collective 665a859676bSMatthew G. Knepley 666a859676bSMatthew G. Knepley Input Parameter: 667a859676bSMatthew G. Knepley . prob - The PetscDS object 668a859676bSMatthew G. Knepley 669a859676bSMatthew G. Knepley Output Parameter: 670a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 671a859676bSMatthew G. Knepley 672a859676bSMatthew G. Knepley Level: beginner 673a859676bSMatthew G. Knepley 674db781477SPatrick Sanan .seealso: `PetscDSSetCoordinateDimension()`, `PetscDSGetSpatialDimension()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 675a859676bSMatthew G. Knepley @*/ 676a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 677a859676bSMatthew G. Knepley { 678a859676bSMatthew G. Knepley PetscFunctionBegin; 679a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 680dadcf809SJacob Faibussowitsch PetscValidIntPointer(dimEmbed, 2); 68108401ef6SPierre Jolivet PetscCheck(prob->dimEmbed >= 0,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 682a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 683a859676bSMatthew G. Knepley PetscFunctionReturn(0); 684a859676bSMatthew G. Knepley } 685a859676bSMatthew G. Knepley 686a859676bSMatthew G. Knepley /*@ 687a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 688a859676bSMatthew G. Knepley 689d083f849SBarry Smith Logically collective on prob 690a859676bSMatthew G. Knepley 691a859676bSMatthew G. Knepley Input Parameters: 692a859676bSMatthew G. Knepley + prob - The PetscDS object 693a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 694a859676bSMatthew G. Knepley 695a859676bSMatthew G. Knepley Level: beginner 696a859676bSMatthew G. Knepley 697db781477SPatrick Sanan .seealso: `PetscDSGetCoordinateDimension()`, `PetscDSGetSpatialDimension()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 698a859676bSMatthew G. Knepley @*/ 699a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 700a859676bSMatthew G. Knepley { 701a859676bSMatthew G. Knepley PetscFunctionBegin; 702a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 70363a3b9bcSJacob Faibussowitsch PetscCheck(dimEmbed >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %" PetscInt_FMT, dimEmbed); 704a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 705a859676bSMatthew G. Knepley PetscFunctionReturn(0); 706a859676bSMatthew G. Knepley } 707a859676bSMatthew G. Knepley 708a859676bSMatthew G. Knepley /*@ 7095fedec97SMatthew G. Knepley PetscDSIsCohesive - Returns the flag indicating that this DS is for a cohesive cell 7108edf6225SMatthew G. Knepley 7118edf6225SMatthew G. Knepley Not collective 7128edf6225SMatthew G. Knepley 7138edf6225SMatthew G. Knepley Input Parameter: 7145fedec97SMatthew G. Knepley . ds - The PetscDS object 7158edf6225SMatthew G. Knepley 7168edf6225SMatthew G. Knepley Output Parameter: 7175fedec97SMatthew G. Knepley . isCohesive - The flag 7188edf6225SMatthew G. Knepley 7198edf6225SMatthew G. Knepley Level: developer 7208edf6225SMatthew G. Knepley 721db781477SPatrick Sanan .seealso: `PetscDSGetNumCohesive()`, `PetscDSGetCohesive()`, `PetscDSSetCohesive()`, `PetscDSCreate()` 7228edf6225SMatthew G. Knepley @*/ 7235fedec97SMatthew G. Knepley PetscErrorCode PetscDSIsCohesive(PetscDS ds, PetscBool *isCohesive) 7248edf6225SMatthew G. Knepley { 7258edf6225SMatthew G. Knepley PetscFunctionBegin; 7265fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 727dadcf809SJacob Faibussowitsch PetscValidBoolPointer(isCohesive, 2); 7285fedec97SMatthew G. Knepley *isCohesive = ds->isCohesive; 7298edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7308edf6225SMatthew G. Knepley } 7318edf6225SMatthew G. Knepley 7328edf6225SMatthew G. Knepley /*@ 7335fedec97SMatthew G. Knepley PetscDSGetNumCohesive - Returns the numer of cohesive fields, meaning those defined on the interior of a cohesive cell 7345fedec97SMatthew G. Knepley 7355fedec97SMatthew G. Knepley Not collective 7365fedec97SMatthew G. Knepley 7375fedec97SMatthew G. Knepley Input Parameter: 7385fedec97SMatthew G. Knepley . ds - The PetscDS object 7395fedec97SMatthew G. Knepley 7405fedec97SMatthew G. Knepley Output Parameter: 7415fedec97SMatthew G. Knepley . numCohesive - The number of cohesive fields 7425fedec97SMatthew G. Knepley 7435fedec97SMatthew G. Knepley Level: developer 7445fedec97SMatthew G. Knepley 745db781477SPatrick Sanan .seealso: `PetscDSSetCohesive()`, `PetscDSCreate()` 7465fedec97SMatthew G. Knepley @*/ 7475fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetNumCohesive(PetscDS ds, PetscInt *numCohesive) 7485fedec97SMatthew G. Knepley { 7495fedec97SMatthew G. Knepley PetscInt f; 7505fedec97SMatthew G. Knepley 7515fedec97SMatthew G. Knepley PetscFunctionBegin; 7525fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 753dadcf809SJacob Faibussowitsch PetscValidIntPointer(numCohesive, 2); 7545fedec97SMatthew G. Knepley *numCohesive = 0; 7555fedec97SMatthew G. Knepley for (f = 0; f < ds->Nf; ++f) *numCohesive += ds->cohesive[f] ? 1 : 0; 7565fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7575fedec97SMatthew G. Knepley } 7585fedec97SMatthew G. Knepley 7595fedec97SMatthew G. Knepley /*@ 7605fedec97SMatthew G. Knepley PetscDSGetCohesive - Returns the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7615fedec97SMatthew G. Knepley 7625fedec97SMatthew G. Knepley Not collective 7635fedec97SMatthew G. Knepley 764f1a722f8SMatthew G. Knepley Input Parameters: 7655fedec97SMatthew G. Knepley + ds - The PetscDS object 7665fedec97SMatthew G. Knepley - f - The field index 7675fedec97SMatthew G. Knepley 7685fedec97SMatthew G. Knepley Output Parameter: 7695fedec97SMatthew G. Knepley . isCohesive - The flag 7705fedec97SMatthew G. Knepley 7715fedec97SMatthew G. Knepley Level: developer 7725fedec97SMatthew G. Knepley 773db781477SPatrick Sanan .seealso: `PetscDSSetCohesive()`, `PetscDSIsCohesive()`, `PetscDSCreate()` 7745fedec97SMatthew G. Knepley @*/ 7755fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetCohesive(PetscDS ds, PetscInt f, PetscBool *isCohesive) 7765fedec97SMatthew G. Knepley { 7775fedec97SMatthew G. Knepley PetscFunctionBegin; 7785fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 779dadcf809SJacob Faibussowitsch PetscValidBoolPointer(isCohesive, 3); 78063a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 7815fedec97SMatthew G. Knepley *isCohesive = ds->cohesive[f]; 7825fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7835fedec97SMatthew G. Knepley } 7845fedec97SMatthew G. Knepley 7855fedec97SMatthew G. Knepley /*@ 7865fedec97SMatthew G. Knepley PetscDSSetCohesive - Set the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7878edf6225SMatthew G. Knepley 7888edf6225SMatthew G. Knepley Not collective 7898edf6225SMatthew G. Knepley 7908edf6225SMatthew G. Knepley Input Parameters: 7915fedec97SMatthew G. Knepley + ds - The PetscDS object 7925fedec97SMatthew G. Knepley . f - The field index 7935fedec97SMatthew G. Knepley - isCohesive - The flag for a cohesive field 7948edf6225SMatthew G. Knepley 7958edf6225SMatthew G. Knepley Level: developer 7968edf6225SMatthew G. Knepley 797db781477SPatrick Sanan .seealso: `PetscDSGetCohesive()`, `PetscDSIsCohesive()`, `PetscDSCreate()` 7988edf6225SMatthew G. Knepley @*/ 7995fedec97SMatthew G. Knepley PetscErrorCode PetscDSSetCohesive(PetscDS ds, PetscInt f, PetscBool isCohesive) 8008edf6225SMatthew G. Knepley { 8015fedec97SMatthew G. Knepley PetscInt i; 8025fedec97SMatthew G. Knepley 8038edf6225SMatthew G. Knepley PetscFunctionBegin; 8045fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 80563a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 8065fedec97SMatthew G. Knepley ds->cohesive[f] = isCohesive; 8075fedec97SMatthew G. Knepley ds->isCohesive = PETSC_FALSE; 8085fedec97SMatthew G. Knepley for (i = 0; i < ds->Nf; ++i) ds->isCohesive = ds->isCohesive || ds->cohesive[f] ? PETSC_TRUE : PETSC_FALSE; 8098edf6225SMatthew G. Knepley PetscFunctionReturn(0); 8108edf6225SMatthew G. Knepley } 8118edf6225SMatthew G. Knepley 8128edf6225SMatthew G. Knepley /*@ 813bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 814bc4ae4beSMatthew G. Knepley 815bc4ae4beSMatthew G. Knepley Not collective 816bc4ae4beSMatthew G. Knepley 817bc4ae4beSMatthew G. Knepley Input Parameter: 818bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 819bc4ae4beSMatthew G. Knepley 820bc4ae4beSMatthew G. Knepley Output Parameter: 821bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 822bc4ae4beSMatthew G. Knepley 823bc4ae4beSMatthew G. Knepley Level: beginner 824bc4ae4beSMatthew G. Knepley 825db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 826bc4ae4beSMatthew G. Knepley @*/ 8272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 8282764a2aaSMatthew G. Knepley { 8292764a2aaSMatthew G. Knepley PetscFunctionBegin; 8302764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8319566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 832dadcf809SJacob Faibussowitsch PetscValidIntPointer(dim, 2); 8332764a2aaSMatthew G. Knepley *dim = prob->totDim; 8342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8352764a2aaSMatthew G. Knepley } 8362764a2aaSMatthew G. Knepley 837bc4ae4beSMatthew G. Knepley /*@ 838bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 839bc4ae4beSMatthew G. Knepley 840bc4ae4beSMatthew G. Knepley Not collective 841bc4ae4beSMatthew G. Knepley 842bc4ae4beSMatthew G. Knepley Input Parameter: 843bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 844bc4ae4beSMatthew G. Knepley 845bc4ae4beSMatthew G. Knepley Output Parameter: 846bc4ae4beSMatthew G. Knepley . dim - The total number of components 847bc4ae4beSMatthew G. Knepley 848bc4ae4beSMatthew G. Knepley Level: beginner 849bc4ae4beSMatthew G. Knepley 850db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 851bc4ae4beSMatthew G. Knepley @*/ 8522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8532764a2aaSMatthew G. Knepley { 8542764a2aaSMatthew G. Knepley PetscFunctionBegin; 8552764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8569566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 857dadcf809SJacob Faibussowitsch PetscValidIntPointer(Nc, 2); 8582764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8602764a2aaSMatthew G. Knepley } 8612764a2aaSMatthew G. Knepley 862bc4ae4beSMatthew G. Knepley /*@ 863bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 864bc4ae4beSMatthew G. Knepley 865bc4ae4beSMatthew G. Knepley Not collective 866bc4ae4beSMatthew G. Knepley 867bc4ae4beSMatthew G. Knepley Input Parameters: 868bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 869bc4ae4beSMatthew G. Knepley - f - The field number 870bc4ae4beSMatthew G. Knepley 871bc4ae4beSMatthew G. Knepley Output Parameter: 872bc4ae4beSMatthew G. Knepley . disc - The discretization object 873bc4ae4beSMatthew G. Knepley 874bc4ae4beSMatthew G. Knepley Level: beginner 875bc4ae4beSMatthew G. Knepley 876db781477SPatrick Sanan .seealso: `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 877bc4ae4beSMatthew G. Knepley @*/ 8782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8792764a2aaSMatthew G. Knepley { 8806528b96dSMatthew G. Knepley PetscFunctionBeginHot; 8812764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8822764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 88363a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 8842764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8862764a2aaSMatthew G. Knepley } 8872764a2aaSMatthew G. Knepley 888bc4ae4beSMatthew G. Knepley /*@ 889bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 890bc4ae4beSMatthew G. Knepley 891bc4ae4beSMatthew G. Knepley Not collective 892bc4ae4beSMatthew G. Knepley 893bc4ae4beSMatthew G. Knepley Input Parameters: 894bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 895bc4ae4beSMatthew G. Knepley . f - The field number 896bc4ae4beSMatthew G. Knepley - disc - The discretization object 897bc4ae4beSMatthew G. Knepley 898bc4ae4beSMatthew G. Knepley Level: beginner 899bc4ae4beSMatthew G. Knepley 900db781477SPatrick Sanan .seealso: `PetscDSGetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 901bc4ae4beSMatthew G. Knepley @*/ 9022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 9032764a2aaSMatthew G. Knepley { 9042764a2aaSMatthew G. Knepley PetscFunctionBegin; 9052764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 906665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 90763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 9089566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 9099566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference(prob->disc[f])); 9102764a2aaSMatthew G. Knepley prob->disc[f] = disc; 9119566063dSJacob Faibussowitsch PetscCall(PetscObjectReference(disc)); 912665f567fSMatthew G. Knepley if (disc) { 913249df284SMatthew G. Knepley PetscClassId id; 914249df284SMatthew G. Knepley 9159566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(disc, &id)); 9161cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 9179566063dSJacob Faibussowitsch PetscCall(PetscDSSetImplicit(prob, f, PETSC_TRUE)); 9181cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 9199566063dSJacob Faibussowitsch PetscCall(PetscDSSetImplicit(prob, f, PETSC_FALSE)); 920a6cbbb48SMatthew G. Knepley } 9219566063dSJacob Faibussowitsch PetscCall(PetscDSSetJetDegree(prob, f, 1)); 922249df284SMatthew G. Knepley } 9232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9242764a2aaSMatthew G. Knepley } 9252764a2aaSMatthew G. Knepley 926bc4ae4beSMatthew G. Knepley /*@ 9276528b96dSMatthew G. Knepley PetscDSGetWeakForm - Returns the weak form object 9286528b96dSMatthew G. Knepley 9296528b96dSMatthew G. Knepley Not collective 9306528b96dSMatthew G. Knepley 9316528b96dSMatthew G. Knepley Input Parameter: 9326528b96dSMatthew G. Knepley . ds - The PetscDS object 9336528b96dSMatthew G. Knepley 9346528b96dSMatthew G. Knepley Output Parameter: 9356528b96dSMatthew G. Knepley . wf - The weak form object 9366528b96dSMatthew G. Knepley 9376528b96dSMatthew G. Knepley Level: beginner 9386528b96dSMatthew G. Knepley 939db781477SPatrick Sanan .seealso: `PetscDSSetWeakForm()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 9406528b96dSMatthew G. Knepley @*/ 9416528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetWeakForm(PetscDS ds, PetscWeakForm *wf) 9426528b96dSMatthew G. Knepley { 9436528b96dSMatthew G. Knepley PetscFunctionBegin; 9446528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9456528b96dSMatthew G. Knepley PetscValidPointer(wf, 2); 9466528b96dSMatthew G. Knepley *wf = ds->wf; 9476528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9486528b96dSMatthew G. Knepley } 9496528b96dSMatthew G. Knepley 9506528b96dSMatthew G. Knepley /*@ 9516528b96dSMatthew G. Knepley PetscDSSetWeakForm - Sets the weak form object 9526528b96dSMatthew G. Knepley 9536528b96dSMatthew G. Knepley Not collective 9546528b96dSMatthew G. Knepley 9556528b96dSMatthew G. Knepley Input Parameters: 9566528b96dSMatthew G. Knepley + ds - The PetscDS object 9576528b96dSMatthew G. Knepley - wf - The weak form object 9586528b96dSMatthew G. Knepley 9596528b96dSMatthew G. Knepley Level: beginner 9606528b96dSMatthew G. Knepley 961db781477SPatrick Sanan .seealso: `PetscDSGetWeakForm()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 9626528b96dSMatthew G. Knepley @*/ 9636528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetWeakForm(PetscDS ds, PetscWeakForm wf) 9646528b96dSMatthew G. Knepley { 9656528b96dSMatthew G. Knepley PetscFunctionBegin; 9666528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9676528b96dSMatthew G. Knepley PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 2); 9689566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference((PetscObject) ds->wf)); 9696528b96dSMatthew G. Knepley ds->wf = wf; 9709566063dSJacob Faibussowitsch PetscCall(PetscObjectReference((PetscObject) wf)); 9719566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(wf, ds->Nf)); 9726528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9736528b96dSMatthew G. Knepley } 9746528b96dSMatthew G. Knepley 9756528b96dSMatthew G. Knepley /*@ 976bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 977bc4ae4beSMatthew G. Knepley 978bc4ae4beSMatthew G. Knepley Not collective 979bc4ae4beSMatthew G. Knepley 980bc4ae4beSMatthew G. Knepley Input Parameters: 981bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 982bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 983bc4ae4beSMatthew G. Knepley 984bc4ae4beSMatthew G. Knepley Level: beginner 985bc4ae4beSMatthew G. Knepley 986db781477SPatrick Sanan .seealso: `PetscDSGetDiscretization()`, `PetscDSSetDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 987bc4ae4beSMatthew G. Knepley @*/ 9882764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9892764a2aaSMatthew G. Knepley { 9902764a2aaSMatthew G. Knepley PetscFunctionBegin; 9919566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(prob, prob->Nf, disc)); 9922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9932764a2aaSMatthew G. Knepley } 9942764a2aaSMatthew G. Knepley 995249df284SMatthew G. Knepley /*@ 996083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 997083401c6SMatthew G. Knepley 998083401c6SMatthew G. Knepley Not collective 999083401c6SMatthew G. Knepley 1000083401c6SMatthew G. Knepley Input Parameter: 1001083401c6SMatthew G. Knepley . prob - The PetscDS object 1002083401c6SMatthew G. Knepley 1003083401c6SMatthew G. Knepley Output Parameter: 1004083401c6SMatthew G. Knepley . q - The quadrature object 1005083401c6SMatthew G. Knepley 1006083401c6SMatthew G. Knepley Level: intermediate 1007083401c6SMatthew G. Knepley 1008db781477SPatrick Sanan .seealso: `PetscDSSetImplicit()`, `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 1009083401c6SMatthew G. Knepley @*/ 1010083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 1011083401c6SMatthew G. Knepley { 1012083401c6SMatthew G. Knepley PetscObject obj; 1013083401c6SMatthew G. Knepley PetscClassId id; 1014083401c6SMatthew G. Knepley 1015083401c6SMatthew G. Knepley PetscFunctionBegin; 1016083401c6SMatthew G. Knepley *q = NULL; 1017083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 10189566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, 0, &obj)); 10199566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 10209566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetQuadrature((PetscFE) obj, q)); 10219566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVGetQuadrature((PetscFV) obj, q)); 102298921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 1023083401c6SMatthew G. Knepley PetscFunctionReturn(0); 1024083401c6SMatthew G. Knepley } 1025083401c6SMatthew G. Knepley 1026083401c6SMatthew G. Knepley /*@ 1027249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 1028249df284SMatthew G. Knepley 1029249df284SMatthew G. Knepley Not collective 1030249df284SMatthew G. Knepley 1031249df284SMatthew G. Knepley Input Parameters: 1032249df284SMatthew G. Knepley + prob - The PetscDS object 1033249df284SMatthew G. Knepley - f - The field number 1034249df284SMatthew G. Knepley 1035249df284SMatthew G. Knepley Output Parameter: 1036249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 1037249df284SMatthew G. Knepley 1038249df284SMatthew G. Knepley Level: developer 1039249df284SMatthew G. Knepley 1040db781477SPatrick Sanan .seealso: `PetscDSSetImplicit()`, `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 1041249df284SMatthew G. Knepley @*/ 1042249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 1043249df284SMatthew G. Knepley { 1044249df284SMatthew G. Knepley PetscFunctionBegin; 1045249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1046dadcf809SJacob Faibussowitsch PetscValidBoolPointer(implicit, 3); 104763a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 1048249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 1049249df284SMatthew G. Knepley PetscFunctionReturn(0); 1050249df284SMatthew G. Knepley } 1051249df284SMatthew G. Knepley 1052249df284SMatthew G. Knepley /*@ 1053249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 1054249df284SMatthew G. Knepley 1055249df284SMatthew G. Knepley Not collective 1056249df284SMatthew G. Knepley 1057249df284SMatthew G. Knepley Input Parameters: 1058249df284SMatthew G. Knepley + prob - The PetscDS object 1059249df284SMatthew G. Knepley . f - The field number 1060249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 1061249df284SMatthew G. Knepley 1062249df284SMatthew G. Knepley Level: developer 1063249df284SMatthew G. Knepley 1064db781477SPatrick Sanan .seealso: `PetscDSGetImplicit()`, `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 1065249df284SMatthew G. Knepley @*/ 1066249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 1067249df284SMatthew G. Knepley { 1068249df284SMatthew G. Knepley PetscFunctionBegin; 1069249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 107063a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 1071249df284SMatthew G. Knepley prob->implicit[f] = implicit; 1072249df284SMatthew G. Knepley PetscFunctionReturn(0); 1073249df284SMatthew G. Knepley } 1074249df284SMatthew G. Knepley 1075f9244615SMatthew G. Knepley /*@ 1076f9244615SMatthew G. Knepley PetscDSGetJetDegree - Returns the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1077f9244615SMatthew G. Knepley 1078f9244615SMatthew G. Knepley Not collective 1079f9244615SMatthew G. Knepley 1080f9244615SMatthew G. Knepley Input Parameters: 1081f9244615SMatthew G. Knepley + ds - The PetscDS object 1082f9244615SMatthew G. Knepley - f - The field number 1083f9244615SMatthew G. Knepley 1084f9244615SMatthew G. Knepley Output Parameter: 1085f9244615SMatthew G. Knepley . k - The highest derivative we need to tabulate 1086f9244615SMatthew G. Knepley 1087f9244615SMatthew G. Knepley Level: developer 1088f9244615SMatthew G. Knepley 1089db781477SPatrick Sanan .seealso: `PetscDSSetJetDegree()`, `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 1090f9244615SMatthew G. Knepley @*/ 1091f9244615SMatthew G. Knepley PetscErrorCode PetscDSGetJetDegree(PetscDS ds, PetscInt f, PetscInt *k) 1092f9244615SMatthew G. Knepley { 1093f9244615SMatthew G. Knepley PetscFunctionBegin; 1094f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1095dadcf809SJacob Faibussowitsch PetscValidIntPointer(k, 3); 109663a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 1097f9244615SMatthew G. Knepley *k = ds->jetDegree[f]; 1098f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1099f9244615SMatthew G. Knepley } 1100f9244615SMatthew G. Knepley 1101f9244615SMatthew G. Knepley /*@ 1102f9244615SMatthew G. Knepley PetscDSSetJetDegree - Set the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1103f9244615SMatthew G. Knepley 1104f9244615SMatthew G. Knepley Not collective 1105f9244615SMatthew G. Knepley 1106f9244615SMatthew G. Knepley Input Parameters: 1107f9244615SMatthew G. Knepley + ds - The PetscDS object 1108f9244615SMatthew G. Knepley . f - The field number 1109f9244615SMatthew G. Knepley - k - The highest derivative we need to tabulate 1110f9244615SMatthew G. Knepley 1111f9244615SMatthew G. Knepley Level: developer 1112f9244615SMatthew G. Knepley 1113db781477SPatrick Sanan .seealso: `PetscDSGetJetDegree()`, `PetscDSSetDiscretization()`, `PetscDSAddDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 1114f9244615SMatthew G. Knepley @*/ 1115f9244615SMatthew G. Knepley PetscErrorCode PetscDSSetJetDegree(PetscDS ds, PetscInt f, PetscInt k) 1116f9244615SMatthew G. Knepley { 1117f9244615SMatthew G. Knepley PetscFunctionBegin; 1118f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 111963a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 1120f9244615SMatthew G. Knepley ds->jetDegree[f] = k; 1121f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1122f9244615SMatthew G. Knepley } 1123f9244615SMatthew G. Knepley 11246528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS ds, PetscInt f, 112530b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1126194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1127194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 112897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11292764a2aaSMatthew G. Knepley { 11306528b96dSMatthew G. Knepley PetscPointFunc *tmp; 11316528b96dSMatthew G. Knepley PetscInt n; 11326528b96dSMatthew G. Knepley 11332764a2aaSMatthew G. Knepley PetscFunctionBegin; 11346528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11356528b96dSMatthew G. Knepley PetscValidPointer(obj, 3); 113663a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 11379566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetObjective(ds->wf, NULL, 0, f, 0, &n, &tmp)); 11386528b96dSMatthew G. Knepley *obj = tmp ? tmp[0] : NULL; 11392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11402764a2aaSMatthew G. Knepley } 11412764a2aaSMatthew G. Knepley 11426528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS ds, PetscInt f, 114330b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1144194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1145194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 114697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11472764a2aaSMatthew G. Knepley { 11482764a2aaSMatthew G. Knepley PetscFunctionBegin; 11496528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11506528b96dSMatthew G. Knepley if (obj) PetscValidFunction(obj, 3); 115163a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 11529566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexObjective(ds->wf, NULL, 0, f, 0, 0, obj)); 11532764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11542764a2aaSMatthew G. Knepley } 11552764a2aaSMatthew G. Knepley 1156194d53e6SMatthew G. Knepley /*@C 1157194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1158194d53e6SMatthew G. Knepley 1159194d53e6SMatthew G. Knepley Not collective 1160194d53e6SMatthew G. Knepley 1161194d53e6SMatthew G. Knepley Input Parameters: 11626528b96dSMatthew G. Knepley + ds - The PetscDS 1163194d53e6SMatthew G. Knepley - f - The test field number 1164194d53e6SMatthew G. Knepley 1165194d53e6SMatthew G. Knepley Output Parameters: 1166194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1167194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1168194d53e6SMatthew G. Knepley 1169194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1170194d53e6SMatthew G. Knepley 1171194d53e6SMatthew 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) 1172194d53e6SMatthew G. Knepley 1173194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1174194d53e6SMatthew G. Knepley 117530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1176194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1177194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1179194d53e6SMatthew G. Knepley 1180194d53e6SMatthew G. Knepley + dim - the spatial dimension 1181194d53e6SMatthew G. Knepley . Nf - the number of fields 1182194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1183194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1184194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1185194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1186194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1187194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1188194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1189194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1190194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1191194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1192194d53e6SMatthew G. Knepley . t - current time 1193194d53e6SMatthew G. Knepley . x - coordinates of the current point 119497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 119597b6e6e8SMatthew G. Knepley . constants - constant parameters 1196194d53e6SMatthew G. Knepley - f0 - output values at the current point 1197194d53e6SMatthew G. Knepley 1198194d53e6SMatthew G. Knepley Level: intermediate 1199194d53e6SMatthew G. Knepley 1200db781477SPatrick Sanan .seealso: `PetscDSSetResidual()` 1201194d53e6SMatthew G. Knepley @*/ 12026528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS ds, PetscInt f, 120330b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1204194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1205194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 120730b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1208194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1209194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12112764a2aaSMatthew G. Knepley { 12126528b96dSMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 12136528b96dSMatthew G. Knepley PetscInt n0, n1; 12146528b96dSMatthew G. Knepley 12152764a2aaSMatthew G. Knepley PetscFunctionBegin; 12166528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 121763a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 12189566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 12196528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 12206528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 12212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12222764a2aaSMatthew G. Knepley } 12232764a2aaSMatthew G. Knepley 1224194d53e6SMatthew G. Knepley /*@C 1225194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1226194d53e6SMatthew G. Knepley 1227194d53e6SMatthew G. Knepley Not collective 1228194d53e6SMatthew G. Knepley 1229194d53e6SMatthew G. Knepley Input Parameters: 12306528b96dSMatthew G. Knepley + ds - The PetscDS 1231194d53e6SMatthew G. Knepley . f - The test field number 1232194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1233194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1234194d53e6SMatthew G. Knepley 1235194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1236194d53e6SMatthew G. Knepley 1237194d53e6SMatthew 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) 1238194d53e6SMatthew G. Knepley 1239194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1240194d53e6SMatthew G. Knepley 124130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1242194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1243194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1245194d53e6SMatthew G. Knepley 1246194d53e6SMatthew G. Knepley + dim - the spatial dimension 1247194d53e6SMatthew G. Knepley . Nf - the number of fields 1248194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1249194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1250194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1251194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1252194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1253194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1254194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1255194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1256194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1257194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1258194d53e6SMatthew G. Knepley . t - current time 1259194d53e6SMatthew G. Knepley . x - coordinates of the current point 126097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 126197b6e6e8SMatthew G. Knepley . constants - constant parameters 1262194d53e6SMatthew G. Knepley - f0 - output values at the current point 1263194d53e6SMatthew G. Knepley 1264194d53e6SMatthew G. Knepley Level: intermediate 1265194d53e6SMatthew G. Knepley 1266db781477SPatrick Sanan .seealso: `PetscDSGetResidual()` 1267194d53e6SMatthew G. Knepley @*/ 12686528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS ds, PetscInt f, 126930b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1270194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1271194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 127330b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1274194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1275194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12772764a2aaSMatthew G. Knepley { 12782764a2aaSMatthew G. Knepley PetscFunctionBegin; 12796528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1280f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1281f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 128263a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 12839566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 12842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12852764a2aaSMatthew G. Knepley } 12862764a2aaSMatthew G. Knepley 12873e75805dSMatthew G. Knepley /*@C 1288cb36c0f9SMatthew G. Knepley PetscDSGetRHSResidual - Get the pointwise RHS residual function for explicit timestepping for a given test field 1289cb36c0f9SMatthew G. Knepley 1290cb36c0f9SMatthew G. Knepley Not collective 1291cb36c0f9SMatthew G. Knepley 1292cb36c0f9SMatthew G. Knepley Input Parameters: 1293cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1294cb36c0f9SMatthew G. Knepley - f - The test field number 1295cb36c0f9SMatthew G. Knepley 1296cb36c0f9SMatthew G. Knepley Output Parameters: 1297cb36c0f9SMatthew G. Knepley + f0 - integrand for the test function term 1298cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1299cb36c0f9SMatthew G. Knepley 1300cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1301cb36c0f9SMatthew G. Knepley 1302cb36c0f9SMatthew 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) 1303cb36c0f9SMatthew G. Knepley 1304cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1305cb36c0f9SMatthew G. Knepley 1306cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1307cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1308cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1309cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1310cb36c0f9SMatthew G. Knepley 1311cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1312cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1313cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1314cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1315cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1316cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1317cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1318cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1319cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1320cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1321cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1322cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1323cb36c0f9SMatthew G. Knepley . t - current time 1324cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1325cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1326cb36c0f9SMatthew G. Knepley . constants - constant parameters 1327cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1328cb36c0f9SMatthew G. Knepley 1329cb36c0f9SMatthew G. Knepley Level: intermediate 1330cb36c0f9SMatthew G. Knepley 1331db781477SPatrick Sanan .seealso: `PetscDSSetRHSResidual()` 1332cb36c0f9SMatthew G. Knepley @*/ 1333cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSGetRHSResidual(PetscDS ds, PetscInt f, 1334cb36c0f9SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1335cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1336cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1337cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1338cb36c0f9SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1339cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1340cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1341cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1342cb36c0f9SMatthew G. Knepley { 1343cb36c0f9SMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 1344cb36c0f9SMatthew G. Knepley PetscInt n0, n1; 1345cb36c0f9SMatthew G. Knepley 1346cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1347cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 134863a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 13499566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 100, &n0, &tmp0, &n1, &tmp1)); 1350cb36c0f9SMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 1351cb36c0f9SMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 1352cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1353cb36c0f9SMatthew G. Knepley } 1354cb36c0f9SMatthew G. Knepley 1355cb36c0f9SMatthew G. Knepley /*@C 1356cb36c0f9SMatthew G. Knepley PetscDSSetRHSResidual - Set the pointwise residual function for explicit timestepping for a given test field 1357cb36c0f9SMatthew G. Knepley 1358cb36c0f9SMatthew G. Knepley Not collective 1359cb36c0f9SMatthew G. Knepley 1360cb36c0f9SMatthew G. Knepley Input Parameters: 1361cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1362cb36c0f9SMatthew G. Knepley . f - The test field number 1363cb36c0f9SMatthew G. Knepley . f0 - integrand for the test function term 1364cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1365cb36c0f9SMatthew G. Knepley 1366cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1367cb36c0f9SMatthew G. Knepley 1368cb36c0f9SMatthew 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) 1369cb36c0f9SMatthew G. Knepley 1370cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1371cb36c0f9SMatthew G. Knepley 1372cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1373cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1374cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1375cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1376cb36c0f9SMatthew G. Knepley 1377cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1378cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1379cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1380cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1381cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1382cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1383cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1384cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1385cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1386cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1387cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1388cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1389cb36c0f9SMatthew G. Knepley . t - current time 1390cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1391cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1392cb36c0f9SMatthew G. Knepley . constants - constant parameters 1393cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1394cb36c0f9SMatthew G. Knepley 1395cb36c0f9SMatthew G. Knepley Level: intermediate 1396cb36c0f9SMatthew G. Knepley 1397db781477SPatrick Sanan .seealso: `PetscDSGetResidual()` 1398cb36c0f9SMatthew G. Knepley @*/ 1399cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSSetRHSResidual(PetscDS ds, PetscInt f, 1400cb36c0f9SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1401cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1402cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1403cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1404cb36c0f9SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1405cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1406cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1407cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1408cb36c0f9SMatthew G. Knepley { 1409cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1410cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1411cb36c0f9SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1412cb36c0f9SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 141363a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 14149566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 100, 0, f0, 0, f1)); 1415cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1416cb36c0f9SMatthew G. Knepley } 1417cb36c0f9SMatthew G. Knepley 1418cb36c0f9SMatthew G. Knepley /*@C 14193e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 14203e75805dSMatthew G. Knepley 14213e75805dSMatthew G. Knepley Not collective 14223e75805dSMatthew G. Knepley 14233e75805dSMatthew G. Knepley Input Parameter: 14243e75805dSMatthew G. Knepley . prob - The PetscDS 14253e75805dSMatthew G. Knepley 14263e75805dSMatthew G. Knepley Output Parameter: 14273e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 14283e75805dSMatthew G. Knepley 14293e75805dSMatthew G. Knepley Level: intermediate 14303e75805dSMatthew G. Knepley 1431db781477SPatrick Sanan .seealso: `PetscDSGetJacobianPreconditioner()`, `PetscDSSetJacobianPreconditioner()`, `PetscDSGetJacobian()` 14323e75805dSMatthew G. Knepley @*/ 14336528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS ds, PetscBool *hasJac) 14343e75805dSMatthew G. Knepley { 14353e75805dSMatthew G. Knepley PetscFunctionBegin; 14366528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14379566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasJacobian(ds->wf, hasJac)); 14383e75805dSMatthew G. Knepley PetscFunctionReturn(0); 14393e75805dSMatthew G. Knepley } 14403e75805dSMatthew G. Knepley 1441194d53e6SMatthew G. Knepley /*@C 1442194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1443194d53e6SMatthew G. Knepley 1444194d53e6SMatthew G. Knepley Not collective 1445194d53e6SMatthew G. Knepley 1446194d53e6SMatthew G. Knepley Input Parameters: 14476528b96dSMatthew G. Knepley + ds - The PetscDS 1448194d53e6SMatthew G. Knepley . f - The test field number 1449194d53e6SMatthew G. Knepley - g - The field number 1450194d53e6SMatthew G. Knepley 1451194d53e6SMatthew G. Knepley Output Parameters: 1452194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1453194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1454194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1455194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1456194d53e6SMatthew G. Knepley 1457194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1458194d53e6SMatthew G. Knepley 1459194d53e6SMatthew 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 1460194d53e6SMatthew G. Knepley 1461194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1462194d53e6SMatthew G. Knepley 146330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1464194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1465194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1467194d53e6SMatthew G. Knepley 1468194d53e6SMatthew G. Knepley + dim - the spatial dimension 1469194d53e6SMatthew G. Knepley . Nf - the number of fields 1470194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1471194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1472194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1473194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1474194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1475194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1476194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1477194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1478194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1479194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1480194d53e6SMatthew G. Knepley . t - current time 14812aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1482194d53e6SMatthew G. Knepley . x - coordinates of the current point 148397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 148497b6e6e8SMatthew G. Knepley . constants - constant parameters 1485194d53e6SMatthew G. Knepley - g0 - output values at the current point 1486194d53e6SMatthew G. Knepley 1487194d53e6SMatthew G. Knepley Level: intermediate 1488194d53e6SMatthew G. Knepley 1489db781477SPatrick Sanan .seealso: `PetscDSSetJacobian()` 1490194d53e6SMatthew G. Knepley @*/ 14916528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS ds, PetscInt f, PetscInt g, 149230b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1493194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1494194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 149630b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1497194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1498194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 150030b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1501194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1502194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 150430b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1505194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1506194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15082764a2aaSMatthew G. Knepley { 15096528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 15106528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 15116528b96dSMatthew G. Knepley 15122764a2aaSMatthew G. Knepley PetscFunctionBegin; 15136528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 151463a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 151563a3b9bcSJacob Faibussowitsch PetscCheck(!(g < 0) && !(g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", g, ds->Nf); 15169566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 15176528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 15186528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 15196528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 15206528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 15212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15222764a2aaSMatthew G. Knepley } 15232764a2aaSMatthew G. Knepley 1524194d53e6SMatthew G. Knepley /*@C 1525194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1526194d53e6SMatthew G. Knepley 1527194d53e6SMatthew G. Knepley Not collective 1528194d53e6SMatthew G. Knepley 1529194d53e6SMatthew G. Knepley Input Parameters: 15306528b96dSMatthew G. Knepley + ds - The PetscDS 1531194d53e6SMatthew G. Knepley . f - The test field number 1532194d53e6SMatthew G. Knepley . g - The field number 1533194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1534194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1535194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1536194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1537194d53e6SMatthew G. Knepley 1538194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1539194d53e6SMatthew G. Knepley 1540194d53e6SMatthew 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 1541194d53e6SMatthew G. Knepley 1542194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1543194d53e6SMatthew G. Knepley 154430b9ff8bSMatthew G. Knepley $ g0(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[], 154730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1548194d53e6SMatthew G. Knepley 1549194d53e6SMatthew G. Knepley + dim - the spatial dimension 1550194d53e6SMatthew G. Knepley . Nf - the number of fields 1551194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1552194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1553194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1554194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1555194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1556194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1557194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1558194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1559194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1560194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1561194d53e6SMatthew G. Knepley . t - current time 15622aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1563194d53e6SMatthew G. Knepley . x - coordinates of the current point 156497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 156597b6e6e8SMatthew G. Knepley . constants - constant parameters 1566194d53e6SMatthew G. Knepley - g0 - output values at the current point 1567194d53e6SMatthew G. Knepley 1568194d53e6SMatthew G. Knepley Level: intermediate 1569194d53e6SMatthew G. Knepley 1570db781477SPatrick Sanan .seealso: `PetscDSGetJacobian()` 1571194d53e6SMatthew G. Knepley @*/ 15726528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS ds, PetscInt f, PetscInt g, 157330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1574194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1575194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 157697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 157730b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1578194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1579194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 158130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1582194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1583194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 158530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1586194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1587194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15892764a2aaSMatthew G. Knepley { 15902764a2aaSMatthew G. Knepley PetscFunctionBegin; 15916528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15922764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 15932764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 15942764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 15952764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 159663a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 159763a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 15989566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 15992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16002764a2aaSMatthew G. Knepley } 16012764a2aaSMatthew G. Knepley 1602475e0ac9SMatthew G. Knepley /*@C 160355c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 160455c1f793SMatthew G. Knepley 160555c1f793SMatthew G. Knepley Not collective 160655c1f793SMatthew G. Knepley 160755c1f793SMatthew G. Knepley Input Parameters: 160855c1f793SMatthew G. Knepley + prob - The PetscDS 160955c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 161055c1f793SMatthew G. Knepley 161155c1f793SMatthew G. Knepley Level: intermediate 161255c1f793SMatthew G. Knepley 1613db781477SPatrick Sanan .seealso: `PetscDSGetJacobianPreconditioner()`, `PetscDSSetJacobianPreconditioner()`, `PetscDSGetJacobian()` 161455c1f793SMatthew G. Knepley @*/ 161555c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 161655c1f793SMatthew G. Knepley { 161755c1f793SMatthew G. Knepley PetscFunctionBegin; 161855c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 161955c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 162055c1f793SMatthew G. Knepley PetscFunctionReturn(0); 162155c1f793SMatthew G. Knepley } 162255c1f793SMatthew G. Knepley 162355c1f793SMatthew G. Knepley /*@C 1624475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1625475e0ac9SMatthew G. Knepley 1626475e0ac9SMatthew G. Knepley Not collective 1627475e0ac9SMatthew G. Knepley 1628475e0ac9SMatthew G. Knepley Input Parameter: 1629475e0ac9SMatthew G. Knepley . prob - The PetscDS 1630475e0ac9SMatthew G. Knepley 1631475e0ac9SMatthew G. Knepley Output Parameter: 1632475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1633475e0ac9SMatthew G. Knepley 1634475e0ac9SMatthew G. Knepley Level: intermediate 1635475e0ac9SMatthew G. Knepley 1636db781477SPatrick Sanan .seealso: `PetscDSGetJacobianPreconditioner()`, `PetscDSSetJacobianPreconditioner()`, `PetscDSGetJacobian()` 1637475e0ac9SMatthew G. Knepley @*/ 16386528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS ds, PetscBool *hasJacPre) 1639475e0ac9SMatthew G. Knepley { 1640475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16416528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1642475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 16436528b96dSMatthew G. Knepley if (!ds->useJacPre) PetscFunctionReturn(0); 16449566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasJacobianPreconditioner(ds->wf, hasJacPre)); 1645475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1646475e0ac9SMatthew G. Knepley } 1647475e0ac9SMatthew G. Knepley 1648475e0ac9SMatthew G. Knepley /*@C 1649475e0ac9SMatthew G. Knepley PetscDSGetJacobianPreconditioner - Get the pointwise Jacobian preconditioner function for given test and basis field. If this is missing, the system matrix is used to build the preconditioner. 1650475e0ac9SMatthew G. Knepley 1651475e0ac9SMatthew G. Knepley Not collective 1652475e0ac9SMatthew G. Knepley 1653475e0ac9SMatthew G. Knepley Input Parameters: 16546528b96dSMatthew G. Knepley + ds - The PetscDS 1655475e0ac9SMatthew G. Knepley . f - The test field number 1656475e0ac9SMatthew G. Knepley - g - The field number 1657475e0ac9SMatthew G. Knepley 1658475e0ac9SMatthew G. Knepley Output Parameters: 1659475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1660475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1661475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1662475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1663475e0ac9SMatthew G. Knepley 1664475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1665475e0ac9SMatthew G. Knepley 1666475e0ac9SMatthew 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 1667475e0ac9SMatthew G. Knepley 1668475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1669475e0ac9SMatthew G. Knepley 1670475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1671475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1672475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1673475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1674475e0ac9SMatthew G. Knepley 1675475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1676475e0ac9SMatthew G. Knepley . Nf - the number of fields 1677475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1678475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1679475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1680475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1681475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1682475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1683475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1684475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1685475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1686475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1687475e0ac9SMatthew G. Knepley . t - current time 1688475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1689475e0ac9SMatthew G. Knepley . x - coordinates of the current point 169097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 169197b6e6e8SMatthew G. Knepley . constants - constant parameters 1692475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1693475e0ac9SMatthew G. Knepley 1694475e0ac9SMatthew G. Knepley Level: intermediate 1695475e0ac9SMatthew G. Knepley 1696db781477SPatrick Sanan .seealso: `PetscDSSetJacobianPreconditioner()`, `PetscDSGetJacobian()` 1697475e0ac9SMatthew G. Knepley @*/ 16986528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1699475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1700475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1701475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1703475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1704475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1705475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1707475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1708475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1709475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1711475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1712475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1713475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1715475e0ac9SMatthew G. Knepley { 17166528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 17176528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 17186528b96dSMatthew G. Knepley 1719475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17206528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 172163a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 172263a3b9bcSJacob Faibussowitsch PetscCheck(!(g < 0) && !(g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", g, ds->Nf); 17239566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 17246528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 17256528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 17266528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 17276528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1728475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1729475e0ac9SMatthew G. Knepley } 1730475e0ac9SMatthew G. Knepley 1731475e0ac9SMatthew G. Knepley /*@C 1732475e0ac9SMatthew G. Knepley PetscDSSetJacobianPreconditioner - Set the pointwise Jacobian preconditioner function for given test and basis fields. If this is missing, the system matrix is used to build the preconditioner. 1733475e0ac9SMatthew G. Knepley 1734475e0ac9SMatthew G. Knepley Not collective 1735475e0ac9SMatthew G. Knepley 1736475e0ac9SMatthew G. Knepley Input Parameters: 17376528b96dSMatthew G. Knepley + ds - The PetscDS 1738475e0ac9SMatthew G. Knepley . f - The test field number 1739475e0ac9SMatthew G. Knepley . g - The field number 1740475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1741475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1742475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1743475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1744475e0ac9SMatthew G. Knepley 1745475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1746475e0ac9SMatthew G. Knepley 1747475e0ac9SMatthew 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 1748475e0ac9SMatthew G. Knepley 1749475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1750475e0ac9SMatthew G. Knepley 1751475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1752475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1753475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1754475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1755475e0ac9SMatthew G. Knepley 1756475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1757475e0ac9SMatthew G. Knepley . Nf - the number of fields 1758475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1759475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1760475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1761475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1762475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1763475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1764475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1765475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1766475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1767475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1768475e0ac9SMatthew G. Knepley . t - current time 1769475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1770475e0ac9SMatthew G. Knepley . x - coordinates of the current point 177197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 177297b6e6e8SMatthew G. Knepley . constants - constant parameters 1773475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1774475e0ac9SMatthew G. Knepley 1775475e0ac9SMatthew G. Knepley Level: intermediate 1776475e0ac9SMatthew G. Knepley 1777db781477SPatrick Sanan .seealso: `PetscDSGetJacobianPreconditioner()`, `PetscDSSetJacobian()` 1778475e0ac9SMatthew G. Knepley @*/ 17796528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1780475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1781475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1782475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1784475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1785475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1786475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1788475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1789475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1790475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1792475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1793475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1794475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1796475e0ac9SMatthew G. Knepley { 1797475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17986528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1799475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1800475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1801475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1802475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 180363a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 180463a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 18059566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1806475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1807475e0ac9SMatthew G. Knepley } 1808475e0ac9SMatthew G. Knepley 1809b7e05686SMatthew G. Knepley /*@C 1810b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1811b7e05686SMatthew G. Knepley 1812b7e05686SMatthew G. Knepley Not collective 1813b7e05686SMatthew G. Knepley 1814b7e05686SMatthew G. Knepley Input Parameter: 18156528b96dSMatthew G. Knepley . ds - The PetscDS 1816b7e05686SMatthew G. Knepley 1817b7e05686SMatthew G. Knepley Output Parameter: 1818b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1819b7e05686SMatthew G. Knepley 1820b7e05686SMatthew G. Knepley Level: intermediate 1821b7e05686SMatthew G. Knepley 1822db781477SPatrick Sanan .seealso: `PetscDSGetDynamicJacobian()`, `PetscDSSetDynamicJacobian()`, `PetscDSGetJacobian()` 1823b7e05686SMatthew G. Knepley @*/ 18246528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS ds, PetscBool *hasDynJac) 1825b7e05686SMatthew G. Knepley { 1826b7e05686SMatthew G. Knepley PetscFunctionBegin; 18276528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18289566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasDynamicJacobian(ds->wf, hasDynJac)); 1829b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1830b7e05686SMatthew G. Knepley } 1831b7e05686SMatthew G. Knepley 1832b7e05686SMatthew G. Knepley /*@C 1833b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1834b7e05686SMatthew G. Knepley 1835b7e05686SMatthew G. Knepley Not collective 1836b7e05686SMatthew G. Knepley 1837b7e05686SMatthew G. Knepley Input Parameters: 18386528b96dSMatthew G. Knepley + ds - The PetscDS 1839b7e05686SMatthew G. Knepley . f - The test field number 1840b7e05686SMatthew G. Knepley - g - The field number 1841b7e05686SMatthew G. Knepley 1842b7e05686SMatthew G. Knepley Output Parameters: 1843b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1844b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1845b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1846b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1847b7e05686SMatthew G. Knepley 1848b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1849b7e05686SMatthew G. Knepley 1850b7e05686SMatthew 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 1851b7e05686SMatthew G. Knepley 1852b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1853b7e05686SMatthew G. Knepley 1854b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1855b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1856b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1857b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1858b7e05686SMatthew G. Knepley 1859b7e05686SMatthew G. Knepley + dim - the spatial dimension 1860b7e05686SMatthew G. Knepley . Nf - the number of fields 1861b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1862b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1863b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1864b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1865b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1866b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1867b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1868b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1869b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1870b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1871b7e05686SMatthew G. Knepley . t - current time 1872b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1873b7e05686SMatthew G. Knepley . x - coordinates of the current point 187497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 187597b6e6e8SMatthew G. Knepley . constants - constant parameters 1876b7e05686SMatthew G. Knepley - g0 - output values at the current point 1877b7e05686SMatthew G. Knepley 1878b7e05686SMatthew G. Knepley Level: intermediate 1879b7e05686SMatthew G. Knepley 1880db781477SPatrick Sanan .seealso: `PetscDSSetJacobian()` 1881b7e05686SMatthew G. Knepley @*/ 18826528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1883b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1884b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1885b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1887b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1888b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1889b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1891b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1892b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1893b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1895b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1896b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1897b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1899b7e05686SMatthew G. Knepley { 19006528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 19016528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 19026528b96dSMatthew G. Knepley 1903b7e05686SMatthew G. Knepley PetscFunctionBegin; 19046528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 190563a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 190663a3b9bcSJacob Faibussowitsch PetscCheck(!(g < 0) && !(g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", g, ds->Nf); 19079566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetDynamicJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 19086528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 19096528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 19106528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 19116528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1912b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1913b7e05686SMatthew G. Knepley } 1914b7e05686SMatthew G. Knepley 1915b7e05686SMatthew G. Knepley /*@C 1916b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1917b7e05686SMatthew G. Knepley 1918b7e05686SMatthew G. Knepley Not collective 1919b7e05686SMatthew G. Knepley 1920b7e05686SMatthew G. Knepley Input Parameters: 19216528b96dSMatthew G. Knepley + ds - The PetscDS 1922b7e05686SMatthew G. Knepley . f - The test field number 1923b7e05686SMatthew G. Knepley . g - The field number 1924b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1925b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1926b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1927b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1928b7e05686SMatthew G. Knepley 1929b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1930b7e05686SMatthew G. Knepley 1931b7e05686SMatthew 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 1932b7e05686SMatthew G. Knepley 1933b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1934b7e05686SMatthew G. Knepley 1935b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1936b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1937b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1938b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1939b7e05686SMatthew G. Knepley 1940b7e05686SMatthew G. Knepley + dim - the spatial dimension 1941b7e05686SMatthew G. Knepley . Nf - the number of fields 1942b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1943b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1944b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1945b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1946b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1947b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1948b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1949b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1950b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1951b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1952b7e05686SMatthew G. Knepley . t - current time 1953b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1954b7e05686SMatthew G. Knepley . x - coordinates of the current point 195597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 195697b6e6e8SMatthew G. Knepley . constants - constant parameters 1957b7e05686SMatthew G. Knepley - g0 - output values at the current point 1958b7e05686SMatthew G. Knepley 1959b7e05686SMatthew G. Knepley Level: intermediate 1960b7e05686SMatthew G. Knepley 1961db781477SPatrick Sanan .seealso: `PetscDSGetJacobian()` 1962b7e05686SMatthew G. Knepley @*/ 19636528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1964b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1965b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1966b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 196797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1968b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1969b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1970b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1972b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1973b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1974b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1976b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1977b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1978b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1980b7e05686SMatthew G. Knepley { 1981b7e05686SMatthew G. Knepley PetscFunctionBegin; 19826528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1983b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1984b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1985b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1986b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 198763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 198863a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 19899566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexDynamicJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1990b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1991b7e05686SMatthew G. Knepley } 1992b7e05686SMatthew G. Knepley 19930c2f2876SMatthew G. Knepley /*@C 19940c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 19950c2f2876SMatthew G. Knepley 19960c2f2876SMatthew G. Knepley Not collective 19970c2f2876SMatthew G. Knepley 19984165533cSJose E. Roman Input Parameters: 19996528b96dSMatthew G. Knepley + ds - The PetscDS object 20000c2f2876SMatthew G. Knepley - f - The field number 20010c2f2876SMatthew G. Knepley 20024165533cSJose E. Roman Output Parameter: 20030c2f2876SMatthew G. Knepley . r - Riemann solver 20040c2f2876SMatthew G. Knepley 20050c2f2876SMatthew G. Knepley Calling sequence for r: 20060c2f2876SMatthew G. Knepley 20075db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20080c2f2876SMatthew G. Knepley 20095db36cf9SMatthew G. Knepley + dim - The spatial dimension 20105db36cf9SMatthew G. Knepley . Nf - The number of fields 20115db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20120c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20130c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20140c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20150c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 201697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 201797b6e6e8SMatthew G. Knepley . constants - constant parameters 20180c2f2876SMatthew G. Knepley - ctx - optional user context 20190c2f2876SMatthew G. Knepley 20200c2f2876SMatthew G. Knepley Level: intermediate 20210c2f2876SMatthew G. Knepley 2022db781477SPatrick Sanan .seealso: `PetscDSSetRiemannSolver()` 20230c2f2876SMatthew G. Knepley @*/ 20246528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS ds, PetscInt f, 202597b6e6e8SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscInt numConstants, const PetscScalar constants[], PetscScalar flux[], void *ctx)) 20260c2f2876SMatthew G. Knepley { 20276528b96dSMatthew G. Knepley PetscRiemannFunc *tmp; 20286528b96dSMatthew G. Knepley PetscInt n; 20296528b96dSMatthew G. Knepley 20300c2f2876SMatthew G. Knepley PetscFunctionBegin; 20316528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20320c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 203363a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 20349566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetRiemannSolver(ds->wf, NULL, 0, f, 0, &n, &tmp)); 20356528b96dSMatthew G. Knepley *r = tmp ? tmp[0] : NULL; 20360c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20370c2f2876SMatthew G. Knepley } 20380c2f2876SMatthew G. Knepley 20390c2f2876SMatthew G. Knepley /*@C 20400c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 20410c2f2876SMatthew G. Knepley 20420c2f2876SMatthew G. Knepley Not collective 20430c2f2876SMatthew G. Knepley 20444165533cSJose E. Roman Input Parameters: 20456528b96dSMatthew G. Knepley + ds - The PetscDS object 20460c2f2876SMatthew G. Knepley . f - The field number 20470c2f2876SMatthew G. Knepley - r - Riemann solver 20480c2f2876SMatthew G. Knepley 20490c2f2876SMatthew G. Knepley Calling sequence for r: 20500c2f2876SMatthew G. Knepley 20515db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20520c2f2876SMatthew G. Knepley 20535db36cf9SMatthew G. Knepley + dim - The spatial dimension 20545db36cf9SMatthew G. Knepley . Nf - The number of fields 20555db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20560c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20570c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20580c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20590c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 206097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 206197b6e6e8SMatthew G. Knepley . constants - constant parameters 20620c2f2876SMatthew G. Knepley - ctx - optional user context 20630c2f2876SMatthew G. Knepley 20640c2f2876SMatthew G. Knepley Level: intermediate 20650c2f2876SMatthew G. Knepley 2066db781477SPatrick Sanan .seealso: `PetscDSGetRiemannSolver()` 20670c2f2876SMatthew G. Knepley @*/ 20686528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS ds, PetscInt f, 206997b6e6e8SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscInt numConstants, const PetscScalar constants[], PetscScalar flux[], void *ctx)) 20700c2f2876SMatthew G. Knepley { 20710c2f2876SMatthew G. Knepley PetscFunctionBegin; 20726528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2073de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 207463a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 20759566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexRiemannSolver(ds->wf, NULL, 0, f, 0, 0, r)); 20760c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20770c2f2876SMatthew G. Knepley } 20780c2f2876SMatthew G. Knepley 207932d2bbc9SMatthew G. Knepley /*@C 208032d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 208132d2bbc9SMatthew G. Knepley 208232d2bbc9SMatthew G. Knepley Not collective 208332d2bbc9SMatthew G. Knepley 208432d2bbc9SMatthew G. Knepley Input Parameters: 20856528b96dSMatthew G. Knepley + ds - The PetscDS 208632d2bbc9SMatthew G. Knepley - f - The field number 208732d2bbc9SMatthew G. Knepley 2088f899ff85SJose E. Roman Output Parameter: 2089a2b725a8SWilliam Gropp . update - update function 209032d2bbc9SMatthew G. Knepley 209132d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 209232d2bbc9SMatthew G. Knepley 209332d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 209432d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 209532d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 209632d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 209732d2bbc9SMatthew G. Knepley 209832d2bbc9SMatthew G. Knepley + dim - the spatial dimension 209932d2bbc9SMatthew G. Knepley . Nf - the number of fields 210032d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 210132d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 210232d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 210332d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 210432d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 210532d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 210632d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 210732d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 210832d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 210932d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 211032d2bbc9SMatthew G. Knepley . t - current time 211132d2bbc9SMatthew G. Knepley . x - coordinates of the current point 211232d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 211332d2bbc9SMatthew G. Knepley 211432d2bbc9SMatthew G. Knepley Level: intermediate 211532d2bbc9SMatthew G. Knepley 2116db781477SPatrick Sanan .seealso: `PetscDSSetUpdate()`, `PetscDSSetResidual()` 211732d2bbc9SMatthew G. Knepley @*/ 21186528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS ds, PetscInt f, 211932d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 212032d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 212132d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21223fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 212332d2bbc9SMatthew G. Knepley { 212432d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21256528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 212663a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 21276528b96dSMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = ds->update[f];} 212832d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 212932d2bbc9SMatthew G. Knepley } 213032d2bbc9SMatthew G. Knepley 213132d2bbc9SMatthew G. Knepley /*@C 21323fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 213332d2bbc9SMatthew G. Knepley 213432d2bbc9SMatthew G. Knepley Not collective 213532d2bbc9SMatthew G. Knepley 213632d2bbc9SMatthew G. Knepley Input Parameters: 21376528b96dSMatthew G. Knepley + ds - The PetscDS 213832d2bbc9SMatthew G. Knepley . f - The field number 213932d2bbc9SMatthew G. Knepley - update - update function 214032d2bbc9SMatthew G. Knepley 214132d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 214232d2bbc9SMatthew G. Knepley 214332d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 214432d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 214532d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 214632d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 214732d2bbc9SMatthew G. Knepley 214832d2bbc9SMatthew G. Knepley + dim - the spatial dimension 214932d2bbc9SMatthew G. Knepley . Nf - the number of fields 215032d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 215132d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 215232d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 215332d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 215432d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 215532d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 215632d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 215732d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 215832d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 215932d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 216032d2bbc9SMatthew G. Knepley . t - current time 216132d2bbc9SMatthew G. Knepley . x - coordinates of the current point 216232d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 216332d2bbc9SMatthew G. Knepley 216432d2bbc9SMatthew G. Knepley Level: intermediate 216532d2bbc9SMatthew G. Knepley 2166db781477SPatrick Sanan .seealso: `PetscDSGetResidual()` 216732d2bbc9SMatthew G. Knepley @*/ 21686528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS ds, PetscInt f, 216932d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 217032d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 217132d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21723fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 217332d2bbc9SMatthew G. Knepley { 217432d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21756528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 217632d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 217763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 21789566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(ds, f+1)); 21796528b96dSMatthew G. Knepley ds->update[f] = update; 218032d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 218132d2bbc9SMatthew G. Knepley } 218232d2bbc9SMatthew G. Knepley 21833ec1f749SStefano Zampini PetscErrorCode PetscDSGetContext(PetscDS ds, PetscInt f, void *ctx) 21840c2f2876SMatthew G. Knepley { 21850c2f2876SMatthew G. Knepley PetscFunctionBegin; 21866528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 218763a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 21880c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 21893ec1f749SStefano Zampini *(void**)ctx = ds->ctx[f]; 21900c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 21910c2f2876SMatthew G. Knepley } 21920c2f2876SMatthew G. Knepley 21936528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS ds, PetscInt f, void *ctx) 21940c2f2876SMatthew G. Knepley { 21950c2f2876SMatthew G. Knepley PetscFunctionBegin; 21966528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 219763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 21989566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(ds, f+1)); 21996528b96dSMatthew G. Knepley ds->ctx[f] = ctx; 22000c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 22010c2f2876SMatthew G. Knepley } 22020c2f2876SMatthew G. Knepley 2203194d53e6SMatthew G. Knepley /*@C 2204194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 2205194d53e6SMatthew G. Knepley 2206194d53e6SMatthew G. Knepley Not collective 2207194d53e6SMatthew G. Knepley 2208194d53e6SMatthew G. Knepley Input Parameters: 22096528b96dSMatthew G. Knepley + ds - The PetscDS 2210194d53e6SMatthew G. Knepley - f - The test field number 2211194d53e6SMatthew G. Knepley 2212194d53e6SMatthew G. Knepley Output Parameters: 2213194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 2214194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2215194d53e6SMatthew G. Knepley 2216194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2217194d53e6SMatthew G. Knepley 2218194d53e6SMatthew 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 2219194d53e6SMatthew G. Knepley 2220194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2221194d53e6SMatthew G. Knepley 222230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2223194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2224194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 222530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2226194d53e6SMatthew G. Knepley 2227194d53e6SMatthew G. Knepley + dim - the spatial dimension 2228194d53e6SMatthew G. Knepley . Nf - the number of fields 2229194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2230194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2231194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2232194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2233194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2234194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2235194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2236194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2237194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2238194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2239194d53e6SMatthew G. Knepley . t - current time 2240194d53e6SMatthew G. Knepley . x - coordinates of the current point 2241194d53e6SMatthew G. Knepley . n - unit normal at the current point 224297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 224397b6e6e8SMatthew G. Knepley . constants - constant parameters 2244194d53e6SMatthew G. Knepley - f0 - output values at the current point 2245194d53e6SMatthew G. Knepley 2246194d53e6SMatthew G. Knepley Level: intermediate 2247194d53e6SMatthew G. Knepley 2248db781477SPatrick Sanan .seealso: `PetscDSSetBdResidual()` 2249194d53e6SMatthew G. Knepley @*/ 22506528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS ds, PetscInt f, 225130b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2252194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2253194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 225530b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2256194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2257194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 22592764a2aaSMatthew G. Knepley { 22606528b96dSMatthew G. Knepley PetscBdPointFunc *tmp0, *tmp1; 22616528b96dSMatthew G. Knepley PetscInt n0, n1; 22626528b96dSMatthew G. Knepley 22632764a2aaSMatthew G. Knepley PetscFunctionBegin; 22646528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 226563a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 22669566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 22676528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 22686528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 22692764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22702764a2aaSMatthew G. Knepley } 22712764a2aaSMatthew G. Knepley 2272194d53e6SMatthew G. Knepley /*@C 2273194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2274194d53e6SMatthew G. Knepley 2275194d53e6SMatthew G. Knepley Not collective 2276194d53e6SMatthew G. Knepley 2277194d53e6SMatthew G. Knepley Input Parameters: 22786528b96dSMatthew G. Knepley + ds - The PetscDS 2279194d53e6SMatthew G. Knepley . f - The test field number 2280194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2281194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2282194d53e6SMatthew G. Knepley 2283194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2284194d53e6SMatthew G. Knepley 2285194d53e6SMatthew 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 2286194d53e6SMatthew G. Knepley 2287194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2288194d53e6SMatthew G. Knepley 228930b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2290194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2291194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 229230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2293194d53e6SMatthew G. Knepley 2294194d53e6SMatthew G. Knepley + dim - the spatial dimension 2295194d53e6SMatthew G. Knepley . Nf - the number of fields 2296194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2297194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2298194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2299194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2300194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2301194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2302194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2303194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2304194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2305194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2306194d53e6SMatthew G. Knepley . t - current time 2307194d53e6SMatthew G. Knepley . x - coordinates of the current point 2308194d53e6SMatthew G. Knepley . n - unit normal at the current point 230997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 231097b6e6e8SMatthew G. Knepley . constants - constant parameters 2311194d53e6SMatthew G. Knepley - f0 - output values at the current point 2312194d53e6SMatthew G. Knepley 2313194d53e6SMatthew G. Knepley Level: intermediate 2314194d53e6SMatthew G. Knepley 2315db781477SPatrick Sanan .seealso: `PetscDSGetBdResidual()` 2316194d53e6SMatthew G. Knepley @*/ 23176528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS ds, PetscInt f, 231830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2319194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2320194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 232230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2323194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2324194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 23262764a2aaSMatthew G. Knepley { 23272764a2aaSMatthew G. Knepley PetscFunctionBegin; 23286528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 232963a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 23309566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 23312764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23322764a2aaSMatthew G. Knepley } 23332764a2aaSMatthew G. Knepley 233427f02ce8SMatthew G. Knepley /*@ 233527f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 233627f02ce8SMatthew G. Knepley 233727f02ce8SMatthew G. Knepley Not collective 233827f02ce8SMatthew G. Knepley 233927f02ce8SMatthew G. Knepley Input Parameter: 23406528b96dSMatthew G. Knepley . ds - The PetscDS 234127f02ce8SMatthew G. Knepley 234227f02ce8SMatthew G. Knepley Output Parameter: 234327f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 234427f02ce8SMatthew G. Knepley 234527f02ce8SMatthew G. Knepley Level: intermediate 234627f02ce8SMatthew G. Knepley 2347db781477SPatrick Sanan .seealso: `PetscDSHasJacobian()`, `PetscDSSetBdJacobian()`, `PetscDSGetBdJacobian()` 234827f02ce8SMatthew G. Knepley @*/ 23496528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS ds, PetscBool *hasBdJac) 235027f02ce8SMatthew G. Knepley { 235127f02ce8SMatthew G. Knepley PetscFunctionBegin; 23526528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23536528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJac, 2); 23549566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasBdJacobian(ds->wf, hasBdJac)); 235527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 235627f02ce8SMatthew G. Knepley } 235727f02ce8SMatthew G. Knepley 2358194d53e6SMatthew G. Knepley /*@C 2359194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2360194d53e6SMatthew G. Knepley 2361194d53e6SMatthew G. Knepley Not collective 2362194d53e6SMatthew G. Knepley 2363194d53e6SMatthew G. Knepley Input Parameters: 23646528b96dSMatthew G. Knepley + ds - The PetscDS 2365194d53e6SMatthew G. Knepley . f - The test field number 2366194d53e6SMatthew G. Knepley - g - The field number 2367194d53e6SMatthew G. Knepley 2368194d53e6SMatthew G. Knepley Output Parameters: 2369194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2370194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2371194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2372194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2373194d53e6SMatthew G. Knepley 2374194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2375194d53e6SMatthew G. Knepley 2376194d53e6SMatthew 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 2377194d53e6SMatthew G. Knepley 2378194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2379194d53e6SMatthew G. Knepley 238030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2381194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2382194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 238330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2384194d53e6SMatthew G. Knepley 2385194d53e6SMatthew G. Knepley + dim - the spatial dimension 2386194d53e6SMatthew G. Knepley . Nf - the number of fields 2387194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2388194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2389194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2390194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2391194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2392194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2393194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2394194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2395194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2396194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2397194d53e6SMatthew G. Knepley . t - current time 23982aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2399194d53e6SMatthew G. Knepley . x - coordinates of the current point 2400194d53e6SMatthew G. Knepley . n - normal at the current point 240197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 240297b6e6e8SMatthew G. Knepley . constants - constant parameters 2403194d53e6SMatthew G. Knepley - g0 - output values at the current point 2404194d53e6SMatthew G. Knepley 2405194d53e6SMatthew G. Knepley Level: intermediate 2406194d53e6SMatthew G. Knepley 2407db781477SPatrick Sanan .seealso: `PetscDSSetBdJacobian()` 2408194d53e6SMatthew G. Knepley @*/ 24096528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 241030b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2411194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2412194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 241430b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2415194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2416194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 241830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2419194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2420194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 242230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2423194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2424194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 24262764a2aaSMatthew G. Knepley { 24276528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 24286528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 24296528b96dSMatthew G. Knepley 24302764a2aaSMatthew G. Knepley PetscFunctionBegin; 24316528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 243263a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 243363a3b9bcSJacob Faibussowitsch PetscCheck(!(g < 0) && !(g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", g, ds->Nf); 24349566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 24356528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 24366528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 24376528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 24386528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 24392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24402764a2aaSMatthew G. Knepley } 24412764a2aaSMatthew G. Knepley 2442194d53e6SMatthew G. Knepley /*@C 2443194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2444194d53e6SMatthew G. Knepley 2445194d53e6SMatthew G. Knepley Not collective 2446194d53e6SMatthew G. Knepley 2447194d53e6SMatthew G. Knepley Input Parameters: 24486528b96dSMatthew G. Knepley + ds - The PetscDS 2449194d53e6SMatthew G. Knepley . f - The test field number 2450194d53e6SMatthew G. Knepley . g - The field number 2451194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2452194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2453194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2454194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2455194d53e6SMatthew G. Knepley 2456194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2457194d53e6SMatthew G. Knepley 2458194d53e6SMatthew 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 2459194d53e6SMatthew G. Knepley 2460194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2461194d53e6SMatthew G. Knepley 246230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2463194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2464194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 246530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2466194d53e6SMatthew G. Knepley 2467194d53e6SMatthew G. Knepley + dim - the spatial dimension 2468194d53e6SMatthew G. Knepley . Nf - the number of fields 2469194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2470194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2471194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2472194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2473194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2474194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2475194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2476194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2477194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2478194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2479194d53e6SMatthew G. Knepley . t - current time 24802aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2481194d53e6SMatthew G. Knepley . x - coordinates of the current point 2482194d53e6SMatthew G. Knepley . n - normal at the current point 248397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 248497b6e6e8SMatthew G. Knepley . constants - constant parameters 2485194d53e6SMatthew G. Knepley - g0 - output values at the current point 2486194d53e6SMatthew G. Knepley 2487194d53e6SMatthew G. Knepley Level: intermediate 2488194d53e6SMatthew G. Knepley 2489db781477SPatrick Sanan .seealso: `PetscDSGetBdJacobian()` 2490194d53e6SMatthew G. Knepley @*/ 24916528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 249230b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2493194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2494194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 249630b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2497194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2498194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 250030b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2501194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2502194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 250430b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2505194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2506194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 25082764a2aaSMatthew G. Knepley { 25092764a2aaSMatthew G. Knepley PetscFunctionBegin; 25106528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25112764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 25122764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 25132764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 25142764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 251563a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 251663a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 25179566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 25182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25192764a2aaSMatthew G. Knepley } 25202764a2aaSMatthew G. Knepley 252127f02ce8SMatthew G. Knepley /*@ 252227f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 252327f02ce8SMatthew G. Knepley 252427f02ce8SMatthew G. Knepley Not collective 252527f02ce8SMatthew G. Knepley 252627f02ce8SMatthew G. Knepley Input Parameter: 25276528b96dSMatthew G. Knepley . ds - The PetscDS 252827f02ce8SMatthew G. Knepley 252927f02ce8SMatthew G. Knepley Output Parameter: 253027f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 253127f02ce8SMatthew G. Knepley 253227f02ce8SMatthew G. Knepley Level: intermediate 253327f02ce8SMatthew G. Knepley 2534db781477SPatrick Sanan .seealso: `PetscDSHasJacobian()`, `PetscDSSetBdJacobian()`, `PetscDSGetBdJacobian()` 253527f02ce8SMatthew G. Knepley @*/ 25366528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS ds, PetscBool *hasBdJacPre) 253727f02ce8SMatthew G. Knepley { 253827f02ce8SMatthew G. Knepley PetscFunctionBegin; 25396528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25406528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJacPre, 2); 25419566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasBdJacobianPreconditioner(ds->wf, hasBdJacPre)); 254227f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 254327f02ce8SMatthew G. Knepley } 254427f02ce8SMatthew G. Knepley 254527f02ce8SMatthew G. Knepley /*@C 254627f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 254727f02ce8SMatthew G. Knepley 254827f02ce8SMatthew G. Knepley Not collective 254927f02ce8SMatthew G. Knepley 255027f02ce8SMatthew G. Knepley Input Parameters: 25516528b96dSMatthew G. Knepley + ds - The PetscDS 255227f02ce8SMatthew G. Knepley . f - The test field number 255327f02ce8SMatthew G. Knepley - g - The field number 255427f02ce8SMatthew G. Knepley 255527f02ce8SMatthew G. Knepley Output Parameters: 255627f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 255727f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 255827f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 255927f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 256027f02ce8SMatthew G. Knepley 256127f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 256227f02ce8SMatthew G. Knepley 256327f02ce8SMatthew 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 256427f02ce8SMatthew G. Knepley 256527f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 256627f02ce8SMatthew G. Knepley 256727f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 256827f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 256927f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 257027f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 257127f02ce8SMatthew G. Knepley 257227f02ce8SMatthew G. Knepley + dim - the spatial dimension 257327f02ce8SMatthew G. Knepley . Nf - the number of fields 257427f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 257527f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 257627f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 257727f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 257827f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 257927f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 258027f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 258127f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 258227f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 258327f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 258427f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 258527f02ce8SMatthew G. Knepley . t - current time 258627f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 258727f02ce8SMatthew G. Knepley . x - coordinates of the current point 258827f02ce8SMatthew G. Knepley . n - normal at the current point 258927f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 259027f02ce8SMatthew G. Knepley . constants - constant parameters 259127f02ce8SMatthew G. Knepley - g0 - output values at the current point 259227f02ce8SMatthew G. Knepley 259327f02ce8SMatthew G. Knepley This is not yet available in Fortran. 259427f02ce8SMatthew G. Knepley 259527f02ce8SMatthew G. Knepley Level: intermediate 259627f02ce8SMatthew G. Knepley 2597db781477SPatrick Sanan .seealso: `PetscDSSetBdJacobianPreconditioner()` 259827f02ce8SMatthew G. Knepley @*/ 25996528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 260027f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260127f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260227f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260327f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 260427f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260527f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260627f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260727f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 260827f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260927f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261027f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261127f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 261227f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 261327f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261427f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261527f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 261627f02ce8SMatthew G. Knepley { 26176528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 26186528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 26196528b96dSMatthew G. Knepley 262027f02ce8SMatthew G. Knepley PetscFunctionBegin; 26216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 262263a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 262363a3b9bcSJacob Faibussowitsch PetscCheck(!(g < 0) && !(g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", g, ds->Nf); 26249566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 26256528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 26266528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 26276528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 26286528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 262927f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 263027f02ce8SMatthew G. Knepley } 263127f02ce8SMatthew G. Knepley 263227f02ce8SMatthew G. Knepley /*@C 263327f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 263427f02ce8SMatthew G. Knepley 263527f02ce8SMatthew G. Knepley Not collective 263627f02ce8SMatthew G. Knepley 263727f02ce8SMatthew G. Knepley Input Parameters: 26386528b96dSMatthew G. Knepley + ds - The PetscDS 263927f02ce8SMatthew G. Knepley . f - The test field number 264027f02ce8SMatthew G. Knepley . g - The field number 264127f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 264227f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 264327f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 264427f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 264527f02ce8SMatthew G. Knepley 264627f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 264727f02ce8SMatthew G. Knepley 264827f02ce8SMatthew 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 264927f02ce8SMatthew G. Knepley 265027f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 265127f02ce8SMatthew G. Knepley 265227f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 265327f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 265427f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 265527f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 265627f02ce8SMatthew G. Knepley 265727f02ce8SMatthew G. Knepley + dim - the spatial dimension 265827f02ce8SMatthew G. Knepley . Nf - the number of fields 265927f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 266027f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 266127f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 266227f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 266327f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 266427f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 266527f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 266627f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 266727f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 266827f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 266927f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 267027f02ce8SMatthew G. Knepley . t - current time 267127f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 267227f02ce8SMatthew G. Knepley . x - coordinates of the current point 267327f02ce8SMatthew G. Knepley . n - normal at the current point 267427f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 267527f02ce8SMatthew G. Knepley . constants - constant parameters 267627f02ce8SMatthew G. Knepley - g0 - output values at the current point 267727f02ce8SMatthew G. Knepley 267827f02ce8SMatthew G. Knepley This is not yet available in Fortran. 267927f02ce8SMatthew G. Knepley 268027f02ce8SMatthew G. Knepley Level: intermediate 268127f02ce8SMatthew G. Knepley 2682db781477SPatrick Sanan .seealso: `PetscDSGetBdJacobianPreconditioner()` 268327f02ce8SMatthew G. Knepley @*/ 26846528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 268527f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 268627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 268727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 268827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 268927f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 269327f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 269727f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269827f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269927f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 270027f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 270127f02ce8SMatthew G. Knepley { 270227f02ce8SMatthew G. Knepley PetscFunctionBegin; 27036528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 270427f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 270527f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 270627f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 270727f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 270863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 270963a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 27109566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 271127f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 271227f02ce8SMatthew G. Knepley } 271327f02ce8SMatthew G. Knepley 27140d3e9b51SMatthew G. Knepley /*@C 2715c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2716c371a6d1SMatthew G. Knepley 2717c371a6d1SMatthew G. Knepley Not collective 2718c371a6d1SMatthew G. Knepley 2719c371a6d1SMatthew G. Knepley Input Parameters: 2720c371a6d1SMatthew G. Knepley + prob - The PetscDS 2721c371a6d1SMatthew G. Knepley - f - The test field number 2722c371a6d1SMatthew G. Knepley 2723d8d19677SJose E. Roman Output Parameters: 272495cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 272595cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2726c371a6d1SMatthew G. Knepley 2727c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2728c371a6d1SMatthew G. Knepley 2729c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2730c371a6d1SMatthew G. Knepley 2731c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2732c371a6d1SMatthew G. Knepley . t - current time 2733c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2734c371a6d1SMatthew G. Knepley . Nc - the number of field components 2735c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2736c371a6d1SMatthew G. Knepley - ctx - a user context 2737c371a6d1SMatthew G. Knepley 2738c371a6d1SMatthew G. Knepley Level: intermediate 2739c371a6d1SMatthew G. Knepley 2740db781477SPatrick Sanan .seealso: `PetscDSSetExactSolution()`, `PetscDSGetExactSolutionTimeDerivative()` 2741c371a6d1SMatthew G. Knepley @*/ 274295cbbfd3SMatthew G. Knepley PetscErrorCode PetscDSGetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (**sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void **ctx) 2743c371a6d1SMatthew G. Knepley { 2744c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2745c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 274663a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 2747c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 274895cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2749c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2750c371a6d1SMatthew G. Knepley } 2751c371a6d1SMatthew G. Knepley 2752c371a6d1SMatthew G. Knepley /*@C 2753578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2754c371a6d1SMatthew G. Knepley 2755c371a6d1SMatthew G. Knepley Not collective 2756c371a6d1SMatthew G. Knepley 2757c371a6d1SMatthew G. Knepley Input Parameters: 2758c371a6d1SMatthew G. Knepley + prob - The PetscDS 2759c371a6d1SMatthew G. Knepley . f - The test field number 276095cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 276195cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2762c371a6d1SMatthew G. Knepley 2763c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2764c371a6d1SMatthew G. Knepley 2765c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2766c371a6d1SMatthew G. Knepley 2767c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2768c371a6d1SMatthew G. Knepley . t - current time 2769c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2770c371a6d1SMatthew G. Knepley . Nc - the number of field components 2771c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2772c371a6d1SMatthew G. Knepley - ctx - a user context 2773c371a6d1SMatthew G. Knepley 2774c371a6d1SMatthew G. Knepley Level: intermediate 2775c371a6d1SMatthew G. Knepley 2776db781477SPatrick Sanan .seealso: `PetscDSGetExactSolution()` 2777c371a6d1SMatthew G. Knepley @*/ 277895cbbfd3SMatthew G. Knepley PetscErrorCode PetscDSSetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (*sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void *ctx) 2779c371a6d1SMatthew G. Knepley { 2780c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2781c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 278263a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 27839566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 2784c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 278595cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2786c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2787c371a6d1SMatthew G. Knepley } 2788c371a6d1SMatthew G. Knepley 27895638fd0eSMatthew G. Knepley /*@C 2790f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2791f2cacb80SMatthew G. Knepley 2792f2cacb80SMatthew G. Knepley Not collective 2793f2cacb80SMatthew G. Knepley 2794f2cacb80SMatthew G. Knepley Input Parameters: 2795f2cacb80SMatthew G. Knepley + prob - The PetscDS 2796f2cacb80SMatthew G. Knepley - f - The test field number 2797f2cacb80SMatthew G. Knepley 2798d8d19677SJose E. Roman Output Parameters: 2799f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2800f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2801f2cacb80SMatthew G. Knepley 2802f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2803f2cacb80SMatthew G. Knepley 2804f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2805f2cacb80SMatthew G. Knepley 2806f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2807f2cacb80SMatthew G. Knepley . t - current time 2808f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2809f2cacb80SMatthew G. Knepley . Nc - the number of field components 2810f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2811f2cacb80SMatthew G. Knepley - ctx - a user context 2812f2cacb80SMatthew G. Knepley 2813f2cacb80SMatthew G. Knepley Level: intermediate 2814f2cacb80SMatthew G. Knepley 2815db781477SPatrick Sanan .seealso: `PetscDSSetExactSolutionTimeDerivative()`, `PetscDSGetExactSolution()` 2816f2cacb80SMatthew G. Knepley @*/ 2817f2cacb80SMatthew G. Knepley PetscErrorCode PetscDSGetExactSolutionTimeDerivative(PetscDS prob, PetscInt f, PetscErrorCode (**sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void **ctx) 2818f2cacb80SMatthew G. Knepley { 2819f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2820f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 282163a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 2822f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2823f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2824f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2825f2cacb80SMatthew G. Knepley } 2826f2cacb80SMatthew G. Knepley 2827f2cacb80SMatthew G. Knepley /*@C 2828f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2829f2cacb80SMatthew G. Knepley 2830f2cacb80SMatthew G. Knepley Not collective 2831f2cacb80SMatthew G. Knepley 2832f2cacb80SMatthew G. Knepley Input Parameters: 2833f2cacb80SMatthew G. Knepley + prob - The PetscDS 2834f2cacb80SMatthew G. Knepley . f - The test field number 2835f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2836f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2837f2cacb80SMatthew G. Knepley 2838f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2839f2cacb80SMatthew G. Knepley 2840f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2841f2cacb80SMatthew G. Knepley 2842f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2843f2cacb80SMatthew G. Knepley . t - current time 2844f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2845f2cacb80SMatthew G. Knepley . Nc - the number of field components 2846f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2847f2cacb80SMatthew G. Knepley - ctx - a user context 2848f2cacb80SMatthew G. Knepley 2849f2cacb80SMatthew G. Knepley Level: intermediate 2850f2cacb80SMatthew G. Knepley 2851db781477SPatrick Sanan .seealso: `PetscDSGetExactSolutionTimeDerivative()`, `PetscDSSetExactSolution()` 2852f2cacb80SMatthew G. Knepley @*/ 2853f2cacb80SMatthew G. Knepley PetscErrorCode PetscDSSetExactSolutionTimeDerivative(PetscDS prob, PetscInt f, PetscErrorCode (*sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void *ctx) 2854f2cacb80SMatthew G. Knepley { 2855f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2856f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 285763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 28589566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 2859f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2860f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2861f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2862f2cacb80SMatthew G. Knepley } 2863f2cacb80SMatthew G. Knepley 2864f2cacb80SMatthew G. Knepley /*@C 286597b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 286697b6e6e8SMatthew G. Knepley 286797b6e6e8SMatthew G. Knepley Not collective 286897b6e6e8SMatthew G. Knepley 286997b6e6e8SMatthew G. Knepley Input Parameter: 287097b6e6e8SMatthew G. Knepley . prob - The PetscDS object 287197b6e6e8SMatthew G. Knepley 287297b6e6e8SMatthew G. Knepley Output Parameters: 287397b6e6e8SMatthew G. Knepley + numConstants - The number of constants 287497b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 287597b6e6e8SMatthew G. Knepley 287697b6e6e8SMatthew G. Knepley Level: intermediate 287797b6e6e8SMatthew G. Knepley 2878db781477SPatrick Sanan .seealso: `PetscDSSetConstants()`, `PetscDSCreate()` 287997b6e6e8SMatthew G. Knepley @*/ 288097b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 288197b6e6e8SMatthew G. Knepley { 288297b6e6e8SMatthew G. Knepley PetscFunctionBegin; 288397b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2884dadcf809SJacob Faibussowitsch if (numConstants) {PetscValidIntPointer(numConstants, 2); *numConstants = prob->numConstants;} 288597b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 288697b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 288797b6e6e8SMatthew G. Knepley } 288897b6e6e8SMatthew G. Knepley 28890d3e9b51SMatthew G. Knepley /*@C 289097b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 289197b6e6e8SMatthew G. Knepley 289297b6e6e8SMatthew G. Knepley Not collective 289397b6e6e8SMatthew G. Knepley 289497b6e6e8SMatthew G. Knepley Input Parameters: 289597b6e6e8SMatthew G. Knepley + prob - The PetscDS object 289697b6e6e8SMatthew G. Knepley . numConstants - The number of constants 289797b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 289897b6e6e8SMatthew G. Knepley 289997b6e6e8SMatthew G. Knepley Level: intermediate 290097b6e6e8SMatthew G. Knepley 2901db781477SPatrick Sanan .seealso: `PetscDSGetConstants()`, `PetscDSCreate()` 290297b6e6e8SMatthew G. Knepley @*/ 290397b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 290497b6e6e8SMatthew G. Knepley { 290597b6e6e8SMatthew G. Knepley PetscFunctionBegin; 290697b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 290797b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 29089566063dSJacob Faibussowitsch PetscCall(PetscFree(prob->constants)); 290997b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 291097b6e6e8SMatthew G. Knepley if (prob->numConstants) { 29119566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(prob->numConstants, &prob->constants)); 291220be0f5bSMatthew G. Knepley } else { 291320be0f5bSMatthew G. Knepley prob->constants = NULL; 291420be0f5bSMatthew G. Knepley } 291520be0f5bSMatthew G. Knepley } 291620be0f5bSMatthew G. Knepley if (prob->numConstants) { 2917dadcf809SJacob Faibussowitsch PetscValidScalarPointer(constants, 3); 29189566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(prob->constants, constants, prob->numConstants)); 291997b6e6e8SMatthew G. Knepley } 292097b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 292197b6e6e8SMatthew G. Knepley } 292297b6e6e8SMatthew G. Knepley 29234cd1e086SMatthew G. Knepley /*@ 29244cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 29254cd1e086SMatthew G. Knepley 29264cd1e086SMatthew G. Knepley Not collective 29274cd1e086SMatthew G. Knepley 29284cd1e086SMatthew G. Knepley Input Parameters: 29294cd1e086SMatthew G. Knepley + prob - The PetscDS object 29304cd1e086SMatthew G. Knepley - disc - The discretization object 29314cd1e086SMatthew G. Knepley 29324cd1e086SMatthew G. Knepley Output Parameter: 29334cd1e086SMatthew G. Knepley . f - The field number 29344cd1e086SMatthew G. Knepley 29354cd1e086SMatthew G. Knepley Level: beginner 29364cd1e086SMatthew G. Knepley 2937db781477SPatrick Sanan .seealso: `PetscGetDiscretization()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 29384cd1e086SMatthew G. Knepley @*/ 29394cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 29404cd1e086SMatthew G. Knepley { 29414cd1e086SMatthew G. Knepley PetscInt g; 29424cd1e086SMatthew G. Knepley 29434cd1e086SMatthew G. Knepley PetscFunctionBegin; 29444cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2945dadcf809SJacob Faibussowitsch PetscValidIntPointer(f, 3); 29464cd1e086SMatthew G. Knepley *f = -1; 29474cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 294808401ef6SPierre Jolivet PetscCheck(g != prob->Nf,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 29494cd1e086SMatthew G. Knepley *f = g; 29504cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29514cd1e086SMatthew G. Knepley } 29524cd1e086SMatthew G. Knepley 29534cd1e086SMatthew G. Knepley /*@ 29544cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 29554cd1e086SMatthew G. Knepley 29564cd1e086SMatthew G. Knepley Not collective 29574cd1e086SMatthew G. Knepley 29584cd1e086SMatthew G. Knepley Input Parameters: 29594cd1e086SMatthew G. Knepley + prob - The PetscDS object 29604cd1e086SMatthew G. Knepley - f - The field number 29614cd1e086SMatthew G. Knepley 29624cd1e086SMatthew G. Knepley Output Parameter: 29634cd1e086SMatthew G. Knepley . size - The size 29644cd1e086SMatthew G. Knepley 29654cd1e086SMatthew G. Knepley Level: beginner 29664cd1e086SMatthew G. Knepley 2967db781477SPatrick Sanan .seealso: `PetscDSGetFieldOffset()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 29684cd1e086SMatthew G. Knepley @*/ 29694cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 29704cd1e086SMatthew G. Knepley { 29714cd1e086SMatthew G. Knepley PetscFunctionBegin; 29724cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2973dadcf809SJacob Faibussowitsch PetscValidIntPointer(size, 3); 297463a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 29759566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 2976d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 29774cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29784cd1e086SMatthew G. Knepley } 29794cd1e086SMatthew G. Knepley 2980bc4ae4beSMatthew G. Knepley /*@ 2981bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2982bc4ae4beSMatthew G. Knepley 2983bc4ae4beSMatthew G. Knepley Not collective 2984bc4ae4beSMatthew G. Knepley 2985bc4ae4beSMatthew G. Knepley Input Parameters: 2986bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2987bc4ae4beSMatthew G. Knepley - f - The field number 2988bc4ae4beSMatthew G. Knepley 2989bc4ae4beSMatthew G. Knepley Output Parameter: 2990bc4ae4beSMatthew G. Knepley . off - The offset 2991bc4ae4beSMatthew G. Knepley 2992bc4ae4beSMatthew G. Knepley Level: beginner 2993bc4ae4beSMatthew G. Knepley 2994db781477SPatrick Sanan .seealso: `PetscDSGetFieldSize()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 2995bc4ae4beSMatthew G. Knepley @*/ 29962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 29972764a2aaSMatthew G. Knepley { 29984cd1e086SMatthew G. Knepley PetscInt size, g; 29992764a2aaSMatthew G. Knepley 30002764a2aaSMatthew G. Knepley PetscFunctionBegin; 30012764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3002dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 300363a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 30042764a2aaSMatthew G. Knepley *off = 0; 30052764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 30069566063dSJacob Faibussowitsch PetscCall(PetscDSGetFieldSize(prob, g, &size)); 30074cd1e086SMatthew G. Knepley *off += size; 30082764a2aaSMatthew G. Knepley } 30092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30102764a2aaSMatthew G. Knepley } 30112764a2aaSMatthew G. Knepley 3012bc4ae4beSMatthew G. Knepley /*@ 30135fedec97SMatthew G. Knepley PetscDSGetFieldOffsetCohesive - Returns the offset of the given field in the full space basis on a cohesive cell 30145fedec97SMatthew G. Knepley 30155fedec97SMatthew G. Knepley Not collective 30165fedec97SMatthew G. Knepley 30175fedec97SMatthew G. Knepley Input Parameters: 30185fedec97SMatthew G. Knepley + prob - The PetscDS object 30195fedec97SMatthew G. Knepley - f - The field number 30205fedec97SMatthew G. Knepley 30215fedec97SMatthew G. Knepley Output Parameter: 30225fedec97SMatthew G. Knepley . off - The offset 30235fedec97SMatthew G. Knepley 30245fedec97SMatthew G. Knepley Level: beginner 30255fedec97SMatthew G. Knepley 3026db781477SPatrick Sanan .seealso: `PetscDSGetFieldSize()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 30275fedec97SMatthew G. Knepley @*/ 30285fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffsetCohesive(PetscDS ds, PetscInt f, PetscInt *off) 30295fedec97SMatthew G. Knepley { 30305fedec97SMatthew G. Knepley PetscInt size, g; 30315fedec97SMatthew G. Knepley 30325fedec97SMatthew G. Knepley PetscFunctionBegin; 30335fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3034dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 303563a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, ds->Nf); 30365fedec97SMatthew G. Knepley *off = 0; 30375fedec97SMatthew G. Knepley for (g = 0; g < f; ++g) { 30385fedec97SMatthew G. Knepley PetscBool cohesive; 30395fedec97SMatthew G. Knepley 30409566063dSJacob Faibussowitsch PetscCall(PetscDSGetCohesive(ds, g, &cohesive)); 30419566063dSJacob Faibussowitsch PetscCall(PetscDSGetFieldSize(ds, g, &size)); 30425fedec97SMatthew G. Knepley *off += cohesive ? size : size*2; 30435fedec97SMatthew G. Knepley } 30445fedec97SMatthew G. Knepley PetscFunctionReturn(0); 30455fedec97SMatthew G. Knepley } 30465fedec97SMatthew G. Knepley 30475fedec97SMatthew G. Knepley /*@ 304847e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 3049bc4ae4beSMatthew G. Knepley 3050bc4ae4beSMatthew G. Knepley Not collective 3051bc4ae4beSMatthew G. Knepley 305247e57110SSander Arens Input Parameter: 305347e57110SSander Arens . prob - The PetscDS object 3054bc4ae4beSMatthew G. Knepley 3055bc4ae4beSMatthew G. Knepley Output Parameter: 305647e57110SSander Arens . dimensions - The number of dimensions 3057bc4ae4beSMatthew G. Knepley 3058bc4ae4beSMatthew G. Knepley Level: beginner 3059bc4ae4beSMatthew G. Knepley 3060db781477SPatrick Sanan .seealso: `PetscDSGetComponentOffsets()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 3061bc4ae4beSMatthew G. Knepley @*/ 306247e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 30632764a2aaSMatthew G. Knepley { 30642764a2aaSMatthew G. Knepley PetscFunctionBegin; 30652764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30669566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 306747e57110SSander Arens PetscValidPointer(dimensions, 2); 306847e57110SSander Arens *dimensions = prob->Nb; 306947e57110SSander Arens PetscFunctionReturn(0); 30706ce16762SMatthew G. Knepley } 307147e57110SSander Arens 307247e57110SSander Arens /*@ 307347e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 307447e57110SSander Arens 307547e57110SSander Arens Not collective 307647e57110SSander Arens 307747e57110SSander Arens Input Parameter: 307847e57110SSander Arens . prob - The PetscDS object 307947e57110SSander Arens 308047e57110SSander Arens Output Parameter: 308147e57110SSander Arens . components - The number of components 308247e57110SSander Arens 308347e57110SSander Arens Level: beginner 308447e57110SSander Arens 3085db781477SPatrick Sanan .seealso: `PetscDSGetComponentOffsets()`, `PetscDSGetNumFields()`, `PetscDSCreate()` 308647e57110SSander Arens @*/ 308747e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 308847e57110SSander Arens { 308947e57110SSander Arens PetscFunctionBegin; 309047e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30919566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 309247e57110SSander Arens PetscValidPointer(components, 2); 309347e57110SSander Arens *components = prob->Nc; 30946ce16762SMatthew G. Knepley PetscFunctionReturn(0); 30956ce16762SMatthew G. Knepley } 30966ce16762SMatthew G. Knepley 30976ce16762SMatthew G. Knepley /*@ 30986ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 30996ce16762SMatthew G. Knepley 31006ce16762SMatthew G. Knepley Not collective 31016ce16762SMatthew G. Knepley 31026ce16762SMatthew G. Knepley Input Parameters: 31036ce16762SMatthew G. Knepley + prob - The PetscDS object 31046ce16762SMatthew G. Knepley - f - The field number 31056ce16762SMatthew G. Knepley 31066ce16762SMatthew G. Knepley Output Parameter: 31076ce16762SMatthew G. Knepley . off - The offset 31086ce16762SMatthew G. Knepley 31096ce16762SMatthew G. Knepley Level: beginner 31106ce16762SMatthew G. Knepley 3111db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 31126ce16762SMatthew G. Knepley @*/ 31136ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 31146ce16762SMatthew G. Knepley { 31156ce16762SMatthew G. Knepley PetscFunctionBegin; 31166ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3117dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 311863a3b9bcSJacob Faibussowitsch PetscCheck(!(f < 0) && !(f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, prob->Nf); 31199566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 312047e57110SSander Arens *off = prob->off[f]; 31212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31222764a2aaSMatthew G. Knepley } 31232764a2aaSMatthew G. Knepley 3124194d53e6SMatthew G. Knepley /*@ 3125194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 3126194d53e6SMatthew G. Knepley 3127194d53e6SMatthew G. Knepley Not collective 3128194d53e6SMatthew G. Knepley 3129194d53e6SMatthew G. Knepley Input Parameter: 3130194d53e6SMatthew G. Knepley . prob - The PetscDS object 3131194d53e6SMatthew G. Knepley 3132194d53e6SMatthew G. Knepley Output Parameter: 3133194d53e6SMatthew G. Knepley . offsets - The offsets 3134194d53e6SMatthew G. Knepley 3135194d53e6SMatthew G. Knepley Level: beginner 3136194d53e6SMatthew G. Knepley 3137db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 3138194d53e6SMatthew G. Knepley @*/ 3139194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 3140194d53e6SMatthew G. Knepley { 3141194d53e6SMatthew G. Knepley PetscFunctionBegin; 3142194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3143194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31449566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3145194d53e6SMatthew G. Knepley *offsets = prob->off; 3146194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3147194d53e6SMatthew G. Knepley } 3148194d53e6SMatthew G. Knepley 3149194d53e6SMatthew G. Knepley /*@ 3150194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 3151194d53e6SMatthew G. Knepley 3152194d53e6SMatthew G. Knepley Not collective 3153194d53e6SMatthew G. Knepley 3154194d53e6SMatthew G. Knepley Input Parameter: 3155194d53e6SMatthew G. Knepley . prob - The PetscDS object 3156194d53e6SMatthew G. Knepley 3157194d53e6SMatthew G. Knepley Output Parameter: 3158194d53e6SMatthew G. Knepley . offsets - The offsets 3159194d53e6SMatthew G. Knepley 3160194d53e6SMatthew G. Knepley Level: beginner 3161194d53e6SMatthew G. Knepley 3162db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 3163194d53e6SMatthew G. Knepley @*/ 3164194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 3165194d53e6SMatthew G. Knepley { 3166194d53e6SMatthew G. Knepley PetscFunctionBegin; 3167194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3168194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31699566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3170194d53e6SMatthew G. Knepley *offsets = prob->offDer; 3171194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3172194d53e6SMatthew G. Knepley } 3173194d53e6SMatthew G. Knepley 31749ee2af8cSMatthew G. Knepley /*@ 31759ee2af8cSMatthew G. Knepley PetscDSGetComponentOffsetsCohesive - Returns the offset of each field on an evaluation point 31769ee2af8cSMatthew G. Knepley 31779ee2af8cSMatthew G. Knepley Not collective 31789ee2af8cSMatthew G. Knepley 31799ee2af8cSMatthew G. Knepley Input Parameters: 31809ee2af8cSMatthew G. Knepley + ds - The PetscDS object 31819ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 31829ee2af8cSMatthew G. Knepley 31839ee2af8cSMatthew G. Knepley Output Parameter: 31849ee2af8cSMatthew G. Knepley . offsets - The offsets 31859ee2af8cSMatthew G. Knepley 31869ee2af8cSMatthew G. Knepley Level: beginner 31879ee2af8cSMatthew G. Knepley 3188db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 31899ee2af8cSMatthew G. Knepley @*/ 31909ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 31919ee2af8cSMatthew G. Knepley { 31929ee2af8cSMatthew G. Knepley PetscFunctionBegin; 31939ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 31949ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 319528b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 319663a3b9bcSJacob Faibussowitsch PetscCheck(!(s < 0) && !(s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %" PetscInt_FMT " is not in [0, 2]", s); 31979566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(ds)); 31989ee2af8cSMatthew G. Knepley *offsets = ds->offCohesive[s]; 31999ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32009ee2af8cSMatthew G. Knepley } 32019ee2af8cSMatthew G. Knepley 32029ee2af8cSMatthew G. Knepley /*@ 32039ee2af8cSMatthew G. Knepley PetscDSGetComponentDerivativeOffsetsCohesive - Returns the offset of each field derivative on an evaluation point 32049ee2af8cSMatthew G. Knepley 32059ee2af8cSMatthew G. Knepley Not collective 32069ee2af8cSMatthew G. Knepley 32079ee2af8cSMatthew G. Knepley Input Parameters: 32089ee2af8cSMatthew G. Knepley + ds - The PetscDS object 32099ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 32109ee2af8cSMatthew G. Knepley 32119ee2af8cSMatthew G. Knepley Output Parameter: 32129ee2af8cSMatthew G. Knepley . offsets - The offsets 32139ee2af8cSMatthew G. Knepley 32149ee2af8cSMatthew G. Knepley Level: beginner 32159ee2af8cSMatthew G. Knepley 3216db781477SPatrick Sanan .seealso: `PetscDSGetNumFields()`, `PetscDSCreate()` 32179ee2af8cSMatthew G. Knepley @*/ 32189ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 32199ee2af8cSMatthew G. Knepley { 32209ee2af8cSMatthew G. Knepley PetscFunctionBegin; 32219ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 32229ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 322328b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 322463a3b9bcSJacob Faibussowitsch PetscCheck(!(s < 0) && !(s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %" PetscInt_FMT " is not in [0, 2]", s); 32259566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(ds)); 32269ee2af8cSMatthew G. Knepley *offsets = ds->offDerCohesive[s]; 32279ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32289ee2af8cSMatthew G. Knepley } 32299ee2af8cSMatthew G. Knepley 323068c9edb9SMatthew G. Knepley /*@C 323168c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 323268c9edb9SMatthew G. Knepley 323368c9edb9SMatthew G. Knepley Not collective 323468c9edb9SMatthew G. Knepley 323568c9edb9SMatthew G. Knepley Input Parameter: 323668c9edb9SMatthew G. Knepley . prob - The PetscDS object 323768c9edb9SMatthew G. Knepley 3238ef0bb6c7SMatthew G. Knepley Output Parameter: 3239ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 324068c9edb9SMatthew G. Knepley 324168c9edb9SMatthew G. Knepley Level: intermediate 324268c9edb9SMatthew G. Knepley 3243db781477SPatrick Sanan .seealso: `PetscDSCreate()` 324468c9edb9SMatthew G. Knepley @*/ 3245ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 32462764a2aaSMatthew G. Knepley { 32472764a2aaSMatthew G. Knepley PetscFunctionBegin; 32482764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3249ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 32509566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3251ef0bb6c7SMatthew G. Knepley *T = prob->T; 32522764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32532764a2aaSMatthew G. Knepley } 32542764a2aaSMatthew G. Knepley 325568c9edb9SMatthew G. Knepley /*@C 32564d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 325768c9edb9SMatthew G. Knepley 325868c9edb9SMatthew G. Knepley Not collective 325968c9edb9SMatthew G. Knepley 326068c9edb9SMatthew G. Knepley Input Parameter: 326168c9edb9SMatthew G. Knepley . prob - The PetscDS object 326268c9edb9SMatthew G. Knepley 3263ef0bb6c7SMatthew G. Knepley Output Parameter: 3264a5b23f4aSJose E. Roman . Tf - The basis function and derivative tabulation on each local face at quadrature points for each and field 326568c9edb9SMatthew G. Knepley 326668c9edb9SMatthew G. Knepley Level: intermediate 326768c9edb9SMatthew G. Knepley 3268db781477SPatrick Sanan .seealso: `PetscDSGetTabulation()`, `PetscDSCreate()` 326968c9edb9SMatthew G. Knepley @*/ 3270ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 32712764a2aaSMatthew G. Knepley { 32722764a2aaSMatthew G. Knepley PetscFunctionBegin; 32732764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3274ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 32759566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3276ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 32772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32782764a2aaSMatthew G. Knepley } 32792764a2aaSMatthew G. Knepley 32802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 32812764a2aaSMatthew G. Knepley { 32822764a2aaSMatthew G. Knepley PetscFunctionBegin; 32832764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32849566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 32852764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 32862764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 32872764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 32882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32892764a2aaSMatthew G. Knepley } 32902764a2aaSMatthew G. Knepley 32912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 32922764a2aaSMatthew G. Knepley { 32932764a2aaSMatthew G. Knepley PetscFunctionBegin; 32942764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32959566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 32962764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 32972764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 32982764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 32992764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 33002764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 33012764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 33022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33032764a2aaSMatthew G. Knepley } 33042764a2aaSMatthew G. Knepley 33054bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 33062764a2aaSMatthew G. Knepley { 33072764a2aaSMatthew G. Knepley PetscFunctionBegin; 33082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33099566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 33102764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 33114bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 33127506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 33137506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 33147506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 33152764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33162764a2aaSMatthew G. Knepley } 33172764a2aaSMatthew G. Knepley 331858ebd649SToby Isaac /*@C 33196aad120cSJose E. Roman PetscDSAddBoundary - Add a boundary condition to the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performed, using the kernels from PetscDSSetBdResidual(). 332058ebd649SToby Isaac 3321783e2ec8SMatthew G. Knepley Collective on ds 3322783e2ec8SMatthew G. Knepley 332358ebd649SToby Isaac Input Parameters: 332458ebd649SToby Isaac + ds - The PetscDS object 33252d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 332658ebd649SToby Isaac . name - The BC name 332745480ffeSMatthew G. Knepley . label - The label defining constrained points 332845480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 332945480ffeSMatthew G. Knepley . values - An array of label values for constrained points 333058ebd649SToby Isaac . field - The field to constrain 333145480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 333258ebd649SToby Isaac . comps - An array of constrained component numbers 333358ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3334a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 333558ebd649SToby Isaac - ctx - An optional user context for bcFunc 333658ebd649SToby Isaac 333745480ffeSMatthew G. Knepley Output Parameters: 333845480ffeSMatthew G. Knepley - bd - The boundary number 333945480ffeSMatthew G. Knepley 334058ebd649SToby Isaac Options Database Keys: 334158ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 334258ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 334358ebd649SToby Isaac 334456cf3b9cSMatthew G. Knepley Note: 334556cf3b9cSMatthew G. Knepley Both bcFunc abd bcFunc_t will depend on the boundary condition type. If the type if DM_BC_ESSENTIAL, Then the calling sequence is: 334656cf3b9cSMatthew G. Knepley 334756cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 334856cf3b9cSMatthew G. Knepley 334956cf3b9cSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 335056cf3b9cSMatthew G. Knepley 335156cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 335256cf3b9cSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 335356cf3b9cSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 335456cf3b9cSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 335556cf3b9cSMatthew G. Knepley 335656cf3b9cSMatthew G. Knepley + dim - the spatial dimension 335756cf3b9cSMatthew G. Knepley . Nf - the number of fields 335856cf3b9cSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 335956cf3b9cSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 336056cf3b9cSMatthew G. Knepley . u - each field evaluated at the current point 336156cf3b9cSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 336256cf3b9cSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 336356cf3b9cSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 336456cf3b9cSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 336556cf3b9cSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 336656cf3b9cSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 336756cf3b9cSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 336856cf3b9cSMatthew G. Knepley . t - current time 336956cf3b9cSMatthew G. Knepley . x - coordinates of the current point 337056cf3b9cSMatthew G. Knepley . numConstants - number of constant parameters 337156cf3b9cSMatthew G. Knepley . constants - constant parameters 337256cf3b9cSMatthew G. Knepley - bcval - output values at the current point 337356cf3b9cSMatthew G. Knepley 337458ebd649SToby Isaac Level: developer 337558ebd649SToby Isaac 3376db781477SPatrick Sanan .seealso: `PetscDSAddBoundaryByName()`, `PetscDSGetBoundary()`, `PetscDSSetResidual()`, `PetscDSSetBdResidual()` 337758ebd649SToby Isaac @*/ 337845480ffeSMatthew G. Knepley PetscErrorCode PetscDSAddBoundary(PetscDS ds, DMBoundaryConditionType type, const char name[], DMLabel label, PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx, PetscInt *bd) 337958ebd649SToby Isaac { 338045480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 338145480ffeSMatthew G. Knepley PetscInt n = 0; 338245480ffeSMatthew G. Knepley const char *lname; 338358ebd649SToby Isaac 338458ebd649SToby Isaac PetscFunctionBegin; 338558ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3386783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 338745480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 338845480ffeSMatthew G. Knepley PetscValidHeaderSpecific(label, DMLABEL_CLASSID, 4); 338945480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 339045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 339145480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 3392d57bb9dbSMatthew G. Knepley if (Nc > 0) { 3393d57bb9dbSMatthew G. Knepley PetscInt *fcomps; 3394d57bb9dbSMatthew G. Knepley PetscInt c; 3395d57bb9dbSMatthew G. Knepley 33969566063dSJacob Faibussowitsch PetscCall(PetscDSGetComponents(ds, &fcomps)); 339763a3b9bcSJacob Faibussowitsch PetscCheck(Nc <= fcomps[field],PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Number of constrained components %" PetscInt_FMT " > %" PetscInt_FMT " components for field %" PetscInt_FMT, Nc, fcomps[field], field); 3398d57bb9dbSMatthew G. Knepley for (c = 0; c < Nc; ++c) { 33991dca8a05SBarry Smith PetscCheck(comps[c] >= 0 && comps[c] < fcomps[field],PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Constrained component[%" PetscInt_FMT "] %" PetscInt_FMT " not in [0, %" PetscInt_FMT ") components for field %" PetscInt_FMT, c, comps[c], fcomps[field], field); 3400d57bb9dbSMatthew G. Knepley } 3401d57bb9dbSMatthew G. Knepley } 34029566063dSJacob Faibussowitsch PetscCall(PetscNew(&b)); 34039566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 34049566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 34059566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 34069566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 34079566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 34089566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 34099566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 34109566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName((PetscObject) label, &lname)); 34119566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(lname, (char **) &b->lname)); 3412f971fd6bSMatthew G. Knepley b->type = type; 341345480ffeSMatthew G. Knepley b->label = label; 341445480ffeSMatthew G. Knepley b->Nv = Nv; 341558ebd649SToby Isaac b->field = field; 341645480ffeSMatthew G. Knepley b->Nc = Nc; 341758ebd649SToby Isaac b->func = bcFunc; 341856cf3b9cSMatthew G. Knepley b->func_t = bcFunc_t; 341958ebd649SToby Isaac b->ctx = ctx; 342045480ffeSMatthew G. Knepley b->next = NULL; 342145480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 342245480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 342345480ffeSMatthew G. Knepley while (head) { 342445480ffeSMatthew G. Knepley if (!head->next) { 342545480ffeSMatthew G. Knepley head->next = b; 342645480ffeSMatthew G. Knepley head = b; 342745480ffeSMatthew G. Knepley } 342845480ffeSMatthew G. Knepley head = head->next; 342945480ffeSMatthew G. Knepley ++n; 343045480ffeSMatthew G. Knepley } 3431064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 343245480ffeSMatthew G. Knepley PetscFunctionReturn(0); 343345480ffeSMatthew G. Knepley } 343445480ffeSMatthew G. Knepley 343545480ffeSMatthew G. Knepley /*@C 34366aad120cSJose E. Roman PetscDSAddBoundaryByName - Add a boundary condition to the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performed, using the kernels from PetscDSSetBdResidual(). 343745480ffeSMatthew G. Knepley 343845480ffeSMatthew G. Knepley Collective on ds 343945480ffeSMatthew G. Knepley 344045480ffeSMatthew G. Knepley Input Parameters: 344145480ffeSMatthew G. Knepley + ds - The PetscDS object 344245480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 344345480ffeSMatthew G. Knepley . name - The BC name 344445480ffeSMatthew G. Knepley . lname - The naem of the label defining constrained points 344545480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 344645480ffeSMatthew G. Knepley . values - An array of label values for constrained points 344745480ffeSMatthew G. Knepley . field - The field to constrain 344845480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 344945480ffeSMatthew G. Knepley . comps - An array of constrained component numbers 345045480ffeSMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3451a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 345245480ffeSMatthew G. Knepley - ctx - An optional user context for bcFunc 345345480ffeSMatthew G. Knepley 345445480ffeSMatthew G. Knepley Output Parameters: 345545480ffeSMatthew G. Knepley - bd - The boundary number 345645480ffeSMatthew G. Knepley 345745480ffeSMatthew G. Knepley Options Database Keys: 345845480ffeSMatthew G. Knepley + -bc_<boundary name> <num> - Overrides the boundary ids 345945480ffeSMatthew G. Knepley - -bc_<boundary name>_comp <num> - Overrides the boundary components 346045480ffeSMatthew G. Knepley 346145480ffeSMatthew G. Knepley Note: 346245480ffeSMatthew G. Knepley This function should only be used with DMForest currently, since labels cannot be defined before the underlygin Plex is built. 346345480ffeSMatthew G. Knepley 346445480ffeSMatthew G. Knepley Both bcFunc abd bcFunc_t will depend on the boundary condition type. If the type if DM_BC_ESSENTIAL, Then the calling sequence is: 346545480ffeSMatthew G. Knepley 346645480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 346745480ffeSMatthew G. Knepley 346845480ffeSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 346945480ffeSMatthew G. Knepley 347045480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 347145480ffeSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 347245480ffeSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 347345480ffeSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 347445480ffeSMatthew G. Knepley 347545480ffeSMatthew G. Knepley + dim - the spatial dimension 347645480ffeSMatthew G. Knepley . Nf - the number of fields 347745480ffeSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 347845480ffeSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 347945480ffeSMatthew G. Knepley . u - each field evaluated at the current point 348045480ffeSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 348145480ffeSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 348245480ffeSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 348345480ffeSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 348445480ffeSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 348545480ffeSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 348645480ffeSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 348745480ffeSMatthew G. Knepley . t - current time 348845480ffeSMatthew G. Knepley . x - coordinates of the current point 348945480ffeSMatthew G. Knepley . numConstants - number of constant parameters 349045480ffeSMatthew G. Knepley . constants - constant parameters 349145480ffeSMatthew G. Knepley - bcval - output values at the current point 349245480ffeSMatthew G. Knepley 349345480ffeSMatthew G. Knepley Level: developer 349445480ffeSMatthew G. Knepley 3495db781477SPatrick Sanan .seealso: `PetscDSAddBoundary()`, `PetscDSGetBoundary()`, `PetscDSSetResidual()`, `PetscDSSetBdResidual()` 349645480ffeSMatthew G. Knepley @*/ 349745480ffeSMatthew G. Knepley PetscErrorCode PetscDSAddBoundaryByName(PetscDS ds, DMBoundaryConditionType type, const char name[], const char lname[], PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx, PetscInt *bd) 349845480ffeSMatthew G. Knepley { 349945480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 350045480ffeSMatthew G. Knepley PetscInt n = 0; 350145480ffeSMatthew G. Knepley 350245480ffeSMatthew G. Knepley PetscFunctionBegin; 350345480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 350445480ffeSMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 350545480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 350645480ffeSMatthew G. Knepley PetscValidCharPointer(lname, 4); 350745480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 350845480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 350945480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 35109566063dSJacob Faibussowitsch PetscCall(PetscNew(&b)); 35119566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 35129566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 35139566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 35149566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 35159566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 35169566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 35179566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 35189566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(lname, (char **) &b->lname)); 351945480ffeSMatthew G. Knepley b->type = type; 352045480ffeSMatthew G. Knepley b->label = NULL; 352145480ffeSMatthew G. Knepley b->Nv = Nv; 352245480ffeSMatthew G. Knepley b->field = field; 352345480ffeSMatthew G. Knepley b->Nc = Nc; 352445480ffeSMatthew G. Knepley b->func = bcFunc; 352545480ffeSMatthew G. Knepley b->func_t = bcFunc_t; 352645480ffeSMatthew G. Knepley b->ctx = ctx; 352745480ffeSMatthew G. Knepley b->next = NULL; 352845480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 352945480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 353045480ffeSMatthew G. Knepley while (head) { 353145480ffeSMatthew G. Knepley if (!head->next) { 353245480ffeSMatthew G. Knepley head->next = b; 353345480ffeSMatthew G. Knepley head = b; 353445480ffeSMatthew G. Knepley } 353545480ffeSMatthew G. Knepley head = head->next; 353645480ffeSMatthew G. Knepley ++n; 353745480ffeSMatthew G. Knepley } 3538064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 353958ebd649SToby Isaac PetscFunctionReturn(0); 354058ebd649SToby Isaac } 354158ebd649SToby Isaac 3542b67eacb3SMatthew G. Knepley /*@C 35436aad120cSJose E. Roman PetscDSUpdateBoundary - Change a boundary condition for the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performed, using the kernels from PetscDSSetBdResidual(). 3544b67eacb3SMatthew G. Knepley 3545b67eacb3SMatthew G. Knepley Input Parameters: 3546b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3547b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3548b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3549b67eacb3SMatthew G. Knepley . name - The BC name 355045480ffeSMatthew G. Knepley . label - The label defining constrained points 355145480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 355245480ffeSMatthew G. Knepley . values - An array of ids for constrained points 3553b67eacb3SMatthew G. Knepley . field - The field to constrain 355445480ffeSMatthew G. Knepley . Nc - The number of constrained field components 3555b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3556b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3557a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 3558b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3559b67eacb3SMatthew G. Knepley 356056cf3b9cSMatthew G. Knepley Note: 356156cf3b9cSMatthew G. Knepley The boundary condition number is the order in which it was registered. The user can get the number of boundary conditions from PetscDSGetNumBoundary(). See PetscDSAddBoundary() for a description of the calling sequences for the callbacks. 35629a6efb6aSMatthew G. Knepley 3563b67eacb3SMatthew G. Knepley Level: developer 3564b67eacb3SMatthew G. Knepley 3565db781477SPatrick Sanan .seealso: `PetscDSAddBoundary()`, `PetscDSGetBoundary()`, `PetscDSGetNumBoundary()` 3566b67eacb3SMatthew G. Knepley @*/ 356745480ffeSMatthew G. Knepley PetscErrorCode PetscDSUpdateBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType type, const char name[], DMLabel label, PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx) 3568b67eacb3SMatthew G. Knepley { 3569b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3570b67eacb3SMatthew G. Knepley PetscInt n = 0; 3571b67eacb3SMatthew G. Knepley 3572b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3573b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3574b67eacb3SMatthew G. Knepley while (b) { 3575b67eacb3SMatthew G. Knepley if (n == bd) break; 3576b67eacb3SMatthew G. Knepley b = b->next; 3577b67eacb3SMatthew G. Knepley ++n; 3578b67eacb3SMatthew G. Knepley } 357963a3b9bcSJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %" PetscInt_FMT " is not in [0, %" PetscInt_FMT ")", bd, n); 3580b67eacb3SMatthew G. Knepley if (name) { 35819566063dSJacob Faibussowitsch PetscCall(PetscFree(b->name)); 35829566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 3583b67eacb3SMatthew G. Knepley } 3584b67eacb3SMatthew G. Knepley b->type = type; 358545480ffeSMatthew G. Knepley if (label) { 358645480ffeSMatthew G. Knepley const char *name; 358745480ffeSMatthew G. Knepley 358845480ffeSMatthew G. Knepley b->label = label; 35899566063dSJacob Faibussowitsch PetscCall(PetscFree(b->lname)); 35909566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName((PetscObject) label, &name)); 35919566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->lname)); 359245480ffeSMatthew G. Knepley } 359345480ffeSMatthew G. Knepley if (Nv >= 0) { 359445480ffeSMatthew G. Knepley b->Nv = Nv; 35959566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 35969566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 35979566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 359845480ffeSMatthew G. Knepley } 359945480ffeSMatthew G. Knepley if (field >= 0) b->field = field; 360045480ffeSMatthew G. Knepley if (Nc >= 0) { 360145480ffeSMatthew G. Knepley b->Nc = Nc; 36029566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 36039566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 36049566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 360545480ffeSMatthew G. Knepley } 360645480ffeSMatthew G. Knepley if (bcFunc) b->func = bcFunc; 360745480ffeSMatthew G. Knepley if (bcFunc_t) b->func_t = bcFunc_t; 360845480ffeSMatthew G. Knepley if (ctx) b->ctx = ctx; 3609b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3610b67eacb3SMatthew G. Knepley } 3611b67eacb3SMatthew G. Knepley 361258ebd649SToby Isaac /*@ 361358ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 361458ebd649SToby Isaac 361558ebd649SToby Isaac Input Parameters: 361658ebd649SToby Isaac . ds - The PetscDS object 361758ebd649SToby Isaac 361858ebd649SToby Isaac Output Parameters: 361958ebd649SToby Isaac . numBd - The number of BC 362058ebd649SToby Isaac 362158ebd649SToby Isaac Level: intermediate 362258ebd649SToby Isaac 3623db781477SPatrick Sanan .seealso: `PetscDSAddBoundary()`, `PetscDSGetBoundary()` 362458ebd649SToby Isaac @*/ 362558ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 362658ebd649SToby Isaac { 362758ebd649SToby Isaac DSBoundary b = ds->boundary; 362858ebd649SToby Isaac 362958ebd649SToby Isaac PetscFunctionBegin; 363058ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3631dadcf809SJacob Faibussowitsch PetscValidIntPointer(numBd, 2); 363258ebd649SToby Isaac *numBd = 0; 363358ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 363458ebd649SToby Isaac PetscFunctionReturn(0); 363558ebd649SToby Isaac } 363658ebd649SToby Isaac 363758ebd649SToby Isaac /*@C 36389a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 363958ebd649SToby Isaac 364058ebd649SToby Isaac Input Parameters: 364158ebd649SToby Isaac + ds - The PetscDS object 364258ebd649SToby Isaac - bd - The BC number 364358ebd649SToby Isaac 364458ebd649SToby Isaac Output Parameters: 364545480ffeSMatthew G. Knepley + wf - The PetscWeakForm holding the pointwise functions 364645480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 364758ebd649SToby Isaac . name - The BC name 364845480ffeSMatthew G. Knepley . label - The label defining constrained points 364945480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 365045480ffeSMatthew G. Knepley . values - An array of ids for constrained points 365158ebd649SToby Isaac . field - The field to constrain 365245480ffeSMatthew G. Knepley . Nc - The number of constrained field components 365358ebd649SToby Isaac . comps - An array of constrained component numbers 365458ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3655a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values 365658ebd649SToby Isaac - ctx - An optional user context for bcFunc 365758ebd649SToby Isaac 365858ebd649SToby Isaac Options Database Keys: 365958ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 366058ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 366158ebd649SToby Isaac 366258ebd649SToby Isaac Level: developer 366358ebd649SToby Isaac 3664db781477SPatrick Sanan .seealso: `PetscDSAddBoundary()` 366558ebd649SToby Isaac @*/ 366645480ffeSMatthew G. Knepley PetscErrorCode PetscDSGetBoundary(PetscDS ds, PetscInt bd, PetscWeakForm *wf, DMBoundaryConditionType *type, const char *name[], DMLabel *label, PetscInt *Nv, const PetscInt *values[], PetscInt *field, PetscInt *Nc, const PetscInt *comps[], void (**func)(void), void (**func_t)(void), void **ctx) 366758ebd649SToby Isaac { 366858ebd649SToby Isaac DSBoundary b = ds->boundary; 366958ebd649SToby Isaac PetscInt n = 0; 367058ebd649SToby Isaac 367158ebd649SToby Isaac PetscFunctionBegin; 367258ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 367358ebd649SToby Isaac while (b) { 367458ebd649SToby Isaac if (n == bd) break; 367558ebd649SToby Isaac b = b->next; 367658ebd649SToby Isaac ++n; 367758ebd649SToby Isaac } 367863a3b9bcSJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %" PetscInt_FMT " is not in [0, %" PetscInt_FMT ")", bd, n); 367945480ffeSMatthew G. Knepley if (wf) { 368045480ffeSMatthew G. Knepley PetscValidPointer(wf, 3); 368145480ffeSMatthew G. Knepley *wf = b->wf; 368245480ffeSMatthew G. Knepley } 3683f971fd6bSMatthew G. Knepley if (type) { 368445480ffeSMatthew G. Knepley PetscValidPointer(type, 4); 3685f971fd6bSMatthew G. Knepley *type = b->type; 368658ebd649SToby Isaac } 368758ebd649SToby Isaac if (name) { 368845480ffeSMatthew G. Knepley PetscValidPointer(name, 5); 368958ebd649SToby Isaac *name = b->name; 369058ebd649SToby Isaac } 369145480ffeSMatthew G. Knepley if (label) { 369245480ffeSMatthew G. Knepley PetscValidPointer(label, 6); 369345480ffeSMatthew G. Knepley *label = b->label; 369445480ffeSMatthew G. Knepley } 369545480ffeSMatthew G. Knepley if (Nv) { 369645480ffeSMatthew G. Knepley PetscValidIntPointer(Nv, 7); 369745480ffeSMatthew G. Knepley *Nv = b->Nv; 369845480ffeSMatthew G. Knepley } 369945480ffeSMatthew G. Knepley if (values) { 370045480ffeSMatthew G. Knepley PetscValidPointer(values, 8); 370145480ffeSMatthew G. Knepley *values = b->values; 370258ebd649SToby Isaac } 370358ebd649SToby Isaac if (field) { 370445480ffeSMatthew G. Knepley PetscValidIntPointer(field, 9); 370558ebd649SToby Isaac *field = b->field; 370658ebd649SToby Isaac } 370745480ffeSMatthew G. Knepley if (Nc) { 370845480ffeSMatthew G. Knepley PetscValidIntPointer(Nc, 10); 370945480ffeSMatthew G. Knepley *Nc = b->Nc; 371058ebd649SToby Isaac } 371158ebd649SToby Isaac if (comps) { 371245480ffeSMatthew G. Knepley PetscValidPointer(comps, 11); 371358ebd649SToby Isaac *comps = b->comps; 371458ebd649SToby Isaac } 371558ebd649SToby Isaac if (func) { 371645480ffeSMatthew G. Knepley PetscValidPointer(func, 12); 371758ebd649SToby Isaac *func = b->func; 371858ebd649SToby Isaac } 371956cf3b9cSMatthew G. Knepley if (func_t) { 372045480ffeSMatthew G. Knepley PetscValidPointer(func_t, 13); 372156cf3b9cSMatthew G. Knepley *func_t = b->func_t; 372256cf3b9cSMatthew G. Knepley } 372358ebd649SToby Isaac if (ctx) { 372445480ffeSMatthew G. Knepley PetscValidPointer(ctx, 14); 372558ebd649SToby Isaac *ctx = b->ctx; 372658ebd649SToby Isaac } 372758ebd649SToby Isaac PetscFunctionReturn(0); 372858ebd649SToby Isaac } 372958ebd649SToby Isaac 373045480ffeSMatthew G. Knepley static PetscErrorCode DSBoundaryDuplicate_Internal(DSBoundary b, DSBoundary *bNew) 373145480ffeSMatthew G. Knepley { 373245480ffeSMatthew G. Knepley PetscFunctionBegin; 37339566063dSJacob Faibussowitsch PetscCall(PetscNew(bNew)); 37349566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &(*bNew)->wf)); 37359566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCopy(b->wf, (*bNew)->wf)); 37369566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(b->name,(char **) &((*bNew)->name))); 37379566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(b->lname,(char **) &((*bNew)->lname))); 373845480ffeSMatthew G. Knepley (*bNew)->type = b->type; 373945480ffeSMatthew G. Knepley (*bNew)->label = b->label; 374045480ffeSMatthew G. Knepley (*bNew)->Nv = b->Nv; 37419566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(b->Nv, &(*bNew)->values)); 37429566063dSJacob Faibussowitsch PetscCall(PetscArraycpy((*bNew)->values, b->values, b->Nv)); 374345480ffeSMatthew G. Knepley (*bNew)->field = b->field; 374445480ffeSMatthew G. Knepley (*bNew)->Nc = b->Nc; 37459566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(b->Nc, &(*bNew)->comps)); 37469566063dSJacob Faibussowitsch PetscCall(PetscArraycpy((*bNew)->comps, b->comps, b->Nc)); 374745480ffeSMatthew G. Knepley (*bNew)->func = b->func; 374845480ffeSMatthew G. Knepley (*bNew)->func_t = b->func_t; 374945480ffeSMatthew G. Knepley (*bNew)->ctx = b->ctx; 375045480ffeSMatthew G. Knepley PetscFunctionReturn(0); 375145480ffeSMatthew G. Knepley } 375245480ffeSMatthew G. Knepley 37539252d075SMatthew G. Knepley /*@ 37549252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 37559252d075SMatthew G. Knepley 37569252d075SMatthew G. Knepley Not collective 37579252d075SMatthew G. Knepley 375836951cb5SMatthew G. Knepley Input Parameters: 375936951cb5SMatthew G. Knepley + ds - The source PetscDS object 376036951cb5SMatthew G. Knepley . numFields - The number of selected fields, or PETSC_DEFAULT for all fields 376136951cb5SMatthew G. Knepley - fields - The selected fields, or NULL for all fields 37629252d075SMatthew G. Knepley 37639252d075SMatthew G. Knepley Output Parameter: 376436951cb5SMatthew G. Knepley . newds - The target PetscDS, now with a copy of the boundary conditions 37659252d075SMatthew G. Knepley 37669252d075SMatthew G. Knepley Level: intermediate 37679252d075SMatthew G. Knepley 3768db781477SPatrick Sanan .seealso: `PetscDSCopyEquations()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 37699252d075SMatthew G. Knepley @*/ 377036951cb5SMatthew G. Knepley PetscErrorCode PetscDSCopyBoundary(PetscDS ds, PetscInt numFields, const PetscInt fields[], PetscDS newds) 3771dff059c6SToby Isaac { 377245480ffeSMatthew G. Knepley DSBoundary b, *lastnext; 3773dff059c6SToby Isaac 3774dff059c6SToby Isaac PetscFunctionBegin; 377536951cb5SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 377636951cb5SMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 4); 377736951cb5SMatthew G. Knepley if (ds == newds) PetscFunctionReturn(0); 37789566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyBoundary(newds)); 377936951cb5SMatthew G. Knepley lastnext = &(newds->boundary); 378036951cb5SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 3781dff059c6SToby Isaac DSBoundary bNew; 378236951cb5SMatthew G. Knepley PetscInt fieldNew = -1; 3783dff059c6SToby Isaac 378436951cb5SMatthew G. Knepley if (numFields > 0 && fields) { 378536951cb5SMatthew G. Knepley PetscInt f; 378636951cb5SMatthew G. Knepley 378736951cb5SMatthew G. Knepley for (f = 0; f < numFields; ++f) if (b->field == fields[f]) break; 378836951cb5SMatthew G. Knepley if (f == numFields) continue; 378936951cb5SMatthew G. Knepley fieldNew = f; 379036951cb5SMatthew G. Knepley } 37919566063dSJacob Faibussowitsch PetscCall(DSBoundaryDuplicate_Internal(b, &bNew)); 379236951cb5SMatthew G. Knepley bNew->field = fieldNew < 0 ? b->field : fieldNew; 3793dff059c6SToby Isaac *lastnext = bNew; 3794dff059c6SToby Isaac lastnext = &(bNew->next); 3795dff059c6SToby Isaac } 3796dff059c6SToby Isaac PetscFunctionReturn(0); 3797dff059c6SToby Isaac } 3798dff059c6SToby Isaac 37996c1eb96dSMatthew G. Knepley /*@ 380045480ffeSMatthew G. Knepley PetscDSDestroyBoundary - Remove all DMBoundary objects from the PetscDS 380145480ffeSMatthew G. Knepley 380245480ffeSMatthew G. Knepley Not collective 380345480ffeSMatthew G. Knepley 380445480ffeSMatthew G. Knepley Input Parameter: 380545480ffeSMatthew G. Knepley . ds - The PetscDS object 380645480ffeSMatthew G. Knepley 380745480ffeSMatthew G. Knepley Level: intermediate 380845480ffeSMatthew G. Knepley 3809db781477SPatrick Sanan .seealso: `PetscDSCopyBoundary()`, `PetscDSCopyEquations()` 381045480ffeSMatthew G. Knepley @*/ 381145480ffeSMatthew G. Knepley PetscErrorCode PetscDSDestroyBoundary(PetscDS ds) 381245480ffeSMatthew G. Knepley { 381345480ffeSMatthew G. Knepley DSBoundary next = ds->boundary; 381445480ffeSMatthew G. Knepley 381545480ffeSMatthew G. Knepley PetscFunctionBegin; 381645480ffeSMatthew G. Knepley while (next) { 381745480ffeSMatthew G. Knepley DSBoundary b = next; 381845480ffeSMatthew G. Knepley 381945480ffeSMatthew G. Knepley next = b->next; 38209566063dSJacob Faibussowitsch PetscCall(PetscWeakFormDestroy(&b->wf)); 38219566063dSJacob Faibussowitsch PetscCall(PetscFree(b->name)); 38229566063dSJacob Faibussowitsch PetscCall(PetscFree(b->lname)); 38239566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 38249566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 38259566063dSJacob Faibussowitsch PetscCall(PetscFree(b)); 382645480ffeSMatthew G. Knepley } 382745480ffeSMatthew G. Knepley PetscFunctionReturn(0); 382845480ffeSMatthew G. Knepley } 382945480ffeSMatthew G. Knepley 383045480ffeSMatthew G. Knepley /*@ 38316c1eb96dSMatthew G. Knepley PetscDSSelectDiscretizations - Copy discretizations to the new problem with different field layout 38326c1eb96dSMatthew G. Knepley 38336c1eb96dSMatthew G. Knepley Not collective 38346c1eb96dSMatthew G. Knepley 3835d8d19677SJose E. Roman Input Parameters: 38366c1eb96dSMatthew G. Knepley + prob - The PetscDS object 38376c1eb96dSMatthew G. Knepley . numFields - Number of new fields 38386c1eb96dSMatthew G. Knepley - fields - Old field number for each new field 38396c1eb96dSMatthew G. Knepley 38406c1eb96dSMatthew G. Knepley Output Parameter: 38416c1eb96dSMatthew G. Knepley . newprob - The PetscDS copy 38426c1eb96dSMatthew G. Knepley 38436c1eb96dSMatthew G. Knepley Level: intermediate 38446c1eb96dSMatthew G. Knepley 3845db781477SPatrick Sanan .seealso: `PetscDSSelectEquations()`, `PetscDSCopyBoundary()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 38466c1eb96dSMatthew G. Knepley @*/ 38476c1eb96dSMatthew G. Knepley PetscErrorCode PetscDSSelectDiscretizations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38486c1eb96dSMatthew G. Knepley { 38496c1eb96dSMatthew G. Knepley PetscInt Nf, Nfn, fn; 38506c1eb96dSMatthew G. Knepley 38516c1eb96dSMatthew G. Knepley PetscFunctionBegin; 38526c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3853dadcf809SJacob Faibussowitsch if (fields) PetscValidIntPointer(fields, 3); 38546c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38559566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 38569566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Nfn)); 385745480ffeSMatthew G. Knepley numFields = numFields < 0 ? Nf : numFields; 38586c1eb96dSMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38596c1eb96dSMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38606c1eb96dSMatthew G. Knepley PetscObject disc; 38616c1eb96dSMatthew G. Knepley 38626c1eb96dSMatthew G. Knepley if (f >= Nf) continue; 38639566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &disc)); 38649566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(newprob, fn, disc)); 38656c1eb96dSMatthew G. Knepley } 38666c1eb96dSMatthew G. Knepley PetscFunctionReturn(0); 38676c1eb96dSMatthew G. Knepley } 38686c1eb96dSMatthew G. Knepley 38696c1eb96dSMatthew G. Knepley /*@ 38709252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 38719252d075SMatthew G. Knepley 38729252d075SMatthew G. Knepley Not collective 38739252d075SMatthew G. Knepley 3874d8d19677SJose E. Roman Input Parameters: 38759252d075SMatthew G. Knepley + prob - The PetscDS object 38769252d075SMatthew G. Knepley . numFields - Number of new fields 38779252d075SMatthew G. Knepley - fields - Old field number for each new field 38789252d075SMatthew G. Knepley 38799252d075SMatthew G. Knepley Output Parameter: 38809252d075SMatthew G. Knepley . newprob - The PetscDS copy 38819252d075SMatthew G. Knepley 38829252d075SMatthew G. Knepley Level: intermediate 38839252d075SMatthew G. Knepley 3884db781477SPatrick Sanan .seealso: `PetscDSSelectDiscretizations()`, `PetscDSCopyBoundary()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 38859252d075SMatthew G. Knepley @*/ 38869252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38879252d075SMatthew G. Knepley { 38889252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 38899252d075SMatthew G. Knepley 38909252d075SMatthew G. Knepley PetscFunctionBegin; 38919252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3892dadcf809SJacob Faibussowitsch if (fields) PetscValidIntPointer(fields, 3); 38939252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38949566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 38959566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Nfn)); 389663a3b9bcSJacob Faibussowitsch PetscCheck(numFields <= Nfn,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields %" PetscInt_FMT " to transfer must not be greater then the total number of fields %" PetscInt_FMT, numFields, Nfn); 38979252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38989252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38999252d075SMatthew G. Knepley PetscPointFunc obj; 39009252d075SMatthew G. Knepley PetscPointFunc f0, f1; 39019252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 39029252d075SMatthew G. Knepley PetscRiemannFunc r; 39039252d075SMatthew G. Knepley 3904c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 39059566063dSJacob Faibussowitsch PetscCall(PetscDSGetObjective(prob, f, &obj)); 39069566063dSJacob Faibussowitsch PetscCall(PetscDSGetResidual(prob, f, &f0, &f1)); 39079566063dSJacob Faibussowitsch PetscCall(PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd)); 39089566063dSJacob Faibussowitsch PetscCall(PetscDSGetRiemannSolver(prob, f, &r)); 39099566063dSJacob Faibussowitsch PetscCall(PetscDSSetObjective(newprob, fn, obj)); 39109566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(newprob, fn, f0, f1)); 39119566063dSJacob Faibussowitsch PetscCall(PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd)); 39129566063dSJacob Faibussowitsch PetscCall(PetscDSSetRiemannSolver(newprob, fn, r)); 39139252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 39149252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 39159252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 39169252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 39179252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 39189252d075SMatthew G. Knepley 3919c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 39209566063dSJacob Faibussowitsch PetscCall(PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3)); 39219566063dSJacob Faibussowitsch PetscCall(PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p)); 39229566063dSJacob Faibussowitsch PetscCall(PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd)); 39239566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3)); 39249566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobianPreconditioner(newprob, fn, gn, g0p, g1p, g2p, g3p)); 39259566063dSJacob Faibussowitsch PetscCall(PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd)); 39269252d075SMatthew G. Knepley } 39279252d075SMatthew G. Knepley } 39289252d075SMatthew G. Knepley PetscFunctionReturn(0); 39299252d075SMatthew G. Knepley } 39309252d075SMatthew G. Knepley 3931da51fcedSMatthew G. Knepley /*@ 3932da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3933da51fcedSMatthew G. Knepley 3934da51fcedSMatthew G. Knepley Not collective 3935da51fcedSMatthew G. Knepley 3936da51fcedSMatthew G. Knepley Input Parameter: 3937da51fcedSMatthew G. Knepley . prob - The PetscDS object 3938da51fcedSMatthew G. Knepley 3939da51fcedSMatthew G. Knepley Output Parameter: 3940da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3941da51fcedSMatthew G. Knepley 3942da51fcedSMatthew G. Knepley Level: intermediate 3943da51fcedSMatthew G. Knepley 3944db781477SPatrick Sanan .seealso: `PetscDSCopyBoundary()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 3945da51fcedSMatthew G. Knepley @*/ 3946da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3947da51fcedSMatthew G. Knepley { 3948b8025e53SMatthew G. Knepley PetscWeakForm wf, newwf; 39499252d075SMatthew G. Knepley PetscInt Nf, Ng; 3950da51fcedSMatthew G. Knepley 3951da51fcedSMatthew G. Knepley PetscFunctionBegin; 3952da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3953da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39549566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 39559566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Ng)); 395663a3b9bcSJacob Faibussowitsch PetscCheck(Nf == Ng,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %" PetscInt_FMT " != %" PetscInt_FMT, Nf, Ng); 39579566063dSJacob Faibussowitsch PetscCall(PetscDSGetWeakForm(prob, &wf)); 39589566063dSJacob Faibussowitsch PetscCall(PetscDSGetWeakForm(newprob, &newwf)); 39599566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCopy(wf, newwf)); 39609252d075SMatthew G. Knepley PetscFunctionReturn(0); 39619252d075SMatthew G. Knepley } 396245480ffeSMatthew G. Knepley 39639252d075SMatthew G. Knepley /*@ 39649252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3965da51fcedSMatthew G. Knepley 39669252d075SMatthew G. Knepley Not collective 39679252d075SMatthew G. Knepley 39689252d075SMatthew G. Knepley Input Parameter: 39699252d075SMatthew G. Knepley . prob - The PetscDS object 39709252d075SMatthew G. Knepley 39719252d075SMatthew G. Knepley Output Parameter: 39729252d075SMatthew G. Knepley . newprob - The PetscDS copy 39739252d075SMatthew G. Knepley 39749252d075SMatthew G. Knepley Level: intermediate 39759252d075SMatthew G. Knepley 3976db781477SPatrick Sanan .seealso: `PetscDSCopyBoundary()`, `PetscDSCopyEquations()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 39779252d075SMatthew G. Knepley @*/ 39789252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 39799252d075SMatthew G. Knepley { 39809252d075SMatthew G. Knepley PetscInt Nc; 39819252d075SMatthew G. Knepley const PetscScalar *constants; 39829252d075SMatthew G. Knepley 39839252d075SMatthew G. Knepley PetscFunctionBegin; 39849252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 39859252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39869566063dSJacob Faibussowitsch PetscCall(PetscDSGetConstants(prob, &Nc, &constants)); 39879566063dSJacob Faibussowitsch PetscCall(PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants)); 3988da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3989da51fcedSMatthew G. Knepley } 3990da51fcedSMatthew G. Knepley 399145480ffeSMatthew G. Knepley /*@ 399245480ffeSMatthew G. Knepley PetscDSCopyExactSolutions - Copy all exact solutions to the new problem 399345480ffeSMatthew G. Knepley 399445480ffeSMatthew G. Knepley Not collective 399545480ffeSMatthew G. Knepley 399645480ffeSMatthew G. Knepley Input Parameter: 399745480ffeSMatthew G. Knepley . ds - The PetscDS object 399845480ffeSMatthew G. Knepley 399945480ffeSMatthew G. Knepley Output Parameter: 400045480ffeSMatthew G. Knepley . newds - The PetscDS copy 400145480ffeSMatthew G. Knepley 400245480ffeSMatthew G. Knepley Level: intermediate 400345480ffeSMatthew G. Knepley 4004db781477SPatrick Sanan .seealso: `PetscDSCopyBoundary()`, `PetscDSCopyEquations()`, `PetscDSSetResidual()`, `PetscDSSetJacobian()`, `PetscDSSetRiemannSolver()`, `PetscDSSetBdResidual()`, `PetscDSSetBdJacobian()`, `PetscDSCreate()` 400545480ffeSMatthew G. Knepley @*/ 400645480ffeSMatthew G. Knepley PetscErrorCode PetscDSCopyExactSolutions(PetscDS ds, PetscDS newds) 400745480ffeSMatthew G. Knepley { 400845480ffeSMatthew G. Knepley PetscSimplePointFunc sol; 400945480ffeSMatthew G. Knepley void *ctx; 401045480ffeSMatthew G. Knepley PetscInt Nf, f; 401145480ffeSMatthew G. Knepley 401245480ffeSMatthew G. Knepley PetscFunctionBegin; 401345480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 401445480ffeSMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 2); 40159566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 401645480ffeSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 40179566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolution(ds, f, &sol, &ctx)); 40189566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolution(newds, f, sol, ctx)); 40199566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolutionTimeDerivative(ds, f, &sol, &ctx)); 40209566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolutionTimeDerivative(newds, f, sol, ctx)); 402145480ffeSMatthew G. Knepley } 402245480ffeSMatthew G. Knepley PetscFunctionReturn(0); 402345480ffeSMatthew G. Knepley } 402445480ffeSMatthew G. Knepley 4025b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 4026b1353e8eSMatthew G. Knepley { 4027df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 4028b1353e8eSMatthew G. Knepley 4029b1353e8eSMatthew G. Knepley PetscFunctionBegin; 4030b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 4031b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 4032b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 40339566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 40349566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(prob, &dim)); 403563a3b9bcSJacob Faibussowitsch PetscCheck(height <= dim,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_OUTOFRANGE, "DS can only handle height in [0, %" PetscInt_FMT "], not %" PetscInt_FMT, dim, height); 40369566063dSJacob Faibussowitsch if (!prob->subprobs) PetscCall(PetscCalloc1(dim, &prob->subprobs)); 4037df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 4038b1353e8eSMatthew G. Knepley PetscInt cdim; 4039b1353e8eSMatthew G. Knepley 40409566063dSJacob Faibussowitsch PetscCall(PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1])); 40419566063dSJacob Faibussowitsch PetscCall(PetscDSGetCoordinateDimension(prob, &cdim)); 40429566063dSJacob Faibussowitsch PetscCall(PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim)); 4043b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 4044b1353e8eSMatthew G. Knepley PetscFE subfe; 4045b1353e8eSMatthew G. Knepley PetscObject obj; 4046b1353e8eSMatthew G. Knepley PetscClassId id; 4047b1353e8eSMatthew G. Knepley 40489566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &obj)); 40499566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 40509566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe)); 405163a3b9bcSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %" PetscInt_FMT, f); 40529566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe)); 4053b1353e8eSMatthew G. Knepley } 4054b1353e8eSMatthew G. Knepley } 4055df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 4056b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 4057b1353e8eSMatthew G. Knepley } 4058b1353e8eSMatthew G. Knepley 4059665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 4060c7bd5f0bSMatthew G. Knepley { 4061c7bd5f0bSMatthew G. Knepley PetscObject obj; 4062c7bd5f0bSMatthew G. Knepley PetscClassId id; 4063c7bd5f0bSMatthew G. Knepley PetscInt Nf; 4064c7bd5f0bSMatthew G. Knepley 4065c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 4066c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 4067665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 4068665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 40699566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 407063a3b9bcSJacob Faibussowitsch PetscCheck(f < Nf,PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, Nf); 40719566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(ds, f, &obj)); 4072665f567fSMatthew G. Knepley if (obj) { 40739566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 4074665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 4075665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 4076665f567fSMatthew G. Knepley } 4077c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 4078c7bd5f0bSMatthew G. Knepley } 4079c7bd5f0bSMatthew G. Knepley 40806528b96dSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS ds) 40812764a2aaSMatthew G. Knepley { 40822764a2aaSMatthew G. Knepley PetscFunctionBegin; 40839566063dSJacob Faibussowitsch PetscCall(PetscFree(ds->data)); 40842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40852764a2aaSMatthew G. Knepley } 40862764a2aaSMatthew G. Knepley 40876528b96dSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS ds) 40882764a2aaSMatthew G. Knepley { 40892764a2aaSMatthew G. Knepley PetscFunctionBegin; 40906528b96dSMatthew G. Knepley ds->ops->setfromoptions = NULL; 40916528b96dSMatthew G. Knepley ds->ops->setup = NULL; 40926528b96dSMatthew G. Knepley ds->ops->view = NULL; 40936528b96dSMatthew G. Knepley ds->ops->destroy = PetscDSDestroy_Basic; 40942764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40952764a2aaSMatthew G. Knepley } 40962764a2aaSMatthew G. Knepley 40972764a2aaSMatthew G. Knepley /*MC 40982764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 40992764a2aaSMatthew G. Knepley 41002764a2aaSMatthew G. Knepley Level: intermediate 41012764a2aaSMatthew G. Knepley 4102db781477SPatrick Sanan .seealso: `PetscDSType`, `PetscDSCreate()`, `PetscDSSetType()` 41032764a2aaSMatthew G. Knepley M*/ 41042764a2aaSMatthew G. Knepley 41056528b96dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS ds) 41062764a2aaSMatthew G. Knepley { 41072764a2aaSMatthew G. Knepley PetscDS_Basic *b; 41082764a2aaSMatthew G. Knepley 41092764a2aaSMatthew G. Knepley PetscFunctionBegin; 41106528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 41119566063dSJacob Faibussowitsch PetscCall(PetscNewLog(ds, &b)); 41126528b96dSMatthew G. Knepley ds->data = b; 41132764a2aaSMatthew G. Knepley 41149566063dSJacob Faibussowitsch PetscCall(PetscDSInitialize_Basic(ds)); 41152764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 41162764a2aaSMatthew G. Knepley } 4117