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 522764a2aaSMatthew G. Knepley .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 782764a2aaSMatthew G. Knepley .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 942764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 959566063dSJacob Faibussowitsch PetscCall((*prob->ops->destroy)(prob)); 962764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 972764a2aaSMatthew G. Knepley } 989566063dSJacob Faibussowitsch PetscCall((*r)(prob)); 999566063dSJacob Faibussowitsch PetscCall(PetscObjectChangeTypeName((PetscObject) prob, name)); 1002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1012764a2aaSMatthew G. Knepley } 1022764a2aaSMatthew G. Knepley 1032764a2aaSMatthew G. Knepley /*@C 1042764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 1052764a2aaSMatthew G. Knepley 1062764a2aaSMatthew G. Knepley Not Collective 1072764a2aaSMatthew G. Knepley 1082764a2aaSMatthew G. Knepley Input Parameter: 1092764a2aaSMatthew G. Knepley . prob - The PetscDS 1102764a2aaSMatthew G. Knepley 1112764a2aaSMatthew G. Knepley Output Parameter: 1122764a2aaSMatthew G. Knepley . name - The PetscDS type name 1132764a2aaSMatthew G. Knepley 1142764a2aaSMatthew G. Knepley Level: intermediate 1152764a2aaSMatthew G. Knepley 116f5f57ec0SBarry Smith Not available from Fortran 117f5f57ec0SBarry Smith 1182764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1192764a2aaSMatthew G. Knepley @*/ 1202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1212764a2aaSMatthew G. Knepley { 1222764a2aaSMatthew G. Knepley PetscFunctionBegin; 1232764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 124c959eef4SJed Brown PetscValidPointer(name, 2); 1259566063dSJacob Faibussowitsch PetscCall(PetscDSRegisterAll()); 1262764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1282764a2aaSMatthew G. Knepley } 1292764a2aaSMatthew G. Knepley 1305fedec97SMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS ds, PetscViewer viewer) 1317d8a60eaSMatthew G. Knepley { 1327d8a60eaSMatthew G. Knepley PetscViewerFormat format; 13397b6e6e8SMatthew G. Knepley const PetscScalar *constants; 1345fedec97SMatthew G. Knepley PetscInt Nf, numConstants, f; 1357d8a60eaSMatthew G. Knepley 1367d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1379566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 1389566063dSJacob Faibussowitsch PetscCall(PetscViewerGetFormat(viewer, &format)); 13963a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Discrete System with %" PetscInt_FMT " fields\n", Nf)); 1409566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 14163a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " cell total dim %" PetscInt_FMT " total comp %" PetscInt_FMT "\n", ds->totDim, ds->totComp)); 1429566063dSJacob Faibussowitsch if (ds->isCohesive) PetscCall(PetscViewerASCIIPrintf(viewer, " cohesive cell\n")); 1435fedec97SMatthew G. Knepley for (f = 0; f < Nf; ++f) { 14440967b3bSMatthew G. Knepley DSBoundary b; 1457d8a60eaSMatthew G. Knepley PetscObject obj; 1467d8a60eaSMatthew G. Knepley PetscClassId id; 147f35450b9SMatthew G. Knepley PetscQuadrature q; 1487d8a60eaSMatthew G. Knepley const char *name; 149f35450b9SMatthew G. Knepley PetscInt Nc, Nq, Nqc; 1507d8a60eaSMatthew G. Knepley 1519566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(ds, f, &obj)); 1529566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 1539566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName(obj, &name)); 1549566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>")); 1559566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 1567d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1579566063dSJacob Faibussowitsch PetscCall(PetscFEGetNumComponents((PetscFE) obj, &Nc)); 1589566063dSJacob Faibussowitsch PetscCall(PetscFEGetQuadrature((PetscFE) obj, &q)); 1599566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " FEM")); 1607d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1619566063dSJacob Faibussowitsch PetscCall(PetscFVGetNumComponents((PetscFV) obj, &Nc)); 1629566063dSJacob Faibussowitsch PetscCall(PetscFVGetQuadrature((PetscFV) obj, &q)); 1639566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " FVM")); 1647d8a60eaSMatthew G. Knepley } 16563a3b9bcSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %" PetscInt_FMT, f); 16663a3b9bcSJacob Faibussowitsch if (Nc > 1) PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT " components", Nc)); 16763a3b9bcSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT " component ", Nc)); 1689566063dSJacob Faibussowitsch if (ds->implicit[f]) PetscCall(PetscViewerASCIIPrintf(viewer, " (implicit)")); 1699566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " (explicit)")); 1703e60c2a6SMatthew G. Knepley if (q) { 1719566063dSJacob Faibussowitsch PetscCall(PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL)); 17263a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " (Nq %" PetscInt_FMT " Nqc %" PetscInt_FMT ")", Nq, Nqc)); 1733e60c2a6SMatthew G. Knepley } 17463a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " %" PetscInt_FMT "-jet", ds->jetDegree[f])); 1759566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 1769566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 1779566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 1789566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEView((PetscFE) obj, viewer)); 1799566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVView((PetscFV) obj, viewer)); 1809566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 18140967b3bSMatthew G. Knepley 1825fedec97SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 18306ad1575SMatthew G. Knepley char *name; 18440967b3bSMatthew G. Knepley PetscInt c, i; 18540967b3bSMatthew G. Knepley 18640967b3bSMatthew G. Knepley if (b->field != f) continue; 1879566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 1889566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->lname, DMBoundaryConditionTypes[b->type])); 18945480ffeSMatthew G. Knepley if (!b->Nc) { 1909566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " all components\n")); 19140967b3bSMatthew G. Knepley } else { 1929566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " components: ")); 1939566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 19445480ffeSMatthew G. Knepley for (c = 0; c < b->Nc; ++c) { 1959566063dSJacob Faibussowitsch if (c > 0) PetscCall(PetscViewerASCIIPrintf(viewer, ", ")); 19663a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT, b->comps[c])); 19740967b3bSMatthew G. Knepley } 1989566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 1999566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 20040967b3bSMatthew G. Knepley } 2019566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, " values: ")); 2029566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 20345480ffeSMatthew G. Knepley for (i = 0; i < b->Nv; ++i) { 2049566063dSJacob Faibussowitsch if (i > 0) PetscCall(PetscViewerASCIIPrintf(viewer, ", ")); 20563a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT, b->values[i])); 20640967b3bSMatthew G. Knepley } 2079566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "\n")); 2089566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 2098e0d8d9cSMatthew G. Knepley if (b->func) { 2109566063dSJacob Faibussowitsch PetscCall(PetscDLAddr(b->func, &name)); 2119566063dSJacob Faibussowitsch if (name) PetscCall(PetscViewerASCIIPrintf(viewer, " func: %s\n", name)); 2129566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " func: %p\n", b->func)); 2139566063dSJacob Faibussowitsch PetscCall(PetscFree(name)); 2148e0d8d9cSMatthew G. Knepley } 2158e0d8d9cSMatthew G. Knepley if (b->func_t) { 2169566063dSJacob Faibussowitsch PetscCall(PetscDLAddr(b->func_t, &name)); 2179566063dSJacob Faibussowitsch if (name) PetscCall(PetscViewerASCIIPrintf(viewer, " func_t: %s\n", name)); 2189566063dSJacob Faibussowitsch else PetscCall(PetscViewerASCIIPrintf(viewer, " func_t: %p\n", b->func_t)); 2199566063dSJacob Faibussowitsch PetscCall(PetscFree(name)); 2208e0d8d9cSMatthew G. Knepley } 2219566063dSJacob Faibussowitsch PetscCall(PetscWeakFormView(b->wf, viewer)); 2229566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 22340967b3bSMatthew G. Knepley } 2247d8a60eaSMatthew G. Knepley } 2259566063dSJacob Faibussowitsch PetscCall(PetscDSGetConstants(ds, &numConstants, &constants)); 22697b6e6e8SMatthew G. Knepley if (numConstants) { 22763a3b9bcSJacob Faibussowitsch PetscCall(PetscViewerASCIIPrintf(viewer, "%" PetscInt_FMT " constants\n", numConstants)); 2289566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPushTab(viewer)); 2299566063dSJacob Faibussowitsch for (f = 0; f < numConstants; ++f) PetscCall(PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]))); 2309566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 23197b6e6e8SMatthew G. Knepley } 2329566063dSJacob Faibussowitsch PetscCall(PetscWeakFormView(ds->wf, viewer)); 2339566063dSJacob Faibussowitsch PetscCall(PetscViewerASCIIPopTab(viewer)); 2347d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 2357d8a60eaSMatthew G. Knepley } 2367d8a60eaSMatthew G. Knepley 2372764a2aaSMatthew G. Knepley /*@C 238fe2efc57SMark PetscDSViewFromOptions - View from Options 239fe2efc57SMark 240fe2efc57SMark Collective on PetscDS 241fe2efc57SMark 242fe2efc57SMark Input Parameters: 243fe2efc57SMark + A - the PetscDS object 244736c3998SJose E. Roman . obj - Optional object 245736c3998SJose E. Roman - name - command line option 246fe2efc57SMark 247fe2efc57SMark Level: intermediate 248fe2efc57SMark .seealso: PetscDS, PetscDSView, PetscObjectViewFromOptions(), PetscDSCreate() 249fe2efc57SMark @*/ 250fe2efc57SMark PetscErrorCode PetscDSViewFromOptions(PetscDS A,PetscObject obj,const char name[]) 251fe2efc57SMark { 252fe2efc57SMark PetscFunctionBegin; 253fe2efc57SMark PetscValidHeaderSpecific(A,PETSCDS_CLASSID,1); 2549566063dSJacob Faibussowitsch PetscCall(PetscObjectViewFromOptions((PetscObject)A,obj,name)); 255fe2efc57SMark PetscFunctionReturn(0); 256fe2efc57SMark } 257fe2efc57SMark 258fe2efc57SMark /*@C 2592764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 2602764a2aaSMatthew G. Knepley 261d083f849SBarry Smith Collective on prob 2622764a2aaSMatthew G. Knepley 263d8d19677SJose E. Roman Input Parameters: 2642764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 2652764a2aaSMatthew G. Knepley - v - the viewer 2662764a2aaSMatthew G. Knepley 2672764a2aaSMatthew G. Knepley Level: developer 2682764a2aaSMatthew G. Knepley 2692764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 2702764a2aaSMatthew G. Knepley @*/ 2712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2722764a2aaSMatthew G. Knepley { 2737d8a60eaSMatthew G. Knepley PetscBool iascii; 2742764a2aaSMatthew G. Knepley 2752764a2aaSMatthew G. Knepley PetscFunctionBegin; 2762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2779566063dSJacob Faibussowitsch if (!v) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v)); 2787d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2799566063dSJacob Faibussowitsch PetscCall(PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii)); 2809566063dSJacob Faibussowitsch if (iascii) PetscCall(PetscDSView_Ascii(prob, v)); 2819566063dSJacob Faibussowitsch if (prob->ops->view) PetscCall((*prob->ops->view)(prob, v)); 2822764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2832764a2aaSMatthew G. Knepley } 2842764a2aaSMatthew G. Knepley 2852764a2aaSMatthew G. Knepley /*@ 2862764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2872764a2aaSMatthew G. Knepley 288d083f849SBarry Smith Collective on prob 2892764a2aaSMatthew G. Knepley 2902764a2aaSMatthew G. Knepley Input Parameter: 2912764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2922764a2aaSMatthew G. Knepley 2932764a2aaSMatthew G. Knepley Options Database: 294147403d9SBarry Smith + -petscds_type <type> - Set the DS type 295147403d9SBarry Smith . -petscds_view <view opt> - View the DS 296147403d9SBarry Smith . -petscds_jac_pre - Turn formation of a separate Jacobian preconditioner on or off 297147403d9SBarry Smith . -bc_<name> <ids> - Specify a list of label ids for a boundary condition 298147403d9SBarry Smith - -bc_<name>_comp <comps> - Specify a list of field components to constrain for a boundary condition 2992764a2aaSMatthew G. Knepley 3002764a2aaSMatthew G. Knepley Level: developer 3012764a2aaSMatthew G. Knepley 3022764a2aaSMatthew G. Knepley .seealso PetscDSView() 3032764a2aaSMatthew G. Knepley @*/ 3042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 3052764a2aaSMatthew G. Knepley { 306f1fd5e65SToby Isaac DSBoundary b; 3072764a2aaSMatthew G. Knepley const char *defaultType; 3082764a2aaSMatthew G. Knepley char name[256]; 3092764a2aaSMatthew G. Knepley PetscBool flg; 3102764a2aaSMatthew G. Knepley 3112764a2aaSMatthew G. Knepley PetscFunctionBegin; 3122764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3132764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3142764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3152764a2aaSMatthew G. Knepley } else { 3162764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3172764a2aaSMatthew G. Knepley } 3189566063dSJacob Faibussowitsch PetscCall(PetscDSRegisterAll()); 3192764a2aaSMatthew G. Knepley 320d0609cedSBarry Smith PetscObjectOptionsBegin((PetscObject) prob); 321f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 322f1fd5e65SToby Isaac char optname[1024]; 323f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 324f1fd5e65SToby Isaac PetscBool flg; 325f1fd5e65SToby Isaac 3269566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name)); 3279566063dSJacob Faibussowitsch PetscCall(PetscMemzero(ids, sizeof(ids))); 3289566063dSJacob Faibussowitsch PetscCall(PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg)); 329f1fd5e65SToby Isaac if (flg) { 33045480ffeSMatthew G. Knepley b->Nv = len; 3319566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 3329566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(len, &b->values)); 3339566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(b->values, ids, len)); 3349566063dSJacob Faibussowitsch PetscCall(PetscWeakFormRewriteKeys(b->wf, b->label, len, b->values)); 335f1fd5e65SToby Isaac } 336e7b0402cSSander Arens len = 1024; 3379566063dSJacob Faibussowitsch PetscCall(PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name)); 3389566063dSJacob Faibussowitsch PetscCall(PetscMemzero(ids, sizeof(ids))); 3399566063dSJacob Faibussowitsch PetscCall(PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg)); 340f1fd5e65SToby Isaac if (flg) { 34145480ffeSMatthew G. Knepley b->Nc = len; 3429566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 3439566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(len, &b->comps)); 3449566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(b->comps, ids, len)); 345f1fd5e65SToby Isaac } 346f1fd5e65SToby Isaac } 3479566063dSJacob Faibussowitsch PetscCall(PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg)); 3482764a2aaSMatthew G. Knepley if (flg) { 3499566063dSJacob Faibussowitsch PetscCall(PetscDSSetType(prob, name)); 3502764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3519566063dSJacob Faibussowitsch PetscCall(PetscDSSetType(prob, defaultType)); 3522764a2aaSMatthew G. Knepley } 3539566063dSJacob Faibussowitsch PetscCall(PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg)); 3549566063dSJacob Faibussowitsch if (prob->ops->setfromoptions) PetscCall((*prob->ops->setfromoptions)(prob)); 3552764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3569566063dSJacob Faibussowitsch PetscCall(PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob)); 357d0609cedSBarry Smith PetscOptionsEnd(); 3589566063dSJacob Faibussowitsch if (prob->Nf) PetscCall(PetscDSViewFromOptions(prob, NULL, "-petscds_view")); 3592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3602764a2aaSMatthew G. Knepley } 3612764a2aaSMatthew G. Knepley 3622764a2aaSMatthew G. Knepley /*@C 3632764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3642764a2aaSMatthew G. Knepley 365d083f849SBarry Smith Collective on prob 3662764a2aaSMatthew G. Knepley 3672764a2aaSMatthew G. Knepley Input Parameter: 3682764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3692764a2aaSMatthew G. Knepley 3702764a2aaSMatthew G. Knepley Level: developer 3712764a2aaSMatthew G. Knepley 3722764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3732764a2aaSMatthew G. Knepley @*/ 3742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3752764a2aaSMatthew G. Knepley { 3762764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 377f9244615SMatthew G. Knepley PetscBool hasH = PETSC_FALSE; 3784bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3792764a2aaSMatthew G. Knepley 3802764a2aaSMatthew G. Knepley PetscFunctionBegin; 3812764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3822764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3832764a2aaSMatthew G. Knepley /* Calculate sizes */ 3849566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(prob, &dim)); 3859566063dSJacob Faibussowitsch PetscCall(PetscDSGetCoordinateDimension(prob, &dimEmbed)); 386f744cafaSSander Arens prob->totDim = prob->totComp = 0; 3879566063dSJacob Faibussowitsch PetscCall(PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb)); 3889566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer)); 3899566063dSJacob 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])); 3909566063dSJacob Faibussowitsch PetscCall(PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf)); 3912764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3929de99aefSMatthew G. Knepley PetscObject obj; 3939de99aefSMatthew G. Knepley PetscClassId id; 394665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 3959de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3962764a2aaSMatthew G. Knepley 3979566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &obj)); 398f9244615SMatthew G. Knepley if (prob->jetDegree[f] > 1) hasH = PETSC_TRUE; 399665f567fSMatthew G. Knepley if (!obj) { 400665f567fSMatthew G. Knepley /* Empty mesh */ 401665f567fSMatthew G. Knepley Nb = Nc = 0; 402665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 403665f567fSMatthew G. Knepley } else { 4049566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 4059de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 4069de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 4079de99aefSMatthew G. Knepley 4089566063dSJacob Faibussowitsch PetscCall(PetscFEGetQuadrature(fe, &q)); 4099566063dSJacob Faibussowitsch PetscCall(PetscFEGetDimension(fe, &Nb)); 4109566063dSJacob Faibussowitsch PetscCall(PetscFEGetNumComponents(fe, &Nc)); 4119566063dSJacob Faibussowitsch PetscCall(PetscFEGetCellTabulation(fe, prob->jetDegree[f], &prob->T[f])); 4129566063dSJacob Faibussowitsch PetscCall(PetscFEGetFaceTabulation(fe, prob->jetDegree[f], &prob->Tf[f])); 4139de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4149de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4159de99aefSMatthew G. Knepley 4169566063dSJacob Faibussowitsch PetscCall(PetscFVGetQuadrature(fv, &q)); 4179566063dSJacob Faibussowitsch PetscCall(PetscFVGetNumComponents(fv, &Nc)); 4189c3cf19fSMatthew G. Knepley Nb = Nc; 4199566063dSJacob Faibussowitsch PetscCall(PetscFVGetCellTabulation(fv, &prob->T[f])); 4204d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 42163a3b9bcSJacob Faibussowitsch } else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %" PetscInt_FMT, f); 422665f567fSMatthew G. Knepley } 42347e57110SSander Arens prob->Nc[f] = Nc; 42447e57110SSander Arens prob->Nb[f] = Nb; 425194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 426194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 4279ee2af8cSMatthew G. Knepley prob->offCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[0][f]; 4289ee2af8cSMatthew G. Knepley prob->offDerCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[0][f]; 4299ee2af8cSMatthew G. Knepley prob->offCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc) + prob->offCohesive[0][f]; 4309ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc)*dimEmbed + prob->offDerCohesive[0][f]; 4319ee2af8cSMatthew G. Knepley prob->offCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[2][f]; 4329ee2af8cSMatthew G. Knepley prob->offDerCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[2][f]; 4339566063dSJacob Faibussowitsch if (q) PetscCall(PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL)); 4342764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4354bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4362764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4379c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4382764a2aaSMatthew G. Knepley prob->totComp += Nc; 4395fedec97SMatthew G. Knepley /* There are two faces for all fields on a cohesive cell, except for cohesive fields */ 4405fedec97SMatthew G. Knepley if (prob->isCohesive && !prob->cohesive[f]) prob->totDim += Nb; 4412764a2aaSMatthew G. Knepley } 4429ee2af8cSMatthew G. Knepley prob->offCohesive[1][Nf] = prob->offCohesive[0][Nf]; 4439ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][Nf] = prob->offDerCohesive[0][Nf]; 4442764a2aaSMatthew G. Knepley /* Allocate works space */ 4455fedec97SMatthew G. Knepley NsMax = 2; /* A non-cohesive discretizations can be used on a cohesive cell, so we need this extra workspace for all DS */ 4469566063dSJacob 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)); 4479566063dSJacob Faibussowitsch PetscCall(PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal)); 448d0609cedSBarry Smith PetscCall(PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 44927f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 450d0609cedSBarry Smith NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3)); 4519566063dSJacob Faibussowitsch if (prob->ops->setup) PetscCall((*prob->ops->setup)(prob)); 4522764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4532764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4542764a2aaSMatthew G. Knepley } 4552764a2aaSMatthew G. Knepley 4562764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4572764a2aaSMatthew G. Knepley { 4582764a2aaSMatthew G. Knepley PetscFunctionBegin; 4599566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->Nc,prob->Nb)); 4609566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->off,prob->offDer)); 4619566063dSJacob Faibussowitsch PetscCall(PetscFree6(prob->offCohesive[0],prob->offCohesive[1],prob->offCohesive[2],prob->offDerCohesive[0],prob->offDerCohesive[1],prob->offDerCohesive[2])); 4629566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->T,prob->Tf)); 4639566063dSJacob Faibussowitsch PetscCall(PetscFree3(prob->u,prob->u_t,prob->u_x)); 4649566063dSJacob Faibussowitsch PetscCall(PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal)); 4659566063dSJacob Faibussowitsch PetscCall(PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3)); 4662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4672764a2aaSMatthew G. Knepley } 4682764a2aaSMatthew G. Knepley 4692764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4702764a2aaSMatthew G. Knepley { 471f744cafaSSander Arens PetscObject *tmpd; 47234aa8a36SMatthew G. Knepley PetscBool *tmpi; 473f9244615SMatthew G. Knepley PetscInt *tmpk; 4745fedec97SMatthew G. Knepley PetscBool *tmpc; 4756528b96dSMatthew G. Knepley PetscPointFunc *tmpup; 476f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 477f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4780c2f2876SMatthew G. Knepley void **tmpctx; 47934aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4802764a2aaSMatthew G. Knepley 4812764a2aaSMatthew G. Knepley PetscFunctionBegin; 4822764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4832764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4849566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyStructs_Static(prob)); 4859566063dSJacob Faibussowitsch PetscCall(PetscMalloc4(NfNew, &tmpd, NfNew, &tmpi, NfNew, &tmpc, NfNew, &tmpk)); 4865fedec97SMatthew 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];} 4875fedec97SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE, tmpc[f] = PETSC_FALSE; tmpk[f] = 1;} 4889566063dSJacob Faibussowitsch PetscCall(PetscFree4(prob->disc, prob->implicit, prob->cohesive, prob->jetDegree)); 4899566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(prob->wf, NfNew)); 4902764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4912764a2aaSMatthew G. Knepley prob->disc = tmpd; 492249df284SMatthew G. Knepley prob->implicit = tmpi; 4935fedec97SMatthew G. Knepley prob->cohesive = tmpc; 494f9244615SMatthew G. Knepley prob->jetDegree = tmpk; 4959566063dSJacob Faibussowitsch PetscCall(PetscCalloc2(NfNew, &tmpup, NfNew, &tmpctx)); 49632d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4970c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 49832d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4990c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 5009566063dSJacob Faibussowitsch PetscCall(PetscFree2(prob->update, prob->ctx)); 50132d2bbc9SMatthew G. Knepley prob->update = tmpup; 5020c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 5039566063dSJacob Faibussowitsch PetscCall(PetscCalloc4(NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t)); 504c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50595cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 506f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 507f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 508c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 50995cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 510f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 511f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 5129566063dSJacob Faibussowitsch PetscCall(PetscFree4(prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t)); 513c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51495cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 515f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 516f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5182764a2aaSMatthew G. Knepley } 5192764a2aaSMatthew G. Knepley 5202764a2aaSMatthew G. Knepley /*@ 5212764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5222764a2aaSMatthew G. Knepley 523d083f849SBarry Smith Collective on prob 5242764a2aaSMatthew G. Knepley 5252764a2aaSMatthew G. Knepley Input Parameter: 5262764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5272764a2aaSMatthew G. Knepley 5282764a2aaSMatthew G. Knepley Level: developer 5292764a2aaSMatthew G. Knepley 5302764a2aaSMatthew G. Knepley .seealso PetscDSView() 5312764a2aaSMatthew G. Knepley @*/ 5326528b96dSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *ds) 5332764a2aaSMatthew G. Knepley { 5342764a2aaSMatthew G. Knepley PetscInt f; 5352764a2aaSMatthew G. Knepley 5362764a2aaSMatthew G. Knepley PetscFunctionBegin; 5376528b96dSMatthew G. Knepley if (!*ds) PetscFunctionReturn(0); 5386528b96dSMatthew G. Knepley PetscValidHeaderSpecific((*ds), PETSCDS_CLASSID, 1); 5392764a2aaSMatthew G. Knepley 5406528b96dSMatthew G. Knepley if (--((PetscObject)(*ds))->refct > 0) {*ds = NULL; PetscFunctionReturn(0);} 5416528b96dSMatthew G. Knepley ((PetscObject) (*ds))->refct = 0; 5426528b96dSMatthew G. Knepley if ((*ds)->subprobs) { 543df3a45bdSMatthew G. Knepley PetscInt dim, d; 544df3a45bdSMatthew G. Knepley 5459566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(*ds, &dim)); 5469566063dSJacob Faibussowitsch for (d = 0; d < dim; ++d) PetscCall(PetscDSDestroy(&(*ds)->subprobs[d])); 547df3a45bdSMatthew G. Knepley } 5489566063dSJacob Faibussowitsch PetscCall(PetscFree((*ds)->subprobs)); 5499566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyStructs_Static(*ds)); 5506528b96dSMatthew G. Knepley for (f = 0; f < (*ds)->Nf; ++f) { 5519566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference((*ds)->disc[f])); 5522764a2aaSMatthew G. Knepley } 5539566063dSJacob Faibussowitsch PetscCall(PetscFree4((*ds)->disc, (*ds)->implicit, (*ds)->cohesive, (*ds)->jetDegree)); 5549566063dSJacob Faibussowitsch PetscCall(PetscWeakFormDestroy(&(*ds)->wf)); 5559566063dSJacob Faibussowitsch PetscCall(PetscFree2((*ds)->update,(*ds)->ctx)); 5569566063dSJacob Faibussowitsch PetscCall(PetscFree4((*ds)->exactSol,(*ds)->exactCtx,(*ds)->exactSol_t,(*ds)->exactCtx_t)); 5579566063dSJacob Faibussowitsch if ((*ds)->ops->destroy) PetscCall((*(*ds)->ops->destroy)(*ds)); 5589566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyBoundary(*ds)); 5599566063dSJacob Faibussowitsch PetscCall(PetscFree((*ds)->constants)); 5609566063dSJacob Faibussowitsch PetscCall(PetscHeaderDestroy(ds)); 5612764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5622764a2aaSMatthew G. Knepley } 5632764a2aaSMatthew G. Knepley 5642764a2aaSMatthew G. Knepley /*@ 5652764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5662764a2aaSMatthew G. Knepley 567d083f849SBarry Smith Collective 5682764a2aaSMatthew G. Knepley 5692764a2aaSMatthew G. Knepley Input Parameter: 5702764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5712764a2aaSMatthew G. Knepley 5722764a2aaSMatthew G. Knepley Output Parameter: 5736528b96dSMatthew G. Knepley . ds - The PetscDS object 5742764a2aaSMatthew G. Knepley 5752764a2aaSMatthew G. Knepley Level: beginner 5762764a2aaSMatthew G. Knepley 5772764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5782764a2aaSMatthew G. Knepley @*/ 5796528b96dSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *ds) 5802764a2aaSMatthew G. Knepley { 5812764a2aaSMatthew G. Knepley PetscDS p; 5822764a2aaSMatthew G. Knepley 5832764a2aaSMatthew G. Knepley PetscFunctionBegin; 5846528b96dSMatthew G. Knepley PetscValidPointer(ds, 2); 5856528b96dSMatthew G. Knepley *ds = NULL; 5869566063dSJacob Faibussowitsch PetscCall(PetscDSInitializePackage()); 5872764a2aaSMatthew G. Knepley 5889566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView)); 5892764a2aaSMatthew G. Knepley 5902764a2aaSMatthew G. Knepley p->Nf = 0; 5912764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 59297b6e6e8SMatthew G. Knepley p->numConstants = 0; 59397b6e6e8SMatthew G. Knepley p->constants = NULL; 594a859676bSMatthew G. Knepley p->dimEmbed = -1; 59555c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5969566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(comm, &p->wf)); 5972764a2aaSMatthew G. Knepley 5986528b96dSMatthew G. Knepley *ds = p; 5992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6002764a2aaSMatthew G. Knepley } 6012764a2aaSMatthew G. Knepley 602bc4ae4beSMatthew G. Knepley /*@ 603bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 604bc4ae4beSMatthew G. Knepley 605bc4ae4beSMatthew G. Knepley Not collective 606bc4ae4beSMatthew G. Knepley 607bc4ae4beSMatthew G. Knepley Input Parameter: 608bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 609bc4ae4beSMatthew G. Knepley 610bc4ae4beSMatthew G. Knepley Output Parameter: 611bc4ae4beSMatthew G. Knepley . Nf - The number of fields 612bc4ae4beSMatthew G. Knepley 613bc4ae4beSMatthew G. Knepley Level: beginner 614bc4ae4beSMatthew G. Knepley 615bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 616bc4ae4beSMatthew G. Knepley @*/ 6172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6182764a2aaSMatthew G. Knepley { 6192764a2aaSMatthew G. Knepley PetscFunctionBegin; 6202764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 621dadcf809SJacob Faibussowitsch PetscValidIntPointer(Nf, 2); 6222764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6242764a2aaSMatthew G. Knepley } 6252764a2aaSMatthew G. Knepley 626bc4ae4beSMatthew G. Knepley /*@ 627a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 628bc4ae4beSMatthew G. Knepley 629bc4ae4beSMatthew G. Knepley Not collective 630bc4ae4beSMatthew G. Knepley 631bc4ae4beSMatthew G. Knepley Input Parameter: 632bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 633bc4ae4beSMatthew G. Knepley 634bc4ae4beSMatthew G. Knepley Output Parameter: 635bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 636bc4ae4beSMatthew G. Knepley 637bc4ae4beSMatthew G. Knepley Level: beginner 638bc4ae4beSMatthew G. Knepley 639a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 640bc4ae4beSMatthew G. Knepley @*/ 6412764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6422764a2aaSMatthew G. Knepley { 6432764a2aaSMatthew G. Knepley PetscFunctionBegin; 6442764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 645dadcf809SJacob Faibussowitsch PetscValidIntPointer(dim, 2); 6462764a2aaSMatthew G. Knepley *dim = 0; 6479de99aefSMatthew G. Knepley if (prob->Nf) { 6489de99aefSMatthew G. Knepley PetscObject obj; 6499de99aefSMatthew G. Knepley PetscClassId id; 6509de99aefSMatthew G. Knepley 6519566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, 0, &obj)); 652665f567fSMatthew G. Knepley if (obj) { 6539566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 6549566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetSpatialDimension((PetscFE) obj, dim)); 6559566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVGetSpatialDimension((PetscFV) obj, dim)); 65698921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6579de99aefSMatthew G. Knepley } 658665f567fSMatthew G. Knepley } 6592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6602764a2aaSMatthew G. Knepley } 6612764a2aaSMatthew G. Knepley 662bc4ae4beSMatthew G. Knepley /*@ 663a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 664a859676bSMatthew G. Knepley 665a859676bSMatthew G. Knepley Not collective 666a859676bSMatthew G. Knepley 667a859676bSMatthew G. Knepley Input Parameter: 668a859676bSMatthew G. Knepley . prob - The PetscDS object 669a859676bSMatthew G. Knepley 670a859676bSMatthew G. Knepley Output Parameter: 671a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 672a859676bSMatthew G. Knepley 673a859676bSMatthew G. Knepley Level: beginner 674a859676bSMatthew G. Knepley 675a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 676a859676bSMatthew G. Knepley @*/ 677a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 678a859676bSMatthew G. Knepley { 679a859676bSMatthew G. Knepley PetscFunctionBegin; 680a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 681dadcf809SJacob Faibussowitsch PetscValidIntPointer(dimEmbed, 2); 68208401ef6SPierre Jolivet PetscCheck(prob->dimEmbed >= 0,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 683a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 684a859676bSMatthew G. Knepley PetscFunctionReturn(0); 685a859676bSMatthew G. Knepley } 686a859676bSMatthew G. Knepley 687a859676bSMatthew G. Knepley /*@ 688a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 689a859676bSMatthew G. Knepley 690d083f849SBarry Smith Logically collective on prob 691a859676bSMatthew G. Knepley 692a859676bSMatthew G. Knepley Input Parameters: 693a859676bSMatthew G. Knepley + prob - The PetscDS object 694a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 695a859676bSMatthew G. Knepley 696a859676bSMatthew G. Knepley Level: beginner 697a859676bSMatthew G. Knepley 698a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 699a859676bSMatthew G. Knepley @*/ 700a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 701a859676bSMatthew G. Knepley { 702a859676bSMatthew G. Knepley PetscFunctionBegin; 703a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 70463a3b9bcSJacob Faibussowitsch PetscCheck(dimEmbed >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %" PetscInt_FMT, dimEmbed); 705a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 706a859676bSMatthew G. Knepley PetscFunctionReturn(0); 707a859676bSMatthew G. Knepley } 708a859676bSMatthew G. Knepley 709a859676bSMatthew G. Knepley /*@ 7105fedec97SMatthew G. Knepley PetscDSIsCohesive - Returns the flag indicating that this DS is for a cohesive cell 7118edf6225SMatthew G. Knepley 7128edf6225SMatthew G. Knepley Not collective 7138edf6225SMatthew G. Knepley 7148edf6225SMatthew G. Knepley Input Parameter: 7155fedec97SMatthew G. Knepley . ds - The PetscDS object 7168edf6225SMatthew G. Knepley 7178edf6225SMatthew G. Knepley Output Parameter: 7185fedec97SMatthew G. Knepley . isCohesive - The flag 7198edf6225SMatthew G. Knepley 7208edf6225SMatthew G. Knepley Level: developer 7218edf6225SMatthew G. Knepley 7225fedec97SMatthew G. Knepley .seealso: PetscDSGetNumCohesive(), PetscDSGetCohesive(), PetscDSSetCohesive(), PetscDSCreate() 7238edf6225SMatthew G. Knepley @*/ 7245fedec97SMatthew G. Knepley PetscErrorCode PetscDSIsCohesive(PetscDS ds, PetscBool *isCohesive) 7258edf6225SMatthew G. Knepley { 7268edf6225SMatthew G. Knepley PetscFunctionBegin; 7275fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 728dadcf809SJacob Faibussowitsch PetscValidBoolPointer(isCohesive, 2); 7295fedec97SMatthew G. Knepley *isCohesive = ds->isCohesive; 7308edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7318edf6225SMatthew G. Knepley } 7328edf6225SMatthew G. Knepley 7338edf6225SMatthew G. Knepley /*@ 7345fedec97SMatthew G. Knepley PetscDSGetNumCohesive - Returns the numer of cohesive fields, meaning those defined on the interior of a cohesive cell 7355fedec97SMatthew G. Knepley 7365fedec97SMatthew G. Knepley Not collective 7375fedec97SMatthew G. Knepley 7385fedec97SMatthew G. Knepley Input Parameter: 7395fedec97SMatthew G. Knepley . ds - The PetscDS object 7405fedec97SMatthew G. Knepley 7415fedec97SMatthew G. Knepley Output Parameter: 7425fedec97SMatthew G. Knepley . numCohesive - The number of cohesive fields 7435fedec97SMatthew G. Knepley 7445fedec97SMatthew G. Knepley Level: developer 7455fedec97SMatthew G. Knepley 7465fedec97SMatthew G. Knepley .seealso: PetscDSSetCohesive(), PetscDSCreate() 7475fedec97SMatthew G. Knepley @*/ 7485fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetNumCohesive(PetscDS ds, PetscInt *numCohesive) 7495fedec97SMatthew G. Knepley { 7505fedec97SMatthew G. Knepley PetscInt f; 7515fedec97SMatthew G. Knepley 7525fedec97SMatthew G. Knepley PetscFunctionBegin; 7535fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 754dadcf809SJacob Faibussowitsch PetscValidIntPointer(numCohesive, 2); 7555fedec97SMatthew G. Knepley *numCohesive = 0; 7565fedec97SMatthew G. Knepley for (f = 0; f < ds->Nf; ++f) *numCohesive += ds->cohesive[f] ? 1 : 0; 7575fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7585fedec97SMatthew G. Knepley } 7595fedec97SMatthew G. Knepley 7605fedec97SMatthew G. Knepley /*@ 7615fedec97SMatthew G. Knepley PetscDSGetCohesive - Returns the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7625fedec97SMatthew G. Knepley 7635fedec97SMatthew G. Knepley Not collective 7645fedec97SMatthew G. Knepley 765f1a722f8SMatthew G. Knepley Input Parameters: 7665fedec97SMatthew G. Knepley + ds - The PetscDS object 7675fedec97SMatthew G. Knepley - f - The field index 7685fedec97SMatthew G. Knepley 7695fedec97SMatthew G. Knepley Output Parameter: 7705fedec97SMatthew G. Knepley . isCohesive - The flag 7715fedec97SMatthew G. Knepley 7725fedec97SMatthew G. Knepley Level: developer 7735fedec97SMatthew G. Knepley 7745fedec97SMatthew G. Knepley .seealso: PetscDSSetCohesive(), PetscDSIsCohesive(), PetscDSCreate() 7755fedec97SMatthew G. Knepley @*/ 7765fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetCohesive(PetscDS ds, PetscInt f, PetscBool *isCohesive) 7775fedec97SMatthew G. Knepley { 7785fedec97SMatthew G. Knepley PetscFunctionBegin; 7795fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 780dadcf809SJacob Faibussowitsch PetscValidBoolPointer(isCohesive, 3); 78163a3b9bcSJacob 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); 7825fedec97SMatthew G. Knepley *isCohesive = ds->cohesive[f]; 7835fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7845fedec97SMatthew G. Knepley } 7855fedec97SMatthew G. Knepley 7865fedec97SMatthew G. Knepley /*@ 7875fedec97SMatthew G. Knepley PetscDSSetCohesive - Set the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7888edf6225SMatthew G. Knepley 7898edf6225SMatthew G. Knepley Not collective 7908edf6225SMatthew G. Knepley 7918edf6225SMatthew G. Knepley Input Parameters: 7925fedec97SMatthew G. Knepley + ds - The PetscDS object 7935fedec97SMatthew G. Knepley . f - The field index 7945fedec97SMatthew G. Knepley - isCohesive - The flag for a cohesive field 7958edf6225SMatthew G. Knepley 7968edf6225SMatthew G. Knepley Level: developer 7978edf6225SMatthew G. Knepley 7985fedec97SMatthew G. Knepley .seealso: PetscDSGetCohesive(), PetscDSIsCohesive(), PetscDSCreate() 7998edf6225SMatthew G. Knepley @*/ 8005fedec97SMatthew G. Knepley PetscErrorCode PetscDSSetCohesive(PetscDS ds, PetscInt f, PetscBool isCohesive) 8018edf6225SMatthew G. Knepley { 8025fedec97SMatthew G. Knepley PetscInt i; 8035fedec97SMatthew G. Knepley 8048edf6225SMatthew G. Knepley PetscFunctionBegin; 8055fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 80663a3b9bcSJacob 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); 8075fedec97SMatthew G. Knepley ds->cohesive[f] = isCohesive; 8085fedec97SMatthew G. Knepley ds->isCohesive = PETSC_FALSE; 8095fedec97SMatthew G. Knepley for (i = 0; i < ds->Nf; ++i) ds->isCohesive = ds->isCohesive || ds->cohesive[f] ? PETSC_TRUE : PETSC_FALSE; 8108edf6225SMatthew G. Knepley PetscFunctionReturn(0); 8118edf6225SMatthew G. Knepley } 8128edf6225SMatthew G. Knepley 8138edf6225SMatthew G. Knepley /*@ 814bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 815bc4ae4beSMatthew G. Knepley 816bc4ae4beSMatthew G. Knepley Not collective 817bc4ae4beSMatthew G. Knepley 818bc4ae4beSMatthew G. Knepley Input Parameter: 819bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 820bc4ae4beSMatthew G. Knepley 821bc4ae4beSMatthew G. Knepley Output Parameter: 822bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 823bc4ae4beSMatthew G. Knepley 824bc4ae4beSMatthew G. Knepley Level: beginner 825bc4ae4beSMatthew G. Knepley 826bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 827bc4ae4beSMatthew G. Knepley @*/ 8282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 8292764a2aaSMatthew G. Knepley { 8302764a2aaSMatthew G. Knepley PetscFunctionBegin; 8312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8329566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 833dadcf809SJacob Faibussowitsch PetscValidIntPointer(dim, 2); 8342764a2aaSMatthew G. Knepley *dim = prob->totDim; 8352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8362764a2aaSMatthew G. Knepley } 8372764a2aaSMatthew G. Knepley 838bc4ae4beSMatthew G. Knepley /*@ 839bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 840bc4ae4beSMatthew G. Knepley 841bc4ae4beSMatthew G. Knepley Not collective 842bc4ae4beSMatthew G. Knepley 843bc4ae4beSMatthew G. Knepley Input Parameter: 844bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 845bc4ae4beSMatthew G. Knepley 846bc4ae4beSMatthew G. Knepley Output Parameter: 847bc4ae4beSMatthew G. Knepley . dim - The total number of components 848bc4ae4beSMatthew G. Knepley 849bc4ae4beSMatthew G. Knepley Level: beginner 850bc4ae4beSMatthew G. Knepley 851bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 852bc4ae4beSMatthew G. Knepley @*/ 8532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8542764a2aaSMatthew G. Knepley { 8552764a2aaSMatthew G. Knepley PetscFunctionBegin; 8562764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8579566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 858dadcf809SJacob Faibussowitsch PetscValidIntPointer(Nc, 2); 8592764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8602764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8612764a2aaSMatthew G. Knepley } 8622764a2aaSMatthew G. Knepley 863bc4ae4beSMatthew G. Knepley /*@ 864bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 865bc4ae4beSMatthew G. Knepley 866bc4ae4beSMatthew G. Knepley Not collective 867bc4ae4beSMatthew G. Knepley 868bc4ae4beSMatthew G. Knepley Input Parameters: 869bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 870bc4ae4beSMatthew G. Knepley - f - The field number 871bc4ae4beSMatthew G. Knepley 872bc4ae4beSMatthew G. Knepley Output Parameter: 873bc4ae4beSMatthew G. Knepley . disc - The discretization object 874bc4ae4beSMatthew G. Knepley 875bc4ae4beSMatthew G. Knepley Level: beginner 876bc4ae4beSMatthew G. Knepley 877f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 878bc4ae4beSMatthew G. Knepley @*/ 8792764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8802764a2aaSMatthew G. Knepley { 8816528b96dSMatthew G. Knepley PetscFunctionBeginHot; 8822764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8832764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 88463a3b9bcSJacob 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); 8852764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8862764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8872764a2aaSMatthew G. Knepley } 8882764a2aaSMatthew G. Knepley 889bc4ae4beSMatthew G. Knepley /*@ 890bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 891bc4ae4beSMatthew G. Knepley 892bc4ae4beSMatthew G. Knepley Not collective 893bc4ae4beSMatthew G. Knepley 894bc4ae4beSMatthew G. Knepley Input Parameters: 895bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 896bc4ae4beSMatthew G. Knepley . f - The field number 897bc4ae4beSMatthew G. Knepley - disc - The discretization object 898bc4ae4beSMatthew G. Knepley 899bc4ae4beSMatthew G. Knepley Level: beginner 900bc4ae4beSMatthew G. Knepley 901bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 902bc4ae4beSMatthew G. Knepley @*/ 9032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 9042764a2aaSMatthew G. Knepley { 9052764a2aaSMatthew G. Knepley PetscFunctionBegin; 9062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 907665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 90863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 9099566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 9109566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference(prob->disc[f])); 9112764a2aaSMatthew G. Knepley prob->disc[f] = disc; 9129566063dSJacob Faibussowitsch PetscCall(PetscObjectReference(disc)); 913665f567fSMatthew G. Knepley if (disc) { 914249df284SMatthew G. Knepley PetscClassId id; 915249df284SMatthew G. Knepley 9169566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(disc, &id)); 9171cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 9189566063dSJacob Faibussowitsch PetscCall(PetscDSSetImplicit(prob, f, PETSC_TRUE)); 9191cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 9209566063dSJacob Faibussowitsch PetscCall(PetscDSSetImplicit(prob, f, PETSC_FALSE)); 921a6cbbb48SMatthew G. Knepley } 9229566063dSJacob Faibussowitsch PetscCall(PetscDSSetJetDegree(prob, f, 1)); 923249df284SMatthew G. Knepley } 9242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9252764a2aaSMatthew G. Knepley } 9262764a2aaSMatthew G. Knepley 927bc4ae4beSMatthew G. Knepley /*@ 9286528b96dSMatthew G. Knepley PetscDSGetWeakForm - Returns the weak form object 9296528b96dSMatthew G. Knepley 9306528b96dSMatthew G. Knepley Not collective 9316528b96dSMatthew G. Knepley 9326528b96dSMatthew G. Knepley Input Parameter: 9336528b96dSMatthew G. Knepley . ds - The PetscDS object 9346528b96dSMatthew G. Knepley 9356528b96dSMatthew G. Knepley Output Parameter: 9366528b96dSMatthew G. Knepley . wf - The weak form object 9376528b96dSMatthew G. Knepley 9386528b96dSMatthew G. Knepley Level: beginner 9396528b96dSMatthew G. Knepley 9406528b96dSMatthew G. Knepley .seealso: PetscDSSetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9416528b96dSMatthew G. Knepley @*/ 9426528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetWeakForm(PetscDS ds, PetscWeakForm *wf) 9436528b96dSMatthew G. Knepley { 9446528b96dSMatthew G. Knepley PetscFunctionBegin; 9456528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9466528b96dSMatthew G. Knepley PetscValidPointer(wf, 2); 9476528b96dSMatthew G. Knepley *wf = ds->wf; 9486528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9496528b96dSMatthew G. Knepley } 9506528b96dSMatthew G. Knepley 9516528b96dSMatthew G. Knepley /*@ 9526528b96dSMatthew G. Knepley PetscDSSetWeakForm - Sets the weak form object 9536528b96dSMatthew G. Knepley 9546528b96dSMatthew G. Knepley Not collective 9556528b96dSMatthew G. Knepley 9566528b96dSMatthew G. Knepley Input Parameters: 9576528b96dSMatthew G. Knepley + ds - The PetscDS object 9586528b96dSMatthew G. Knepley - wf - The weak form object 9596528b96dSMatthew G. Knepley 9606528b96dSMatthew G. Knepley Level: beginner 9616528b96dSMatthew G. Knepley 9626528b96dSMatthew G. Knepley .seealso: PetscDSGetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9636528b96dSMatthew G. Knepley @*/ 9646528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetWeakForm(PetscDS ds, PetscWeakForm wf) 9656528b96dSMatthew G. Knepley { 9666528b96dSMatthew G. Knepley PetscFunctionBegin; 9676528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9686528b96dSMatthew G. Knepley PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 2); 9699566063dSJacob Faibussowitsch PetscCall(PetscObjectDereference((PetscObject) ds->wf)); 9706528b96dSMatthew G. Knepley ds->wf = wf; 9719566063dSJacob Faibussowitsch PetscCall(PetscObjectReference((PetscObject) wf)); 9729566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(wf, ds->Nf)); 9736528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9746528b96dSMatthew G. Knepley } 9756528b96dSMatthew G. Knepley 9766528b96dSMatthew G. Knepley /*@ 977bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 978bc4ae4beSMatthew G. Knepley 979bc4ae4beSMatthew G. Knepley Not collective 980bc4ae4beSMatthew G. Knepley 981bc4ae4beSMatthew G. Knepley Input Parameters: 982bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 983bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 984bc4ae4beSMatthew G. Knepley 985bc4ae4beSMatthew G. Knepley Level: beginner 986bc4ae4beSMatthew G. Knepley 987bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 988bc4ae4beSMatthew G. Knepley @*/ 9892764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9902764a2aaSMatthew G. Knepley { 9912764a2aaSMatthew G. Knepley PetscFunctionBegin; 9929566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(prob, prob->Nf, disc)); 9932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9942764a2aaSMatthew G. Knepley } 9952764a2aaSMatthew G. Knepley 996249df284SMatthew G. Knepley /*@ 997083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 998083401c6SMatthew G. Knepley 999083401c6SMatthew G. Knepley Not collective 1000083401c6SMatthew G. Knepley 1001083401c6SMatthew G. Knepley Input Parameter: 1002083401c6SMatthew G. Knepley . prob - The PetscDS object 1003083401c6SMatthew G. Knepley 1004083401c6SMatthew G. Knepley Output Parameter: 1005083401c6SMatthew G. Knepley . q - The quadrature object 1006083401c6SMatthew G. Knepley 1007083401c6SMatthew G. Knepley Level: intermediate 1008083401c6SMatthew G. Knepley 1009083401c6SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1010083401c6SMatthew G. Knepley @*/ 1011083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 1012083401c6SMatthew G. Knepley { 1013083401c6SMatthew G. Knepley PetscObject obj; 1014083401c6SMatthew G. Knepley PetscClassId id; 1015083401c6SMatthew G. Knepley 1016083401c6SMatthew G. Knepley PetscFunctionBegin; 1017083401c6SMatthew G. Knepley *q = NULL; 1018083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 10199566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, 0, &obj)); 10209566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 10219566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetQuadrature((PetscFE) obj, q)); 10229566063dSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) PetscCall(PetscFVGetQuadrature((PetscFV) obj, q)); 102398921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 1024083401c6SMatthew G. Knepley PetscFunctionReturn(0); 1025083401c6SMatthew G. Knepley } 1026083401c6SMatthew G. Knepley 1027083401c6SMatthew G. Knepley /*@ 1028249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 1029249df284SMatthew G. Knepley 1030249df284SMatthew G. Knepley Not collective 1031249df284SMatthew G. Knepley 1032249df284SMatthew G. Knepley Input Parameters: 1033249df284SMatthew G. Knepley + prob - The PetscDS object 1034249df284SMatthew G. Knepley - f - The field number 1035249df284SMatthew G. Knepley 1036249df284SMatthew G. Knepley Output Parameter: 1037249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 1038249df284SMatthew G. Knepley 1039249df284SMatthew G. Knepley Level: developer 1040249df284SMatthew G. Knepley 1041f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1042249df284SMatthew G. Knepley @*/ 1043249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 1044249df284SMatthew G. Knepley { 1045249df284SMatthew G. Knepley PetscFunctionBegin; 1046249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1047dadcf809SJacob Faibussowitsch PetscValidBoolPointer(implicit, 3); 104863a3b9bcSJacob 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); 1049249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 1050249df284SMatthew G. Knepley PetscFunctionReturn(0); 1051249df284SMatthew G. Knepley } 1052249df284SMatthew G. Knepley 1053249df284SMatthew G. Knepley /*@ 1054249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 1055249df284SMatthew G. Knepley 1056249df284SMatthew G. Knepley Not collective 1057249df284SMatthew G. Knepley 1058249df284SMatthew G. Knepley Input Parameters: 1059249df284SMatthew G. Knepley + prob - The PetscDS object 1060249df284SMatthew G. Knepley . f - The field number 1061249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 1062249df284SMatthew G. Knepley 1063249df284SMatthew G. Knepley Level: developer 1064249df284SMatthew G. Knepley 1065f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1066249df284SMatthew G. Knepley @*/ 1067249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 1068249df284SMatthew G. Knepley { 1069249df284SMatthew G. Knepley PetscFunctionBegin; 1070249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 107163a3b9bcSJacob 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); 1072249df284SMatthew G. Knepley prob->implicit[f] = implicit; 1073249df284SMatthew G. Knepley PetscFunctionReturn(0); 1074249df284SMatthew G. Knepley } 1075249df284SMatthew G. Knepley 1076f9244615SMatthew G. Knepley /*@ 1077f9244615SMatthew G. Knepley PetscDSGetJetDegree - Returns the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1078f9244615SMatthew G. Knepley 1079f9244615SMatthew G. Knepley Not collective 1080f9244615SMatthew G. Knepley 1081f9244615SMatthew G. Knepley Input Parameters: 1082f9244615SMatthew G. Knepley + ds - The PetscDS object 1083f9244615SMatthew G. Knepley - f - The field number 1084f9244615SMatthew G. Knepley 1085f9244615SMatthew G. Knepley Output Parameter: 1086f9244615SMatthew G. Knepley . k - The highest derivative we need to tabulate 1087f9244615SMatthew G. Knepley 1088f9244615SMatthew G. Knepley Level: developer 1089f9244615SMatthew G. Knepley 1090f9244615SMatthew G. Knepley .seealso: PetscDSSetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1091f9244615SMatthew G. Knepley @*/ 1092f9244615SMatthew G. Knepley PetscErrorCode PetscDSGetJetDegree(PetscDS ds, PetscInt f, PetscInt *k) 1093f9244615SMatthew G. Knepley { 1094f9244615SMatthew G. Knepley PetscFunctionBegin; 1095f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1096dadcf809SJacob Faibussowitsch PetscValidIntPointer(k, 3); 109763a3b9bcSJacob 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); 1098f9244615SMatthew G. Knepley *k = ds->jetDegree[f]; 1099f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1100f9244615SMatthew G. Knepley } 1101f9244615SMatthew G. Knepley 1102f9244615SMatthew G. Knepley /*@ 1103f9244615SMatthew G. Knepley PetscDSSetJetDegree - Set the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1104f9244615SMatthew G. Knepley 1105f9244615SMatthew G. Knepley Not collective 1106f9244615SMatthew G. Knepley 1107f9244615SMatthew G. Knepley Input Parameters: 1108f9244615SMatthew G. Knepley + ds - The PetscDS object 1109f9244615SMatthew G. Knepley . f - The field number 1110f9244615SMatthew G. Knepley - k - The highest derivative we need to tabulate 1111f9244615SMatthew G. Knepley 1112f9244615SMatthew G. Knepley Level: developer 1113f9244615SMatthew G. Knepley 1114f9244615SMatthew G. Knepley .seealso: PetscDSGetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1115f9244615SMatthew G. Knepley @*/ 1116f9244615SMatthew G. Knepley PetscErrorCode PetscDSSetJetDegree(PetscDS ds, PetscInt f, PetscInt k) 1117f9244615SMatthew G. Knepley { 1118f9244615SMatthew G. Knepley PetscFunctionBegin; 1119f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 112063a3b9bcSJacob 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); 1121f9244615SMatthew G. Knepley ds->jetDegree[f] = k; 1122f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1123f9244615SMatthew G. Knepley } 1124f9244615SMatthew G. Knepley 11256528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS ds, PetscInt f, 112630b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1127194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1128194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 112997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11302764a2aaSMatthew G. Knepley { 11316528b96dSMatthew G. Knepley PetscPointFunc *tmp; 11326528b96dSMatthew G. Knepley PetscInt n; 11336528b96dSMatthew G. Knepley 11342764a2aaSMatthew G. Knepley PetscFunctionBegin; 11356528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11366528b96dSMatthew G. Knepley PetscValidPointer(obj, 3); 113763a3b9bcSJacob 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); 11389566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetObjective(ds->wf, NULL, 0, f, 0, &n, &tmp)); 11396528b96dSMatthew G. Knepley *obj = tmp ? tmp[0] : NULL; 11402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11412764a2aaSMatthew G. Knepley } 11422764a2aaSMatthew G. Knepley 11436528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS ds, PetscInt f, 114430b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1145194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1146194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 114797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11482764a2aaSMatthew G. Knepley { 11492764a2aaSMatthew G. Knepley PetscFunctionBegin; 11506528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11516528b96dSMatthew G. Knepley if (obj) PetscValidFunction(obj, 3); 115263a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 11539566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexObjective(ds->wf, NULL, 0, f, 0, 0, obj)); 11542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11552764a2aaSMatthew G. Knepley } 11562764a2aaSMatthew G. Knepley 1157194d53e6SMatthew G. Knepley /*@C 1158194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1159194d53e6SMatthew G. Knepley 1160194d53e6SMatthew G. Knepley Not collective 1161194d53e6SMatthew G. Knepley 1162194d53e6SMatthew G. Knepley Input Parameters: 11636528b96dSMatthew G. Knepley + ds - The PetscDS 1164194d53e6SMatthew G. Knepley - f - The test field number 1165194d53e6SMatthew G. Knepley 1166194d53e6SMatthew G. Knepley Output Parameters: 1167194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1168194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1169194d53e6SMatthew G. Knepley 1170194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1171194d53e6SMatthew G. Knepley 1172194d53e6SMatthew 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) 1173194d53e6SMatthew G. Knepley 1174194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1175194d53e6SMatthew G. Knepley 117630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1177194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1178194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1180194d53e6SMatthew G. Knepley 1181194d53e6SMatthew G. Knepley + dim - the spatial dimension 1182194d53e6SMatthew G. Knepley . Nf - the number of fields 1183194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1184194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1185194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1186194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1187194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1188194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1189194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1190194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1191194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1192194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1193194d53e6SMatthew G. Knepley . t - current time 1194194d53e6SMatthew G. Knepley . x - coordinates of the current point 119597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 119697b6e6e8SMatthew G. Knepley . constants - constant parameters 1197194d53e6SMatthew G. Knepley - f0 - output values at the current point 1198194d53e6SMatthew G. Knepley 1199194d53e6SMatthew G. Knepley Level: intermediate 1200194d53e6SMatthew G. Knepley 1201194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1202194d53e6SMatthew G. Knepley @*/ 12036528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS ds, PetscInt f, 120430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1205194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1206194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 120830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1209194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1210194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12122764a2aaSMatthew G. Knepley { 12136528b96dSMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 12146528b96dSMatthew G. Knepley PetscInt n0, n1; 12156528b96dSMatthew G. Knepley 12162764a2aaSMatthew G. Knepley PetscFunctionBegin; 12176528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 121863a3b9bcSJacob 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); 12199566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 12206528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 12216528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 12222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12232764a2aaSMatthew G. Knepley } 12242764a2aaSMatthew G. Knepley 1225194d53e6SMatthew G. Knepley /*@C 1226194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1227194d53e6SMatthew G. Knepley 1228194d53e6SMatthew G. Knepley Not collective 1229194d53e6SMatthew G. Knepley 1230194d53e6SMatthew G. Knepley Input Parameters: 12316528b96dSMatthew G. Knepley + ds - The PetscDS 1232194d53e6SMatthew G. Knepley . f - The test field number 1233194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1234194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1235194d53e6SMatthew G. Knepley 1236194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1237194d53e6SMatthew G. Knepley 1238194d53e6SMatthew 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) 1239194d53e6SMatthew G. Knepley 1240194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1241194d53e6SMatthew G. Knepley 124230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1243194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1244194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1246194d53e6SMatthew G. Knepley 1247194d53e6SMatthew G. Knepley + dim - the spatial dimension 1248194d53e6SMatthew G. Knepley . Nf - the number of fields 1249194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1250194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1251194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1252194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1253194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1254194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1255194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1256194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1257194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1258194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1259194d53e6SMatthew G. Knepley . t - current time 1260194d53e6SMatthew G. Knepley . x - coordinates of the current point 126197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 126297b6e6e8SMatthew G. Knepley . constants - constant parameters 1263194d53e6SMatthew G. Knepley - f0 - output values at the current point 1264194d53e6SMatthew G. Knepley 1265194d53e6SMatthew G. Knepley Level: intermediate 1266194d53e6SMatthew G. Knepley 1267194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1268194d53e6SMatthew G. Knepley @*/ 12696528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS ds, PetscInt f, 127030b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1271194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1272194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 127430b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1275194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1276194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12782764a2aaSMatthew G. Knepley { 12792764a2aaSMatthew G. Knepley PetscFunctionBegin; 12806528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1281f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1282f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 128363a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 12849566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 12852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12862764a2aaSMatthew G. Knepley } 12872764a2aaSMatthew G. Knepley 12883e75805dSMatthew G. Knepley /*@C 1289cb36c0f9SMatthew G. Knepley PetscDSGetRHSResidual - Get the pointwise RHS residual function for explicit timestepping for a given test field 1290cb36c0f9SMatthew G. Knepley 1291cb36c0f9SMatthew G. Knepley Not collective 1292cb36c0f9SMatthew G. Knepley 1293cb36c0f9SMatthew G. Knepley Input Parameters: 1294cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1295cb36c0f9SMatthew G. Knepley - f - The test field number 1296cb36c0f9SMatthew G. Knepley 1297cb36c0f9SMatthew G. Knepley Output Parameters: 1298cb36c0f9SMatthew G. Knepley + f0 - integrand for the test function term 1299cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1300cb36c0f9SMatthew G. Knepley 1301cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1302cb36c0f9SMatthew G. Knepley 1303cb36c0f9SMatthew 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) 1304cb36c0f9SMatthew G. Knepley 1305cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1306cb36c0f9SMatthew G. Knepley 1307cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1308cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1309cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1310cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1311cb36c0f9SMatthew G. Knepley 1312cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1313cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1314cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1315cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1316cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1317cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1318cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1319cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1320cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1321cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1322cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1323cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1324cb36c0f9SMatthew G. Knepley . t - current time 1325cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1326cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1327cb36c0f9SMatthew G. Knepley . constants - constant parameters 1328cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1329cb36c0f9SMatthew G. Knepley 1330cb36c0f9SMatthew G. Knepley Level: intermediate 1331cb36c0f9SMatthew G. Knepley 1332cb36c0f9SMatthew G. Knepley .seealso: PetscDSSetRHSResidual() 1333cb36c0f9SMatthew G. Knepley @*/ 1334cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSGetRHSResidual(PetscDS ds, PetscInt f, 1335cb36c0f9SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1336cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1337cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1338cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1339cb36c0f9SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1340cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1341cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1342cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1343cb36c0f9SMatthew G. Knepley { 1344cb36c0f9SMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 1345cb36c0f9SMatthew G. Knepley PetscInt n0, n1; 1346cb36c0f9SMatthew G. Knepley 1347cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1348cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 134963a3b9bcSJacob 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); 13509566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 100, &n0, &tmp0, &n1, &tmp1)); 1351cb36c0f9SMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 1352cb36c0f9SMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 1353cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1354cb36c0f9SMatthew G. Knepley } 1355cb36c0f9SMatthew G. Knepley 1356cb36c0f9SMatthew G. Knepley /*@C 1357cb36c0f9SMatthew G. Knepley PetscDSSetRHSResidual - Set the pointwise residual function for explicit timestepping for a given test field 1358cb36c0f9SMatthew G. Knepley 1359cb36c0f9SMatthew G. Knepley Not collective 1360cb36c0f9SMatthew G. Knepley 1361cb36c0f9SMatthew G. Knepley Input Parameters: 1362cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1363cb36c0f9SMatthew G. Knepley . f - The test field number 1364cb36c0f9SMatthew G. Knepley . f0 - integrand for the test function term 1365cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1366cb36c0f9SMatthew G. Knepley 1367cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1368cb36c0f9SMatthew G. Knepley 1369cb36c0f9SMatthew 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) 1370cb36c0f9SMatthew G. Knepley 1371cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1372cb36c0f9SMatthew G. Knepley 1373cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1374cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1375cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1376cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1377cb36c0f9SMatthew G. Knepley 1378cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1379cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1380cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1381cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1382cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1383cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1384cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1385cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1386cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1387cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1388cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1389cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1390cb36c0f9SMatthew G. Knepley . t - current time 1391cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1392cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1393cb36c0f9SMatthew G. Knepley . constants - constant parameters 1394cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1395cb36c0f9SMatthew G. Knepley 1396cb36c0f9SMatthew G. Knepley Level: intermediate 1397cb36c0f9SMatthew G. Knepley 1398cb36c0f9SMatthew G. Knepley .seealso: PetscDSGetResidual() 1399cb36c0f9SMatthew G. Knepley @*/ 1400cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSSetRHSResidual(PetscDS ds, PetscInt f, 1401cb36c0f9SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1402cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1403cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1404cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1405cb36c0f9SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1406cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1407cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1408cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1409cb36c0f9SMatthew G. Knepley { 1410cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1411cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1412cb36c0f9SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1413cb36c0f9SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 141463a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 14159566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 100, 0, f0, 0, f1)); 1416cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1417cb36c0f9SMatthew G. Knepley } 1418cb36c0f9SMatthew G. Knepley 1419cb36c0f9SMatthew G. Knepley /*@C 14203e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 14213e75805dSMatthew G. Knepley 14223e75805dSMatthew G. Knepley Not collective 14233e75805dSMatthew G. Knepley 14243e75805dSMatthew G. Knepley Input Parameter: 14253e75805dSMatthew G. Knepley . prob - The PetscDS 14263e75805dSMatthew G. Knepley 14273e75805dSMatthew G. Knepley Output Parameter: 14283e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 14293e75805dSMatthew G. Knepley 14303e75805dSMatthew G. Knepley Level: intermediate 14313e75805dSMatthew G. Knepley 14323e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 14333e75805dSMatthew G. Knepley @*/ 14346528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS ds, PetscBool *hasJac) 14353e75805dSMatthew G. Knepley { 14363e75805dSMatthew G. Knepley PetscFunctionBegin; 14376528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14389566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasJacobian(ds->wf, hasJac)); 14393e75805dSMatthew G. Knepley PetscFunctionReturn(0); 14403e75805dSMatthew G. Knepley } 14413e75805dSMatthew G. Knepley 1442194d53e6SMatthew G. Knepley /*@C 1443194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1444194d53e6SMatthew G. Knepley 1445194d53e6SMatthew G. Knepley Not collective 1446194d53e6SMatthew G. Knepley 1447194d53e6SMatthew G. Knepley Input Parameters: 14486528b96dSMatthew G. Knepley + ds - The PetscDS 1449194d53e6SMatthew G. Knepley . f - The test field number 1450194d53e6SMatthew G. Knepley - g - The field number 1451194d53e6SMatthew G. Knepley 1452194d53e6SMatthew G. Knepley Output Parameters: 1453194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1454194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1455194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1456194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1457194d53e6SMatthew G. Knepley 1458194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1459194d53e6SMatthew G. Knepley 1460194d53e6SMatthew 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 1461194d53e6SMatthew G. Knepley 1462194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1463194d53e6SMatthew G. Knepley 146430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1465194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1466194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1468194d53e6SMatthew G. Knepley 1469194d53e6SMatthew G. Knepley + dim - the spatial dimension 1470194d53e6SMatthew G. Knepley . Nf - the number of fields 1471194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1472194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1473194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1474194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1475194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1476194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1477194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1478194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1479194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1480194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1481194d53e6SMatthew G. Knepley . t - current time 14822aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1483194d53e6SMatthew G. Knepley . x - coordinates of the current point 148497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 148597b6e6e8SMatthew G. Knepley . constants - constant parameters 1486194d53e6SMatthew G. Knepley - g0 - output values at the current point 1487194d53e6SMatthew G. Knepley 1488194d53e6SMatthew G. Knepley Level: intermediate 1489194d53e6SMatthew G. Knepley 1490194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1491194d53e6SMatthew G. Knepley @*/ 14926528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS ds, PetscInt f, PetscInt g, 149330b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1494194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1495194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 149730b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1498194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1499194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 150130b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1502194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1503194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 150530b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1506194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1507194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15092764a2aaSMatthew G. Knepley { 15106528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 15116528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 15126528b96dSMatthew G. Knepley 15132764a2aaSMatthew G. Knepley PetscFunctionBegin; 15146528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 151563a3b9bcSJacob 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); 151663a3b9bcSJacob 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); 15179566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 15186528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 15196528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 15206528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 15216528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 15222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15232764a2aaSMatthew G. Knepley } 15242764a2aaSMatthew G. Knepley 1525194d53e6SMatthew G. Knepley /*@C 1526194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1527194d53e6SMatthew G. Knepley 1528194d53e6SMatthew G. Knepley Not collective 1529194d53e6SMatthew G. Knepley 1530194d53e6SMatthew G. Knepley Input Parameters: 15316528b96dSMatthew G. Knepley + ds - The PetscDS 1532194d53e6SMatthew G. Knepley . f - The test field number 1533194d53e6SMatthew G. Knepley . g - The field number 1534194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1535194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1536194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1537194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1538194d53e6SMatthew G. Knepley 1539194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1540194d53e6SMatthew G. Knepley 1541194d53e6SMatthew 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 1542194d53e6SMatthew G. Knepley 1543194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1544194d53e6SMatthew G. Knepley 154530b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1546194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1547194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1549194d53e6SMatthew G. Knepley 1550194d53e6SMatthew G. Knepley + dim - the spatial dimension 1551194d53e6SMatthew G. Knepley . Nf - the number of fields 1552194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1553194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1554194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1555194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1556194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1557194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1558194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1559194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1560194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1561194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1562194d53e6SMatthew G. Knepley . t - current time 15632aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1564194d53e6SMatthew G. Knepley . x - coordinates of the current point 156597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 156697b6e6e8SMatthew G. Knepley . constants - constant parameters 1567194d53e6SMatthew G. Knepley - g0 - output values at the current point 1568194d53e6SMatthew G. Knepley 1569194d53e6SMatthew G. Knepley Level: intermediate 1570194d53e6SMatthew G. Knepley 1571194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1572194d53e6SMatthew G. Knepley @*/ 15736528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS ds, PetscInt f, PetscInt g, 157430b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1575194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1576194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 157797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 157830b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1579194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1580194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 158230b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1583194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1584194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 158630b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1587194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1588194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15902764a2aaSMatthew G. Knepley { 15912764a2aaSMatthew G. Knepley PetscFunctionBegin; 15926528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15932764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 15942764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 15952764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 15962764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 159763a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 159863a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 15999566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 16002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16012764a2aaSMatthew G. Knepley } 16022764a2aaSMatthew G. Knepley 1603475e0ac9SMatthew G. Knepley /*@C 160455c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 160555c1f793SMatthew G. Knepley 160655c1f793SMatthew G. Knepley Not collective 160755c1f793SMatthew G. Knepley 160855c1f793SMatthew G. Knepley Input Parameters: 160955c1f793SMatthew G. Knepley + prob - The PetscDS 161055c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 161155c1f793SMatthew G. Knepley 161255c1f793SMatthew G. Knepley Level: intermediate 161355c1f793SMatthew G. Knepley 161455c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 161555c1f793SMatthew G. Knepley @*/ 161655c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 161755c1f793SMatthew G. Knepley { 161855c1f793SMatthew G. Knepley PetscFunctionBegin; 161955c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 162055c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 162155c1f793SMatthew G. Knepley PetscFunctionReturn(0); 162255c1f793SMatthew G. Knepley } 162355c1f793SMatthew G. Knepley 162455c1f793SMatthew G. Knepley /*@C 1625475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1626475e0ac9SMatthew G. Knepley 1627475e0ac9SMatthew G. Knepley Not collective 1628475e0ac9SMatthew G. Knepley 1629475e0ac9SMatthew G. Knepley Input Parameter: 1630475e0ac9SMatthew G. Knepley . prob - The PetscDS 1631475e0ac9SMatthew G. Knepley 1632475e0ac9SMatthew G. Knepley Output Parameter: 1633475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1634475e0ac9SMatthew G. Knepley 1635475e0ac9SMatthew G. Knepley Level: intermediate 1636475e0ac9SMatthew G. Knepley 1637475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1638475e0ac9SMatthew G. Knepley @*/ 16396528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS ds, PetscBool *hasJacPre) 1640475e0ac9SMatthew G. Knepley { 1641475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16426528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1643475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 16446528b96dSMatthew G. Knepley if (!ds->useJacPre) PetscFunctionReturn(0); 16459566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasJacobianPreconditioner(ds->wf, hasJacPre)); 1646475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1647475e0ac9SMatthew G. Knepley } 1648475e0ac9SMatthew G. Knepley 1649475e0ac9SMatthew G. Knepley /*@C 1650475e0ac9SMatthew 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. 1651475e0ac9SMatthew G. Knepley 1652475e0ac9SMatthew G. Knepley Not collective 1653475e0ac9SMatthew G. Knepley 1654475e0ac9SMatthew G. Knepley Input Parameters: 16556528b96dSMatthew G. Knepley + ds - The PetscDS 1656475e0ac9SMatthew G. Knepley . f - The test field number 1657475e0ac9SMatthew G. Knepley - g - The field number 1658475e0ac9SMatthew G. Knepley 1659475e0ac9SMatthew G. Knepley Output Parameters: 1660475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1661475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1662475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1663475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1664475e0ac9SMatthew G. Knepley 1665475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1666475e0ac9SMatthew G. Knepley 1667475e0ac9SMatthew 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 1668475e0ac9SMatthew G. Knepley 1669475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1670475e0ac9SMatthew G. Knepley 1671475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1672475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1673475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1674475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1675475e0ac9SMatthew G. Knepley 1676475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1677475e0ac9SMatthew G. Knepley . Nf - the number of fields 1678475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1679475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1680475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1681475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1682475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1683475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1684475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1685475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1686475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1687475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1688475e0ac9SMatthew G. Knepley . t - current time 1689475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1690475e0ac9SMatthew G. Knepley . x - coordinates of the current point 169197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 169297b6e6e8SMatthew G. Knepley . constants - constant parameters 1693475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1694475e0ac9SMatthew G. Knepley 1695475e0ac9SMatthew G. Knepley Level: intermediate 1696475e0ac9SMatthew G. Knepley 1697475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1698475e0ac9SMatthew G. Knepley @*/ 16996528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1700475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1701475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1702475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1704475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1705475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1706475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1708475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1709475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1710475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1712475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1713475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1714475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1716475e0ac9SMatthew G. Knepley { 17176528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 17186528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 17196528b96dSMatthew G. Knepley 1720475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 172263a3b9bcSJacob 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); 172363a3b9bcSJacob 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); 17249566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 17256528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 17266528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 17276528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 17286528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1729475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1730475e0ac9SMatthew G. Knepley } 1731475e0ac9SMatthew G. Knepley 1732475e0ac9SMatthew G. Knepley /*@C 1733475e0ac9SMatthew 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. 1734475e0ac9SMatthew G. Knepley 1735475e0ac9SMatthew G. Knepley Not collective 1736475e0ac9SMatthew G. Knepley 1737475e0ac9SMatthew G. Knepley Input Parameters: 17386528b96dSMatthew G. Knepley + ds - The PetscDS 1739475e0ac9SMatthew G. Knepley . f - The test field number 1740475e0ac9SMatthew G. Knepley . g - The field number 1741475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1742475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1743475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1744475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1745475e0ac9SMatthew G. Knepley 1746475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1747475e0ac9SMatthew G. Knepley 1748475e0ac9SMatthew 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 1749475e0ac9SMatthew G. Knepley 1750475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1751475e0ac9SMatthew G. Knepley 1752475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1753475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1754475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1755475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1756475e0ac9SMatthew G. Knepley 1757475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1758475e0ac9SMatthew G. Knepley . Nf - the number of fields 1759475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1760475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1761475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1762475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1763475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1764475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1765475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1766475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1767475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1768475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1769475e0ac9SMatthew G. Knepley . t - current time 1770475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1771475e0ac9SMatthew G. Knepley . x - coordinates of the current point 177297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 177397b6e6e8SMatthew G. Knepley . constants - constant parameters 1774475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1775475e0ac9SMatthew G. Knepley 1776475e0ac9SMatthew G. Knepley Level: intermediate 1777475e0ac9SMatthew G. Knepley 1778475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1779475e0ac9SMatthew G. Knepley @*/ 17806528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1781475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1782475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1783475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1785475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1786475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1787475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1789475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1790475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1791475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1793475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1794475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1795475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1797475e0ac9SMatthew G. Knepley { 1798475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17996528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1800475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1801475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1802475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1803475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 180463a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 180563a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 18069566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1807475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1808475e0ac9SMatthew G. Knepley } 1809475e0ac9SMatthew G. Knepley 1810b7e05686SMatthew G. Knepley /*@C 1811b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1812b7e05686SMatthew G. Knepley 1813b7e05686SMatthew G. Knepley Not collective 1814b7e05686SMatthew G. Knepley 1815b7e05686SMatthew G. Knepley Input Parameter: 18166528b96dSMatthew G. Knepley . ds - The PetscDS 1817b7e05686SMatthew G. Knepley 1818b7e05686SMatthew G. Knepley Output Parameter: 1819b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1820b7e05686SMatthew G. Knepley 1821b7e05686SMatthew G. Knepley Level: intermediate 1822b7e05686SMatthew G. Knepley 1823b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1824b7e05686SMatthew G. Knepley @*/ 18256528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS ds, PetscBool *hasDynJac) 1826b7e05686SMatthew G. Knepley { 1827b7e05686SMatthew G. Knepley PetscFunctionBegin; 18286528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18299566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasDynamicJacobian(ds->wf, hasDynJac)); 1830b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1831b7e05686SMatthew G. Knepley } 1832b7e05686SMatthew G. Knepley 1833b7e05686SMatthew G. Knepley /*@C 1834b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1835b7e05686SMatthew G. Knepley 1836b7e05686SMatthew G. Knepley Not collective 1837b7e05686SMatthew G. Knepley 1838b7e05686SMatthew G. Knepley Input Parameters: 18396528b96dSMatthew G. Knepley + ds - The PetscDS 1840b7e05686SMatthew G. Knepley . f - The test field number 1841b7e05686SMatthew G. Knepley - g - The field number 1842b7e05686SMatthew G. Knepley 1843b7e05686SMatthew G. Knepley Output Parameters: 1844b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1845b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1846b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1847b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1848b7e05686SMatthew G. Knepley 1849b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1850b7e05686SMatthew G. Knepley 1851b7e05686SMatthew 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 1852b7e05686SMatthew G. Knepley 1853b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1854b7e05686SMatthew G. Knepley 1855b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1856b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1857b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1858b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1859b7e05686SMatthew G. Knepley 1860b7e05686SMatthew G. Knepley + dim - the spatial dimension 1861b7e05686SMatthew G. Knepley . Nf - the number of fields 1862b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1863b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1864b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1865b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1866b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1867b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1868b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1869b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1870b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1871b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1872b7e05686SMatthew G. Knepley . t - current time 1873b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1874b7e05686SMatthew G. Knepley . x - coordinates of the current point 187597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 187697b6e6e8SMatthew G. Knepley . constants - constant parameters 1877b7e05686SMatthew G. Knepley - g0 - output values at the current point 1878b7e05686SMatthew G. Knepley 1879b7e05686SMatthew G. Knepley Level: intermediate 1880b7e05686SMatthew G. Knepley 1881b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1882b7e05686SMatthew G. Knepley @*/ 18836528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1884b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1885b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1886b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1888b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1889b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1890b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1892b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1893b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1894b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1896b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1897b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1898b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1900b7e05686SMatthew G. Knepley { 19016528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 19026528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 19036528b96dSMatthew G. Knepley 1904b7e05686SMatthew G. Knepley PetscFunctionBegin; 19056528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 190663a3b9bcSJacob 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); 190763a3b9bcSJacob 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); 19089566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetDynamicJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 19096528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 19106528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 19116528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 19126528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1913b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1914b7e05686SMatthew G. Knepley } 1915b7e05686SMatthew G. Knepley 1916b7e05686SMatthew G. Knepley /*@C 1917b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1918b7e05686SMatthew G. Knepley 1919b7e05686SMatthew G. Knepley Not collective 1920b7e05686SMatthew G. Knepley 1921b7e05686SMatthew G. Knepley Input Parameters: 19226528b96dSMatthew G. Knepley + ds - The PetscDS 1923b7e05686SMatthew G. Knepley . f - The test field number 1924b7e05686SMatthew G. Knepley . g - The field number 1925b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1926b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1927b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1928b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1929b7e05686SMatthew G. Knepley 1930b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1931b7e05686SMatthew G. Knepley 1932b7e05686SMatthew 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 1933b7e05686SMatthew G. Knepley 1934b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1935b7e05686SMatthew G. Knepley 1936b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1937b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1938b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1939b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1940b7e05686SMatthew G. Knepley 1941b7e05686SMatthew G. Knepley + dim - the spatial dimension 1942b7e05686SMatthew G. Knepley . Nf - the number of fields 1943b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1944b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1945b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1946b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1947b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1948b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1949b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1950b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1951b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1952b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1953b7e05686SMatthew G. Knepley . t - current time 1954b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1955b7e05686SMatthew G. Knepley . x - coordinates of the current point 195697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 195797b6e6e8SMatthew G. Knepley . constants - constant parameters 1958b7e05686SMatthew G. Knepley - g0 - output values at the current point 1959b7e05686SMatthew G. Knepley 1960b7e05686SMatthew G. Knepley Level: intermediate 1961b7e05686SMatthew G. Knepley 1962b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1963b7e05686SMatthew G. Knepley @*/ 19646528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1965b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1966b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1967b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 196897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1969b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1970b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1971b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1973b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1974b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1975b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1977b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1978b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1979b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1981b7e05686SMatthew G. Knepley { 1982b7e05686SMatthew G. Knepley PetscFunctionBegin; 19836528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1984b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1985b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1986b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1987b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 198863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 198963a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 19909566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexDynamicJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1991b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1992b7e05686SMatthew G. Knepley } 1993b7e05686SMatthew G. Knepley 19940c2f2876SMatthew G. Knepley /*@C 19950c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 19960c2f2876SMatthew G. Knepley 19970c2f2876SMatthew G. Knepley Not collective 19980c2f2876SMatthew G. Knepley 19994165533cSJose E. Roman Input Parameters: 20006528b96dSMatthew G. Knepley + ds - The PetscDS object 20010c2f2876SMatthew G. Knepley - f - The field number 20020c2f2876SMatthew G. Knepley 20034165533cSJose E. Roman Output Parameter: 20040c2f2876SMatthew G. Knepley . r - Riemann solver 20050c2f2876SMatthew G. Knepley 20060c2f2876SMatthew G. Knepley Calling sequence for r: 20070c2f2876SMatthew G. Knepley 20085db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20090c2f2876SMatthew G. Knepley 20105db36cf9SMatthew G. Knepley + dim - The spatial dimension 20115db36cf9SMatthew G. Knepley . Nf - The number of fields 20125db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20130c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20140c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20150c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20160c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 201797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 201897b6e6e8SMatthew G. Knepley . constants - constant parameters 20190c2f2876SMatthew G. Knepley - ctx - optional user context 20200c2f2876SMatthew G. Knepley 20210c2f2876SMatthew G. Knepley Level: intermediate 20220c2f2876SMatthew G. Knepley 20230c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 20240c2f2876SMatthew G. Knepley @*/ 20256528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS ds, PetscInt f, 202697b6e6e8SMatthew 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)) 20270c2f2876SMatthew G. Knepley { 20286528b96dSMatthew G. Knepley PetscRiemannFunc *tmp; 20296528b96dSMatthew G. Knepley PetscInt n; 20306528b96dSMatthew G. Knepley 20310c2f2876SMatthew G. Knepley PetscFunctionBegin; 20326528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20330c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 203463a3b9bcSJacob 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); 20359566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetRiemannSolver(ds->wf, NULL, 0, f, 0, &n, &tmp)); 20366528b96dSMatthew G. Knepley *r = tmp ? tmp[0] : NULL; 20370c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20380c2f2876SMatthew G. Knepley } 20390c2f2876SMatthew G. Knepley 20400c2f2876SMatthew G. Knepley /*@C 20410c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 20420c2f2876SMatthew G. Knepley 20430c2f2876SMatthew G. Knepley Not collective 20440c2f2876SMatthew G. Knepley 20454165533cSJose E. Roman Input Parameters: 20466528b96dSMatthew G. Knepley + ds - The PetscDS object 20470c2f2876SMatthew G. Knepley . f - The field number 20480c2f2876SMatthew G. Knepley - r - Riemann solver 20490c2f2876SMatthew G. Knepley 20500c2f2876SMatthew G. Knepley Calling sequence for r: 20510c2f2876SMatthew G. Knepley 20525db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20530c2f2876SMatthew G. Knepley 20545db36cf9SMatthew G. Knepley + dim - The spatial dimension 20555db36cf9SMatthew G. Knepley . Nf - The number of fields 20565db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20570c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20580c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20590c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20600c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 206197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 206297b6e6e8SMatthew G. Knepley . constants - constant parameters 20630c2f2876SMatthew G. Knepley - ctx - optional user context 20640c2f2876SMatthew G. Knepley 20650c2f2876SMatthew G. Knepley Level: intermediate 20660c2f2876SMatthew G. Knepley 20670c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 20680c2f2876SMatthew G. Knepley @*/ 20696528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS ds, PetscInt f, 207097b6e6e8SMatthew 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)) 20710c2f2876SMatthew G. Knepley { 20720c2f2876SMatthew G. Knepley PetscFunctionBegin; 20736528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2074de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 207563a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 20769566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexRiemannSolver(ds->wf, NULL, 0, f, 0, 0, r)); 20770c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20780c2f2876SMatthew G. Knepley } 20790c2f2876SMatthew G. Knepley 208032d2bbc9SMatthew G. Knepley /*@C 208132d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 208232d2bbc9SMatthew G. Knepley 208332d2bbc9SMatthew G. Knepley Not collective 208432d2bbc9SMatthew G. Knepley 208532d2bbc9SMatthew G. Knepley Input Parameters: 20866528b96dSMatthew G. Knepley + ds - The PetscDS 208732d2bbc9SMatthew G. Knepley - f - The field number 208832d2bbc9SMatthew G. Knepley 2089f899ff85SJose E. Roman Output Parameter: 2090a2b725a8SWilliam Gropp . update - update function 209132d2bbc9SMatthew G. Knepley 209232d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 209332d2bbc9SMatthew G. Knepley 209432d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 209532d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 209632d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 209732d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 209832d2bbc9SMatthew G. Knepley 209932d2bbc9SMatthew G. Knepley + dim - the spatial dimension 210032d2bbc9SMatthew G. Knepley . Nf - the number of fields 210132d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 210232d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 210332d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 210432d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 210532d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 210632d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 210732d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 210832d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 210932d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 211032d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 211132d2bbc9SMatthew G. Knepley . t - current time 211232d2bbc9SMatthew G. Knepley . x - coordinates of the current point 211332d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 211432d2bbc9SMatthew G. Knepley 211532d2bbc9SMatthew G. Knepley Level: intermediate 211632d2bbc9SMatthew G. Knepley 211732d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 211832d2bbc9SMatthew G. Knepley @*/ 21196528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS ds, PetscInt f, 212032d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 212132d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 212232d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21233fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 212432d2bbc9SMatthew G. Knepley { 212532d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21266528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 212763a3b9bcSJacob 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); 21286528b96dSMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = ds->update[f];} 212932d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 213032d2bbc9SMatthew G. Knepley } 213132d2bbc9SMatthew G. Knepley 213232d2bbc9SMatthew G. Knepley /*@C 21333fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 213432d2bbc9SMatthew G. Knepley 213532d2bbc9SMatthew G. Knepley Not collective 213632d2bbc9SMatthew G. Knepley 213732d2bbc9SMatthew G. Knepley Input Parameters: 21386528b96dSMatthew G. Knepley + ds - The PetscDS 213932d2bbc9SMatthew G. Knepley . f - The field number 214032d2bbc9SMatthew G. Knepley - update - update function 214132d2bbc9SMatthew G. Knepley 214232d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 214332d2bbc9SMatthew G. Knepley 214432d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 214532d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 214632d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 214732d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 214832d2bbc9SMatthew G. Knepley 214932d2bbc9SMatthew G. Knepley + dim - the spatial dimension 215032d2bbc9SMatthew G. Knepley . Nf - the number of fields 215132d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 215232d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 215332d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 215432d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 215532d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 215632d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 215732d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 215832d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 215932d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 216032d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 216132d2bbc9SMatthew G. Knepley . t - current time 216232d2bbc9SMatthew G. Knepley . x - coordinates of the current point 216332d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 216432d2bbc9SMatthew G. Knepley 216532d2bbc9SMatthew G. Knepley Level: intermediate 216632d2bbc9SMatthew G. Knepley 216732d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 216832d2bbc9SMatthew G. Knepley @*/ 21696528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS ds, PetscInt f, 217032d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 217132d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 217232d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21733fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 217432d2bbc9SMatthew G. Knepley { 217532d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21766528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 217732d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 217863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 21799566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(ds, f+1)); 21806528b96dSMatthew G. Knepley ds->update[f] = update; 218132d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 218232d2bbc9SMatthew G. Knepley } 218332d2bbc9SMatthew G. Knepley 21843ec1f749SStefano Zampini PetscErrorCode PetscDSGetContext(PetscDS ds, PetscInt f, void *ctx) 21850c2f2876SMatthew G. Knepley { 21860c2f2876SMatthew G. Knepley PetscFunctionBegin; 21876528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 218863a3b9bcSJacob 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); 21890c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 21903ec1f749SStefano Zampini *(void**)ctx = ds->ctx[f]; 21910c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 21920c2f2876SMatthew G. Knepley } 21930c2f2876SMatthew G. Knepley 21946528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS ds, PetscInt f, void *ctx) 21950c2f2876SMatthew G. Knepley { 21960c2f2876SMatthew G. Knepley PetscFunctionBegin; 21976528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 219863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 21999566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(ds, f+1)); 22006528b96dSMatthew G. Knepley ds->ctx[f] = ctx; 22010c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 22020c2f2876SMatthew G. Knepley } 22030c2f2876SMatthew G. Knepley 2204194d53e6SMatthew G. Knepley /*@C 2205194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 2206194d53e6SMatthew G. Knepley 2207194d53e6SMatthew G. Knepley Not collective 2208194d53e6SMatthew G. Knepley 2209194d53e6SMatthew G. Knepley Input Parameters: 22106528b96dSMatthew G. Knepley + ds - The PetscDS 2211194d53e6SMatthew G. Knepley - f - The test field number 2212194d53e6SMatthew G. Knepley 2213194d53e6SMatthew G. Knepley Output Parameters: 2214194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 2215194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2216194d53e6SMatthew G. Knepley 2217194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2218194d53e6SMatthew G. Knepley 2219194d53e6SMatthew 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 2220194d53e6SMatthew G. Knepley 2221194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2222194d53e6SMatthew G. Knepley 222330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2224194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2225194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 222630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2227194d53e6SMatthew G. Knepley 2228194d53e6SMatthew G. Knepley + dim - the spatial dimension 2229194d53e6SMatthew G. Knepley . Nf - the number of fields 2230194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2231194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2232194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2233194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2234194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2235194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2236194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2237194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2238194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2239194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2240194d53e6SMatthew G. Knepley . t - current time 2241194d53e6SMatthew G. Knepley . x - coordinates of the current point 2242194d53e6SMatthew G. Knepley . n - unit normal at the current point 224397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 224497b6e6e8SMatthew G. Knepley . constants - constant parameters 2245194d53e6SMatthew G. Knepley - f0 - output values at the current point 2246194d53e6SMatthew G. Knepley 2247194d53e6SMatthew G. Knepley Level: intermediate 2248194d53e6SMatthew G. Knepley 2249194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 2250194d53e6SMatthew G. Knepley @*/ 22516528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS ds, PetscInt f, 225230b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2253194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2254194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 225630b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2257194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2258194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 22602764a2aaSMatthew G. Knepley { 22616528b96dSMatthew G. Knepley PetscBdPointFunc *tmp0, *tmp1; 22626528b96dSMatthew G. Knepley PetscInt n0, n1; 22636528b96dSMatthew G. Knepley 22642764a2aaSMatthew G. Knepley PetscFunctionBegin; 22656528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 226663a3b9bcSJacob 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); 22679566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 22686528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 22696528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 22702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22712764a2aaSMatthew G. Knepley } 22722764a2aaSMatthew G. Knepley 2273194d53e6SMatthew G. Knepley /*@C 2274194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2275194d53e6SMatthew G. Knepley 2276194d53e6SMatthew G. Knepley Not collective 2277194d53e6SMatthew G. Knepley 2278194d53e6SMatthew G. Knepley Input Parameters: 22796528b96dSMatthew G. Knepley + ds - The PetscDS 2280194d53e6SMatthew G. Knepley . f - The test field number 2281194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2282194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2283194d53e6SMatthew G. Knepley 2284194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2285194d53e6SMatthew G. Knepley 2286194d53e6SMatthew 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 2287194d53e6SMatthew G. Knepley 2288194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2289194d53e6SMatthew G. Knepley 229030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2291194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2292194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 229330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2294194d53e6SMatthew G. Knepley 2295194d53e6SMatthew G. Knepley + dim - the spatial dimension 2296194d53e6SMatthew G. Knepley . Nf - the number of fields 2297194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2298194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2299194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2300194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2301194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2302194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2303194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2304194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2305194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2306194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2307194d53e6SMatthew G. Knepley . t - current time 2308194d53e6SMatthew G. Knepley . x - coordinates of the current point 2309194d53e6SMatthew G. Knepley . n - unit normal at the current point 231097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 231197b6e6e8SMatthew G. Knepley . constants - constant parameters 2312194d53e6SMatthew G. Knepley - f0 - output values at the current point 2313194d53e6SMatthew G. Knepley 2314194d53e6SMatthew G. Knepley Level: intermediate 2315194d53e6SMatthew G. Knepley 2316194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2317194d53e6SMatthew G. Knepley @*/ 23186528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS ds, PetscInt f, 231930b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2320194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2321194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 232330b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2324194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2325194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 23272764a2aaSMatthew G. Knepley { 23282764a2aaSMatthew G. Knepley PetscFunctionBegin; 23296528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 233063a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 23319566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 23322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23332764a2aaSMatthew G. Knepley } 23342764a2aaSMatthew G. Knepley 233527f02ce8SMatthew G. Knepley /*@ 233627f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 233727f02ce8SMatthew G. Knepley 233827f02ce8SMatthew G. Knepley Not collective 233927f02ce8SMatthew G. Knepley 234027f02ce8SMatthew G. Knepley Input Parameter: 23416528b96dSMatthew G. Knepley . ds - The PetscDS 234227f02ce8SMatthew G. Knepley 234327f02ce8SMatthew G. Knepley Output Parameter: 234427f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 234527f02ce8SMatthew G. Knepley 234627f02ce8SMatthew G. Knepley Level: intermediate 234727f02ce8SMatthew G. Knepley 234827f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 234927f02ce8SMatthew G. Knepley @*/ 23506528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS ds, PetscBool *hasBdJac) 235127f02ce8SMatthew G. Knepley { 235227f02ce8SMatthew G. Knepley PetscFunctionBegin; 23536528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23546528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJac, 2); 23559566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasBdJacobian(ds->wf, hasBdJac)); 235627f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 235727f02ce8SMatthew G. Knepley } 235827f02ce8SMatthew G. Knepley 2359194d53e6SMatthew G. Knepley /*@C 2360194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2361194d53e6SMatthew G. Knepley 2362194d53e6SMatthew G. Knepley Not collective 2363194d53e6SMatthew G. Knepley 2364194d53e6SMatthew G. Knepley Input Parameters: 23656528b96dSMatthew G. Knepley + ds - The PetscDS 2366194d53e6SMatthew G. Knepley . f - The test field number 2367194d53e6SMatthew G. Knepley - g - The field number 2368194d53e6SMatthew G. Knepley 2369194d53e6SMatthew G. Knepley Output Parameters: 2370194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2371194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2372194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2373194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2374194d53e6SMatthew G. Knepley 2375194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2376194d53e6SMatthew G. Knepley 2377194d53e6SMatthew 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 2378194d53e6SMatthew G. Knepley 2379194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2380194d53e6SMatthew G. Knepley 238130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2382194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2383194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 238430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2385194d53e6SMatthew G. Knepley 2386194d53e6SMatthew G. Knepley + dim - the spatial dimension 2387194d53e6SMatthew G. Knepley . Nf - the number of fields 2388194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2389194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2390194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2391194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2392194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2393194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2394194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2395194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2396194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2397194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2398194d53e6SMatthew G. Knepley . t - current time 23992aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2400194d53e6SMatthew G. Knepley . x - coordinates of the current point 2401194d53e6SMatthew G. Knepley . n - normal at the current point 240297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 240397b6e6e8SMatthew G. Knepley . constants - constant parameters 2404194d53e6SMatthew G. Knepley - g0 - output values at the current point 2405194d53e6SMatthew G. Knepley 2406194d53e6SMatthew G. Knepley Level: intermediate 2407194d53e6SMatthew G. Knepley 2408194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2409194d53e6SMatthew G. Knepley @*/ 24106528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 241130b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2412194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2413194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 241530b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2416194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2417194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 241930b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2420194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2421194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 242330b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2424194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2425194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 24272764a2aaSMatthew G. Knepley { 24286528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 24296528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 24306528b96dSMatthew G. Knepley 24312764a2aaSMatthew G. Knepley PetscFunctionBegin; 24326528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 243363a3b9bcSJacob 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); 243463a3b9bcSJacob 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); 24359566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 24366528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 24376528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 24386528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 24396528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 24402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24412764a2aaSMatthew G. Knepley } 24422764a2aaSMatthew G. Knepley 2443194d53e6SMatthew G. Knepley /*@C 2444194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2445194d53e6SMatthew G. Knepley 2446194d53e6SMatthew G. Knepley Not collective 2447194d53e6SMatthew G. Knepley 2448194d53e6SMatthew G. Knepley Input Parameters: 24496528b96dSMatthew G. Knepley + ds - The PetscDS 2450194d53e6SMatthew G. Knepley . f - The test field number 2451194d53e6SMatthew G. Knepley . g - The field number 2452194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2453194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2454194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2455194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2456194d53e6SMatthew G. Knepley 2457194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2458194d53e6SMatthew G. Knepley 2459194d53e6SMatthew 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 2460194d53e6SMatthew G. Knepley 2461194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2462194d53e6SMatthew G. Knepley 246330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2464194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2465194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 246630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2467194d53e6SMatthew G. Knepley 2468194d53e6SMatthew G. Knepley + dim - the spatial dimension 2469194d53e6SMatthew G. Knepley . Nf - the number of fields 2470194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2471194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2472194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2473194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2474194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2475194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2476194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2477194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2478194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2479194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2480194d53e6SMatthew G. Knepley . t - current time 24812aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2482194d53e6SMatthew G. Knepley . x - coordinates of the current point 2483194d53e6SMatthew G. Knepley . n - normal at the current point 248497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 248597b6e6e8SMatthew G. Knepley . constants - constant parameters 2486194d53e6SMatthew G. Knepley - g0 - output values at the current point 2487194d53e6SMatthew G. Knepley 2488194d53e6SMatthew G. Knepley Level: intermediate 2489194d53e6SMatthew G. Knepley 2490194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2491194d53e6SMatthew G. Knepley @*/ 24926528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 249330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2494194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2495194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 249730b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2498194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2499194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 250130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2502194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2503194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 250530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2506194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2507194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 25092764a2aaSMatthew G. Knepley { 25102764a2aaSMatthew G. Knepley PetscFunctionBegin; 25116528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25122764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 25132764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 25142764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 25152764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 251663a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 251763a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 25189566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 25192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25202764a2aaSMatthew G. Knepley } 25212764a2aaSMatthew G. Knepley 252227f02ce8SMatthew G. Knepley /*@ 252327f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 252427f02ce8SMatthew G. Knepley 252527f02ce8SMatthew G. Knepley Not collective 252627f02ce8SMatthew G. Knepley 252727f02ce8SMatthew G. Knepley Input Parameter: 25286528b96dSMatthew G. Knepley . ds - The PetscDS 252927f02ce8SMatthew G. Knepley 253027f02ce8SMatthew G. Knepley Output Parameter: 253127f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 253227f02ce8SMatthew G. Knepley 253327f02ce8SMatthew G. Knepley Level: intermediate 253427f02ce8SMatthew G. Knepley 253527f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 253627f02ce8SMatthew G. Knepley @*/ 25376528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS ds, PetscBool *hasBdJacPre) 253827f02ce8SMatthew G. Knepley { 253927f02ce8SMatthew G. Knepley PetscFunctionBegin; 25406528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25416528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJacPre, 2); 25429566063dSJacob Faibussowitsch PetscCall(PetscWeakFormHasBdJacobianPreconditioner(ds->wf, hasBdJacPre)); 254327f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 254427f02ce8SMatthew G. Knepley } 254527f02ce8SMatthew G. Knepley 254627f02ce8SMatthew G. Knepley /*@C 254727f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 254827f02ce8SMatthew G. Knepley 254927f02ce8SMatthew G. Knepley Not collective 255027f02ce8SMatthew G. Knepley 255127f02ce8SMatthew G. Knepley Input Parameters: 25526528b96dSMatthew G. Knepley + ds - The PetscDS 255327f02ce8SMatthew G. Knepley . f - The test field number 255427f02ce8SMatthew G. Knepley - g - The field number 255527f02ce8SMatthew G. Knepley 255627f02ce8SMatthew G. Knepley Output Parameters: 255727f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 255827f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 255927f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 256027f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 256127f02ce8SMatthew G. Knepley 256227f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 256327f02ce8SMatthew G. Knepley 256427f02ce8SMatthew 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 256527f02ce8SMatthew G. Knepley 256627f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 256727f02ce8SMatthew G. Knepley 256827f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 256927f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 257027f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 257127f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 257227f02ce8SMatthew G. Knepley 257327f02ce8SMatthew G. Knepley + dim - the spatial dimension 257427f02ce8SMatthew G. Knepley . Nf - the number of fields 257527f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 257627f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 257727f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 257827f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 257927f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 258027f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 258127f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 258227f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 258327f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 258427f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 258527f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 258627f02ce8SMatthew G. Knepley . t - current time 258727f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 258827f02ce8SMatthew G. Knepley . x - coordinates of the current point 258927f02ce8SMatthew G. Knepley . n - normal at the current point 259027f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 259127f02ce8SMatthew G. Knepley . constants - constant parameters 259227f02ce8SMatthew G. Knepley - g0 - output values at the current point 259327f02ce8SMatthew G. Knepley 259427f02ce8SMatthew G. Knepley This is not yet available in Fortran. 259527f02ce8SMatthew G. Knepley 259627f02ce8SMatthew G. Knepley Level: intermediate 259727f02ce8SMatthew G. Knepley 259827f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 259927f02ce8SMatthew G. Knepley @*/ 26006528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 260127f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260227f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260327f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260427f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 260527f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 260927f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 261027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 261327f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 261427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 261727f02ce8SMatthew G. Knepley { 26186528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 26196528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 26206528b96dSMatthew G. Knepley 262127f02ce8SMatthew G. Knepley PetscFunctionBegin; 26226528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 262363a3b9bcSJacob 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); 262463a3b9bcSJacob 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); 26259566063dSJacob Faibussowitsch PetscCall(PetscWeakFormGetBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 26266528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 26276528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 26286528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 26296528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 263027f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 263127f02ce8SMatthew G. Knepley } 263227f02ce8SMatthew G. Knepley 263327f02ce8SMatthew G. Knepley /*@C 263427f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 263527f02ce8SMatthew G. Knepley 263627f02ce8SMatthew G. Knepley Not collective 263727f02ce8SMatthew G. Knepley 263827f02ce8SMatthew G. Knepley Input Parameters: 26396528b96dSMatthew G. Knepley + ds - The PetscDS 264027f02ce8SMatthew G. Knepley . f - The test field number 264127f02ce8SMatthew G. Knepley . g - The field number 264227f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 264327f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 264427f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 264527f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 264627f02ce8SMatthew G. Knepley 264727f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 264827f02ce8SMatthew G. Knepley 264927f02ce8SMatthew 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 265027f02ce8SMatthew G. Knepley 265127f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 265227f02ce8SMatthew G. Knepley 265327f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 265427f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 265527f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 265627f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 265727f02ce8SMatthew G. Knepley 265827f02ce8SMatthew G. Knepley + dim - the spatial dimension 265927f02ce8SMatthew G. Knepley . Nf - the number of fields 266027f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 266127f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 266227f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 266327f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 266427f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 266527f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 266627f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 266727f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 266827f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 266927f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 267027f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 267127f02ce8SMatthew G. Knepley . t - current time 267227f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 267327f02ce8SMatthew G. Knepley . x - coordinates of the current point 267427f02ce8SMatthew G. Knepley . n - normal at the current point 267527f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 267627f02ce8SMatthew G. Knepley . constants - constant parameters 267727f02ce8SMatthew G. Knepley - g0 - output values at the current point 267827f02ce8SMatthew G. Knepley 267927f02ce8SMatthew G. Knepley This is not yet available in Fortran. 268027f02ce8SMatthew G. Knepley 268127f02ce8SMatthew G. Knepley Level: intermediate 268227f02ce8SMatthew G. Knepley 268327f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 268427f02ce8SMatthew G. Knepley @*/ 26856528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 268627f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 268727f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 268827f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 268927f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 269027f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269127f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269227f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269327f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 269427f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269527f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269627f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269727f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 269827f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269927f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 270027f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 270127f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 270227f02ce8SMatthew G. Knepley { 270327f02ce8SMatthew G. Knepley PetscFunctionBegin; 27046528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 270527f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 270627f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 270727f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 270827f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 270963a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 271063a3b9bcSJacob Faibussowitsch PetscCheck(g >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", g); 27119566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetIndexBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 271227f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 271327f02ce8SMatthew G. Knepley } 271427f02ce8SMatthew G. Knepley 27150d3e9b51SMatthew G. Knepley /*@C 2716c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2717c371a6d1SMatthew G. Knepley 2718c371a6d1SMatthew G. Knepley Not collective 2719c371a6d1SMatthew G. Knepley 2720c371a6d1SMatthew G. Knepley Input Parameters: 2721c371a6d1SMatthew G. Knepley + prob - The PetscDS 2722c371a6d1SMatthew G. Knepley - f - The test field number 2723c371a6d1SMatthew G. Knepley 2724d8d19677SJose E. Roman Output Parameters: 272595cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 272695cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2727c371a6d1SMatthew G. Knepley 2728c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2729c371a6d1SMatthew G. Knepley 2730c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2731c371a6d1SMatthew G. Knepley 2732c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2733c371a6d1SMatthew G. Knepley . t - current time 2734c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2735c371a6d1SMatthew G. Knepley . Nc - the number of field components 2736c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2737c371a6d1SMatthew G. Knepley - ctx - a user context 2738c371a6d1SMatthew G. Knepley 2739c371a6d1SMatthew G. Knepley Level: intermediate 2740c371a6d1SMatthew G. Knepley 2741f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolution(), PetscDSGetExactSolutionTimeDerivative() 2742c371a6d1SMatthew G. Knepley @*/ 274395cbbfd3SMatthew 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) 2744c371a6d1SMatthew G. Knepley { 2745c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2746c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 274763a3b9bcSJacob 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); 2748c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 274995cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2750c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2751c371a6d1SMatthew G. Knepley } 2752c371a6d1SMatthew G. Knepley 2753c371a6d1SMatthew G. Knepley /*@C 2754578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2755c371a6d1SMatthew G. Knepley 2756c371a6d1SMatthew G. Knepley Not collective 2757c371a6d1SMatthew G. Knepley 2758c371a6d1SMatthew G. Knepley Input Parameters: 2759c371a6d1SMatthew G. Knepley + prob - The PetscDS 2760c371a6d1SMatthew G. Knepley . f - The test field number 276195cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 276295cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2763c371a6d1SMatthew G. Knepley 2764c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2765c371a6d1SMatthew G. Knepley 2766c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2767c371a6d1SMatthew G. Knepley 2768c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2769c371a6d1SMatthew G. Knepley . t - current time 2770c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2771c371a6d1SMatthew G. Knepley . Nc - the number of field components 2772c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2773c371a6d1SMatthew G. Knepley - ctx - a user context 2774c371a6d1SMatthew G. Knepley 2775c371a6d1SMatthew G. Knepley Level: intermediate 2776c371a6d1SMatthew G. Knepley 2777c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2778c371a6d1SMatthew G. Knepley @*/ 277995cbbfd3SMatthew 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) 2780c371a6d1SMatthew G. Knepley { 2781c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2782c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 278363a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 27849566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 2785c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 278695cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2787c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2788c371a6d1SMatthew G. Knepley } 2789c371a6d1SMatthew G. Knepley 27905638fd0eSMatthew G. Knepley /*@C 2791f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2792f2cacb80SMatthew G. Knepley 2793f2cacb80SMatthew G. Knepley Not collective 2794f2cacb80SMatthew G. Knepley 2795f2cacb80SMatthew G. Knepley Input Parameters: 2796f2cacb80SMatthew G. Knepley + prob - The PetscDS 2797f2cacb80SMatthew G. Knepley - f - The test field number 2798f2cacb80SMatthew G. Knepley 2799d8d19677SJose E. Roman Output Parameters: 2800f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2801f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2802f2cacb80SMatthew G. Knepley 2803f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2804f2cacb80SMatthew G. Knepley 2805f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2806f2cacb80SMatthew G. Knepley 2807f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2808f2cacb80SMatthew G. Knepley . t - current time 2809f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2810f2cacb80SMatthew G. Knepley . Nc - the number of field components 2811f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2812f2cacb80SMatthew G. Knepley - ctx - a user context 2813f2cacb80SMatthew G. Knepley 2814f2cacb80SMatthew G. Knepley Level: intermediate 2815f2cacb80SMatthew G. Knepley 2816f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolutionTimeDerivative(), PetscDSGetExactSolution() 2817f2cacb80SMatthew G. Knepley @*/ 2818f2cacb80SMatthew 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) 2819f2cacb80SMatthew G. Knepley { 2820f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2821f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 282263a3b9bcSJacob 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); 2823f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2824f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2825f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2826f2cacb80SMatthew G. Knepley } 2827f2cacb80SMatthew G. Knepley 2828f2cacb80SMatthew G. Knepley /*@C 2829f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2830f2cacb80SMatthew G. Knepley 2831f2cacb80SMatthew G. Knepley Not collective 2832f2cacb80SMatthew G. Knepley 2833f2cacb80SMatthew G. Knepley Input Parameters: 2834f2cacb80SMatthew G. Knepley + prob - The PetscDS 2835f2cacb80SMatthew G. Knepley . f - The test field number 2836f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2837f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2838f2cacb80SMatthew G. Knepley 2839f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2840f2cacb80SMatthew G. Knepley 2841f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2842f2cacb80SMatthew G. Knepley 2843f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2844f2cacb80SMatthew G. Knepley . t - current time 2845f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2846f2cacb80SMatthew G. Knepley . Nc - the number of field components 2847f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2848f2cacb80SMatthew G. Knepley - ctx - a user context 2849f2cacb80SMatthew G. Knepley 2850f2cacb80SMatthew G. Knepley Level: intermediate 2851f2cacb80SMatthew G. Knepley 2852f2cacb80SMatthew G. Knepley .seealso: PetscDSGetExactSolutionTimeDerivative(), PetscDSSetExactSolution() 2853f2cacb80SMatthew G. Knepley @*/ 2854f2cacb80SMatthew 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) 2855f2cacb80SMatthew G. Knepley { 2856f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2857f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 285863a3b9bcSJacob Faibussowitsch PetscCheck(f >= 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %" PetscInt_FMT " must be non-negative", f); 28599566063dSJacob Faibussowitsch PetscCall(PetscDSEnlarge_Static(prob, f+1)); 2860f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2861f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2862f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2863f2cacb80SMatthew G. Knepley } 2864f2cacb80SMatthew G. Knepley 2865f2cacb80SMatthew G. Knepley /*@C 286697b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 286797b6e6e8SMatthew G. Knepley 286897b6e6e8SMatthew G. Knepley Not collective 286997b6e6e8SMatthew G. Knepley 287097b6e6e8SMatthew G. Knepley Input Parameter: 287197b6e6e8SMatthew G. Knepley . prob - The PetscDS object 287297b6e6e8SMatthew G. Knepley 287397b6e6e8SMatthew G. Knepley Output Parameters: 287497b6e6e8SMatthew G. Knepley + numConstants - The number of constants 287597b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 287697b6e6e8SMatthew G. Knepley 287797b6e6e8SMatthew G. Knepley Level: intermediate 287897b6e6e8SMatthew G. Knepley 287997b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 288097b6e6e8SMatthew G. Knepley @*/ 288197b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 288297b6e6e8SMatthew G. Knepley { 288397b6e6e8SMatthew G. Knepley PetscFunctionBegin; 288497b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2885dadcf809SJacob Faibussowitsch if (numConstants) {PetscValidIntPointer(numConstants, 2); *numConstants = prob->numConstants;} 288697b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 288797b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 288897b6e6e8SMatthew G. Knepley } 288997b6e6e8SMatthew G. Knepley 28900d3e9b51SMatthew G. Knepley /*@C 289197b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 289297b6e6e8SMatthew G. Knepley 289397b6e6e8SMatthew G. Knepley Not collective 289497b6e6e8SMatthew G. Knepley 289597b6e6e8SMatthew G. Knepley Input Parameters: 289697b6e6e8SMatthew G. Knepley + prob - The PetscDS object 289797b6e6e8SMatthew G. Knepley . numConstants - The number of constants 289897b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 289997b6e6e8SMatthew G. Knepley 290097b6e6e8SMatthew G. Knepley Level: intermediate 290197b6e6e8SMatthew G. Knepley 290297b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 290397b6e6e8SMatthew G. Knepley @*/ 290497b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 290597b6e6e8SMatthew G. Knepley { 290697b6e6e8SMatthew G. Knepley PetscFunctionBegin; 290797b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 290897b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 29099566063dSJacob Faibussowitsch PetscCall(PetscFree(prob->constants)); 291097b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 291197b6e6e8SMatthew G. Knepley if (prob->numConstants) { 29129566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(prob->numConstants, &prob->constants)); 291320be0f5bSMatthew G. Knepley } else { 291420be0f5bSMatthew G. Knepley prob->constants = NULL; 291520be0f5bSMatthew G. Knepley } 291620be0f5bSMatthew G. Knepley } 291720be0f5bSMatthew G. Knepley if (prob->numConstants) { 2918dadcf809SJacob Faibussowitsch PetscValidScalarPointer(constants, 3); 29199566063dSJacob Faibussowitsch PetscCall(PetscArraycpy(prob->constants, constants, prob->numConstants)); 292097b6e6e8SMatthew G. Knepley } 292197b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 292297b6e6e8SMatthew G. Knepley } 292397b6e6e8SMatthew G. Knepley 29244cd1e086SMatthew G. Knepley /*@ 29254cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 29264cd1e086SMatthew G. Knepley 29274cd1e086SMatthew G. Knepley Not collective 29284cd1e086SMatthew G. Knepley 29294cd1e086SMatthew G. Knepley Input Parameters: 29304cd1e086SMatthew G. Knepley + prob - The PetscDS object 29314cd1e086SMatthew G. Knepley - disc - The discretization object 29324cd1e086SMatthew G. Knepley 29334cd1e086SMatthew G. Knepley Output Parameter: 29344cd1e086SMatthew G. Knepley . f - The field number 29354cd1e086SMatthew G. Knepley 29364cd1e086SMatthew G. Knepley Level: beginner 29374cd1e086SMatthew G. Knepley 2938f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 29394cd1e086SMatthew G. Knepley @*/ 29404cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 29414cd1e086SMatthew G. Knepley { 29424cd1e086SMatthew G. Knepley PetscInt g; 29434cd1e086SMatthew G. Knepley 29444cd1e086SMatthew G. Knepley PetscFunctionBegin; 29454cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2946dadcf809SJacob Faibussowitsch PetscValidIntPointer(f, 3); 29474cd1e086SMatthew G. Knepley *f = -1; 29484cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 294908401ef6SPierre Jolivet PetscCheck(g != prob->Nf,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 29504cd1e086SMatthew G. Knepley *f = g; 29514cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29524cd1e086SMatthew G. Knepley } 29534cd1e086SMatthew G. Knepley 29544cd1e086SMatthew G. Knepley /*@ 29554cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 29564cd1e086SMatthew G. Knepley 29574cd1e086SMatthew G. Knepley Not collective 29584cd1e086SMatthew G. Knepley 29594cd1e086SMatthew G. Knepley Input Parameters: 29604cd1e086SMatthew G. Knepley + prob - The PetscDS object 29614cd1e086SMatthew G. Knepley - f - The field number 29624cd1e086SMatthew G. Knepley 29634cd1e086SMatthew G. Knepley Output Parameter: 29644cd1e086SMatthew G. Knepley . size - The size 29654cd1e086SMatthew G. Knepley 29664cd1e086SMatthew G. Knepley Level: beginner 29674cd1e086SMatthew G. Knepley 2968f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 29694cd1e086SMatthew G. Knepley @*/ 29704cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 29714cd1e086SMatthew G. Knepley { 29724cd1e086SMatthew G. Knepley PetscFunctionBegin; 29734cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2974dadcf809SJacob Faibussowitsch PetscValidIntPointer(size, 3); 297563a3b9bcSJacob 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); 29769566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 2977d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 29784cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29794cd1e086SMatthew G. Knepley } 29804cd1e086SMatthew G. Knepley 2981bc4ae4beSMatthew G. Knepley /*@ 2982bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2983bc4ae4beSMatthew G. Knepley 2984bc4ae4beSMatthew G. Knepley Not collective 2985bc4ae4beSMatthew G. Knepley 2986bc4ae4beSMatthew G. Knepley Input Parameters: 2987bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2988bc4ae4beSMatthew G. Knepley - f - The field number 2989bc4ae4beSMatthew G. Knepley 2990bc4ae4beSMatthew G. Knepley Output Parameter: 2991bc4ae4beSMatthew G. Knepley . off - The offset 2992bc4ae4beSMatthew G. Knepley 2993bc4ae4beSMatthew G. Knepley Level: beginner 2994bc4ae4beSMatthew G. Knepley 2995f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2996bc4ae4beSMatthew G. Knepley @*/ 29972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 29982764a2aaSMatthew G. Knepley { 29994cd1e086SMatthew G. Knepley PetscInt size, g; 30002764a2aaSMatthew G. Knepley 30012764a2aaSMatthew G. Knepley PetscFunctionBegin; 30022764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3003dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 300463a3b9bcSJacob 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); 30052764a2aaSMatthew G. Knepley *off = 0; 30062764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 30079566063dSJacob Faibussowitsch PetscCall(PetscDSGetFieldSize(prob, g, &size)); 30084cd1e086SMatthew G. Knepley *off += size; 30092764a2aaSMatthew G. Knepley } 30102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30112764a2aaSMatthew G. Knepley } 30122764a2aaSMatthew G. Knepley 3013bc4ae4beSMatthew G. Knepley /*@ 30145fedec97SMatthew G. Knepley PetscDSGetFieldOffsetCohesive - Returns the offset of the given field in the full space basis on a cohesive cell 30155fedec97SMatthew G. Knepley 30165fedec97SMatthew G. Knepley Not collective 30175fedec97SMatthew G. Knepley 30185fedec97SMatthew G. Knepley Input Parameters: 30195fedec97SMatthew G. Knepley + prob - The PetscDS object 30205fedec97SMatthew G. Knepley - f - The field number 30215fedec97SMatthew G. Knepley 30225fedec97SMatthew G. Knepley Output Parameter: 30235fedec97SMatthew G. Knepley . off - The offset 30245fedec97SMatthew G. Knepley 30255fedec97SMatthew G. Knepley Level: beginner 30265fedec97SMatthew G. Knepley 30275fedec97SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 30285fedec97SMatthew G. Knepley @*/ 30295fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffsetCohesive(PetscDS ds, PetscInt f, PetscInt *off) 30305fedec97SMatthew G. Knepley { 30315fedec97SMatthew G. Knepley PetscInt size, g; 30325fedec97SMatthew G. Knepley 30335fedec97SMatthew G. Knepley PetscFunctionBegin; 30345fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3035dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 303663a3b9bcSJacob 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); 30375fedec97SMatthew G. Knepley *off = 0; 30385fedec97SMatthew G. Knepley for (g = 0; g < f; ++g) { 30395fedec97SMatthew G. Knepley PetscBool cohesive; 30405fedec97SMatthew G. Knepley 30419566063dSJacob Faibussowitsch PetscCall(PetscDSGetCohesive(ds, g, &cohesive)); 30429566063dSJacob Faibussowitsch PetscCall(PetscDSGetFieldSize(ds, g, &size)); 30435fedec97SMatthew G. Knepley *off += cohesive ? size : size*2; 30445fedec97SMatthew G. Knepley } 30455fedec97SMatthew G. Knepley PetscFunctionReturn(0); 30465fedec97SMatthew G. Knepley } 30475fedec97SMatthew G. Knepley 30485fedec97SMatthew G. Knepley /*@ 304947e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 3050bc4ae4beSMatthew G. Knepley 3051bc4ae4beSMatthew G. Knepley Not collective 3052bc4ae4beSMatthew G. Knepley 305347e57110SSander Arens Input Parameter: 305447e57110SSander Arens . prob - The PetscDS object 3055bc4ae4beSMatthew G. Knepley 3056bc4ae4beSMatthew G. Knepley Output Parameter: 305747e57110SSander Arens . dimensions - The number of dimensions 3058bc4ae4beSMatthew G. Knepley 3059bc4ae4beSMatthew G. Knepley Level: beginner 3060bc4ae4beSMatthew G. Knepley 306147e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 3062bc4ae4beSMatthew G. Knepley @*/ 306347e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 30642764a2aaSMatthew G. Knepley { 30652764a2aaSMatthew G. Knepley PetscFunctionBegin; 30662764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30679566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 306847e57110SSander Arens PetscValidPointer(dimensions, 2); 306947e57110SSander Arens *dimensions = prob->Nb; 307047e57110SSander Arens PetscFunctionReturn(0); 30716ce16762SMatthew G. Knepley } 307247e57110SSander Arens 307347e57110SSander Arens /*@ 307447e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 307547e57110SSander Arens 307647e57110SSander Arens Not collective 307747e57110SSander Arens 307847e57110SSander Arens Input Parameter: 307947e57110SSander Arens . prob - The PetscDS object 308047e57110SSander Arens 308147e57110SSander Arens Output Parameter: 308247e57110SSander Arens . components - The number of components 308347e57110SSander Arens 308447e57110SSander Arens Level: beginner 308547e57110SSander Arens 308647e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 308747e57110SSander Arens @*/ 308847e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 308947e57110SSander Arens { 309047e57110SSander Arens PetscFunctionBegin; 309147e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30929566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 309347e57110SSander Arens PetscValidPointer(components, 2); 309447e57110SSander Arens *components = prob->Nc; 30956ce16762SMatthew G. Knepley PetscFunctionReturn(0); 30966ce16762SMatthew G. Knepley } 30976ce16762SMatthew G. Knepley 30986ce16762SMatthew G. Knepley /*@ 30996ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 31006ce16762SMatthew G. Knepley 31016ce16762SMatthew G. Knepley Not collective 31026ce16762SMatthew G. Knepley 31036ce16762SMatthew G. Knepley Input Parameters: 31046ce16762SMatthew G. Knepley + prob - The PetscDS object 31056ce16762SMatthew G. Knepley - f - The field number 31066ce16762SMatthew G. Knepley 31076ce16762SMatthew G. Knepley Output Parameter: 31086ce16762SMatthew G. Knepley . off - The offset 31096ce16762SMatthew G. Knepley 31106ce16762SMatthew G. Knepley Level: beginner 31116ce16762SMatthew G. Knepley 3112f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 31136ce16762SMatthew G. Knepley @*/ 31146ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 31156ce16762SMatthew G. Knepley { 31166ce16762SMatthew G. Knepley PetscFunctionBegin; 31176ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3118dadcf809SJacob Faibussowitsch PetscValidIntPointer(off, 3); 311963a3b9bcSJacob 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); 31209566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 312147e57110SSander Arens *off = prob->off[f]; 31222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31232764a2aaSMatthew G. Knepley } 31242764a2aaSMatthew G. Knepley 3125194d53e6SMatthew G. Knepley /*@ 3126194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 3127194d53e6SMatthew G. Knepley 3128194d53e6SMatthew G. Knepley Not collective 3129194d53e6SMatthew G. Knepley 3130194d53e6SMatthew G. Knepley Input Parameter: 3131194d53e6SMatthew G. Knepley . prob - The PetscDS object 3132194d53e6SMatthew G. Knepley 3133194d53e6SMatthew G. Knepley Output Parameter: 3134194d53e6SMatthew G. Knepley . offsets - The offsets 3135194d53e6SMatthew G. Knepley 3136194d53e6SMatthew G. Knepley Level: beginner 3137194d53e6SMatthew G. Knepley 3138f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3139194d53e6SMatthew G. Knepley @*/ 3140194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 3141194d53e6SMatthew G. Knepley { 3142194d53e6SMatthew G. Knepley PetscFunctionBegin; 3143194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3144194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31459566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3146194d53e6SMatthew G. Knepley *offsets = prob->off; 3147194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3148194d53e6SMatthew G. Knepley } 3149194d53e6SMatthew G. Knepley 3150194d53e6SMatthew G. Knepley /*@ 3151194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 3152194d53e6SMatthew G. Knepley 3153194d53e6SMatthew G. Knepley Not collective 3154194d53e6SMatthew G. Knepley 3155194d53e6SMatthew G. Knepley Input Parameter: 3156194d53e6SMatthew G. Knepley . prob - The PetscDS object 3157194d53e6SMatthew G. Knepley 3158194d53e6SMatthew G. Knepley Output Parameter: 3159194d53e6SMatthew G. Knepley . offsets - The offsets 3160194d53e6SMatthew G. Knepley 3161194d53e6SMatthew G. Knepley Level: beginner 3162194d53e6SMatthew G. Knepley 3163f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3164194d53e6SMatthew G. Knepley @*/ 3165194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 3166194d53e6SMatthew G. Knepley { 3167194d53e6SMatthew G. Knepley PetscFunctionBegin; 3168194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3169194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31709566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3171194d53e6SMatthew G. Knepley *offsets = prob->offDer; 3172194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3173194d53e6SMatthew G. Knepley } 3174194d53e6SMatthew G. Knepley 31759ee2af8cSMatthew G. Knepley /*@ 31769ee2af8cSMatthew G. Knepley PetscDSGetComponentOffsetsCohesive - Returns the offset of each field on an evaluation point 31779ee2af8cSMatthew G. Knepley 31789ee2af8cSMatthew G. Knepley Not collective 31799ee2af8cSMatthew G. Knepley 31809ee2af8cSMatthew G. Knepley Input Parameters: 31819ee2af8cSMatthew G. Knepley + ds - The PetscDS object 31829ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 31839ee2af8cSMatthew G. Knepley 31849ee2af8cSMatthew G. Knepley Output Parameter: 31859ee2af8cSMatthew G. Knepley . offsets - The offsets 31869ee2af8cSMatthew G. Knepley 31879ee2af8cSMatthew G. Knepley Level: beginner 31889ee2af8cSMatthew G. Knepley 31899ee2af8cSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 31909ee2af8cSMatthew G. Knepley @*/ 31919ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 31929ee2af8cSMatthew G. Knepley { 31939ee2af8cSMatthew G. Knepley PetscFunctionBegin; 31949ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 31959ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 319628b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 319763a3b9bcSJacob Faibussowitsch PetscCheck(!(s < 0) && !(s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %" PetscInt_FMT " is not in [0, 2]", s); 31989566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(ds)); 31999ee2af8cSMatthew G. Knepley *offsets = ds->offCohesive[s]; 32009ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32019ee2af8cSMatthew G. Knepley } 32029ee2af8cSMatthew G. Knepley 32039ee2af8cSMatthew G. Knepley /*@ 32049ee2af8cSMatthew G. Knepley PetscDSGetComponentDerivativeOffsetsCohesive - Returns the offset of each field derivative on an evaluation point 32059ee2af8cSMatthew G. Knepley 32069ee2af8cSMatthew G. Knepley Not collective 32079ee2af8cSMatthew G. Knepley 32089ee2af8cSMatthew G. Knepley Input Parameters: 32099ee2af8cSMatthew G. Knepley + ds - The PetscDS object 32109ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 32119ee2af8cSMatthew G. Knepley 32129ee2af8cSMatthew G. Knepley Output Parameter: 32139ee2af8cSMatthew G. Knepley . offsets - The offsets 32149ee2af8cSMatthew G. Knepley 32159ee2af8cSMatthew G. Knepley Level: beginner 32169ee2af8cSMatthew G. Knepley 32179ee2af8cSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 32189ee2af8cSMatthew G. Knepley @*/ 32199ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 32209ee2af8cSMatthew G. Knepley { 32219ee2af8cSMatthew G. Knepley PetscFunctionBegin; 32229ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 32239ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 322428b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 322563a3b9bcSJacob Faibussowitsch PetscCheck(!(s < 0) && !(s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %" PetscInt_FMT " is not in [0, 2]", s); 32269566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(ds)); 32279ee2af8cSMatthew G. Knepley *offsets = ds->offDerCohesive[s]; 32289ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32299ee2af8cSMatthew G. Knepley } 32309ee2af8cSMatthew G. Knepley 323168c9edb9SMatthew G. Knepley /*@C 323268c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 323368c9edb9SMatthew G. Knepley 323468c9edb9SMatthew G. Knepley Not collective 323568c9edb9SMatthew G. Knepley 323668c9edb9SMatthew G. Knepley Input Parameter: 323768c9edb9SMatthew G. Knepley . prob - The PetscDS object 323868c9edb9SMatthew G. Knepley 3239ef0bb6c7SMatthew G. Knepley Output Parameter: 3240ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 324168c9edb9SMatthew G. Knepley 324268c9edb9SMatthew G. Knepley Level: intermediate 324368c9edb9SMatthew G. Knepley 3244f744cafaSSander Arens .seealso: PetscDSCreate() 324568c9edb9SMatthew G. Knepley @*/ 3246ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 32472764a2aaSMatthew G. Knepley { 32482764a2aaSMatthew G. Knepley PetscFunctionBegin; 32492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3250ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 32519566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3252ef0bb6c7SMatthew G. Knepley *T = prob->T; 32532764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32542764a2aaSMatthew G. Knepley } 32552764a2aaSMatthew G. Knepley 325668c9edb9SMatthew G. Knepley /*@C 32574d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 325868c9edb9SMatthew G. Knepley 325968c9edb9SMatthew G. Knepley Not collective 326068c9edb9SMatthew G. Knepley 326168c9edb9SMatthew G. Knepley Input Parameter: 326268c9edb9SMatthew G. Knepley . prob - The PetscDS object 326368c9edb9SMatthew G. Knepley 3264ef0bb6c7SMatthew G. Knepley Output Parameter: 3265a5b23f4aSJose E. Roman . Tf - The basis function and derivative tabulation on each local face at quadrature points for each and field 326668c9edb9SMatthew G. Knepley 326768c9edb9SMatthew G. Knepley Level: intermediate 326868c9edb9SMatthew G. Knepley 326968c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 327068c9edb9SMatthew G. Knepley @*/ 3271ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 32722764a2aaSMatthew G. Knepley { 32732764a2aaSMatthew G. Knepley PetscFunctionBegin; 32742764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3275ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 32769566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 3277ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 32782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32792764a2aaSMatthew G. Knepley } 32802764a2aaSMatthew G. Knepley 32812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 32822764a2aaSMatthew G. Knepley { 32832764a2aaSMatthew G. Knepley PetscFunctionBegin; 32842764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32859566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 32862764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 32872764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 32882764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 32892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32902764a2aaSMatthew G. Knepley } 32912764a2aaSMatthew G. Knepley 32922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 32932764a2aaSMatthew G. Knepley { 32942764a2aaSMatthew G. Knepley PetscFunctionBegin; 32952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32969566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 32972764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 32982764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 32992764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 33002764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 33012764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 33022764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 33032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33042764a2aaSMatthew G. Knepley } 33052764a2aaSMatthew G. Knepley 33064bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 33072764a2aaSMatthew G. Knepley { 33082764a2aaSMatthew G. Knepley PetscFunctionBegin; 33092764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33109566063dSJacob Faibussowitsch PetscCall(PetscDSSetUp(prob)); 33112764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 33124bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 33137506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 33147506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 33157506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 33162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33172764a2aaSMatthew G. Knepley } 33182764a2aaSMatthew G. Knepley 331958ebd649SToby Isaac /*@C 332056cf3b9cSMatthew G. Knepley 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 performaed, using the kernels from PetscDSSetBdResidual(). 332158ebd649SToby Isaac 3322783e2ec8SMatthew G. Knepley Collective on ds 3323783e2ec8SMatthew G. Knepley 332458ebd649SToby Isaac Input Parameters: 332558ebd649SToby Isaac + ds - The PetscDS object 33262d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 332758ebd649SToby Isaac . name - The BC name 332845480ffeSMatthew G. Knepley . label - The label defining constrained points 332945480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 333045480ffeSMatthew G. Knepley . values - An array of label values for constrained points 333158ebd649SToby Isaac . field - The field to constrain 333245480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 333358ebd649SToby Isaac . comps - An array of constrained component numbers 333458ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3335a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 333658ebd649SToby Isaac - ctx - An optional user context for bcFunc 333758ebd649SToby Isaac 333845480ffeSMatthew G. Knepley Output Parameters: 333945480ffeSMatthew G. Knepley - bd - The boundary number 334045480ffeSMatthew G. Knepley 334158ebd649SToby Isaac Options Database Keys: 334258ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 334358ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 334458ebd649SToby Isaac 334556cf3b9cSMatthew G. Knepley Note: 334656cf3b9cSMatthew 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: 334756cf3b9cSMatthew G. Knepley 334856cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 334956cf3b9cSMatthew G. Knepley 335056cf3b9cSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 335156cf3b9cSMatthew G. Knepley 335256cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 335356cf3b9cSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 335456cf3b9cSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 335556cf3b9cSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 335656cf3b9cSMatthew G. Knepley 335756cf3b9cSMatthew G. Knepley + dim - the spatial dimension 335856cf3b9cSMatthew G. Knepley . Nf - the number of fields 335956cf3b9cSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 336056cf3b9cSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 336156cf3b9cSMatthew G. Knepley . u - each field evaluated at the current point 336256cf3b9cSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 336356cf3b9cSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 336456cf3b9cSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 336556cf3b9cSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 336656cf3b9cSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 336756cf3b9cSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 336856cf3b9cSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 336956cf3b9cSMatthew G. Knepley . t - current time 337056cf3b9cSMatthew G. Knepley . x - coordinates of the current point 337156cf3b9cSMatthew G. Knepley . numConstants - number of constant parameters 337256cf3b9cSMatthew G. Knepley . constants - constant parameters 337356cf3b9cSMatthew G. Knepley - bcval - output values at the current point 337456cf3b9cSMatthew G. Knepley 337558ebd649SToby Isaac Level: developer 337658ebd649SToby Isaac 337745480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundaryByName(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 337858ebd649SToby Isaac @*/ 337945480ffeSMatthew 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) 338058ebd649SToby Isaac { 338145480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 338245480ffeSMatthew G. Knepley PetscInt n = 0; 338345480ffeSMatthew G. Knepley const char *lname; 338458ebd649SToby Isaac 338558ebd649SToby Isaac PetscFunctionBegin; 338658ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3387783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 338845480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 338945480ffeSMatthew G. Knepley PetscValidHeaderSpecific(label, DMLABEL_CLASSID, 4); 339045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 339145480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 339245480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 3393d57bb9dbSMatthew G. Knepley if (Nc > 0) { 3394d57bb9dbSMatthew G. Knepley PetscInt *fcomps; 3395d57bb9dbSMatthew G. Knepley PetscInt c; 3396d57bb9dbSMatthew G. Knepley 33979566063dSJacob Faibussowitsch PetscCall(PetscDSGetComponents(ds, &fcomps)); 339863a3b9bcSJacob 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); 3399d57bb9dbSMatthew G. Knepley for (c = 0; c < Nc; ++c) { 3400*1dca8a05SBarry 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); 3401d57bb9dbSMatthew G. Knepley } 3402d57bb9dbSMatthew G. Knepley } 34039566063dSJacob Faibussowitsch PetscCall(PetscNew(&b)); 34049566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 34059566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 34069566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 34079566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 34089566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 34099566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 34109566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 34119566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName((PetscObject) label, &lname)); 34129566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(lname, (char **) &b->lname)); 3413f971fd6bSMatthew G. Knepley b->type = type; 341445480ffeSMatthew G. Knepley b->label = label; 341545480ffeSMatthew G. Knepley b->Nv = Nv; 341658ebd649SToby Isaac b->field = field; 341745480ffeSMatthew G. Knepley b->Nc = Nc; 341858ebd649SToby Isaac b->func = bcFunc; 341956cf3b9cSMatthew G. Knepley b->func_t = bcFunc_t; 342058ebd649SToby Isaac b->ctx = ctx; 342145480ffeSMatthew G. Knepley b->next = NULL; 342245480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 342345480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 342445480ffeSMatthew G. Knepley while (head) { 342545480ffeSMatthew G. Knepley if (!head->next) { 342645480ffeSMatthew G. Knepley head->next = b; 342745480ffeSMatthew G. Knepley head = b; 342845480ffeSMatthew G. Knepley } 342945480ffeSMatthew G. Knepley head = head->next; 343045480ffeSMatthew G. Knepley ++n; 343145480ffeSMatthew G. Knepley } 3432064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 343345480ffeSMatthew G. Knepley PetscFunctionReturn(0); 343445480ffeSMatthew G. Knepley } 343545480ffeSMatthew G. Knepley 343645480ffeSMatthew G. Knepley /*@C 343745480ffeSMatthew G. Knepley 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 performaed, using the kernels from PetscDSSetBdResidual(). 343845480ffeSMatthew G. Knepley 343945480ffeSMatthew G. Knepley Collective on ds 344045480ffeSMatthew G. Knepley 344145480ffeSMatthew G. Knepley Input Parameters: 344245480ffeSMatthew G. Knepley + ds - The PetscDS object 344345480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 344445480ffeSMatthew G. Knepley . name - The BC name 344545480ffeSMatthew G. Knepley . lname - The naem of the label defining constrained points 344645480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 344745480ffeSMatthew G. Knepley . values - An array of label values for constrained points 344845480ffeSMatthew G. Knepley . field - The field to constrain 344945480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 345045480ffeSMatthew G. Knepley . comps - An array of constrained component numbers 345145480ffeSMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3452a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 345345480ffeSMatthew G. Knepley - ctx - An optional user context for bcFunc 345445480ffeSMatthew G. Knepley 345545480ffeSMatthew G. Knepley Output Parameters: 345645480ffeSMatthew G. Knepley - bd - The boundary number 345745480ffeSMatthew G. Knepley 345845480ffeSMatthew G. Knepley Options Database Keys: 345945480ffeSMatthew G. Knepley + -bc_<boundary name> <num> - Overrides the boundary ids 346045480ffeSMatthew G. Knepley - -bc_<boundary name>_comp <num> - Overrides the boundary components 346145480ffeSMatthew G. Knepley 346245480ffeSMatthew G. Knepley Note: 346345480ffeSMatthew G. Knepley This function should only be used with DMForest currently, since labels cannot be defined before the underlygin Plex is built. 346445480ffeSMatthew G. Knepley 346545480ffeSMatthew 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: 346645480ffeSMatthew G. Knepley 346745480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 346845480ffeSMatthew G. Knepley 346945480ffeSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 347045480ffeSMatthew G. Knepley 347145480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 347245480ffeSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 347345480ffeSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 347445480ffeSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 347545480ffeSMatthew G. Knepley 347645480ffeSMatthew G. Knepley + dim - the spatial dimension 347745480ffeSMatthew G. Knepley . Nf - the number of fields 347845480ffeSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 347945480ffeSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 348045480ffeSMatthew G. Knepley . u - each field evaluated at the current point 348145480ffeSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 348245480ffeSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 348345480ffeSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 348445480ffeSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 348545480ffeSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 348645480ffeSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 348745480ffeSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 348845480ffeSMatthew G. Knepley . t - current time 348945480ffeSMatthew G. Knepley . x - coordinates of the current point 349045480ffeSMatthew G. Knepley . numConstants - number of constant parameters 349145480ffeSMatthew G. Knepley . constants - constant parameters 349245480ffeSMatthew G. Knepley - bcval - output values at the current point 349345480ffeSMatthew G. Knepley 349445480ffeSMatthew G. Knepley Level: developer 349545480ffeSMatthew G. Knepley 349645480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 349745480ffeSMatthew G. Knepley @*/ 349845480ffeSMatthew 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) 349945480ffeSMatthew G. Knepley { 350045480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 350145480ffeSMatthew G. Knepley PetscInt n = 0; 350245480ffeSMatthew G. Knepley 350345480ffeSMatthew G. Knepley PetscFunctionBegin; 350445480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 350545480ffeSMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 350645480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 350745480ffeSMatthew G. Knepley PetscValidCharPointer(lname, 4); 350845480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 350945480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 351045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 35119566063dSJacob Faibussowitsch PetscCall(PetscNew(&b)); 35129566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 35139566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 35149566063dSJacob Faibussowitsch PetscCall(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 35159566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 35169566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 35179566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 35189566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 35199566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(lname, (char **) &b->lname)); 352045480ffeSMatthew G. Knepley b->type = type; 352145480ffeSMatthew G. Knepley b->label = NULL; 352245480ffeSMatthew G. Knepley b->Nv = Nv; 352345480ffeSMatthew G. Knepley b->field = field; 352445480ffeSMatthew G. Knepley b->Nc = Nc; 352545480ffeSMatthew G. Knepley b->func = bcFunc; 352645480ffeSMatthew G. Knepley b->func_t = bcFunc_t; 352745480ffeSMatthew G. Knepley b->ctx = ctx; 352845480ffeSMatthew G. Knepley b->next = NULL; 352945480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 353045480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 353145480ffeSMatthew G. Knepley while (head) { 353245480ffeSMatthew G. Knepley if (!head->next) { 353345480ffeSMatthew G. Knepley head->next = b; 353445480ffeSMatthew G. Knepley head = b; 353545480ffeSMatthew G. Knepley } 353645480ffeSMatthew G. Knepley head = head->next; 353745480ffeSMatthew G. Knepley ++n; 353845480ffeSMatthew G. Knepley } 3539064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 354058ebd649SToby Isaac PetscFunctionReturn(0); 354158ebd649SToby Isaac } 354258ebd649SToby Isaac 3543b67eacb3SMatthew G. Knepley /*@C 354456cf3b9cSMatthew G. Knepley 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 performaed, using the kernels from PetscDSSetBdResidual(). 3545b67eacb3SMatthew G. Knepley 3546b67eacb3SMatthew G. Knepley Input Parameters: 3547b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3548b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3549b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3550b67eacb3SMatthew G. Knepley . name - The BC name 355145480ffeSMatthew G. Knepley . label - The label defining constrained points 355245480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 355345480ffeSMatthew G. Knepley . values - An array of ids for constrained points 3554b67eacb3SMatthew G. Knepley . field - The field to constrain 355545480ffeSMatthew G. Knepley . Nc - The number of constrained field components 3556b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3557b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3558a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 3559b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3560b67eacb3SMatthew G. Knepley 356156cf3b9cSMatthew G. Knepley Note: 356256cf3b9cSMatthew 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. 35639a6efb6aSMatthew G. Knepley 3564b67eacb3SMatthew G. Knepley Level: developer 3565b67eacb3SMatthew G. Knepley 35669a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3567b67eacb3SMatthew G. Knepley @*/ 356845480ffeSMatthew 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) 3569b67eacb3SMatthew G. Knepley { 3570b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3571b67eacb3SMatthew G. Knepley PetscInt n = 0; 3572b67eacb3SMatthew G. Knepley 3573b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3574b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3575b67eacb3SMatthew G. Knepley while (b) { 3576b67eacb3SMatthew G. Knepley if (n == bd) break; 3577b67eacb3SMatthew G. Knepley b = b->next; 3578b67eacb3SMatthew G. Knepley ++n; 3579b67eacb3SMatthew G. Knepley } 358063a3b9bcSJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %" PetscInt_FMT " is not in [0, %" PetscInt_FMT ")", bd, n); 3581b67eacb3SMatthew G. Knepley if (name) { 35829566063dSJacob Faibussowitsch PetscCall(PetscFree(b->name)); 35839566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->name)); 3584b67eacb3SMatthew G. Knepley } 3585b67eacb3SMatthew G. Knepley b->type = type; 358645480ffeSMatthew G. Knepley if (label) { 358745480ffeSMatthew G. Knepley const char *name; 358845480ffeSMatthew G. Knepley 358945480ffeSMatthew G. Knepley b->label = label; 35909566063dSJacob Faibussowitsch PetscCall(PetscFree(b->lname)); 35919566063dSJacob Faibussowitsch PetscCall(PetscObjectGetName((PetscObject) label, &name)); 35929566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(name, (char **) &b->lname)); 359345480ffeSMatthew G. Knepley } 359445480ffeSMatthew G. Knepley if (Nv >= 0) { 359545480ffeSMatthew G. Knepley b->Nv = Nv; 35969566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 35979566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nv, &b->values)); 35989566063dSJacob Faibussowitsch if (Nv) PetscCall(PetscArraycpy(b->values, values, Nv)); 359945480ffeSMatthew G. Knepley } 360045480ffeSMatthew G. Knepley if (field >= 0) b->field = field; 360145480ffeSMatthew G. Knepley if (Nc >= 0) { 360245480ffeSMatthew G. Knepley b->Nc = Nc; 36039566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 36049566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(Nc, &b->comps)); 36059566063dSJacob Faibussowitsch if (Nc) PetscCall(PetscArraycpy(b->comps, comps, Nc)); 360645480ffeSMatthew G. Knepley } 360745480ffeSMatthew G. Knepley if (bcFunc) b->func = bcFunc; 360845480ffeSMatthew G. Knepley if (bcFunc_t) b->func_t = bcFunc_t; 360945480ffeSMatthew G. Knepley if (ctx) b->ctx = ctx; 3610b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3611b67eacb3SMatthew G. Knepley } 3612b67eacb3SMatthew G. Knepley 361358ebd649SToby Isaac /*@ 361458ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 361558ebd649SToby Isaac 361658ebd649SToby Isaac Input Parameters: 361758ebd649SToby Isaac . ds - The PetscDS object 361858ebd649SToby Isaac 361958ebd649SToby Isaac Output Parameters: 362058ebd649SToby Isaac . numBd - The number of BC 362158ebd649SToby Isaac 362258ebd649SToby Isaac Level: intermediate 362358ebd649SToby Isaac 362458ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 362558ebd649SToby Isaac @*/ 362658ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 362758ebd649SToby Isaac { 362858ebd649SToby Isaac DSBoundary b = ds->boundary; 362958ebd649SToby Isaac 363058ebd649SToby Isaac PetscFunctionBegin; 363158ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3632dadcf809SJacob Faibussowitsch PetscValidIntPointer(numBd, 2); 363358ebd649SToby Isaac *numBd = 0; 363458ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 363558ebd649SToby Isaac PetscFunctionReturn(0); 363658ebd649SToby Isaac } 363758ebd649SToby Isaac 363858ebd649SToby Isaac /*@C 36399a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 364058ebd649SToby Isaac 364158ebd649SToby Isaac Input Parameters: 364258ebd649SToby Isaac + ds - The PetscDS object 364358ebd649SToby Isaac - bd - The BC number 364458ebd649SToby Isaac 364558ebd649SToby Isaac Output Parameters: 364645480ffeSMatthew G. Knepley + wf - The PetscWeakForm holding the pointwise functions 364745480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 364858ebd649SToby Isaac . name - The BC name 364945480ffeSMatthew G. Knepley . label - The label defining constrained points 365045480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 365145480ffeSMatthew G. Knepley . values - An array of ids for constrained points 365258ebd649SToby Isaac . field - The field to constrain 365345480ffeSMatthew G. Knepley . Nc - The number of constrained field components 365458ebd649SToby Isaac . comps - An array of constrained component numbers 365558ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3656a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values 365758ebd649SToby Isaac - ctx - An optional user context for bcFunc 365858ebd649SToby Isaac 365958ebd649SToby Isaac Options Database Keys: 366058ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 366158ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 366258ebd649SToby Isaac 366358ebd649SToby Isaac Level: developer 366458ebd649SToby Isaac 366558ebd649SToby Isaac .seealso: PetscDSAddBoundary() 366658ebd649SToby Isaac @*/ 366745480ffeSMatthew 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) 366858ebd649SToby Isaac { 366958ebd649SToby Isaac DSBoundary b = ds->boundary; 367058ebd649SToby Isaac PetscInt n = 0; 367158ebd649SToby Isaac 367258ebd649SToby Isaac PetscFunctionBegin; 367358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 367458ebd649SToby Isaac while (b) { 367558ebd649SToby Isaac if (n == bd) break; 367658ebd649SToby Isaac b = b->next; 367758ebd649SToby Isaac ++n; 367858ebd649SToby Isaac } 367963a3b9bcSJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %" PetscInt_FMT " is not in [0, %" PetscInt_FMT ")", bd, n); 368045480ffeSMatthew G. Knepley if (wf) { 368145480ffeSMatthew G. Knepley PetscValidPointer(wf, 3); 368245480ffeSMatthew G. Knepley *wf = b->wf; 368345480ffeSMatthew G. Knepley } 3684f971fd6bSMatthew G. Knepley if (type) { 368545480ffeSMatthew G. Knepley PetscValidPointer(type, 4); 3686f971fd6bSMatthew G. Knepley *type = b->type; 368758ebd649SToby Isaac } 368858ebd649SToby Isaac if (name) { 368945480ffeSMatthew G. Knepley PetscValidPointer(name, 5); 369058ebd649SToby Isaac *name = b->name; 369158ebd649SToby Isaac } 369245480ffeSMatthew G. Knepley if (label) { 369345480ffeSMatthew G. Knepley PetscValidPointer(label, 6); 369445480ffeSMatthew G. Knepley *label = b->label; 369545480ffeSMatthew G. Knepley } 369645480ffeSMatthew G. Knepley if (Nv) { 369745480ffeSMatthew G. Knepley PetscValidIntPointer(Nv, 7); 369845480ffeSMatthew G. Knepley *Nv = b->Nv; 369945480ffeSMatthew G. Knepley } 370045480ffeSMatthew G. Knepley if (values) { 370145480ffeSMatthew G. Knepley PetscValidPointer(values, 8); 370245480ffeSMatthew G. Knepley *values = b->values; 370358ebd649SToby Isaac } 370458ebd649SToby Isaac if (field) { 370545480ffeSMatthew G. Knepley PetscValidIntPointer(field, 9); 370658ebd649SToby Isaac *field = b->field; 370758ebd649SToby Isaac } 370845480ffeSMatthew G. Knepley if (Nc) { 370945480ffeSMatthew G. Knepley PetscValidIntPointer(Nc, 10); 371045480ffeSMatthew G. Knepley *Nc = b->Nc; 371158ebd649SToby Isaac } 371258ebd649SToby Isaac if (comps) { 371345480ffeSMatthew G. Knepley PetscValidPointer(comps, 11); 371458ebd649SToby Isaac *comps = b->comps; 371558ebd649SToby Isaac } 371658ebd649SToby Isaac if (func) { 371745480ffeSMatthew G. Knepley PetscValidPointer(func, 12); 371858ebd649SToby Isaac *func = b->func; 371958ebd649SToby Isaac } 372056cf3b9cSMatthew G. Knepley if (func_t) { 372145480ffeSMatthew G. Knepley PetscValidPointer(func_t, 13); 372256cf3b9cSMatthew G. Knepley *func_t = b->func_t; 372356cf3b9cSMatthew G. Knepley } 372458ebd649SToby Isaac if (ctx) { 372545480ffeSMatthew G. Knepley PetscValidPointer(ctx, 14); 372658ebd649SToby Isaac *ctx = b->ctx; 372758ebd649SToby Isaac } 372858ebd649SToby Isaac PetscFunctionReturn(0); 372958ebd649SToby Isaac } 373058ebd649SToby Isaac 373145480ffeSMatthew G. Knepley static PetscErrorCode DSBoundaryDuplicate_Internal(DSBoundary b, DSBoundary *bNew) 373245480ffeSMatthew G. Knepley { 373345480ffeSMatthew G. Knepley PetscFunctionBegin; 37349566063dSJacob Faibussowitsch PetscCall(PetscNew(bNew)); 37359566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCreate(PETSC_COMM_SELF, &(*bNew)->wf)); 37369566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCopy(b->wf, (*bNew)->wf)); 37379566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(b->name,(char **) &((*bNew)->name))); 37389566063dSJacob Faibussowitsch PetscCall(PetscStrallocpy(b->lname,(char **) &((*bNew)->lname))); 373945480ffeSMatthew G. Knepley (*bNew)->type = b->type; 374045480ffeSMatthew G. Knepley (*bNew)->label = b->label; 374145480ffeSMatthew G. Knepley (*bNew)->Nv = b->Nv; 37429566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(b->Nv, &(*bNew)->values)); 37439566063dSJacob Faibussowitsch PetscCall(PetscArraycpy((*bNew)->values, b->values, b->Nv)); 374445480ffeSMatthew G. Knepley (*bNew)->field = b->field; 374545480ffeSMatthew G. Knepley (*bNew)->Nc = b->Nc; 37469566063dSJacob Faibussowitsch PetscCall(PetscMalloc1(b->Nc, &(*bNew)->comps)); 37479566063dSJacob Faibussowitsch PetscCall(PetscArraycpy((*bNew)->comps, b->comps, b->Nc)); 374845480ffeSMatthew G. Knepley (*bNew)->func = b->func; 374945480ffeSMatthew G. Knepley (*bNew)->func_t = b->func_t; 375045480ffeSMatthew G. Knepley (*bNew)->ctx = b->ctx; 375145480ffeSMatthew G. Knepley PetscFunctionReturn(0); 375245480ffeSMatthew G. Knepley } 375345480ffeSMatthew G. Knepley 37549252d075SMatthew G. Knepley /*@ 37559252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 37569252d075SMatthew G. Knepley 37579252d075SMatthew G. Knepley Not collective 37589252d075SMatthew G. Knepley 375936951cb5SMatthew G. Knepley Input Parameters: 376036951cb5SMatthew G. Knepley + ds - The source PetscDS object 376136951cb5SMatthew G. Knepley . numFields - The number of selected fields, or PETSC_DEFAULT for all fields 376236951cb5SMatthew G. Knepley - fields - The selected fields, or NULL for all fields 37639252d075SMatthew G. Knepley 37649252d075SMatthew G. Knepley Output Parameter: 376536951cb5SMatthew G. Knepley . newds - The target PetscDS, now with a copy of the boundary conditions 37669252d075SMatthew G. Knepley 37679252d075SMatthew G. Knepley Level: intermediate 37689252d075SMatthew G. Knepley 37699252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 37709252d075SMatthew G. Knepley @*/ 377136951cb5SMatthew G. Knepley PetscErrorCode PetscDSCopyBoundary(PetscDS ds, PetscInt numFields, const PetscInt fields[], PetscDS newds) 3772dff059c6SToby Isaac { 377345480ffeSMatthew G. Knepley DSBoundary b, *lastnext; 3774dff059c6SToby Isaac 3775dff059c6SToby Isaac PetscFunctionBegin; 377636951cb5SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 377736951cb5SMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 4); 377836951cb5SMatthew G. Knepley if (ds == newds) PetscFunctionReturn(0); 37799566063dSJacob Faibussowitsch PetscCall(PetscDSDestroyBoundary(newds)); 378036951cb5SMatthew G. Knepley lastnext = &(newds->boundary); 378136951cb5SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 3782dff059c6SToby Isaac DSBoundary bNew; 378336951cb5SMatthew G. Knepley PetscInt fieldNew = -1; 3784dff059c6SToby Isaac 378536951cb5SMatthew G. Knepley if (numFields > 0 && fields) { 378636951cb5SMatthew G. Knepley PetscInt f; 378736951cb5SMatthew G. Knepley 378836951cb5SMatthew G. Knepley for (f = 0; f < numFields; ++f) if (b->field == fields[f]) break; 378936951cb5SMatthew G. Knepley if (f == numFields) continue; 379036951cb5SMatthew G. Knepley fieldNew = f; 379136951cb5SMatthew G. Knepley } 37929566063dSJacob Faibussowitsch PetscCall(DSBoundaryDuplicate_Internal(b, &bNew)); 379336951cb5SMatthew G. Knepley bNew->field = fieldNew < 0 ? b->field : fieldNew; 3794dff059c6SToby Isaac *lastnext = bNew; 3795dff059c6SToby Isaac lastnext = &(bNew->next); 3796dff059c6SToby Isaac } 3797dff059c6SToby Isaac PetscFunctionReturn(0); 3798dff059c6SToby Isaac } 3799dff059c6SToby Isaac 38006c1eb96dSMatthew G. Knepley /*@ 380145480ffeSMatthew G. Knepley PetscDSDestroyBoundary - Remove all DMBoundary objects from the PetscDS 380245480ffeSMatthew G. Knepley 380345480ffeSMatthew G. Knepley Not collective 380445480ffeSMatthew G. Knepley 380545480ffeSMatthew G. Knepley Input Parameter: 380645480ffeSMatthew G. Knepley . ds - The PetscDS object 380745480ffeSMatthew G. Knepley 380845480ffeSMatthew G. Knepley Level: intermediate 380945480ffeSMatthew G. Knepley 381045480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations() 381145480ffeSMatthew G. Knepley @*/ 381245480ffeSMatthew G. Knepley PetscErrorCode PetscDSDestroyBoundary(PetscDS ds) 381345480ffeSMatthew G. Knepley { 381445480ffeSMatthew G. Knepley DSBoundary next = ds->boundary; 381545480ffeSMatthew G. Knepley 381645480ffeSMatthew G. Knepley PetscFunctionBegin; 381745480ffeSMatthew G. Knepley while (next) { 381845480ffeSMatthew G. Knepley DSBoundary b = next; 381945480ffeSMatthew G. Knepley 382045480ffeSMatthew G. Knepley next = b->next; 38219566063dSJacob Faibussowitsch PetscCall(PetscWeakFormDestroy(&b->wf)); 38229566063dSJacob Faibussowitsch PetscCall(PetscFree(b->name)); 38239566063dSJacob Faibussowitsch PetscCall(PetscFree(b->lname)); 38249566063dSJacob Faibussowitsch PetscCall(PetscFree(b->values)); 38259566063dSJacob Faibussowitsch PetscCall(PetscFree(b->comps)); 38269566063dSJacob Faibussowitsch PetscCall(PetscFree(b)); 382745480ffeSMatthew G. Knepley } 382845480ffeSMatthew G. Knepley PetscFunctionReturn(0); 382945480ffeSMatthew G. Knepley } 383045480ffeSMatthew G. Knepley 383145480ffeSMatthew G. Knepley /*@ 38326c1eb96dSMatthew G. Knepley PetscDSSelectDiscretizations - Copy discretizations to the new problem with different field layout 38336c1eb96dSMatthew G. Knepley 38346c1eb96dSMatthew G. Knepley Not collective 38356c1eb96dSMatthew G. Knepley 3836d8d19677SJose E. Roman Input Parameters: 38376c1eb96dSMatthew G. Knepley + prob - The PetscDS object 38386c1eb96dSMatthew G. Knepley . numFields - Number of new fields 38396c1eb96dSMatthew G. Knepley - fields - Old field number for each new field 38406c1eb96dSMatthew G. Knepley 38416c1eb96dSMatthew G. Knepley Output Parameter: 38426c1eb96dSMatthew G. Knepley . newprob - The PetscDS copy 38436c1eb96dSMatthew G. Knepley 38446c1eb96dSMatthew G. Knepley Level: intermediate 38456c1eb96dSMatthew G. Knepley 38466c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectEquations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 38476c1eb96dSMatthew G. Knepley @*/ 38486c1eb96dSMatthew G. Knepley PetscErrorCode PetscDSSelectDiscretizations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38496c1eb96dSMatthew G. Knepley { 38506c1eb96dSMatthew G. Knepley PetscInt Nf, Nfn, fn; 38516c1eb96dSMatthew G. Knepley 38526c1eb96dSMatthew G. Knepley PetscFunctionBegin; 38536c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3854dadcf809SJacob Faibussowitsch if (fields) PetscValidIntPointer(fields, 3); 38556c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38569566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 38579566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Nfn)); 385845480ffeSMatthew G. Knepley numFields = numFields < 0 ? Nf : numFields; 38596c1eb96dSMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38606c1eb96dSMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38616c1eb96dSMatthew G. Knepley PetscObject disc; 38626c1eb96dSMatthew G. Knepley 38636c1eb96dSMatthew G. Knepley if (f >= Nf) continue; 38649566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &disc)); 38659566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(newprob, fn, disc)); 38666c1eb96dSMatthew G. Knepley } 38676c1eb96dSMatthew G. Knepley PetscFunctionReturn(0); 38686c1eb96dSMatthew G. Knepley } 38696c1eb96dSMatthew G. Knepley 38706c1eb96dSMatthew G. Knepley /*@ 38719252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 38729252d075SMatthew G. Knepley 38739252d075SMatthew G. Knepley Not collective 38749252d075SMatthew G. Knepley 3875d8d19677SJose E. Roman Input Parameters: 38769252d075SMatthew G. Knepley + prob - The PetscDS object 38779252d075SMatthew G. Knepley . numFields - Number of new fields 38789252d075SMatthew G. Knepley - fields - Old field number for each new field 38799252d075SMatthew G. Knepley 38809252d075SMatthew G. Knepley Output Parameter: 38819252d075SMatthew G. Knepley . newprob - The PetscDS copy 38829252d075SMatthew G. Knepley 38839252d075SMatthew G. Knepley Level: intermediate 38849252d075SMatthew G. Knepley 38856c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectDiscretizations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 38869252d075SMatthew G. Knepley @*/ 38879252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38889252d075SMatthew G. Knepley { 38899252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 38909252d075SMatthew G. Knepley 38919252d075SMatthew G. Knepley PetscFunctionBegin; 38929252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3893dadcf809SJacob Faibussowitsch if (fields) PetscValidIntPointer(fields, 3); 38949252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38959566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 38969566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Nfn)); 389763a3b9bcSJacob 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); 38989252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38999252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 39009252d075SMatthew G. Knepley PetscPointFunc obj; 39019252d075SMatthew G. Knepley PetscPointFunc f0, f1; 39029252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 39039252d075SMatthew G. Knepley PetscRiemannFunc r; 39049252d075SMatthew G. Knepley 3905c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 39069566063dSJacob Faibussowitsch PetscCall(PetscDSGetObjective(prob, f, &obj)); 39079566063dSJacob Faibussowitsch PetscCall(PetscDSGetResidual(prob, f, &f0, &f1)); 39089566063dSJacob Faibussowitsch PetscCall(PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd)); 39099566063dSJacob Faibussowitsch PetscCall(PetscDSGetRiemannSolver(prob, f, &r)); 39109566063dSJacob Faibussowitsch PetscCall(PetscDSSetObjective(newprob, fn, obj)); 39119566063dSJacob Faibussowitsch PetscCall(PetscDSSetResidual(newprob, fn, f0, f1)); 39129566063dSJacob Faibussowitsch PetscCall(PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd)); 39139566063dSJacob Faibussowitsch PetscCall(PetscDSSetRiemannSolver(newprob, fn, r)); 39149252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 39159252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 39169252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 39179252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 39189252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 39199252d075SMatthew G. Knepley 3920c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 39219566063dSJacob Faibussowitsch PetscCall(PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3)); 39229566063dSJacob Faibussowitsch PetscCall(PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p)); 39239566063dSJacob Faibussowitsch PetscCall(PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd)); 39249566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3)); 39259566063dSJacob Faibussowitsch PetscCall(PetscDSSetJacobianPreconditioner(newprob, fn, gn, g0p, g1p, g2p, g3p)); 39269566063dSJacob Faibussowitsch PetscCall(PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd)); 39279252d075SMatthew G. Knepley } 39289252d075SMatthew G. Knepley } 39299252d075SMatthew G. Knepley PetscFunctionReturn(0); 39309252d075SMatthew G. Knepley } 39319252d075SMatthew G. Knepley 3932da51fcedSMatthew G. Knepley /*@ 3933da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3934da51fcedSMatthew G. Knepley 3935da51fcedSMatthew G. Knepley Not collective 3936da51fcedSMatthew G. Knepley 3937da51fcedSMatthew G. Knepley Input Parameter: 3938da51fcedSMatthew G. Knepley . prob - The PetscDS object 3939da51fcedSMatthew G. Knepley 3940da51fcedSMatthew G. Knepley Output Parameter: 3941da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3942da51fcedSMatthew G. Knepley 3943da51fcedSMatthew G. Knepley Level: intermediate 3944da51fcedSMatthew G. Knepley 39459252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3946da51fcedSMatthew G. Knepley @*/ 3947da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3948da51fcedSMatthew G. Knepley { 3949b8025e53SMatthew G. Knepley PetscWeakForm wf, newwf; 39509252d075SMatthew G. Knepley PetscInt Nf, Ng; 3951da51fcedSMatthew G. Knepley 3952da51fcedSMatthew G. Knepley PetscFunctionBegin; 3953da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3954da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39559566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 39569566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(newprob, &Ng)); 395763a3b9bcSJacob Faibussowitsch PetscCheck(Nf == Ng,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %" PetscInt_FMT " != %" PetscInt_FMT, Nf, Ng); 39589566063dSJacob Faibussowitsch PetscCall(PetscDSGetWeakForm(prob, &wf)); 39599566063dSJacob Faibussowitsch PetscCall(PetscDSGetWeakForm(newprob, &newwf)); 39609566063dSJacob Faibussowitsch PetscCall(PetscWeakFormCopy(wf, newwf)); 39619252d075SMatthew G. Knepley PetscFunctionReturn(0); 39629252d075SMatthew G. Knepley } 396345480ffeSMatthew G. Knepley 39649252d075SMatthew G. Knepley /*@ 39659252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3966da51fcedSMatthew G. Knepley 39679252d075SMatthew G. Knepley Not collective 39689252d075SMatthew G. Knepley 39699252d075SMatthew G. Knepley Input Parameter: 39709252d075SMatthew G. Knepley . prob - The PetscDS object 39719252d075SMatthew G. Knepley 39729252d075SMatthew G. Knepley Output Parameter: 39739252d075SMatthew G. Knepley . newprob - The PetscDS copy 39749252d075SMatthew G. Knepley 39759252d075SMatthew G. Knepley Level: intermediate 39769252d075SMatthew G. Knepley 39779252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 39789252d075SMatthew G. Knepley @*/ 39799252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 39809252d075SMatthew G. Knepley { 39819252d075SMatthew G. Knepley PetscInt Nc; 39829252d075SMatthew G. Knepley const PetscScalar *constants; 39839252d075SMatthew G. Knepley 39849252d075SMatthew G. Knepley PetscFunctionBegin; 39859252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 39869252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39879566063dSJacob Faibussowitsch PetscCall(PetscDSGetConstants(prob, &Nc, &constants)); 39889566063dSJacob Faibussowitsch PetscCall(PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants)); 3989da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3990da51fcedSMatthew G. Knepley } 3991da51fcedSMatthew G. Knepley 399245480ffeSMatthew G. Knepley /*@ 399345480ffeSMatthew G. Knepley PetscDSCopyExactSolutions - Copy all exact solutions to the new problem 399445480ffeSMatthew G. Knepley 399545480ffeSMatthew G. Knepley Not collective 399645480ffeSMatthew G. Knepley 399745480ffeSMatthew G. Knepley Input Parameter: 399845480ffeSMatthew G. Knepley . ds - The PetscDS object 399945480ffeSMatthew G. Knepley 400045480ffeSMatthew G. Knepley Output Parameter: 400145480ffeSMatthew G. Knepley . newds - The PetscDS copy 400245480ffeSMatthew G. Knepley 400345480ffeSMatthew G. Knepley Level: intermediate 400445480ffeSMatthew G. Knepley 400545480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 400645480ffeSMatthew G. Knepley @*/ 400745480ffeSMatthew G. Knepley PetscErrorCode PetscDSCopyExactSolutions(PetscDS ds, PetscDS newds) 400845480ffeSMatthew G. Knepley { 400945480ffeSMatthew G. Knepley PetscSimplePointFunc sol; 401045480ffeSMatthew G. Knepley void *ctx; 401145480ffeSMatthew G. Knepley PetscInt Nf, f; 401245480ffeSMatthew G. Knepley 401345480ffeSMatthew G. Knepley PetscFunctionBegin; 401445480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 401545480ffeSMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 2); 40169566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 401745480ffeSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 40189566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolution(ds, f, &sol, &ctx)); 40199566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolution(newds, f, sol, ctx)); 40209566063dSJacob Faibussowitsch PetscCall(PetscDSGetExactSolutionTimeDerivative(ds, f, &sol, &ctx)); 40219566063dSJacob Faibussowitsch PetscCall(PetscDSSetExactSolutionTimeDerivative(newds, f, sol, ctx)); 402245480ffeSMatthew G. Knepley } 402345480ffeSMatthew G. Knepley PetscFunctionReturn(0); 402445480ffeSMatthew G. Knepley } 402545480ffeSMatthew G. Knepley 4026b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 4027b1353e8eSMatthew G. Knepley { 4028df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 4029b1353e8eSMatthew G. Knepley 4030b1353e8eSMatthew G. Knepley PetscFunctionBegin; 4031b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 4032b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 4033b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 40349566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(prob, &Nf)); 40359566063dSJacob Faibussowitsch PetscCall(PetscDSGetSpatialDimension(prob, &dim)); 403663a3b9bcSJacob 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); 40379566063dSJacob Faibussowitsch if (!prob->subprobs) PetscCall(PetscCalloc1(dim, &prob->subprobs)); 4038df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 4039b1353e8eSMatthew G. Knepley PetscInt cdim; 4040b1353e8eSMatthew G. Knepley 40419566063dSJacob Faibussowitsch PetscCall(PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1])); 40429566063dSJacob Faibussowitsch PetscCall(PetscDSGetCoordinateDimension(prob, &cdim)); 40439566063dSJacob Faibussowitsch PetscCall(PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim)); 4044b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 4045b1353e8eSMatthew G. Knepley PetscFE subfe; 4046b1353e8eSMatthew G. Knepley PetscObject obj; 4047b1353e8eSMatthew G. Knepley PetscClassId id; 4048b1353e8eSMatthew G. Knepley 40499566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(prob, f, &obj)); 40509566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 40519566063dSJacob Faibussowitsch if (id == PETSCFE_CLASSID) PetscCall(PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe)); 405263a3b9bcSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %" PetscInt_FMT, f); 40539566063dSJacob Faibussowitsch PetscCall(PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe)); 4054b1353e8eSMatthew G. Knepley } 4055b1353e8eSMatthew G. Knepley } 4056df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 4057b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 4058b1353e8eSMatthew G. Knepley } 4059b1353e8eSMatthew G. Knepley 4060665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 4061c7bd5f0bSMatthew G. Knepley { 4062c7bd5f0bSMatthew G. Knepley PetscObject obj; 4063c7bd5f0bSMatthew G. Knepley PetscClassId id; 4064c7bd5f0bSMatthew G. Knepley PetscInt Nf; 4065c7bd5f0bSMatthew G. Knepley 4066c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 4067c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 4068665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 4069665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 40709566063dSJacob Faibussowitsch PetscCall(PetscDSGetNumFields(ds, &Nf)); 407163a3b9bcSJacob Faibussowitsch PetscCheck(f < Nf,PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %" PetscInt_FMT " must be in [0, %" PetscInt_FMT ")", f, Nf); 40729566063dSJacob Faibussowitsch PetscCall(PetscDSGetDiscretization(ds, f, &obj)); 4073665f567fSMatthew G. Knepley if (obj) { 40749566063dSJacob Faibussowitsch PetscCall(PetscObjectGetClassId(obj, &id)); 4075665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 4076665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 4077665f567fSMatthew G. Knepley } 4078c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 4079c7bd5f0bSMatthew G. Knepley } 4080c7bd5f0bSMatthew G. Knepley 40816528b96dSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS ds) 40822764a2aaSMatthew G. Knepley { 40832764a2aaSMatthew G. Knepley PetscFunctionBegin; 40849566063dSJacob Faibussowitsch PetscCall(PetscFree(ds->data)); 40852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40862764a2aaSMatthew G. Knepley } 40872764a2aaSMatthew G. Knepley 40886528b96dSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS ds) 40892764a2aaSMatthew G. Knepley { 40902764a2aaSMatthew G. Knepley PetscFunctionBegin; 40916528b96dSMatthew G. Knepley ds->ops->setfromoptions = NULL; 40926528b96dSMatthew G. Knepley ds->ops->setup = NULL; 40936528b96dSMatthew G. Knepley ds->ops->view = NULL; 40946528b96dSMatthew G. Knepley ds->ops->destroy = PetscDSDestroy_Basic; 40952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40962764a2aaSMatthew G. Knepley } 40972764a2aaSMatthew G. Knepley 40982764a2aaSMatthew G. Knepley /*MC 40992764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 41002764a2aaSMatthew G. Knepley 41012764a2aaSMatthew G. Knepley Level: intermediate 41022764a2aaSMatthew G. Knepley 41032764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 41042764a2aaSMatthew G. Knepley M*/ 41052764a2aaSMatthew G. Knepley 41066528b96dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS ds) 41072764a2aaSMatthew G. Knepley { 41082764a2aaSMatthew G. Knepley PetscDS_Basic *b; 41092764a2aaSMatthew G. Knepley 41102764a2aaSMatthew G. Knepley PetscFunctionBegin; 41116528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 41129566063dSJacob Faibussowitsch PetscCall(PetscNewLog(ds, &b)); 41136528b96dSMatthew G. Knepley ds->data = b; 41142764a2aaSMatthew G. Knepley 41159566063dSJacob Faibussowitsch PetscCall(PetscDSInitialize_Basic(ds)); 41162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 41172764a2aaSMatthew G. Knepley } 4118