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; 585f80ce2aSJacob Faibussowitsch CHKERRQ(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); 875f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectTypeCompare((PetscObject) prob, name, &match)); 882764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 892764a2aaSMatthew G. Knepley 905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSRegisterAll()); 915f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFunctionListFind(PetscDSList, name, &r)); 92*28b400f6SJacob 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) { 955f80ce2aSJacob Faibussowitsch CHKERRQ((*prob->ops->destroy)(prob)); 962764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 972764a2aaSMatthew G. Knepley } 985f80ce2aSJacob Faibussowitsch CHKERRQ((*r)(prob)); 995f80ce2aSJacob Faibussowitsch CHKERRQ(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); 1255f80ce2aSJacob Faibussowitsch CHKERRQ(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; 1375f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(ds, &Nf)); 1385f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerGetFormat(viewer, &format)); 1395f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", Nf)); 1405f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPushTab(viewer)); 1415f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " cell total dim %D total comp %D\n", ds->totDim, ds->totComp)); 1425f80ce2aSJacob Faibussowitsch if (ds->isCohesive) CHKERRQ(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 1515f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(ds, f, &obj)); 1525f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 1535f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetName(obj, &name)); 1545f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>")); 1555f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 1567d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1575f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetNumComponents((PetscFE) obj, &Nc)); 1585f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetQuadrature((PetscFE) obj, &q)); 1595f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " FEM")); 1607d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1615f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFVGetNumComponents((PetscFV) obj, &Nc)); 1625f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFVGetQuadrature((PetscFV) obj, &q)); 1635f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " FVM")); 1647d8a60eaSMatthew G. Knepley } 16598921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %D", f); 1665f80ce2aSJacob Faibussowitsch if (Nc > 1) CHKERRQ(PetscViewerASCIIPrintf(viewer, " %D components", Nc)); 1675f80ce2aSJacob Faibussowitsch else CHKERRQ(PetscViewerASCIIPrintf(viewer, " %D component ", Nc)); 1685f80ce2aSJacob Faibussowitsch if (ds->implicit[f]) CHKERRQ(PetscViewerASCIIPrintf(viewer, " (implicit)")); 1695f80ce2aSJacob Faibussowitsch else CHKERRQ(PetscViewerASCIIPrintf(viewer, " (explicit)")); 1703e60c2a6SMatthew G. Knepley if (q) { 1715f80ce2aSJacob Faibussowitsch CHKERRQ(PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL)); 1725f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " (Nq %D Nqc %D)", Nq, Nqc)); 1733e60c2a6SMatthew G. Knepley } 1745f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " %D-jet", ds->jetDegree[f])); 1755f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "\n")); 1765f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 1775f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPushTab(viewer)); 1785f80ce2aSJacob Faibussowitsch if (id == PETSCFE_CLASSID) CHKERRQ(PetscFEView((PetscFE) obj, viewer)); 1795f80ce2aSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) CHKERRQ(PetscFVView((PetscFV) obj, viewer)); 1805f80ce2aSJacob Faibussowitsch CHKERRQ(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; 1875f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPushTab(viewer)); 1885f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->lname, DMBoundaryConditionTypes[b->type])); 18945480ffeSMatthew G. Knepley if (!b->Nc) { 1905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " all components\n")); 19140967b3bSMatthew G. Knepley } else { 1925f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " components: ")); 1935f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 19445480ffeSMatthew G. Knepley for (c = 0; c < b->Nc; ++c) { 1955f80ce2aSJacob Faibussowitsch if (c > 0) CHKERRQ(PetscViewerASCIIPrintf(viewer, ", ")); 1965f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "%D", b->comps[c])); 19740967b3bSMatthew G. Knepley } 1985f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "\n")); 1995f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 20040967b3bSMatthew G. Knepley } 2015f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, " values: ")); 2025f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE)); 20345480ffeSMatthew G. Knepley for (i = 0; i < b->Nv; ++i) { 2045f80ce2aSJacob Faibussowitsch if (i > 0) CHKERRQ(PetscViewerASCIIPrintf(viewer, ", ")); 2055f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "%D", b->values[i])); 20640967b3bSMatthew G. Knepley } 2075f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "\n")); 2085f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE)); 2098e0d8d9cSMatthew G. Knepley if (b->func) { 2105f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDLAddr(b->func, &name)); 2115f80ce2aSJacob Faibussowitsch if (name) CHKERRQ(PetscViewerASCIIPrintf(viewer, " func: %s\n", name)); 2125f80ce2aSJacob Faibussowitsch else CHKERRQ(PetscViewerASCIIPrintf(viewer, " func: %p\n", b->func)); 2135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(name)); 2148e0d8d9cSMatthew G. Knepley } 2158e0d8d9cSMatthew G. Knepley if (b->func_t) { 2165f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDLAddr(b->func_t, &name)); 2175f80ce2aSJacob Faibussowitsch if (name) CHKERRQ(PetscViewerASCIIPrintf(viewer, " func_t: %s\n", name)); 2185f80ce2aSJacob Faibussowitsch else CHKERRQ(PetscViewerASCIIPrintf(viewer, " func_t: %p\n", b->func_t)); 2195f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(name)); 2208e0d8d9cSMatthew G. Knepley } 2215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormView(b->wf, viewer)); 2225f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPopTab(viewer)); 22340967b3bSMatthew G. Knepley } 2247d8a60eaSMatthew G. Knepley } 2255f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetConstants(ds, &numConstants, &constants)); 22697b6e6e8SMatthew G. Knepley if (numConstants) { 2275f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPrintf(viewer, "%D constants\n", numConstants)); 2285f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPushTab(viewer)); 2295f80ce2aSJacob Faibussowitsch for (f = 0; f < numConstants; ++f) CHKERRQ(PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]))); 2305f80ce2aSJacob Faibussowitsch CHKERRQ(PetscViewerASCIIPopTab(viewer)); 23197b6e6e8SMatthew G. Knepley } 2325f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormView(ds->wf, viewer)); 2335f80ce2aSJacob Faibussowitsch CHKERRQ(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); 2545f80ce2aSJacob Faibussowitsch CHKERRQ(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); 2775f80ce2aSJacob Faibussowitsch if (!v) CHKERRQ(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v)); 2787d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2795f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii)); 2805f80ce2aSJacob Faibussowitsch if (iascii) CHKERRQ(PetscDSView_Ascii(prob, v)); 2815f80ce2aSJacob Faibussowitsch if (prob->ops->view) CHKERRQ((*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 PetscErrorCode ierr; 3112764a2aaSMatthew G. Knepley 3122764a2aaSMatthew G. Knepley PetscFunctionBegin; 3132764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3142764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3152764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3162764a2aaSMatthew G. Knepley } else { 3172764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3182764a2aaSMatthew G. Knepley } 3195f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSRegisterAll()); 3202764a2aaSMatthew G. Knepley 3212764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 322f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 323f1fd5e65SToby Isaac char optname[1024]; 324f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 325f1fd5e65SToby Isaac PetscBool flg; 326f1fd5e65SToby Isaac 3275f80ce2aSJacob Faibussowitsch CHKERRQ(PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name)); 3285f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMemzero(ids, sizeof(ids))); 3295f80ce2aSJacob Faibussowitsch CHKERRQ(PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg)); 330f1fd5e65SToby Isaac if (flg) { 33145480ffeSMatthew G. Knepley b->Nv = len; 3325f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->values)); 3335f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(len, &b->values)); 3345f80ce2aSJacob Faibussowitsch CHKERRQ(PetscArraycpy(b->values, ids, len)); 3355f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormRewriteKeys(b->wf, b->label, len, b->values)); 336f1fd5e65SToby Isaac } 337e7b0402cSSander Arens len = 1024; 3385f80ce2aSJacob Faibussowitsch CHKERRQ(PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name)); 3395f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMemzero(ids, sizeof(ids))); 3405f80ce2aSJacob Faibussowitsch CHKERRQ(PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg)); 341f1fd5e65SToby Isaac if (flg) { 34245480ffeSMatthew G. Knepley b->Nc = len; 3435f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->comps)); 3445f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(len, &b->comps)); 3455f80ce2aSJacob Faibussowitsch CHKERRQ(PetscArraycpy(b->comps, ids, len)); 346f1fd5e65SToby Isaac } 347f1fd5e65SToby Isaac } 3485f80ce2aSJacob Faibussowitsch CHKERRQ(PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg)); 3492764a2aaSMatthew G. Knepley if (flg) { 3505f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetType(prob, name)); 3512764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3525f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetType(prob, defaultType)); 3532764a2aaSMatthew G. Knepley } 3545f80ce2aSJacob Faibussowitsch CHKERRQ(PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg)); 3555f80ce2aSJacob Faibussowitsch if (prob->ops->setfromoptions) CHKERRQ((*prob->ops->setfromoptions)(prob)); 3562764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3575f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob)); 3582764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 3595f80ce2aSJacob Faibussowitsch if (prob->Nf) CHKERRQ(PetscDSViewFromOptions(prob, NULL, "-petscds_view")); 3602764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3612764a2aaSMatthew G. Knepley } 3622764a2aaSMatthew G. Knepley 3632764a2aaSMatthew G. Knepley /*@C 3642764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3652764a2aaSMatthew G. Knepley 366d083f849SBarry Smith Collective on prob 3672764a2aaSMatthew G. Knepley 3682764a2aaSMatthew G. Knepley Input Parameter: 3692764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3702764a2aaSMatthew G. Knepley 3712764a2aaSMatthew G. Knepley Level: developer 3722764a2aaSMatthew G. Knepley 3732764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3742764a2aaSMatthew G. Knepley @*/ 3752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3762764a2aaSMatthew G. Knepley { 3772764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 378f9244615SMatthew G. Knepley PetscBool hasH = PETSC_FALSE; 3794bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3802764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3812764a2aaSMatthew G. Knepley 3822764a2aaSMatthew G. Knepley PetscFunctionBegin; 3832764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3842764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3852764a2aaSMatthew G. Knepley /* Calculate sizes */ 3865f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetSpatialDimension(prob, &dim)); 3875f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetCoordinateDimension(prob, &dimEmbed)); 388f744cafaSSander Arens prob->totDim = prob->totComp = 0; 3895f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb)); 3905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer)); 3915f80ce2aSJacob Faibussowitsch CHKERRQ(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])); 3925f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf)); 3932764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3949de99aefSMatthew G. Knepley PetscObject obj; 3959de99aefSMatthew G. Knepley PetscClassId id; 396665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 3979de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3982764a2aaSMatthew G. Knepley 3995f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(prob, f, &obj)); 400f9244615SMatthew G. Knepley if (prob->jetDegree[f] > 1) hasH = PETSC_TRUE; 401665f567fSMatthew G. Knepley if (!obj) { 402665f567fSMatthew G. Knepley /* Empty mesh */ 403665f567fSMatthew G. Knepley Nb = Nc = 0; 404665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 405665f567fSMatthew G. Knepley } else { 4065f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 4079de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 4089de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 4099de99aefSMatthew G. Knepley 4105f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetQuadrature(fe, &q)); 4115f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetDimension(fe, &Nb)); 4125f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetNumComponents(fe, &Nc)); 4135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetCellTabulation(fe, prob->jetDegree[f], &prob->T[f])); 4145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFEGetFaceTabulation(fe, prob->jetDegree[f], &prob->Tf[f])); 4159de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4169de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4179de99aefSMatthew G. Knepley 4185f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFVGetQuadrature(fv, &q)); 4195f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFVGetNumComponents(fv, &Nc)); 4209c3cf19fSMatthew G. Knepley Nb = Nc; 4215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFVGetCellTabulation(fv, &prob->T[f])); 4224d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 42398921bdaSJacob Faibussowitsch } else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 424665f567fSMatthew G. Knepley } 42547e57110SSander Arens prob->Nc[f] = Nc; 42647e57110SSander Arens prob->Nb[f] = Nb; 427194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 428194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 4299ee2af8cSMatthew G. Knepley prob->offCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[0][f]; 4309ee2af8cSMatthew G. Knepley prob->offDerCohesive[0][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[0][f]; 4319ee2af8cSMatthew G. Knepley prob->offCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc) + prob->offCohesive[0][f]; 4329ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][f] = (prob->cohesive[f] ? 0 : Nc)*dimEmbed + prob->offDerCohesive[0][f]; 4339ee2af8cSMatthew G. Knepley prob->offCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2) + prob->offCohesive[2][f]; 4349ee2af8cSMatthew G. Knepley prob->offDerCohesive[2][f+1] = (prob->cohesive[f] ? Nc : Nc*2)*dimEmbed + prob->offDerCohesive[2][f]; 4355f80ce2aSJacob Faibussowitsch if (q) CHKERRQ(PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL)); 4362764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4374bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4382764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4399c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4402764a2aaSMatthew G. Knepley prob->totComp += Nc; 4415fedec97SMatthew G. Knepley /* There are two faces for all fields on a cohesive cell, except for cohesive fields */ 4425fedec97SMatthew G. Knepley if (prob->isCohesive && !prob->cohesive[f]) prob->totDim += Nb; 4432764a2aaSMatthew G. Knepley } 4449ee2af8cSMatthew G. Knepley prob->offCohesive[1][Nf] = prob->offCohesive[0][Nf]; 4459ee2af8cSMatthew G. Knepley prob->offDerCohesive[1][Nf] = prob->offDerCohesive[0][Nf]; 4462764a2aaSMatthew G. Knepley /* Allocate works space */ 4475fedec97SMatthew G. Knepley NsMax = 2; /* A non-cohesive discretizations can be used on a cohesive cell, so we need this extra workspace for all DS */ 4485f80ce2aSJacob Faibussowitsch CHKERRQ(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)); 4495f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal)); 45027f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 45127f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 45227f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4535f80ce2aSJacob Faibussowitsch if (prob->ops->setup) CHKERRQ((*prob->ops->setup)(prob)); 4542764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4562764a2aaSMatthew G. Knepley } 4572764a2aaSMatthew G. Knepley 4582764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4592764a2aaSMatthew G. Knepley { 4602764a2aaSMatthew G. Knepley PetscFunctionBegin; 4615f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree2(prob->Nc,prob->Nb)); 4625f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree2(prob->off,prob->offDer)); 4635f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree6(prob->offCohesive[0],prob->offCohesive[1],prob->offCohesive[2],prob->offDerCohesive[0],prob->offDerCohesive[1],prob->offDerCohesive[2])); 4645f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree2(prob->T,prob->Tf)); 4655f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree3(prob->u,prob->u_t,prob->u_x)); 4665f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal)); 4675f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3)); 4682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4692764a2aaSMatthew G. Knepley } 4702764a2aaSMatthew G. Knepley 4712764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4722764a2aaSMatthew G. Knepley { 473f744cafaSSander Arens PetscObject *tmpd; 47434aa8a36SMatthew G. Knepley PetscBool *tmpi; 475f9244615SMatthew G. Knepley PetscInt *tmpk; 4765fedec97SMatthew G. Knepley PetscBool *tmpc; 4776528b96dSMatthew G. Knepley PetscPointFunc *tmpup; 478f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 479f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4800c2f2876SMatthew G. Knepley void **tmpctx; 48134aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4822764a2aaSMatthew G. Knepley 4832764a2aaSMatthew G. Knepley PetscFunctionBegin; 4842764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4852764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4865f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSDestroyStructs_Static(prob)); 4875f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc4(NfNew, &tmpd, NfNew, &tmpi, NfNew, &tmpc, NfNew, &tmpk)); 4885fedec97SMatthew 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];} 4895fedec97SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE, tmpc[f] = PETSC_FALSE; tmpk[f] = 1;} 4905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree4(prob->disc, prob->implicit, prob->cohesive, prob->jetDegree)); 4915f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetNumFields(prob->wf, NfNew)); 4922764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4932764a2aaSMatthew G. Knepley prob->disc = tmpd; 494249df284SMatthew G. Knepley prob->implicit = tmpi; 4955fedec97SMatthew G. Knepley prob->cohesive = tmpc; 496f9244615SMatthew G. Knepley prob->jetDegree = tmpk; 4975f80ce2aSJacob Faibussowitsch CHKERRQ(PetscCalloc2(NfNew, &tmpup, NfNew, &tmpctx)); 49832d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4990c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 50032d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 5010c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 5025f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree2(prob->update, prob->ctx)); 50332d2bbc9SMatthew G. Knepley prob->update = tmpup; 5040c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 5055f80ce2aSJacob Faibussowitsch CHKERRQ(PetscCalloc4(NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t)); 506c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50795cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 508f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 509f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 510c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 51195cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 512f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 513f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 5145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree4(prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t)); 515c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51695cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 517f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 518f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5202764a2aaSMatthew G. Knepley } 5212764a2aaSMatthew G. Knepley 5222764a2aaSMatthew G. Knepley /*@ 5232764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5242764a2aaSMatthew G. Knepley 525d083f849SBarry Smith Collective on prob 5262764a2aaSMatthew G. Knepley 5272764a2aaSMatthew G. Knepley Input Parameter: 5282764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5292764a2aaSMatthew G. Knepley 5302764a2aaSMatthew G. Knepley Level: developer 5312764a2aaSMatthew G. Knepley 5322764a2aaSMatthew G. Knepley .seealso PetscDSView() 5332764a2aaSMatthew G. Knepley @*/ 5346528b96dSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *ds) 5352764a2aaSMatthew G. Knepley { 5362764a2aaSMatthew G. Knepley PetscInt f; 5372764a2aaSMatthew G. Knepley 5382764a2aaSMatthew G. Knepley PetscFunctionBegin; 5396528b96dSMatthew G. Knepley if (!*ds) PetscFunctionReturn(0); 5406528b96dSMatthew G. Knepley PetscValidHeaderSpecific((*ds), PETSCDS_CLASSID, 1); 5412764a2aaSMatthew G. Knepley 5426528b96dSMatthew G. Knepley if (--((PetscObject)(*ds))->refct > 0) {*ds = NULL; PetscFunctionReturn(0);} 5436528b96dSMatthew G. Knepley ((PetscObject) (*ds))->refct = 0; 5446528b96dSMatthew G. Knepley if ((*ds)->subprobs) { 545df3a45bdSMatthew G. Knepley PetscInt dim, d; 546df3a45bdSMatthew G. Knepley 5475f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetSpatialDimension(*ds, &dim)); 5485f80ce2aSJacob Faibussowitsch for (d = 0; d < dim; ++d) CHKERRQ(PetscDSDestroy(&(*ds)->subprobs[d])); 549df3a45bdSMatthew G. Knepley } 5505f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree((*ds)->subprobs)); 5515f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSDestroyStructs_Static(*ds)); 5526528b96dSMatthew G. Knepley for (f = 0; f < (*ds)->Nf; ++f) { 5535f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectDereference((*ds)->disc[f])); 5542764a2aaSMatthew G. Knepley } 5555f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree4((*ds)->disc, (*ds)->implicit, (*ds)->cohesive, (*ds)->jetDegree)); 5565f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormDestroy(&(*ds)->wf)); 5575f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree2((*ds)->update,(*ds)->ctx)); 5585f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree4((*ds)->exactSol,(*ds)->exactCtx,(*ds)->exactSol_t,(*ds)->exactCtx_t)); 5595f80ce2aSJacob Faibussowitsch if ((*ds)->ops->destroy) CHKERRQ((*(*ds)->ops->destroy)(*ds)); 5605f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSDestroyBoundary(*ds)); 5615f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree((*ds)->constants)); 5625f80ce2aSJacob Faibussowitsch CHKERRQ(PetscHeaderDestroy(ds)); 5632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5642764a2aaSMatthew G. Knepley } 5652764a2aaSMatthew G. Knepley 5662764a2aaSMatthew G. Knepley /*@ 5672764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5682764a2aaSMatthew G. Knepley 569d083f849SBarry Smith Collective 5702764a2aaSMatthew G. Knepley 5712764a2aaSMatthew G. Knepley Input Parameter: 5722764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5732764a2aaSMatthew G. Knepley 5742764a2aaSMatthew G. Knepley Output Parameter: 5756528b96dSMatthew G. Knepley . ds - The PetscDS object 5762764a2aaSMatthew G. Knepley 5772764a2aaSMatthew G. Knepley Level: beginner 5782764a2aaSMatthew G. Knepley 5792764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5802764a2aaSMatthew G. Knepley @*/ 5816528b96dSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *ds) 5822764a2aaSMatthew G. Knepley { 5832764a2aaSMatthew G. Knepley PetscDS p; 5842764a2aaSMatthew G. Knepley 5852764a2aaSMatthew G. Knepley PetscFunctionBegin; 5866528b96dSMatthew G. Knepley PetscValidPointer(ds, 2); 5876528b96dSMatthew G. Knepley *ds = NULL; 5885f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSInitializePackage()); 5892764a2aaSMatthew G. Knepley 5905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView)); 5912764a2aaSMatthew G. Knepley 5922764a2aaSMatthew G. Knepley p->Nf = 0; 5932764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 59497b6e6e8SMatthew G. Knepley p->numConstants = 0; 59597b6e6e8SMatthew G. Knepley p->constants = NULL; 596a859676bSMatthew G. Knepley p->dimEmbed = -1; 59755c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5985f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCreate(comm, &p->wf)); 5992764a2aaSMatthew G. Knepley 6006528b96dSMatthew G. Knepley *ds = p; 6012764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6022764a2aaSMatthew G. Knepley } 6032764a2aaSMatthew G. Knepley 604bc4ae4beSMatthew G. Knepley /*@ 605bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 606bc4ae4beSMatthew G. Knepley 607bc4ae4beSMatthew G. Knepley Not collective 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Input Parameter: 610bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 611bc4ae4beSMatthew G. Knepley 612bc4ae4beSMatthew G. Knepley Output Parameter: 613bc4ae4beSMatthew G. Knepley . Nf - The number of fields 614bc4ae4beSMatthew G. Knepley 615bc4ae4beSMatthew G. Knepley Level: beginner 616bc4ae4beSMatthew G. Knepley 617bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 618bc4ae4beSMatthew G. Knepley @*/ 6192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6202764a2aaSMatthew G. Knepley { 6212764a2aaSMatthew G. Knepley PetscFunctionBegin; 6222764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6232764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6242764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6262764a2aaSMatthew G. Knepley } 6272764a2aaSMatthew G. Knepley 628bc4ae4beSMatthew G. Knepley /*@ 629a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 630bc4ae4beSMatthew G. Knepley 631bc4ae4beSMatthew G. Knepley Not collective 632bc4ae4beSMatthew G. Knepley 633bc4ae4beSMatthew G. Knepley Input Parameter: 634bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 635bc4ae4beSMatthew G. Knepley 636bc4ae4beSMatthew G. Knepley Output Parameter: 637bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 638bc4ae4beSMatthew G. Knepley 639bc4ae4beSMatthew G. Knepley Level: beginner 640bc4ae4beSMatthew G. Knepley 641a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 642bc4ae4beSMatthew G. Knepley @*/ 6432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6442764a2aaSMatthew G. Knepley { 6452764a2aaSMatthew G. Knepley PetscFunctionBegin; 6462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6472764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6482764a2aaSMatthew G. Knepley *dim = 0; 6499de99aefSMatthew G. Knepley if (prob->Nf) { 6509de99aefSMatthew G. Knepley PetscObject obj; 6519de99aefSMatthew G. Knepley PetscClassId id; 6529de99aefSMatthew G. Knepley 6535f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(prob, 0, &obj)); 654665f567fSMatthew G. Knepley if (obj) { 6555f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 6565f80ce2aSJacob Faibussowitsch if (id == PETSCFE_CLASSID) CHKERRQ(PetscFEGetSpatialDimension((PetscFE) obj, dim)); 6575f80ce2aSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) CHKERRQ(PetscFVGetSpatialDimension((PetscFV) obj, dim)); 65898921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6599de99aefSMatthew G. Knepley } 660665f567fSMatthew G. Knepley } 6612764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6622764a2aaSMatthew G. Knepley } 6632764a2aaSMatthew G. Knepley 664bc4ae4beSMatthew G. Knepley /*@ 665a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 666a859676bSMatthew G. Knepley 667a859676bSMatthew G. Knepley Not collective 668a859676bSMatthew G. Knepley 669a859676bSMatthew G. Knepley Input Parameter: 670a859676bSMatthew G. Knepley . prob - The PetscDS object 671a859676bSMatthew G. Knepley 672a859676bSMatthew G. Knepley Output Parameter: 673a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 674a859676bSMatthew G. Knepley 675a859676bSMatthew G. Knepley Level: beginner 676a859676bSMatthew G. Knepley 677a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 678a859676bSMatthew G. Knepley @*/ 679a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 680a859676bSMatthew G. Knepley { 681a859676bSMatthew G. Knepley PetscFunctionBegin; 682a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 683a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 6842c71b3e2SJacob Faibussowitsch PetscCheckFalse(prob->dimEmbed < 0,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 685a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 686a859676bSMatthew G. Knepley PetscFunctionReturn(0); 687a859676bSMatthew G. Knepley } 688a859676bSMatthew G. Knepley 689a859676bSMatthew G. Knepley /*@ 690a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 691a859676bSMatthew G. Knepley 692d083f849SBarry Smith Logically collective on prob 693a859676bSMatthew G. Knepley 694a859676bSMatthew G. Knepley Input Parameters: 695a859676bSMatthew G. Knepley + prob - The PetscDS object 696a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 697a859676bSMatthew G. Knepley 698a859676bSMatthew G. Knepley Level: beginner 699a859676bSMatthew G. Knepley 700a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 701a859676bSMatthew G. Knepley @*/ 702a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 703a859676bSMatthew G. Knepley { 704a859676bSMatthew G. Knepley PetscFunctionBegin; 705a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7062c71b3e2SJacob Faibussowitsch PetscCheckFalse(dimEmbed < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 707a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 708a859676bSMatthew G. Knepley PetscFunctionReturn(0); 709a859676bSMatthew G. Knepley } 710a859676bSMatthew G. Knepley 711a859676bSMatthew G. Knepley /*@ 7125fedec97SMatthew G. Knepley PetscDSIsCohesive - Returns the flag indicating that this DS is for a cohesive cell 7138edf6225SMatthew G. Knepley 7148edf6225SMatthew G. Knepley Not collective 7158edf6225SMatthew G. Knepley 7168edf6225SMatthew G. Knepley Input Parameter: 7175fedec97SMatthew G. Knepley . ds - The PetscDS object 7188edf6225SMatthew G. Knepley 7198edf6225SMatthew G. Knepley Output Parameter: 7205fedec97SMatthew G. Knepley . isCohesive - The flag 7218edf6225SMatthew G. Knepley 7228edf6225SMatthew G. Knepley Level: developer 7238edf6225SMatthew G. Knepley 7245fedec97SMatthew G. Knepley .seealso: PetscDSGetNumCohesive(), PetscDSGetCohesive(), PetscDSSetCohesive(), PetscDSCreate() 7258edf6225SMatthew G. Knepley @*/ 7265fedec97SMatthew G. Knepley PetscErrorCode PetscDSIsCohesive(PetscDS ds, PetscBool *isCohesive) 7278edf6225SMatthew G. Knepley { 7288edf6225SMatthew G. Knepley PetscFunctionBegin; 7295fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 7305fedec97SMatthew G. Knepley PetscValidPointer(isCohesive, 2); 7315fedec97SMatthew G. Knepley *isCohesive = ds->isCohesive; 7328edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7338edf6225SMatthew G. Knepley } 7348edf6225SMatthew G. Knepley 7358edf6225SMatthew G. Knepley /*@ 7365fedec97SMatthew G. Knepley PetscDSGetNumCohesive - Returns the numer of cohesive fields, meaning those defined on the interior of a cohesive cell 7375fedec97SMatthew G. Knepley 7385fedec97SMatthew G. Knepley Not collective 7395fedec97SMatthew G. Knepley 7405fedec97SMatthew G. Knepley Input Parameter: 7415fedec97SMatthew G. Knepley . ds - The PetscDS object 7425fedec97SMatthew G. Knepley 7435fedec97SMatthew G. Knepley Output Parameter: 7445fedec97SMatthew G. Knepley . numCohesive - The number of cohesive fields 7455fedec97SMatthew G. Knepley 7465fedec97SMatthew G. Knepley Level: developer 7475fedec97SMatthew G. Knepley 7485fedec97SMatthew G. Knepley .seealso: PetscDSSetCohesive(), PetscDSCreate() 7495fedec97SMatthew G. Knepley @*/ 7505fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetNumCohesive(PetscDS ds, PetscInt *numCohesive) 7515fedec97SMatthew G. Knepley { 7525fedec97SMatthew G. Knepley PetscInt f; 7535fedec97SMatthew G. Knepley 7545fedec97SMatthew G. Knepley PetscFunctionBegin; 7555fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 7565fedec97SMatthew G. Knepley PetscValidPointer(numCohesive, 2); 7575fedec97SMatthew G. Knepley *numCohesive = 0; 7585fedec97SMatthew G. Knepley for (f = 0; f < ds->Nf; ++f) *numCohesive += ds->cohesive[f] ? 1 : 0; 7595fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7605fedec97SMatthew G. Knepley } 7615fedec97SMatthew G. Knepley 7625fedec97SMatthew G. Knepley /*@ 7635fedec97SMatthew G. Knepley PetscDSGetCohesive - Returns the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7645fedec97SMatthew G. Knepley 7655fedec97SMatthew G. Knepley Not collective 7665fedec97SMatthew G. Knepley 767f1a722f8SMatthew G. Knepley Input Parameters: 7685fedec97SMatthew G. Knepley + ds - The PetscDS object 7695fedec97SMatthew G. Knepley - f - The field index 7705fedec97SMatthew G. Knepley 7715fedec97SMatthew G. Knepley Output Parameter: 7725fedec97SMatthew G. Knepley . isCohesive - The flag 7735fedec97SMatthew G. Knepley 7745fedec97SMatthew G. Knepley Level: developer 7755fedec97SMatthew G. Knepley 7765fedec97SMatthew G. Knepley .seealso: PetscDSSetCohesive(), PetscDSIsCohesive(), PetscDSCreate() 7775fedec97SMatthew G. Knepley @*/ 7785fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetCohesive(PetscDS ds, PetscInt f, PetscBool *isCohesive) 7795fedec97SMatthew G. Knepley { 7805fedec97SMatthew G. Knepley PetscFunctionBegin; 7815fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 7825fedec97SMatthew G. Knepley PetscValidPointer(isCohesive, 3); 7832c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 7845fedec97SMatthew G. Knepley *isCohesive = ds->cohesive[f]; 7855fedec97SMatthew G. Knepley PetscFunctionReturn(0); 7865fedec97SMatthew G. Knepley } 7875fedec97SMatthew G. Knepley 7885fedec97SMatthew G. Knepley /*@ 7895fedec97SMatthew G. Knepley PetscDSSetCohesive - Set the flag indicating that a field is cohesive, meaning it is defined on the interior of a cohesive cell 7908edf6225SMatthew G. Knepley 7918edf6225SMatthew G. Knepley Not collective 7928edf6225SMatthew G. Knepley 7938edf6225SMatthew G. Knepley Input Parameters: 7945fedec97SMatthew G. Knepley + ds - The PetscDS object 7955fedec97SMatthew G. Knepley . f - The field index 7965fedec97SMatthew G. Knepley - isCohesive - The flag for a cohesive field 7978edf6225SMatthew G. Knepley 7988edf6225SMatthew G. Knepley Level: developer 7998edf6225SMatthew G. Knepley 8005fedec97SMatthew G. Knepley .seealso: PetscDSGetCohesive(), PetscDSIsCohesive(), PetscDSCreate() 8018edf6225SMatthew G. Knepley @*/ 8025fedec97SMatthew G. Knepley PetscErrorCode PetscDSSetCohesive(PetscDS ds, PetscInt f, PetscBool isCohesive) 8038edf6225SMatthew G. Knepley { 8045fedec97SMatthew G. Knepley PetscInt i; 8055fedec97SMatthew G. Knepley 8068edf6225SMatthew G. Knepley PetscFunctionBegin; 8075fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 8082c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 8095fedec97SMatthew G. Knepley ds->cohesive[f] = isCohesive; 8105fedec97SMatthew G. Knepley ds->isCohesive = PETSC_FALSE; 8115fedec97SMatthew G. Knepley for (i = 0; i < ds->Nf; ++i) ds->isCohesive = ds->isCohesive || ds->cohesive[f] ? PETSC_TRUE : PETSC_FALSE; 8128edf6225SMatthew G. Knepley PetscFunctionReturn(0); 8138edf6225SMatthew G. Knepley } 8148edf6225SMatthew G. Knepley 8158edf6225SMatthew G. Knepley /*@ 816bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 817bc4ae4beSMatthew G. Knepley 818bc4ae4beSMatthew G. Knepley Not collective 819bc4ae4beSMatthew G. Knepley 820bc4ae4beSMatthew G. Knepley Input Parameter: 821bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 822bc4ae4beSMatthew G. Knepley 823bc4ae4beSMatthew G. Knepley Output Parameter: 824bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 825bc4ae4beSMatthew G. Knepley 826bc4ae4beSMatthew G. Knepley Level: beginner 827bc4ae4beSMatthew G. Knepley 828bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 829bc4ae4beSMatthew G. Knepley @*/ 8302764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 8312764a2aaSMatthew G. Knepley { 8322764a2aaSMatthew G. Knepley PetscFunctionBegin; 8332764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8345f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 8352764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 8362764a2aaSMatthew G. Knepley *dim = prob->totDim; 8372764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8382764a2aaSMatthew G. Knepley } 8392764a2aaSMatthew G. Knepley 840bc4ae4beSMatthew G. Knepley /*@ 841bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 842bc4ae4beSMatthew G. Knepley 843bc4ae4beSMatthew G. Knepley Not collective 844bc4ae4beSMatthew G. Knepley 845bc4ae4beSMatthew G. Knepley Input Parameter: 846bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 847bc4ae4beSMatthew G. Knepley 848bc4ae4beSMatthew G. Knepley Output Parameter: 849bc4ae4beSMatthew G. Knepley . dim - The total number of components 850bc4ae4beSMatthew G. Knepley 851bc4ae4beSMatthew G. Knepley Level: beginner 852bc4ae4beSMatthew G. Knepley 853bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 854bc4ae4beSMatthew G. Knepley @*/ 8552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8562764a2aaSMatthew G. Knepley { 8572764a2aaSMatthew G. Knepley PetscFunctionBegin; 8582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8595f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 8602764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8612764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8622764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8632764a2aaSMatthew G. Knepley } 8642764a2aaSMatthew G. Knepley 865bc4ae4beSMatthew G. Knepley /*@ 866bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 867bc4ae4beSMatthew G. Knepley 868bc4ae4beSMatthew G. Knepley Not collective 869bc4ae4beSMatthew G. Knepley 870bc4ae4beSMatthew G. Knepley Input Parameters: 871bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 872bc4ae4beSMatthew G. Knepley - f - The field number 873bc4ae4beSMatthew G. Knepley 874bc4ae4beSMatthew G. Knepley Output Parameter: 875bc4ae4beSMatthew G. Knepley . disc - The discretization object 876bc4ae4beSMatthew G. Knepley 877bc4ae4beSMatthew G. Knepley Level: beginner 878bc4ae4beSMatthew G. Knepley 879f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 880bc4ae4beSMatthew G. Knepley @*/ 8812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8822764a2aaSMatthew G. Knepley { 8836528b96dSMatthew G. Knepley PetscFunctionBeginHot; 8842764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8852764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8862c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 8872764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8892764a2aaSMatthew G. Knepley } 8902764a2aaSMatthew G. Knepley 891bc4ae4beSMatthew G. Knepley /*@ 892bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 893bc4ae4beSMatthew G. Knepley 894bc4ae4beSMatthew G. Knepley Not collective 895bc4ae4beSMatthew G. Knepley 896bc4ae4beSMatthew G. Knepley Input Parameters: 897bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 898bc4ae4beSMatthew G. Knepley . f - The field number 899bc4ae4beSMatthew G. Knepley - disc - The discretization object 900bc4ae4beSMatthew G. Knepley 901bc4ae4beSMatthew G. Knepley Level: beginner 902bc4ae4beSMatthew G. Knepley 903bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 904bc4ae4beSMatthew G. Knepley @*/ 9052764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 9062764a2aaSMatthew G. Knepley { 9072764a2aaSMatthew G. Knepley PetscFunctionBegin; 9082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 909665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 9102c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9115f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSEnlarge_Static(prob, f+1)); 9125f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectDereference(prob->disc[f])); 9132764a2aaSMatthew G. Knepley prob->disc[f] = disc; 9145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectReference(disc)); 915665f567fSMatthew G. Knepley if (disc) { 916249df284SMatthew G. Knepley PetscClassId id; 917249df284SMatthew G. Knepley 9185f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(disc, &id)); 9191cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 9205f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetImplicit(prob, f, PETSC_TRUE)); 9211cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 9225f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetImplicit(prob, f, PETSC_FALSE)); 923a6cbbb48SMatthew G. Knepley } 9245f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetJetDegree(prob, f, 1)); 925249df284SMatthew G. Knepley } 9262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9272764a2aaSMatthew G. Knepley } 9282764a2aaSMatthew G. Knepley 929bc4ae4beSMatthew G. Knepley /*@ 9306528b96dSMatthew G. Knepley PetscDSGetWeakForm - Returns the weak form object 9316528b96dSMatthew G. Knepley 9326528b96dSMatthew G. Knepley Not collective 9336528b96dSMatthew G. Knepley 9346528b96dSMatthew G. Knepley Input Parameter: 9356528b96dSMatthew G. Knepley . ds - The PetscDS object 9366528b96dSMatthew G. Knepley 9376528b96dSMatthew G. Knepley Output Parameter: 9386528b96dSMatthew G. Knepley . wf - The weak form object 9396528b96dSMatthew G. Knepley 9406528b96dSMatthew G. Knepley Level: beginner 9416528b96dSMatthew G. Knepley 9426528b96dSMatthew G. Knepley .seealso: PetscDSSetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9436528b96dSMatthew G. Knepley @*/ 9446528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetWeakForm(PetscDS ds, PetscWeakForm *wf) 9456528b96dSMatthew G. Knepley { 9466528b96dSMatthew G. Knepley PetscFunctionBegin; 9476528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9486528b96dSMatthew G. Knepley PetscValidPointer(wf, 2); 9496528b96dSMatthew G. Knepley *wf = ds->wf; 9506528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9516528b96dSMatthew G. Knepley } 9526528b96dSMatthew G. Knepley 9536528b96dSMatthew G. Knepley /*@ 9546528b96dSMatthew G. Knepley PetscDSSetWeakForm - Sets the weak form object 9556528b96dSMatthew G. Knepley 9566528b96dSMatthew G. Knepley Not collective 9576528b96dSMatthew G. Knepley 9586528b96dSMatthew G. Knepley Input Parameters: 9596528b96dSMatthew G. Knepley + ds - The PetscDS object 9606528b96dSMatthew G. Knepley - wf - The weak form object 9616528b96dSMatthew G. Knepley 9626528b96dSMatthew G. Knepley Level: beginner 9636528b96dSMatthew G. Knepley 9646528b96dSMatthew G. Knepley .seealso: PetscDSGetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9656528b96dSMatthew G. Knepley @*/ 9666528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetWeakForm(PetscDS ds, PetscWeakForm wf) 9676528b96dSMatthew G. Knepley { 9686528b96dSMatthew G. Knepley PetscFunctionBegin; 9696528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9706528b96dSMatthew G. Knepley PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 2); 9715f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectDereference((PetscObject) ds->wf)); 9726528b96dSMatthew G. Knepley ds->wf = wf; 9735f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectReference((PetscObject) wf)); 9745f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetNumFields(wf, ds->Nf)); 9756528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9766528b96dSMatthew G. Knepley } 9776528b96dSMatthew G. Knepley 9786528b96dSMatthew G. Knepley /*@ 979bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 980bc4ae4beSMatthew G. Knepley 981bc4ae4beSMatthew G. Knepley Not collective 982bc4ae4beSMatthew G. Knepley 983bc4ae4beSMatthew G. Knepley Input Parameters: 984bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 985bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 986bc4ae4beSMatthew G. Knepley 987bc4ae4beSMatthew G. Knepley Level: beginner 988bc4ae4beSMatthew G. Knepley 989bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 990bc4ae4beSMatthew G. Knepley @*/ 9912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9922764a2aaSMatthew G. Knepley { 9932764a2aaSMatthew G. Knepley PetscFunctionBegin; 9945f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetDiscretization(prob, prob->Nf, disc)); 9952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9962764a2aaSMatthew G. Knepley } 9972764a2aaSMatthew G. Knepley 998249df284SMatthew G. Knepley /*@ 999083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 1000083401c6SMatthew G. Knepley 1001083401c6SMatthew G. Knepley Not collective 1002083401c6SMatthew G. Knepley 1003083401c6SMatthew G. Knepley Input Parameter: 1004083401c6SMatthew G. Knepley . prob - The PetscDS object 1005083401c6SMatthew G. Knepley 1006083401c6SMatthew G. Knepley Output Parameter: 1007083401c6SMatthew G. Knepley . q - The quadrature object 1008083401c6SMatthew G. Knepley 1009083401c6SMatthew G. Knepley Level: intermediate 1010083401c6SMatthew G. Knepley 1011083401c6SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1012083401c6SMatthew G. Knepley @*/ 1013083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 1014083401c6SMatthew G. Knepley { 1015083401c6SMatthew G. Knepley PetscObject obj; 1016083401c6SMatthew G. Knepley PetscClassId id; 1017083401c6SMatthew G. Knepley 1018083401c6SMatthew G. Knepley PetscFunctionBegin; 1019083401c6SMatthew G. Knepley *q = NULL; 1020083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 10215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(prob, 0, &obj)); 10225f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 10235f80ce2aSJacob Faibussowitsch if (id == PETSCFE_CLASSID) CHKERRQ(PetscFEGetQuadrature((PetscFE) obj, q)); 10245f80ce2aSJacob Faibussowitsch else if (id == PETSCFV_CLASSID) CHKERRQ(PetscFVGetQuadrature((PetscFV) obj, q)); 102598921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 1026083401c6SMatthew G. Knepley PetscFunctionReturn(0); 1027083401c6SMatthew G. Knepley } 1028083401c6SMatthew G. Knepley 1029083401c6SMatthew G. Knepley /*@ 1030249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 1031249df284SMatthew G. Knepley 1032249df284SMatthew G. Knepley Not collective 1033249df284SMatthew G. Knepley 1034249df284SMatthew G. Knepley Input Parameters: 1035249df284SMatthew G. Knepley + prob - The PetscDS object 1036249df284SMatthew G. Knepley - f - The field number 1037249df284SMatthew G. Knepley 1038249df284SMatthew G. Knepley Output Parameter: 1039249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 1040249df284SMatthew G. Knepley 1041249df284SMatthew G. Knepley Level: developer 1042249df284SMatthew G. Knepley 1043f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1044249df284SMatthew G. Knepley @*/ 1045249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 1046249df284SMatthew G. Knepley { 1047249df284SMatthew G. Knepley PetscFunctionBegin; 1048249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1049249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 10502c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1051249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 1052249df284SMatthew G. Knepley PetscFunctionReturn(0); 1053249df284SMatthew G. Knepley } 1054249df284SMatthew G. Knepley 1055249df284SMatthew G. Knepley /*@ 1056249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 1057249df284SMatthew G. Knepley 1058249df284SMatthew G. Knepley Not collective 1059249df284SMatthew G. Knepley 1060249df284SMatthew G. Knepley Input Parameters: 1061249df284SMatthew G. Knepley + prob - The PetscDS object 1062249df284SMatthew G. Knepley . f - The field number 1063249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 1064249df284SMatthew G. Knepley 1065249df284SMatthew G. Knepley Level: developer 1066249df284SMatthew G. Knepley 1067f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1068249df284SMatthew G. Knepley @*/ 1069249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 1070249df284SMatthew G. Knepley { 1071249df284SMatthew G. Knepley PetscFunctionBegin; 1072249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10732c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1074249df284SMatthew G. Knepley prob->implicit[f] = implicit; 1075249df284SMatthew G. Knepley PetscFunctionReturn(0); 1076249df284SMatthew G. Knepley } 1077249df284SMatthew G. Knepley 1078f9244615SMatthew G. Knepley /*@ 1079f9244615SMatthew G. Knepley PetscDSGetJetDegree - Returns the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1080f9244615SMatthew G. Knepley 1081f9244615SMatthew G. Knepley Not collective 1082f9244615SMatthew G. Knepley 1083f9244615SMatthew G. Knepley Input Parameters: 1084f9244615SMatthew G. Knepley + ds - The PetscDS object 1085f9244615SMatthew G. Knepley - f - The field number 1086f9244615SMatthew G. Knepley 1087f9244615SMatthew G. Knepley Output Parameter: 1088f9244615SMatthew G. Knepley . k - The highest derivative we need to tabulate 1089f9244615SMatthew G. Knepley 1090f9244615SMatthew G. Knepley Level: developer 1091f9244615SMatthew G. Knepley 1092f9244615SMatthew G. Knepley .seealso: PetscDSSetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1093f9244615SMatthew G. Knepley @*/ 1094f9244615SMatthew G. Knepley PetscErrorCode PetscDSGetJetDegree(PetscDS ds, PetscInt f, PetscInt *k) 1095f9244615SMatthew G. Knepley { 1096f9244615SMatthew G. Knepley PetscFunctionBegin; 1097f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1098f9244615SMatthew G. Knepley PetscValidPointer(k, 3); 10992c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1100f9244615SMatthew G. Knepley *k = ds->jetDegree[f]; 1101f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1102f9244615SMatthew G. Knepley } 1103f9244615SMatthew G. Knepley 1104f9244615SMatthew G. Knepley /*@ 1105f9244615SMatthew G. Knepley PetscDSSetJetDegree - Set the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1106f9244615SMatthew G. Knepley 1107f9244615SMatthew G. Knepley Not collective 1108f9244615SMatthew G. Knepley 1109f9244615SMatthew G. Knepley Input Parameters: 1110f9244615SMatthew G. Knepley + ds - The PetscDS object 1111f9244615SMatthew G. Knepley . f - The field number 1112f9244615SMatthew G. Knepley - k - The highest derivative we need to tabulate 1113f9244615SMatthew G. Knepley 1114f9244615SMatthew G. Knepley Level: developer 1115f9244615SMatthew G. Knepley 1116f9244615SMatthew G. Knepley .seealso: PetscDSGetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1117f9244615SMatthew G. Knepley @*/ 1118f9244615SMatthew G. Knepley PetscErrorCode PetscDSSetJetDegree(PetscDS ds, PetscInt f, PetscInt k) 1119f9244615SMatthew G. Knepley { 1120f9244615SMatthew G. Knepley PetscFunctionBegin; 1121f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11222c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1123f9244615SMatthew G. Knepley ds->jetDegree[f] = k; 1124f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1125f9244615SMatthew G. Knepley } 1126f9244615SMatthew G. Knepley 11276528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS ds, PetscInt f, 112830b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1129194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1130194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 113197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11322764a2aaSMatthew G. Knepley { 11336528b96dSMatthew G. Knepley PetscPointFunc *tmp; 11346528b96dSMatthew G. Knepley PetscInt n; 11356528b96dSMatthew G. Knepley 11362764a2aaSMatthew G. Knepley PetscFunctionBegin; 11376528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11386528b96dSMatthew G. Knepley PetscValidPointer(obj, 3); 11392c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 11405f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetObjective(ds->wf, NULL, 0, f, 0, &n, &tmp)); 11416528b96dSMatthew G. Knepley *obj = tmp ? tmp[0] : NULL; 11422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11432764a2aaSMatthew G. Knepley } 11442764a2aaSMatthew G. Knepley 11456528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS ds, PetscInt f, 114630b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1147194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1148194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 114997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11502764a2aaSMatthew G. Knepley { 11512764a2aaSMatthew G. Knepley PetscFunctionBegin; 11526528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11536528b96dSMatthew G. Knepley if (obj) PetscValidFunction(obj, 3); 11542c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11555f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexObjective(ds->wf, NULL, 0, f, 0, 0, obj)); 11562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11572764a2aaSMatthew G. Knepley } 11582764a2aaSMatthew G. Knepley 1159194d53e6SMatthew G. Knepley /*@C 1160194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1161194d53e6SMatthew G. Knepley 1162194d53e6SMatthew G. Knepley Not collective 1163194d53e6SMatthew G. Knepley 1164194d53e6SMatthew G. Knepley Input Parameters: 11656528b96dSMatthew G. Knepley + ds - The PetscDS 1166194d53e6SMatthew G. Knepley - f - The test field number 1167194d53e6SMatthew G. Knepley 1168194d53e6SMatthew G. Knepley Output Parameters: 1169194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1170194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1171194d53e6SMatthew G. Knepley 1172194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1173194d53e6SMatthew G. Knepley 1174194d53e6SMatthew 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) 1175194d53e6SMatthew G. Knepley 1176194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1177194d53e6SMatthew G. Knepley 117830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1179194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1180194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 118130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1182194d53e6SMatthew G. Knepley 1183194d53e6SMatthew G. Knepley + dim - the spatial dimension 1184194d53e6SMatthew G. Knepley . Nf - the number of fields 1185194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1186194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1187194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1188194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1189194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1190194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1191194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1192194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1193194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1194194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1195194d53e6SMatthew G. Knepley . t - current time 1196194d53e6SMatthew G. Knepley . x - coordinates of the current point 119797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 119897b6e6e8SMatthew G. Knepley . constants - constant parameters 1199194d53e6SMatthew G. Knepley - f0 - output values at the current point 1200194d53e6SMatthew G. Knepley 1201194d53e6SMatthew G. Knepley Level: intermediate 1202194d53e6SMatthew G. Knepley 1203194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1204194d53e6SMatthew G. Knepley @*/ 12056528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS ds, PetscInt f, 120630b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1207194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1208194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 121030b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1211194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1212194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12142764a2aaSMatthew G. Knepley { 12156528b96dSMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 12166528b96dSMatthew G. Knepley PetscInt n0, n1; 12176528b96dSMatthew G. Knepley 12182764a2aaSMatthew G. Knepley PetscFunctionBegin; 12196528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 12202c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 12215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 12226528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 12236528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 12242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12252764a2aaSMatthew G. Knepley } 12262764a2aaSMatthew G. Knepley 1227194d53e6SMatthew G. Knepley /*@C 1228194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1229194d53e6SMatthew G. Knepley 1230194d53e6SMatthew G. Knepley Not collective 1231194d53e6SMatthew G. Knepley 1232194d53e6SMatthew G. Knepley Input Parameters: 12336528b96dSMatthew G. Knepley + ds - The PetscDS 1234194d53e6SMatthew G. Knepley . f - The test field number 1235194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1236194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1237194d53e6SMatthew G. Knepley 1238194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1239194d53e6SMatthew G. Knepley 1240194d53e6SMatthew 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) 1241194d53e6SMatthew G. Knepley 1242194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1243194d53e6SMatthew G. Knepley 124430b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1245194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1246194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1248194d53e6SMatthew G. Knepley 1249194d53e6SMatthew G. Knepley + dim - the spatial dimension 1250194d53e6SMatthew G. Knepley . Nf - the number of fields 1251194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1252194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1253194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1254194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1255194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1256194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1257194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1258194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1259194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1260194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1261194d53e6SMatthew G. Knepley . t - current time 1262194d53e6SMatthew G. Knepley . x - coordinates of the current point 126397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 126497b6e6e8SMatthew G. Knepley . constants - constant parameters 1265194d53e6SMatthew G. Knepley - f0 - output values at the current point 1266194d53e6SMatthew G. Knepley 1267194d53e6SMatthew G. Knepley Level: intermediate 1268194d53e6SMatthew G. Knepley 1269194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1270194d53e6SMatthew G. Knepley @*/ 12716528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS ds, PetscInt f, 127230b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1273194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1274194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 127630b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1277194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1278194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12802764a2aaSMatthew G. Knepley { 12812764a2aaSMatthew G. Knepley PetscFunctionBegin; 12826528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1283f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1284f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 12852c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12865f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 12872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12882764a2aaSMatthew G. Knepley } 12892764a2aaSMatthew G. Knepley 12903e75805dSMatthew G. Knepley /*@C 1291cb36c0f9SMatthew G. Knepley PetscDSGetRHSResidual - Get the pointwise RHS residual function for explicit timestepping for a given test field 1292cb36c0f9SMatthew G. Knepley 1293cb36c0f9SMatthew G. Knepley Not collective 1294cb36c0f9SMatthew G. Knepley 1295cb36c0f9SMatthew G. Knepley Input Parameters: 1296cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1297cb36c0f9SMatthew G. Knepley - f - The test field number 1298cb36c0f9SMatthew G. Knepley 1299cb36c0f9SMatthew G. Knepley Output Parameters: 1300cb36c0f9SMatthew G. Knepley + f0 - integrand for the test function term 1301cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1302cb36c0f9SMatthew G. Knepley 1303cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1304cb36c0f9SMatthew G. Knepley 1305cb36c0f9SMatthew 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) 1306cb36c0f9SMatthew G. Knepley 1307cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1308cb36c0f9SMatthew G. Knepley 1309cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1310cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1311cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1312cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1313cb36c0f9SMatthew G. Knepley 1314cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1315cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1316cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1317cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1318cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1319cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1320cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1321cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1322cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1323cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1324cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1325cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1326cb36c0f9SMatthew G. Knepley . t - current time 1327cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1328cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1329cb36c0f9SMatthew G. Knepley . constants - constant parameters 1330cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1331cb36c0f9SMatthew G. Knepley 1332cb36c0f9SMatthew G. Knepley Level: intermediate 1333cb36c0f9SMatthew G. Knepley 1334cb36c0f9SMatthew G. Knepley .seealso: PetscDSSetRHSResidual() 1335cb36c0f9SMatthew G. Knepley @*/ 1336cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSGetRHSResidual(PetscDS ds, PetscInt f, 1337cb36c0f9SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1338cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1339cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1340cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1341cb36c0f9SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1342cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1343cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1344cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1345cb36c0f9SMatthew G. Knepley { 1346cb36c0f9SMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 1347cb36c0f9SMatthew G. Knepley PetscInt n0, n1; 1348cb36c0f9SMatthew G. Knepley 1349cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1350cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 13512c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 13525f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 100, &n0, &tmp0, &n1, &tmp1)); 1353cb36c0f9SMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 1354cb36c0f9SMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 1355cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1356cb36c0f9SMatthew G. Knepley } 1357cb36c0f9SMatthew G. Knepley 1358cb36c0f9SMatthew G. Knepley /*@C 1359cb36c0f9SMatthew G. Knepley PetscDSSetRHSResidual - Set the pointwise residual function for explicit timestepping for a given test field 1360cb36c0f9SMatthew G. Knepley 1361cb36c0f9SMatthew G. Knepley Not collective 1362cb36c0f9SMatthew G. Knepley 1363cb36c0f9SMatthew G. Knepley Input Parameters: 1364cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1365cb36c0f9SMatthew G. Knepley . f - The test field number 1366cb36c0f9SMatthew G. Knepley . f0 - integrand for the test function term 1367cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1368cb36c0f9SMatthew G. Knepley 1369cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1370cb36c0f9SMatthew G. Knepley 1371cb36c0f9SMatthew 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) 1372cb36c0f9SMatthew G. Knepley 1373cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1374cb36c0f9SMatthew G. Knepley 1375cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1376cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1377cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1378cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1379cb36c0f9SMatthew G. Knepley 1380cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1381cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1382cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1383cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1384cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1385cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1386cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1387cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1388cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1389cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1390cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1391cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1392cb36c0f9SMatthew G. Knepley . t - current time 1393cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1394cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1395cb36c0f9SMatthew G. Knepley . constants - constant parameters 1396cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1397cb36c0f9SMatthew G. Knepley 1398cb36c0f9SMatthew G. Knepley Level: intermediate 1399cb36c0f9SMatthew G. Knepley 1400cb36c0f9SMatthew G. Knepley .seealso: PetscDSGetResidual() 1401cb36c0f9SMatthew G. Knepley @*/ 1402cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSSetRHSResidual(PetscDS ds, PetscInt f, 1403cb36c0f9SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1404cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1405cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1406cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1407cb36c0f9SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1408cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1409cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1410cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1411cb36c0f9SMatthew G. Knepley { 1412cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1413cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1414cb36c0f9SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1415cb36c0f9SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 14162c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 14175f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 100, 0, f0, 0, f1)); 1418cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1419cb36c0f9SMatthew G. Knepley } 1420cb36c0f9SMatthew G. Knepley 1421cb36c0f9SMatthew G. Knepley /*@C 14223e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 14233e75805dSMatthew G. Knepley 14243e75805dSMatthew G. Knepley Not collective 14253e75805dSMatthew G. Knepley 14263e75805dSMatthew G. Knepley Input Parameter: 14273e75805dSMatthew G. Knepley . prob - The PetscDS 14283e75805dSMatthew G. Knepley 14293e75805dSMatthew G. Knepley Output Parameter: 14303e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 14313e75805dSMatthew G. Knepley 14323e75805dSMatthew G. Knepley Level: intermediate 14333e75805dSMatthew G. Knepley 14343e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 14353e75805dSMatthew G. Knepley @*/ 14366528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS ds, PetscBool *hasJac) 14373e75805dSMatthew G. Knepley { 14383e75805dSMatthew G. Knepley PetscFunctionBegin; 14396528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14405f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormHasJacobian(ds->wf, hasJac)); 14413e75805dSMatthew G. Knepley PetscFunctionReturn(0); 14423e75805dSMatthew G. Knepley } 14433e75805dSMatthew G. Knepley 1444194d53e6SMatthew G. Knepley /*@C 1445194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1446194d53e6SMatthew G. Knepley 1447194d53e6SMatthew G. Knepley Not collective 1448194d53e6SMatthew G. Knepley 1449194d53e6SMatthew G. Knepley Input Parameters: 14506528b96dSMatthew G. Knepley + ds - The PetscDS 1451194d53e6SMatthew G. Knepley . f - The test field number 1452194d53e6SMatthew G. Knepley - g - The field number 1453194d53e6SMatthew G. Knepley 1454194d53e6SMatthew G. Knepley Output Parameters: 1455194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1456194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1457194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1458194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1459194d53e6SMatthew G. Knepley 1460194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1461194d53e6SMatthew G. Knepley 1462194d53e6SMatthew 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 1463194d53e6SMatthew G. Knepley 1464194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1465194d53e6SMatthew G. Knepley 146630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1467194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1468194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1470194d53e6SMatthew G. Knepley 1471194d53e6SMatthew G. Knepley + dim - the spatial dimension 1472194d53e6SMatthew G. Knepley . Nf - the number of fields 1473194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1474194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1475194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1476194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1477194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1478194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1479194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1480194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1481194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1482194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1483194d53e6SMatthew G. Knepley . t - current time 14842aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1485194d53e6SMatthew G. Knepley . x - coordinates of the current point 148697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 148797b6e6e8SMatthew G. Knepley . constants - constant parameters 1488194d53e6SMatthew G. Knepley - g0 - output values at the current point 1489194d53e6SMatthew G. Knepley 1490194d53e6SMatthew G. Knepley Level: intermediate 1491194d53e6SMatthew G. Knepley 1492194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1493194d53e6SMatthew G. Knepley @*/ 14946528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS ds, PetscInt f, PetscInt g, 149530b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1496194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1497194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 149930b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1500194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1501194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 150330b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1504194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1505194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 150730b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1508194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1509194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 151097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15112764a2aaSMatthew G. Knepley { 15126528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 15136528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 15146528b96dSMatthew G. Knepley 15152764a2aaSMatthew G. Knepley PetscFunctionBegin; 15166528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15172c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 15182c71b3e2SJacob Faibussowitsch PetscCheckFalse((g < 0) || (g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 15195f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 15206528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 15216528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 15226528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 15236528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 15242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15252764a2aaSMatthew G. Knepley } 15262764a2aaSMatthew G. Knepley 1527194d53e6SMatthew G. Knepley /*@C 1528194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1529194d53e6SMatthew G. Knepley 1530194d53e6SMatthew G. Knepley Not collective 1531194d53e6SMatthew G. Knepley 1532194d53e6SMatthew G. Knepley Input Parameters: 15336528b96dSMatthew G. Knepley + ds - The PetscDS 1534194d53e6SMatthew G. Knepley . f - The test field number 1535194d53e6SMatthew G. Knepley . g - The field number 1536194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1537194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1538194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1539194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1540194d53e6SMatthew G. Knepley 1541194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1542194d53e6SMatthew G. Knepley 1543194d53e6SMatthew 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 1544194d53e6SMatthew G. Knepley 1545194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1546194d53e6SMatthew G. Knepley 154730b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1548194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1549194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1551194d53e6SMatthew G. Knepley 1552194d53e6SMatthew G. Knepley + dim - the spatial dimension 1553194d53e6SMatthew G. Knepley . Nf - the number of fields 1554194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1555194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1556194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1557194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1558194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1559194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1560194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1561194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1562194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1563194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1564194d53e6SMatthew G. Knepley . t - current time 15652aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1566194d53e6SMatthew G. Knepley . x - coordinates of the current point 156797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 156897b6e6e8SMatthew G. Knepley . constants - constant parameters 1569194d53e6SMatthew G. Knepley - g0 - output values at the current point 1570194d53e6SMatthew G. Knepley 1571194d53e6SMatthew G. Knepley Level: intermediate 1572194d53e6SMatthew G. Knepley 1573194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1574194d53e6SMatthew G. Knepley @*/ 15756528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS ds, PetscInt f, PetscInt g, 157630b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1577194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1578194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 157997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 158030b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1581194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1582194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 158430b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1585194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1586194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 158830b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1589194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1590194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 159197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15922764a2aaSMatthew G. Knepley { 15932764a2aaSMatthew G. Knepley PetscFunctionBegin; 15946528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15952764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 15962764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 15972764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 15982764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 15992c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 16002c71b3e2SJacob Faibussowitsch PetscCheckFalse(g < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 16015f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 16022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16032764a2aaSMatthew G. Knepley } 16042764a2aaSMatthew G. Knepley 1605475e0ac9SMatthew G. Knepley /*@C 160655c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 160755c1f793SMatthew G. Knepley 160855c1f793SMatthew G. Knepley Not collective 160955c1f793SMatthew G. Knepley 161055c1f793SMatthew G. Knepley Input Parameters: 161155c1f793SMatthew G. Knepley + prob - The PetscDS 161255c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 161355c1f793SMatthew G. Knepley 161455c1f793SMatthew G. Knepley Level: intermediate 161555c1f793SMatthew G. Knepley 161655c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 161755c1f793SMatthew G. Knepley @*/ 161855c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 161955c1f793SMatthew G. Knepley { 162055c1f793SMatthew G. Knepley PetscFunctionBegin; 162155c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 162255c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 162355c1f793SMatthew G. Knepley PetscFunctionReturn(0); 162455c1f793SMatthew G. Knepley } 162555c1f793SMatthew G. Knepley 162655c1f793SMatthew G. Knepley /*@C 1627475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1628475e0ac9SMatthew G. Knepley 1629475e0ac9SMatthew G. Knepley Not collective 1630475e0ac9SMatthew G. Knepley 1631475e0ac9SMatthew G. Knepley Input Parameter: 1632475e0ac9SMatthew G. Knepley . prob - The PetscDS 1633475e0ac9SMatthew G. Knepley 1634475e0ac9SMatthew G. Knepley Output Parameter: 1635475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1636475e0ac9SMatthew G. Knepley 1637475e0ac9SMatthew G. Knepley Level: intermediate 1638475e0ac9SMatthew G. Knepley 1639475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1640475e0ac9SMatthew G. Knepley @*/ 16416528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS ds, PetscBool *hasJacPre) 1642475e0ac9SMatthew G. Knepley { 1643475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16446528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1645475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 16466528b96dSMatthew G. Knepley if (!ds->useJacPre) PetscFunctionReturn(0); 16475f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormHasJacobianPreconditioner(ds->wf, hasJacPre)); 1648475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1649475e0ac9SMatthew G. Knepley } 1650475e0ac9SMatthew G. Knepley 1651475e0ac9SMatthew G. Knepley /*@C 1652475e0ac9SMatthew 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. 1653475e0ac9SMatthew G. Knepley 1654475e0ac9SMatthew G. Knepley Not collective 1655475e0ac9SMatthew G. Knepley 1656475e0ac9SMatthew G. Knepley Input Parameters: 16576528b96dSMatthew G. Knepley + ds - The PetscDS 1658475e0ac9SMatthew G. Knepley . f - The test field number 1659475e0ac9SMatthew G. Knepley - g - The field number 1660475e0ac9SMatthew G. Knepley 1661475e0ac9SMatthew G. Knepley Output Parameters: 1662475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1663475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1664475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1665475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1666475e0ac9SMatthew G. Knepley 1667475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1668475e0ac9SMatthew G. Knepley 1669475e0ac9SMatthew 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 1670475e0ac9SMatthew G. Knepley 1671475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1672475e0ac9SMatthew G. Knepley 1673475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1674475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1675475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1676475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1677475e0ac9SMatthew G. Knepley 1678475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1679475e0ac9SMatthew G. Knepley . Nf - the number of fields 1680475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1681475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1682475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1683475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1684475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1685475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1686475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1687475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1688475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1689475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1690475e0ac9SMatthew G. Knepley . t - current time 1691475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1692475e0ac9SMatthew G. Knepley . x - coordinates of the current point 169397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 169497b6e6e8SMatthew G. Knepley . constants - constant parameters 1695475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1696475e0ac9SMatthew G. Knepley 1697475e0ac9SMatthew G. Knepley Level: intermediate 1698475e0ac9SMatthew G. Knepley 1699475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1700475e0ac9SMatthew G. Knepley @*/ 17016528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1702475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1703475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1704475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1706475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1707475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1708475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1710475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1711475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1712475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1714475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1715475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1716475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1718475e0ac9SMatthew G. Knepley { 17196528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 17206528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 17216528b96dSMatthew G. Knepley 1722475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17236528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 17242c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 17252c71b3e2SJacob Faibussowitsch PetscCheckFalse((g < 0) || (g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 17265f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 17276528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 17286528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 17296528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 17306528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1731475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1732475e0ac9SMatthew G. Knepley } 1733475e0ac9SMatthew G. Knepley 1734475e0ac9SMatthew G. Knepley /*@C 1735475e0ac9SMatthew 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. 1736475e0ac9SMatthew G. Knepley 1737475e0ac9SMatthew G. Knepley Not collective 1738475e0ac9SMatthew G. Knepley 1739475e0ac9SMatthew G. Knepley Input Parameters: 17406528b96dSMatthew G. Knepley + ds - The PetscDS 1741475e0ac9SMatthew G. Knepley . f - The test field number 1742475e0ac9SMatthew G. Knepley . g - The field number 1743475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1744475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1745475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1746475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1747475e0ac9SMatthew G. Knepley 1748475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1749475e0ac9SMatthew G. Knepley 1750475e0ac9SMatthew 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 1751475e0ac9SMatthew G. Knepley 1752475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1753475e0ac9SMatthew G. Knepley 1754475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1755475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1756475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1757475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1758475e0ac9SMatthew G. Knepley 1759475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1760475e0ac9SMatthew G. Knepley . Nf - the number of fields 1761475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1762475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1763475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1764475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1765475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1766475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1767475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1768475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1769475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1770475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1771475e0ac9SMatthew G. Knepley . t - current time 1772475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1773475e0ac9SMatthew G. Knepley . x - coordinates of the current point 177497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 177597b6e6e8SMatthew G. Knepley . constants - constant parameters 1776475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1777475e0ac9SMatthew G. Knepley 1778475e0ac9SMatthew G. Knepley Level: intermediate 1779475e0ac9SMatthew G. Knepley 1780475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1781475e0ac9SMatthew G. Knepley @*/ 17826528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1783475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1784475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1785475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1787475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1788475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1789475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1791475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1792475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1793475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1795475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1796475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1797475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 179897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1799475e0ac9SMatthew G. Knepley { 1800475e0ac9SMatthew G. Knepley PetscFunctionBegin; 18016528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1802475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1803475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1804475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1805475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 18062c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18072c71b3e2SJacob Faibussowitsch PetscCheckFalse(g < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 18085f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1809475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1810475e0ac9SMatthew G. Knepley } 1811475e0ac9SMatthew G. Knepley 1812b7e05686SMatthew G. Knepley /*@C 1813b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1814b7e05686SMatthew G. Knepley 1815b7e05686SMatthew G. Knepley Not collective 1816b7e05686SMatthew G. Knepley 1817b7e05686SMatthew G. Knepley Input Parameter: 18186528b96dSMatthew G. Knepley . ds - The PetscDS 1819b7e05686SMatthew G. Knepley 1820b7e05686SMatthew G. Knepley Output Parameter: 1821b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1822b7e05686SMatthew G. Knepley 1823b7e05686SMatthew G. Knepley Level: intermediate 1824b7e05686SMatthew G. Knepley 1825b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1826b7e05686SMatthew G. Knepley @*/ 18276528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS ds, PetscBool *hasDynJac) 1828b7e05686SMatthew G. Knepley { 1829b7e05686SMatthew G. Knepley PetscFunctionBegin; 18306528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18315f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormHasDynamicJacobian(ds->wf, hasDynJac)); 1832b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1833b7e05686SMatthew G. Knepley } 1834b7e05686SMatthew G. Knepley 1835b7e05686SMatthew G. Knepley /*@C 1836b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1837b7e05686SMatthew G. Knepley 1838b7e05686SMatthew G. Knepley Not collective 1839b7e05686SMatthew G. Knepley 1840b7e05686SMatthew G. Knepley Input Parameters: 18416528b96dSMatthew G. Knepley + ds - The PetscDS 1842b7e05686SMatthew G. Knepley . f - The test field number 1843b7e05686SMatthew G. Knepley - g - The field number 1844b7e05686SMatthew G. Knepley 1845b7e05686SMatthew G. Knepley Output Parameters: 1846b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1847b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1848b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1849b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1850b7e05686SMatthew G. Knepley 1851b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1852b7e05686SMatthew G. Knepley 1853b7e05686SMatthew 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 1854b7e05686SMatthew G. Knepley 1855b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1856b7e05686SMatthew G. Knepley 1857b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1858b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1859b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1860b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1861b7e05686SMatthew G. Knepley 1862b7e05686SMatthew G. Knepley + dim - the spatial dimension 1863b7e05686SMatthew G. Knepley . Nf - the number of fields 1864b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1865b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1866b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1867b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1868b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1869b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1870b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1871b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1872b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1873b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1874b7e05686SMatthew G. Knepley . t - current time 1875b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1876b7e05686SMatthew G. Knepley . x - coordinates of the current point 187797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 187897b6e6e8SMatthew G. Knepley . constants - constant parameters 1879b7e05686SMatthew G. Knepley - g0 - output values at the current point 1880b7e05686SMatthew G. Knepley 1881b7e05686SMatthew G. Knepley Level: intermediate 1882b7e05686SMatthew G. Knepley 1883b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1884b7e05686SMatthew G. Knepley @*/ 18856528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1886b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1887b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1888b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1890b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1891b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1892b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1894b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1895b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1896b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 189797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1898b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1899b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1900b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 190197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1902b7e05686SMatthew G. Knepley { 19036528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 19046528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 19056528b96dSMatthew G. Knepley 1906b7e05686SMatthew G. Knepley PetscFunctionBegin; 19076528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 19082c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 19092c71b3e2SJacob Faibussowitsch PetscCheckFalse((g < 0) || (g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 19105f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetDynamicJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 19116528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 19126528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 19136528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 19146528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1915b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1916b7e05686SMatthew G. Knepley } 1917b7e05686SMatthew G. Knepley 1918b7e05686SMatthew G. Knepley /*@C 1919b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1920b7e05686SMatthew G. Knepley 1921b7e05686SMatthew G. Knepley Not collective 1922b7e05686SMatthew G. Knepley 1923b7e05686SMatthew G. Knepley Input Parameters: 19246528b96dSMatthew G. Knepley + ds - The PetscDS 1925b7e05686SMatthew G. Knepley . f - The test field number 1926b7e05686SMatthew G. Knepley . g - The field number 1927b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1928b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1929b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1930b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1931b7e05686SMatthew G. Knepley 1932b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1933b7e05686SMatthew G. Knepley 1934b7e05686SMatthew 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 1935b7e05686SMatthew G. Knepley 1936b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1937b7e05686SMatthew G. Knepley 1938b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1939b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1940b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1941b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1942b7e05686SMatthew G. Knepley 1943b7e05686SMatthew G. Knepley + dim - the spatial dimension 1944b7e05686SMatthew G. Knepley . Nf - the number of fields 1945b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1946b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1947b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1948b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1949b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1950b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1951b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1952b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1953b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1954b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1955b7e05686SMatthew G. Knepley . t - current time 1956b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1957b7e05686SMatthew G. Knepley . x - coordinates of the current point 195897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 195997b6e6e8SMatthew G. Knepley . constants - constant parameters 1960b7e05686SMatthew G. Knepley - g0 - output values at the current point 1961b7e05686SMatthew G. Knepley 1962b7e05686SMatthew G. Knepley Level: intermediate 1963b7e05686SMatthew G. Knepley 1964b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1965b7e05686SMatthew G. Knepley @*/ 19666528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1967b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1968b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1969b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1971b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1972b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1973b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1975b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1976b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1977b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1979b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1980b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1981b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1983b7e05686SMatthew G. Knepley { 1984b7e05686SMatthew G. Knepley PetscFunctionBegin; 19856528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1986b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1987b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1988b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1989b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 19902c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19912c71b3e2SJacob Faibussowitsch PetscCheckFalse(g < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 19925f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexDynamicJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 1993b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1994b7e05686SMatthew G. Knepley } 1995b7e05686SMatthew G. Knepley 19960c2f2876SMatthew G. Knepley /*@C 19970c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 19980c2f2876SMatthew G. Knepley 19990c2f2876SMatthew G. Knepley Not collective 20000c2f2876SMatthew G. Knepley 20014165533cSJose E. Roman Input Parameters: 20026528b96dSMatthew G. Knepley + ds - The PetscDS object 20030c2f2876SMatthew G. Knepley - f - The field number 20040c2f2876SMatthew G. Knepley 20054165533cSJose E. Roman Output Parameter: 20060c2f2876SMatthew G. Knepley . r - Riemann solver 20070c2f2876SMatthew G. Knepley 20080c2f2876SMatthew G. Knepley Calling sequence for r: 20090c2f2876SMatthew G. Knepley 20105db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20110c2f2876SMatthew G. Knepley 20125db36cf9SMatthew G. Knepley + dim - The spatial dimension 20135db36cf9SMatthew G. Knepley . Nf - The number of fields 20145db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20150c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20160c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20170c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20180c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 201997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 202097b6e6e8SMatthew G. Knepley . constants - constant parameters 20210c2f2876SMatthew G. Knepley - ctx - optional user context 20220c2f2876SMatthew G. Knepley 20230c2f2876SMatthew G. Knepley Level: intermediate 20240c2f2876SMatthew G. Knepley 20250c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 20260c2f2876SMatthew G. Knepley @*/ 20276528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS ds, PetscInt f, 202897b6e6e8SMatthew 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)) 20290c2f2876SMatthew G. Knepley { 20306528b96dSMatthew G. Knepley PetscRiemannFunc *tmp; 20316528b96dSMatthew G. Knepley PetscInt n; 20326528b96dSMatthew G. Knepley 20330c2f2876SMatthew G. Knepley PetscFunctionBegin; 20346528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20350c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 20362c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 20375f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetRiemannSolver(ds->wf, NULL, 0, f, 0, &n, &tmp)); 20386528b96dSMatthew G. Knepley *r = tmp ? tmp[0] : NULL; 20390c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20400c2f2876SMatthew G. Knepley } 20410c2f2876SMatthew G. Knepley 20420c2f2876SMatthew G. Knepley /*@C 20430c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 20440c2f2876SMatthew G. Knepley 20450c2f2876SMatthew G. Knepley Not collective 20460c2f2876SMatthew G. Knepley 20474165533cSJose E. Roman Input Parameters: 20486528b96dSMatthew G. Knepley + ds - The PetscDS object 20490c2f2876SMatthew G. Knepley . f - The field number 20500c2f2876SMatthew G. Knepley - r - Riemann solver 20510c2f2876SMatthew G. Knepley 20520c2f2876SMatthew G. Knepley Calling sequence for r: 20530c2f2876SMatthew G. Knepley 20545db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20550c2f2876SMatthew G. Knepley 20565db36cf9SMatthew G. Knepley + dim - The spatial dimension 20575db36cf9SMatthew G. Knepley . Nf - The number of fields 20585db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20590c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20600c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20610c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20620c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 206397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 206497b6e6e8SMatthew G. Knepley . constants - constant parameters 20650c2f2876SMatthew G. Knepley - ctx - optional user context 20660c2f2876SMatthew G. Knepley 20670c2f2876SMatthew G. Knepley Level: intermediate 20680c2f2876SMatthew G. Knepley 20690c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 20700c2f2876SMatthew G. Knepley @*/ 20716528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS ds, PetscInt f, 207297b6e6e8SMatthew 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)) 20730c2f2876SMatthew G. Knepley { 20740c2f2876SMatthew G. Knepley PetscFunctionBegin; 20756528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2076de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 20772c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20785f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexRiemannSolver(ds->wf, NULL, 0, f, 0, 0, r)); 20790c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20800c2f2876SMatthew G. Knepley } 20810c2f2876SMatthew G. Knepley 208232d2bbc9SMatthew G. Knepley /*@C 208332d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 208432d2bbc9SMatthew G. Knepley 208532d2bbc9SMatthew G. Knepley Not collective 208632d2bbc9SMatthew G. Knepley 208732d2bbc9SMatthew G. Knepley Input Parameters: 20886528b96dSMatthew G. Knepley + ds - The PetscDS 208932d2bbc9SMatthew G. Knepley - f - The field number 209032d2bbc9SMatthew G. Knepley 2091f899ff85SJose E. Roman Output Parameter: 2092a2b725a8SWilliam Gropp . update - update function 209332d2bbc9SMatthew G. Knepley 209432d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 209532d2bbc9SMatthew G. Knepley 209632d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 209732d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 209832d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 209932d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 210032d2bbc9SMatthew G. Knepley 210132d2bbc9SMatthew G. Knepley + dim - the spatial dimension 210232d2bbc9SMatthew G. Knepley . Nf - the number of fields 210332d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 210432d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 210532d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 210632d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 210732d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 210832d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 210932d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 211032d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 211132d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 211232d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 211332d2bbc9SMatthew G. Knepley . t - current time 211432d2bbc9SMatthew G. Knepley . x - coordinates of the current point 211532d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 211632d2bbc9SMatthew G. Knepley 211732d2bbc9SMatthew G. Knepley Level: intermediate 211832d2bbc9SMatthew G. Knepley 211932d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 212032d2bbc9SMatthew G. Knepley @*/ 21216528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS ds, PetscInt f, 212232d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 212332d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 212432d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21253fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 212632d2bbc9SMatthew G. Knepley { 212732d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21286528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21292c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 21306528b96dSMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = ds->update[f];} 213132d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 213232d2bbc9SMatthew G. Knepley } 213332d2bbc9SMatthew G. Knepley 213432d2bbc9SMatthew G. Knepley /*@C 21353fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 213632d2bbc9SMatthew G. Knepley 213732d2bbc9SMatthew G. Knepley Not collective 213832d2bbc9SMatthew G. Knepley 213932d2bbc9SMatthew G. Knepley Input Parameters: 21406528b96dSMatthew G. Knepley + ds - The PetscDS 214132d2bbc9SMatthew G. Knepley . f - The field number 214232d2bbc9SMatthew G. Knepley - update - update function 214332d2bbc9SMatthew G. Knepley 214432d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 214532d2bbc9SMatthew G. Knepley 214632d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 214732d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 214832d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 214932d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 215032d2bbc9SMatthew G. Knepley 215132d2bbc9SMatthew G. Knepley + dim - the spatial dimension 215232d2bbc9SMatthew G. Knepley . Nf - the number of fields 215332d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 215432d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 215532d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 215632d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 215732d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 215832d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 215932d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 216032d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 216132d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 216232d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 216332d2bbc9SMatthew G. Knepley . t - current time 216432d2bbc9SMatthew G. Knepley . x - coordinates of the current point 216532d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 216632d2bbc9SMatthew G. Knepley 216732d2bbc9SMatthew G. Knepley Level: intermediate 216832d2bbc9SMatthew G. Knepley 216932d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 217032d2bbc9SMatthew G. Knepley @*/ 21716528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS ds, PetscInt f, 217232d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 217332d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 217432d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21753fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 217632d2bbc9SMatthew G. Knepley { 217732d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21786528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 217932d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 21802c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21815f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSEnlarge_Static(ds, f+1)); 21826528b96dSMatthew G. Knepley ds->update[f] = update; 218332d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 218432d2bbc9SMatthew G. Knepley } 218532d2bbc9SMatthew G. Knepley 21863ec1f749SStefano Zampini PetscErrorCode PetscDSGetContext(PetscDS ds, PetscInt f, void *ctx) 21870c2f2876SMatthew G. Knepley { 21880c2f2876SMatthew G. Knepley PetscFunctionBegin; 21896528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21902c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 21910c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 21923ec1f749SStefano Zampini *(void**)ctx = ds->ctx[f]; 21930c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 21940c2f2876SMatthew G. Knepley } 21950c2f2876SMatthew G. Knepley 21966528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS ds, PetscInt f, void *ctx) 21970c2f2876SMatthew G. Knepley { 21980c2f2876SMatthew G. Knepley PetscFunctionBegin; 21996528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 22002c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 22015f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSEnlarge_Static(ds, f+1)); 22026528b96dSMatthew G. Knepley ds->ctx[f] = ctx; 22030c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 22040c2f2876SMatthew G. Knepley } 22050c2f2876SMatthew G. Knepley 2206194d53e6SMatthew G. Knepley /*@C 2207194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 2208194d53e6SMatthew G. Knepley 2209194d53e6SMatthew G. Knepley Not collective 2210194d53e6SMatthew G. Knepley 2211194d53e6SMatthew G. Knepley Input Parameters: 22126528b96dSMatthew G. Knepley + ds - The PetscDS 2213194d53e6SMatthew G. Knepley - f - The test field number 2214194d53e6SMatthew G. Knepley 2215194d53e6SMatthew G. Knepley Output Parameters: 2216194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 2217194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2218194d53e6SMatthew G. Knepley 2219194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2220194d53e6SMatthew G. Knepley 2221194d53e6SMatthew 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 2222194d53e6SMatthew G. Knepley 2223194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2224194d53e6SMatthew G. Knepley 222530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2226194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2227194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 222830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2229194d53e6SMatthew G. Knepley 2230194d53e6SMatthew G. Knepley + dim - the spatial dimension 2231194d53e6SMatthew G. Knepley . Nf - the number of fields 2232194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2233194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2234194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2235194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2236194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2237194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2238194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2239194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2240194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2241194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2242194d53e6SMatthew G. Knepley . t - current time 2243194d53e6SMatthew G. Knepley . x - coordinates of the current point 2244194d53e6SMatthew G. Knepley . n - unit normal at the current point 224597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 224697b6e6e8SMatthew G. Knepley . constants - constant parameters 2247194d53e6SMatthew G. Knepley - f0 - output values at the current point 2248194d53e6SMatthew G. Knepley 2249194d53e6SMatthew G. Knepley Level: intermediate 2250194d53e6SMatthew G. Knepley 2251194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 2252194d53e6SMatthew G. Knepley @*/ 22536528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS ds, PetscInt f, 225430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2255194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2256194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 225830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2259194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2260194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 226197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 22622764a2aaSMatthew G. Knepley { 22636528b96dSMatthew G. Knepley PetscBdPointFunc *tmp0, *tmp1; 22646528b96dSMatthew G. Knepley PetscInt n0, n1; 22656528b96dSMatthew G. Knepley 22662764a2aaSMatthew G. Knepley PetscFunctionBegin; 22676528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 22682c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 22695f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetBdResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1)); 22706528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 22716528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 22722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22732764a2aaSMatthew G. Knepley } 22742764a2aaSMatthew G. Knepley 2275194d53e6SMatthew G. Knepley /*@C 2276194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2277194d53e6SMatthew G. Knepley 2278194d53e6SMatthew G. Knepley Not collective 2279194d53e6SMatthew G. Knepley 2280194d53e6SMatthew G. Knepley Input Parameters: 22816528b96dSMatthew G. Knepley + ds - The PetscDS 2282194d53e6SMatthew G. Knepley . f - The test field number 2283194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2284194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2285194d53e6SMatthew G. Knepley 2286194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2287194d53e6SMatthew G. Knepley 2288194d53e6SMatthew 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 2289194d53e6SMatthew G. Knepley 2290194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2291194d53e6SMatthew G. Knepley 229230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2293194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2294194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 229530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2296194d53e6SMatthew G. Knepley 2297194d53e6SMatthew G. Knepley + dim - the spatial dimension 2298194d53e6SMatthew G. Knepley . Nf - the number of fields 2299194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2300194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2301194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2302194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2303194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2304194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2305194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2306194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2307194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2308194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2309194d53e6SMatthew G. Knepley . t - current time 2310194d53e6SMatthew G. Knepley . x - coordinates of the current point 2311194d53e6SMatthew G. Knepley . n - unit normal at the current point 231297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 231397b6e6e8SMatthew G. Knepley . constants - constant parameters 2314194d53e6SMatthew G. Knepley - f0 - output values at the current point 2315194d53e6SMatthew G. Knepley 2316194d53e6SMatthew G. Knepley Level: intermediate 2317194d53e6SMatthew G. Knepley 2318194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2319194d53e6SMatthew G. Knepley @*/ 23206528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS ds, PetscInt f, 232130b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2322194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2323194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 232530b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2326194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2327194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 23292764a2aaSMatthew G. Knepley { 23302764a2aaSMatthew G. Knepley PetscFunctionBegin; 23316528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23322c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 23335f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexBdResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1)); 23342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23352764a2aaSMatthew G. Knepley } 23362764a2aaSMatthew G. Knepley 233727f02ce8SMatthew G. Knepley /*@ 233827f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 233927f02ce8SMatthew G. Knepley 234027f02ce8SMatthew G. Knepley Not collective 234127f02ce8SMatthew G. Knepley 234227f02ce8SMatthew G. Knepley Input Parameter: 23436528b96dSMatthew G. Knepley . ds - The PetscDS 234427f02ce8SMatthew G. Knepley 234527f02ce8SMatthew G. Knepley Output Parameter: 234627f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 234727f02ce8SMatthew G. Knepley 234827f02ce8SMatthew G. Knepley Level: intermediate 234927f02ce8SMatthew G. Knepley 235027f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 235127f02ce8SMatthew G. Knepley @*/ 23526528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS ds, PetscBool *hasBdJac) 235327f02ce8SMatthew G. Knepley { 235427f02ce8SMatthew G. Knepley PetscFunctionBegin; 23556528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23566528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJac, 2); 23575f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormHasBdJacobian(ds->wf, hasBdJac)); 235827f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 235927f02ce8SMatthew G. Knepley } 236027f02ce8SMatthew G. Knepley 2361194d53e6SMatthew G. Knepley /*@C 2362194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2363194d53e6SMatthew G. Knepley 2364194d53e6SMatthew G. Knepley Not collective 2365194d53e6SMatthew G. Knepley 2366194d53e6SMatthew G. Knepley Input Parameters: 23676528b96dSMatthew G. Knepley + ds - The PetscDS 2368194d53e6SMatthew G. Knepley . f - The test field number 2369194d53e6SMatthew G. Knepley - g - The field number 2370194d53e6SMatthew G. Knepley 2371194d53e6SMatthew G. Knepley Output Parameters: 2372194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2373194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2374194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2375194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2376194d53e6SMatthew G. Knepley 2377194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2378194d53e6SMatthew G. Knepley 2379194d53e6SMatthew 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 2380194d53e6SMatthew G. Knepley 2381194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2382194d53e6SMatthew G. Knepley 238330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2384194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2385194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 238630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2387194d53e6SMatthew G. Knepley 2388194d53e6SMatthew G. Knepley + dim - the spatial dimension 2389194d53e6SMatthew G. Knepley . Nf - the number of fields 2390194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2391194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2392194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2393194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2394194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2395194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2396194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2397194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2398194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2399194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2400194d53e6SMatthew G. Knepley . t - current time 24012aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2402194d53e6SMatthew G. Knepley . x - coordinates of the current point 2403194d53e6SMatthew G. Knepley . n - normal at the current point 240497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 240597b6e6e8SMatthew G. Knepley . constants - constant parameters 2406194d53e6SMatthew G. Knepley - g0 - output values at the current point 2407194d53e6SMatthew G. Knepley 2408194d53e6SMatthew G. Knepley Level: intermediate 2409194d53e6SMatthew G. Knepley 2410194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2411194d53e6SMatthew G. Knepley @*/ 24126528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 241330b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2414194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2415194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 241730b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2418194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2419194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 242130b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2422194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2423194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 242530b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2426194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2427194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 242897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 24292764a2aaSMatthew G. Knepley { 24306528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 24316528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 24326528b96dSMatthew G. Knepley 24332764a2aaSMatthew G. Knepley PetscFunctionBegin; 24346528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 24352c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 24362c71b3e2SJacob Faibussowitsch PetscCheckFalse((g < 0) || (g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 24375f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetBdJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 24386528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 24396528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 24406528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 24416528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 24422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24432764a2aaSMatthew G. Knepley } 24442764a2aaSMatthew G. Knepley 2445194d53e6SMatthew G. Knepley /*@C 2446194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2447194d53e6SMatthew G. Knepley 2448194d53e6SMatthew G. Knepley Not collective 2449194d53e6SMatthew G. Knepley 2450194d53e6SMatthew G. Knepley Input Parameters: 24516528b96dSMatthew G. Knepley + ds - The PetscDS 2452194d53e6SMatthew G. Knepley . f - The test field number 2453194d53e6SMatthew G. Knepley . g - The field number 2454194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2455194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2456194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2457194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2458194d53e6SMatthew G. Knepley 2459194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2460194d53e6SMatthew G. Knepley 2461194d53e6SMatthew 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 2462194d53e6SMatthew G. Knepley 2463194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2464194d53e6SMatthew G. Knepley 246530b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2466194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2467194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 246830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2469194d53e6SMatthew G. Knepley 2470194d53e6SMatthew G. Knepley + dim - the spatial dimension 2471194d53e6SMatthew G. Knepley . Nf - the number of fields 2472194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2473194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2474194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2475194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2476194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2477194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2478194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2479194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2480194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2481194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2482194d53e6SMatthew G. Knepley . t - current time 24832aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2484194d53e6SMatthew G. Knepley . x - coordinates of the current point 2485194d53e6SMatthew G. Knepley . n - normal at the current point 248697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 248797b6e6e8SMatthew G. Knepley . constants - constant parameters 2488194d53e6SMatthew G. Knepley - g0 - output values at the current point 2489194d53e6SMatthew G. Knepley 2490194d53e6SMatthew G. Knepley Level: intermediate 2491194d53e6SMatthew G. Knepley 2492194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2493194d53e6SMatthew G. Knepley @*/ 24946528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 249530b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2496194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2497194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 249930b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2500194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2501194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 250330b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2504194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2505194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 250697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 250730b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2508194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2509194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 251097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 25112764a2aaSMatthew G. Knepley { 25122764a2aaSMatthew G. Knepley PetscFunctionBegin; 25136528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25142764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 25152764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 25162764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 25172764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 25182c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 25192c71b3e2SJacob Faibussowitsch PetscCheckFalse(g < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 25205f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexBdJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 25212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25222764a2aaSMatthew G. Knepley } 25232764a2aaSMatthew G. Knepley 252427f02ce8SMatthew G. Knepley /*@ 252527f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 252627f02ce8SMatthew G. Knepley 252727f02ce8SMatthew G. Knepley Not collective 252827f02ce8SMatthew G. Knepley 252927f02ce8SMatthew G. Knepley Input Parameter: 25306528b96dSMatthew G. Knepley . ds - The PetscDS 253127f02ce8SMatthew G. Knepley 253227f02ce8SMatthew G. Knepley Output Parameter: 253327f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 253427f02ce8SMatthew G. Knepley 253527f02ce8SMatthew G. Knepley Level: intermediate 253627f02ce8SMatthew G. Knepley 253727f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 253827f02ce8SMatthew G. Knepley @*/ 25396528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS ds, PetscBool *hasBdJacPre) 254027f02ce8SMatthew G. Knepley { 254127f02ce8SMatthew G. Knepley PetscFunctionBegin; 25426528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25436528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJacPre, 2); 25445f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormHasBdJacobianPreconditioner(ds->wf, hasBdJacPre)); 254527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 254627f02ce8SMatthew G. Knepley } 254727f02ce8SMatthew G. Knepley 254827f02ce8SMatthew G. Knepley /*@C 254927f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 255027f02ce8SMatthew G. Knepley 255127f02ce8SMatthew G. Knepley Not collective 255227f02ce8SMatthew G. Knepley 255327f02ce8SMatthew G. Knepley Input Parameters: 25546528b96dSMatthew G. Knepley + ds - The PetscDS 255527f02ce8SMatthew G. Knepley . f - The test field number 255627f02ce8SMatthew G. Knepley - g - The field number 255727f02ce8SMatthew G. Knepley 255827f02ce8SMatthew G. Knepley Output Parameters: 255927f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 256027f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 256127f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 256227f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 256327f02ce8SMatthew G. Knepley 256427f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 256527f02ce8SMatthew G. Knepley 256627f02ce8SMatthew 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 256727f02ce8SMatthew G. Knepley 256827f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 256927f02ce8SMatthew G. Knepley 257027f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 257127f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 257227f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 257327f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 257427f02ce8SMatthew G. Knepley 257527f02ce8SMatthew G. Knepley + dim - the spatial dimension 257627f02ce8SMatthew G. Knepley . Nf - the number of fields 257727f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 257827f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 257927f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 258027f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 258127f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 258227f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 258327f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 258427f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 258527f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 258627f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 258727f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 258827f02ce8SMatthew G. Knepley . t - current time 258927f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 259027f02ce8SMatthew G. Knepley . x - coordinates of the current point 259127f02ce8SMatthew G. Knepley . n - normal at the current point 259227f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 259327f02ce8SMatthew G. Knepley . constants - constant parameters 259427f02ce8SMatthew G. Knepley - g0 - output values at the current point 259527f02ce8SMatthew G. Knepley 259627f02ce8SMatthew G. Knepley This is not yet available in Fortran. 259727f02ce8SMatthew G. Knepley 259827f02ce8SMatthew G. Knepley Level: intermediate 259927f02ce8SMatthew G. Knepley 260027f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 260127f02ce8SMatthew G. Knepley @*/ 26026528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 260327f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 260727f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260827f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260927f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261027f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 261127f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 261227f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261327f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261427f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 261527f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 261627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 261727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 261827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 261927f02ce8SMatthew G. Knepley { 26206528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 26216528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 26226528b96dSMatthew G. Knepley 262327f02ce8SMatthew G. Knepley PetscFunctionBegin; 26246528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 26252c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 26262c71b3e2SJacob Faibussowitsch PetscCheckFalse((g < 0) || (g >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 26275f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormGetBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3)); 26286528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 26296528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 26306528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 26316528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 263227f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 263327f02ce8SMatthew G. Knepley } 263427f02ce8SMatthew G. Knepley 263527f02ce8SMatthew G. Knepley /*@C 263627f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 263727f02ce8SMatthew G. Knepley 263827f02ce8SMatthew G. Knepley Not collective 263927f02ce8SMatthew G. Knepley 264027f02ce8SMatthew G. Knepley Input Parameters: 26416528b96dSMatthew G. Knepley + ds - The PetscDS 264227f02ce8SMatthew G. Knepley . f - The test field number 264327f02ce8SMatthew G. Knepley . g - The field number 264427f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 264527f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 264627f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 264727f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 264827f02ce8SMatthew G. Knepley 264927f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 265027f02ce8SMatthew G. Knepley 265127f02ce8SMatthew 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 265227f02ce8SMatthew G. Knepley 265327f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 265427f02ce8SMatthew G. Knepley 265527f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 265627f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 265727f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 265827f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 265927f02ce8SMatthew G. Knepley 266027f02ce8SMatthew G. Knepley + dim - the spatial dimension 266127f02ce8SMatthew G. Knepley . Nf - the number of fields 266227f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 266327f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 266427f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 266527f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 266627f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 266727f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 266827f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 266927f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 267027f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 267127f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 267227f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 267327f02ce8SMatthew G. Knepley . t - current time 267427f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 267527f02ce8SMatthew G. Knepley . x - coordinates of the current point 267627f02ce8SMatthew G. Knepley . n - normal at the current point 267727f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 267827f02ce8SMatthew G. Knepley . constants - constant parameters 267927f02ce8SMatthew G. Knepley - g0 - output values at the current point 268027f02ce8SMatthew G. Knepley 268127f02ce8SMatthew G. Knepley This is not yet available in Fortran. 268227f02ce8SMatthew G. Knepley 268327f02ce8SMatthew G. Knepley Level: intermediate 268427f02ce8SMatthew G. Knepley 268527f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 268627f02ce8SMatthew G. Knepley @*/ 26876528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 268827f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 268927f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269027f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269127f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 269227f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269327f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269427f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269527f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 269627f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269727f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269827f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269927f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 270027f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 270127f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 270227f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 270327f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 270427f02ce8SMatthew G. Knepley { 270527f02ce8SMatthew G. Knepley PetscFunctionBegin; 27066528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 270727f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 270827f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 270927f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 271027f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 27112c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 27122c71b3e2SJacob Faibussowitsch PetscCheckFalse(g < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 27135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetIndexBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3)); 271427f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 271527f02ce8SMatthew G. Knepley } 271627f02ce8SMatthew G. Knepley 27170d3e9b51SMatthew G. Knepley /*@C 2718c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2719c371a6d1SMatthew G. Knepley 2720c371a6d1SMatthew G. Knepley Not collective 2721c371a6d1SMatthew G. Knepley 2722c371a6d1SMatthew G. Knepley Input Parameters: 2723c371a6d1SMatthew G. Knepley + prob - The PetscDS 2724c371a6d1SMatthew G. Knepley - f - The test field number 2725c371a6d1SMatthew G. Knepley 2726d8d19677SJose E. Roman Output Parameters: 272795cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 272895cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2729c371a6d1SMatthew G. Knepley 2730c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2731c371a6d1SMatthew G. Knepley 2732c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2733c371a6d1SMatthew G. Knepley 2734c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2735c371a6d1SMatthew G. Knepley . t - current time 2736c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2737c371a6d1SMatthew G. Knepley . Nc - the number of field components 2738c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2739c371a6d1SMatthew G. Knepley - ctx - a user context 2740c371a6d1SMatthew G. Knepley 2741c371a6d1SMatthew G. Knepley Level: intermediate 2742c371a6d1SMatthew G. Knepley 2743f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolution(), PetscDSGetExactSolutionTimeDerivative() 2744c371a6d1SMatthew G. Knepley @*/ 274595cbbfd3SMatthew 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) 2746c371a6d1SMatthew G. Knepley { 2747c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2748c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27492c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 2750c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 275195cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2752c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2753c371a6d1SMatthew G. Knepley } 2754c371a6d1SMatthew G. Knepley 2755c371a6d1SMatthew G. Knepley /*@C 2756578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2757c371a6d1SMatthew G. Knepley 2758c371a6d1SMatthew G. Knepley Not collective 2759c371a6d1SMatthew G. Knepley 2760c371a6d1SMatthew G. Knepley Input Parameters: 2761c371a6d1SMatthew G. Knepley + prob - The PetscDS 2762c371a6d1SMatthew G. Knepley . f - The test field number 276395cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 276495cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2765c371a6d1SMatthew G. Knepley 2766c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2767c371a6d1SMatthew G. Knepley 2768c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2769c371a6d1SMatthew G. Knepley 2770c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2771c371a6d1SMatthew G. Knepley . t - current time 2772c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2773c371a6d1SMatthew G. Knepley . Nc - the number of field components 2774c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2775c371a6d1SMatthew G. Knepley - ctx - a user context 2776c371a6d1SMatthew G. Knepley 2777c371a6d1SMatthew G. Knepley Level: intermediate 2778c371a6d1SMatthew G. Knepley 2779c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2780c371a6d1SMatthew G. Knepley @*/ 278195cbbfd3SMatthew 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) 2782c371a6d1SMatthew G. Knepley { 2783c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2784c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27852c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 27865f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSEnlarge_Static(prob, f+1)); 2787c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 278895cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2789c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2790c371a6d1SMatthew G. Knepley } 2791c371a6d1SMatthew G. Knepley 27925638fd0eSMatthew G. Knepley /*@C 2793f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2794f2cacb80SMatthew G. Knepley 2795f2cacb80SMatthew G. Knepley Not collective 2796f2cacb80SMatthew G. Knepley 2797f2cacb80SMatthew G. Knepley Input Parameters: 2798f2cacb80SMatthew G. Knepley + prob - The PetscDS 2799f2cacb80SMatthew G. Knepley - f - The test field number 2800f2cacb80SMatthew G. Knepley 2801d8d19677SJose E. Roman Output Parameters: 2802f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2803f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2804f2cacb80SMatthew G. Knepley 2805f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2806f2cacb80SMatthew G. Knepley 2807f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2808f2cacb80SMatthew G. Knepley 2809f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2810f2cacb80SMatthew G. Knepley . t - current time 2811f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2812f2cacb80SMatthew G. Knepley . Nc - the number of field components 2813f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2814f2cacb80SMatthew G. Knepley - ctx - a user context 2815f2cacb80SMatthew G. Knepley 2816f2cacb80SMatthew G. Knepley Level: intermediate 2817f2cacb80SMatthew G. Knepley 2818f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolutionTimeDerivative(), PetscDSGetExactSolution() 2819f2cacb80SMatthew G. Knepley @*/ 2820f2cacb80SMatthew 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) 2821f2cacb80SMatthew G. Knepley { 2822f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2823f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28242c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 2825f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2826f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2827f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2828f2cacb80SMatthew G. Knepley } 2829f2cacb80SMatthew G. Knepley 2830f2cacb80SMatthew G. Knepley /*@C 2831f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2832f2cacb80SMatthew G. Knepley 2833f2cacb80SMatthew G. Knepley Not collective 2834f2cacb80SMatthew G. Knepley 2835f2cacb80SMatthew G. Knepley Input Parameters: 2836f2cacb80SMatthew G. Knepley + prob - The PetscDS 2837f2cacb80SMatthew G. Knepley . f - The test field number 2838f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2839f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2840f2cacb80SMatthew G. Knepley 2841f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2842f2cacb80SMatthew G. Knepley 2843f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2844f2cacb80SMatthew G. Knepley 2845f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2846f2cacb80SMatthew G. Knepley . t - current time 2847f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2848f2cacb80SMatthew G. Knepley . Nc - the number of field components 2849f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2850f2cacb80SMatthew G. Knepley - ctx - a user context 2851f2cacb80SMatthew G. Knepley 2852f2cacb80SMatthew G. Knepley Level: intermediate 2853f2cacb80SMatthew G. Knepley 2854f2cacb80SMatthew G. Knepley .seealso: PetscDSGetExactSolutionTimeDerivative(), PetscDSSetExactSolution() 2855f2cacb80SMatthew G. Knepley @*/ 2856f2cacb80SMatthew 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) 2857f2cacb80SMatthew G. Knepley { 2858f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2859f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28602c71b3e2SJacob Faibussowitsch PetscCheckFalse(f < 0,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 28615f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSEnlarge_Static(prob, f+1)); 2862f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2863f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2864f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2865f2cacb80SMatthew G. Knepley } 2866f2cacb80SMatthew G. Knepley 2867f2cacb80SMatthew G. Knepley /*@C 286897b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 286997b6e6e8SMatthew G. Knepley 287097b6e6e8SMatthew G. Knepley Not collective 287197b6e6e8SMatthew G. Knepley 287297b6e6e8SMatthew G. Knepley Input Parameter: 287397b6e6e8SMatthew G. Knepley . prob - The PetscDS object 287497b6e6e8SMatthew G. Knepley 287597b6e6e8SMatthew G. Knepley Output Parameters: 287697b6e6e8SMatthew G. Knepley + numConstants - The number of constants 287797b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 287897b6e6e8SMatthew G. Knepley 287997b6e6e8SMatthew G. Knepley Level: intermediate 288097b6e6e8SMatthew G. Knepley 288197b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 288297b6e6e8SMatthew G. Knepley @*/ 288397b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 288497b6e6e8SMatthew G. Knepley { 288597b6e6e8SMatthew G. Knepley PetscFunctionBegin; 288697b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 288797b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 288897b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 288997b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 289097b6e6e8SMatthew G. Knepley } 289197b6e6e8SMatthew G. Knepley 28920d3e9b51SMatthew G. Knepley /*@C 289397b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 289497b6e6e8SMatthew G. Knepley 289597b6e6e8SMatthew G. Knepley Not collective 289697b6e6e8SMatthew G. Knepley 289797b6e6e8SMatthew G. Knepley Input Parameters: 289897b6e6e8SMatthew G. Knepley + prob - The PetscDS object 289997b6e6e8SMatthew G. Knepley . numConstants - The number of constants 290097b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 290197b6e6e8SMatthew G. Knepley 290297b6e6e8SMatthew G. Knepley Level: intermediate 290397b6e6e8SMatthew G. Knepley 290497b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 290597b6e6e8SMatthew G. Knepley @*/ 290697b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 290797b6e6e8SMatthew G. Knepley { 290897b6e6e8SMatthew G. Knepley PetscFunctionBegin; 290997b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 291097b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 29115f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(prob->constants)); 291297b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 291397b6e6e8SMatthew G. Knepley if (prob->numConstants) { 29145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(prob->numConstants, &prob->constants)); 291520be0f5bSMatthew G. Knepley } else { 291620be0f5bSMatthew G. Knepley prob->constants = NULL; 291720be0f5bSMatthew G. Knepley } 291820be0f5bSMatthew G. Knepley } 291920be0f5bSMatthew G. Knepley if (prob->numConstants) { 292020be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 29215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscArraycpy(prob->constants, constants, prob->numConstants)); 292297b6e6e8SMatthew G. Knepley } 292397b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 292497b6e6e8SMatthew G. Knepley } 292597b6e6e8SMatthew G. Knepley 29264cd1e086SMatthew G. Knepley /*@ 29274cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 29284cd1e086SMatthew G. Knepley 29294cd1e086SMatthew G. Knepley Not collective 29304cd1e086SMatthew G. Knepley 29314cd1e086SMatthew G. Knepley Input Parameters: 29324cd1e086SMatthew G. Knepley + prob - The PetscDS object 29334cd1e086SMatthew G. Knepley - disc - The discretization object 29344cd1e086SMatthew G. Knepley 29354cd1e086SMatthew G. Knepley Output Parameter: 29364cd1e086SMatthew G. Knepley . f - The field number 29374cd1e086SMatthew G. Knepley 29384cd1e086SMatthew G. Knepley Level: beginner 29394cd1e086SMatthew G. Knepley 2940f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 29414cd1e086SMatthew G. Knepley @*/ 29424cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 29434cd1e086SMatthew G. Knepley { 29444cd1e086SMatthew G. Knepley PetscInt g; 29454cd1e086SMatthew G. Knepley 29464cd1e086SMatthew G. Knepley PetscFunctionBegin; 29474cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29484cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 29494cd1e086SMatthew G. Knepley *f = -1; 29504cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 29512c71b3e2SJacob Faibussowitsch PetscCheckFalse(g == prob->Nf,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 29524cd1e086SMatthew G. Knepley *f = g; 29534cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29544cd1e086SMatthew G. Knepley } 29554cd1e086SMatthew G. Knepley 29564cd1e086SMatthew G. Knepley /*@ 29574cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 29584cd1e086SMatthew G. Knepley 29594cd1e086SMatthew G. Knepley Not collective 29604cd1e086SMatthew G. Knepley 29614cd1e086SMatthew G. Knepley Input Parameters: 29624cd1e086SMatthew G. Knepley + prob - The PetscDS object 29634cd1e086SMatthew G. Knepley - f - The field number 29644cd1e086SMatthew G. Knepley 29654cd1e086SMatthew G. Knepley Output Parameter: 29664cd1e086SMatthew G. Knepley . size - The size 29674cd1e086SMatthew G. Knepley 29684cd1e086SMatthew G. Knepley Level: beginner 29694cd1e086SMatthew G. Knepley 2970f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 29714cd1e086SMatthew G. Knepley @*/ 29724cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 29734cd1e086SMatthew G. Knepley { 29744cd1e086SMatthew G. Knepley PetscFunctionBegin; 29754cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29764cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 29772c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 29785f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 2979d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 29804cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29814cd1e086SMatthew G. Knepley } 29824cd1e086SMatthew G. Knepley 2983bc4ae4beSMatthew G. Knepley /*@ 2984bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2985bc4ae4beSMatthew G. Knepley 2986bc4ae4beSMatthew G. Knepley Not collective 2987bc4ae4beSMatthew G. Knepley 2988bc4ae4beSMatthew G. Knepley Input Parameters: 2989bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2990bc4ae4beSMatthew G. Knepley - f - The field number 2991bc4ae4beSMatthew G. Knepley 2992bc4ae4beSMatthew G. Knepley Output Parameter: 2993bc4ae4beSMatthew G. Knepley . off - The offset 2994bc4ae4beSMatthew G. Knepley 2995bc4ae4beSMatthew G. Knepley Level: beginner 2996bc4ae4beSMatthew G. Knepley 2997f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2998bc4ae4beSMatthew G. Knepley @*/ 29992764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 30002764a2aaSMatthew G. Knepley { 30014cd1e086SMatthew G. Knepley PetscInt size, g; 30022764a2aaSMatthew G. Knepley 30032764a2aaSMatthew G. Knepley PetscFunctionBegin; 30042764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30052764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 30062c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 30072764a2aaSMatthew G. Knepley *off = 0; 30082764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 30095f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetFieldSize(prob, g, &size)); 30104cd1e086SMatthew G. Knepley *off += size; 30112764a2aaSMatthew G. Knepley } 30122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30132764a2aaSMatthew G. Knepley } 30142764a2aaSMatthew G. Knepley 3015bc4ae4beSMatthew G. Knepley /*@ 30165fedec97SMatthew G. Knepley PetscDSGetFieldOffsetCohesive - Returns the offset of the given field in the full space basis on a cohesive cell 30175fedec97SMatthew G. Knepley 30185fedec97SMatthew G. Knepley Not collective 30195fedec97SMatthew G. Knepley 30205fedec97SMatthew G. Knepley Input Parameters: 30215fedec97SMatthew G. Knepley + prob - The PetscDS object 30225fedec97SMatthew G. Knepley - f - The field number 30235fedec97SMatthew G. Knepley 30245fedec97SMatthew G. Knepley Output Parameter: 30255fedec97SMatthew G. Knepley . off - The offset 30265fedec97SMatthew G. Knepley 30275fedec97SMatthew G. Knepley Level: beginner 30285fedec97SMatthew G. Knepley 30295fedec97SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 30305fedec97SMatthew G. Knepley @*/ 30315fedec97SMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffsetCohesive(PetscDS ds, PetscInt f, PetscInt *off) 30325fedec97SMatthew G. Knepley { 30335fedec97SMatthew G. Knepley PetscInt size, g; 30345fedec97SMatthew G. Knepley 30355fedec97SMatthew G. Knepley PetscFunctionBegin; 30365fedec97SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 30375fedec97SMatthew G. Knepley PetscValidPointer(off, 3); 30382c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= ds->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 30395fedec97SMatthew G. Knepley *off = 0; 30405fedec97SMatthew G. Knepley for (g = 0; g < f; ++g) { 30415fedec97SMatthew G. Knepley PetscBool cohesive; 30425fedec97SMatthew G. Knepley 30435f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetCohesive(ds, g, &cohesive)); 30445f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetFieldSize(ds, g, &size)); 30455fedec97SMatthew G. Knepley *off += cohesive ? size : size*2; 30465fedec97SMatthew G. Knepley } 30475fedec97SMatthew G. Knepley PetscFunctionReturn(0); 30485fedec97SMatthew G. Knepley } 30495fedec97SMatthew G. Knepley 30505fedec97SMatthew G. Knepley /*@ 305147e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 3052bc4ae4beSMatthew G. Knepley 3053bc4ae4beSMatthew G. Knepley Not collective 3054bc4ae4beSMatthew G. Knepley 305547e57110SSander Arens Input Parameter: 305647e57110SSander Arens . prob - The PetscDS object 3057bc4ae4beSMatthew G. Knepley 3058bc4ae4beSMatthew G. Knepley Output Parameter: 305947e57110SSander Arens . dimensions - The number of dimensions 3060bc4ae4beSMatthew G. Knepley 3061bc4ae4beSMatthew G. Knepley Level: beginner 3062bc4ae4beSMatthew G. Knepley 306347e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 3064bc4ae4beSMatthew G. Knepley @*/ 306547e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 30662764a2aaSMatthew G. Knepley { 30672764a2aaSMatthew G. Knepley PetscFunctionBegin; 30682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30695f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 307047e57110SSander Arens PetscValidPointer(dimensions, 2); 307147e57110SSander Arens *dimensions = prob->Nb; 307247e57110SSander Arens PetscFunctionReturn(0); 30736ce16762SMatthew G. Knepley } 307447e57110SSander Arens 307547e57110SSander Arens /*@ 307647e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 307747e57110SSander Arens 307847e57110SSander Arens Not collective 307947e57110SSander Arens 308047e57110SSander Arens Input Parameter: 308147e57110SSander Arens . prob - The PetscDS object 308247e57110SSander Arens 308347e57110SSander Arens Output Parameter: 308447e57110SSander Arens . components - The number of components 308547e57110SSander Arens 308647e57110SSander Arens Level: beginner 308747e57110SSander Arens 308847e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 308947e57110SSander Arens @*/ 309047e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 309147e57110SSander Arens { 309247e57110SSander Arens PetscFunctionBegin; 309347e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30945f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 309547e57110SSander Arens PetscValidPointer(components, 2); 309647e57110SSander Arens *components = prob->Nc; 30976ce16762SMatthew G. Knepley PetscFunctionReturn(0); 30986ce16762SMatthew G. Knepley } 30996ce16762SMatthew G. Knepley 31006ce16762SMatthew G. Knepley /*@ 31016ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 31026ce16762SMatthew G. Knepley 31036ce16762SMatthew G. Knepley Not collective 31046ce16762SMatthew G. Knepley 31056ce16762SMatthew G. Knepley Input Parameters: 31066ce16762SMatthew G. Knepley + prob - The PetscDS object 31076ce16762SMatthew G. Knepley - f - The field number 31086ce16762SMatthew G. Knepley 31096ce16762SMatthew G. Knepley Output Parameter: 31106ce16762SMatthew G. Knepley . off - The offset 31116ce16762SMatthew G. Knepley 31126ce16762SMatthew G. Knepley Level: beginner 31136ce16762SMatthew G. Knepley 3114f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 31156ce16762SMatthew G. Knepley @*/ 31166ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 31176ce16762SMatthew G. Knepley { 31186ce16762SMatthew G. Knepley PetscFunctionBegin; 31196ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 31206ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 31212c71b3e2SJacob Faibussowitsch PetscCheckFalse((f < 0) || (f >= prob->Nf),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 31225f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 312347e57110SSander Arens *off = prob->off[f]; 31242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31252764a2aaSMatthew G. Knepley } 31262764a2aaSMatthew G. Knepley 3127194d53e6SMatthew G. Knepley /*@ 3128194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 3129194d53e6SMatthew G. Knepley 3130194d53e6SMatthew G. Knepley Not collective 3131194d53e6SMatthew G. Knepley 3132194d53e6SMatthew G. Knepley Input Parameter: 3133194d53e6SMatthew G. Knepley . prob - The PetscDS object 3134194d53e6SMatthew G. Knepley 3135194d53e6SMatthew G. Knepley Output Parameter: 3136194d53e6SMatthew G. Knepley . offsets - The offsets 3137194d53e6SMatthew G. Knepley 3138194d53e6SMatthew G. Knepley Level: beginner 3139194d53e6SMatthew G. Knepley 3140f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3141194d53e6SMatthew G. Knepley @*/ 3142194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 3143194d53e6SMatthew G. Knepley { 3144194d53e6SMatthew G. Knepley PetscFunctionBegin; 3145194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3146194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31475f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 3148194d53e6SMatthew G. Knepley *offsets = prob->off; 3149194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3150194d53e6SMatthew G. Knepley } 3151194d53e6SMatthew G. Knepley 3152194d53e6SMatthew G. Knepley /*@ 3153194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 3154194d53e6SMatthew G. Knepley 3155194d53e6SMatthew G. Knepley Not collective 3156194d53e6SMatthew G. Knepley 3157194d53e6SMatthew G. Knepley Input Parameter: 3158194d53e6SMatthew G. Knepley . prob - The PetscDS object 3159194d53e6SMatthew G. Knepley 3160194d53e6SMatthew G. Knepley Output Parameter: 3161194d53e6SMatthew G. Knepley . offsets - The offsets 3162194d53e6SMatthew G. Knepley 3163194d53e6SMatthew G. Knepley Level: beginner 3164194d53e6SMatthew G. Knepley 3165f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3166194d53e6SMatthew G. Knepley @*/ 3167194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 3168194d53e6SMatthew G. Knepley { 3169194d53e6SMatthew G. Knepley PetscFunctionBegin; 3170194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3171194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 31725f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 3173194d53e6SMatthew G. Knepley *offsets = prob->offDer; 3174194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3175194d53e6SMatthew G. Knepley } 3176194d53e6SMatthew G. Knepley 31779ee2af8cSMatthew G. Knepley /*@ 31789ee2af8cSMatthew G. Knepley PetscDSGetComponentOffsetsCohesive - Returns the offset of each field on an evaluation point 31799ee2af8cSMatthew G. Knepley 31809ee2af8cSMatthew G. Knepley Not collective 31819ee2af8cSMatthew G. Knepley 31829ee2af8cSMatthew G. Knepley Input Parameters: 31839ee2af8cSMatthew G. Knepley + ds - The PetscDS object 31849ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 31859ee2af8cSMatthew G. Knepley 31869ee2af8cSMatthew G. Knepley Output Parameter: 31879ee2af8cSMatthew G. Knepley . offsets - The offsets 31889ee2af8cSMatthew G. Knepley 31899ee2af8cSMatthew G. Knepley Level: beginner 31909ee2af8cSMatthew G. Knepley 31919ee2af8cSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 31929ee2af8cSMatthew G. Knepley @*/ 31939ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 31949ee2af8cSMatthew G. Knepley { 31959ee2af8cSMatthew G. Knepley PetscFunctionBegin; 31969ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 31979ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 3198*28b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 31992c71b3e2SJacob Faibussowitsch PetscCheckFalse((s < 0) || (s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %D is not in [0, 2]", s); 32005f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(ds)); 32019ee2af8cSMatthew G. Knepley *offsets = ds->offCohesive[s]; 32029ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32039ee2af8cSMatthew G. Knepley } 32049ee2af8cSMatthew G. Knepley 32059ee2af8cSMatthew G. Knepley /*@ 32069ee2af8cSMatthew G. Knepley PetscDSGetComponentDerivativeOffsetsCohesive - Returns the offset of each field derivative on an evaluation point 32079ee2af8cSMatthew G. Knepley 32089ee2af8cSMatthew G. Knepley Not collective 32099ee2af8cSMatthew G. Knepley 32109ee2af8cSMatthew G. Knepley Input Parameters: 32119ee2af8cSMatthew G. Knepley + ds - The PetscDS object 32129ee2af8cSMatthew G. Knepley - s - The cohesive side, 0 for negative, 1 for positive, 2 for cohesive 32139ee2af8cSMatthew G. Knepley 32149ee2af8cSMatthew G. Knepley Output Parameter: 32159ee2af8cSMatthew G. Knepley . offsets - The offsets 32169ee2af8cSMatthew G. Knepley 32179ee2af8cSMatthew G. Knepley Level: beginner 32189ee2af8cSMatthew G. Knepley 32199ee2af8cSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 32209ee2af8cSMatthew G. Knepley @*/ 32219ee2af8cSMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsetsCohesive(PetscDS ds, PetscInt s, PetscInt *offsets[]) 32229ee2af8cSMatthew G. Knepley { 32239ee2af8cSMatthew G. Knepley PetscFunctionBegin; 32249ee2af8cSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 32259ee2af8cSMatthew G. Knepley PetscValidPointer(offsets, 3); 3226*28b400f6SJacob Faibussowitsch PetscCheck(ds->isCohesive,PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Cohesive offsets are only valid for a cohesive DS"); 32272c71b3e2SJacob Faibussowitsch PetscCheckFalse((s < 0) || (s > 2),PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cohesive side %D is not in [0, 2]", s); 32285f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(ds)); 32299ee2af8cSMatthew G. Knepley *offsets = ds->offDerCohesive[s]; 32309ee2af8cSMatthew G. Knepley PetscFunctionReturn(0); 32319ee2af8cSMatthew G. Knepley } 32329ee2af8cSMatthew G. Knepley 323368c9edb9SMatthew G. Knepley /*@C 323468c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 323568c9edb9SMatthew G. Knepley 323668c9edb9SMatthew G. Knepley Not collective 323768c9edb9SMatthew G. Knepley 323868c9edb9SMatthew G. Knepley Input Parameter: 323968c9edb9SMatthew G. Knepley . prob - The PetscDS object 324068c9edb9SMatthew G. Knepley 3241ef0bb6c7SMatthew G. Knepley Output Parameter: 3242ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 324368c9edb9SMatthew G. Knepley 324468c9edb9SMatthew G. Knepley Level: intermediate 324568c9edb9SMatthew G. Knepley 3246f744cafaSSander Arens .seealso: PetscDSCreate() 324768c9edb9SMatthew G. Knepley @*/ 3248ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 32492764a2aaSMatthew G. Knepley { 32502764a2aaSMatthew G. Knepley PetscFunctionBegin; 32512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3252ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 32535f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 3254ef0bb6c7SMatthew G. Knepley *T = prob->T; 32552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32562764a2aaSMatthew G. Knepley } 32572764a2aaSMatthew G. Knepley 325868c9edb9SMatthew G. Knepley /*@C 32594d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 326068c9edb9SMatthew G. Knepley 326168c9edb9SMatthew G. Knepley Not collective 326268c9edb9SMatthew G. Knepley 326368c9edb9SMatthew G. Knepley Input Parameter: 326468c9edb9SMatthew G. Knepley . prob - The PetscDS object 326568c9edb9SMatthew G. Knepley 3266ef0bb6c7SMatthew G. Knepley Output Parameter: 3267a5b23f4aSJose E. Roman . Tf - The basis function and derivative tabulation on each local face at quadrature points for each and field 326868c9edb9SMatthew G. Knepley 326968c9edb9SMatthew G. Knepley Level: intermediate 327068c9edb9SMatthew G. Knepley 327168c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 327268c9edb9SMatthew G. Knepley @*/ 3273ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 32742764a2aaSMatthew G. Knepley { 32752764a2aaSMatthew G. Knepley PetscFunctionBegin; 32762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3277ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 32785f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 3279ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 32802764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32812764a2aaSMatthew G. Knepley } 32822764a2aaSMatthew G. Knepley 32832764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 32842764a2aaSMatthew G. Knepley { 32852764a2aaSMatthew G. Knepley PetscFunctionBegin; 32862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32875f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 32882764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 32892764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 32902764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 32912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32922764a2aaSMatthew G. Knepley } 32932764a2aaSMatthew G. Knepley 32942764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 32952764a2aaSMatthew G. Knepley { 32962764a2aaSMatthew G. Knepley PetscFunctionBegin; 32972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32985f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 32992764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 33002764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 33012764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 33022764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 33032764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 33042764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 33052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33062764a2aaSMatthew G. Knepley } 33072764a2aaSMatthew G. Knepley 33084bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 33092764a2aaSMatthew G. Knepley { 33102764a2aaSMatthew G. Knepley PetscFunctionBegin; 33112764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33125f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetUp(prob)); 33132764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 33144bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 33157506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 33167506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 33177506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 33182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33192764a2aaSMatthew G. Knepley } 33202764a2aaSMatthew G. Knepley 332158ebd649SToby Isaac /*@C 332256cf3b9cSMatthew 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(). 332358ebd649SToby Isaac 3324783e2ec8SMatthew G. Knepley Collective on ds 3325783e2ec8SMatthew G. Knepley 332658ebd649SToby Isaac Input Parameters: 332758ebd649SToby Isaac + ds - The PetscDS object 33282d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 332958ebd649SToby Isaac . name - The BC name 333045480ffeSMatthew G. Knepley . label - The label defining constrained points 333145480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 333245480ffeSMatthew G. Knepley . values - An array of label values for constrained points 333358ebd649SToby Isaac . field - The field to constrain 333445480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 333558ebd649SToby Isaac . comps - An array of constrained component numbers 333658ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3337a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 333858ebd649SToby Isaac - ctx - An optional user context for bcFunc 333958ebd649SToby Isaac 334045480ffeSMatthew G. Knepley Output Parameters: 334145480ffeSMatthew G. Knepley - bd - The boundary number 334245480ffeSMatthew G. Knepley 334358ebd649SToby Isaac Options Database Keys: 334458ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 334558ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 334658ebd649SToby Isaac 334756cf3b9cSMatthew G. Knepley Note: 334856cf3b9cSMatthew 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: 334956cf3b9cSMatthew G. Knepley 335056cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 335156cf3b9cSMatthew G. Knepley 335256cf3b9cSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 335356cf3b9cSMatthew G. Knepley 335456cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 335556cf3b9cSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 335656cf3b9cSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 335756cf3b9cSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 335856cf3b9cSMatthew G. Knepley 335956cf3b9cSMatthew G. Knepley + dim - the spatial dimension 336056cf3b9cSMatthew G. Knepley . Nf - the number of fields 336156cf3b9cSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 336256cf3b9cSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 336356cf3b9cSMatthew G. Knepley . u - each field evaluated at the current point 336456cf3b9cSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 336556cf3b9cSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 336656cf3b9cSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 336756cf3b9cSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 336856cf3b9cSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 336956cf3b9cSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 337056cf3b9cSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 337156cf3b9cSMatthew G. Knepley . t - current time 337256cf3b9cSMatthew G. Knepley . x - coordinates of the current point 337356cf3b9cSMatthew G. Knepley . numConstants - number of constant parameters 337456cf3b9cSMatthew G. Knepley . constants - constant parameters 337556cf3b9cSMatthew G. Knepley - bcval - output values at the current point 337656cf3b9cSMatthew G. Knepley 337758ebd649SToby Isaac Level: developer 337858ebd649SToby Isaac 337945480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundaryByName(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 338058ebd649SToby Isaac @*/ 338145480ffeSMatthew 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) 338258ebd649SToby Isaac { 338345480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 338445480ffeSMatthew G. Knepley PetscInt n = 0; 338545480ffeSMatthew G. Knepley const char *lname; 338658ebd649SToby Isaac 338758ebd649SToby Isaac PetscFunctionBegin; 338858ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3389783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 339045480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 339145480ffeSMatthew G. Knepley PetscValidHeaderSpecific(label, DMLABEL_CLASSID, 4); 339245480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 339345480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 339445480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 3395d57bb9dbSMatthew G. Knepley if (Nc > 0) { 3396d57bb9dbSMatthew G. Knepley PetscInt *fcomps; 3397d57bb9dbSMatthew G. Knepley PetscInt c; 3398d57bb9dbSMatthew G. Knepley 33995f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetComponents(ds, &fcomps)); 34002c71b3e2SJacob Faibussowitsch PetscCheckFalse(Nc > fcomps[field],PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Number of constrained components %D > %D components for field %D", Nc, fcomps[field], field); 3401d57bb9dbSMatthew G. Knepley for (c = 0; c < Nc; ++c) { 34022c71b3e2SJacob Faibussowitsch PetscCheckFalse(comps[c] < 0 || comps[c] >= fcomps[field],PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Constrained component[%D] %D not in [0, %D) components for field %D", c, comps[c], fcomps[field], field); 3403d57bb9dbSMatthew G. Knepley } 3404d57bb9dbSMatthew G. Knepley } 34055f80ce2aSJacob Faibussowitsch CHKERRQ(PetscNew(&b)); 34065f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(name, (char **) &b->name)); 34075f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 34085f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 34095f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nv, &b->values)); 34105f80ce2aSJacob Faibussowitsch if (Nv) CHKERRQ(PetscArraycpy(b->values, values, Nv)); 34115f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nc, &b->comps)); 34125f80ce2aSJacob Faibussowitsch if (Nc) CHKERRQ(PetscArraycpy(b->comps, comps, Nc)); 34135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetName((PetscObject) label, &lname)); 34145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(lname, (char **) &b->lname)); 3415f971fd6bSMatthew G. Knepley b->type = type; 341645480ffeSMatthew G. Knepley b->label = label; 341745480ffeSMatthew G. Knepley b->Nv = Nv; 341858ebd649SToby Isaac b->field = field; 341945480ffeSMatthew G. Knepley b->Nc = Nc; 342058ebd649SToby Isaac b->func = bcFunc; 342156cf3b9cSMatthew G. Knepley b->func_t = bcFunc_t; 342258ebd649SToby Isaac b->ctx = ctx; 342345480ffeSMatthew G. Knepley b->next = NULL; 342445480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 342545480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 342645480ffeSMatthew G. Knepley while (head) { 342745480ffeSMatthew G. Knepley if (!head->next) { 342845480ffeSMatthew G. Knepley head->next = b; 342945480ffeSMatthew G. Knepley head = b; 343045480ffeSMatthew G. Knepley } 343145480ffeSMatthew G. Knepley head = head->next; 343245480ffeSMatthew G. Knepley ++n; 343345480ffeSMatthew G. Knepley } 3434064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 343545480ffeSMatthew G. Knepley PetscFunctionReturn(0); 343645480ffeSMatthew G. Knepley } 343745480ffeSMatthew G. Knepley 343845480ffeSMatthew G. Knepley /*@C 343945480ffeSMatthew 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(). 344045480ffeSMatthew G. Knepley 344145480ffeSMatthew G. Knepley Collective on ds 344245480ffeSMatthew G. Knepley 344345480ffeSMatthew G. Knepley Input Parameters: 344445480ffeSMatthew G. Knepley + ds - The PetscDS object 344545480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 344645480ffeSMatthew G. Knepley . name - The BC name 344745480ffeSMatthew G. Knepley . lname - The naem of the label defining constrained points 344845480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 344945480ffeSMatthew G. Knepley . values - An array of label values for constrained points 345045480ffeSMatthew G. Knepley . field - The field to constrain 345145480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 345245480ffeSMatthew G. Knepley . comps - An array of constrained component numbers 345345480ffeSMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3454a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 345545480ffeSMatthew G. Knepley - ctx - An optional user context for bcFunc 345645480ffeSMatthew G. Knepley 345745480ffeSMatthew G. Knepley Output Parameters: 345845480ffeSMatthew G. Knepley - bd - The boundary number 345945480ffeSMatthew G. Knepley 346045480ffeSMatthew G. Knepley Options Database Keys: 346145480ffeSMatthew G. Knepley + -bc_<boundary name> <num> - Overrides the boundary ids 346245480ffeSMatthew G. Knepley - -bc_<boundary name>_comp <num> - Overrides the boundary components 346345480ffeSMatthew G. Knepley 346445480ffeSMatthew G. Knepley Note: 346545480ffeSMatthew G. Knepley This function should only be used with DMForest currently, since labels cannot be defined before the underlygin Plex is built. 346645480ffeSMatthew G. Knepley 346745480ffeSMatthew 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: 346845480ffeSMatthew G. Knepley 346945480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 347045480ffeSMatthew G. Knepley 347145480ffeSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 347245480ffeSMatthew G. Knepley 347345480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 347445480ffeSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 347545480ffeSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 347645480ffeSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 347745480ffeSMatthew G. Knepley 347845480ffeSMatthew G. Knepley + dim - the spatial dimension 347945480ffeSMatthew G. Knepley . Nf - the number of fields 348045480ffeSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 348145480ffeSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 348245480ffeSMatthew G. Knepley . u - each field evaluated at the current point 348345480ffeSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 348445480ffeSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 348545480ffeSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 348645480ffeSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 348745480ffeSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 348845480ffeSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 348945480ffeSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 349045480ffeSMatthew G. Knepley . t - current time 349145480ffeSMatthew G. Knepley . x - coordinates of the current point 349245480ffeSMatthew G. Knepley . numConstants - number of constant parameters 349345480ffeSMatthew G. Knepley . constants - constant parameters 349445480ffeSMatthew G. Knepley - bcval - output values at the current point 349545480ffeSMatthew G. Knepley 349645480ffeSMatthew G. Knepley Level: developer 349745480ffeSMatthew G. Knepley 349845480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 349945480ffeSMatthew G. Knepley @*/ 350045480ffeSMatthew 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) 350145480ffeSMatthew G. Knepley { 350245480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 350345480ffeSMatthew G. Knepley PetscInt n = 0; 350445480ffeSMatthew G. Knepley 350545480ffeSMatthew G. Knepley PetscFunctionBegin; 350645480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 350745480ffeSMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 350845480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 350945480ffeSMatthew G. Knepley PetscValidCharPointer(lname, 4); 351045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 351145480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 351245480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 35135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscNew(&b)); 35145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(name, (char **) &b->name)); 35155f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf)); 35165f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormSetNumFields(b->wf, ds->Nf)); 35175f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nv, &b->values)); 35185f80ce2aSJacob Faibussowitsch if (Nv) CHKERRQ(PetscArraycpy(b->values, values, Nv)); 35195f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nc, &b->comps)); 35205f80ce2aSJacob Faibussowitsch if (Nc) CHKERRQ(PetscArraycpy(b->comps, comps, Nc)); 35215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(lname, (char **) &b->lname)); 352245480ffeSMatthew G. Knepley b->type = type; 352345480ffeSMatthew G. Knepley b->label = NULL; 352445480ffeSMatthew G. Knepley b->Nv = Nv; 352545480ffeSMatthew G. Knepley b->field = field; 352645480ffeSMatthew G. Knepley b->Nc = Nc; 352745480ffeSMatthew G. Knepley b->func = bcFunc; 352845480ffeSMatthew G. Knepley b->func_t = bcFunc_t; 352945480ffeSMatthew G. Knepley b->ctx = ctx; 353045480ffeSMatthew G. Knepley b->next = NULL; 353145480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 353245480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 353345480ffeSMatthew G. Knepley while (head) { 353445480ffeSMatthew G. Knepley if (!head->next) { 353545480ffeSMatthew G. Knepley head->next = b; 353645480ffeSMatthew G. Knepley head = b; 353745480ffeSMatthew G. Knepley } 353845480ffeSMatthew G. Knepley head = head->next; 353945480ffeSMatthew G. Knepley ++n; 354045480ffeSMatthew G. Knepley } 3541064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 354258ebd649SToby Isaac PetscFunctionReturn(0); 354358ebd649SToby Isaac } 354458ebd649SToby Isaac 3545b67eacb3SMatthew G. Knepley /*@C 354656cf3b9cSMatthew 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(). 3547b67eacb3SMatthew G. Knepley 3548b67eacb3SMatthew G. Knepley Input Parameters: 3549b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3550b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3551b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3552b67eacb3SMatthew G. Knepley . name - The BC name 355345480ffeSMatthew G. Knepley . label - The label defining constrained points 355445480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 355545480ffeSMatthew G. Knepley . values - An array of ids for constrained points 3556b67eacb3SMatthew G. Knepley . field - The field to constrain 355745480ffeSMatthew G. Knepley . Nc - The number of constrained field components 3558b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3559b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3560a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 3561b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3562b67eacb3SMatthew G. Knepley 356356cf3b9cSMatthew G. Knepley Note: 356456cf3b9cSMatthew 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. 35659a6efb6aSMatthew G. Knepley 3566b67eacb3SMatthew G. Knepley Level: developer 3567b67eacb3SMatthew G. Knepley 35689a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3569b67eacb3SMatthew G. Knepley @*/ 357045480ffeSMatthew 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) 3571b67eacb3SMatthew G. Knepley { 3572b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3573b67eacb3SMatthew G. Knepley PetscInt n = 0; 3574b67eacb3SMatthew G. Knepley 3575b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3576b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3577b67eacb3SMatthew G. Knepley while (b) { 3578b67eacb3SMatthew G. Knepley if (n == bd) break; 3579b67eacb3SMatthew G. Knepley b = b->next; 3580b67eacb3SMatthew G. Knepley ++n; 3581b67eacb3SMatthew G. Knepley } 3582*28b400f6SJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3583b67eacb3SMatthew G. Knepley if (name) { 35845f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->name)); 35855f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(name, (char **) &b->name)); 3586b67eacb3SMatthew G. Knepley } 3587b67eacb3SMatthew G. Knepley b->type = type; 358845480ffeSMatthew G. Knepley if (label) { 358945480ffeSMatthew G. Knepley const char *name; 359045480ffeSMatthew G. Knepley 359145480ffeSMatthew G. Knepley b->label = label; 35925f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->lname)); 35935f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetName((PetscObject) label, &name)); 35945f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(name, (char **) &b->lname)); 359545480ffeSMatthew G. Knepley } 359645480ffeSMatthew G. Knepley if (Nv >= 0) { 359745480ffeSMatthew G. Knepley b->Nv = Nv; 35985f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->values)); 35995f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nv, &b->values)); 36005f80ce2aSJacob Faibussowitsch if (Nv) CHKERRQ(PetscArraycpy(b->values, values, Nv)); 360145480ffeSMatthew G. Knepley } 360245480ffeSMatthew G. Knepley if (field >= 0) b->field = field; 360345480ffeSMatthew G. Knepley if (Nc >= 0) { 360445480ffeSMatthew G. Knepley b->Nc = Nc; 36055f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->comps)); 36065f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(Nc, &b->comps)); 36075f80ce2aSJacob Faibussowitsch if (Nc) CHKERRQ(PetscArraycpy(b->comps, comps, Nc)); 360845480ffeSMatthew G. Knepley } 360945480ffeSMatthew G. Knepley if (bcFunc) b->func = bcFunc; 361045480ffeSMatthew G. Knepley if (bcFunc_t) b->func_t = bcFunc_t; 361145480ffeSMatthew G. Knepley if (ctx) b->ctx = ctx; 3612b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3613b67eacb3SMatthew G. Knepley } 3614b67eacb3SMatthew G. Knepley 361558ebd649SToby Isaac /*@ 361658ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 361758ebd649SToby Isaac 361858ebd649SToby Isaac Input Parameters: 361958ebd649SToby Isaac . ds - The PetscDS object 362058ebd649SToby Isaac 362158ebd649SToby Isaac Output Parameters: 362258ebd649SToby Isaac . numBd - The number of BC 362358ebd649SToby Isaac 362458ebd649SToby Isaac Level: intermediate 362558ebd649SToby Isaac 362658ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 362758ebd649SToby Isaac @*/ 362858ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 362958ebd649SToby Isaac { 363058ebd649SToby Isaac DSBoundary b = ds->boundary; 363158ebd649SToby Isaac 363258ebd649SToby Isaac PetscFunctionBegin; 363358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 363458ebd649SToby Isaac PetscValidPointer(numBd, 2); 363558ebd649SToby Isaac *numBd = 0; 363658ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 363758ebd649SToby Isaac PetscFunctionReturn(0); 363858ebd649SToby Isaac } 363958ebd649SToby Isaac 364058ebd649SToby Isaac /*@C 36419a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 364258ebd649SToby Isaac 364358ebd649SToby Isaac Input Parameters: 364458ebd649SToby Isaac + ds - The PetscDS object 364558ebd649SToby Isaac - bd - The BC number 364658ebd649SToby Isaac 364758ebd649SToby Isaac Output Parameters: 364845480ffeSMatthew G. Knepley + wf - The PetscWeakForm holding the pointwise functions 364945480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 365058ebd649SToby Isaac . name - The BC name 365145480ffeSMatthew G. Knepley . label - The label defining constrained points 365245480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 365345480ffeSMatthew G. Knepley . values - An array of ids for constrained points 365458ebd649SToby Isaac . field - The field to constrain 365545480ffeSMatthew G. Knepley . Nc - The number of constrained field components 365658ebd649SToby Isaac . comps - An array of constrained component numbers 365758ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3658a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values 365958ebd649SToby Isaac - ctx - An optional user context for bcFunc 366058ebd649SToby Isaac 366158ebd649SToby Isaac Options Database Keys: 366258ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 366358ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 366458ebd649SToby Isaac 366558ebd649SToby Isaac Level: developer 366658ebd649SToby Isaac 366758ebd649SToby Isaac .seealso: PetscDSAddBoundary() 366858ebd649SToby Isaac @*/ 366945480ffeSMatthew 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) 367058ebd649SToby Isaac { 367158ebd649SToby Isaac DSBoundary b = ds->boundary; 367258ebd649SToby Isaac PetscInt n = 0; 367358ebd649SToby Isaac 367458ebd649SToby Isaac PetscFunctionBegin; 367558ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 367658ebd649SToby Isaac while (b) { 367758ebd649SToby Isaac if (n == bd) break; 367858ebd649SToby Isaac b = b->next; 367958ebd649SToby Isaac ++n; 368058ebd649SToby Isaac } 3681*28b400f6SJacob Faibussowitsch PetscCheck(b,PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 368245480ffeSMatthew G. Knepley if (wf) { 368345480ffeSMatthew G. Knepley PetscValidPointer(wf, 3); 368445480ffeSMatthew G. Knepley *wf = b->wf; 368545480ffeSMatthew G. Knepley } 3686f971fd6bSMatthew G. Knepley if (type) { 368745480ffeSMatthew G. Knepley PetscValidPointer(type, 4); 3688f971fd6bSMatthew G. Knepley *type = b->type; 368958ebd649SToby Isaac } 369058ebd649SToby Isaac if (name) { 369145480ffeSMatthew G. Knepley PetscValidPointer(name, 5); 369258ebd649SToby Isaac *name = b->name; 369358ebd649SToby Isaac } 369445480ffeSMatthew G. Knepley if (label) { 369545480ffeSMatthew G. Knepley PetscValidPointer(label, 6); 369645480ffeSMatthew G. Knepley *label = b->label; 369745480ffeSMatthew G. Knepley } 369845480ffeSMatthew G. Knepley if (Nv) { 369945480ffeSMatthew G. Knepley PetscValidIntPointer(Nv, 7); 370045480ffeSMatthew G. Knepley *Nv = b->Nv; 370145480ffeSMatthew G. Knepley } 370245480ffeSMatthew G. Knepley if (values) { 370345480ffeSMatthew G. Knepley PetscValidPointer(values, 8); 370445480ffeSMatthew G. Knepley *values = b->values; 370558ebd649SToby Isaac } 370658ebd649SToby Isaac if (field) { 370745480ffeSMatthew G. Knepley PetscValidIntPointer(field, 9); 370858ebd649SToby Isaac *field = b->field; 370958ebd649SToby Isaac } 371045480ffeSMatthew G. Knepley if (Nc) { 371145480ffeSMatthew G. Knepley PetscValidIntPointer(Nc, 10); 371245480ffeSMatthew G. Knepley *Nc = b->Nc; 371358ebd649SToby Isaac } 371458ebd649SToby Isaac if (comps) { 371545480ffeSMatthew G. Knepley PetscValidPointer(comps, 11); 371658ebd649SToby Isaac *comps = b->comps; 371758ebd649SToby Isaac } 371858ebd649SToby Isaac if (func) { 371945480ffeSMatthew G. Knepley PetscValidPointer(func, 12); 372058ebd649SToby Isaac *func = b->func; 372158ebd649SToby Isaac } 372256cf3b9cSMatthew G. Knepley if (func_t) { 372345480ffeSMatthew G. Knepley PetscValidPointer(func_t, 13); 372456cf3b9cSMatthew G. Knepley *func_t = b->func_t; 372556cf3b9cSMatthew G. Knepley } 372658ebd649SToby Isaac if (ctx) { 372745480ffeSMatthew G. Knepley PetscValidPointer(ctx, 14); 372858ebd649SToby Isaac *ctx = b->ctx; 372958ebd649SToby Isaac } 373058ebd649SToby Isaac PetscFunctionReturn(0); 373158ebd649SToby Isaac } 373258ebd649SToby Isaac 373345480ffeSMatthew G. Knepley static PetscErrorCode DSBoundaryDuplicate_Internal(DSBoundary b, DSBoundary *bNew) 373445480ffeSMatthew G. Knepley { 373545480ffeSMatthew G. Knepley PetscFunctionBegin; 37365f80ce2aSJacob Faibussowitsch CHKERRQ(PetscNew(bNew)); 37375f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCreate(PETSC_COMM_SELF, &(*bNew)->wf)); 37385f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCopy(b->wf, (*bNew)->wf)); 37395f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(b->name,(char **) &((*bNew)->name))); 37405f80ce2aSJacob Faibussowitsch CHKERRQ(PetscStrallocpy(b->lname,(char **) &((*bNew)->lname))); 374145480ffeSMatthew G. Knepley (*bNew)->type = b->type; 374245480ffeSMatthew G. Knepley (*bNew)->label = b->label; 374345480ffeSMatthew G. Knepley (*bNew)->Nv = b->Nv; 37445f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(b->Nv, &(*bNew)->values)); 37455f80ce2aSJacob Faibussowitsch CHKERRQ(PetscArraycpy((*bNew)->values, b->values, b->Nv)); 374645480ffeSMatthew G. Knepley (*bNew)->field = b->field; 374745480ffeSMatthew G. Knepley (*bNew)->Nc = b->Nc; 37485f80ce2aSJacob Faibussowitsch CHKERRQ(PetscMalloc1(b->Nc, &(*bNew)->comps)); 37495f80ce2aSJacob Faibussowitsch CHKERRQ(PetscArraycpy((*bNew)->comps, b->comps, b->Nc)); 375045480ffeSMatthew G. Knepley (*bNew)->func = b->func; 375145480ffeSMatthew G. Knepley (*bNew)->func_t = b->func_t; 375245480ffeSMatthew G. Knepley (*bNew)->ctx = b->ctx; 375345480ffeSMatthew G. Knepley PetscFunctionReturn(0); 375445480ffeSMatthew G. Knepley } 375545480ffeSMatthew G. Knepley 37569252d075SMatthew G. Knepley /*@ 37579252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 37589252d075SMatthew G. Knepley 37599252d075SMatthew G. Knepley Not collective 37609252d075SMatthew G. Knepley 376136951cb5SMatthew G. Knepley Input Parameters: 376236951cb5SMatthew G. Knepley + ds - The source PetscDS object 376336951cb5SMatthew G. Knepley . numFields - The number of selected fields, or PETSC_DEFAULT for all fields 376436951cb5SMatthew G. Knepley - fields - The selected fields, or NULL for all fields 37659252d075SMatthew G. Knepley 37669252d075SMatthew G. Knepley Output Parameter: 376736951cb5SMatthew G. Knepley . newds - The target PetscDS, now with a copy of the boundary conditions 37689252d075SMatthew G. Knepley 37699252d075SMatthew G. Knepley Level: intermediate 37709252d075SMatthew G. Knepley 37719252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 37729252d075SMatthew G. Knepley @*/ 377336951cb5SMatthew G. Knepley PetscErrorCode PetscDSCopyBoundary(PetscDS ds, PetscInt numFields, const PetscInt fields[], PetscDS newds) 3774dff059c6SToby Isaac { 377545480ffeSMatthew G. Knepley DSBoundary b, *lastnext; 3776dff059c6SToby Isaac 3777dff059c6SToby Isaac PetscFunctionBegin; 377836951cb5SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 377936951cb5SMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 4); 378036951cb5SMatthew G. Knepley if (ds == newds) PetscFunctionReturn(0); 37815f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSDestroyBoundary(newds)); 378236951cb5SMatthew G. Knepley lastnext = &(newds->boundary); 378336951cb5SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 3784dff059c6SToby Isaac DSBoundary bNew; 378536951cb5SMatthew G. Knepley PetscInt fieldNew = -1; 3786dff059c6SToby Isaac 378736951cb5SMatthew G. Knepley if (numFields > 0 && fields) { 378836951cb5SMatthew G. Knepley PetscInt f; 378936951cb5SMatthew G. Knepley 379036951cb5SMatthew G. Knepley for (f = 0; f < numFields; ++f) if (b->field == fields[f]) break; 379136951cb5SMatthew G. Knepley if (f == numFields) continue; 379236951cb5SMatthew G. Knepley fieldNew = f; 379336951cb5SMatthew G. Knepley } 37945f80ce2aSJacob Faibussowitsch CHKERRQ(DSBoundaryDuplicate_Internal(b, &bNew)); 379536951cb5SMatthew G. Knepley bNew->field = fieldNew < 0 ? b->field : fieldNew; 3796dff059c6SToby Isaac *lastnext = bNew; 3797dff059c6SToby Isaac lastnext = &(bNew->next); 3798dff059c6SToby Isaac } 3799dff059c6SToby Isaac PetscFunctionReturn(0); 3800dff059c6SToby Isaac } 3801dff059c6SToby Isaac 38026c1eb96dSMatthew G. Knepley /*@ 380345480ffeSMatthew G. Knepley PetscDSDestroyBoundary - Remove all DMBoundary objects from the PetscDS 380445480ffeSMatthew G. Knepley 380545480ffeSMatthew G. Knepley Not collective 380645480ffeSMatthew G. Knepley 380745480ffeSMatthew G. Knepley Input Parameter: 380845480ffeSMatthew G. Knepley . ds - The PetscDS object 380945480ffeSMatthew G. Knepley 381045480ffeSMatthew G. Knepley Level: intermediate 381145480ffeSMatthew G. Knepley 381245480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations() 381345480ffeSMatthew G. Knepley @*/ 381445480ffeSMatthew G. Knepley PetscErrorCode PetscDSDestroyBoundary(PetscDS ds) 381545480ffeSMatthew G. Knepley { 381645480ffeSMatthew G. Knepley DSBoundary next = ds->boundary; 381745480ffeSMatthew G. Knepley 381845480ffeSMatthew G. Knepley PetscFunctionBegin; 381945480ffeSMatthew G. Knepley while (next) { 382045480ffeSMatthew G. Knepley DSBoundary b = next; 382145480ffeSMatthew G. Knepley 382245480ffeSMatthew G. Knepley next = b->next; 38235f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormDestroy(&b->wf)); 38245f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->name)); 38255f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->lname)); 38265f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->values)); 38275f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b->comps)); 38285f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(b)); 382945480ffeSMatthew G. Knepley } 383045480ffeSMatthew G. Knepley PetscFunctionReturn(0); 383145480ffeSMatthew G. Knepley } 383245480ffeSMatthew G. Knepley 383345480ffeSMatthew G. Knepley /*@ 38346c1eb96dSMatthew G. Knepley PetscDSSelectDiscretizations - Copy discretizations to the new problem with different field layout 38356c1eb96dSMatthew G. Knepley 38366c1eb96dSMatthew G. Knepley Not collective 38376c1eb96dSMatthew G. Knepley 3838d8d19677SJose E. Roman Input Parameters: 38396c1eb96dSMatthew G. Knepley + prob - The PetscDS object 38406c1eb96dSMatthew G. Knepley . numFields - Number of new fields 38416c1eb96dSMatthew G. Knepley - fields - Old field number for each new field 38426c1eb96dSMatthew G. Knepley 38436c1eb96dSMatthew G. Knepley Output Parameter: 38446c1eb96dSMatthew G. Knepley . newprob - The PetscDS copy 38456c1eb96dSMatthew G. Knepley 38466c1eb96dSMatthew G. Knepley Level: intermediate 38476c1eb96dSMatthew G. Knepley 38486c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectEquations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 38496c1eb96dSMatthew G. Knepley @*/ 38506c1eb96dSMatthew G. Knepley PetscErrorCode PetscDSSelectDiscretizations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38516c1eb96dSMatthew G. Knepley { 38526c1eb96dSMatthew G. Knepley PetscInt Nf, Nfn, fn; 38536c1eb96dSMatthew G. Knepley 38546c1eb96dSMatthew G. Knepley PetscFunctionBegin; 38556c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 38566c1eb96dSMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 38576c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38585f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(prob, &Nf)); 38595f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(newprob, &Nfn)); 386045480ffeSMatthew G. Knepley numFields = numFields < 0 ? Nf : numFields; 38616c1eb96dSMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38626c1eb96dSMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38636c1eb96dSMatthew G. Knepley PetscObject disc; 38646c1eb96dSMatthew G. Knepley 38656c1eb96dSMatthew G. Knepley if (f >= Nf) continue; 38665f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(prob, f, &disc)); 38675f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetDiscretization(newprob, fn, disc)); 38686c1eb96dSMatthew G. Knepley } 38696c1eb96dSMatthew G. Knepley PetscFunctionReturn(0); 38706c1eb96dSMatthew G. Knepley } 38716c1eb96dSMatthew G. Knepley 38726c1eb96dSMatthew G. Knepley /*@ 38739252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 38749252d075SMatthew G. Knepley 38759252d075SMatthew G. Knepley Not collective 38769252d075SMatthew G. Knepley 3877d8d19677SJose E. Roman Input Parameters: 38789252d075SMatthew G. Knepley + prob - The PetscDS object 38799252d075SMatthew G. Knepley . numFields - Number of new fields 38809252d075SMatthew G. Knepley - fields - Old field number for each new field 38819252d075SMatthew G. Knepley 38829252d075SMatthew G. Knepley Output Parameter: 38839252d075SMatthew G. Knepley . newprob - The PetscDS copy 38849252d075SMatthew G. Knepley 38859252d075SMatthew G. Knepley Level: intermediate 38869252d075SMatthew G. Knepley 38876c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectDiscretizations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 38889252d075SMatthew G. Knepley @*/ 38899252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38909252d075SMatthew G. Knepley { 38919252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 38929252d075SMatthew G. Knepley 38939252d075SMatthew G. Knepley PetscFunctionBegin; 38949252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 38959252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 38969252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38975f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(prob, &Nf)); 38985f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(newprob, &Nfn)); 38992c71b3e2SJacob Faibussowitsch PetscCheckFalse(numFields > Nfn,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields %D to transfer must not be greater then the total number of fields %D", numFields, Nfn); 39009252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 39019252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 39029252d075SMatthew G. Knepley PetscPointFunc obj; 39039252d075SMatthew G. Knepley PetscPointFunc f0, f1; 39049252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 39059252d075SMatthew G. Knepley PetscRiemannFunc r; 39069252d075SMatthew G. Knepley 3907c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 39085f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetObjective(prob, f, &obj)); 39095f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetResidual(prob, f, &f0, &f1)); 39105f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd)); 39115f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetRiemannSolver(prob, f, &r)); 39125f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetObjective(newprob, fn, obj)); 39135f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetResidual(newprob, fn, f0, f1)); 39145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd)); 39155f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetRiemannSolver(newprob, fn, r)); 39169252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 39179252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 39189252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 39199252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 39209252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 39219252d075SMatthew G. Knepley 3922c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 39235f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3)); 39245f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p)); 39255f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd)); 39265f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3)); 39275f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetJacobianPreconditioner(newprob, fn, gn, g0p, g1p, g2p, g3p)); 39285f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd)); 39299252d075SMatthew G. Knepley } 39309252d075SMatthew G. Knepley } 39319252d075SMatthew G. Knepley PetscFunctionReturn(0); 39329252d075SMatthew G. Knepley } 39339252d075SMatthew G. Knepley 3934da51fcedSMatthew G. Knepley /*@ 3935da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3936da51fcedSMatthew G. Knepley 3937da51fcedSMatthew G. Knepley Not collective 3938da51fcedSMatthew G. Knepley 3939da51fcedSMatthew G. Knepley Input Parameter: 3940da51fcedSMatthew G. Knepley . prob - The PetscDS object 3941da51fcedSMatthew G. Knepley 3942da51fcedSMatthew G. Knepley Output Parameter: 3943da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3944da51fcedSMatthew G. Knepley 3945da51fcedSMatthew G. Knepley Level: intermediate 3946da51fcedSMatthew G. Knepley 39479252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3948da51fcedSMatthew G. Knepley @*/ 3949da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3950da51fcedSMatthew G. Knepley { 3951b8025e53SMatthew G. Knepley PetscWeakForm wf, newwf; 39529252d075SMatthew G. Knepley PetscInt Nf, Ng; 3953da51fcedSMatthew G. Knepley 3954da51fcedSMatthew G. Knepley PetscFunctionBegin; 3955da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3956da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39575f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(prob, &Nf)); 39585f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(newprob, &Ng)); 39592c71b3e2SJacob Faibussowitsch PetscCheckFalse(Nf != Ng,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 39605f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetWeakForm(prob, &wf)); 39615f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetWeakForm(newprob, &newwf)); 39625f80ce2aSJacob Faibussowitsch CHKERRQ(PetscWeakFormCopy(wf, newwf)); 39639252d075SMatthew G. Knepley PetscFunctionReturn(0); 39649252d075SMatthew G. Knepley } 396545480ffeSMatthew G. Knepley 39669252d075SMatthew G. Knepley /*@ 39679252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3968da51fcedSMatthew G. Knepley 39699252d075SMatthew G. Knepley Not collective 39709252d075SMatthew G. Knepley 39719252d075SMatthew G. Knepley Input Parameter: 39729252d075SMatthew G. Knepley . prob - The PetscDS object 39739252d075SMatthew G. Knepley 39749252d075SMatthew G. Knepley Output Parameter: 39759252d075SMatthew G. Knepley . newprob - The PetscDS copy 39769252d075SMatthew G. Knepley 39779252d075SMatthew G. Knepley Level: intermediate 39789252d075SMatthew G. Knepley 39799252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 39809252d075SMatthew G. Knepley @*/ 39819252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 39829252d075SMatthew G. Knepley { 39839252d075SMatthew G. Knepley PetscInt Nc; 39849252d075SMatthew G. Knepley const PetscScalar *constants; 39859252d075SMatthew G. Knepley 39869252d075SMatthew G. Knepley PetscFunctionBegin; 39879252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 39889252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39895f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetConstants(prob, &Nc, &constants)); 39905f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants)); 3991da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3992da51fcedSMatthew G. Knepley } 3993da51fcedSMatthew G. Knepley 399445480ffeSMatthew G. Knepley /*@ 399545480ffeSMatthew G. Knepley PetscDSCopyExactSolutions - Copy all exact solutions to the new problem 399645480ffeSMatthew G. Knepley 399745480ffeSMatthew G. Knepley Not collective 399845480ffeSMatthew G. Knepley 399945480ffeSMatthew G. Knepley Input Parameter: 400045480ffeSMatthew G. Knepley . ds - The PetscDS object 400145480ffeSMatthew G. Knepley 400245480ffeSMatthew G. Knepley Output Parameter: 400345480ffeSMatthew G. Knepley . newds - The PetscDS copy 400445480ffeSMatthew G. Knepley 400545480ffeSMatthew G. Knepley Level: intermediate 400645480ffeSMatthew G. Knepley 400745480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 400845480ffeSMatthew G. Knepley @*/ 400945480ffeSMatthew G. Knepley PetscErrorCode PetscDSCopyExactSolutions(PetscDS ds, PetscDS newds) 401045480ffeSMatthew G. Knepley { 401145480ffeSMatthew G. Knepley PetscSimplePointFunc sol; 401245480ffeSMatthew G. Knepley void *ctx; 401345480ffeSMatthew G. Knepley PetscInt Nf, f; 401445480ffeSMatthew G. Knepley 401545480ffeSMatthew G. Knepley PetscFunctionBegin; 401645480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 401745480ffeSMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 2); 40185f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(ds, &Nf)); 401945480ffeSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 40205f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetExactSolution(ds, f, &sol, &ctx)); 40215f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetExactSolution(newds, f, sol, ctx)); 40225f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetExactSolutionTimeDerivative(ds, f, &sol, &ctx)); 40235f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetExactSolutionTimeDerivative(newds, f, sol, ctx)); 402445480ffeSMatthew G. Knepley } 402545480ffeSMatthew G. Knepley PetscFunctionReturn(0); 402645480ffeSMatthew G. Knepley } 402745480ffeSMatthew G. Knepley 4028b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 4029b1353e8eSMatthew G. Knepley { 4030df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 4031b1353e8eSMatthew G. Knepley 4032b1353e8eSMatthew G. Knepley PetscFunctionBegin; 4033b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 4034b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 4035b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 40365f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(prob, &Nf)); 40375f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetSpatialDimension(prob, &dim)); 40382c71b3e2SJacob Faibussowitsch PetscCheckFalse(height > dim,PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_OUTOFRANGE, "DS can only handle height in [0, %D], not %D", dim, height); 40395f80ce2aSJacob Faibussowitsch if (!prob->subprobs) CHKERRQ(PetscCalloc1(dim, &prob->subprobs)); 4040df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 4041b1353e8eSMatthew G. Knepley PetscInt cdim; 4042b1353e8eSMatthew G. Knepley 40435f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1])); 40445f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetCoordinateDimension(prob, &cdim)); 40455f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim)); 4046b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 4047b1353e8eSMatthew G. Knepley PetscFE subfe; 4048b1353e8eSMatthew G. Knepley PetscObject obj; 4049b1353e8eSMatthew G. Knepley PetscClassId id; 4050b1353e8eSMatthew G. Knepley 40515f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(prob, f, &obj)); 40525f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 40535f80ce2aSJacob Faibussowitsch if (id == PETSCFE_CLASSID) CHKERRQ(PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe)); 405498921bdaSJacob Faibussowitsch else SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 40555f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe)); 4056b1353e8eSMatthew G. Knepley } 4057b1353e8eSMatthew G. Knepley } 4058df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 4059b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 4060b1353e8eSMatthew G. Knepley } 4061b1353e8eSMatthew G. Knepley 4062665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 4063c7bd5f0bSMatthew G. Knepley { 4064c7bd5f0bSMatthew G. Knepley PetscObject obj; 4065c7bd5f0bSMatthew G. Knepley PetscClassId id; 4066c7bd5f0bSMatthew G. Knepley PetscInt Nf; 4067c7bd5f0bSMatthew G. Knepley 4068c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 4069c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 4070665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 4071665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 40725f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetNumFields(ds, &Nf)); 40732c71b3e2SJacob Faibussowitsch PetscCheckFalse(f >= Nf,PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 40745f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSGetDiscretization(ds, f, &obj)); 4075665f567fSMatthew G. Knepley if (obj) { 40765f80ce2aSJacob Faibussowitsch CHKERRQ(PetscObjectGetClassId(obj, &id)); 4077665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 4078665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 4079665f567fSMatthew G. Knepley } 4080c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 4081c7bd5f0bSMatthew G. Knepley } 4082c7bd5f0bSMatthew G. Knepley 40836528b96dSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS ds) 40842764a2aaSMatthew G. Knepley { 40852764a2aaSMatthew G. Knepley PetscFunctionBegin; 40865f80ce2aSJacob Faibussowitsch CHKERRQ(PetscFree(ds->data)); 40872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40882764a2aaSMatthew G. Knepley } 40892764a2aaSMatthew G. Knepley 40906528b96dSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS ds) 40912764a2aaSMatthew G. Knepley { 40922764a2aaSMatthew G. Knepley PetscFunctionBegin; 40936528b96dSMatthew G. Knepley ds->ops->setfromoptions = NULL; 40946528b96dSMatthew G. Knepley ds->ops->setup = NULL; 40956528b96dSMatthew G. Knepley ds->ops->view = NULL; 40966528b96dSMatthew G. Knepley ds->ops->destroy = PetscDSDestroy_Basic; 40972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40982764a2aaSMatthew G. Knepley } 40992764a2aaSMatthew G. Knepley 41002764a2aaSMatthew G. Knepley /*MC 41012764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 41022764a2aaSMatthew G. Knepley 41032764a2aaSMatthew G. Knepley Level: intermediate 41042764a2aaSMatthew G. Knepley 41052764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 41062764a2aaSMatthew G. Knepley M*/ 41072764a2aaSMatthew G. Knepley 41086528b96dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS ds) 41092764a2aaSMatthew G. Knepley { 41102764a2aaSMatthew G. Knepley PetscDS_Basic *b; 41112764a2aaSMatthew G. Knepley 41122764a2aaSMatthew G. Knepley PetscFunctionBegin; 41136528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 41145f80ce2aSJacob Faibussowitsch CHKERRQ(PetscNewLog(ds, &b)); 41156528b96dSMatthew G. Knepley ds->data = b; 41162764a2aaSMatthew G. Knepley 41175f80ce2aSJacob Faibussowitsch CHKERRQ(PetscDSInitialize_Basic(ds)); 41182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 41192764a2aaSMatthew G. Knepley } 4120