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 PetscErrorCode ierr; 582764a2aaSMatthew G. Knepley 592764a2aaSMatthew G. Knepley PetscFunctionBegin; 602764a2aaSMatthew G. Knepley ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr); 612764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 622764a2aaSMatthew G. Knepley } 632764a2aaSMatthew G. Knepley 642764a2aaSMatthew G. Knepley /*@C 652764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 662764a2aaSMatthew G. Knepley 67d083f849SBarry Smith Collective on prob 682764a2aaSMatthew G. Knepley 692764a2aaSMatthew G. Knepley Input Parameters: 702764a2aaSMatthew G. Knepley + prob - The PetscDS object 712764a2aaSMatthew G. Knepley - name - The kind of system 722764a2aaSMatthew G. Knepley 732764a2aaSMatthew G. Knepley Options Database Key: 742764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 752764a2aaSMatthew G. Knepley 762764a2aaSMatthew G. Knepley Level: intermediate 772764a2aaSMatthew G. Knepley 78f5f57ec0SBarry Smith Not available from Fortran 79f5f57ec0SBarry Smith 802764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate() 812764a2aaSMatthew G. Knepley @*/ 822764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 832764a2aaSMatthew G. Knepley { 842764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 852764a2aaSMatthew G. Knepley PetscBool match; 862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 872764a2aaSMatthew G. Knepley 882764a2aaSMatthew G. Knepley PetscFunctionBegin; 892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 902764a2aaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr); 912764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 922764a2aaSMatthew G. Knepley 930f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 942764a2aaSMatthew G. Knepley ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr); 952764a2aaSMatthew G. Knepley if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 962764a2aaSMatthew G. Knepley 972764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 982764a2aaSMatthew G. Knepley ierr = (*prob->ops->destroy)(prob);CHKERRQ(ierr); 992764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 1002764a2aaSMatthew G. Knepley } 1012764a2aaSMatthew G. Knepley ierr = (*r)(prob);CHKERRQ(ierr); 1022764a2aaSMatthew G. Knepley ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr); 1032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1042764a2aaSMatthew G. Knepley } 1052764a2aaSMatthew G. Knepley 1062764a2aaSMatthew G. Knepley /*@C 1072764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 1082764a2aaSMatthew G. Knepley 1092764a2aaSMatthew G. Knepley Not Collective 1102764a2aaSMatthew G. Knepley 1112764a2aaSMatthew G. Knepley Input Parameter: 1122764a2aaSMatthew G. Knepley . prob - The PetscDS 1132764a2aaSMatthew G. Knepley 1142764a2aaSMatthew G. Knepley Output Parameter: 1152764a2aaSMatthew G. Knepley . name - The PetscDS type name 1162764a2aaSMatthew G. Knepley 1172764a2aaSMatthew G. Knepley Level: intermediate 1182764a2aaSMatthew G. Knepley 119f5f57ec0SBarry Smith Not available from Fortran 120f5f57ec0SBarry Smith 1212764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1222764a2aaSMatthew G. Knepley @*/ 1232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1242764a2aaSMatthew G. Knepley { 1252764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1262764a2aaSMatthew G. Knepley 1272764a2aaSMatthew G. Knepley PetscFunctionBegin; 1282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 129c959eef4SJed Brown PetscValidPointer(name, 2); 1300f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 1312764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1332764a2aaSMatthew G. Knepley } 1342764a2aaSMatthew G. Knepley 1357d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1367d8a60eaSMatthew G. Knepley { 1377d8a60eaSMatthew G. Knepley PetscViewerFormat format; 13897b6e6e8SMatthew G. Knepley const PetscScalar *constants; 13997b6e6e8SMatthew G. Knepley PetscInt numConstants, f; 1407d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1417d8a60eaSMatthew G. Knepley 1427d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1437d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1447d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1457d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1464727e194SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " cell total dim %D total comp %D\n", prob->totDim, prob->totComp);CHKERRQ(ierr); 1474727e194SMatthew G. Knepley if (prob->isHybrid) {ierr = PetscViewerASCIIPrintf(viewer, " hybrid cell\n");CHKERRQ(ierr);} 1487d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 14940967b3bSMatthew G. Knepley DSBoundary b; 1507d8a60eaSMatthew G. Knepley PetscObject obj; 1517d8a60eaSMatthew G. Knepley PetscClassId id; 152f35450b9SMatthew G. Knepley PetscQuadrature q; 1537d8a60eaSMatthew G. Knepley const char *name; 154f35450b9SMatthew G. Knepley PetscInt Nc, Nq, Nqc; 1557d8a60eaSMatthew G. Knepley 1567d8a60eaSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 1577d8a60eaSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 1587d8a60eaSMatthew G. Knepley ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr); 1597d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr); 1604727e194SMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 1617d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1627d8a60eaSMatthew G. Knepley ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr); 163f35450b9SMatthew G. Knepley ierr = PetscFEGetQuadrature((PetscFE) obj, &q);CHKERRQ(ierr); 1647d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1657d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1667d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 167f35450b9SMatthew G. Knepley ierr = PetscFVGetQuadrature((PetscFV) obj, &q);CHKERRQ(ierr); 1687d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1697d8a60eaSMatthew G. Knepley } 17097b6e6e8SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %D", f); 17197b6e6e8SMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, " %D components", Nc);CHKERRQ(ierr);} 17297b6e6e8SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " %D component ", Nc);CHKERRQ(ierr);} 173249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 174249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 1753e60c2a6SMatthew G. Knepley if (q) { 176f35450b9SMatthew G. Knepley ierr = PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL);CHKERRQ(ierr); 177f35450b9SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " (Nq %D Nqc %D)", Nq, Nqc);CHKERRQ(ierr); 1783e60c2a6SMatthew G. Knepley } 179f9244615SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " %D-jet", prob->jetDegree[f]);CHKERRQ(ierr); 1807d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1814727e194SMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 1825d160056SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1837d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1847d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1855d160056SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 18640967b3bSMatthew G. Knepley 18740967b3bSMatthew G. Knepley for (b = prob->boundary; b; b = b->next) { 18806ad1575SMatthew G. Knepley char *name; 18940967b3bSMatthew G. Knepley PetscInt c, i; 19040967b3bSMatthew G. Knepley 19140967b3bSMatthew G. Knepley if (b->field != f) continue; 19240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 19345480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->lname, DMBoundaryConditionTypes[b->type]);CHKERRQ(ierr); 19445480ffeSMatthew G. Knepley if (!b->Nc) { 19540967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " all components\n");CHKERRQ(ierr); 19640967b3bSMatthew G. Knepley } else { 19740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " components: ");CHKERRQ(ierr); 19840967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 19945480ffeSMatthew G. Knepley for (c = 0; c < b->Nc; ++c) { 20040967b3bSMatthew G. Knepley if (c > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 20140967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->comps[c]);CHKERRQ(ierr); 20240967b3bSMatthew G. Knepley } 20340967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 20440967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 20540967b3bSMatthew G. Knepley } 20645480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " values: ");CHKERRQ(ierr); 20740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 20845480ffeSMatthew G. Knepley for (i = 0; i < b->Nv; ++i) { 20940967b3bSMatthew G. Knepley if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 21045480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->values[i]);CHKERRQ(ierr); 21140967b3bSMatthew G. Knepley } 21240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 21340967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 2148e0d8d9cSMatthew G. Knepley if (b->func) { 2158e0d8d9cSMatthew G. Knepley ierr = PetscDLAddr(b->func, &name);CHKERRQ(ierr); 2168e0d8d9cSMatthew G. Knepley if (name) {ierr = PetscViewerASCIIPrintf(viewer, " func: %s\n", name);CHKERRQ(ierr);} 2178e0d8d9cSMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " func: %p\n", b->func);CHKERRQ(ierr);} 21806ad1575SMatthew G. Knepley ierr = PetscFree(name);CHKERRQ(ierr); 2198e0d8d9cSMatthew G. Knepley } 2208e0d8d9cSMatthew G. Knepley if (b->func_t) { 2218e0d8d9cSMatthew G. Knepley ierr = PetscDLAddr(b->func_t, &name);CHKERRQ(ierr); 2222e144d55SMatthew G. Knepley if (name) {ierr = PetscViewerASCIIPrintf(viewer, " func_t: %s\n", name);CHKERRQ(ierr);} 2232e144d55SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " func_t: %p\n", b->func_t);CHKERRQ(ierr);} 22406ad1575SMatthew G. Knepley ierr = PetscFree(name);CHKERRQ(ierr); 2258e0d8d9cSMatthew G. Knepley } 22645480ffeSMatthew G. Knepley ierr = PetscWeakFormView(b->wf, viewer);CHKERRQ(ierr); 22740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 22840967b3bSMatthew G. Knepley } 2297d8a60eaSMatthew G. Knepley } 23097b6e6e8SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &numConstants, &constants);CHKERRQ(ierr); 23197b6e6e8SMatthew G. Knepley if (numConstants) { 23297b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D constants\n", numConstants);CHKERRQ(ierr); 23397b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 23457fc01e9SMatthew G. Knepley for (f = 0; f < numConstants; ++f) {ierr = PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]));CHKERRQ(ierr);} 23597b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 23697b6e6e8SMatthew G. Knepley } 2376528b96dSMatthew G. Knepley ierr = PetscWeakFormView(prob->wf, viewer);CHKERRQ(ierr); 2387d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 2397d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 2407d8a60eaSMatthew G. Knepley } 2417d8a60eaSMatthew G. Knepley 2422764a2aaSMatthew G. Knepley /*@C 243fe2efc57SMark PetscDSViewFromOptions - View from Options 244fe2efc57SMark 245fe2efc57SMark Collective on PetscDS 246fe2efc57SMark 247fe2efc57SMark Input Parameters: 248fe2efc57SMark + A - the PetscDS object 249736c3998SJose E. Roman . obj - Optional object 250736c3998SJose E. Roman - name - command line option 251fe2efc57SMark 252fe2efc57SMark Level: intermediate 253fe2efc57SMark .seealso: PetscDS, PetscDSView, PetscObjectViewFromOptions(), PetscDSCreate() 254fe2efc57SMark @*/ 255fe2efc57SMark PetscErrorCode PetscDSViewFromOptions(PetscDS A,PetscObject obj,const char name[]) 256fe2efc57SMark { 257fe2efc57SMark PetscErrorCode ierr; 258fe2efc57SMark 259fe2efc57SMark PetscFunctionBegin; 260fe2efc57SMark PetscValidHeaderSpecific(A,PETSCDS_CLASSID,1); 261fe2efc57SMark ierr = PetscObjectViewFromOptions((PetscObject)A,obj,name);CHKERRQ(ierr); 262fe2efc57SMark PetscFunctionReturn(0); 263fe2efc57SMark } 264fe2efc57SMark 265fe2efc57SMark /*@C 2662764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 2672764a2aaSMatthew G. Knepley 268d083f849SBarry Smith Collective on prob 2692764a2aaSMatthew G. Knepley 270d8d19677SJose E. Roman Input Parameters: 2712764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 2722764a2aaSMatthew G. Knepley - v - the viewer 2732764a2aaSMatthew G. Knepley 2742764a2aaSMatthew G. Knepley Level: developer 2752764a2aaSMatthew G. Knepley 2762764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 2772764a2aaSMatthew G. Knepley @*/ 2782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2792764a2aaSMatthew G. Knepley { 2807d8a60eaSMatthew G. Knepley PetscBool iascii; 2812764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2822764a2aaSMatthew G. Knepley 2832764a2aaSMatthew G. Knepley PetscFunctionBegin; 2842764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2852764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 2867d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2877d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2887d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2892764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2902764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2912764a2aaSMatthew G. Knepley } 2922764a2aaSMatthew G. Knepley 2932764a2aaSMatthew G. Knepley /*@ 2942764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2952764a2aaSMatthew G. Knepley 296d083f849SBarry Smith Collective on prob 2972764a2aaSMatthew G. Knepley 2982764a2aaSMatthew G. Knepley Input Parameter: 2992764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 3002764a2aaSMatthew G. Knepley 3012764a2aaSMatthew G. Knepley Options Database: 30255c1f793SMatthew G. Knepley + -petscds_type <type> : Set the DS type 30355c1f793SMatthew G. Knepley . -petscds_view <view opt> : View the DS 30455c1f793SMatthew G. Knepley . -petscds_jac_pre : Turn formation of a separate Jacobian preconditioner on and off 30555c1f793SMatthew G. Knepley . -bc_<name> <ids> : Specify a list of label ids for a boundary condition 30655c1f793SMatthew G. Knepley - -bc_<name>_comp <comps> : Specify a list of field components to constrain for a boundary condition 3072764a2aaSMatthew G. Knepley 3082764a2aaSMatthew G. Knepley Level: developer 3092764a2aaSMatthew G. Knepley 3102764a2aaSMatthew G. Knepley .seealso PetscDSView() 3112764a2aaSMatthew G. Knepley @*/ 3122764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 3132764a2aaSMatthew G. Knepley { 314f1fd5e65SToby Isaac DSBoundary b; 3152764a2aaSMatthew G. Knepley const char *defaultType; 3162764a2aaSMatthew G. Knepley char name[256]; 3172764a2aaSMatthew G. Knepley PetscBool flg; 3182764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3192764a2aaSMatthew G. Knepley 3202764a2aaSMatthew G. Knepley PetscFunctionBegin; 3212764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3222764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3232764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3242764a2aaSMatthew G. Knepley } else { 3252764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3262764a2aaSMatthew G. Knepley } 3270f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 3282764a2aaSMatthew G. Knepley 3292764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 330f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 331f1fd5e65SToby Isaac char optname[1024]; 332f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 333f1fd5e65SToby Isaac PetscBool flg; 334f1fd5e65SToby Isaac 335f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name);CHKERRQ(ierr); 336f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 337f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg);CHKERRQ(ierr); 338f1fd5e65SToby Isaac if (flg) { 33945480ffeSMatthew G. Knepley b->Nv = len; 34045480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 34145480ffeSMatthew G. Knepley ierr = PetscMalloc1(len, &b->values);CHKERRQ(ierr); 34245480ffeSMatthew G. Knepley ierr = PetscArraycpy(b->values, ids, len);CHKERRQ(ierr); 34345480ffeSMatthew G. Knepley ierr = PetscWeakFormRewriteKeys(b->wf, b->label, len, b->values);CHKERRQ(ierr); 344f1fd5e65SToby Isaac } 345e7b0402cSSander Arens len = 1024; 346f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name);CHKERRQ(ierr); 347f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 348f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg);CHKERRQ(ierr); 349f1fd5e65SToby Isaac if (flg) { 35045480ffeSMatthew G. Knepley b->Nc = len; 351f1fd5e65SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 352f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->comps);CHKERRQ(ierr); 353580bdb30SBarry Smith ierr = PetscArraycpy(b->comps, ids, len);CHKERRQ(ierr); 354f1fd5e65SToby Isaac } 355f1fd5e65SToby Isaac } 3562764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 3572764a2aaSMatthew G. Knepley if (flg) { 3582764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 3592764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3602764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 3612764a2aaSMatthew G. Knepley } 36255c1f793SMatthew G. Knepley ierr = PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg);CHKERRQ(ierr); 3632764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 3642764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3650633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 3662764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 3675d160056SMatthew G. Knepley if (prob->Nf) {ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);} 3682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3692764a2aaSMatthew G. Knepley } 3702764a2aaSMatthew G. Knepley 3712764a2aaSMatthew G. Knepley /*@C 3722764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3732764a2aaSMatthew G. Knepley 374d083f849SBarry Smith Collective on prob 3752764a2aaSMatthew G. Knepley 3762764a2aaSMatthew G. Knepley Input Parameter: 3772764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3782764a2aaSMatthew G. Knepley 3792764a2aaSMatthew G. Knepley Level: developer 3802764a2aaSMatthew G. Knepley 3812764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3822764a2aaSMatthew G. Knepley @*/ 3832764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3842764a2aaSMatthew G. Knepley { 3852764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 386f9244615SMatthew G. Knepley PetscBool hasH = PETSC_FALSE; 3874bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3882764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3892764a2aaSMatthew G. Knepley 3902764a2aaSMatthew G. Knepley PetscFunctionBegin; 3912764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3922764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3932764a2aaSMatthew G. Knepley /* Calculate sizes */ 3942764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 395d1506c7cSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &dimEmbed);CHKERRQ(ierr); 396f744cafaSSander Arens prob->totDim = prob->totComp = 0; 39747e57110SSander Arens ierr = PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb);CHKERRQ(ierr); 398f744cafaSSander Arens ierr = PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer);CHKERRQ(ierr); 399ef0bb6c7SMatthew G. Knepley ierr = PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf);CHKERRQ(ierr); 4002764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 4019de99aefSMatthew G. Knepley PetscObject obj; 4029de99aefSMatthew G. Knepley PetscClassId id; 403665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 4049de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 4052764a2aaSMatthew G. Knepley 4069de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 407f9244615SMatthew G. Knepley if (prob->jetDegree[f] > 1) hasH = PETSC_TRUE; 408665f567fSMatthew G. Knepley if (!obj) { 409665f567fSMatthew G. Knepley /* Empty mesh */ 410665f567fSMatthew G. Knepley Nb = Nc = 0; 411665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 412665f567fSMatthew G. Knepley } else { 4139de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 4149de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 4159de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 4169de99aefSMatthew G. Knepley 4172764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 4182764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 4192764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 420f9244615SMatthew G. Knepley ierr = PetscFEGetCellTabulation(fe, prob->jetDegree[f], &prob->T[f]);CHKERRQ(ierr); 421f9244615SMatthew G. Knepley ierr = PetscFEGetFaceTabulation(fe, prob->jetDegree[f], &prob->Tf[f]);CHKERRQ(ierr); 4229de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4239de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4249de99aefSMatthew G. Knepley 4259de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 4269de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 4279c3cf19fSMatthew G. Knepley Nb = Nc; 428ef0bb6c7SMatthew G. Knepley ierr = PetscFVGetCellTabulation(fv, &prob->T[f]);CHKERRQ(ierr); 4294d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 430abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 431665f567fSMatthew G. Knepley } 43247e57110SSander Arens prob->Nc[f] = Nc; 43347e57110SSander Arens prob->Nb[f] = Nb; 434194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 435194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 436a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 4372764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4384bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4392764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4409c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4412764a2aaSMatthew G. Knepley prob->totComp += Nc; 44294a5e212SMatthew G. Knepley /* There are two faces for all fields but the cohesive field on a hybrid cell */ 44394a5e212SMatthew G. Knepley if (prob->isHybrid && (f < Nf-1)) prob->totDim += Nb; 4442764a2aaSMatthew G. Knepley } 4452764a2aaSMatthew G. Knepley /* Allocate works space */ 446b9d30458SMatthew G. Knepley NsMax = 2; /* Even non-hybrid discretizations can be used in a hybrid integration, so we need this extra workspace */ 447f9244615SMatthew G. Knepley ierr = 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);CHKERRQ(ierr); 4484bee2e38SMatthew G. Knepley ierr = PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal);CHKERRQ(ierr); 44927f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 45027f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 45127f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4522764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 4532764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4552764a2aaSMatthew G. Knepley } 4562764a2aaSMatthew G. Knepley 4572764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4582764a2aaSMatthew G. Knepley { 4592764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4602764a2aaSMatthew G. Knepley 4612764a2aaSMatthew G. Knepley PetscFunctionBegin; 46247e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 463f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 464ef0bb6c7SMatthew G. Knepley ierr = PetscFree2(prob->T,prob->Tf);CHKERRQ(ierr); 4654bee2e38SMatthew G. Knepley ierr = PetscFree3(prob->u,prob->u_t,prob->u_x);CHKERRQ(ierr); 4664bee2e38SMatthew G. Knepley ierr = PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal);CHKERRQ(ierr); 4672764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 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; 4766528b96dSMatthew G. Knepley PetscPointFunc *tmpup; 477f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 478f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4790c2f2876SMatthew G. Knepley void **tmpctx; 48034aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4812764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4822764a2aaSMatthew G. Knepley 4832764a2aaSMatthew G. Knepley PetscFunctionBegin; 4842764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4852764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4862764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 487f9244615SMatthew G. Knepley ierr = PetscMalloc3(NfNew, &tmpd, NfNew, &tmpi, NfNew, &tmpk);CHKERRQ(ierr); 488f9244615SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f]; tmpk[f] = prob->jetDegree[f];} 489f9244615SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpk[f] = 1;} 490f9244615SMatthew G. Knepley ierr = PetscFree3(prob->disc, prob->implicit, prob->jetDegree);CHKERRQ(ierr); 4916528b96dSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(prob->wf, NfNew);CHKERRQ(ierr); 4922764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4932764a2aaSMatthew G. Knepley prob->disc = tmpd; 494249df284SMatthew G. Knepley prob->implicit = tmpi; 495f9244615SMatthew G. Knepley prob->jetDegree = tmpk; 4966528b96dSMatthew G. Knepley ierr = PetscCalloc2(NfNew, &tmpup, NfNew, &tmpctx);CHKERRQ(ierr); 49732d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4980c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 49932d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 5000c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 5016528b96dSMatthew G. Knepley ierr = PetscFree2(prob->update, prob->ctx);CHKERRQ(ierr); 50232d2bbc9SMatthew G. Knepley prob->update = tmpup; 5030c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 5046528b96dSMatthew G. Knepley ierr = PetscCalloc4(NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t);CHKERRQ(ierr); 505c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50695cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 507f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 508f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 509c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 51095cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 511f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 512f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 5136528b96dSMatthew G. Knepley ierr = PetscFree4(prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t);CHKERRQ(ierr); 514c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51595cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 516f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 517f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5192764a2aaSMatthew G. Knepley } 5202764a2aaSMatthew G. Knepley 5212764a2aaSMatthew G. Knepley /*@ 5222764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5232764a2aaSMatthew G. Knepley 524d083f849SBarry Smith Collective on prob 5252764a2aaSMatthew G. Knepley 5262764a2aaSMatthew G. Knepley Input Parameter: 5272764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5282764a2aaSMatthew G. Knepley 5292764a2aaSMatthew G. Knepley Level: developer 5302764a2aaSMatthew G. Knepley 5312764a2aaSMatthew G. Knepley .seealso PetscDSView() 5322764a2aaSMatthew G. Knepley @*/ 5336528b96dSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *ds) 5342764a2aaSMatthew G. Knepley { 5352764a2aaSMatthew G. Knepley PetscInt f; 5362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 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 5476528b96dSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*ds, &dim);CHKERRQ(ierr); 5486528b96dSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*ds)->subprobs[d]);CHKERRQ(ierr);} 549df3a45bdSMatthew G. Knepley } 5506528b96dSMatthew G. Knepley ierr = PetscFree((*ds)->subprobs);CHKERRQ(ierr); 5516528b96dSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*ds);CHKERRQ(ierr); 5526528b96dSMatthew G. Knepley for (f = 0; f < (*ds)->Nf; ++f) { 5536528b96dSMatthew G. Knepley ierr = PetscObjectDereference((*ds)->disc[f]);CHKERRQ(ierr); 5542764a2aaSMatthew G. Knepley } 5556528b96dSMatthew G. Knepley ierr = PetscFree3((*ds)->disc, (*ds)->implicit, (*ds)->jetDegree);CHKERRQ(ierr); 5566528b96dSMatthew G. Knepley ierr = PetscWeakFormDestroy(&(*ds)->wf);CHKERRQ(ierr); 5576528b96dSMatthew G. Knepley ierr = PetscFree2((*ds)->update,(*ds)->ctx);CHKERRQ(ierr); 5586528b96dSMatthew G. Knepley ierr = PetscFree4((*ds)->exactSol,(*ds)->exactCtx,(*ds)->exactSol_t,(*ds)->exactCtx_t);CHKERRQ(ierr); 5596528b96dSMatthew G. Knepley if ((*ds)->ops->destroy) {ierr = (*(*ds)->ops->destroy)(*ds);CHKERRQ(ierr);} 56045480ffeSMatthew G. Knepley ierr = PetscDSDestroyBoundary(*ds);CHKERRQ(ierr); 5616528b96dSMatthew G. Knepley ierr = PetscFree((*ds)->constants);CHKERRQ(ierr); 5626528b96dSMatthew G. Knepley ierr = PetscHeaderDestroy(ds);CHKERRQ(ierr); 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 PetscErrorCode ierr; 5852764a2aaSMatthew G. Knepley 5862764a2aaSMatthew G. Knepley PetscFunctionBegin; 5876528b96dSMatthew G. Knepley PetscValidPointer(ds, 2); 5886528b96dSMatthew G. Knepley *ds = NULL; 5892764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5902764a2aaSMatthew G. Knepley 59173107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5922764a2aaSMatthew G. Knepley 5932764a2aaSMatthew G. Knepley p->Nf = 0; 5942764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 59597b6e6e8SMatthew G. Knepley p->numConstants = 0; 59697b6e6e8SMatthew G. Knepley p->constants = NULL; 597a859676bSMatthew G. Knepley p->dimEmbed = -1; 59855c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5996528b96dSMatthew G. Knepley ierr = PetscWeakFormCreate(comm, &p->wf);CHKERRQ(ierr); 6002764a2aaSMatthew G. Knepley 6016528b96dSMatthew G. Knepley *ds = p; 6022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6032764a2aaSMatthew G. Knepley } 6042764a2aaSMatthew G. Knepley 605bc4ae4beSMatthew G. Knepley /*@ 606bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 607bc4ae4beSMatthew G. Knepley 608bc4ae4beSMatthew G. Knepley Not collective 609bc4ae4beSMatthew G. Knepley 610bc4ae4beSMatthew G. Knepley Input Parameter: 611bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 612bc4ae4beSMatthew G. Knepley 613bc4ae4beSMatthew G. Knepley Output Parameter: 614bc4ae4beSMatthew G. Knepley . Nf - The number of fields 615bc4ae4beSMatthew G. Knepley 616bc4ae4beSMatthew G. Knepley Level: beginner 617bc4ae4beSMatthew G. Knepley 618bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 619bc4ae4beSMatthew G. Knepley @*/ 6202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6212764a2aaSMatthew G. Knepley { 6222764a2aaSMatthew G. Knepley PetscFunctionBegin; 6232764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6242764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6252764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6272764a2aaSMatthew G. Knepley } 6282764a2aaSMatthew G. Knepley 629bc4ae4beSMatthew G. Knepley /*@ 630a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 631bc4ae4beSMatthew G. Knepley 632bc4ae4beSMatthew G. Knepley Not collective 633bc4ae4beSMatthew G. Knepley 634bc4ae4beSMatthew G. Knepley Input Parameter: 635bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 636bc4ae4beSMatthew G. Knepley 637bc4ae4beSMatthew G. Knepley Output Parameter: 638bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 639bc4ae4beSMatthew G. Knepley 640bc4ae4beSMatthew G. Knepley Level: beginner 641bc4ae4beSMatthew G. Knepley 642a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 643bc4ae4beSMatthew G. Knepley @*/ 6442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6452764a2aaSMatthew G. Knepley { 6462764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6472764a2aaSMatthew G. Knepley 6482764a2aaSMatthew G. Knepley PetscFunctionBegin; 6492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6502764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6512764a2aaSMatthew G. Knepley *dim = 0; 6529de99aefSMatthew G. Knepley if (prob->Nf) { 6539de99aefSMatthew G. Knepley PetscObject obj; 6549de99aefSMatthew G. Knepley PetscClassId id; 6559de99aefSMatthew G. Knepley 6569de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 657665f567fSMatthew G. Knepley if (obj) { 6589de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 6599de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 6609de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 6619de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6629de99aefSMatthew G. Knepley } 663665f567fSMatthew G. Knepley } 6642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6652764a2aaSMatthew G. Knepley } 6662764a2aaSMatthew G. Knepley 667bc4ae4beSMatthew G. Knepley /*@ 668a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 669a859676bSMatthew G. Knepley 670a859676bSMatthew G. Knepley Not collective 671a859676bSMatthew G. Knepley 672a859676bSMatthew G. Knepley Input Parameter: 673a859676bSMatthew G. Knepley . prob - The PetscDS object 674a859676bSMatthew G. Knepley 675a859676bSMatthew G. Knepley Output Parameter: 676a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 677a859676bSMatthew G. Knepley 678a859676bSMatthew G. Knepley Level: beginner 679a859676bSMatthew G. Knepley 680a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 681a859676bSMatthew G. Knepley @*/ 682a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 683a859676bSMatthew G. Knepley { 684a859676bSMatthew G. Knepley PetscFunctionBegin; 685a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 686a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 687a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 688a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 689a859676bSMatthew G. Knepley PetscFunctionReturn(0); 690a859676bSMatthew G. Knepley } 691a859676bSMatthew G. Knepley 692a859676bSMatthew G. Knepley /*@ 693a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 694a859676bSMatthew G. Knepley 695d083f849SBarry Smith Logically collective on prob 696a859676bSMatthew G. Knepley 697a859676bSMatthew G. Knepley Input Parameters: 698a859676bSMatthew G. Knepley + prob - The PetscDS object 699a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 700a859676bSMatthew G. Knepley 701a859676bSMatthew G. Knepley Level: beginner 702a859676bSMatthew G. Knepley 703a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 704a859676bSMatthew G. Knepley @*/ 705a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 706a859676bSMatthew G. Knepley { 707a859676bSMatthew G. Knepley PetscFunctionBegin; 708a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 709ebfe4b0dSMatthew G. Knepley if (dimEmbed < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 710a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 711a859676bSMatthew G. Knepley PetscFunctionReturn(0); 712a859676bSMatthew G. Knepley } 713a859676bSMatthew G. Knepley 714a859676bSMatthew G. Knepley /*@ 7158edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 7168edf6225SMatthew G. Knepley 7178edf6225SMatthew G. Knepley Not collective 7188edf6225SMatthew G. Knepley 7198edf6225SMatthew G. Knepley Input Parameter: 7208edf6225SMatthew G. Knepley . prob - The PetscDS object 7218edf6225SMatthew G. Knepley 7228edf6225SMatthew G. Knepley Output Parameter: 7238edf6225SMatthew G. Knepley . isHybrid - The flag 7248edf6225SMatthew G. Knepley 7258edf6225SMatthew G. Knepley Level: developer 7268edf6225SMatthew G. Knepley 7278edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 7288edf6225SMatthew G. Knepley @*/ 7298edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 7308edf6225SMatthew G. Knepley { 7318edf6225SMatthew G. Knepley PetscFunctionBegin; 7328edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7338edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 7348edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 7358edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7368edf6225SMatthew G. Knepley } 7378edf6225SMatthew G. Knepley 7388edf6225SMatthew G. Knepley /*@ 7398edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 7408edf6225SMatthew G. Knepley 7418edf6225SMatthew G. Knepley Not collective 7428edf6225SMatthew G. Knepley 7438edf6225SMatthew G. Knepley Input Parameters: 7448edf6225SMatthew G. Knepley + prob - The PetscDS object 7458edf6225SMatthew G. Knepley - isHybrid - The flag 7468edf6225SMatthew G. Knepley 7478edf6225SMatthew G. Knepley Level: developer 7488edf6225SMatthew G. Knepley 7498edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 7508edf6225SMatthew G. Knepley @*/ 7518edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 7528edf6225SMatthew G. Knepley { 7538edf6225SMatthew G. Knepley PetscFunctionBegin; 7548edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7558edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 7568edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7578edf6225SMatthew G. Knepley } 7588edf6225SMatthew G. Knepley 7598edf6225SMatthew G. Knepley /*@ 760bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 761bc4ae4beSMatthew G. Knepley 762bc4ae4beSMatthew G. Knepley Not collective 763bc4ae4beSMatthew G. Knepley 764bc4ae4beSMatthew G. Knepley Input Parameter: 765bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 766bc4ae4beSMatthew G. Knepley 767bc4ae4beSMatthew G. Knepley Output Parameter: 768bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 769bc4ae4beSMatthew G. Knepley 770bc4ae4beSMatthew G. Knepley Level: beginner 771bc4ae4beSMatthew G. Knepley 772bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 773bc4ae4beSMatthew G. Knepley @*/ 7742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7752764a2aaSMatthew G. Knepley { 7762764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7772764a2aaSMatthew G. Knepley 7782764a2aaSMatthew G. Knepley PetscFunctionBegin; 7792764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7802764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7812764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 7822764a2aaSMatthew G. Knepley *dim = prob->totDim; 7832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7842764a2aaSMatthew G. Knepley } 7852764a2aaSMatthew G. Knepley 786bc4ae4beSMatthew G. Knepley /*@ 787bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 788bc4ae4beSMatthew G. Knepley 789bc4ae4beSMatthew G. Knepley Not collective 790bc4ae4beSMatthew G. Knepley 791bc4ae4beSMatthew G. Knepley Input Parameter: 792bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 793bc4ae4beSMatthew G. Knepley 794bc4ae4beSMatthew G. Knepley Output Parameter: 795bc4ae4beSMatthew G. Knepley . dim - The total number of components 796bc4ae4beSMatthew G. Knepley 797bc4ae4beSMatthew G. Knepley Level: beginner 798bc4ae4beSMatthew G. Knepley 799bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 800bc4ae4beSMatthew G. Knepley @*/ 8012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8022764a2aaSMatthew G. Knepley { 8032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8042764a2aaSMatthew G. Knepley 8052764a2aaSMatthew G. Knepley PetscFunctionBegin; 8062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8072764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8082764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8092764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8112764a2aaSMatthew G. Knepley } 8122764a2aaSMatthew G. Knepley 813bc4ae4beSMatthew G. Knepley /*@ 814bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 815bc4ae4beSMatthew G. Knepley 816bc4ae4beSMatthew G. Knepley Not collective 817bc4ae4beSMatthew G. Knepley 818bc4ae4beSMatthew G. Knepley Input Parameters: 819bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 820bc4ae4beSMatthew G. Knepley - f - The field number 821bc4ae4beSMatthew G. Knepley 822bc4ae4beSMatthew G. Knepley Output Parameter: 823bc4ae4beSMatthew G. Knepley . disc - The discretization object 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley Level: beginner 826bc4ae4beSMatthew G. Knepley 827f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 828bc4ae4beSMatthew G. Knepley @*/ 8292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8302764a2aaSMatthew G. Knepley { 8316528b96dSMatthew G. Knepley PetscFunctionBeginHot; 8322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8332764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8342764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 8352764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8362764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8372764a2aaSMatthew G. Knepley } 8382764a2aaSMatthew G. Knepley 839bc4ae4beSMatthew G. Knepley /*@ 840bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 841bc4ae4beSMatthew G. Knepley 842bc4ae4beSMatthew G. Knepley Not collective 843bc4ae4beSMatthew G. Knepley 844bc4ae4beSMatthew G. Knepley Input Parameters: 845bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 846bc4ae4beSMatthew G. Knepley . f - The field number 847bc4ae4beSMatthew G. Knepley - disc - The discretization object 848bc4ae4beSMatthew G. Knepley 849bc4ae4beSMatthew G. Knepley Level: beginner 850bc4ae4beSMatthew G. Knepley 851bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 852bc4ae4beSMatthew G. Knepley @*/ 8532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 8542764a2aaSMatthew G. Knepley { 8552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8562764a2aaSMatthew G. Knepley 8572764a2aaSMatthew G. Knepley PetscFunctionBegin; 8582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 859665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 8602764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 8612764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 862c10f2116SMatthew G. Knepley ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr); 8632764a2aaSMatthew G. Knepley prob->disc[f] = disc; 8642764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 865665f567fSMatthew G. Knepley if (disc) { 866249df284SMatthew G. Knepley PetscClassId id; 867249df284SMatthew G. Knepley 868249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8691cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8701cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8711cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8721cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 873a6cbbb48SMatthew G. Knepley } 874f9244615SMatthew G. Knepley ierr = PetscDSSetJetDegree(prob, f, 1);CHKERRQ(ierr); 875249df284SMatthew G. Knepley } 8762764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8772764a2aaSMatthew G. Knepley } 8782764a2aaSMatthew G. Knepley 879bc4ae4beSMatthew G. Knepley /*@ 8806528b96dSMatthew G. Knepley PetscDSGetWeakForm - Returns the weak form object 8816528b96dSMatthew G. Knepley 8826528b96dSMatthew G. Knepley Not collective 8836528b96dSMatthew G. Knepley 8846528b96dSMatthew G. Knepley Input Parameter: 8856528b96dSMatthew G. Knepley . ds - The PetscDS object 8866528b96dSMatthew G. Knepley 8876528b96dSMatthew G. Knepley Output Parameter: 8886528b96dSMatthew G. Knepley . wf - The weak form object 8896528b96dSMatthew G. Knepley 8906528b96dSMatthew G. Knepley Level: beginner 8916528b96dSMatthew G. Knepley 8926528b96dSMatthew G. Knepley .seealso: PetscDSSetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 8936528b96dSMatthew G. Knepley @*/ 8946528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetWeakForm(PetscDS ds, PetscWeakForm *wf) 8956528b96dSMatthew G. Knepley { 8966528b96dSMatthew G. Knepley PetscFunctionBegin; 8976528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 8986528b96dSMatthew G. Knepley PetscValidPointer(wf, 2); 8996528b96dSMatthew G. Knepley *wf = ds->wf; 9006528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9016528b96dSMatthew G. Knepley } 9026528b96dSMatthew G. Knepley 9036528b96dSMatthew G. Knepley /*@ 9046528b96dSMatthew G. Knepley PetscDSSetWeakForm - Sets the weak form object 9056528b96dSMatthew G. Knepley 9066528b96dSMatthew G. Knepley Not collective 9076528b96dSMatthew G. Knepley 9086528b96dSMatthew G. Knepley Input Parameters: 9096528b96dSMatthew G. Knepley + ds - The PetscDS object 9106528b96dSMatthew G. Knepley - wf - The weak form object 9116528b96dSMatthew G. Knepley 9126528b96dSMatthew G. Knepley Level: beginner 9136528b96dSMatthew G. Knepley 9146528b96dSMatthew G. Knepley .seealso: PetscDSGetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9156528b96dSMatthew G. Knepley @*/ 9166528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetWeakForm(PetscDS ds, PetscWeakForm wf) 9176528b96dSMatthew G. Knepley { 9186528b96dSMatthew G. Knepley PetscErrorCode ierr; 9196528b96dSMatthew G. Knepley 9206528b96dSMatthew G. Knepley PetscFunctionBegin; 9216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9226528b96dSMatthew G. Knepley PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 2); 9236528b96dSMatthew G. Knepley ierr = PetscObjectDereference((PetscObject) ds->wf);CHKERRQ(ierr); 9246528b96dSMatthew G. Knepley ds->wf = wf; 9256528b96dSMatthew G. Knepley ierr = PetscObjectReference((PetscObject) wf);CHKERRQ(ierr); 9266528b96dSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(wf, ds->Nf);CHKERRQ(ierr); 9276528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9286528b96dSMatthew G. Knepley } 9296528b96dSMatthew G. Knepley 9306528b96dSMatthew G. Knepley /*@ 931bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 932bc4ae4beSMatthew G. Knepley 933bc4ae4beSMatthew G. Knepley Not collective 934bc4ae4beSMatthew G. Knepley 935bc4ae4beSMatthew G. Knepley Input Parameters: 936bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 937bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 938bc4ae4beSMatthew G. Knepley 939bc4ae4beSMatthew G. Knepley Level: beginner 940bc4ae4beSMatthew G. Knepley 941bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 942bc4ae4beSMatthew G. Knepley @*/ 9432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9442764a2aaSMatthew G. Knepley { 9452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9462764a2aaSMatthew G. Knepley 9472764a2aaSMatthew G. Knepley PetscFunctionBegin; 9482764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 9492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9502764a2aaSMatthew G. Knepley } 9512764a2aaSMatthew G. Knepley 952249df284SMatthew G. Knepley /*@ 953083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 954083401c6SMatthew G. Knepley 955083401c6SMatthew G. Knepley Not collective 956083401c6SMatthew G. Knepley 957083401c6SMatthew G. Knepley Input Parameter: 958083401c6SMatthew G. Knepley . prob - The PetscDS object 959083401c6SMatthew G. Knepley 960083401c6SMatthew G. Knepley Output Parameter: 961083401c6SMatthew G. Knepley . q - The quadrature object 962083401c6SMatthew G. Knepley 963083401c6SMatthew G. Knepley Level: intermediate 964083401c6SMatthew G. Knepley 965083401c6SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 966083401c6SMatthew G. Knepley @*/ 967083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 968083401c6SMatthew G. Knepley { 969083401c6SMatthew G. Knepley PetscObject obj; 970083401c6SMatthew G. Knepley PetscClassId id; 971083401c6SMatthew G. Knepley PetscErrorCode ierr; 972083401c6SMatthew G. Knepley 973083401c6SMatthew G. Knepley PetscFunctionBegin; 974083401c6SMatthew G. Knepley *q = NULL; 975083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 976083401c6SMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 977083401c6SMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 978083401c6SMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetQuadrature((PetscFE) obj, q);CHKERRQ(ierr);} 979083401c6SMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetQuadrature((PetscFV) obj, q);CHKERRQ(ierr);} 980083401c6SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 981083401c6SMatthew G. Knepley PetscFunctionReturn(0); 982083401c6SMatthew G. Knepley } 983083401c6SMatthew G. Knepley 984083401c6SMatthew G. Knepley /*@ 985249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 986249df284SMatthew G. Knepley 987249df284SMatthew G. Knepley Not collective 988249df284SMatthew G. Knepley 989249df284SMatthew G. Knepley Input Parameters: 990249df284SMatthew G. Knepley + prob - The PetscDS object 991249df284SMatthew G. Knepley - f - The field number 992249df284SMatthew G. Knepley 993249df284SMatthew G. Knepley Output Parameter: 994249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 995249df284SMatthew G. Knepley 996249df284SMatthew G. Knepley Level: developer 997249df284SMatthew G. Knepley 998f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 999249df284SMatthew G. Knepley @*/ 1000249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 1001249df284SMatthew G. Knepley { 1002249df284SMatthew G. Knepley PetscFunctionBegin; 1003249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1004249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 1005249df284SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1006249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 1007249df284SMatthew G. Knepley PetscFunctionReturn(0); 1008249df284SMatthew G. Knepley } 1009249df284SMatthew G. Knepley 1010249df284SMatthew G. Knepley /*@ 1011249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 1012249df284SMatthew G. Knepley 1013249df284SMatthew G. Knepley Not collective 1014249df284SMatthew G. Knepley 1015249df284SMatthew G. Knepley Input Parameters: 1016249df284SMatthew G. Knepley + prob - The PetscDS object 1017249df284SMatthew G. Knepley . f - The field number 1018249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 1019249df284SMatthew G. Knepley 1020249df284SMatthew G. Knepley Level: developer 1021249df284SMatthew G. Knepley 1022f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1023249df284SMatthew G. Knepley @*/ 1024249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 1025249df284SMatthew G. Knepley { 1026249df284SMatthew G. Knepley PetscFunctionBegin; 1027249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1028249df284SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1029249df284SMatthew G. Knepley prob->implicit[f] = implicit; 1030249df284SMatthew G. Knepley PetscFunctionReturn(0); 1031249df284SMatthew G. Knepley } 1032249df284SMatthew G. Knepley 1033f9244615SMatthew G. Knepley /*@ 1034f9244615SMatthew G. Knepley PetscDSGetJetDegree - Returns the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1035f9244615SMatthew G. Knepley 1036f9244615SMatthew G. Knepley Not collective 1037f9244615SMatthew G. Knepley 1038f9244615SMatthew G. Knepley Input Parameters: 1039f9244615SMatthew G. Knepley + ds - The PetscDS object 1040f9244615SMatthew G. Knepley - f - The field number 1041f9244615SMatthew G. Knepley 1042f9244615SMatthew G. Knepley Output Parameter: 1043f9244615SMatthew G. Knepley . k - The highest derivative we need to tabulate 1044f9244615SMatthew G. Knepley 1045f9244615SMatthew G. Knepley Level: developer 1046f9244615SMatthew G. Knepley 1047f9244615SMatthew G. Knepley .seealso: PetscDSSetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1048f9244615SMatthew G. Knepley @*/ 1049f9244615SMatthew G. Knepley PetscErrorCode PetscDSGetJetDegree(PetscDS ds, PetscInt f, PetscInt *k) 1050f9244615SMatthew G. Knepley { 1051f9244615SMatthew G. Knepley PetscFunctionBegin; 1052f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1053f9244615SMatthew G. Knepley PetscValidPointer(k, 3); 1054f9244615SMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1055f9244615SMatthew G. Knepley *k = ds->jetDegree[f]; 1056f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1057f9244615SMatthew G. Knepley } 1058f9244615SMatthew G. Knepley 1059f9244615SMatthew G. Knepley /*@ 1060f9244615SMatthew G. Knepley PetscDSSetJetDegree - Set the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1061f9244615SMatthew G. Knepley 1062f9244615SMatthew G. Knepley Not collective 1063f9244615SMatthew G. Knepley 1064f9244615SMatthew G. Knepley Input Parameters: 1065f9244615SMatthew G. Knepley + ds - The PetscDS object 1066f9244615SMatthew G. Knepley . f - The field number 1067f9244615SMatthew G. Knepley - k - The highest derivative we need to tabulate 1068f9244615SMatthew G. Knepley 1069f9244615SMatthew G. Knepley Level: developer 1070f9244615SMatthew G. Knepley 1071f9244615SMatthew G. Knepley .seealso: PetscDSGetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1072f9244615SMatthew G. Knepley @*/ 1073f9244615SMatthew G. Knepley PetscErrorCode PetscDSSetJetDegree(PetscDS ds, PetscInt f, PetscInt k) 1074f9244615SMatthew G. Knepley { 1075f9244615SMatthew G. Knepley PetscFunctionBegin; 1076f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1077f9244615SMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1078f9244615SMatthew G. Knepley ds->jetDegree[f] = k; 1079f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1080f9244615SMatthew G. Knepley } 1081f9244615SMatthew G. Knepley 10826528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS ds, PetscInt f, 108330b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1084194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1085194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 10872764a2aaSMatthew G. Knepley { 10886528b96dSMatthew G. Knepley PetscPointFunc *tmp; 10896528b96dSMatthew G. Knepley PetscInt n; 10906528b96dSMatthew G. Knepley PetscErrorCode ierr; 10916528b96dSMatthew G. Knepley 10922764a2aaSMatthew G. Knepley PetscFunctionBegin; 10936528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 10946528b96dSMatthew G. Knepley PetscValidPointer(obj, 3); 10956528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 109606ad1575SMatthew G. Knepley ierr = PetscWeakFormGetObjective(ds->wf, NULL, 0, f, 0, &n, &tmp);CHKERRQ(ierr); 10976528b96dSMatthew G. Knepley *obj = tmp ? tmp[0] : NULL; 10982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10992764a2aaSMatthew G. Knepley } 11002764a2aaSMatthew G. Knepley 11016528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS ds, PetscInt f, 110230b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1103194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1104194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11062764a2aaSMatthew G. Knepley { 11072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11082764a2aaSMatthew G. Knepley 11092764a2aaSMatthew G. Knepley PetscFunctionBegin; 11106528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11116528b96dSMatthew G. Knepley if (obj) PetscValidFunction(obj, 3); 11122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 111306ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexObjective(ds->wf, NULL, 0, f, 0, 0, obj);CHKERRQ(ierr); 11142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11152764a2aaSMatthew G. Knepley } 11162764a2aaSMatthew G. Knepley 1117194d53e6SMatthew G. Knepley /*@C 1118194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1119194d53e6SMatthew G. Knepley 1120194d53e6SMatthew G. Knepley Not collective 1121194d53e6SMatthew G. Knepley 1122194d53e6SMatthew G. Knepley Input Parameters: 11236528b96dSMatthew G. Knepley + ds - The PetscDS 1124194d53e6SMatthew G. Knepley - f - The test field number 1125194d53e6SMatthew G. Knepley 1126194d53e6SMatthew G. Knepley Output Parameters: 1127194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1128194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1129194d53e6SMatthew G. Knepley 1130194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1131194d53e6SMatthew G. Knepley 1132194d53e6SMatthew 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) 1133194d53e6SMatthew G. Knepley 1134194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1135194d53e6SMatthew G. Knepley 113630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1137194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1138194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 113930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1140194d53e6SMatthew G. Knepley 1141194d53e6SMatthew G. Knepley + dim - the spatial dimension 1142194d53e6SMatthew G. Knepley . Nf - the number of fields 1143194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1144194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1145194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1146194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1147194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1148194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1149194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1150194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1151194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1152194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1153194d53e6SMatthew G. Knepley . t - current time 1154194d53e6SMatthew G. Knepley . x - coordinates of the current point 115597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 115697b6e6e8SMatthew G. Knepley . constants - constant parameters 1157194d53e6SMatthew G. Knepley - f0 - output values at the current point 1158194d53e6SMatthew G. Knepley 1159194d53e6SMatthew G. Knepley Level: intermediate 1160194d53e6SMatthew G. Knepley 1161194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1162194d53e6SMatthew G. Knepley @*/ 11636528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS ds, PetscInt f, 116430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1165194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1166194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 116830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1169194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1170194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11722764a2aaSMatthew G. Knepley { 11736528b96dSMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 11746528b96dSMatthew G. Knepley PetscInt n0, n1; 11756528b96dSMatthew G. Knepley PetscErrorCode ierr; 11766528b96dSMatthew G. Knepley 11772764a2aaSMatthew G. Knepley PetscFunctionBegin; 11786528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11796528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 118006ad1575SMatthew G. Knepley ierr = PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1);CHKERRQ(ierr); 11816528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 11826528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 11832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11842764a2aaSMatthew G. Knepley } 11852764a2aaSMatthew G. Knepley 1186194d53e6SMatthew G. Knepley /*@C 1187194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1188194d53e6SMatthew G. Knepley 1189194d53e6SMatthew G. Knepley Not collective 1190194d53e6SMatthew G. Knepley 1191194d53e6SMatthew G. Knepley Input Parameters: 11926528b96dSMatthew G. Knepley + ds - The PetscDS 1193194d53e6SMatthew G. Knepley . f - The test field number 1194194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1195194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1196194d53e6SMatthew G. Knepley 1197194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1198194d53e6SMatthew G. Knepley 1199194d53e6SMatthew 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) 1200194d53e6SMatthew G. Knepley 1201194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1202194d53e6SMatthew G. Knepley 120330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1204194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1205194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1207194d53e6SMatthew G. Knepley 1208194d53e6SMatthew G. Knepley + dim - the spatial dimension 1209194d53e6SMatthew G. Knepley . Nf - the number of fields 1210194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1211194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1212194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1213194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1214194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1215194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1216194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1217194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1218194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1219194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1220194d53e6SMatthew G. Knepley . t - current time 1221194d53e6SMatthew G. Knepley . x - coordinates of the current point 122297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 122397b6e6e8SMatthew G. Knepley . constants - constant parameters 1224194d53e6SMatthew G. Knepley - f0 - output values at the current point 1225194d53e6SMatthew G. Knepley 1226194d53e6SMatthew G. Knepley Level: intermediate 1227194d53e6SMatthew G. Knepley 1228194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1229194d53e6SMatthew G. Knepley @*/ 12306528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS ds, PetscInt f, 123130b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1232194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1233194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 123530b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1236194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1237194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12392764a2aaSMatthew G. Knepley { 12402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12412764a2aaSMatthew G. Knepley 12422764a2aaSMatthew G. Knepley PetscFunctionBegin; 12436528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1244f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1245f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 12462764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 124706ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1);CHKERRQ(ierr); 12482764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12492764a2aaSMatthew G. Knepley } 12502764a2aaSMatthew G. Knepley 12513e75805dSMatthew G. Knepley /*@C 1252*cb36c0f9SMatthew G. Knepley PetscDSGetRHSResidual - Get the pointwise RHS residual function for explicit timestepping for a given test field 1253*cb36c0f9SMatthew G. Knepley 1254*cb36c0f9SMatthew G. Knepley Not collective 1255*cb36c0f9SMatthew G. Knepley 1256*cb36c0f9SMatthew G. Knepley Input Parameters: 1257*cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1258*cb36c0f9SMatthew G. Knepley - f - The test field number 1259*cb36c0f9SMatthew G. Knepley 1260*cb36c0f9SMatthew G. Knepley Output Parameters: 1261*cb36c0f9SMatthew G. Knepley + f0 - integrand for the test function term 1262*cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1263*cb36c0f9SMatthew G. Knepley 1264*cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1265*cb36c0f9SMatthew G. Knepley 1266*cb36c0f9SMatthew 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) 1267*cb36c0f9SMatthew G. Knepley 1268*cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1269*cb36c0f9SMatthew G. Knepley 1270*cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1271*cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1272*cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1273*cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1274*cb36c0f9SMatthew G. Knepley 1275*cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1276*cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1277*cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1278*cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1279*cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1280*cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1281*cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1282*cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1283*cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1284*cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1285*cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1286*cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1287*cb36c0f9SMatthew G. Knepley . t - current time 1288*cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1289*cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1290*cb36c0f9SMatthew G. Knepley . constants - constant parameters 1291*cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1292*cb36c0f9SMatthew G. Knepley 1293*cb36c0f9SMatthew G. Knepley Level: intermediate 1294*cb36c0f9SMatthew G. Knepley 1295*cb36c0f9SMatthew G. Knepley .seealso: PetscDSSetRHSResidual() 1296*cb36c0f9SMatthew G. Knepley @*/ 1297*cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSGetRHSResidual(PetscDS ds, PetscInt f, 1298*cb36c0f9SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1299*cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1300*cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1301*cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1302*cb36c0f9SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1303*cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1304*cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1305*cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1306*cb36c0f9SMatthew G. Knepley { 1307*cb36c0f9SMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 1308*cb36c0f9SMatthew G. Knepley PetscInt n0, n1; 1309*cb36c0f9SMatthew G. Knepley PetscErrorCode ierr; 1310*cb36c0f9SMatthew G. Knepley 1311*cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1312*cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1313*cb36c0f9SMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1314*cb36c0f9SMatthew G. Knepley ierr = PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 100, &n0, &tmp0, &n1, &tmp1);CHKERRQ(ierr); 1315*cb36c0f9SMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 1316*cb36c0f9SMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 1317*cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1318*cb36c0f9SMatthew G. Knepley } 1319*cb36c0f9SMatthew G. Knepley 1320*cb36c0f9SMatthew G. Knepley /*@C 1321*cb36c0f9SMatthew G. Knepley PetscDSSetRHSResidual - Set the pointwise residual function for explicit timestepping for a given test field 1322*cb36c0f9SMatthew G. Knepley 1323*cb36c0f9SMatthew G. Knepley Not collective 1324*cb36c0f9SMatthew G. Knepley 1325*cb36c0f9SMatthew G. Knepley Input Parameters: 1326*cb36c0f9SMatthew G. Knepley + ds - The PetscDS 1327*cb36c0f9SMatthew G. Knepley . f - The test field number 1328*cb36c0f9SMatthew G. Knepley . f0 - integrand for the test function term 1329*cb36c0f9SMatthew G. Knepley - f1 - integrand for the test function gradient term 1330*cb36c0f9SMatthew G. Knepley 1331*cb36c0f9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1332*cb36c0f9SMatthew G. Knepley 1333*cb36c0f9SMatthew 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) 1334*cb36c0f9SMatthew G. Knepley 1335*cb36c0f9SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1336*cb36c0f9SMatthew G. Knepley 1337*cb36c0f9SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1338*cb36c0f9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1339*cb36c0f9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1340*cb36c0f9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1341*cb36c0f9SMatthew G. Knepley 1342*cb36c0f9SMatthew G. Knepley + dim - the spatial dimension 1343*cb36c0f9SMatthew G. Knepley . Nf - the number of fields 1344*cb36c0f9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1345*cb36c0f9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1346*cb36c0f9SMatthew G. Knepley . u - each field evaluated at the current point 1347*cb36c0f9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1348*cb36c0f9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1349*cb36c0f9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1350*cb36c0f9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1351*cb36c0f9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1352*cb36c0f9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1353*cb36c0f9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1354*cb36c0f9SMatthew G. Knepley . t - current time 1355*cb36c0f9SMatthew G. Knepley . x - coordinates of the current point 1356*cb36c0f9SMatthew G. Knepley . numConstants - number of constant parameters 1357*cb36c0f9SMatthew G. Knepley . constants - constant parameters 1358*cb36c0f9SMatthew G. Knepley - f0 - output values at the current point 1359*cb36c0f9SMatthew G. Knepley 1360*cb36c0f9SMatthew G. Knepley Level: intermediate 1361*cb36c0f9SMatthew G. Knepley 1362*cb36c0f9SMatthew G. Knepley .seealso: PetscDSGetResidual() 1363*cb36c0f9SMatthew G. Knepley @*/ 1364*cb36c0f9SMatthew G. Knepley PetscErrorCode PetscDSSetRHSResidual(PetscDS ds, PetscInt f, 1365*cb36c0f9SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1366*cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1367*cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1368*cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 1369*cb36c0f9SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1370*cb36c0f9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1371*cb36c0f9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1372*cb36c0f9SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 1373*cb36c0f9SMatthew G. Knepley { 1374*cb36c0f9SMatthew G. Knepley PetscErrorCode ierr; 1375*cb36c0f9SMatthew G. Knepley 1376*cb36c0f9SMatthew G. Knepley PetscFunctionBegin; 1377*cb36c0f9SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1378*cb36c0f9SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1379*cb36c0f9SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 1380*cb36c0f9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1381*cb36c0f9SMatthew G. Knepley ierr = PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 100, 0, f0, 0, f1);CHKERRQ(ierr); 1382*cb36c0f9SMatthew G. Knepley PetscFunctionReturn(0); 1383*cb36c0f9SMatthew G. Knepley } 1384*cb36c0f9SMatthew G. Knepley 1385*cb36c0f9SMatthew G. Knepley /*@C 13863e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 13873e75805dSMatthew G. Knepley 13883e75805dSMatthew G. Knepley Not collective 13893e75805dSMatthew G. Knepley 13903e75805dSMatthew G. Knepley Input Parameter: 13913e75805dSMatthew G. Knepley . prob - The PetscDS 13923e75805dSMatthew G. Knepley 13933e75805dSMatthew G. Knepley Output Parameter: 13943e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 13953e75805dSMatthew G. Knepley 13963e75805dSMatthew G. Knepley Level: intermediate 13973e75805dSMatthew G. Knepley 13983e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 13993e75805dSMatthew G. Knepley @*/ 14006528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS ds, PetscBool *hasJac) 14013e75805dSMatthew G. Knepley { 14026528b96dSMatthew G. Knepley PetscErrorCode ierr; 14033e75805dSMatthew G. Knepley 14043e75805dSMatthew G. Knepley PetscFunctionBegin; 14056528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14066528b96dSMatthew G. Knepley ierr = PetscWeakFormHasJacobian(ds->wf, hasJac);CHKERRQ(ierr); 14073e75805dSMatthew G. Knepley PetscFunctionReturn(0); 14083e75805dSMatthew G. Knepley } 14093e75805dSMatthew G. Knepley 1410194d53e6SMatthew G. Knepley /*@C 1411194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1412194d53e6SMatthew G. Knepley 1413194d53e6SMatthew G. Knepley Not collective 1414194d53e6SMatthew G. Knepley 1415194d53e6SMatthew G. Knepley Input Parameters: 14166528b96dSMatthew G. Knepley + ds - The PetscDS 1417194d53e6SMatthew G. Knepley . f - The test field number 1418194d53e6SMatthew G. Knepley - g - The field number 1419194d53e6SMatthew G. Knepley 1420194d53e6SMatthew G. Knepley Output Parameters: 1421194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1422194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1423194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1424194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1425194d53e6SMatthew G. Knepley 1426194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1427194d53e6SMatthew G. Knepley 1428194d53e6SMatthew 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 1429194d53e6SMatthew G. Knepley 1430194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1431194d53e6SMatthew G. Knepley 143230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1433194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1434194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 143530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1436194d53e6SMatthew G. Knepley 1437194d53e6SMatthew G. Knepley + dim - the spatial dimension 1438194d53e6SMatthew G. Knepley . Nf - the number of fields 1439194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1440194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1441194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1442194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1443194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1444194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1445194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1446194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1447194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1448194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1449194d53e6SMatthew G. Knepley . t - current time 14502aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1451194d53e6SMatthew G. Knepley . x - coordinates of the current point 145297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 145397b6e6e8SMatthew G. Knepley . constants - constant parameters 1454194d53e6SMatthew G. Knepley - g0 - output values at the current point 1455194d53e6SMatthew G. Knepley 1456194d53e6SMatthew G. Knepley Level: intermediate 1457194d53e6SMatthew G. Knepley 1458194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1459194d53e6SMatthew G. Knepley @*/ 14606528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS ds, PetscInt f, PetscInt g, 146130b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1462194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1463194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 146530b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1466194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1467194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 146930b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1470194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1471194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 147297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 147330b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1474194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1475194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 147697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 14772764a2aaSMatthew G. Knepley { 14786528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 14796528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 14806528b96dSMatthew G. Knepley PetscErrorCode ierr; 14816528b96dSMatthew G. Knepley 14822764a2aaSMatthew G. Knepley PetscFunctionBegin; 14836528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14846528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 14856528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 148606ad1575SMatthew G. Knepley ierr = PetscWeakFormGetJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 14876528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 14886528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 14896528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 14906528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 14912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14922764a2aaSMatthew G. Knepley } 14932764a2aaSMatthew G. Knepley 1494194d53e6SMatthew G. Knepley /*@C 1495194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1496194d53e6SMatthew G. Knepley 1497194d53e6SMatthew G. Knepley Not collective 1498194d53e6SMatthew G. Knepley 1499194d53e6SMatthew G. Knepley Input Parameters: 15006528b96dSMatthew G. Knepley + ds - The PetscDS 1501194d53e6SMatthew G. Knepley . f - The test field number 1502194d53e6SMatthew G. Knepley . g - The field number 1503194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1504194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1505194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1506194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1507194d53e6SMatthew G. Knepley 1508194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1509194d53e6SMatthew G. Knepley 1510194d53e6SMatthew 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 1511194d53e6SMatthew G. Knepley 1512194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1513194d53e6SMatthew G. Knepley 151430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1515194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1516194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 151730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1518194d53e6SMatthew G. Knepley 1519194d53e6SMatthew G. Knepley + dim - the spatial dimension 1520194d53e6SMatthew G. Knepley . Nf - the number of fields 1521194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1522194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1523194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1524194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1525194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1526194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1527194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1528194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1529194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1530194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1531194d53e6SMatthew G. Knepley . t - current time 15322aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1533194d53e6SMatthew G. Knepley . x - coordinates of the current point 153497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 153597b6e6e8SMatthew G. Knepley . constants - constant parameters 1536194d53e6SMatthew G. Knepley - g0 - output values at the current point 1537194d53e6SMatthew G. Knepley 1538194d53e6SMatthew G. Knepley Level: intermediate 1539194d53e6SMatthew G. Knepley 1540194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1541194d53e6SMatthew G. Knepley @*/ 15426528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS ds, PetscInt f, PetscInt g, 154330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1544194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1545194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 154730b9ff8bSMatthew G. Knepley void (*g1)(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[], 155097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 155130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1552194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1553194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 155530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1556194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1557194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 15592764a2aaSMatthew G. Knepley { 15602764a2aaSMatthew G. Knepley PetscErrorCode ierr; 15612764a2aaSMatthew G. Knepley 15622764a2aaSMatthew G. Knepley PetscFunctionBegin; 15636528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15642764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 15652764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 15662764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 15672764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 15682764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 15692764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 157006ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 15712764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15722764a2aaSMatthew G. Knepley } 15732764a2aaSMatthew G. Knepley 1574475e0ac9SMatthew G. Knepley /*@C 157555c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 157655c1f793SMatthew G. Knepley 157755c1f793SMatthew G. Knepley Not collective 157855c1f793SMatthew G. Knepley 157955c1f793SMatthew G. Knepley Input Parameters: 158055c1f793SMatthew G. Knepley + prob - The PetscDS 158155c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 158255c1f793SMatthew G. Knepley 158355c1f793SMatthew G. Knepley Level: intermediate 158455c1f793SMatthew G. Knepley 158555c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 158655c1f793SMatthew G. Knepley @*/ 158755c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 158855c1f793SMatthew G. Knepley { 158955c1f793SMatthew G. Knepley PetscFunctionBegin; 159055c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 159155c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 159255c1f793SMatthew G. Knepley PetscFunctionReturn(0); 159355c1f793SMatthew G. Knepley } 159455c1f793SMatthew G. Knepley 159555c1f793SMatthew G. Knepley /*@C 1596475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1597475e0ac9SMatthew G. Knepley 1598475e0ac9SMatthew G. Knepley Not collective 1599475e0ac9SMatthew G. Knepley 1600475e0ac9SMatthew G. Knepley Input Parameter: 1601475e0ac9SMatthew G. Knepley . prob - The PetscDS 1602475e0ac9SMatthew G. Knepley 1603475e0ac9SMatthew G. Knepley Output Parameter: 1604475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1605475e0ac9SMatthew G. Knepley 1606475e0ac9SMatthew G. Knepley Level: intermediate 1607475e0ac9SMatthew G. Knepley 1608475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1609475e0ac9SMatthew G. Knepley @*/ 16106528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS ds, PetscBool *hasJacPre) 1611475e0ac9SMatthew G. Knepley { 16126528b96dSMatthew G. Knepley PetscErrorCode ierr; 1613475e0ac9SMatthew G. Knepley 1614475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16156528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1616475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 16176528b96dSMatthew G. Knepley if (!ds->useJacPre) PetscFunctionReturn(0); 16186528b96dSMatthew G. Knepley ierr = PetscWeakFormHasJacobianPreconditioner(ds->wf, hasJacPre);CHKERRQ(ierr); 1619475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1620475e0ac9SMatthew G. Knepley } 1621475e0ac9SMatthew G. Knepley 1622475e0ac9SMatthew G. Knepley /*@C 1623475e0ac9SMatthew 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. 1624475e0ac9SMatthew G. Knepley 1625475e0ac9SMatthew G. Knepley Not collective 1626475e0ac9SMatthew G. Knepley 1627475e0ac9SMatthew G. Knepley Input Parameters: 16286528b96dSMatthew G. Knepley + ds - The PetscDS 1629475e0ac9SMatthew G. Knepley . f - The test field number 1630475e0ac9SMatthew G. Knepley - g - The field number 1631475e0ac9SMatthew G. Knepley 1632475e0ac9SMatthew G. Knepley Output Parameters: 1633475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1634475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1635475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1636475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1637475e0ac9SMatthew G. Knepley 1638475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1639475e0ac9SMatthew G. Knepley 1640475e0ac9SMatthew 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 1641475e0ac9SMatthew G. Knepley 1642475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1643475e0ac9SMatthew G. Knepley 1644475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1645475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1646475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1647475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1648475e0ac9SMatthew G. Knepley 1649475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1650475e0ac9SMatthew G. Knepley . Nf - the number of fields 1651475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1652475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1653475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1654475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1655475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1656475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1657475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1658475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1659475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1660475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1661475e0ac9SMatthew G. Knepley . t - current time 1662475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1663475e0ac9SMatthew G. Knepley . x - coordinates of the current point 166497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 166597b6e6e8SMatthew G. Knepley . constants - constant parameters 1666475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1667475e0ac9SMatthew G. Knepley 1668475e0ac9SMatthew G. Knepley Level: intermediate 1669475e0ac9SMatthew G. Knepley 1670475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1671475e0ac9SMatthew G. Knepley @*/ 16726528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1673475e0ac9SMatthew G. Knepley void (**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[], 167697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1677475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1678475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1679475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 168097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1681475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1682475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1683475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 168497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1685475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1686475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1687475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 168897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1689475e0ac9SMatthew G. Knepley { 16906528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 16916528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 16926528b96dSMatthew G. Knepley PetscErrorCode ierr; 16936528b96dSMatthew G. Knepley 1694475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16956528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 16966528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 16976528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 169806ad1575SMatthew G. Knepley ierr = PetscWeakFormGetJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 16996528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 17006528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 17016528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 17026528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1703475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1704475e0ac9SMatthew G. Knepley } 1705475e0ac9SMatthew G. Knepley 1706475e0ac9SMatthew G. Knepley /*@C 1707475e0ac9SMatthew 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. 1708475e0ac9SMatthew G. Knepley 1709475e0ac9SMatthew G. Knepley Not collective 1710475e0ac9SMatthew G. Knepley 1711475e0ac9SMatthew G. Knepley Input Parameters: 17126528b96dSMatthew G. Knepley + ds - The PetscDS 1713475e0ac9SMatthew G. Knepley . f - The test field number 1714475e0ac9SMatthew G. Knepley . g - The field number 1715475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1716475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1717475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1718475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1719475e0ac9SMatthew G. Knepley 1720475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1721475e0ac9SMatthew G. Knepley 1722475e0ac9SMatthew 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 1723475e0ac9SMatthew G. Knepley 1724475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1725475e0ac9SMatthew G. Knepley 1726475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1727475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1728475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1729475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1730475e0ac9SMatthew G. Knepley 1731475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1732475e0ac9SMatthew G. Knepley . Nf - the number of fields 1733475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1734475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1735475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1736475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1737475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1738475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1739475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1740475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1741475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1742475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1743475e0ac9SMatthew G. Knepley . t - current time 1744475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1745475e0ac9SMatthew G. Knepley . x - coordinates of the current point 174697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 174797b6e6e8SMatthew G. Knepley . constants - constant parameters 1748475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1749475e0ac9SMatthew G. Knepley 1750475e0ac9SMatthew G. Knepley Level: intermediate 1751475e0ac9SMatthew G. Knepley 1752475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1753475e0ac9SMatthew G. Knepley @*/ 17546528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1755475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1756475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1757475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 175897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1759475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1760475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1761475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 176297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1763475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1764475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1765475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 176697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1767475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1768475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1769475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 177097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1771475e0ac9SMatthew G. Knepley { 1772475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1773475e0ac9SMatthew G. Knepley 1774475e0ac9SMatthew G. Knepley PetscFunctionBegin; 17756528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1776475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1777475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1778475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1779475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1780475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1781475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 178206ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 1783475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1784475e0ac9SMatthew G. Knepley } 1785475e0ac9SMatthew G. Knepley 1786b7e05686SMatthew G. Knepley /*@C 1787b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1788b7e05686SMatthew G. Knepley 1789b7e05686SMatthew G. Knepley Not collective 1790b7e05686SMatthew G. Knepley 1791b7e05686SMatthew G. Knepley Input Parameter: 17926528b96dSMatthew G. Knepley . ds - The PetscDS 1793b7e05686SMatthew G. Knepley 1794b7e05686SMatthew G. Knepley Output Parameter: 1795b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1796b7e05686SMatthew G. Knepley 1797b7e05686SMatthew G. Knepley Level: intermediate 1798b7e05686SMatthew G. Knepley 1799b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1800b7e05686SMatthew G. Knepley @*/ 18016528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS ds, PetscBool *hasDynJac) 1802b7e05686SMatthew G. Knepley { 18036528b96dSMatthew G. Knepley PetscErrorCode ierr; 1804b7e05686SMatthew G. Knepley 1805b7e05686SMatthew G. Knepley PetscFunctionBegin; 18066528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18076528b96dSMatthew G. Knepley ierr = PetscWeakFormHasDynamicJacobian(ds->wf, hasDynJac);CHKERRQ(ierr); 1808b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1809b7e05686SMatthew G. Knepley } 1810b7e05686SMatthew G. Knepley 1811b7e05686SMatthew G. Knepley /*@C 1812b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1813b7e05686SMatthew G. Knepley 1814b7e05686SMatthew G. Knepley Not collective 1815b7e05686SMatthew G. Knepley 1816b7e05686SMatthew G. Knepley Input Parameters: 18176528b96dSMatthew G. Knepley + ds - The PetscDS 1818b7e05686SMatthew G. Knepley . f - The test field number 1819b7e05686SMatthew G. Knepley - g - The field number 1820b7e05686SMatthew G. Knepley 1821b7e05686SMatthew G. Knepley Output Parameters: 1822b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1823b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1824b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1825b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1826b7e05686SMatthew G. Knepley 1827b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1828b7e05686SMatthew G. Knepley 1829b7e05686SMatthew 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 1830b7e05686SMatthew G. Knepley 1831b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1832b7e05686SMatthew G. Knepley 1833b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1834b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1835b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1836b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1837b7e05686SMatthew G. Knepley 1838b7e05686SMatthew G. Knepley + dim - the spatial dimension 1839b7e05686SMatthew G. Knepley . Nf - the number of fields 1840b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1841b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1842b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1843b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1844b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1845b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1846b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1847b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1848b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1849b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1850b7e05686SMatthew G. Knepley . t - current time 1851b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1852b7e05686SMatthew G. Knepley . x - coordinates of the current point 185397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 185497b6e6e8SMatthew G. Knepley . constants - constant parameters 1855b7e05686SMatthew G. Knepley - g0 - output values at the current point 1856b7e05686SMatthew G. Knepley 1857b7e05686SMatthew G. Knepley Level: intermediate 1858b7e05686SMatthew G. Knepley 1859b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1860b7e05686SMatthew G. Knepley @*/ 18616528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1862b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1863b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1864b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 186597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1866b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1867b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1868b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 186997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1870b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1871b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1872b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1874b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1875b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1876b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1878b7e05686SMatthew G. Knepley { 18796528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 18806528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 18816528b96dSMatthew G. Knepley PetscErrorCode ierr; 18826528b96dSMatthew G. Knepley 1883b7e05686SMatthew G. Knepley PetscFunctionBegin; 18846528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18856528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 18866528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 188706ad1575SMatthew G. Knepley ierr = PetscWeakFormGetDynamicJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 18886528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 18896528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 18906528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 18916528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1892b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1893b7e05686SMatthew G. Knepley } 1894b7e05686SMatthew G. Knepley 1895b7e05686SMatthew G. Knepley /*@C 1896b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1897b7e05686SMatthew G. Knepley 1898b7e05686SMatthew G. Knepley Not collective 1899b7e05686SMatthew G. Knepley 1900b7e05686SMatthew G. Knepley Input Parameters: 19016528b96dSMatthew G. Knepley + ds - The PetscDS 1902b7e05686SMatthew G. Knepley . f - The test field number 1903b7e05686SMatthew G. Knepley . g - The field number 1904b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1905b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1906b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1907b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1908b7e05686SMatthew G. Knepley 1909b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1910b7e05686SMatthew G. Knepley 1911b7e05686SMatthew 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 1912b7e05686SMatthew G. Knepley 1913b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1914b7e05686SMatthew G. Knepley 1915b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1916b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1917b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1918b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1919b7e05686SMatthew G. Knepley 1920b7e05686SMatthew G. Knepley + dim - the spatial dimension 1921b7e05686SMatthew G. Knepley . Nf - the number of fields 1922b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1923b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1924b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1925b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1926b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1927b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1928b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1929b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1930b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1931b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1932b7e05686SMatthew G. Knepley . t - current time 1933b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1934b7e05686SMatthew G. Knepley . x - coordinates of the current point 193597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 193697b6e6e8SMatthew G. Knepley . constants - constant parameters 1937b7e05686SMatthew G. Knepley - g0 - output values at the current point 1938b7e05686SMatthew G. Knepley 1939b7e05686SMatthew G. Knepley Level: intermediate 1940b7e05686SMatthew G. Knepley 1941b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1942b7e05686SMatthew G. Knepley @*/ 19436528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1944b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1945b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1946b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1948b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1949b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1950b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 195197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1952b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1953b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1954b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 195597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1956b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1957b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1958b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 195997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1960b7e05686SMatthew G. Knepley { 1961b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1962b7e05686SMatthew G. Knepley 1963b7e05686SMatthew G. Knepley PetscFunctionBegin; 19646528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1965b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1966b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1967b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1968b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1969b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1970b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 197106ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexDynamicJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 1972b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1973b7e05686SMatthew G. Knepley } 1974b7e05686SMatthew G. Knepley 19750c2f2876SMatthew G. Knepley /*@C 19760c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 19770c2f2876SMatthew G. Knepley 19780c2f2876SMatthew G. Knepley Not collective 19790c2f2876SMatthew G. Knepley 19804165533cSJose E. Roman Input Parameters: 19816528b96dSMatthew G. Knepley + ds - The PetscDS object 19820c2f2876SMatthew G. Knepley - f - The field number 19830c2f2876SMatthew G. Knepley 19844165533cSJose E. Roman Output Parameter: 19850c2f2876SMatthew G. Knepley . r - Riemann solver 19860c2f2876SMatthew G. Knepley 19870c2f2876SMatthew G. Knepley Calling sequence for r: 19880c2f2876SMatthew G. Knepley 19895db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 19900c2f2876SMatthew G. Knepley 19915db36cf9SMatthew G. Knepley + dim - The spatial dimension 19925db36cf9SMatthew G. Knepley . Nf - The number of fields 19935db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 19940c2f2876SMatthew G. Knepley . n - The normal vector to the interface 19950c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 19960c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 19970c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 199897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 199997b6e6e8SMatthew G. Knepley . constants - constant parameters 20000c2f2876SMatthew G. Knepley - ctx - optional user context 20010c2f2876SMatthew G. Knepley 20020c2f2876SMatthew G. Knepley Level: intermediate 20030c2f2876SMatthew G. Knepley 20040c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 20050c2f2876SMatthew G. Knepley @*/ 20066528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS ds, PetscInt f, 200797b6e6e8SMatthew 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)) 20080c2f2876SMatthew G. Knepley { 20096528b96dSMatthew G. Knepley PetscRiemannFunc *tmp; 20106528b96dSMatthew G. Knepley PetscInt n; 20116528b96dSMatthew G. Knepley PetscErrorCode ierr; 20126528b96dSMatthew G. Knepley 20130c2f2876SMatthew G. Knepley PetscFunctionBegin; 20146528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20150c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 20166528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 201706ad1575SMatthew G. Knepley ierr = PetscWeakFormGetRiemannSolver(ds->wf, NULL, 0, f, 0, &n, &tmp);CHKERRQ(ierr); 20186528b96dSMatthew G. Knepley *r = tmp ? tmp[0] : NULL; 20190c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20200c2f2876SMatthew G. Knepley } 20210c2f2876SMatthew G. Knepley 20220c2f2876SMatthew G. Knepley /*@C 20230c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 20240c2f2876SMatthew G. Knepley 20250c2f2876SMatthew G. Knepley Not collective 20260c2f2876SMatthew G. Knepley 20274165533cSJose E. Roman Input Parameters: 20286528b96dSMatthew G. Knepley + ds - The PetscDS object 20290c2f2876SMatthew G. Knepley . f - The field number 20300c2f2876SMatthew G. Knepley - r - Riemann solver 20310c2f2876SMatthew G. Knepley 20320c2f2876SMatthew G. Knepley Calling sequence for r: 20330c2f2876SMatthew G. Knepley 20345db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 20350c2f2876SMatthew G. Knepley 20365db36cf9SMatthew G. Knepley + dim - The spatial dimension 20375db36cf9SMatthew G. Knepley . Nf - The number of fields 20385db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 20390c2f2876SMatthew G. Knepley . n - The normal vector to the interface 20400c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 20410c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 20420c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 204397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 204497b6e6e8SMatthew G. Knepley . constants - constant parameters 20450c2f2876SMatthew G. Knepley - ctx - optional user context 20460c2f2876SMatthew G. Knepley 20470c2f2876SMatthew G. Knepley Level: intermediate 20480c2f2876SMatthew G. Knepley 20490c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 20500c2f2876SMatthew G. Knepley @*/ 20516528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS ds, PetscInt f, 205297b6e6e8SMatthew 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)) 20530c2f2876SMatthew G. Knepley { 20540c2f2876SMatthew G. Knepley PetscErrorCode ierr; 20550c2f2876SMatthew G. Knepley 20560c2f2876SMatthew G. Knepley PetscFunctionBegin; 20576528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2058de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 20590c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 206006ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexRiemannSolver(ds->wf, NULL, 0, f, 0, 0, r);CHKERRQ(ierr); 20610c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20620c2f2876SMatthew G. Knepley } 20630c2f2876SMatthew G. Knepley 206432d2bbc9SMatthew G. Knepley /*@C 206532d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 206632d2bbc9SMatthew G. Knepley 206732d2bbc9SMatthew G. Knepley Not collective 206832d2bbc9SMatthew G. Knepley 206932d2bbc9SMatthew G. Knepley Input Parameters: 20706528b96dSMatthew G. Knepley + ds - The PetscDS 207132d2bbc9SMatthew G. Knepley - f - The field number 207232d2bbc9SMatthew G. Knepley 2073f899ff85SJose E. Roman Output Parameter: 2074a2b725a8SWilliam Gropp . update - update function 207532d2bbc9SMatthew G. Knepley 207632d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 207732d2bbc9SMatthew G. Knepley 207832d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 207932d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 208032d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 208132d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 208232d2bbc9SMatthew G. Knepley 208332d2bbc9SMatthew G. Knepley + dim - the spatial dimension 208432d2bbc9SMatthew G. Knepley . Nf - the number of fields 208532d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 208632d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 208732d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 208832d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 208932d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 209032d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 209132d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 209232d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 209332d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 209432d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 209532d2bbc9SMatthew G. Knepley . t - current time 209632d2bbc9SMatthew G. Knepley . x - coordinates of the current point 209732d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 209832d2bbc9SMatthew G. Knepley 209932d2bbc9SMatthew G. Knepley Level: intermediate 210032d2bbc9SMatthew G. Knepley 210132d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 210232d2bbc9SMatthew G. Knepley @*/ 21036528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS ds, PetscInt f, 210432d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 210532d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 210632d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21073fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 210832d2bbc9SMatthew G. Knepley { 210932d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21106528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21116528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 21126528b96dSMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = ds->update[f];} 211332d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 211432d2bbc9SMatthew G. Knepley } 211532d2bbc9SMatthew G. Knepley 211632d2bbc9SMatthew G. Knepley /*@C 21173fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 211832d2bbc9SMatthew G. Knepley 211932d2bbc9SMatthew G. Knepley Not collective 212032d2bbc9SMatthew G. Knepley 212132d2bbc9SMatthew G. Knepley Input Parameters: 21226528b96dSMatthew G. Knepley + ds - The PetscDS 212332d2bbc9SMatthew G. Knepley . f - The field number 212432d2bbc9SMatthew G. Knepley - update - update function 212532d2bbc9SMatthew G. Knepley 212632d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 212732d2bbc9SMatthew G. Knepley 212832d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 212932d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 213032d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 213132d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 213232d2bbc9SMatthew G. Knepley 213332d2bbc9SMatthew G. Knepley + dim - the spatial dimension 213432d2bbc9SMatthew G. Knepley . Nf - the number of fields 213532d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 213632d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 213732d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 213832d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 213932d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 214032d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 214132d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 214232d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 214332d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 214432d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 214532d2bbc9SMatthew G. Knepley . t - current time 214632d2bbc9SMatthew G. Knepley . x - coordinates of the current point 214732d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 214832d2bbc9SMatthew G. Knepley 214932d2bbc9SMatthew G. Knepley Level: intermediate 215032d2bbc9SMatthew G. Knepley 215132d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 215232d2bbc9SMatthew G. Knepley @*/ 21536528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS ds, PetscInt f, 215432d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 215532d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 215632d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21573fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 215832d2bbc9SMatthew G. Knepley { 215932d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 216032d2bbc9SMatthew G. Knepley 216132d2bbc9SMatthew G. Knepley PetscFunctionBegin; 21626528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 216332d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 216432d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21656528b96dSMatthew G. Knepley ierr = PetscDSEnlarge_Static(ds, f+1);CHKERRQ(ierr); 21666528b96dSMatthew G. Knepley ds->update[f] = update; 216732d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 216832d2bbc9SMatthew G. Knepley } 216932d2bbc9SMatthew G. Knepley 21703ec1f749SStefano Zampini PetscErrorCode PetscDSGetContext(PetscDS ds, PetscInt f, void *ctx) 21710c2f2876SMatthew G. Knepley { 21720c2f2876SMatthew G. Knepley PetscFunctionBegin; 21736528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21746528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 21750c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 21763ec1f749SStefano Zampini *(void**)ctx = ds->ctx[f]; 21770c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 21780c2f2876SMatthew G. Knepley } 21790c2f2876SMatthew G. Knepley 21806528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS ds, PetscInt f, void *ctx) 21810c2f2876SMatthew G. Knepley { 21820c2f2876SMatthew G. Knepley PetscErrorCode ierr; 21830c2f2876SMatthew G. Knepley 21840c2f2876SMatthew G. Knepley PetscFunctionBegin; 21856528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21860c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21876528b96dSMatthew G. Knepley ierr = PetscDSEnlarge_Static(ds, f+1);CHKERRQ(ierr); 21886528b96dSMatthew G. Knepley ds->ctx[f] = ctx; 21890c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 21900c2f2876SMatthew G. Knepley } 21910c2f2876SMatthew G. Knepley 2192194d53e6SMatthew G. Knepley /*@C 2193194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 2194194d53e6SMatthew G. Knepley 2195194d53e6SMatthew G. Knepley Not collective 2196194d53e6SMatthew G. Knepley 2197194d53e6SMatthew G. Knepley Input Parameters: 21986528b96dSMatthew G. Knepley + ds - The PetscDS 2199194d53e6SMatthew G. Knepley - f - The test field number 2200194d53e6SMatthew G. Knepley 2201194d53e6SMatthew G. Knepley Output Parameters: 2202194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 2203194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2204194d53e6SMatthew G. Knepley 2205194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2206194d53e6SMatthew G. Knepley 2207194d53e6SMatthew 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 2208194d53e6SMatthew G. Knepley 2209194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2210194d53e6SMatthew G. Knepley 221130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2212194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2213194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 221430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2215194d53e6SMatthew G. Knepley 2216194d53e6SMatthew G. Knepley + dim - the spatial dimension 2217194d53e6SMatthew G. Knepley . Nf - the number of fields 2218194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2219194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2220194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2221194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2222194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2223194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2224194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2225194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2226194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2227194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2228194d53e6SMatthew G. Knepley . t - current time 2229194d53e6SMatthew G. Knepley . x - coordinates of the current point 2230194d53e6SMatthew G. Knepley . n - unit normal at the current point 223197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 223297b6e6e8SMatthew G. Knepley . constants - constant parameters 2233194d53e6SMatthew G. Knepley - f0 - output values at the current point 2234194d53e6SMatthew G. Knepley 2235194d53e6SMatthew G. Knepley Level: intermediate 2236194d53e6SMatthew G. Knepley 2237194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 2238194d53e6SMatthew G. Knepley @*/ 22396528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS ds, PetscInt f, 224030b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2241194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2242194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 224430b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2245194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2246194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 22482764a2aaSMatthew G. Knepley { 22496528b96dSMatthew G. Knepley PetscBdPointFunc *tmp0, *tmp1; 22506528b96dSMatthew G. Knepley PetscInt n0, n1; 22516528b96dSMatthew G. Knepley PetscErrorCode ierr; 22526528b96dSMatthew G. Knepley 22532764a2aaSMatthew G. Knepley PetscFunctionBegin; 22546528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 22556528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 225606ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1);CHKERRQ(ierr); 22576528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 22586528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 22592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22602764a2aaSMatthew G. Knepley } 22612764a2aaSMatthew G. Knepley 2262194d53e6SMatthew G. Knepley /*@C 2263194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2264194d53e6SMatthew G. Knepley 2265194d53e6SMatthew G. Knepley Not collective 2266194d53e6SMatthew G. Knepley 2267194d53e6SMatthew G. Knepley Input Parameters: 22686528b96dSMatthew G. Knepley + ds - The PetscDS 2269194d53e6SMatthew G. Knepley . f - The test field number 2270194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2271194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2272194d53e6SMatthew G. Knepley 2273194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2274194d53e6SMatthew G. Knepley 2275194d53e6SMatthew 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 2276194d53e6SMatthew G. Knepley 2277194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2278194d53e6SMatthew G. Knepley 227930b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2280194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2281194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 228230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2283194d53e6SMatthew G. Knepley 2284194d53e6SMatthew G. Knepley + dim - the spatial dimension 2285194d53e6SMatthew G. Knepley . Nf - the number of fields 2286194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2287194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2288194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2289194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2290194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2291194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2292194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2293194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2294194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2295194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2296194d53e6SMatthew G. Knepley . t - current time 2297194d53e6SMatthew G. Knepley . x - coordinates of the current point 2298194d53e6SMatthew G. Knepley . n - unit normal at the current point 229997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 230097b6e6e8SMatthew G. Knepley . constants - constant parameters 2301194d53e6SMatthew G. Knepley - f0 - output values at the current point 2302194d53e6SMatthew G. Knepley 2303194d53e6SMatthew G. Knepley Level: intermediate 2304194d53e6SMatthew G. Knepley 2305194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2306194d53e6SMatthew G. Knepley @*/ 23076528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS ds, PetscInt f, 230830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2309194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2310194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 231197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 231230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2313194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2314194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 231597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 23162764a2aaSMatthew G. Knepley { 23172764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23182764a2aaSMatthew G. Knepley 23192764a2aaSMatthew G. Knepley PetscFunctionBegin; 23206528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23212764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 232206ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1);CHKERRQ(ierr); 23232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23242764a2aaSMatthew G. Knepley } 23252764a2aaSMatthew G. Knepley 232627f02ce8SMatthew G. Knepley /*@ 232727f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 232827f02ce8SMatthew G. Knepley 232927f02ce8SMatthew G. Knepley Not collective 233027f02ce8SMatthew G. Knepley 233127f02ce8SMatthew G. Knepley Input Parameter: 23326528b96dSMatthew G. Knepley . ds - The PetscDS 233327f02ce8SMatthew G. Knepley 233427f02ce8SMatthew G. Knepley Output Parameter: 233527f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 233627f02ce8SMatthew G. Knepley 233727f02ce8SMatthew G. Knepley Level: intermediate 233827f02ce8SMatthew G. Knepley 233927f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 234027f02ce8SMatthew G. Knepley @*/ 23416528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS ds, PetscBool *hasBdJac) 234227f02ce8SMatthew G. Knepley { 23436528b96dSMatthew G. Knepley PetscErrorCode ierr; 234427f02ce8SMatthew G. Knepley 234527f02ce8SMatthew G. Knepley PetscFunctionBegin; 23466528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23476528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJac, 2); 23486528b96dSMatthew G. Knepley ierr = PetscWeakFormHasBdJacobian(ds->wf, hasBdJac);CHKERRQ(ierr); 234927f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 235027f02ce8SMatthew G. Knepley } 235127f02ce8SMatthew G. Knepley 2352194d53e6SMatthew G. Knepley /*@C 2353194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2354194d53e6SMatthew G. Knepley 2355194d53e6SMatthew G. Knepley Not collective 2356194d53e6SMatthew G. Knepley 2357194d53e6SMatthew G. Knepley Input Parameters: 23586528b96dSMatthew G. Knepley + ds - The PetscDS 2359194d53e6SMatthew G. Knepley . f - The test field number 2360194d53e6SMatthew G. Knepley - g - The field number 2361194d53e6SMatthew G. Knepley 2362194d53e6SMatthew G. Knepley Output Parameters: 2363194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2364194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2365194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2366194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2367194d53e6SMatthew G. Knepley 2368194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2369194d53e6SMatthew G. Knepley 2370194d53e6SMatthew 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 2371194d53e6SMatthew G. Knepley 2372194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2373194d53e6SMatthew G. Knepley 237430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2375194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2376194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 237730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2378194d53e6SMatthew G. Knepley 2379194d53e6SMatthew G. Knepley + dim - the spatial dimension 2380194d53e6SMatthew G. Knepley . Nf - the number of fields 2381194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2382194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2383194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2384194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2385194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2386194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2387194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2388194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2389194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2390194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2391194d53e6SMatthew G. Knepley . t - current time 23922aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2393194d53e6SMatthew G. Knepley . x - coordinates of the current point 2394194d53e6SMatthew G. Knepley . n - normal at the current point 239597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 239697b6e6e8SMatthew G. Knepley . constants - constant parameters 2397194d53e6SMatthew G. Knepley - g0 - output values at the current point 2398194d53e6SMatthew G. Knepley 2399194d53e6SMatthew G. Knepley Level: intermediate 2400194d53e6SMatthew G. Knepley 2401194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2402194d53e6SMatthew G. Knepley @*/ 24036528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 240430b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2405194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2406194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 240797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 240830b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2409194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2410194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 241230b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2413194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2414194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 241630b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2417194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2418194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 24202764a2aaSMatthew G. Knepley { 24216528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 24226528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 24236528b96dSMatthew G. Knepley PetscErrorCode ierr; 24246528b96dSMatthew G. Knepley 24252764a2aaSMatthew G. Knepley PetscFunctionBegin; 24266528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 24276528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 24286528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 242906ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 24306528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 24316528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 24326528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 24336528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 24342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24352764a2aaSMatthew G. Knepley } 24362764a2aaSMatthew G. Knepley 2437194d53e6SMatthew G. Knepley /*@C 2438194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2439194d53e6SMatthew G. Knepley 2440194d53e6SMatthew G. Knepley Not collective 2441194d53e6SMatthew G. Knepley 2442194d53e6SMatthew G. Knepley Input Parameters: 24436528b96dSMatthew G. Knepley + ds - The PetscDS 2444194d53e6SMatthew G. Knepley . f - The test field number 2445194d53e6SMatthew G. Knepley . g - The field number 2446194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2447194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2448194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2449194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2450194d53e6SMatthew G. Knepley 2451194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2452194d53e6SMatthew G. Knepley 2453194d53e6SMatthew 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 2454194d53e6SMatthew G. Knepley 2455194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2456194d53e6SMatthew G. Knepley 245730b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2458194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2459194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 246030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2461194d53e6SMatthew G. Knepley 2462194d53e6SMatthew G. Knepley + dim - the spatial dimension 2463194d53e6SMatthew G. Knepley . Nf - the number of fields 2464194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2465194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2466194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2467194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2468194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2469194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2470194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2471194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2472194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2473194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2474194d53e6SMatthew G. Knepley . t - current time 24752aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2476194d53e6SMatthew G. Knepley . x - coordinates of the current point 2477194d53e6SMatthew G. Knepley . n - normal at the current point 247897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 247997b6e6e8SMatthew G. Knepley . constants - constant parameters 2480194d53e6SMatthew G. Knepley - g0 - output values at the current point 2481194d53e6SMatthew G. Knepley 2482194d53e6SMatthew G. Knepley Level: intermediate 2483194d53e6SMatthew G. Knepley 2484194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2485194d53e6SMatthew G. Knepley @*/ 24866528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 248730b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2488194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2489194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 249130b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2492194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2493194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 249530b9ff8bSMatthew G. Knepley void (*g2)(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 g2[]), 249930b9ff8bSMatthew G. Knepley void (*g3)(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 g3[])) 25032764a2aaSMatthew G. Knepley { 25042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25052764a2aaSMatthew G. Knepley 25062764a2aaSMatthew G. Knepley PetscFunctionBegin; 25076528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25082764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 25092764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 25102764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 25112764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 25122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 25132764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 251406ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 25152764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25162764a2aaSMatthew G. Knepley } 25172764a2aaSMatthew G. Knepley 251827f02ce8SMatthew G. Knepley /*@ 251927f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 252027f02ce8SMatthew G. Knepley 252127f02ce8SMatthew G. Knepley Not collective 252227f02ce8SMatthew G. Knepley 252327f02ce8SMatthew G. Knepley Input Parameter: 25246528b96dSMatthew G. Knepley . ds - The PetscDS 252527f02ce8SMatthew G. Knepley 252627f02ce8SMatthew G. Knepley Output Parameter: 252727f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 252827f02ce8SMatthew G. Knepley 252927f02ce8SMatthew G. Knepley Level: intermediate 253027f02ce8SMatthew G. Knepley 253127f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 253227f02ce8SMatthew G. Knepley @*/ 25336528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS ds, PetscBool *hasBdJacPre) 253427f02ce8SMatthew G. Knepley { 25356528b96dSMatthew G. Knepley PetscErrorCode ierr; 253627f02ce8SMatthew G. Knepley 253727f02ce8SMatthew G. Knepley PetscFunctionBegin; 25386528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 25396528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJacPre, 2); 25406528b96dSMatthew G. Knepley ierr = PetscWeakFormHasBdJacobianPreconditioner(ds->wf, hasBdJacPre);CHKERRQ(ierr); 254127f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 254227f02ce8SMatthew G. Knepley } 254327f02ce8SMatthew G. Knepley 254427f02ce8SMatthew G. Knepley /*@C 254527f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 254627f02ce8SMatthew G. Knepley 254727f02ce8SMatthew G. Knepley Not collective 254827f02ce8SMatthew G. Knepley 254927f02ce8SMatthew G. Knepley Input Parameters: 25506528b96dSMatthew G. Knepley + ds - The PetscDS 255127f02ce8SMatthew G. Knepley . f - The test field number 255227f02ce8SMatthew G. Knepley - g - The field number 255327f02ce8SMatthew G. Knepley 255427f02ce8SMatthew G. Knepley Output Parameters: 255527f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 255627f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 255727f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 255827f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 255927f02ce8SMatthew G. Knepley 256027f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 256127f02ce8SMatthew G. Knepley 256227f02ce8SMatthew 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 256327f02ce8SMatthew G. Knepley 256427f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 256527f02ce8SMatthew G. Knepley 256627f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 256727f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 256827f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 256927f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 257027f02ce8SMatthew G. Knepley 257127f02ce8SMatthew G. Knepley + dim - the spatial dimension 257227f02ce8SMatthew G. Knepley . Nf - the number of fields 257327f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 257427f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 257527f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 257627f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 257727f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 257827f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 257927f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 258027f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 258127f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 258227f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 258327f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 258427f02ce8SMatthew G. Knepley . t - current time 258527f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 258627f02ce8SMatthew G. Knepley . x - coordinates of the current point 258727f02ce8SMatthew G. Knepley . n - normal at the current point 258827f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 258927f02ce8SMatthew G. Knepley . constants - constant parameters 259027f02ce8SMatthew G. Knepley - g0 - output values at the current point 259127f02ce8SMatthew G. Knepley 259227f02ce8SMatthew G. Knepley This is not yet available in Fortran. 259327f02ce8SMatthew G. Knepley 259427f02ce8SMatthew G. Knepley Level: intermediate 259527f02ce8SMatthew G. Knepley 259627f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 259727f02ce8SMatthew G. Knepley @*/ 25986528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 259927f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 260027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 260127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 260227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 260327f02ce8SMatthew G. Knepley void (**g1)(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 g1[]), 260727f02ce8SMatthew G. Knepley void (**g2)(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 g2[]), 261127f02ce8SMatthew G. Knepley void (**g3)(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 g3[])) 261527f02ce8SMatthew G. Knepley { 26166528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 26176528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 26186528b96dSMatthew G. Knepley PetscErrorCode ierr; 26196528b96dSMatthew G. Knepley 262027f02ce8SMatthew G. Knepley PetscFunctionBegin; 26216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 26226528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 26236528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 262406ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 26256528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 26266528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 26276528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 26286528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 262927f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 263027f02ce8SMatthew G. Knepley } 263127f02ce8SMatthew G. Knepley 263227f02ce8SMatthew G. Knepley /*@C 263327f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 263427f02ce8SMatthew G. Knepley 263527f02ce8SMatthew G. Knepley Not collective 263627f02ce8SMatthew G. Knepley 263727f02ce8SMatthew G. Knepley Input Parameters: 26386528b96dSMatthew G. Knepley + ds - The PetscDS 263927f02ce8SMatthew G. Knepley . f - The test field number 264027f02ce8SMatthew G. Knepley . g - The field number 264127f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 264227f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 264327f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 264427f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 264527f02ce8SMatthew G. Knepley 264627f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 264727f02ce8SMatthew G. Knepley 264827f02ce8SMatthew G. Knepley \int_\Gamma \phi {\vec g}_0(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \cdot \hat n \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \hat n \cdot \nabla \psi 264927f02ce8SMatthew G. Knepley 265027f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 265127f02ce8SMatthew G. Knepley 265227f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 265327f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 265427f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 265527f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 265627f02ce8SMatthew G. Knepley 265727f02ce8SMatthew G. Knepley + dim - the spatial dimension 265827f02ce8SMatthew G. Knepley . Nf - the number of fields 265927f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 266027f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 266127f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 266227f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 266327f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 266427f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 266527f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 266627f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 266727f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 266827f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 266927f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 267027f02ce8SMatthew G. Knepley . t - current time 267127f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 267227f02ce8SMatthew G. Knepley . x - coordinates of the current point 267327f02ce8SMatthew G. Knepley . n - normal at the current point 267427f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 267527f02ce8SMatthew G. Knepley . constants - constant parameters 267627f02ce8SMatthew G. Knepley - g0 - output values at the current point 267727f02ce8SMatthew G. Knepley 267827f02ce8SMatthew G. Knepley This is not yet available in Fortran. 267927f02ce8SMatthew G. Knepley 268027f02ce8SMatthew G. Knepley Level: intermediate 268127f02ce8SMatthew G. Knepley 268227f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 268327f02ce8SMatthew G. Knepley @*/ 26846528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 268527f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 268627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 268727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 268827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 268927f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 269327f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 269627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 269727f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 269827f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 269927f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 270027f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 270127f02ce8SMatthew G. Knepley { 270227f02ce8SMatthew G. Knepley PetscErrorCode ierr; 270327f02ce8SMatthew G. Knepley 270427f02ce8SMatthew G. Knepley PetscFunctionBegin; 27056528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 270627f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 270727f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 270827f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 270927f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 271027f02ce8SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 271127f02ce8SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 271206ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 271327f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 271427f02ce8SMatthew G. Knepley } 271527f02ce8SMatthew G. Knepley 27160d3e9b51SMatthew G. Knepley /*@C 2717c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2718c371a6d1SMatthew G. Knepley 2719c371a6d1SMatthew G. Knepley Not collective 2720c371a6d1SMatthew G. Knepley 2721c371a6d1SMatthew G. Knepley Input Parameters: 2722c371a6d1SMatthew G. Knepley + prob - The PetscDS 2723c371a6d1SMatthew G. Knepley - f - The test field number 2724c371a6d1SMatthew G. Knepley 2725d8d19677SJose E. Roman Output Parameters: 272695cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 272795cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2728c371a6d1SMatthew G. Knepley 2729c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2730c371a6d1SMatthew G. Knepley 2731c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2732c371a6d1SMatthew G. Knepley 2733c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2734c371a6d1SMatthew G. Knepley . t - current time 2735c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2736c371a6d1SMatthew G. Knepley . Nc - the number of field components 2737c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2738c371a6d1SMatthew G. Knepley - ctx - a user context 2739c371a6d1SMatthew G. Knepley 2740c371a6d1SMatthew G. Knepley Level: intermediate 2741c371a6d1SMatthew G. Knepley 2742f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolution(), PetscDSGetExactSolutionTimeDerivative() 2743c371a6d1SMatthew G. Knepley @*/ 274495cbbfd3SMatthew 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) 2745c371a6d1SMatthew G. Knepley { 2746c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2747c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2748c371a6d1SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 2749c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 275095cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2751c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2752c371a6d1SMatthew G. Knepley } 2753c371a6d1SMatthew G. Knepley 2754c371a6d1SMatthew G. Knepley /*@C 2755578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2756c371a6d1SMatthew G. Knepley 2757c371a6d1SMatthew G. Knepley Not collective 2758c371a6d1SMatthew G. Knepley 2759c371a6d1SMatthew G. Knepley Input Parameters: 2760c371a6d1SMatthew G. Knepley + prob - The PetscDS 2761c371a6d1SMatthew G. Knepley . f - The test field number 276295cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 276395cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2764c371a6d1SMatthew G. Knepley 2765c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2766c371a6d1SMatthew G. Knepley 2767c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2768c371a6d1SMatthew G. Knepley 2769c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2770c371a6d1SMatthew G. Knepley . t - current time 2771c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2772c371a6d1SMatthew G. Knepley . Nc - the number of field components 2773c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2774c371a6d1SMatthew G. Knepley - ctx - a user context 2775c371a6d1SMatthew G. Knepley 2776c371a6d1SMatthew G. Knepley Level: intermediate 2777c371a6d1SMatthew G. Knepley 2778c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2779c371a6d1SMatthew G. Knepley @*/ 278095cbbfd3SMatthew 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) 2781c371a6d1SMatthew G. Knepley { 2782c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2783c371a6d1SMatthew G. Knepley 2784c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2785c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2786c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2787c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2788c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 278995cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2790c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2791c371a6d1SMatthew G. Knepley } 2792c371a6d1SMatthew G. Knepley 27935638fd0eSMatthew G. Knepley /*@C 2794f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2795f2cacb80SMatthew G. Knepley 2796f2cacb80SMatthew G. Knepley Not collective 2797f2cacb80SMatthew G. Knepley 2798f2cacb80SMatthew G. Knepley Input Parameters: 2799f2cacb80SMatthew G. Knepley + prob - The PetscDS 2800f2cacb80SMatthew G. Knepley - f - The test field number 2801f2cacb80SMatthew G. Knepley 2802d8d19677SJose E. Roman Output Parameters: 2803f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2804f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2805f2cacb80SMatthew G. Knepley 2806f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2807f2cacb80SMatthew G. Knepley 2808f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2809f2cacb80SMatthew G. Knepley 2810f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2811f2cacb80SMatthew G. Knepley . t - current time 2812f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2813f2cacb80SMatthew G. Knepley . Nc - the number of field components 2814f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2815f2cacb80SMatthew G. Knepley - ctx - a user context 2816f2cacb80SMatthew G. Knepley 2817f2cacb80SMatthew G. Knepley Level: intermediate 2818f2cacb80SMatthew G. Knepley 2819f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolutionTimeDerivative(), PetscDSGetExactSolution() 2820f2cacb80SMatthew G. Knepley @*/ 2821f2cacb80SMatthew 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) 2822f2cacb80SMatthew G. Knepley { 2823f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2824f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2825f2cacb80SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 2826f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2827f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2828f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2829f2cacb80SMatthew G. Knepley } 2830f2cacb80SMatthew G. Knepley 2831f2cacb80SMatthew G. Knepley /*@C 2832f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2833f2cacb80SMatthew G. Knepley 2834f2cacb80SMatthew G. Knepley Not collective 2835f2cacb80SMatthew G. Knepley 2836f2cacb80SMatthew G. Knepley Input Parameters: 2837f2cacb80SMatthew G. Knepley + prob - The PetscDS 2838f2cacb80SMatthew G. Knepley . f - The test field number 2839f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2840f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2841f2cacb80SMatthew G. Knepley 2842f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2843f2cacb80SMatthew G. Knepley 2844f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2845f2cacb80SMatthew G. Knepley 2846f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2847f2cacb80SMatthew G. Knepley . t - current time 2848f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2849f2cacb80SMatthew G. Knepley . Nc - the number of field components 2850f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2851f2cacb80SMatthew G. Knepley - ctx - a user context 2852f2cacb80SMatthew G. Knepley 2853f2cacb80SMatthew G. Knepley Level: intermediate 2854f2cacb80SMatthew G. Knepley 2855f2cacb80SMatthew G. Knepley .seealso: PetscDSGetExactSolutionTimeDerivative(), PetscDSSetExactSolution() 2856f2cacb80SMatthew G. Knepley @*/ 2857f2cacb80SMatthew 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) 2858f2cacb80SMatthew G. Knepley { 2859f2cacb80SMatthew G. Knepley PetscErrorCode ierr; 2860f2cacb80SMatthew G. Knepley 2861f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2862f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2863f2cacb80SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2864f2cacb80SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2865f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2866f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2867f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2868f2cacb80SMatthew G. Knepley } 2869f2cacb80SMatthew G. Knepley 2870f2cacb80SMatthew G. Knepley /*@C 287197b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 287297b6e6e8SMatthew G. Knepley 287397b6e6e8SMatthew G. Knepley Not collective 287497b6e6e8SMatthew G. Knepley 287597b6e6e8SMatthew G. Knepley Input Parameter: 287697b6e6e8SMatthew G. Knepley . prob - The PetscDS object 287797b6e6e8SMatthew G. Knepley 287897b6e6e8SMatthew G. Knepley Output Parameters: 287997b6e6e8SMatthew G. Knepley + numConstants - The number of constants 288097b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 288197b6e6e8SMatthew G. Knepley 288297b6e6e8SMatthew G. Knepley Level: intermediate 288397b6e6e8SMatthew G. Knepley 288497b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 288597b6e6e8SMatthew G. Knepley @*/ 288697b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 288797b6e6e8SMatthew G. Knepley { 288897b6e6e8SMatthew G. Knepley PetscFunctionBegin; 288997b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 289097b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 289197b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 289297b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 289397b6e6e8SMatthew G. Knepley } 289497b6e6e8SMatthew G. Knepley 28950d3e9b51SMatthew G. Knepley /*@C 289697b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 289797b6e6e8SMatthew G. Knepley 289897b6e6e8SMatthew G. Knepley Not collective 289997b6e6e8SMatthew G. Knepley 290097b6e6e8SMatthew G. Knepley Input Parameters: 290197b6e6e8SMatthew G. Knepley + prob - The PetscDS object 290297b6e6e8SMatthew G. Knepley . numConstants - The number of constants 290397b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 290497b6e6e8SMatthew G. Knepley 290597b6e6e8SMatthew G. Knepley Level: intermediate 290697b6e6e8SMatthew G. Knepley 290797b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 290897b6e6e8SMatthew G. Knepley @*/ 290997b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 291097b6e6e8SMatthew G. Knepley { 291197b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 291297b6e6e8SMatthew G. Knepley 291397b6e6e8SMatthew G. Knepley PetscFunctionBegin; 291497b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 291597b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 291697b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 291797b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 291897b6e6e8SMatthew G. Knepley if (prob->numConstants) { 291997b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 292020be0f5bSMatthew G. Knepley } else { 292120be0f5bSMatthew G. Knepley prob->constants = NULL; 292220be0f5bSMatthew G. Knepley } 292320be0f5bSMatthew G. Knepley } 292420be0f5bSMatthew G. Knepley if (prob->numConstants) { 292520be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 2926580bdb30SBarry Smith ierr = PetscArraycpy(prob->constants, constants, prob->numConstants);CHKERRQ(ierr); 292797b6e6e8SMatthew G. Knepley } 292897b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 292997b6e6e8SMatthew G. Knepley } 293097b6e6e8SMatthew G. Knepley 29314cd1e086SMatthew G. Knepley /*@ 29324cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 29334cd1e086SMatthew G. Knepley 29344cd1e086SMatthew G. Knepley Not collective 29354cd1e086SMatthew G. Knepley 29364cd1e086SMatthew G. Knepley Input Parameters: 29374cd1e086SMatthew G. Knepley + prob - The PetscDS object 29384cd1e086SMatthew G. Knepley - disc - The discretization object 29394cd1e086SMatthew G. Knepley 29404cd1e086SMatthew G. Knepley Output Parameter: 29414cd1e086SMatthew G. Knepley . f - The field number 29424cd1e086SMatthew G. Knepley 29434cd1e086SMatthew G. Knepley Level: beginner 29444cd1e086SMatthew G. Knepley 2945f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 29464cd1e086SMatthew G. Knepley @*/ 29474cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 29484cd1e086SMatthew G. Knepley { 29494cd1e086SMatthew G. Knepley PetscInt g; 29504cd1e086SMatthew G. Knepley 29514cd1e086SMatthew G. Knepley PetscFunctionBegin; 29524cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29534cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 29544cd1e086SMatthew G. Knepley *f = -1; 29554cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 29564cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 29574cd1e086SMatthew G. Knepley *f = g; 29584cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29594cd1e086SMatthew G. Knepley } 29604cd1e086SMatthew G. Knepley 29614cd1e086SMatthew G. Knepley /*@ 29624cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 29634cd1e086SMatthew G. Knepley 29644cd1e086SMatthew G. Knepley Not collective 29654cd1e086SMatthew G. Knepley 29664cd1e086SMatthew G. Knepley Input Parameters: 29674cd1e086SMatthew G. Knepley + prob - The PetscDS object 29684cd1e086SMatthew G. Knepley - f - The field number 29694cd1e086SMatthew G. Knepley 29704cd1e086SMatthew G. Knepley Output Parameter: 29714cd1e086SMatthew G. Knepley . size - The size 29724cd1e086SMatthew G. Knepley 29734cd1e086SMatthew G. Knepley Level: beginner 29744cd1e086SMatthew G. Knepley 2975f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 29764cd1e086SMatthew G. Knepley @*/ 29774cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 29784cd1e086SMatthew G. Knepley { 29792166fd64SMatthew G. Knepley PetscErrorCode ierr; 29802166fd64SMatthew G. Knepley 29814cd1e086SMatthew G. Knepley PetscFunctionBegin; 29824cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29834cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 29844cd1e086SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 29852166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2986d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 29874cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 29884cd1e086SMatthew G. Knepley } 29894cd1e086SMatthew G. Knepley 2990bc4ae4beSMatthew G. Knepley /*@ 2991bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2992bc4ae4beSMatthew G. Knepley 2993bc4ae4beSMatthew G. Knepley Not collective 2994bc4ae4beSMatthew G. Knepley 2995bc4ae4beSMatthew G. Knepley Input Parameters: 2996bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2997bc4ae4beSMatthew G. Knepley - f - The field number 2998bc4ae4beSMatthew G. Knepley 2999bc4ae4beSMatthew G. Knepley Output Parameter: 3000bc4ae4beSMatthew G. Knepley . off - The offset 3001bc4ae4beSMatthew G. Knepley 3002bc4ae4beSMatthew G. Knepley Level: beginner 3003bc4ae4beSMatthew G. Knepley 3004f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 3005bc4ae4beSMatthew G. Knepley @*/ 30062764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 30072764a2aaSMatthew G. Knepley { 30084cd1e086SMatthew G. Knepley PetscInt size, g; 30092764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30102764a2aaSMatthew G. Knepley 30112764a2aaSMatthew G. Knepley PetscFunctionBegin; 30122764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30132764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 30142764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 30152764a2aaSMatthew G. Knepley *off = 0; 30162764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 30174cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 30184cd1e086SMatthew G. Knepley *off += size; 30192764a2aaSMatthew G. Knepley } 30202764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30212764a2aaSMatthew G. Knepley } 30222764a2aaSMatthew G. Knepley 3023bc4ae4beSMatthew G. Knepley /*@ 302447e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 3025bc4ae4beSMatthew G. Knepley 3026bc4ae4beSMatthew G. Knepley Not collective 3027bc4ae4beSMatthew G. Knepley 302847e57110SSander Arens Input Parameter: 302947e57110SSander Arens . prob - The PetscDS object 3030bc4ae4beSMatthew G. Knepley 3031bc4ae4beSMatthew G. Knepley Output Parameter: 303247e57110SSander Arens . dimensions - The number of dimensions 3033bc4ae4beSMatthew G. Knepley 3034bc4ae4beSMatthew G. Knepley Level: beginner 3035bc4ae4beSMatthew G. Knepley 303647e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 3037bc4ae4beSMatthew G. Knepley @*/ 303847e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 30392764a2aaSMatthew G. Knepley { 30402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30412764a2aaSMatthew G. Knepley 30422764a2aaSMatthew G. Knepley PetscFunctionBegin; 30432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 304447e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 304547e57110SSander Arens PetscValidPointer(dimensions, 2); 304647e57110SSander Arens *dimensions = prob->Nb; 304747e57110SSander Arens PetscFunctionReturn(0); 30486ce16762SMatthew G. Knepley } 304947e57110SSander Arens 305047e57110SSander Arens /*@ 305147e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 305247e57110SSander Arens 305347e57110SSander Arens Not collective 305447e57110SSander Arens 305547e57110SSander Arens Input Parameter: 305647e57110SSander Arens . prob - The PetscDS object 305747e57110SSander Arens 305847e57110SSander Arens Output Parameter: 305947e57110SSander Arens . components - The number of components 306047e57110SSander Arens 306147e57110SSander Arens Level: beginner 306247e57110SSander Arens 306347e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 306447e57110SSander Arens @*/ 306547e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 306647e57110SSander Arens { 306747e57110SSander Arens PetscErrorCode ierr; 306847e57110SSander Arens 306947e57110SSander Arens PetscFunctionBegin; 307047e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 307147e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 307247e57110SSander Arens PetscValidPointer(components, 2); 307347e57110SSander Arens *components = prob->Nc; 30746ce16762SMatthew G. Knepley PetscFunctionReturn(0); 30756ce16762SMatthew G. Knepley } 30766ce16762SMatthew G. Knepley 30776ce16762SMatthew G. Knepley /*@ 30786ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 30796ce16762SMatthew G. Knepley 30806ce16762SMatthew G. Knepley Not collective 30816ce16762SMatthew G. Knepley 30826ce16762SMatthew G. Knepley Input Parameters: 30836ce16762SMatthew G. Knepley + prob - The PetscDS object 30846ce16762SMatthew G. Knepley - f - The field number 30856ce16762SMatthew G. Knepley 30866ce16762SMatthew G. Knepley Output Parameter: 30876ce16762SMatthew G. Knepley . off - The offset 30886ce16762SMatthew G. Knepley 30896ce16762SMatthew G. Knepley Level: beginner 30906ce16762SMatthew G. Knepley 3091f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 30926ce16762SMatthew G. Knepley @*/ 30936ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 30946ce16762SMatthew G. Knepley { 3095e1d313ffSMatthew G. Knepley PetscErrorCode ierr; 3096e1d313ffSMatthew G. Knepley 30976ce16762SMatthew G. Knepley PetscFunctionBegin; 30986ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30996ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 31006ce16762SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 3101e1d313ffSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 310247e57110SSander Arens *off = prob->off[f]; 31032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31042764a2aaSMatthew G. Knepley } 31052764a2aaSMatthew G. Knepley 3106194d53e6SMatthew G. Knepley /*@ 3107194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 3108194d53e6SMatthew G. Knepley 3109194d53e6SMatthew G. Knepley Not collective 3110194d53e6SMatthew G. Knepley 3111194d53e6SMatthew G. Knepley Input Parameter: 3112194d53e6SMatthew G. Knepley . prob - The PetscDS object 3113194d53e6SMatthew G. Knepley 3114194d53e6SMatthew G. Knepley Output Parameter: 3115194d53e6SMatthew G. Knepley . offsets - The offsets 3116194d53e6SMatthew G. Knepley 3117194d53e6SMatthew G. Knepley Level: beginner 3118194d53e6SMatthew G. Knepley 3119f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3120194d53e6SMatthew G. Knepley @*/ 3121194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 3122194d53e6SMatthew G. Knepley { 3123e1d313ffSMatthew G. Knepley PetscErrorCode ierr; 3124e1d313ffSMatthew G. Knepley 3125194d53e6SMatthew G. Knepley PetscFunctionBegin; 3126194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3127194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 3128e1d313ffSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3129194d53e6SMatthew G. Knepley *offsets = prob->off; 3130194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3131194d53e6SMatthew G. Knepley } 3132194d53e6SMatthew G. Knepley 3133194d53e6SMatthew G. Knepley /*@ 3134194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 3135194d53e6SMatthew G. Knepley 3136194d53e6SMatthew G. Knepley Not collective 3137194d53e6SMatthew G. Knepley 3138194d53e6SMatthew G. Knepley Input Parameter: 3139194d53e6SMatthew G. Knepley . prob - The PetscDS object 3140194d53e6SMatthew G. Knepley 3141194d53e6SMatthew G. Knepley Output Parameter: 3142194d53e6SMatthew G. Knepley . offsets - The offsets 3143194d53e6SMatthew G. Knepley 3144194d53e6SMatthew G. Knepley Level: beginner 3145194d53e6SMatthew G. Knepley 3146f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3147194d53e6SMatthew G. Knepley @*/ 3148194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 3149194d53e6SMatthew G. Knepley { 3150e1d313ffSMatthew G. Knepley PetscErrorCode ierr; 3151e1d313ffSMatthew G. Knepley 3152194d53e6SMatthew G. Knepley PetscFunctionBegin; 3153194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3154194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 3155e1d313ffSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3156194d53e6SMatthew G. Knepley *offsets = prob->offDer; 3157194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3158194d53e6SMatthew G. Knepley } 3159194d53e6SMatthew G. Knepley 316068c9edb9SMatthew G. Knepley /*@C 316168c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 316268c9edb9SMatthew G. Knepley 316368c9edb9SMatthew G. Knepley Not collective 316468c9edb9SMatthew G. Knepley 316568c9edb9SMatthew G. Knepley Input Parameter: 316668c9edb9SMatthew G. Knepley . prob - The PetscDS object 316768c9edb9SMatthew G. Knepley 3168ef0bb6c7SMatthew G. Knepley Output Parameter: 3169ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 317068c9edb9SMatthew G. Knepley 317168c9edb9SMatthew G. Knepley Level: intermediate 317268c9edb9SMatthew G. Knepley 3173f744cafaSSander Arens .seealso: PetscDSCreate() 317468c9edb9SMatthew G. Knepley @*/ 3175ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 31762764a2aaSMatthew G. Knepley { 31772764a2aaSMatthew G. Knepley PetscErrorCode ierr; 31782764a2aaSMatthew G. Knepley 31792764a2aaSMatthew G. Knepley PetscFunctionBegin; 31802764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3181ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 31822764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3183ef0bb6c7SMatthew G. Knepley *T = prob->T; 31842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31852764a2aaSMatthew G. Knepley } 31862764a2aaSMatthew G. Knepley 318768c9edb9SMatthew G. Knepley /*@C 31884d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 318968c9edb9SMatthew G. Knepley 319068c9edb9SMatthew G. Knepley Not collective 319168c9edb9SMatthew G. Knepley 319268c9edb9SMatthew G. Knepley Input Parameter: 319368c9edb9SMatthew G. Knepley . prob - The PetscDS object 319468c9edb9SMatthew G. Knepley 3195ef0bb6c7SMatthew G. Knepley Output Parameter: 3196a5b23f4aSJose E. Roman . Tf - The basis function and derivative tabulation on each local face at quadrature points for each and field 319768c9edb9SMatthew G. Knepley 319868c9edb9SMatthew G. Knepley Level: intermediate 319968c9edb9SMatthew G. Knepley 320068c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 320168c9edb9SMatthew G. Knepley @*/ 3202ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 32032764a2aaSMatthew G. Knepley { 32042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 32052764a2aaSMatthew G. Knepley 32062764a2aaSMatthew G. Knepley PetscFunctionBegin; 32072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3208ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 32092764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3210ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 32112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32122764a2aaSMatthew G. Knepley } 32132764a2aaSMatthew G. Knepley 32142764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 32152764a2aaSMatthew G. Knepley { 32162764a2aaSMatthew G. Knepley PetscErrorCode ierr; 32172764a2aaSMatthew G. Knepley 32182764a2aaSMatthew G. Knepley PetscFunctionBegin; 32192764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32202764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 32212764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 32222764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 32232764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 32242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32252764a2aaSMatthew G. Knepley } 32262764a2aaSMatthew G. Knepley 32272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 32282764a2aaSMatthew G. Knepley { 32292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 32302764a2aaSMatthew G. Knepley 32312764a2aaSMatthew G. Knepley PetscFunctionBegin; 32322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32332764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 32342764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 32352764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 32362764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 32372764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 32382764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 32392764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 32402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32412764a2aaSMatthew G. Knepley } 32422764a2aaSMatthew G. Knepley 32434bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 32442764a2aaSMatthew G. Knepley { 32452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 32462764a2aaSMatthew G. Knepley 32472764a2aaSMatthew G. Knepley PetscFunctionBegin; 32482764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32492764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 32502764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 32514bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 32527506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 32537506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 32547506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 32552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 32562764a2aaSMatthew G. Knepley } 32572764a2aaSMatthew G. Knepley 325858ebd649SToby Isaac /*@C 325956cf3b9cSMatthew 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(). 326058ebd649SToby Isaac 3261783e2ec8SMatthew G. Knepley Collective on ds 3262783e2ec8SMatthew G. Knepley 326358ebd649SToby Isaac Input Parameters: 326458ebd649SToby Isaac + ds - The PetscDS object 32652d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 326658ebd649SToby Isaac . name - The BC name 326745480ffeSMatthew G. Knepley . label - The label defining constrained points 326845480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 326945480ffeSMatthew G. Knepley . values - An array of label values for constrained points 327058ebd649SToby Isaac . field - The field to constrain 327145480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 327258ebd649SToby Isaac . comps - An array of constrained component numbers 327358ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3274a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 327558ebd649SToby Isaac - ctx - An optional user context for bcFunc 327658ebd649SToby Isaac 327745480ffeSMatthew G. Knepley Output Parameters: 327845480ffeSMatthew G. Knepley - bd - The boundary number 327945480ffeSMatthew G. Knepley 328058ebd649SToby Isaac Options Database Keys: 328158ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 328258ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 328358ebd649SToby Isaac 328456cf3b9cSMatthew G. Knepley Note: 328556cf3b9cSMatthew 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: 328656cf3b9cSMatthew G. Knepley 328756cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 328856cf3b9cSMatthew G. Knepley 328956cf3b9cSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 329056cf3b9cSMatthew G. Knepley 329156cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 329256cf3b9cSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 329356cf3b9cSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 329456cf3b9cSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 329556cf3b9cSMatthew G. Knepley 329656cf3b9cSMatthew G. Knepley + dim - the spatial dimension 329756cf3b9cSMatthew G. Knepley . Nf - the number of fields 329856cf3b9cSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 329956cf3b9cSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 330056cf3b9cSMatthew G. Knepley . u - each field evaluated at the current point 330156cf3b9cSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 330256cf3b9cSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 330356cf3b9cSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 330456cf3b9cSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 330556cf3b9cSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 330656cf3b9cSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 330756cf3b9cSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 330856cf3b9cSMatthew G. Knepley . t - current time 330956cf3b9cSMatthew G. Knepley . x - coordinates of the current point 331056cf3b9cSMatthew G. Knepley . numConstants - number of constant parameters 331156cf3b9cSMatthew G. Knepley . constants - constant parameters 331256cf3b9cSMatthew G. Knepley - bcval - output values at the current point 331356cf3b9cSMatthew G. Knepley 331458ebd649SToby Isaac Level: developer 331558ebd649SToby Isaac 331645480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundaryByName(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 331758ebd649SToby Isaac @*/ 331845480ffeSMatthew 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) 331958ebd649SToby Isaac { 332045480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 332145480ffeSMatthew G. Knepley PetscInt n = 0; 332245480ffeSMatthew G. Knepley const char *lname; 332358ebd649SToby Isaac PetscErrorCode ierr; 332458ebd649SToby Isaac 332558ebd649SToby Isaac PetscFunctionBegin; 332658ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3327783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 332845480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 332945480ffeSMatthew G. Knepley PetscValidHeaderSpecific(label, DMLABEL_CLASSID, 4); 333045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 333145480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 333245480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 3333d57bb9dbSMatthew G. Knepley if (Nc > 0) { 3334d57bb9dbSMatthew G. Knepley PetscInt *fcomps; 3335d57bb9dbSMatthew G. Knepley PetscInt c; 3336d57bb9dbSMatthew G. Knepley 3337d57bb9dbSMatthew G. Knepley ierr = PetscDSGetComponents(ds, &fcomps);CHKERRQ(ierr); 3338d57bb9dbSMatthew G. Knepley if (Nc > fcomps[field]) SETERRQ3(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Number of constrained components %D > %D components for field %D", Nc, fcomps[field], field); 3339d57bb9dbSMatthew G. Knepley for (c = 0; c < Nc; ++c) { 3340d57bb9dbSMatthew G. Knepley if (comps[c] < 0 || comps[c] >= fcomps[field]) SETERRQ4(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); 3341d57bb9dbSMatthew G. Knepley } 3342d57bb9dbSMatthew G. Knepley } 334358ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 334458ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 334545480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf);CHKERRQ(ierr); 334645480ffeSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(b->wf, ds->Nf);CHKERRQ(ierr); 334745480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 334845480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 334945480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 335045480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 335145480ffeSMatthew G. Knepley ierr = PetscObjectGetName((PetscObject) label, &lname);CHKERRQ(ierr); 335245480ffeSMatthew G. Knepley ierr = PetscStrallocpy(lname, (char **) &b->lname);CHKERRQ(ierr); 3353f971fd6bSMatthew G. Knepley b->type = type; 335445480ffeSMatthew G. Knepley b->label = label; 335545480ffeSMatthew G. Knepley b->Nv = Nv; 335658ebd649SToby Isaac b->field = field; 335745480ffeSMatthew G. Knepley b->Nc = Nc; 335858ebd649SToby Isaac b->func = bcFunc; 335956cf3b9cSMatthew G. Knepley b->func_t = bcFunc_t; 336058ebd649SToby Isaac b->ctx = ctx; 336145480ffeSMatthew G. Knepley b->next = NULL; 336245480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 336345480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 336445480ffeSMatthew G. Knepley while (head) { 336545480ffeSMatthew G. Knepley if (!head->next) { 336645480ffeSMatthew G. Knepley head->next = b; 336745480ffeSMatthew G. Knepley head = b; 336845480ffeSMatthew G. Knepley } 336945480ffeSMatthew G. Knepley head = head->next; 337045480ffeSMatthew G. Knepley ++n; 337145480ffeSMatthew G. Knepley } 3372064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 337345480ffeSMatthew G. Knepley PetscFunctionReturn(0); 337445480ffeSMatthew G. Knepley } 337545480ffeSMatthew G. Knepley 337645480ffeSMatthew G. Knepley /*@C 337745480ffeSMatthew 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(). 337845480ffeSMatthew G. Knepley 337945480ffeSMatthew G. Knepley Collective on ds 338045480ffeSMatthew G. Knepley 338145480ffeSMatthew G. Knepley Input Parameters: 338245480ffeSMatthew G. Knepley + ds - The PetscDS object 338345480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 338445480ffeSMatthew G. Knepley . name - The BC name 338545480ffeSMatthew G. Knepley . lname - The naem of the label defining constrained points 338645480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 338745480ffeSMatthew G. Knepley . values - An array of label values for constrained points 338845480ffeSMatthew G. Knepley . field - The field to constrain 338945480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 339045480ffeSMatthew G. Knepley . comps - An array of constrained component numbers 339145480ffeSMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3392a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 339345480ffeSMatthew G. Knepley - ctx - An optional user context for bcFunc 339445480ffeSMatthew G. Knepley 339545480ffeSMatthew G. Knepley Output Parameters: 339645480ffeSMatthew G. Knepley - bd - The boundary number 339745480ffeSMatthew G. Knepley 339845480ffeSMatthew G. Knepley Options Database Keys: 339945480ffeSMatthew G. Knepley + -bc_<boundary name> <num> - Overrides the boundary ids 340045480ffeSMatthew G. Knepley - -bc_<boundary name>_comp <num> - Overrides the boundary components 340145480ffeSMatthew G. Knepley 340245480ffeSMatthew G. Knepley Note: 340345480ffeSMatthew G. Knepley This function should only be used with DMForest currently, since labels cannot be defined before the underlygin Plex is built. 340445480ffeSMatthew G. Knepley 340545480ffeSMatthew 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: 340645480ffeSMatthew G. Knepley 340745480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 340845480ffeSMatthew G. Knepley 340945480ffeSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 341045480ffeSMatthew G. Knepley 341145480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 341245480ffeSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 341345480ffeSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 341445480ffeSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 341545480ffeSMatthew G. Knepley 341645480ffeSMatthew G. Knepley + dim - the spatial dimension 341745480ffeSMatthew G. Knepley . Nf - the number of fields 341845480ffeSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 341945480ffeSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 342045480ffeSMatthew G. Knepley . u - each field evaluated at the current point 342145480ffeSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 342245480ffeSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 342345480ffeSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 342445480ffeSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 342545480ffeSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 342645480ffeSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 342745480ffeSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 342845480ffeSMatthew G. Knepley . t - current time 342945480ffeSMatthew G. Knepley . x - coordinates of the current point 343045480ffeSMatthew G. Knepley . numConstants - number of constant parameters 343145480ffeSMatthew G. Knepley . constants - constant parameters 343245480ffeSMatthew G. Knepley - bcval - output values at the current point 343345480ffeSMatthew G. Knepley 343445480ffeSMatthew G. Knepley Level: developer 343545480ffeSMatthew G. Knepley 343645480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 343745480ffeSMatthew G. Knepley @*/ 343845480ffeSMatthew 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) 343945480ffeSMatthew G. Knepley { 344045480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 344145480ffeSMatthew G. Knepley PetscInt n = 0; 344245480ffeSMatthew G. Knepley PetscErrorCode ierr; 344345480ffeSMatthew G. Knepley 344445480ffeSMatthew G. Knepley PetscFunctionBegin; 344545480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 344645480ffeSMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 344745480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 344845480ffeSMatthew G. Knepley PetscValidCharPointer(lname, 4); 344945480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 345045480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 345145480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 345245480ffeSMatthew G. Knepley ierr = PetscNew(&b);CHKERRQ(ierr); 345345480ffeSMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 345445480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf);CHKERRQ(ierr); 345545480ffeSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(b->wf, ds->Nf);CHKERRQ(ierr); 345645480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 345745480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 345845480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 345945480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 346045480ffeSMatthew G. Knepley ierr = PetscStrallocpy(lname, (char **) &b->lname);CHKERRQ(ierr); 346145480ffeSMatthew G. Knepley b->type = type; 346245480ffeSMatthew G. Knepley b->label = NULL; 346345480ffeSMatthew G. Knepley b->Nv = Nv; 346445480ffeSMatthew G. Knepley b->field = field; 346545480ffeSMatthew G. Knepley b->Nc = Nc; 346645480ffeSMatthew G. Knepley b->func = bcFunc; 346745480ffeSMatthew G. Knepley b->func_t = bcFunc_t; 346845480ffeSMatthew G. Knepley b->ctx = ctx; 346945480ffeSMatthew G. Knepley b->next = NULL; 347045480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 347145480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 347245480ffeSMatthew G. Knepley while (head) { 347345480ffeSMatthew G. Knepley if (!head->next) { 347445480ffeSMatthew G. Knepley head->next = b; 347545480ffeSMatthew G. Knepley head = b; 347645480ffeSMatthew G. Knepley } 347745480ffeSMatthew G. Knepley head = head->next; 347845480ffeSMatthew G. Knepley ++n; 347945480ffeSMatthew G. Knepley } 3480064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 348158ebd649SToby Isaac PetscFunctionReturn(0); 348258ebd649SToby Isaac } 348358ebd649SToby Isaac 3484b67eacb3SMatthew G. Knepley /*@C 348556cf3b9cSMatthew 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(). 3486b67eacb3SMatthew G. Knepley 3487b67eacb3SMatthew G. Knepley Input Parameters: 3488b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3489b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3490b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3491b67eacb3SMatthew G. Knepley . name - The BC name 349245480ffeSMatthew G. Knepley . label - The label defining constrained points 349345480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 349445480ffeSMatthew G. Knepley . values - An array of ids for constrained points 3495b67eacb3SMatthew G. Knepley . field - The field to constrain 349645480ffeSMatthew G. Knepley . Nc - The number of constrained field components 3497b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3498b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3499a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values, or NULL 3500b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3501b67eacb3SMatthew G. Knepley 350256cf3b9cSMatthew G. Knepley Note: 350356cf3b9cSMatthew 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. 35049a6efb6aSMatthew G. Knepley 3505b67eacb3SMatthew G. Knepley Level: developer 3506b67eacb3SMatthew G. Knepley 35079a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3508b67eacb3SMatthew G. Knepley @*/ 350945480ffeSMatthew 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) 3510b67eacb3SMatthew G. Knepley { 3511b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3512b67eacb3SMatthew G. Knepley PetscInt n = 0; 3513b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 3514b67eacb3SMatthew G. Knepley 3515b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3516b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3517b67eacb3SMatthew G. Knepley while (b) { 3518b67eacb3SMatthew G. Knepley if (n == bd) break; 3519b67eacb3SMatthew G. Knepley b = b->next; 3520b67eacb3SMatthew G. Knepley ++n; 3521b67eacb3SMatthew G. Knepley } 3522b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3523b67eacb3SMatthew G. Knepley if (name) { 3524b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 3525b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 3526b67eacb3SMatthew G. Knepley } 3527b67eacb3SMatthew G. Knepley b->type = type; 352845480ffeSMatthew G. Knepley if (label) { 352945480ffeSMatthew G. Knepley const char *name; 353045480ffeSMatthew G. Knepley 353145480ffeSMatthew G. Knepley b->label = label; 353245480ffeSMatthew G. Knepley ierr = PetscFree(b->lname);CHKERRQ(ierr); 353345480ffeSMatthew G. Knepley ierr = PetscObjectGetName((PetscObject) label, &name);CHKERRQ(ierr); 353445480ffeSMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->lname);CHKERRQ(ierr); 353545480ffeSMatthew G. Knepley } 353645480ffeSMatthew G. Knepley if (Nv >= 0) { 353745480ffeSMatthew G. Knepley b->Nv = Nv; 353845480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 353945480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 354045480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 354145480ffeSMatthew G. Knepley } 354245480ffeSMatthew G. Knepley if (field >= 0) b->field = field; 354345480ffeSMatthew G. Knepley if (Nc >= 0) { 354445480ffeSMatthew G. Knepley b->Nc = Nc; 354545480ffeSMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 354645480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 354745480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 354845480ffeSMatthew G. Knepley } 354945480ffeSMatthew G. Knepley if (bcFunc) b->func = bcFunc; 355045480ffeSMatthew G. Knepley if (bcFunc_t) b->func_t = bcFunc_t; 355145480ffeSMatthew G. Knepley if (ctx) b->ctx = ctx; 3552b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3553b67eacb3SMatthew G. Knepley } 3554b67eacb3SMatthew G. Knepley 355558ebd649SToby Isaac /*@ 355658ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 355758ebd649SToby Isaac 355858ebd649SToby Isaac Input Parameters: 355958ebd649SToby Isaac . ds - The PetscDS object 356058ebd649SToby Isaac 356158ebd649SToby Isaac Output Parameters: 356258ebd649SToby Isaac . numBd - The number of BC 356358ebd649SToby Isaac 356458ebd649SToby Isaac Level: intermediate 356558ebd649SToby Isaac 356658ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 356758ebd649SToby Isaac @*/ 356858ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 356958ebd649SToby Isaac { 357058ebd649SToby Isaac DSBoundary b = ds->boundary; 357158ebd649SToby Isaac 357258ebd649SToby Isaac PetscFunctionBegin; 357358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 357458ebd649SToby Isaac PetscValidPointer(numBd, 2); 357558ebd649SToby Isaac *numBd = 0; 357658ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 357758ebd649SToby Isaac PetscFunctionReturn(0); 357858ebd649SToby Isaac } 357958ebd649SToby Isaac 358058ebd649SToby Isaac /*@C 35819a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 358258ebd649SToby Isaac 358358ebd649SToby Isaac Input Parameters: 358458ebd649SToby Isaac + ds - The PetscDS object 358558ebd649SToby Isaac - bd - The BC number 358658ebd649SToby Isaac 358758ebd649SToby Isaac Output Parameters: 358845480ffeSMatthew G. Knepley + wf - The PetscWeakForm holding the pointwise functions 358945480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 359058ebd649SToby Isaac . name - The BC name 359145480ffeSMatthew G. Knepley . label - The label defining constrained points 359245480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 359345480ffeSMatthew G. Knepley . values - An array of ids for constrained points 359458ebd649SToby Isaac . field - The field to constrain 359545480ffeSMatthew G. Knepley . Nc - The number of constrained field components 359658ebd649SToby Isaac . comps - An array of constrained component numbers 359758ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 3598a5b23f4aSJose E. Roman . bcFunc_t - A pointwise function giving the time derivative of the boundary values 359958ebd649SToby Isaac - ctx - An optional user context for bcFunc 360058ebd649SToby Isaac 360158ebd649SToby Isaac Options Database Keys: 360258ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 360358ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 360458ebd649SToby Isaac 360558ebd649SToby Isaac Level: developer 360658ebd649SToby Isaac 360758ebd649SToby Isaac .seealso: PetscDSAddBoundary() 360858ebd649SToby Isaac @*/ 360945480ffeSMatthew 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) 361058ebd649SToby Isaac { 361158ebd649SToby Isaac DSBoundary b = ds->boundary; 361258ebd649SToby Isaac PetscInt n = 0; 361358ebd649SToby Isaac 361458ebd649SToby Isaac PetscFunctionBegin; 361558ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 361658ebd649SToby Isaac while (b) { 361758ebd649SToby Isaac if (n == bd) break; 361858ebd649SToby Isaac b = b->next; 361958ebd649SToby Isaac ++n; 362058ebd649SToby Isaac } 362158ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 362245480ffeSMatthew G. Knepley if (wf) { 362345480ffeSMatthew G. Knepley PetscValidPointer(wf, 3); 362445480ffeSMatthew G. Knepley *wf = b->wf; 362545480ffeSMatthew G. Knepley } 3626f971fd6bSMatthew G. Knepley if (type) { 362745480ffeSMatthew G. Knepley PetscValidPointer(type, 4); 3628f971fd6bSMatthew G. Knepley *type = b->type; 362958ebd649SToby Isaac } 363058ebd649SToby Isaac if (name) { 363145480ffeSMatthew G. Knepley PetscValidPointer(name, 5); 363258ebd649SToby Isaac *name = b->name; 363358ebd649SToby Isaac } 363445480ffeSMatthew G. Knepley if (label) { 363545480ffeSMatthew G. Knepley PetscValidPointer(label, 6); 363645480ffeSMatthew G. Knepley *label = b->label; 363745480ffeSMatthew G. Knepley } 363845480ffeSMatthew G. Knepley if (Nv) { 363945480ffeSMatthew G. Knepley PetscValidIntPointer(Nv, 7); 364045480ffeSMatthew G. Knepley *Nv = b->Nv; 364145480ffeSMatthew G. Knepley } 364245480ffeSMatthew G. Knepley if (values) { 364345480ffeSMatthew G. Knepley PetscValidPointer(values, 8); 364445480ffeSMatthew G. Knepley *values = b->values; 364558ebd649SToby Isaac } 364658ebd649SToby Isaac if (field) { 364745480ffeSMatthew G. Knepley PetscValidIntPointer(field, 9); 364858ebd649SToby Isaac *field = b->field; 364958ebd649SToby Isaac } 365045480ffeSMatthew G. Knepley if (Nc) { 365145480ffeSMatthew G. Knepley PetscValidIntPointer(Nc, 10); 365245480ffeSMatthew G. Knepley *Nc = b->Nc; 365358ebd649SToby Isaac } 365458ebd649SToby Isaac if (comps) { 365545480ffeSMatthew G. Knepley PetscValidPointer(comps, 11); 365658ebd649SToby Isaac *comps = b->comps; 365758ebd649SToby Isaac } 365858ebd649SToby Isaac if (func) { 365945480ffeSMatthew G. Knepley PetscValidPointer(func, 12); 366058ebd649SToby Isaac *func = b->func; 366158ebd649SToby Isaac } 366256cf3b9cSMatthew G. Knepley if (func_t) { 366345480ffeSMatthew G. Knepley PetscValidPointer(func_t, 13); 366456cf3b9cSMatthew G. Knepley *func_t = b->func_t; 366556cf3b9cSMatthew G. Knepley } 366658ebd649SToby Isaac if (ctx) { 366745480ffeSMatthew G. Knepley PetscValidPointer(ctx, 14); 366858ebd649SToby Isaac *ctx = b->ctx; 366958ebd649SToby Isaac } 367058ebd649SToby Isaac PetscFunctionReturn(0); 367158ebd649SToby Isaac } 367258ebd649SToby Isaac 367345480ffeSMatthew G. Knepley static PetscErrorCode DSBoundaryDuplicate_Internal(DSBoundary b, DSBoundary *bNew) 367445480ffeSMatthew G. Knepley { 367545480ffeSMatthew G. Knepley PetscErrorCode ierr; 367645480ffeSMatthew G. Knepley 367745480ffeSMatthew G. Knepley PetscFunctionBegin; 367845480ffeSMatthew G. Knepley ierr = PetscNew(bNew);CHKERRQ(ierr); 367945480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &(*bNew)->wf);CHKERRQ(ierr); 368045480ffeSMatthew G. Knepley ierr = PetscWeakFormCopy(b->wf, (*bNew)->wf);CHKERRQ(ierr); 368145480ffeSMatthew G. Knepley ierr = PetscStrallocpy(b->name,(char **) &((*bNew)->name));CHKERRQ(ierr); 368245480ffeSMatthew G. Knepley ierr = PetscStrallocpy(b->lname,(char **) &((*bNew)->lname));CHKERRQ(ierr); 368345480ffeSMatthew G. Knepley (*bNew)->type = b->type; 368445480ffeSMatthew G. Knepley (*bNew)->label = b->label; 368545480ffeSMatthew G. Knepley (*bNew)->Nv = b->Nv; 368645480ffeSMatthew G. Knepley ierr = PetscMalloc1(b->Nv, &(*bNew)->values);CHKERRQ(ierr); 368745480ffeSMatthew G. Knepley ierr = PetscArraycpy((*bNew)->values, b->values, b->Nv);CHKERRQ(ierr); 368845480ffeSMatthew G. Knepley (*bNew)->field = b->field; 368945480ffeSMatthew G. Knepley (*bNew)->Nc = b->Nc; 369045480ffeSMatthew G. Knepley ierr = PetscMalloc1(b->Nc, &(*bNew)->comps);CHKERRQ(ierr); 369145480ffeSMatthew G. Knepley ierr = PetscArraycpy((*bNew)->comps, b->comps, b->Nc);CHKERRQ(ierr); 369245480ffeSMatthew G. Knepley (*bNew)->func = b->func; 369345480ffeSMatthew G. Knepley (*bNew)->func_t = b->func_t; 369445480ffeSMatthew G. Knepley (*bNew)->ctx = b->ctx; 369545480ffeSMatthew G. Knepley PetscFunctionReturn(0); 369645480ffeSMatthew G. Knepley } 369745480ffeSMatthew G. Knepley 36989252d075SMatthew G. Knepley /*@ 36999252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 37009252d075SMatthew G. Knepley 37019252d075SMatthew G. Knepley Not collective 37029252d075SMatthew G. Knepley 370336951cb5SMatthew G. Knepley Input Parameters: 370436951cb5SMatthew G. Knepley + ds - The source PetscDS object 370536951cb5SMatthew G. Knepley . numFields - The number of selected fields, or PETSC_DEFAULT for all fields 370636951cb5SMatthew G. Knepley - fields - The selected fields, or NULL for all fields 37079252d075SMatthew G. Knepley 37089252d075SMatthew G. Knepley Output Parameter: 370936951cb5SMatthew G. Knepley . newds - The target PetscDS, now with a copy of the boundary conditions 37109252d075SMatthew G. Knepley 37119252d075SMatthew G. Knepley Level: intermediate 37129252d075SMatthew G. Knepley 37139252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 37149252d075SMatthew G. Knepley @*/ 371536951cb5SMatthew G. Knepley PetscErrorCode PetscDSCopyBoundary(PetscDS ds, PetscInt numFields, const PetscInt fields[], PetscDS newds) 3716dff059c6SToby Isaac { 371745480ffeSMatthew G. Knepley DSBoundary b, *lastnext; 3718dff059c6SToby Isaac PetscErrorCode ierr; 3719dff059c6SToby Isaac 3720dff059c6SToby Isaac PetscFunctionBegin; 372136951cb5SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 372236951cb5SMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 4); 372336951cb5SMatthew G. Knepley if (ds == newds) PetscFunctionReturn(0); 372445480ffeSMatthew G. Knepley ierr = PetscDSDestroyBoundary(newds);CHKERRQ(ierr); 372536951cb5SMatthew G. Knepley lastnext = &(newds->boundary); 372636951cb5SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 3727dff059c6SToby Isaac DSBoundary bNew; 372836951cb5SMatthew G. Knepley PetscInt fieldNew = -1; 3729dff059c6SToby Isaac 373036951cb5SMatthew G. Knepley if (numFields > 0 && fields) { 373136951cb5SMatthew G. Knepley PetscInt f; 373236951cb5SMatthew G. Knepley 373336951cb5SMatthew G. Knepley for (f = 0; f < numFields; ++f) if (b->field == fields[f]) break; 373436951cb5SMatthew G. Knepley if (f == numFields) continue; 373536951cb5SMatthew G. Knepley fieldNew = f; 373636951cb5SMatthew G. Knepley } 373745480ffeSMatthew G. Knepley ierr = DSBoundaryDuplicate_Internal(b, &bNew);CHKERRQ(ierr); 373836951cb5SMatthew G. Knepley bNew->field = fieldNew < 0 ? b->field : fieldNew; 3739dff059c6SToby Isaac *lastnext = bNew; 3740dff059c6SToby Isaac lastnext = &(bNew->next); 3741dff059c6SToby Isaac } 3742dff059c6SToby Isaac PetscFunctionReturn(0); 3743dff059c6SToby Isaac } 3744dff059c6SToby Isaac 37456c1eb96dSMatthew G. Knepley /*@ 374645480ffeSMatthew G. Knepley PetscDSDestroyBoundary - Remove all DMBoundary objects from the PetscDS 374745480ffeSMatthew G. Knepley 374845480ffeSMatthew G. Knepley Not collective 374945480ffeSMatthew G. Knepley 375045480ffeSMatthew G. Knepley Input Parameter: 375145480ffeSMatthew G. Knepley . ds - The PetscDS object 375245480ffeSMatthew G. Knepley 375345480ffeSMatthew G. Knepley Level: intermediate 375445480ffeSMatthew G. Knepley 375545480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations() 375645480ffeSMatthew G. Knepley @*/ 375745480ffeSMatthew G. Knepley PetscErrorCode PetscDSDestroyBoundary(PetscDS ds) 375845480ffeSMatthew G. Knepley { 375945480ffeSMatthew G. Knepley DSBoundary next = ds->boundary; 376045480ffeSMatthew G. Knepley PetscErrorCode ierr; 376145480ffeSMatthew G. Knepley 376245480ffeSMatthew G. Knepley PetscFunctionBegin; 376345480ffeSMatthew G. Knepley while (next) { 376445480ffeSMatthew G. Knepley DSBoundary b = next; 376545480ffeSMatthew G. Knepley 376645480ffeSMatthew G. Knepley next = b->next; 376745480ffeSMatthew G. Knepley ierr = PetscWeakFormDestroy(&b->wf);CHKERRQ(ierr); 376845480ffeSMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 376945480ffeSMatthew G. Knepley ierr = PetscFree(b->lname);CHKERRQ(ierr); 377045480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 377145480ffeSMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 377245480ffeSMatthew G. Knepley ierr = PetscFree(b);CHKERRQ(ierr); 377345480ffeSMatthew G. Knepley } 377445480ffeSMatthew G. Knepley PetscFunctionReturn(0); 377545480ffeSMatthew G. Knepley } 377645480ffeSMatthew G. Knepley 377745480ffeSMatthew G. Knepley /*@ 37786c1eb96dSMatthew G. Knepley PetscDSSelectDiscretizations - Copy discretizations to the new problem with different field layout 37796c1eb96dSMatthew G. Knepley 37806c1eb96dSMatthew G. Knepley Not collective 37816c1eb96dSMatthew G. Knepley 3782d8d19677SJose E. Roman Input Parameters: 37836c1eb96dSMatthew G. Knepley + prob - The PetscDS object 37846c1eb96dSMatthew G. Knepley . numFields - Number of new fields 37856c1eb96dSMatthew G. Knepley - fields - Old field number for each new field 37866c1eb96dSMatthew G. Knepley 37876c1eb96dSMatthew G. Knepley Output Parameter: 37886c1eb96dSMatthew G. Knepley . newprob - The PetscDS copy 37896c1eb96dSMatthew G. Knepley 37906c1eb96dSMatthew G. Knepley Level: intermediate 37916c1eb96dSMatthew G. Knepley 37926c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectEquations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 37936c1eb96dSMatthew G. Knepley @*/ 37946c1eb96dSMatthew G. Knepley PetscErrorCode PetscDSSelectDiscretizations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 37956c1eb96dSMatthew G. Knepley { 37966c1eb96dSMatthew G. Knepley PetscInt Nf, Nfn, fn; 37976c1eb96dSMatthew G. Knepley PetscErrorCode ierr; 37986c1eb96dSMatthew G. Knepley 37996c1eb96dSMatthew G. Knepley PetscFunctionBegin; 38006c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 38016c1eb96dSMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 38026c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38036c1eb96dSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 38046c1eb96dSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 380545480ffeSMatthew G. Knepley numFields = numFields < 0 ? Nf : numFields; 38066c1eb96dSMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38076c1eb96dSMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38086c1eb96dSMatthew G. Knepley PetscObject disc; 38096c1eb96dSMatthew G. Knepley 38106c1eb96dSMatthew G. Knepley if (f >= Nf) continue; 38116c1eb96dSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &disc);CHKERRQ(ierr); 38126c1eb96dSMatthew G. Knepley ierr = PetscDSSetDiscretization(newprob, fn, disc);CHKERRQ(ierr); 38136c1eb96dSMatthew G. Knepley } 38146c1eb96dSMatthew G. Knepley PetscFunctionReturn(0); 38156c1eb96dSMatthew G. Knepley } 38166c1eb96dSMatthew G. Knepley 38176c1eb96dSMatthew G. Knepley /*@ 38189252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 38199252d075SMatthew G. Knepley 38209252d075SMatthew G. Knepley Not collective 38219252d075SMatthew G. Knepley 3822d8d19677SJose E. Roman Input Parameters: 38239252d075SMatthew G. Knepley + prob - The PetscDS object 38249252d075SMatthew G. Knepley . numFields - Number of new fields 38259252d075SMatthew G. Knepley - fields - Old field number for each new field 38269252d075SMatthew G. Knepley 38279252d075SMatthew G. Knepley Output Parameter: 38289252d075SMatthew G. Knepley . newprob - The PetscDS copy 38299252d075SMatthew G. Knepley 38309252d075SMatthew G. Knepley Level: intermediate 38319252d075SMatthew G. Knepley 38326c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectDiscretizations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 38339252d075SMatthew G. Knepley @*/ 38349252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 38359252d075SMatthew G. Knepley { 38369252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 38379252d075SMatthew G. Knepley PetscErrorCode ierr; 38389252d075SMatthew G. Knepley 38399252d075SMatthew G. Knepley PetscFunctionBegin; 38409252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 38419252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 38429252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 38439252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 38449252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 38459252d075SMatthew G. Knepley if (numFields > Nfn) SETERRQ2(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); 38469252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 38479252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 38489252d075SMatthew G. Knepley PetscPointFunc obj; 38499252d075SMatthew G. Knepley PetscPointFunc f0, f1; 38509252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 38519252d075SMatthew G. Knepley PetscRiemannFunc r; 38529252d075SMatthew G. Knepley 3853c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 38549252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 38559252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 38569252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 38579252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 38589252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 38599252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 38609252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 38619252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 38629252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 38639252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 38649252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 38659252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 38669252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 38679252d075SMatthew G. Knepley 3868c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 38699252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 38709252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 38719252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 38729252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 38736c1eb96dSMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(newprob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 38749252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 38759252d075SMatthew G. Knepley } 38769252d075SMatthew G. Knepley } 38779252d075SMatthew G. Knepley PetscFunctionReturn(0); 38789252d075SMatthew G. Knepley } 38799252d075SMatthew G. Knepley 3880da51fcedSMatthew G. Knepley /*@ 3881da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3882da51fcedSMatthew G. Knepley 3883da51fcedSMatthew G. Knepley Not collective 3884da51fcedSMatthew G. Knepley 3885da51fcedSMatthew G. Knepley Input Parameter: 3886da51fcedSMatthew G. Knepley . prob - The PetscDS object 3887da51fcedSMatthew G. Knepley 3888da51fcedSMatthew G. Knepley Output Parameter: 3889da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3890da51fcedSMatthew G. Knepley 3891da51fcedSMatthew G. Knepley Level: intermediate 3892da51fcedSMatthew G. Knepley 38939252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3894da51fcedSMatthew G. Knepley @*/ 3895da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3896da51fcedSMatthew G. Knepley { 3897b8025e53SMatthew G. Knepley PetscWeakForm wf, newwf; 38989252d075SMatthew G. Knepley PetscInt Nf, Ng; 3899da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3900da51fcedSMatthew G. Knepley 3901da51fcedSMatthew G. Knepley PetscFunctionBegin; 3902da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3903da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3904da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3905da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 390613903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 3907b8025e53SMatthew G. Knepley ierr = PetscDSGetWeakForm(prob, &wf);CHKERRQ(ierr); 3908b8025e53SMatthew G. Knepley ierr = PetscDSGetWeakForm(newprob, &newwf);CHKERRQ(ierr); 3909b8025e53SMatthew G. Knepley ierr = PetscWeakFormCopy(wf, newwf);CHKERRQ(ierr); 39109252d075SMatthew G. Knepley PetscFunctionReturn(0); 39119252d075SMatthew G. Knepley } 391245480ffeSMatthew G. Knepley 39139252d075SMatthew G. Knepley /*@ 39149252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3915da51fcedSMatthew G. Knepley 39169252d075SMatthew G. Knepley Not collective 39179252d075SMatthew G. Knepley 39189252d075SMatthew G. Knepley Input Parameter: 39199252d075SMatthew G. Knepley . prob - The PetscDS object 39209252d075SMatthew G. Knepley 39219252d075SMatthew G. Knepley Output Parameter: 39229252d075SMatthew G. Knepley . newprob - The PetscDS copy 39239252d075SMatthew G. Knepley 39249252d075SMatthew G. Knepley Level: intermediate 39259252d075SMatthew G. Knepley 39269252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 39279252d075SMatthew G. Knepley @*/ 39289252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 39299252d075SMatthew G. Knepley { 39309252d075SMatthew G. Knepley PetscInt Nc; 39319252d075SMatthew G. Knepley const PetscScalar *constants; 39329252d075SMatthew G. Knepley PetscErrorCode ierr; 39339252d075SMatthew G. Knepley 39349252d075SMatthew G. Knepley PetscFunctionBegin; 39359252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 39369252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 39379252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 39389252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3939da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3940da51fcedSMatthew G. Knepley } 3941da51fcedSMatthew G. Knepley 394245480ffeSMatthew G. Knepley /*@ 394345480ffeSMatthew G. Knepley PetscDSCopyExactSolutions - Copy all exact solutions to the new problem 394445480ffeSMatthew G. Knepley 394545480ffeSMatthew G. Knepley Not collective 394645480ffeSMatthew G. Knepley 394745480ffeSMatthew G. Knepley Input Parameter: 394845480ffeSMatthew G. Knepley . ds - The PetscDS object 394945480ffeSMatthew G. Knepley 395045480ffeSMatthew G. Knepley Output Parameter: 395145480ffeSMatthew G. Knepley . newds - The PetscDS copy 395245480ffeSMatthew G. Knepley 395345480ffeSMatthew G. Knepley Level: intermediate 395445480ffeSMatthew G. Knepley 395545480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 395645480ffeSMatthew G. Knepley @*/ 395745480ffeSMatthew G. Knepley PetscErrorCode PetscDSCopyExactSolutions(PetscDS ds, PetscDS newds) 395845480ffeSMatthew G. Knepley { 395945480ffeSMatthew G. Knepley PetscSimplePointFunc sol; 396045480ffeSMatthew G. Knepley void *ctx; 396145480ffeSMatthew G. Knepley PetscInt Nf, f; 396245480ffeSMatthew G. Knepley PetscErrorCode ierr; 396345480ffeSMatthew G. Knepley 396445480ffeSMatthew G. Knepley PetscFunctionBegin; 396545480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 396645480ffeSMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 2); 396745480ffeSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 396845480ffeSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 396945480ffeSMatthew G. Knepley ierr = PetscDSGetExactSolution(ds, f, &sol, &ctx);CHKERRQ(ierr); 397045480ffeSMatthew G. Knepley ierr = PetscDSSetExactSolution(newds, f, sol, ctx);CHKERRQ(ierr); 397145480ffeSMatthew G. Knepley ierr = PetscDSGetExactSolutionTimeDerivative(ds, f, &sol, &ctx);CHKERRQ(ierr); 397245480ffeSMatthew G. Knepley ierr = PetscDSSetExactSolutionTimeDerivative(newds, f, sol, ctx);CHKERRQ(ierr); 397345480ffeSMatthew G. Knepley } 397445480ffeSMatthew G. Knepley PetscFunctionReturn(0); 397545480ffeSMatthew G. Knepley } 397645480ffeSMatthew G. Knepley 3977b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3978b1353e8eSMatthew G. Knepley { 3979df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3980b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3981b1353e8eSMatthew G. Knepley 3982b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3983b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3984b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3985b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3986b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3987df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3988df3a45bdSMatthew G. Knepley if (height > dim) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_OUTOFRANGE, "DS can only handle height in [0, %D], not %D", dim, height); 3989df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3990df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3991b1353e8eSMatthew G. Knepley PetscInt cdim; 3992b1353e8eSMatthew G. Knepley 3993df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3994b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3995df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3996b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3997b1353e8eSMatthew G. Knepley PetscFE subfe; 3998b1353e8eSMatthew G. Knepley PetscObject obj; 3999b1353e8eSMatthew G. Knepley PetscClassId id; 4000b1353e8eSMatthew G. Knepley 4001b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 4002b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 4003b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 4004b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 4005df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 4006b1353e8eSMatthew G. Knepley } 4007b1353e8eSMatthew G. Knepley } 4008df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 4009b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 4010b1353e8eSMatthew G. Knepley } 4011b1353e8eSMatthew G. Knepley 4012665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 4013c7bd5f0bSMatthew G. Knepley { 4014c7bd5f0bSMatthew G. Knepley PetscObject obj; 4015c7bd5f0bSMatthew G. Knepley PetscClassId id; 4016c7bd5f0bSMatthew G. Knepley PetscInt Nf; 4017c7bd5f0bSMatthew G. Knepley PetscErrorCode ierr; 4018c7bd5f0bSMatthew G. Knepley 4019c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 4020c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 4021665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 4022665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 4023c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 4024c7bd5f0bSMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 4025c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetDiscretization(ds, f, &obj);CHKERRQ(ierr); 4026665f567fSMatthew G. Knepley if (obj) { 4027c7bd5f0bSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 4028665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 4029665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 4030665f567fSMatthew G. Knepley } 4031c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 4032c7bd5f0bSMatthew G. Knepley } 4033c7bd5f0bSMatthew G. Knepley 40346528b96dSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS ds) 40352764a2aaSMatthew G. Knepley { 4036931fb3b8SToby Isaac PetscErrorCode ierr; 4037931fb3b8SToby Isaac 40382764a2aaSMatthew G. Knepley PetscFunctionBegin; 40396528b96dSMatthew G. Knepley ierr = PetscFree(ds->data);CHKERRQ(ierr); 40402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40412764a2aaSMatthew G. Knepley } 40422764a2aaSMatthew G. Knepley 40436528b96dSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS ds) 40442764a2aaSMatthew G. Knepley { 40452764a2aaSMatthew G. Knepley PetscFunctionBegin; 40466528b96dSMatthew G. Knepley ds->ops->setfromoptions = NULL; 40476528b96dSMatthew G. Knepley ds->ops->setup = NULL; 40486528b96dSMatthew G. Knepley ds->ops->view = NULL; 40496528b96dSMatthew G. Knepley ds->ops->destroy = PetscDSDestroy_Basic; 40502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40512764a2aaSMatthew G. Knepley } 40522764a2aaSMatthew G. Knepley 40532764a2aaSMatthew G. Knepley /*MC 40542764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 40552764a2aaSMatthew G. Knepley 40562764a2aaSMatthew G. Knepley Level: intermediate 40572764a2aaSMatthew G. Knepley 40582764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 40592764a2aaSMatthew G. Knepley M*/ 40602764a2aaSMatthew G. Knepley 40616528b96dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS ds) 40622764a2aaSMatthew G. Knepley { 40632764a2aaSMatthew G. Knepley PetscDS_Basic *b; 40642764a2aaSMatthew G. Knepley PetscErrorCode ierr; 40652764a2aaSMatthew G. Knepley 40662764a2aaSMatthew G. Knepley PetscFunctionBegin; 40676528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 40686528b96dSMatthew G. Knepley ierr = PetscNewLog(ds, &b);CHKERRQ(ierr); 40696528b96dSMatthew G. Knepley ds->data = b; 40702764a2aaSMatthew G. Knepley 40716528b96dSMatthew G. Knepley ierr = PetscDSInitialize_Basic(ds);CHKERRQ(ierr); 40722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 40732764a2aaSMatthew G. Knepley } 4074