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 } 1797d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1804727e194SMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 1815d160056SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1827d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1837d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1845d160056SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 18540967b3bSMatthew G. Knepley 18640967b3bSMatthew G. Knepley for (b = prob->boundary; b; b = b->next) { 18740967b3bSMatthew G. Knepley PetscInt c, i; 18840967b3bSMatthew G. Knepley 18940967b3bSMatthew G. Knepley if (b->field != f) continue; 19040967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 19140967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->labelname, DMBoundaryConditionTypes[b->type]);CHKERRQ(ierr); 19240967b3bSMatthew G. Knepley if (!b->numcomps) { 19340967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " all components\n");CHKERRQ(ierr); 19440967b3bSMatthew G. Knepley } else { 19540967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " components: ");CHKERRQ(ierr); 19640967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 19740967b3bSMatthew G. Knepley for (c = 0; c < b->numcomps; ++c) { 19840967b3bSMatthew G. Knepley if (c > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 19940967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->comps[c]);CHKERRQ(ierr); 20040967b3bSMatthew G. Knepley } 20140967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 20240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 20340967b3bSMatthew G. Knepley } 20440967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " ids: ");CHKERRQ(ierr); 20540967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 20640967b3bSMatthew G. Knepley for (i = 0; i < b->numids; ++i) { 20740967b3bSMatthew G. Knepley if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 20840967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->ids[i]);CHKERRQ(ierr); 20940967b3bSMatthew G. Knepley } 21040967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 21140967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 21240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 21340967b3bSMatthew G. Knepley } 2147d8a60eaSMatthew G. Knepley } 21597b6e6e8SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &numConstants, &constants);CHKERRQ(ierr); 21697b6e6e8SMatthew G. Knepley if (numConstants) { 21797b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D constants\n", numConstants);CHKERRQ(ierr); 21897b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 21957fc01e9SMatthew G. Knepley for (f = 0; f < numConstants; ++f) {ierr = PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]));CHKERRQ(ierr);} 22097b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 22197b6e6e8SMatthew G. Knepley } 2227d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 2237d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 2247d8a60eaSMatthew G. Knepley } 2257d8a60eaSMatthew G. Knepley 2262764a2aaSMatthew G. Knepley /*@C 227fe2efc57SMark PetscDSViewFromOptions - View from Options 228fe2efc57SMark 229fe2efc57SMark Collective on PetscDS 230fe2efc57SMark 231fe2efc57SMark Input Parameters: 232fe2efc57SMark + A - the PetscDS object 233736c3998SJose E. Roman . obj - Optional object 234736c3998SJose E. Roman - name - command line option 235fe2efc57SMark 236fe2efc57SMark Level: intermediate 237fe2efc57SMark .seealso: PetscDS, PetscDSView, PetscObjectViewFromOptions(), PetscDSCreate() 238fe2efc57SMark @*/ 239fe2efc57SMark PetscErrorCode PetscDSViewFromOptions(PetscDS A,PetscObject obj,const char name[]) 240fe2efc57SMark { 241fe2efc57SMark PetscErrorCode ierr; 242fe2efc57SMark 243fe2efc57SMark PetscFunctionBegin; 244fe2efc57SMark PetscValidHeaderSpecific(A,PETSCDS_CLASSID,1); 245fe2efc57SMark ierr = PetscObjectViewFromOptions((PetscObject)A,obj,name);CHKERRQ(ierr); 246fe2efc57SMark PetscFunctionReturn(0); 247fe2efc57SMark } 248fe2efc57SMark 249fe2efc57SMark /*@C 2502764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 2512764a2aaSMatthew G. Knepley 252d083f849SBarry Smith Collective on prob 2532764a2aaSMatthew G. Knepley 2542764a2aaSMatthew G. Knepley Input Parameter: 2552764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 2562764a2aaSMatthew G. Knepley - v - the viewer 2572764a2aaSMatthew G. Knepley 2582764a2aaSMatthew G. Knepley Level: developer 2592764a2aaSMatthew G. Knepley 2602764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 2612764a2aaSMatthew G. Knepley @*/ 2622764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2632764a2aaSMatthew G. Knepley { 2647d8a60eaSMatthew G. Knepley PetscBool iascii; 2652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2662764a2aaSMatthew G. Knepley 2672764a2aaSMatthew G. Knepley PetscFunctionBegin; 2682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2692764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 2707d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2717d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2727d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2732764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2742764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2752764a2aaSMatthew G. Knepley } 2762764a2aaSMatthew G. Knepley 2772764a2aaSMatthew G. Knepley /*@ 2782764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2792764a2aaSMatthew G. Knepley 280d083f849SBarry Smith Collective on prob 2812764a2aaSMatthew G. Knepley 2822764a2aaSMatthew G. Knepley Input Parameter: 2832764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2842764a2aaSMatthew G. Knepley 2852764a2aaSMatthew G. Knepley Options Database: 28655c1f793SMatthew G. Knepley + -petscds_type <type> : Set the DS type 28755c1f793SMatthew G. Knepley . -petscds_view <view opt> : View the DS 28855c1f793SMatthew G. Knepley . -petscds_jac_pre : Turn formation of a separate Jacobian preconditioner on and off 28955c1f793SMatthew G. Knepley . -bc_<name> <ids> : Specify a list of label ids for a boundary condition 29055c1f793SMatthew G. Knepley - -bc_<name>_comp <comps> : Specify a list of field components to constrain for a boundary condition 2912764a2aaSMatthew G. Knepley 2922764a2aaSMatthew G. Knepley Level: developer 2932764a2aaSMatthew G. Knepley 2942764a2aaSMatthew G. Knepley .seealso PetscDSView() 2952764a2aaSMatthew G. Knepley @*/ 2962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2972764a2aaSMatthew G. Knepley { 298f1fd5e65SToby Isaac DSBoundary b; 2992764a2aaSMatthew G. Knepley const char *defaultType; 3002764a2aaSMatthew G. Knepley char name[256]; 3012764a2aaSMatthew G. Knepley PetscBool flg; 3022764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3032764a2aaSMatthew G. Knepley 3042764a2aaSMatthew G. Knepley PetscFunctionBegin; 3052764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3062764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3072764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3082764a2aaSMatthew G. Knepley } else { 3092764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3102764a2aaSMatthew G. Knepley } 3110f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 3122764a2aaSMatthew G. Knepley 3132764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 314f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 315f1fd5e65SToby Isaac char optname[1024]; 316f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 317f1fd5e65SToby Isaac PetscBool flg; 318f1fd5e65SToby Isaac 319f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name);CHKERRQ(ierr); 320f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 321f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg);CHKERRQ(ierr); 322f1fd5e65SToby Isaac if (flg) { 323f1fd5e65SToby Isaac b->numids = len; 324f1fd5e65SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 325f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->ids);CHKERRQ(ierr); 326580bdb30SBarry Smith ierr = PetscArraycpy(b->ids, ids, len);CHKERRQ(ierr); 327f1fd5e65SToby Isaac } 328e7b0402cSSander Arens len = 1024; 329f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name);CHKERRQ(ierr); 330f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 331f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg);CHKERRQ(ierr); 332f1fd5e65SToby Isaac if (flg) { 333f1fd5e65SToby Isaac b->numcomps = len; 334f1fd5e65SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 335f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->comps);CHKERRQ(ierr); 336580bdb30SBarry Smith ierr = PetscArraycpy(b->comps, ids, len);CHKERRQ(ierr); 337f1fd5e65SToby Isaac } 338f1fd5e65SToby Isaac } 3392764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 3402764a2aaSMatthew G. Knepley if (flg) { 3412764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 3422764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3432764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 3442764a2aaSMatthew G. Knepley } 34555c1f793SMatthew G. Knepley ierr = PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg);CHKERRQ(ierr); 3462764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 3472764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3480633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 3492764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 3505d160056SMatthew G. Knepley if (prob->Nf) {ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);} 3512764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3522764a2aaSMatthew G. Knepley } 3532764a2aaSMatthew G. Knepley 3542764a2aaSMatthew G. Knepley /*@C 3552764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3562764a2aaSMatthew G. Knepley 357d083f849SBarry Smith Collective on prob 3582764a2aaSMatthew G. Knepley 3592764a2aaSMatthew G. Knepley Input Parameter: 3602764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3612764a2aaSMatthew G. Knepley 3622764a2aaSMatthew G. Knepley Level: developer 3632764a2aaSMatthew G. Knepley 3642764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3652764a2aaSMatthew G. Knepley @*/ 3662764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3672764a2aaSMatthew G. Knepley { 3682764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 3694bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3702764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3712764a2aaSMatthew G. Knepley 3722764a2aaSMatthew G. Knepley PetscFunctionBegin; 3732764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3742764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3752764a2aaSMatthew G. Knepley /* Calculate sizes */ 3762764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 377d1506c7cSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &dimEmbed);CHKERRQ(ierr); 378f744cafaSSander Arens prob->totDim = prob->totComp = 0; 37947e57110SSander Arens ierr = PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb);CHKERRQ(ierr); 380f744cafaSSander Arens ierr = PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer);CHKERRQ(ierr); 381ef0bb6c7SMatthew G. Knepley ierr = PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf);CHKERRQ(ierr); 3822764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3839de99aefSMatthew G. Knepley PetscObject obj; 3849de99aefSMatthew G. Knepley PetscClassId id; 385665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 3869de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3872764a2aaSMatthew G. Knepley 3889de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 389665f567fSMatthew G. Knepley if (!obj) { 390665f567fSMatthew G. Knepley /* Empty mesh */ 391665f567fSMatthew G. Knepley Nb = Nc = 0; 392665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 393665f567fSMatthew G. Knepley } else { 3949de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3959de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3969de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3979de99aefSMatthew G. Knepley 3982764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3992764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 4002764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 401ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetCellTabulation(fe, &prob->T[f]);CHKERRQ(ierr); 402ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetFaceTabulation(fe, &prob->Tf[f]);CHKERRQ(ierr); 4039de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4049de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4059de99aefSMatthew G. Knepley 4069de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 4079de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 4089c3cf19fSMatthew G. Knepley Nb = Nc; 409ef0bb6c7SMatthew G. Knepley ierr = PetscFVGetCellTabulation(fv, &prob->T[f]);CHKERRQ(ierr); 4104d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 411abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 412665f567fSMatthew G. Knepley } 41347e57110SSander Arens prob->Nc[f] = Nc; 41447e57110SSander Arens prob->Nb[f] = Nb; 415194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 416194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 417a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 4182764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4194bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4202764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4219c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4222764a2aaSMatthew G. Knepley prob->totComp += Nc; 42394a5e212SMatthew G. Knepley /* There are two faces for all fields but the cohesive field on a hybrid cell */ 42494a5e212SMatthew G. Knepley if (prob->isHybrid && (f < Nf-1)) prob->totDim += Nb; 4252764a2aaSMatthew G. Knepley } 4262764a2aaSMatthew G. Knepley /* Allocate works space */ 42794a5e212SMatthew G. Knepley if (prob->isHybrid) NsMax = 2; 4284bee2e38SMatthew G. Knepley ierr = PetscMalloc3(NsMax*prob->totComp,&prob->u,NsMax*prob->totComp,&prob->u_t,NsMax*prob->totComp*dimEmbed,&prob->u_x);CHKERRQ(ierr); 4294bee2e38SMatthew 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); 43027f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 43127f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 43227f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4332764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 4342764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4362764a2aaSMatthew G. Knepley } 4372764a2aaSMatthew G. Knepley 4382764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4392764a2aaSMatthew G. Knepley { 4402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4412764a2aaSMatthew G. Knepley 4422764a2aaSMatthew G. Knepley PetscFunctionBegin; 44347e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 444f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 445ef0bb6c7SMatthew G. Knepley ierr = PetscFree2(prob->T,prob->Tf);CHKERRQ(ierr); 4464bee2e38SMatthew G. Knepley ierr = PetscFree3(prob->u,prob->u_t,prob->u_x);CHKERRQ(ierr); 4474bee2e38SMatthew G. Knepley ierr = PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal);CHKERRQ(ierr); 4482764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 4492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4502764a2aaSMatthew G. Knepley } 4512764a2aaSMatthew G. Knepley 4522764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4532764a2aaSMatthew G. Knepley { 454f744cafaSSander Arens PetscObject *tmpd; 45534aa8a36SMatthew G. Knepley PetscBool *tmpi; 45632d2bbc9SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf, *tmpup; 457b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 4582aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 45927f02ce8SMatthew G. Knepley PetscBdPointJac *tmpgbd, *tmpgpbd; 460194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 461*f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 462*f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4630c2f2876SMatthew G. Knepley void **tmpctx; 46434aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4662764a2aaSMatthew G. Knepley 4672764a2aaSMatthew G. Knepley PetscFunctionBegin; 4682764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4692764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4702764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 47134aa8a36SMatthew G. Knepley ierr = PetscMalloc2(NfNew, &tmpd, NfNew, &tmpi);CHKERRQ(ierr); 47234aa8a36SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f];} 47334aa8a36SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE;} 47434aa8a36SMatthew G. Knepley ierr = PetscFree2(prob->disc, prob->implicit);CHKERRQ(ierr); 4752764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4762764a2aaSMatthew G. Knepley prob->disc = tmpd; 477249df284SMatthew G. Knepley prob->implicit = tmpi; 478b7e05686SMatthew G. Knepley ierr = PetscCalloc7(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew*NfNew*4, &tmpgp, NfNew*NfNew*4, &tmpgt, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 47932d2bbc9SMatthew G. Knepley ierr = PetscCalloc1(NfNew, &tmpup);CHKERRQ(ierr); 4802764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4812764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4822764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 483475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4840c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 48532d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4860c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4872764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4882764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4892764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 490475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 491b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4920c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 49332d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4940c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 495b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 49632d2bbc9SMatthew G. Knepley ierr = PetscFree(prob->update);CHKERRQ(ierr); 4972764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4982764a2aaSMatthew G. Knepley prob->f = tmpf; 4992764a2aaSMatthew G. Knepley prob->g = tmpg; 500475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 501b7e05686SMatthew G. Knepley prob->gt = tmpgt; 5020c2f2876SMatthew G. Knepley prob->r = tmpr; 50332d2bbc9SMatthew G. Knepley prob->update = tmpup; 5040c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 505*f2cacb80SMatthew G. Knepley ierr = PetscCalloc7(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd, NfNew*NfNew*4, &tmpgpbd, NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t);CHKERRQ(ierr); 5062764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 5072764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 50827f02ce8SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgpbd[f] = prob->gpBd[f]; 509c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 51095cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 511*f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 512*f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 5132764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 5142764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 51527f02ce8SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgpbd[f] = NULL; 516c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 51795cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 518*f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 519*f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 520*f2cacb80SMatthew G. Knepley ierr = PetscFree7(prob->fBd, prob->gBd, prob->gpBd, prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t);CHKERRQ(ierr); 5212764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 5222764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 52327f02ce8SMatthew G. Knepley prob->gpBd = tmpgpbd; 524c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 52595cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 526*f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 527*f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5282764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5292764a2aaSMatthew G. Knepley } 5302764a2aaSMatthew G. Knepley 5312764a2aaSMatthew G. Knepley /*@ 5322764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5332764a2aaSMatthew G. Knepley 534d083f849SBarry Smith Collective on prob 5352764a2aaSMatthew G. Knepley 5362764a2aaSMatthew G. Knepley Input Parameter: 5372764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5382764a2aaSMatthew G. Knepley 5392764a2aaSMatthew G. Knepley Level: developer 5402764a2aaSMatthew G. Knepley 5412764a2aaSMatthew G. Knepley .seealso PetscDSView() 5422764a2aaSMatthew G. Knepley @*/ 5432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 5442764a2aaSMatthew G. Knepley { 5452764a2aaSMatthew G. Knepley PetscInt f; 54658ebd649SToby Isaac DSBoundary next; 5472764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5482764a2aaSMatthew G. Knepley 5492764a2aaSMatthew G. Knepley PetscFunctionBegin; 5502764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 5512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 5522764a2aaSMatthew G. Knepley 5532764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 5542764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 555df3a45bdSMatthew G. Knepley if ((*prob)->subprobs) { 556df3a45bdSMatthew G. Knepley PetscInt dim, d; 557df3a45bdSMatthew G. Knepley 558df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*prob, &dim);CHKERRQ(ierr); 559df3a45bdSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*prob)->subprobs[d]);CHKERRQ(ierr);} 560df3a45bdSMatthew G. Knepley } 561df3a45bdSMatthew G. Knepley ierr = PetscFree((*prob)->subprobs);CHKERRQ(ierr); 5622764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 5632764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 5642764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 5652764a2aaSMatthew G. Knepley } 56634aa8a36SMatthew G. Knepley ierr = PetscFree2((*prob)->disc, (*prob)->implicit);CHKERRQ(ierr); 567b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 56832d2bbc9SMatthew G. Knepley ierr = PetscFree((*prob)->update);CHKERRQ(ierr); 569*f2cacb80SMatthew G. Knepley ierr = PetscFree7((*prob)->fBd,(*prob)->gBd,(*prob)->gpBd,(*prob)->exactSol,(*prob)->exactCtx,(*prob)->exactSol_t,(*prob)->exactCtx_t);CHKERRQ(ierr); 5702764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 57158ebd649SToby Isaac next = (*prob)->boundary; 57258ebd649SToby Isaac while (next) { 57358ebd649SToby Isaac DSBoundary b = next; 57458ebd649SToby Isaac 57558ebd649SToby Isaac next = b->next; 57658ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 57758ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 57858ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 57958ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 58058ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 58158ebd649SToby Isaac } 58297b6e6e8SMatthew G. Knepley ierr = PetscFree((*prob)->constants);CHKERRQ(ierr); 5832764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 5842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5852764a2aaSMatthew G. Knepley } 5862764a2aaSMatthew G. Knepley 5872764a2aaSMatthew G. Knepley /*@ 5882764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5892764a2aaSMatthew G. Knepley 590d083f849SBarry Smith Collective 5912764a2aaSMatthew G. Knepley 5922764a2aaSMatthew G. Knepley Input Parameter: 5932764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5942764a2aaSMatthew G. Knepley 5952764a2aaSMatthew G. Knepley Output Parameter: 5962764a2aaSMatthew G. Knepley . prob - The PetscDS object 5972764a2aaSMatthew G. Knepley 5982764a2aaSMatthew G. Knepley Level: beginner 5992764a2aaSMatthew G. Knepley 6002764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 6012764a2aaSMatthew G. Knepley @*/ 6022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 6032764a2aaSMatthew G. Knepley { 6042764a2aaSMatthew G. Knepley PetscDS p; 6052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6062764a2aaSMatthew G. Knepley 6072764a2aaSMatthew G. Knepley PetscFunctionBegin; 6082764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 6092764a2aaSMatthew G. Knepley *prob = NULL; 6102764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 6112764a2aaSMatthew G. Knepley 61273107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 6132764a2aaSMatthew G. Knepley 6142764a2aaSMatthew G. Knepley p->Nf = 0; 6152764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 61697b6e6e8SMatthew G. Knepley p->numConstants = 0; 61797b6e6e8SMatthew G. Knepley p->constants = NULL; 618a859676bSMatthew G. Knepley p->dimEmbed = -1; 61955c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 6202764a2aaSMatthew G. Knepley 6212764a2aaSMatthew G. Knepley *prob = p; 6222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6232764a2aaSMatthew G. Knepley } 6242764a2aaSMatthew G. Knepley 625bc4ae4beSMatthew G. Knepley /*@ 626bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 627bc4ae4beSMatthew G. Knepley 628bc4ae4beSMatthew G. Knepley Not collective 629bc4ae4beSMatthew G. Knepley 630bc4ae4beSMatthew G. Knepley Input Parameter: 631bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 632bc4ae4beSMatthew G. Knepley 633bc4ae4beSMatthew G. Knepley Output Parameter: 634bc4ae4beSMatthew G. Knepley . Nf - The number of fields 635bc4ae4beSMatthew G. Knepley 636bc4ae4beSMatthew G. Knepley Level: beginner 637bc4ae4beSMatthew G. Knepley 638bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 639bc4ae4beSMatthew G. Knepley @*/ 6402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6412764a2aaSMatthew G. Knepley { 6422764a2aaSMatthew G. Knepley PetscFunctionBegin; 6432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6442764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6452764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6462764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6472764a2aaSMatthew G. Knepley } 6482764a2aaSMatthew G. Knepley 649bc4ae4beSMatthew G. Knepley /*@ 650a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 651bc4ae4beSMatthew G. Knepley 652bc4ae4beSMatthew G. Knepley Not collective 653bc4ae4beSMatthew G. Knepley 654bc4ae4beSMatthew G. Knepley Input Parameter: 655bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 656bc4ae4beSMatthew G. Knepley 657bc4ae4beSMatthew G. Knepley Output Parameter: 658bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 659bc4ae4beSMatthew G. Knepley 660bc4ae4beSMatthew G. Knepley Level: beginner 661bc4ae4beSMatthew G. Knepley 662a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 663bc4ae4beSMatthew G. Knepley @*/ 6642764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6652764a2aaSMatthew G. Knepley { 6662764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6672764a2aaSMatthew G. Knepley 6682764a2aaSMatthew G. Knepley PetscFunctionBegin; 6692764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6702764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6712764a2aaSMatthew G. Knepley *dim = 0; 6729de99aefSMatthew G. Knepley if (prob->Nf) { 6739de99aefSMatthew G. Knepley PetscObject obj; 6749de99aefSMatthew G. Knepley PetscClassId id; 6759de99aefSMatthew G. Knepley 6769de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 677665f567fSMatthew G. Knepley if (obj) { 6789de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 6799de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 6809de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 6819de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6829de99aefSMatthew G. Knepley } 683665f567fSMatthew G. Knepley } 6842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6852764a2aaSMatthew G. Knepley } 6862764a2aaSMatthew G. Knepley 687bc4ae4beSMatthew G. Knepley /*@ 688a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 689a859676bSMatthew G. Knepley 690a859676bSMatthew G. Knepley Not collective 691a859676bSMatthew G. Knepley 692a859676bSMatthew G. Knepley Input Parameter: 693a859676bSMatthew G. Knepley . prob - The PetscDS object 694a859676bSMatthew G. Knepley 695a859676bSMatthew G. Knepley Output Parameter: 696a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 697a859676bSMatthew G. Knepley 698a859676bSMatthew G. Knepley Level: beginner 699a859676bSMatthew G. Knepley 700a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 701a859676bSMatthew G. Knepley @*/ 702a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 703a859676bSMatthew G. Knepley { 704a859676bSMatthew G. Knepley PetscFunctionBegin; 705a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 706a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 707a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 708a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 709a859676bSMatthew G. Knepley PetscFunctionReturn(0); 710a859676bSMatthew G. Knepley } 711a859676bSMatthew G. Knepley 712a859676bSMatthew G. Knepley /*@ 713a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 714a859676bSMatthew G. Knepley 715d083f849SBarry Smith Logically collective on prob 716a859676bSMatthew G. Knepley 717a859676bSMatthew G. Knepley Input Parameters: 718a859676bSMatthew G. Knepley + prob - The PetscDS object 719a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 720a859676bSMatthew G. Knepley 721a859676bSMatthew G. Knepley Level: beginner 722a859676bSMatthew G. Knepley 723a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 724a859676bSMatthew G. Knepley @*/ 725a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 726a859676bSMatthew G. Knepley { 727a859676bSMatthew G. Knepley PetscFunctionBegin; 728a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 729ebfe4b0dSMatthew G. Knepley if (dimEmbed < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 730a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 731a859676bSMatthew G. Knepley PetscFunctionReturn(0); 732a859676bSMatthew G. Knepley } 733a859676bSMatthew G. Knepley 734a859676bSMatthew G. Knepley /*@ 7358edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 7368edf6225SMatthew G. Knepley 7378edf6225SMatthew G. Knepley Not collective 7388edf6225SMatthew G. Knepley 7398edf6225SMatthew G. Knepley Input Parameter: 7408edf6225SMatthew G. Knepley . prob - The PetscDS object 7418edf6225SMatthew G. Knepley 7428edf6225SMatthew G. Knepley Output Parameter: 7438edf6225SMatthew G. Knepley . isHybrid - The flag 7448edf6225SMatthew G. Knepley 7458edf6225SMatthew G. Knepley Level: developer 7468edf6225SMatthew G. Knepley 7478edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 7488edf6225SMatthew G. Knepley @*/ 7498edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 7508edf6225SMatthew G. Knepley { 7518edf6225SMatthew G. Knepley PetscFunctionBegin; 7528edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7538edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 7548edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 7558edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7568edf6225SMatthew G. Knepley } 7578edf6225SMatthew G. Knepley 7588edf6225SMatthew G. Knepley /*@ 7598edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 7608edf6225SMatthew G. Knepley 7618edf6225SMatthew G. Knepley Not collective 7628edf6225SMatthew G. Knepley 7638edf6225SMatthew G. Knepley Input Parameters: 7648edf6225SMatthew G. Knepley + prob - The PetscDS object 7658edf6225SMatthew G. Knepley - isHybrid - The flag 7668edf6225SMatthew G. Knepley 7678edf6225SMatthew G. Knepley Level: developer 7688edf6225SMatthew G. Knepley 7698edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 7708edf6225SMatthew G. Knepley @*/ 7718edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 7728edf6225SMatthew G. Knepley { 7738edf6225SMatthew G. Knepley PetscFunctionBegin; 7748edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7758edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 7768edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7778edf6225SMatthew G. Knepley } 7788edf6225SMatthew G. Knepley 7798edf6225SMatthew G. Knepley /*@ 780bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 781bc4ae4beSMatthew G. Knepley 782bc4ae4beSMatthew G. Knepley Not collective 783bc4ae4beSMatthew G. Knepley 784bc4ae4beSMatthew G. Knepley Input Parameter: 785bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 786bc4ae4beSMatthew G. Knepley 787bc4ae4beSMatthew G. Knepley Output Parameter: 788bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 789bc4ae4beSMatthew G. Knepley 790bc4ae4beSMatthew G. Knepley Level: beginner 791bc4ae4beSMatthew G. Knepley 792bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 793bc4ae4beSMatthew G. Knepley @*/ 7942764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7952764a2aaSMatthew G. Knepley { 7962764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7972764a2aaSMatthew G. Knepley 7982764a2aaSMatthew G. Knepley PetscFunctionBegin; 7992764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8002764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8012764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 8022764a2aaSMatthew G. Knepley *dim = prob->totDim; 8032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8042764a2aaSMatthew G. Knepley } 8052764a2aaSMatthew G. Knepley 806bc4ae4beSMatthew G. Knepley /*@ 807bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 808bc4ae4beSMatthew G. Knepley 809bc4ae4beSMatthew G. Knepley Not collective 810bc4ae4beSMatthew G. Knepley 811bc4ae4beSMatthew G. Knepley Input Parameter: 812bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 813bc4ae4beSMatthew G. Knepley 814bc4ae4beSMatthew G. Knepley Output Parameter: 815bc4ae4beSMatthew G. Knepley . dim - The total number of components 816bc4ae4beSMatthew G. Knepley 817bc4ae4beSMatthew G. Knepley Level: beginner 818bc4ae4beSMatthew G. Knepley 819bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 820bc4ae4beSMatthew G. Knepley @*/ 8212764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8222764a2aaSMatthew G. Knepley { 8232764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8242764a2aaSMatthew G. Knepley 8252764a2aaSMatthew G. Knepley PetscFunctionBegin; 8262764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8272764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8282764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8292764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8302764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8312764a2aaSMatthew G. Knepley } 8322764a2aaSMatthew G. Knepley 833bc4ae4beSMatthew G. Knepley /*@ 834bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 835bc4ae4beSMatthew G. Knepley 836bc4ae4beSMatthew G. Knepley Not collective 837bc4ae4beSMatthew G. Knepley 838bc4ae4beSMatthew G. Knepley Input Parameters: 839bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 840bc4ae4beSMatthew G. Knepley - f - The field number 841bc4ae4beSMatthew G. Knepley 842bc4ae4beSMatthew G. Knepley Output Parameter: 843bc4ae4beSMatthew G. Knepley . disc - The discretization object 844bc4ae4beSMatthew G. Knepley 845bc4ae4beSMatthew G. Knepley Level: beginner 846bc4ae4beSMatthew G. Knepley 847f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 848bc4ae4beSMatthew G. Knepley @*/ 8492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8502764a2aaSMatthew G. Knepley { 8512764a2aaSMatthew G. Knepley PetscFunctionBegin; 8522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8532764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8542764a2aaSMatthew 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); 8552764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8572764a2aaSMatthew G. Knepley } 8582764a2aaSMatthew G. Knepley 859bc4ae4beSMatthew G. Knepley /*@ 860bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 861bc4ae4beSMatthew G. Knepley 862bc4ae4beSMatthew G. Knepley Not collective 863bc4ae4beSMatthew G. Knepley 864bc4ae4beSMatthew G. Knepley Input Parameters: 865bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 866bc4ae4beSMatthew G. Knepley . f - The field number 867bc4ae4beSMatthew G. Knepley - disc - The discretization object 868bc4ae4beSMatthew G. Knepley 869bc4ae4beSMatthew G. Knepley Level: beginner 870bc4ae4beSMatthew G. Knepley 871bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 872bc4ae4beSMatthew G. Knepley @*/ 8732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 8742764a2aaSMatthew G. Knepley { 8752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8762764a2aaSMatthew G. Knepley 8772764a2aaSMatthew G. Knepley PetscFunctionBegin; 8782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 879665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 8802764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 8812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 882c10f2116SMatthew G. Knepley ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr); 8832764a2aaSMatthew G. Knepley prob->disc[f] = disc; 8842764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 885665f567fSMatthew G. Knepley if (disc) { 886249df284SMatthew G. Knepley PetscClassId id; 887249df284SMatthew G. Knepley 888249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8891cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8901cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8911cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8921cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 893a6cbbb48SMatthew G. Knepley } 894249df284SMatthew G. Knepley } 8952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8962764a2aaSMatthew G. Knepley } 8972764a2aaSMatthew G. Knepley 898bc4ae4beSMatthew G. Knepley /*@ 899bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 900bc4ae4beSMatthew G. Knepley 901bc4ae4beSMatthew G. Knepley Not collective 902bc4ae4beSMatthew G. Knepley 903bc4ae4beSMatthew G. Knepley Input Parameters: 904bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 905bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 906bc4ae4beSMatthew G. Knepley 907bc4ae4beSMatthew G. Knepley Level: beginner 908bc4ae4beSMatthew G. Knepley 909bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 910bc4ae4beSMatthew G. Knepley @*/ 9112764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9122764a2aaSMatthew G. Knepley { 9132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9142764a2aaSMatthew G. Knepley 9152764a2aaSMatthew G. Knepley PetscFunctionBegin; 9162764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 9172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9182764a2aaSMatthew G. Knepley } 9192764a2aaSMatthew G. Knepley 920249df284SMatthew G. Knepley /*@ 921083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 922083401c6SMatthew G. Knepley 923083401c6SMatthew G. Knepley Not collective 924083401c6SMatthew G. Knepley 925083401c6SMatthew G. Knepley Input Parameter: 926083401c6SMatthew G. Knepley . prob - The PetscDS object 927083401c6SMatthew G. Knepley 928083401c6SMatthew G. Knepley Output Parameter: 929083401c6SMatthew G. Knepley . q - The quadrature object 930083401c6SMatthew G. Knepley 931083401c6SMatthew G. Knepley Level: intermediate 932083401c6SMatthew G. Knepley 933083401c6SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 934083401c6SMatthew G. Knepley @*/ 935083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 936083401c6SMatthew G. Knepley { 937083401c6SMatthew G. Knepley PetscObject obj; 938083401c6SMatthew G. Knepley PetscClassId id; 939083401c6SMatthew G. Knepley PetscErrorCode ierr; 940083401c6SMatthew G. Knepley 941083401c6SMatthew G. Knepley PetscFunctionBegin; 942083401c6SMatthew G. Knepley *q = NULL; 943083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 944083401c6SMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 945083401c6SMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 946083401c6SMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetQuadrature((PetscFE) obj, q);CHKERRQ(ierr);} 947083401c6SMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetQuadrature((PetscFV) obj, q);CHKERRQ(ierr);} 948083401c6SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 949083401c6SMatthew G. Knepley PetscFunctionReturn(0); 950083401c6SMatthew G. Knepley } 951083401c6SMatthew G. Knepley 952083401c6SMatthew G. Knepley /*@ 953249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 954249df284SMatthew G. Knepley 955249df284SMatthew G. Knepley Not collective 956249df284SMatthew G. Knepley 957249df284SMatthew G. Knepley Input Parameters: 958249df284SMatthew G. Knepley + prob - The PetscDS object 959249df284SMatthew G. Knepley - f - The field number 960249df284SMatthew G. Knepley 961249df284SMatthew G. Knepley Output Parameter: 962249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 963249df284SMatthew G. Knepley 964249df284SMatthew G. Knepley Level: developer 965249df284SMatthew G. Knepley 966f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 967249df284SMatthew G. Knepley @*/ 968249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 969249df284SMatthew G. Knepley { 970249df284SMatthew G. Knepley PetscFunctionBegin; 971249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 972249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 973249df284SMatthew 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); 974249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 975249df284SMatthew G. Knepley PetscFunctionReturn(0); 976249df284SMatthew G. Knepley } 977249df284SMatthew G. Knepley 978249df284SMatthew G. Knepley /*@ 979249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 980249df284SMatthew G. Knepley 981249df284SMatthew G. Knepley Not collective 982249df284SMatthew G. Knepley 983249df284SMatthew G. Knepley Input Parameters: 984249df284SMatthew G. Knepley + prob - The PetscDS object 985249df284SMatthew G. Knepley . f - The field number 986249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 987249df284SMatthew G. Knepley 988249df284SMatthew G. Knepley Level: developer 989249df284SMatthew G. Knepley 990f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 991249df284SMatthew G. Knepley @*/ 992249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 993249df284SMatthew G. Knepley { 994249df284SMatthew G. Knepley PetscFunctionBegin; 995249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 996249df284SMatthew 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); 997249df284SMatthew G. Knepley prob->implicit[f] = implicit; 998249df284SMatthew G. Knepley PetscFunctionReturn(0); 999249df284SMatthew G. Knepley } 1000249df284SMatthew G. Knepley 10012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 100230b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1003194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1004194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 100597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 10062764a2aaSMatthew G. Knepley { 10072764a2aaSMatthew G. Knepley PetscFunctionBegin; 10082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10092764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 10102764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 10112764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 10122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10132764a2aaSMatthew G. Knepley } 10142764a2aaSMatthew G. Knepley 10152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 101630b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1017194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1018194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 10202764a2aaSMatthew G. Knepley { 10212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 10222764a2aaSMatthew G. Knepley 10232764a2aaSMatthew G. Knepley PetscFunctionBegin; 10242764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1025de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 10262764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10272764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10282764a2aaSMatthew G. Knepley prob->obj[f] = obj; 10292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10302764a2aaSMatthew G. Knepley } 10312764a2aaSMatthew G. Knepley 1032194d53e6SMatthew G. Knepley /*@C 1033194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1034194d53e6SMatthew G. Knepley 1035194d53e6SMatthew G. Knepley Not collective 1036194d53e6SMatthew G. Knepley 1037194d53e6SMatthew G. Knepley Input Parameters: 1038194d53e6SMatthew G. Knepley + prob - The PetscDS 1039194d53e6SMatthew G. Knepley - f - The test field number 1040194d53e6SMatthew G. Knepley 1041194d53e6SMatthew G. Knepley Output Parameters: 1042194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1043194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1044194d53e6SMatthew G. Knepley 1045194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1046194d53e6SMatthew G. Knepley 1047194d53e6SMatthew 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) 1048194d53e6SMatthew G. Knepley 1049194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1050194d53e6SMatthew G. Knepley 105130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1052194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1053194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 105430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1055194d53e6SMatthew G. Knepley 1056194d53e6SMatthew G. Knepley + dim - the spatial dimension 1057194d53e6SMatthew G. Knepley . Nf - the number of fields 1058194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1059194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1060194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1061194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1062194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1063194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1064194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1065194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1066194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1067194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1068194d53e6SMatthew G. Knepley . t - current time 1069194d53e6SMatthew G. Knepley . x - coordinates of the current point 107097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 107197b6e6e8SMatthew G. Knepley . constants - constant parameters 1072194d53e6SMatthew G. Knepley - f0 - output values at the current point 1073194d53e6SMatthew G. Knepley 1074194d53e6SMatthew G. Knepley Level: intermediate 1075194d53e6SMatthew G. Knepley 1076194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1077194d53e6SMatthew G. Knepley @*/ 10782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 107930b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1080194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1081194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 108330b9ff8bSMatthew G. Knepley void (**f1)(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 f1[])) 10872764a2aaSMatthew G. Knepley { 10882764a2aaSMatthew G. Knepley PetscFunctionBegin; 10892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10902764a2aaSMatthew 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); 10912764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10922764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10942764a2aaSMatthew G. Knepley } 10952764a2aaSMatthew G. Knepley 1096194d53e6SMatthew G. Knepley /*@C 1097194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1098194d53e6SMatthew G. Knepley 1099194d53e6SMatthew G. Knepley Not collective 1100194d53e6SMatthew G. Knepley 1101194d53e6SMatthew G. Knepley Input Parameters: 1102194d53e6SMatthew G. Knepley + prob - The PetscDS 1103194d53e6SMatthew G. Knepley . f - The test field number 1104194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1105194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1106194d53e6SMatthew G. Knepley 1107194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1108194d53e6SMatthew G. Knepley 1109194d53e6SMatthew 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) 1110194d53e6SMatthew G. Knepley 1111194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1112194d53e6SMatthew G. Knepley 111330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1114194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1115194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 111630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1117194d53e6SMatthew G. Knepley 1118194d53e6SMatthew G. Knepley + dim - the spatial dimension 1119194d53e6SMatthew G. Knepley . Nf - the number of fields 1120194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1121194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1122194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1123194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1124194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1125194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1126194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1127194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1128194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1129194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1130194d53e6SMatthew G. Knepley . t - current time 1131194d53e6SMatthew G. Knepley . x - coordinates of the current point 113297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 113397b6e6e8SMatthew G. Knepley . constants - constant parameters 1134194d53e6SMatthew G. Knepley - f0 - output values at the current point 1135194d53e6SMatthew G. Knepley 1136194d53e6SMatthew G. Knepley Level: intermediate 1137194d53e6SMatthew G. Knepley 1138194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1139194d53e6SMatthew G. Knepley @*/ 11402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 114130b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1142194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1143194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 114497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 114530b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1146194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1147194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 114897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11492764a2aaSMatthew G. Knepley { 11502764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11512764a2aaSMatthew G. Knepley 11522764a2aaSMatthew G. Knepley PetscFunctionBegin; 11532764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1154f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1155f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11562764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11572764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11582764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11592764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11602764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11612764a2aaSMatthew G. Knepley } 11622764a2aaSMatthew G. Knepley 11633e75805dSMatthew G. Knepley /*@C 11643e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11653e75805dSMatthew G. Knepley 11663e75805dSMatthew G. Knepley Not collective 11673e75805dSMatthew G. Knepley 11683e75805dSMatthew G. Knepley Input Parameter: 11693e75805dSMatthew G. Knepley . prob - The PetscDS 11703e75805dSMatthew G. Knepley 11713e75805dSMatthew G. Knepley Output Parameter: 11723e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11733e75805dSMatthew G. Knepley 11743e75805dSMatthew G. Knepley Level: intermediate 11753e75805dSMatthew G. Knepley 11763e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11773e75805dSMatthew G. Knepley @*/ 11783e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11793e75805dSMatthew G. Knepley { 11803e75805dSMatthew G. Knepley PetscInt f, g, h; 11813e75805dSMatthew G. Knepley 11823e75805dSMatthew G. Knepley PetscFunctionBegin; 11833e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11843e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11853e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11863e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11873e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11883e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11893e75805dSMatthew G. Knepley } 11903e75805dSMatthew G. Knepley } 11913e75805dSMatthew G. Knepley } 11923e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11933e75805dSMatthew G. Knepley } 11943e75805dSMatthew G. Knepley 1195194d53e6SMatthew G. Knepley /*@C 1196194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1197194d53e6SMatthew G. Knepley 1198194d53e6SMatthew G. Knepley Not collective 1199194d53e6SMatthew G. Knepley 1200194d53e6SMatthew G. Knepley Input Parameters: 1201194d53e6SMatthew G. Knepley + prob - The PetscDS 1202194d53e6SMatthew G. Knepley . f - The test field number 1203194d53e6SMatthew G. Knepley - g - The field number 1204194d53e6SMatthew G. Knepley 1205194d53e6SMatthew G. Knepley Output Parameters: 1206194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1207194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1208194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1209194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1210194d53e6SMatthew G. Knepley 1211194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1212194d53e6SMatthew G. Knepley 1213194d53e6SMatthew 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 1214194d53e6SMatthew G. Knepley 1215194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1216194d53e6SMatthew G. Knepley 121730b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1218194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1219194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 122030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1221194d53e6SMatthew G. Knepley 1222194d53e6SMatthew G. Knepley + dim - the spatial dimension 1223194d53e6SMatthew G. Knepley . Nf - the number of fields 1224194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1225194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1226194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1227194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1228194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1229194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1230194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1231194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1232194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1233194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1234194d53e6SMatthew G. Knepley . t - current time 12352aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1236194d53e6SMatthew G. Knepley . x - coordinates of the current point 123797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 123897b6e6e8SMatthew G. Knepley . constants - constant parameters 1239194d53e6SMatthew G. Knepley - g0 - output values at the current point 1240194d53e6SMatthew G. Knepley 1241194d53e6SMatthew G. Knepley Level: intermediate 1242194d53e6SMatthew G. Knepley 1243194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1244194d53e6SMatthew G. Knepley @*/ 12452764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 124630b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1247194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1248194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 125030b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1251194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1252194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 125397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 125430b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1255194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1256194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 125797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 125830b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1259194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1260194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 126197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12622764a2aaSMatthew G. Knepley { 12632764a2aaSMatthew G. Knepley PetscFunctionBegin; 12642764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12652764a2aaSMatthew 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); 12662764a2aaSMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 12672764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12682764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12692764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12702764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12712764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12722764a2aaSMatthew G. Knepley } 12732764a2aaSMatthew G. Knepley 1274194d53e6SMatthew G. Knepley /*@C 1275194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1276194d53e6SMatthew G. Knepley 1277194d53e6SMatthew G. Knepley Not collective 1278194d53e6SMatthew G. Knepley 1279194d53e6SMatthew G. Knepley Input Parameters: 1280194d53e6SMatthew G. Knepley + prob - The PetscDS 1281194d53e6SMatthew G. Knepley . f - The test field number 1282194d53e6SMatthew G. Knepley . g - The field number 1283194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1284194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1285194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1286194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1287194d53e6SMatthew G. Knepley 1288194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1289194d53e6SMatthew G. Knepley 1290194d53e6SMatthew 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 1291194d53e6SMatthew G. Knepley 1292194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1293194d53e6SMatthew G. Knepley 129430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1295194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1296194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1298194d53e6SMatthew G. Knepley 1299194d53e6SMatthew G. Knepley + dim - the spatial dimension 1300194d53e6SMatthew G. Knepley . Nf - the number of fields 1301194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1302194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1303194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1304194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1305194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1306194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1307194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1308194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1309194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1310194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1311194d53e6SMatthew G. Knepley . t - current time 13122aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1313194d53e6SMatthew G. Knepley . x - coordinates of the current point 131497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 131597b6e6e8SMatthew G. Knepley . constants - constant parameters 1316194d53e6SMatthew G. Knepley - g0 - output values at the current point 1317194d53e6SMatthew G. Knepley 1318194d53e6SMatthew G. Knepley Level: intermediate 1319194d53e6SMatthew G. Knepley 1320194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1321194d53e6SMatthew G. Knepley @*/ 13222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 132330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1324194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1325194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 132697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 132730b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1328194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1329194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 133130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1332194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1333194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 133530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1336194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1337194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 13392764a2aaSMatthew G. Knepley { 13402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13412764a2aaSMatthew G. Knepley 13422764a2aaSMatthew G. Knepley PetscFunctionBegin; 13432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13442764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 13452764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 13462764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 13472764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13482764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13492764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13502764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13512764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13522764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13532764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13542764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13562764a2aaSMatthew G. Knepley } 13572764a2aaSMatthew G. Knepley 1358475e0ac9SMatthew G. Knepley /*@C 135955c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 136055c1f793SMatthew G. Knepley 136155c1f793SMatthew G. Knepley Not collective 136255c1f793SMatthew G. Knepley 136355c1f793SMatthew G. Knepley Input Parameters: 136455c1f793SMatthew G. Knepley + prob - The PetscDS 136555c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 136655c1f793SMatthew G. Knepley 136755c1f793SMatthew G. Knepley Level: intermediate 136855c1f793SMatthew G. Knepley 136955c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 137055c1f793SMatthew G. Knepley @*/ 137155c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 137255c1f793SMatthew G. Knepley { 137355c1f793SMatthew G. Knepley PetscFunctionBegin; 137455c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 137555c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 137655c1f793SMatthew G. Knepley PetscFunctionReturn(0); 137755c1f793SMatthew G. Knepley } 137855c1f793SMatthew G. Knepley 137955c1f793SMatthew G. Knepley /*@C 1380475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1381475e0ac9SMatthew G. Knepley 1382475e0ac9SMatthew G. Knepley Not collective 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew G. Knepley Input Parameter: 1385475e0ac9SMatthew G. Knepley . prob - The PetscDS 1386475e0ac9SMatthew G. Knepley 1387475e0ac9SMatthew G. Knepley Output Parameter: 1388475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1389475e0ac9SMatthew G. Knepley 1390475e0ac9SMatthew G. Knepley Level: intermediate 1391475e0ac9SMatthew G. Knepley 1392475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1393475e0ac9SMatthew G. Knepley @*/ 1394475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1395475e0ac9SMatthew G. Knepley { 1396475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1397475e0ac9SMatthew G. Knepley 1398475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1399475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1400475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 140155c1f793SMatthew G. Knepley if (!prob->useJacPre) PetscFunctionReturn(0); 1402475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1403475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1404475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1405475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1406475e0ac9SMatthew G. Knepley } 1407475e0ac9SMatthew G. Knepley } 1408475e0ac9SMatthew G. Knepley } 1409475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1410475e0ac9SMatthew G. Knepley } 1411475e0ac9SMatthew G. Knepley 1412475e0ac9SMatthew G. Knepley /*@C 1413475e0ac9SMatthew 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. 1414475e0ac9SMatthew G. Knepley 1415475e0ac9SMatthew G. Knepley Not collective 1416475e0ac9SMatthew G. Knepley 1417475e0ac9SMatthew G. Knepley Input Parameters: 1418475e0ac9SMatthew G. Knepley + prob - The PetscDS 1419475e0ac9SMatthew G. Knepley . f - The test field number 1420475e0ac9SMatthew G. Knepley - g - The field number 1421475e0ac9SMatthew G. Knepley 1422475e0ac9SMatthew G. Knepley Output Parameters: 1423475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1424475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1425475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1426475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1427475e0ac9SMatthew G. Knepley 1428475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1429475e0ac9SMatthew G. Knepley 1430475e0ac9SMatthew 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 1431475e0ac9SMatthew G. Knepley 1432475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1433475e0ac9SMatthew G. Knepley 1434475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1435475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1436475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1437475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1438475e0ac9SMatthew G. Knepley 1439475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1440475e0ac9SMatthew G. Knepley . Nf - the number of fields 1441475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1442475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1443475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1444475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1445475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1446475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1447475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1448475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1449475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1450475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1451475e0ac9SMatthew G. Knepley . t - current time 1452475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1453475e0ac9SMatthew G. Knepley . x - coordinates of the current point 145497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 145597b6e6e8SMatthew G. Knepley . constants - constant parameters 1456475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1457475e0ac9SMatthew G. Knepley 1458475e0ac9SMatthew G. Knepley Level: intermediate 1459475e0ac9SMatthew G. Knepley 1460475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1461475e0ac9SMatthew G. Knepley @*/ 1462475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1463475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1464475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1465475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1467475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1468475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1469475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 147097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1471475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1472475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1473475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 147497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1475475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1476475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1477475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 147897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1479475e0ac9SMatthew G. Knepley { 1480475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1481475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1482475e0ac9SMatthew 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); 1483475e0ac9SMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 1484475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1485475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1486475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1487475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1488475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1489475e0ac9SMatthew G. Knepley } 1490475e0ac9SMatthew G. Knepley 1491475e0ac9SMatthew G. Knepley /*@C 1492475e0ac9SMatthew 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. 1493475e0ac9SMatthew G. Knepley 1494475e0ac9SMatthew G. Knepley Not collective 1495475e0ac9SMatthew G. Knepley 1496475e0ac9SMatthew G. Knepley Input Parameters: 1497475e0ac9SMatthew G. Knepley + prob - The PetscDS 1498475e0ac9SMatthew G. Knepley . f - The test field number 1499475e0ac9SMatthew G. Knepley . g - The field number 1500475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1501475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1502475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1503475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1504475e0ac9SMatthew G. Knepley 1505475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1506475e0ac9SMatthew G. Knepley 1507475e0ac9SMatthew 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 1508475e0ac9SMatthew G. Knepley 1509475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1510475e0ac9SMatthew G. Knepley 1511475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1512475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1513475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1514475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1515475e0ac9SMatthew G. Knepley 1516475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1517475e0ac9SMatthew G. Knepley . Nf - the number of fields 1518475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1519475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1520475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1521475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1522475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1523475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1524475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1525475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1526475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1527475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1528475e0ac9SMatthew G. Knepley . t - current time 1529475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1530475e0ac9SMatthew G. Knepley . x - coordinates of the current point 153197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 153297b6e6e8SMatthew G. Knepley . constants - constant parameters 1533475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1534475e0ac9SMatthew G. Knepley 1535475e0ac9SMatthew G. Knepley Level: intermediate 1536475e0ac9SMatthew G. Knepley 1537475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1538475e0ac9SMatthew G. Knepley @*/ 1539475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1540475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1541475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1542475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1544475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1545475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1546475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1548475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1549475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1550475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1552475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1553475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1554475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1556475e0ac9SMatthew G. Knepley { 1557475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1558475e0ac9SMatthew G. Knepley 1559475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1560475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1561475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1562475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1563475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1564475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1565475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1566475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1567475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1568475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1569475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1570475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1571475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1572475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1573475e0ac9SMatthew G. Knepley } 1574475e0ac9SMatthew G. Knepley 1575b7e05686SMatthew G. Knepley /*@C 1576b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1577b7e05686SMatthew G. Knepley 1578b7e05686SMatthew G. Knepley Not collective 1579b7e05686SMatthew G. Knepley 1580b7e05686SMatthew G. Knepley Input Parameter: 1581b7e05686SMatthew G. Knepley . prob - The PetscDS 1582b7e05686SMatthew G. Knepley 1583b7e05686SMatthew G. Knepley Output Parameter: 1584b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1585b7e05686SMatthew G. Knepley 1586b7e05686SMatthew G. Knepley Level: intermediate 1587b7e05686SMatthew G. Knepley 1588b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1589b7e05686SMatthew G. Knepley @*/ 1590b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1591b7e05686SMatthew G. Knepley { 1592b7e05686SMatthew G. Knepley PetscInt f, g, h; 1593b7e05686SMatthew G. Knepley 1594b7e05686SMatthew G. Knepley PetscFunctionBegin; 1595b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1596b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1597b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1598b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1599b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1600b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1601b7e05686SMatthew G. Knepley } 1602b7e05686SMatthew G. Knepley } 1603b7e05686SMatthew G. Knepley } 1604b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1605b7e05686SMatthew G. Knepley } 1606b7e05686SMatthew G. Knepley 1607b7e05686SMatthew G. Knepley /*@C 1608b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1609b7e05686SMatthew G. Knepley 1610b7e05686SMatthew G. Knepley Not collective 1611b7e05686SMatthew G. Knepley 1612b7e05686SMatthew G. Knepley Input Parameters: 1613b7e05686SMatthew G. Knepley + prob - The PetscDS 1614b7e05686SMatthew G. Knepley . f - The test field number 1615b7e05686SMatthew G. Knepley - g - The field number 1616b7e05686SMatthew G. Knepley 1617b7e05686SMatthew G. Knepley Output Parameters: 1618b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1619b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1620b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1621b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1622b7e05686SMatthew G. Knepley 1623b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1624b7e05686SMatthew G. Knepley 1625b7e05686SMatthew 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 1626b7e05686SMatthew G. Knepley 1627b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1628b7e05686SMatthew G. Knepley 1629b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1630b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1631b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1632b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1633b7e05686SMatthew G. Knepley 1634b7e05686SMatthew G. Knepley + dim - the spatial dimension 1635b7e05686SMatthew G. Knepley . Nf - the number of fields 1636b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1637b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1638b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1639b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1640b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1641b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1642b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1643b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1644b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1645b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1646b7e05686SMatthew G. Knepley . t - current time 1647b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1648b7e05686SMatthew G. Knepley . x - coordinates of the current point 164997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 165097b6e6e8SMatthew G. Knepley . constants - constant parameters 1651b7e05686SMatthew G. Knepley - g0 - output values at the current point 1652b7e05686SMatthew G. Knepley 1653b7e05686SMatthew G. Knepley Level: intermediate 1654b7e05686SMatthew G. Knepley 1655b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1656b7e05686SMatthew G. Knepley @*/ 1657b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1658b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1659b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1660b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 166197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1662b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1663b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1664b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 166597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1666b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1667b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1668b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 166997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1670b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1671b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1672b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 167397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1674b7e05686SMatthew G. Knepley { 1675b7e05686SMatthew G. Knepley PetscFunctionBegin; 1676b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1677b7e05686SMatthew 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); 1678b7e05686SMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 1679b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1680b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1681b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1682b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1683b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1684b7e05686SMatthew G. Knepley } 1685b7e05686SMatthew G. Knepley 1686b7e05686SMatthew G. Knepley /*@C 1687b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1688b7e05686SMatthew G. Knepley 1689b7e05686SMatthew G. Knepley Not collective 1690b7e05686SMatthew G. Knepley 1691b7e05686SMatthew G. Knepley Input Parameters: 1692b7e05686SMatthew G. Knepley + prob - The PetscDS 1693b7e05686SMatthew G. Knepley . f - The test field number 1694b7e05686SMatthew G. Knepley . g - The field number 1695b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1696b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1697b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1698b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1699b7e05686SMatthew G. Knepley 1700b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1701b7e05686SMatthew G. Knepley 1702b7e05686SMatthew 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 1703b7e05686SMatthew G. Knepley 1704b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1705b7e05686SMatthew G. Knepley 1706b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1707b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1708b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1709b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1710b7e05686SMatthew G. Knepley 1711b7e05686SMatthew G. Knepley + dim - the spatial dimension 1712b7e05686SMatthew G. Knepley . Nf - the number of fields 1713b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1714b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1715b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1716b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1717b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1718b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1719b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1720b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1721b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1722b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1723b7e05686SMatthew G. Knepley . t - current time 1724b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1725b7e05686SMatthew G. Knepley . x - coordinates of the current point 172697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 172797b6e6e8SMatthew G. Knepley . constants - constant parameters 1728b7e05686SMatthew G. Knepley - g0 - output values at the current point 1729b7e05686SMatthew G. Knepley 1730b7e05686SMatthew G. Knepley Level: intermediate 1731b7e05686SMatthew G. Knepley 1732b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1733b7e05686SMatthew G. Knepley @*/ 1734b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1735b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1736b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1737b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 173897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1739b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1740b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1741b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 174297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1743b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1744b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1745b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 174697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1747b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1748b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1749b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 175097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1751b7e05686SMatthew G. Knepley { 1752b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1753b7e05686SMatthew G. Knepley 1754b7e05686SMatthew G. Knepley PetscFunctionBegin; 1755b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1756b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1757b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1758b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1759b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1760b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1761b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1762b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1763b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1764b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1765b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1766b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1767b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1768b7e05686SMatthew G. Knepley } 1769b7e05686SMatthew G. Knepley 17700c2f2876SMatthew G. Knepley /*@C 17710c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17720c2f2876SMatthew G. Knepley 17730c2f2876SMatthew G. Knepley Not collective 17740c2f2876SMatthew G. Knepley 17750c2f2876SMatthew G. Knepley Input Arguments: 17760c2f2876SMatthew G. Knepley + prob - The PetscDS object 17770c2f2876SMatthew G. Knepley - f - The field number 17780c2f2876SMatthew G. Knepley 17790c2f2876SMatthew G. Knepley Output Argument: 17800c2f2876SMatthew G. Knepley . r - Riemann solver 17810c2f2876SMatthew G. Knepley 17820c2f2876SMatthew G. Knepley Calling sequence for r: 17830c2f2876SMatthew G. Knepley 17845db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17850c2f2876SMatthew G. Knepley 17865db36cf9SMatthew G. Knepley + dim - The spatial dimension 17875db36cf9SMatthew G. Knepley . Nf - The number of fields 17885db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17890c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17900c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17910c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17920c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 179397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 179497b6e6e8SMatthew G. Knepley . constants - constant parameters 17950c2f2876SMatthew G. Knepley - ctx - optional user context 17960c2f2876SMatthew G. Knepley 17970c2f2876SMatthew G. Knepley Level: intermediate 17980c2f2876SMatthew G. Knepley 17990c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 18000c2f2876SMatthew G. Knepley @*/ 18010c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 180297b6e6e8SMatthew 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)) 18030c2f2876SMatthew G. Knepley { 18040c2f2876SMatthew G. Knepley PetscFunctionBegin; 18050c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18060c2f2876SMatthew 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); 18070c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 18080c2f2876SMatthew G. Knepley *r = prob->r[f]; 18090c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18100c2f2876SMatthew G. Knepley } 18110c2f2876SMatthew G. Knepley 18120c2f2876SMatthew G. Knepley /*@C 18130c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 18140c2f2876SMatthew G. Knepley 18150c2f2876SMatthew G. Knepley Not collective 18160c2f2876SMatthew G. Knepley 18170c2f2876SMatthew G. Knepley Input Arguments: 18180c2f2876SMatthew G. Knepley + prob - The PetscDS object 18190c2f2876SMatthew G. Knepley . f - The field number 18200c2f2876SMatthew G. Knepley - r - Riemann solver 18210c2f2876SMatthew G. Knepley 18220c2f2876SMatthew G. Knepley Calling sequence for r: 18230c2f2876SMatthew G. Knepley 18245db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 18250c2f2876SMatthew G. Knepley 18265db36cf9SMatthew G. Knepley + dim - The spatial dimension 18275db36cf9SMatthew G. Knepley . Nf - The number of fields 18285db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 18290c2f2876SMatthew G. Knepley . n - The normal vector to the interface 18300c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 18310c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 18320c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 183397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 183497b6e6e8SMatthew G. Knepley . constants - constant parameters 18350c2f2876SMatthew G. Knepley - ctx - optional user context 18360c2f2876SMatthew G. Knepley 18370c2f2876SMatthew G. Knepley Level: intermediate 18380c2f2876SMatthew G. Knepley 18390c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 18400c2f2876SMatthew G. Knepley @*/ 18410c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 184297b6e6e8SMatthew 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)) 18430c2f2876SMatthew G. Knepley { 18440c2f2876SMatthew G. Knepley PetscErrorCode ierr; 18450c2f2876SMatthew G. Knepley 18460c2f2876SMatthew G. Knepley PetscFunctionBegin; 18470c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1848de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 18490c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18500c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18510c2f2876SMatthew G. Knepley prob->r[f] = r; 18520c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18530c2f2876SMatthew G. Knepley } 18540c2f2876SMatthew G. Knepley 185532d2bbc9SMatthew G. Knepley /*@C 185632d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 185732d2bbc9SMatthew G. Knepley 185832d2bbc9SMatthew G. Knepley Not collective 185932d2bbc9SMatthew G. Knepley 186032d2bbc9SMatthew G. Knepley Input Parameters: 186132d2bbc9SMatthew G. Knepley + prob - The PetscDS 186232d2bbc9SMatthew G. Knepley - f - The field number 186332d2bbc9SMatthew G. Knepley 186432d2bbc9SMatthew G. Knepley Output Parameters: 1865a2b725a8SWilliam Gropp . update - update function 186632d2bbc9SMatthew G. Knepley 186732d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 186832d2bbc9SMatthew G. Knepley 186932d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 187032d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 187132d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187232d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 187332d2bbc9SMatthew G. Knepley 187432d2bbc9SMatthew G. Knepley + dim - the spatial dimension 187532d2bbc9SMatthew G. Knepley . Nf - the number of fields 187632d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 187732d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 187832d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 187932d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 188032d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 188132d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 188232d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 188332d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 188432d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 188532d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 188632d2bbc9SMatthew G. Knepley . t - current time 188732d2bbc9SMatthew G. Knepley . x - coordinates of the current point 188832d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 188932d2bbc9SMatthew G. Knepley 189032d2bbc9SMatthew G. Knepley Level: intermediate 189132d2bbc9SMatthew G. Knepley 189232d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 189332d2bbc9SMatthew G. Knepley @*/ 189432d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS prob, PetscInt f, 189532d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 189632d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 189732d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18983fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 189932d2bbc9SMatthew G. Knepley { 190032d2bbc9SMatthew G. Knepley PetscFunctionBegin; 190132d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 190232d2bbc9SMatthew 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); 190332d2bbc9SMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = prob->update[f];} 190432d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 190532d2bbc9SMatthew G. Knepley } 190632d2bbc9SMatthew G. Knepley 190732d2bbc9SMatthew G. Knepley /*@C 19083fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 190932d2bbc9SMatthew G. Knepley 191032d2bbc9SMatthew G. Knepley Not collective 191132d2bbc9SMatthew G. Knepley 191232d2bbc9SMatthew G. Knepley Input Parameters: 191332d2bbc9SMatthew G. Knepley + prob - The PetscDS 191432d2bbc9SMatthew G. Knepley . f - The field number 191532d2bbc9SMatthew G. Knepley - update - update function 191632d2bbc9SMatthew G. Knepley 191732d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 191832d2bbc9SMatthew G. Knepley 191932d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 192032d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 192132d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 192232d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 192332d2bbc9SMatthew G. Knepley 192432d2bbc9SMatthew G. Knepley + dim - the spatial dimension 192532d2bbc9SMatthew G. Knepley . Nf - the number of fields 192632d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 192732d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 192832d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 192932d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 193032d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 193132d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 193232d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 193332d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 193432d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 193532d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 193632d2bbc9SMatthew G. Knepley . t - current time 193732d2bbc9SMatthew G. Knepley . x - coordinates of the current point 193832d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 193932d2bbc9SMatthew G. Knepley 194032d2bbc9SMatthew G. Knepley Level: intermediate 194132d2bbc9SMatthew G. Knepley 194232d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 194332d2bbc9SMatthew G. Knepley @*/ 194432d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS prob, PetscInt f, 194532d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 194632d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 194732d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19483fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 194932d2bbc9SMatthew G. Knepley { 195032d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 195132d2bbc9SMatthew G. Knepley 195232d2bbc9SMatthew G. Knepley PetscFunctionBegin; 195332d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 195432d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 195532d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 195632d2bbc9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 195732d2bbc9SMatthew G. Knepley prob->update[f] = update; 195832d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 195932d2bbc9SMatthew G. Knepley } 196032d2bbc9SMatthew G. Knepley 19610c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 19620c2f2876SMatthew G. Knepley { 19630c2f2876SMatthew G. Knepley PetscFunctionBegin; 19640c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19650c2f2876SMatthew 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); 19660c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 19670c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 19680c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19690c2f2876SMatthew G. Knepley } 19700c2f2876SMatthew G. Knepley 19710c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 19720c2f2876SMatthew G. Knepley { 19730c2f2876SMatthew G. Knepley PetscErrorCode ierr; 19740c2f2876SMatthew G. Knepley 19750c2f2876SMatthew G. Knepley PetscFunctionBegin; 19760c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19770c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19780c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19790c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 19800c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19810c2f2876SMatthew G. Knepley } 19820c2f2876SMatthew G. Knepley 1983194d53e6SMatthew G. Knepley /*@C 1984194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1985194d53e6SMatthew G. Knepley 1986194d53e6SMatthew G. Knepley Not collective 1987194d53e6SMatthew G. Knepley 1988194d53e6SMatthew G. Knepley Input Parameters: 1989194d53e6SMatthew G. Knepley + prob - The PetscDS 1990194d53e6SMatthew G. Knepley - f - The test field number 1991194d53e6SMatthew G. Knepley 1992194d53e6SMatthew G. Knepley Output Parameters: 1993194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1994194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1995194d53e6SMatthew G. Knepley 1996194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1997194d53e6SMatthew G. Knepley 1998194d53e6SMatthew 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 1999194d53e6SMatthew G. Knepley 2000194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2001194d53e6SMatthew G. Knepley 200230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2003194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2004194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 200530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2006194d53e6SMatthew G. Knepley 2007194d53e6SMatthew G. Knepley + dim - the spatial dimension 2008194d53e6SMatthew G. Knepley . Nf - the number of fields 2009194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2010194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2011194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2012194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2013194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2014194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2015194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2016194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2017194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2018194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2019194d53e6SMatthew G. Knepley . t - current time 2020194d53e6SMatthew G. Knepley . x - coordinates of the current point 2021194d53e6SMatthew G. Knepley . n - unit normal at the current point 202297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 202397b6e6e8SMatthew G. Knepley . constants - constant parameters 2024194d53e6SMatthew G. Knepley - f0 - output values at the current point 2025194d53e6SMatthew G. Knepley 2026194d53e6SMatthew G. Knepley Level: intermediate 2027194d53e6SMatthew G. Knepley 2028194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 2029194d53e6SMatthew G. Knepley @*/ 20302764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 203130b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2032194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2033194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 203497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 203530b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2036194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2037194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 203897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20392764a2aaSMatthew G. Knepley { 20402764a2aaSMatthew G. Knepley PetscFunctionBegin; 20412764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20422764a2aaSMatthew 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); 20432764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 20442764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 20452764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20462764a2aaSMatthew G. Knepley } 20472764a2aaSMatthew G. Knepley 2048194d53e6SMatthew G. Knepley /*@C 2049194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2050194d53e6SMatthew G. Knepley 2051194d53e6SMatthew G. Knepley Not collective 2052194d53e6SMatthew G. Knepley 2053194d53e6SMatthew G. Knepley Input Parameters: 2054194d53e6SMatthew G. Knepley + prob - The PetscDS 2055194d53e6SMatthew G. Knepley . f - The test field number 2056194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2057194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2058194d53e6SMatthew G. Knepley 2059194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2060194d53e6SMatthew G. Knepley 2061194d53e6SMatthew 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 2062194d53e6SMatthew G. Knepley 2063194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2064194d53e6SMatthew G. Knepley 206530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2066194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2067194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 206830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2069194d53e6SMatthew G. Knepley 2070194d53e6SMatthew G. Knepley + dim - the spatial dimension 2071194d53e6SMatthew G. Knepley . Nf - the number of fields 2072194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2073194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2074194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2075194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2076194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2077194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2078194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2079194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2080194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2081194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2082194d53e6SMatthew G. Knepley . t - current time 2083194d53e6SMatthew G. Knepley . x - coordinates of the current point 2084194d53e6SMatthew G. Knepley . n - unit normal at the current point 208597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 208697b6e6e8SMatthew G. Knepley . constants - constant parameters 2087194d53e6SMatthew G. Knepley - f0 - output values at the current point 2088194d53e6SMatthew G. Knepley 2089194d53e6SMatthew G. Knepley Level: intermediate 2090194d53e6SMatthew G. Knepley 2091194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2092194d53e6SMatthew G. Knepley @*/ 20932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 209430b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2095194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2096194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 209797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 209830b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2099194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2100194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 210197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 21022764a2aaSMatthew G. Knepley { 21032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21042764a2aaSMatthew G. Knepley 21052764a2aaSMatthew G. Knepley PetscFunctionBegin; 21062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21072764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21082764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 21092764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 21102764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 21112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21122764a2aaSMatthew G. Knepley } 21132764a2aaSMatthew G. Knepley 211427f02ce8SMatthew G. Knepley /*@ 211527f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 211627f02ce8SMatthew G. Knepley 211727f02ce8SMatthew G. Knepley Not collective 211827f02ce8SMatthew G. Knepley 211927f02ce8SMatthew G. Knepley Input Parameter: 212027f02ce8SMatthew G. Knepley . prob - The PetscDS 212127f02ce8SMatthew G. Knepley 212227f02ce8SMatthew G. Knepley Output Parameter: 212327f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 212427f02ce8SMatthew G. Knepley 212527f02ce8SMatthew G. Knepley Level: intermediate 212627f02ce8SMatthew G. Knepley 212727f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 212827f02ce8SMatthew G. Knepley @*/ 212927f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS prob, PetscBool *hasBdJac) 213027f02ce8SMatthew G. Knepley { 213127f02ce8SMatthew G. Knepley PetscInt f, g, h; 213227f02ce8SMatthew G. Knepley 213327f02ce8SMatthew G. Knepley PetscFunctionBegin; 213427f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 213527f02ce8SMatthew G. Knepley *hasBdJac = PETSC_FALSE; 213627f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 213727f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 213827f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 213927f02ce8SMatthew G. Knepley if (prob->gBd[(f*prob->Nf + g)*4+h]) *hasBdJac = PETSC_TRUE; 214027f02ce8SMatthew G. Knepley } 214127f02ce8SMatthew G. Knepley } 214227f02ce8SMatthew G. Knepley } 214327f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 214427f02ce8SMatthew G. Knepley } 214527f02ce8SMatthew G. Knepley 2146194d53e6SMatthew G. Knepley /*@C 2147194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2148194d53e6SMatthew G. Knepley 2149194d53e6SMatthew G. Knepley Not collective 2150194d53e6SMatthew G. Knepley 2151194d53e6SMatthew G. Knepley Input Parameters: 2152194d53e6SMatthew G. Knepley + prob - The PetscDS 2153194d53e6SMatthew G. Knepley . f - The test field number 2154194d53e6SMatthew G. Knepley - g - The field number 2155194d53e6SMatthew G. Knepley 2156194d53e6SMatthew G. Knepley Output Parameters: 2157194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2158194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2159194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2160194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2161194d53e6SMatthew G. Knepley 2162194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2163194d53e6SMatthew G. Knepley 2164194d53e6SMatthew 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 2165194d53e6SMatthew G. Knepley 2166194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2167194d53e6SMatthew G. Knepley 216830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2169194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2170194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 217130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2172194d53e6SMatthew G. Knepley 2173194d53e6SMatthew G. Knepley + dim - the spatial dimension 2174194d53e6SMatthew G. Knepley . Nf - the number of fields 2175194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2176194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2177194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2178194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2179194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2180194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2181194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2182194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2183194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2184194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2185194d53e6SMatthew G. Knepley . t - current time 21862aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2187194d53e6SMatthew G. Knepley . x - coordinates of the current point 2188194d53e6SMatthew G. Knepley . n - normal at the current point 218997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 219097b6e6e8SMatthew G. Knepley . constants - constant parameters 2191194d53e6SMatthew G. Knepley - g0 - output values at the current point 2192194d53e6SMatthew G. Knepley 2193194d53e6SMatthew G. Knepley Level: intermediate 2194194d53e6SMatthew G. Knepley 2195194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2196194d53e6SMatthew G. Knepley @*/ 21972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 219830b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2199194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2200194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 220230b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2203194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2204194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 220630b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2207194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2208194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 221030b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2211194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2212194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 221397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22142764a2aaSMatthew G. Knepley { 22152764a2aaSMatthew G. Knepley PetscFunctionBegin; 22162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22172764a2aaSMatthew 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); 22182764a2aaSMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 22192764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 22202764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 22212764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 22222764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 22232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22242764a2aaSMatthew G. Knepley } 22252764a2aaSMatthew G. Knepley 2226194d53e6SMatthew G. Knepley /*@C 2227194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2228194d53e6SMatthew G. Knepley 2229194d53e6SMatthew G. Knepley Not collective 2230194d53e6SMatthew G. Knepley 2231194d53e6SMatthew G. Knepley Input Parameters: 2232194d53e6SMatthew G. Knepley + prob - The PetscDS 2233194d53e6SMatthew G. Knepley . f - The test field number 2234194d53e6SMatthew G. Knepley . g - The field number 2235194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2236194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2237194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2238194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2239194d53e6SMatthew G. Knepley 2240194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2241194d53e6SMatthew G. Knepley 2242194d53e6SMatthew 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 2243194d53e6SMatthew G. Knepley 2244194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2245194d53e6SMatthew G. Knepley 224630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2247194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2248194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2250194d53e6SMatthew G. Knepley 2251194d53e6SMatthew G. Knepley + dim - the spatial dimension 2252194d53e6SMatthew G. Knepley . Nf - the number of fields 2253194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2254194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2255194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2256194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2257194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2258194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2259194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2260194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2261194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2262194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2263194d53e6SMatthew G. Knepley . t - current time 22642aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2265194d53e6SMatthew G. Knepley . x - coordinates of the current point 2266194d53e6SMatthew G. Knepley . n - normal at the current point 226797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 226897b6e6e8SMatthew G. Knepley . constants - constant parameters 2269194d53e6SMatthew G. Knepley - g0 - output values at the current point 2270194d53e6SMatthew G. Knepley 2271194d53e6SMatthew G. Knepley Level: intermediate 2272194d53e6SMatthew G. Knepley 2273194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2274194d53e6SMatthew G. Knepley @*/ 22752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 227630b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2277194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2278194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 227997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 228030b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2281194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2282194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 228397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 228430b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2285194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2286194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 228797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 228830b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2289194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2290194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 229197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22922764a2aaSMatthew G. Knepley { 22932764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22942764a2aaSMatthew G. Knepley 22952764a2aaSMatthew G. Knepley PetscFunctionBegin; 22962764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22972764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 22982764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 22992764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 23002764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 23012764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 23022764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 23032764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 23042764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 23052764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 23062764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 23072764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 23082764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23092764a2aaSMatthew G. Knepley } 23102764a2aaSMatthew G. Knepley 231127f02ce8SMatthew G. Knepley /*@ 231227f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 231327f02ce8SMatthew G. Knepley 231427f02ce8SMatthew G. Knepley Not collective 231527f02ce8SMatthew G. Knepley 231627f02ce8SMatthew G. Knepley Input Parameter: 231727f02ce8SMatthew G. Knepley . prob - The PetscDS 231827f02ce8SMatthew G. Knepley 231927f02ce8SMatthew G. Knepley Output Parameter: 232027f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 232127f02ce8SMatthew G. Knepley 232227f02ce8SMatthew G. Knepley Level: intermediate 232327f02ce8SMatthew G. Knepley 232427f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 232527f02ce8SMatthew G. Knepley @*/ 232627f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS prob, PetscBool *hasBdJacPre) 232727f02ce8SMatthew G. Knepley { 232827f02ce8SMatthew G. Knepley PetscInt f, g, h; 232927f02ce8SMatthew G. Knepley 233027f02ce8SMatthew G. Knepley PetscFunctionBegin; 233127f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 233227f02ce8SMatthew G. Knepley *hasBdJacPre = PETSC_FALSE; 233327f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 233427f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 233527f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 233627f02ce8SMatthew G. Knepley if (prob->gpBd[(f*prob->Nf + g)*4+h]) *hasBdJacPre = PETSC_TRUE; 233727f02ce8SMatthew G. Knepley } 233827f02ce8SMatthew G. Knepley } 233927f02ce8SMatthew G. Knepley } 234027f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 234127f02ce8SMatthew G. Knepley } 234227f02ce8SMatthew G. Knepley 234327f02ce8SMatthew G. Knepley /*@C 234427f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 234527f02ce8SMatthew G. Knepley 234627f02ce8SMatthew G. Knepley Not collective 234727f02ce8SMatthew G. Knepley 234827f02ce8SMatthew G. Knepley Input Parameters: 234927f02ce8SMatthew G. Knepley + prob - The PetscDS 235027f02ce8SMatthew G. Knepley . f - The test field number 235127f02ce8SMatthew G. Knepley - g - The field number 235227f02ce8SMatthew G. Knepley 235327f02ce8SMatthew G. Knepley Output Parameters: 235427f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 235527f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 235627f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 235727f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 235827f02ce8SMatthew G. Knepley 235927f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 236027f02ce8SMatthew G. Knepley 236127f02ce8SMatthew 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 236227f02ce8SMatthew G. Knepley 236327f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 236427f02ce8SMatthew G. Knepley 236527f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 236627f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 236727f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236827f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 236927f02ce8SMatthew G. Knepley 237027f02ce8SMatthew G. Knepley + dim - the spatial dimension 237127f02ce8SMatthew G. Knepley . Nf - the number of fields 237227f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 237327f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 237427f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 237527f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 237627f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 237727f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 237827f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 237927f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 238027f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 238127f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 238227f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 238327f02ce8SMatthew G. Knepley . t - current time 238427f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 238527f02ce8SMatthew G. Knepley . x - coordinates of the current point 238627f02ce8SMatthew G. Knepley . n - normal at the current point 238727f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 238827f02ce8SMatthew G. Knepley . constants - constant parameters 238927f02ce8SMatthew G. Knepley - g0 - output values at the current point 239027f02ce8SMatthew G. Knepley 239127f02ce8SMatthew G. Knepley This is not yet available in Fortran. 239227f02ce8SMatthew G. Knepley 239327f02ce8SMatthew G. Knepley Level: intermediate 239427f02ce8SMatthew G. Knepley 239527f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 239627f02ce8SMatthew G. Knepley @*/ 239727f02ce8SMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 239827f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 239927f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 240027f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 240127f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 240227f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 240327f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 240427f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 240527f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 240627f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 240727f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 240827f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 240927f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 241027f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 241127f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 241227f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241327f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 241427f02ce8SMatthew G. Knepley { 241527f02ce8SMatthew G. Knepley PetscFunctionBegin; 241627f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 241727f02ce8SMatthew 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); 241827f02ce8SMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 241927f02ce8SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gpBd[(f*prob->Nf + g)*4+0];} 242027f02ce8SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gpBd[(f*prob->Nf + g)*4+1];} 242127f02ce8SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gpBd[(f*prob->Nf + g)*4+2];} 242227f02ce8SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gpBd[(f*prob->Nf + g)*4+3];} 242327f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 242427f02ce8SMatthew G. Knepley } 242527f02ce8SMatthew G. Knepley 242627f02ce8SMatthew G. Knepley /*@C 242727f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 242827f02ce8SMatthew G. Knepley 242927f02ce8SMatthew G. Knepley Not collective 243027f02ce8SMatthew G. Knepley 243127f02ce8SMatthew G. Knepley Input Parameters: 243227f02ce8SMatthew G. Knepley + prob - The PetscDS 243327f02ce8SMatthew G. Knepley . f - The test field number 243427f02ce8SMatthew G. Knepley . g - The field number 243527f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 243627f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 243727f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 243827f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 243927f02ce8SMatthew G. Knepley 244027f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 244127f02ce8SMatthew G. Knepley 244227f02ce8SMatthew 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 244327f02ce8SMatthew G. Knepley 244427f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 244527f02ce8SMatthew G. Knepley 244627f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 244727f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 244827f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 244927f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 245027f02ce8SMatthew G. Knepley 245127f02ce8SMatthew G. Knepley + dim - the spatial dimension 245227f02ce8SMatthew G. Knepley . Nf - the number of fields 245327f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 245427f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 245527f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 245627f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 245727f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 245827f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 245927f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 246027f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 246127f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 246227f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 246327f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 246427f02ce8SMatthew G. Knepley . t - current time 246527f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 246627f02ce8SMatthew G. Knepley . x - coordinates of the current point 246727f02ce8SMatthew G. Knepley . n - normal at the current point 246827f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 246927f02ce8SMatthew G. Knepley . constants - constant parameters 247027f02ce8SMatthew G. Knepley - g0 - output values at the current point 247127f02ce8SMatthew G. Knepley 247227f02ce8SMatthew G. Knepley This is not yet available in Fortran. 247327f02ce8SMatthew G. Knepley 247427f02ce8SMatthew G. Knepley Level: intermediate 247527f02ce8SMatthew G. Knepley 247627f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 247727f02ce8SMatthew G. Knepley @*/ 247827f02ce8SMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 247927f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 248027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 248127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 248227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 248327f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 248427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 248527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 248627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 248727f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 248827f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 248927f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249027f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 249127f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 249227f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 249327f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 249427f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 249527f02ce8SMatthew G. Knepley { 249627f02ce8SMatthew G. Knepley PetscErrorCode ierr; 249727f02ce8SMatthew G. Knepley 249827f02ce8SMatthew G. Knepley PetscFunctionBegin; 249927f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 250027f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 250127f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 250227f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 250327f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 250427f02ce8SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 250527f02ce8SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 250627f02ce8SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 250727f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+0] = g0; 250827f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+1] = g1; 250927f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+2] = g2; 251027f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+3] = g3; 251127f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 251227f02ce8SMatthew G. Knepley } 251327f02ce8SMatthew G. Knepley 25140d3e9b51SMatthew G. Knepley /*@C 2515c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2516c371a6d1SMatthew G. Knepley 2517c371a6d1SMatthew G. Knepley Not collective 2518c371a6d1SMatthew G. Knepley 2519c371a6d1SMatthew G. Knepley Input Parameters: 2520c371a6d1SMatthew G. Knepley + prob - The PetscDS 2521c371a6d1SMatthew G. Knepley - f - The test field number 2522c371a6d1SMatthew G. Knepley 2523c371a6d1SMatthew G. Knepley Output Parameter: 252495cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 252595cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2526c371a6d1SMatthew G. Knepley 2527c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2528c371a6d1SMatthew G. Knepley 2529c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2530c371a6d1SMatthew G. Knepley 2531c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2532c371a6d1SMatthew G. Knepley . t - current time 2533c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2534c371a6d1SMatthew G. Knepley . Nc - the number of field components 2535c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2536c371a6d1SMatthew G. Knepley - ctx - a user context 2537c371a6d1SMatthew G. Knepley 2538c371a6d1SMatthew G. Knepley Level: intermediate 2539c371a6d1SMatthew G. Knepley 2540*f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolution(), PetscDSGetExactSolutionTimeDerivative() 2541c371a6d1SMatthew G. Knepley @*/ 254295cbbfd3SMatthew 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) 2543c371a6d1SMatthew G. Knepley { 2544c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2545c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2546c371a6d1SMatthew 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); 2547c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 254895cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2549c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2550c371a6d1SMatthew G. Knepley } 2551c371a6d1SMatthew G. Knepley 2552c371a6d1SMatthew G. Knepley /*@C 2553578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2554c371a6d1SMatthew G. Knepley 2555c371a6d1SMatthew G. Knepley Not collective 2556c371a6d1SMatthew G. Knepley 2557c371a6d1SMatthew G. Knepley Input Parameters: 2558c371a6d1SMatthew G. Knepley + prob - The PetscDS 2559c371a6d1SMatthew G. Knepley . f - The test field number 256095cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 256195cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2562c371a6d1SMatthew G. Knepley 2563c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2564c371a6d1SMatthew G. Knepley 2565c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2566c371a6d1SMatthew G. Knepley 2567c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2568c371a6d1SMatthew G. Knepley . t - current time 2569c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2570c371a6d1SMatthew G. Knepley . Nc - the number of field components 2571c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2572c371a6d1SMatthew G. Knepley - ctx - a user context 2573c371a6d1SMatthew G. Knepley 2574c371a6d1SMatthew G. Knepley Level: intermediate 2575c371a6d1SMatthew G. Knepley 2576c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2577c371a6d1SMatthew G. Knepley @*/ 257895cbbfd3SMatthew 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) 2579c371a6d1SMatthew G. Knepley { 2580c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2581c371a6d1SMatthew G. Knepley 2582c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2583c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2584c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2585c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2586c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 258795cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2588c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2589c371a6d1SMatthew G. Knepley } 2590c371a6d1SMatthew G. Knepley 25915638fd0eSMatthew G. Knepley /*@C 2592*f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2593*f2cacb80SMatthew G. Knepley 2594*f2cacb80SMatthew G. Knepley Not collective 2595*f2cacb80SMatthew G. Knepley 2596*f2cacb80SMatthew G. Knepley Input Parameters: 2597*f2cacb80SMatthew G. Knepley + prob - The PetscDS 2598*f2cacb80SMatthew G. Knepley - f - The test field number 2599*f2cacb80SMatthew G. Knepley 2600*f2cacb80SMatthew G. Knepley Output Parameter: 2601*f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2602*f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2603*f2cacb80SMatthew G. Knepley 2604*f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2605*f2cacb80SMatthew G. Knepley 2606*f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2607*f2cacb80SMatthew G. Knepley 2608*f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2609*f2cacb80SMatthew G. Knepley . t - current time 2610*f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2611*f2cacb80SMatthew G. Knepley . Nc - the number of field components 2612*f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2613*f2cacb80SMatthew G. Knepley - ctx - a user context 2614*f2cacb80SMatthew G. Knepley 2615*f2cacb80SMatthew G. Knepley Level: intermediate 2616*f2cacb80SMatthew G. Knepley 2617*f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolutionTimeDerivative(), PetscDSGetExactSolution() 2618*f2cacb80SMatthew G. Knepley @*/ 2619*f2cacb80SMatthew 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) 2620*f2cacb80SMatthew G. Knepley { 2621*f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2622*f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2623*f2cacb80SMatthew 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); 2624*f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2625*f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2626*f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2627*f2cacb80SMatthew G. Knepley } 2628*f2cacb80SMatthew G. Knepley 2629*f2cacb80SMatthew G. Knepley /*@C 2630*f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2631*f2cacb80SMatthew G. Knepley 2632*f2cacb80SMatthew G. Knepley Not collective 2633*f2cacb80SMatthew G. Knepley 2634*f2cacb80SMatthew G. Knepley Input Parameters: 2635*f2cacb80SMatthew G. Knepley + prob - The PetscDS 2636*f2cacb80SMatthew G. Knepley . f - The test field number 2637*f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2638*f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2639*f2cacb80SMatthew G. Knepley 2640*f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2641*f2cacb80SMatthew G. Knepley 2642*f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2643*f2cacb80SMatthew G. Knepley 2644*f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2645*f2cacb80SMatthew G. Knepley . t - current time 2646*f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2647*f2cacb80SMatthew G. Knepley . Nc - the number of field components 2648*f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2649*f2cacb80SMatthew G. Knepley - ctx - a user context 2650*f2cacb80SMatthew G. Knepley 2651*f2cacb80SMatthew G. Knepley Level: intermediate 2652*f2cacb80SMatthew G. Knepley 2653*f2cacb80SMatthew G. Knepley .seealso: PetscDSGetExactSolutionTimeDerivative(), PetscDSSetExactSolution() 2654*f2cacb80SMatthew G. Knepley @*/ 2655*f2cacb80SMatthew 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) 2656*f2cacb80SMatthew G. Knepley { 2657*f2cacb80SMatthew G. Knepley PetscErrorCode ierr; 2658*f2cacb80SMatthew G. Knepley 2659*f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2660*f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2661*f2cacb80SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2662*f2cacb80SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2663*f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2664*f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2665*f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2666*f2cacb80SMatthew G. Knepley } 2667*f2cacb80SMatthew G. Knepley 2668*f2cacb80SMatthew G. Knepley /*@C 266997b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 267097b6e6e8SMatthew G. Knepley 267197b6e6e8SMatthew G. Knepley Not collective 267297b6e6e8SMatthew G. Knepley 267397b6e6e8SMatthew G. Knepley Input Parameter: 267497b6e6e8SMatthew G. Knepley . prob - The PetscDS object 267597b6e6e8SMatthew G. Knepley 267697b6e6e8SMatthew G. Knepley Output Parameters: 267797b6e6e8SMatthew G. Knepley + numConstants - The number of constants 267897b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 267997b6e6e8SMatthew G. Knepley 268097b6e6e8SMatthew G. Knepley Level: intermediate 268197b6e6e8SMatthew G. Knepley 268297b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 268397b6e6e8SMatthew G. Knepley @*/ 268497b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 268597b6e6e8SMatthew G. Knepley { 268697b6e6e8SMatthew G. Knepley PetscFunctionBegin; 268797b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 268897b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 268997b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 269097b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 269197b6e6e8SMatthew G. Knepley } 269297b6e6e8SMatthew G. Knepley 26930d3e9b51SMatthew G. Knepley /*@C 269497b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 269597b6e6e8SMatthew G. Knepley 269697b6e6e8SMatthew G. Knepley Not collective 269797b6e6e8SMatthew G. Knepley 269897b6e6e8SMatthew G. Knepley Input Parameters: 269997b6e6e8SMatthew G. Knepley + prob - The PetscDS object 270097b6e6e8SMatthew G. Knepley . numConstants - The number of constants 270197b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 270297b6e6e8SMatthew G. Knepley 270397b6e6e8SMatthew G. Knepley Level: intermediate 270497b6e6e8SMatthew G. Knepley 270597b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 270697b6e6e8SMatthew G. Knepley @*/ 270797b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 270897b6e6e8SMatthew G. Knepley { 270997b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 271097b6e6e8SMatthew G. Knepley 271197b6e6e8SMatthew G. Knepley PetscFunctionBegin; 271297b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 271397b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 271497b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 271597b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 271697b6e6e8SMatthew G. Knepley if (prob->numConstants) { 271797b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 271820be0f5bSMatthew G. Knepley } else { 271920be0f5bSMatthew G. Knepley prob->constants = NULL; 272020be0f5bSMatthew G. Knepley } 272120be0f5bSMatthew G. Knepley } 272220be0f5bSMatthew G. Knepley if (prob->numConstants) { 272320be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 2724580bdb30SBarry Smith ierr = PetscArraycpy(prob->constants, constants, prob->numConstants);CHKERRQ(ierr); 272597b6e6e8SMatthew G. Knepley } 272697b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 272797b6e6e8SMatthew G. Knepley } 272897b6e6e8SMatthew G. Knepley 27294cd1e086SMatthew G. Knepley /*@ 27304cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 27314cd1e086SMatthew G. Knepley 27324cd1e086SMatthew G. Knepley Not collective 27334cd1e086SMatthew G. Knepley 27344cd1e086SMatthew G. Knepley Input Parameters: 27354cd1e086SMatthew G. Knepley + prob - The PetscDS object 27364cd1e086SMatthew G. Knepley - disc - The discretization object 27374cd1e086SMatthew G. Knepley 27384cd1e086SMatthew G. Knepley Output Parameter: 27394cd1e086SMatthew G. Knepley . f - The field number 27404cd1e086SMatthew G. Knepley 27414cd1e086SMatthew G. Knepley Level: beginner 27424cd1e086SMatthew G. Knepley 2743f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 27444cd1e086SMatthew G. Knepley @*/ 27454cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 27464cd1e086SMatthew G. Knepley { 27474cd1e086SMatthew G. Knepley PetscInt g; 27484cd1e086SMatthew G. Knepley 27494cd1e086SMatthew G. Knepley PetscFunctionBegin; 27504cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27514cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 27524cd1e086SMatthew G. Knepley *f = -1; 27534cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 27544cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 27554cd1e086SMatthew G. Knepley *f = g; 27564cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 27574cd1e086SMatthew G. Knepley } 27584cd1e086SMatthew G. Knepley 27594cd1e086SMatthew G. Knepley /*@ 27604cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 27614cd1e086SMatthew G. Knepley 27624cd1e086SMatthew G. Knepley Not collective 27634cd1e086SMatthew G. Knepley 27644cd1e086SMatthew G. Knepley Input Parameters: 27654cd1e086SMatthew G. Knepley + prob - The PetscDS object 27664cd1e086SMatthew G. Knepley - f - The field number 27674cd1e086SMatthew G. Knepley 27684cd1e086SMatthew G. Knepley Output Parameter: 27694cd1e086SMatthew G. Knepley . size - The size 27704cd1e086SMatthew G. Knepley 27714cd1e086SMatthew G. Knepley Level: beginner 27724cd1e086SMatthew G. Knepley 2773f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 27744cd1e086SMatthew G. Knepley @*/ 27754cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 27764cd1e086SMatthew G. Knepley { 27772166fd64SMatthew G. Knepley PetscErrorCode ierr; 27782166fd64SMatthew G. Knepley 27794cd1e086SMatthew G. Knepley PetscFunctionBegin; 27804cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27814cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 27824cd1e086SMatthew 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); 27832166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2784d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 27854cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 27864cd1e086SMatthew G. Knepley } 27874cd1e086SMatthew G. Knepley 2788bc4ae4beSMatthew G. Knepley /*@ 2789bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2790bc4ae4beSMatthew G. Knepley 2791bc4ae4beSMatthew G. Knepley Not collective 2792bc4ae4beSMatthew G. Knepley 2793bc4ae4beSMatthew G. Knepley Input Parameters: 2794bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2795bc4ae4beSMatthew G. Knepley - f - The field number 2796bc4ae4beSMatthew G. Knepley 2797bc4ae4beSMatthew G. Knepley Output Parameter: 2798bc4ae4beSMatthew G. Knepley . off - The offset 2799bc4ae4beSMatthew G. Knepley 2800bc4ae4beSMatthew G. Knepley Level: beginner 2801bc4ae4beSMatthew G. Knepley 2802f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2803bc4ae4beSMatthew G. Knepley @*/ 28042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 28052764a2aaSMatthew G. Knepley { 28064cd1e086SMatthew G. Knepley PetscInt size, g; 28072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28082764a2aaSMatthew G. Knepley 28092764a2aaSMatthew G. Knepley PetscFunctionBegin; 28102764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28112764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 28122764a2aaSMatthew 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); 28132764a2aaSMatthew G. Knepley *off = 0; 28142764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 28154cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 28164cd1e086SMatthew G. Knepley *off += size; 28172764a2aaSMatthew G. Knepley } 28182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28192764a2aaSMatthew G. Knepley } 28202764a2aaSMatthew G. Knepley 2821bc4ae4beSMatthew G. Knepley /*@ 282247e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2823bc4ae4beSMatthew G. Knepley 2824bc4ae4beSMatthew G. Knepley Not collective 2825bc4ae4beSMatthew G. Knepley 282647e57110SSander Arens Input Parameter: 282747e57110SSander Arens . prob - The PetscDS object 2828bc4ae4beSMatthew G. Knepley 2829bc4ae4beSMatthew G. Knepley Output Parameter: 283047e57110SSander Arens . dimensions - The number of dimensions 2831bc4ae4beSMatthew G. Knepley 2832bc4ae4beSMatthew G. Knepley Level: beginner 2833bc4ae4beSMatthew G. Knepley 283447e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2835bc4ae4beSMatthew G. Knepley @*/ 283647e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 28372764a2aaSMatthew G. Knepley { 28382764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28392764a2aaSMatthew G. Knepley 28402764a2aaSMatthew G. Knepley PetscFunctionBegin; 28412764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 284247e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 284347e57110SSander Arens PetscValidPointer(dimensions, 2); 284447e57110SSander Arens *dimensions = prob->Nb; 284547e57110SSander Arens PetscFunctionReturn(0); 28466ce16762SMatthew G. Knepley } 284747e57110SSander Arens 284847e57110SSander Arens /*@ 284947e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 285047e57110SSander Arens 285147e57110SSander Arens Not collective 285247e57110SSander Arens 285347e57110SSander Arens Input Parameter: 285447e57110SSander Arens . prob - The PetscDS object 285547e57110SSander Arens 285647e57110SSander Arens Output Parameter: 285747e57110SSander Arens . components - The number of components 285847e57110SSander Arens 285947e57110SSander Arens Level: beginner 286047e57110SSander Arens 286147e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 286247e57110SSander Arens @*/ 286347e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 286447e57110SSander Arens { 286547e57110SSander Arens PetscErrorCode ierr; 286647e57110SSander Arens 286747e57110SSander Arens PetscFunctionBegin; 286847e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 286947e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 287047e57110SSander Arens PetscValidPointer(components, 2); 287147e57110SSander Arens *components = prob->Nc; 28726ce16762SMatthew G. Knepley PetscFunctionReturn(0); 28736ce16762SMatthew G. Knepley } 28746ce16762SMatthew G. Knepley 28756ce16762SMatthew G. Knepley /*@ 28766ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 28776ce16762SMatthew G. Knepley 28786ce16762SMatthew G. Knepley Not collective 28796ce16762SMatthew G. Knepley 28806ce16762SMatthew G. Knepley Input Parameters: 28816ce16762SMatthew G. Knepley + prob - The PetscDS object 28826ce16762SMatthew G. Knepley - f - The field number 28836ce16762SMatthew G. Knepley 28846ce16762SMatthew G. Knepley Output Parameter: 28856ce16762SMatthew G. Knepley . off - The offset 28866ce16762SMatthew G. Knepley 28876ce16762SMatthew G. Knepley Level: beginner 28886ce16762SMatthew G. Knepley 2889f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 28906ce16762SMatthew G. Knepley @*/ 28916ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 28926ce16762SMatthew G. Knepley { 28936ce16762SMatthew G. Knepley PetscFunctionBegin; 28946ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28956ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 28966ce16762SMatthew 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); 289747e57110SSander Arens *off = prob->off[f]; 28982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28992764a2aaSMatthew G. Knepley } 29002764a2aaSMatthew G. Knepley 2901194d53e6SMatthew G. Knepley /*@ 2902194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2903194d53e6SMatthew G. Knepley 2904194d53e6SMatthew G. Knepley Not collective 2905194d53e6SMatthew G. Knepley 2906194d53e6SMatthew G. Knepley Input Parameter: 2907194d53e6SMatthew G. Knepley . prob - The PetscDS object 2908194d53e6SMatthew G. Knepley 2909194d53e6SMatthew G. Knepley Output Parameter: 2910194d53e6SMatthew G. Knepley . offsets - The offsets 2911194d53e6SMatthew G. Knepley 2912194d53e6SMatthew G. Knepley Level: beginner 2913194d53e6SMatthew G. Knepley 2914f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2915194d53e6SMatthew G. Knepley @*/ 2916194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2917194d53e6SMatthew G. Knepley { 2918194d53e6SMatthew G. Knepley PetscFunctionBegin; 2919194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2920194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2921194d53e6SMatthew G. Knepley *offsets = prob->off; 2922194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2923194d53e6SMatthew G. Knepley } 2924194d53e6SMatthew G. Knepley 2925194d53e6SMatthew G. Knepley /*@ 2926194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2927194d53e6SMatthew G. Knepley 2928194d53e6SMatthew G. Knepley Not collective 2929194d53e6SMatthew G. Knepley 2930194d53e6SMatthew G. Knepley Input Parameter: 2931194d53e6SMatthew G. Knepley . prob - The PetscDS object 2932194d53e6SMatthew G. Knepley 2933194d53e6SMatthew G. Knepley Output Parameter: 2934194d53e6SMatthew G. Knepley . offsets - The offsets 2935194d53e6SMatthew G. Knepley 2936194d53e6SMatthew G. Knepley Level: beginner 2937194d53e6SMatthew G. Knepley 2938f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2939194d53e6SMatthew G. Knepley @*/ 2940194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2941194d53e6SMatthew G. Knepley { 2942194d53e6SMatthew G. Knepley PetscFunctionBegin; 2943194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2944194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2945194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2946194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2947194d53e6SMatthew G. Knepley } 2948194d53e6SMatthew G. Knepley 294968c9edb9SMatthew G. Knepley /*@C 295068c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 295168c9edb9SMatthew G. Knepley 295268c9edb9SMatthew G. Knepley Not collective 295368c9edb9SMatthew G. Knepley 295468c9edb9SMatthew G. Knepley Input Parameter: 295568c9edb9SMatthew G. Knepley . prob - The PetscDS object 295668c9edb9SMatthew G. Knepley 2957ef0bb6c7SMatthew G. Knepley Output Parameter: 2958ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 295968c9edb9SMatthew G. Knepley 296068c9edb9SMatthew G. Knepley Level: intermediate 296168c9edb9SMatthew G. Knepley 2962f744cafaSSander Arens .seealso: PetscDSCreate() 296368c9edb9SMatthew G. Knepley @*/ 2964ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 29652764a2aaSMatthew G. Knepley { 29662764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29672764a2aaSMatthew G. Knepley 29682764a2aaSMatthew G. Knepley PetscFunctionBegin; 29692764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2970ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 29712764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2972ef0bb6c7SMatthew G. Knepley *T = prob->T; 29732764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29742764a2aaSMatthew G. Knepley } 29752764a2aaSMatthew G. Knepley 297668c9edb9SMatthew G. Knepley /*@C 29774d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 297868c9edb9SMatthew G. Knepley 297968c9edb9SMatthew G. Knepley Not collective 298068c9edb9SMatthew G. Knepley 298168c9edb9SMatthew G. Knepley Input Parameter: 298268c9edb9SMatthew G. Knepley . prob - The PetscDS object 298368c9edb9SMatthew G. Knepley 2984ef0bb6c7SMatthew G. Knepley Output Parameter: 298519815104SMartin Diehl . Tf - The basis function and derviative tabulation on each local face at quadrature points for each and field 298668c9edb9SMatthew G. Knepley 298768c9edb9SMatthew G. Knepley Level: intermediate 298868c9edb9SMatthew G. Knepley 298968c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 299068c9edb9SMatthew G. Knepley @*/ 2991ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 29922764a2aaSMatthew G. Knepley { 29932764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29942764a2aaSMatthew G. Knepley 29952764a2aaSMatthew G. Knepley PetscFunctionBegin; 29962764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2997ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 29982764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2999ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 30002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30012764a2aaSMatthew G. Knepley } 30022764a2aaSMatthew G. Knepley 30032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 30042764a2aaSMatthew G. Knepley { 30052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30062764a2aaSMatthew G. Knepley 30072764a2aaSMatthew G. Knepley PetscFunctionBegin; 30082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30092764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 30102764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 30112764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 30122764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 30132764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30142764a2aaSMatthew G. Knepley } 30152764a2aaSMatthew G. Knepley 30162764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 30172764a2aaSMatthew G. Knepley { 30182764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30192764a2aaSMatthew G. Knepley 30202764a2aaSMatthew G. Knepley PetscFunctionBegin; 30212764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30222764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 30232764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 30242764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 30252764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 30262764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 30272764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 30282764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 30292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30302764a2aaSMatthew G. Knepley } 30312764a2aaSMatthew G. Knepley 30324bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 30332764a2aaSMatthew G. Knepley { 30342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30352764a2aaSMatthew G. Knepley 30362764a2aaSMatthew G. Knepley PetscFunctionBegin; 30372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30382764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 30392764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 30404bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 30417506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 30427506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 30437506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 30442764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30452764a2aaSMatthew G. Knepley } 30462764a2aaSMatthew G. Knepley 304758ebd649SToby Isaac /*@C 304858ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 304958ebd649SToby Isaac 3050783e2ec8SMatthew G. Knepley Collective on ds 3051783e2ec8SMatthew G. Knepley 305258ebd649SToby Isaac Input Parameters: 305358ebd649SToby Isaac + ds - The PetscDS object 30542d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 305558ebd649SToby Isaac . name - The BC name 305658ebd649SToby Isaac . labelname - The label defining constrained points 305758ebd649SToby Isaac . field - The field to constrain 3058e8ecbf3fSStefano Zampini . numcomps - The number of constrained field components (0 will constrain all fields) 305958ebd649SToby Isaac . comps - An array of constrained component numbers 306058ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 306158ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 306258ebd649SToby Isaac . ids - An array of ids for constrained points 306358ebd649SToby Isaac - ctx - An optional user context for bcFunc 306458ebd649SToby Isaac 306558ebd649SToby Isaac Options Database Keys: 306658ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 306758ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 306858ebd649SToby Isaac 306958ebd649SToby Isaac Level: developer 307058ebd649SToby Isaac 307158ebd649SToby Isaac .seealso: PetscDSGetBoundary() 307258ebd649SToby Isaac @*/ 3073a30ec4eaSSatish Balay PetscErrorCode PetscDSAddBoundary(PetscDS ds, DMBoundaryConditionType type, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(void), PetscInt numids, const PetscInt *ids, void *ctx) 307458ebd649SToby Isaac { 307558ebd649SToby Isaac DSBoundary b; 307658ebd649SToby Isaac PetscErrorCode ierr; 307758ebd649SToby Isaac 307858ebd649SToby Isaac PetscFunctionBegin; 307958ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3080783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 3081783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 5); 3082783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numcomps, 6); 3083783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numids, 9); 308458ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 308558ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 308658ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 308758ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 3088580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 308958ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 3090580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 3091f971fd6bSMatthew G. Knepley b->type = type; 309258ebd649SToby Isaac b->field = field; 309358ebd649SToby Isaac b->numcomps = numcomps; 309458ebd649SToby Isaac b->func = bcFunc; 309558ebd649SToby Isaac b->numids = numids; 309658ebd649SToby Isaac b->ctx = ctx; 309758ebd649SToby Isaac b->next = ds->boundary; 309858ebd649SToby Isaac ds->boundary = b; 309958ebd649SToby Isaac PetscFunctionReturn(0); 310058ebd649SToby Isaac } 310158ebd649SToby Isaac 3102b67eacb3SMatthew G. Knepley /*@C 3103b67eacb3SMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model 3104b67eacb3SMatthew G. Knepley 3105b67eacb3SMatthew G. Knepley Input Parameters: 3106b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3107b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3108b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3109b67eacb3SMatthew G. Knepley . name - The BC name 3110b67eacb3SMatthew G. Knepley . labelname - The label defining constrained points 3111b67eacb3SMatthew G. Knepley . field - The field to constrain 3112b67eacb3SMatthew G. Knepley . numcomps - The number of constrained field components 3113b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3114b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3115b67eacb3SMatthew G. Knepley . numids - The number of DMLabel ids for constrained points 3116b67eacb3SMatthew G. Knepley . ids - An array of ids for constrained points 3117b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3118b67eacb3SMatthew G. Knepley 31199a6efb6aSMatthew G. Knepley Note: The boundary condition number is the order in which it was registered. The user can get the number of boundary conditions from PetscDSGetNumBoundary(). 31209a6efb6aSMatthew G. Knepley 3121b67eacb3SMatthew G. Knepley Level: developer 3122b67eacb3SMatthew G. Knepley 31239a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3124b67eacb3SMatthew G. Knepley @*/ 3125b67eacb3SMatthew G. Knepley PetscErrorCode PetscDSUpdateBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType type, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(void), PetscInt numids, const PetscInt *ids, void *ctx) 3126b67eacb3SMatthew G. Knepley { 3127b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3128b67eacb3SMatthew G. Knepley PetscInt n = 0; 3129b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 3130b67eacb3SMatthew G. Knepley 3131b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3132b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3133b67eacb3SMatthew G. Knepley while (b) { 3134b67eacb3SMatthew G. Knepley if (n == bd) break; 3135b67eacb3SMatthew G. Knepley b = b->next; 3136b67eacb3SMatthew G. Knepley ++n; 3137b67eacb3SMatthew G. Knepley } 3138b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3139b67eacb3SMatthew G. Knepley if (name) { 3140b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 3141b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 3142b67eacb3SMatthew G. Knepley } 3143b67eacb3SMatthew G. Knepley if (labelname) { 3144b67eacb3SMatthew G. Knepley ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3145b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 3146b67eacb3SMatthew G. Knepley } 3147b67eacb3SMatthew G. Knepley if (numcomps >= 0 && numcomps != b->numcomps) { 3148b67eacb3SMatthew G. Knepley b->numcomps = numcomps; 3149b67eacb3SMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 3150b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 3151580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 3152b67eacb3SMatthew G. Knepley } 3153b67eacb3SMatthew G. Knepley if (numids >= 0 && numids != b->numids) { 3154b67eacb3SMatthew G. Knepley b->numids = numids; 3155b67eacb3SMatthew G. Knepley ierr = PetscFree(b->ids);CHKERRQ(ierr); 3156b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 3157580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 3158b67eacb3SMatthew G. Knepley } 3159b67eacb3SMatthew G. Knepley b->type = type; 3160b67eacb3SMatthew G. Knepley if (field >= 0) {b->field = field;} 3161b67eacb3SMatthew G. Knepley if (bcFunc) {b->func = bcFunc;} 3162b67eacb3SMatthew G. Knepley if (ctx) {b->ctx = ctx;} 3163b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3164b67eacb3SMatthew G. Knepley } 3165b67eacb3SMatthew G. Knepley 316658ebd649SToby Isaac /*@ 316758ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 316858ebd649SToby Isaac 316958ebd649SToby Isaac Input Parameters: 317058ebd649SToby Isaac . ds - The PetscDS object 317158ebd649SToby Isaac 317258ebd649SToby Isaac Output Parameters: 317358ebd649SToby Isaac . numBd - The number of BC 317458ebd649SToby Isaac 317558ebd649SToby Isaac Level: intermediate 317658ebd649SToby Isaac 317758ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 317858ebd649SToby Isaac @*/ 317958ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 318058ebd649SToby Isaac { 318158ebd649SToby Isaac DSBoundary b = ds->boundary; 318258ebd649SToby Isaac 318358ebd649SToby Isaac PetscFunctionBegin; 318458ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 318558ebd649SToby Isaac PetscValidPointer(numBd, 2); 318658ebd649SToby Isaac *numBd = 0; 318758ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 318858ebd649SToby Isaac PetscFunctionReturn(0); 318958ebd649SToby Isaac } 319058ebd649SToby Isaac 319158ebd649SToby Isaac /*@C 31929a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 319358ebd649SToby Isaac 319458ebd649SToby Isaac Input Parameters: 319558ebd649SToby Isaac + ds - The PetscDS object 319658ebd649SToby Isaac - bd - The BC number 319758ebd649SToby Isaac 319858ebd649SToby Isaac Output Parameters: 31992d47a189SJulian Andrej + type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 320058ebd649SToby Isaac . name - The BC name 320158ebd649SToby Isaac . labelname - The label defining constrained points 320258ebd649SToby Isaac . field - The field to constrain 320358ebd649SToby Isaac . numcomps - The number of constrained field components 320458ebd649SToby Isaac . comps - An array of constrained component numbers 320558ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 320658ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 320758ebd649SToby Isaac . ids - An array of ids for constrained points 320858ebd649SToby Isaac - ctx - An optional user context for bcFunc 320958ebd649SToby Isaac 321058ebd649SToby Isaac Options Database Keys: 321158ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 321258ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 321358ebd649SToby Isaac 321458ebd649SToby Isaac Level: developer 321558ebd649SToby Isaac 321658ebd649SToby Isaac .seealso: PetscDSAddBoundary() 321758ebd649SToby Isaac @*/ 3218a30ec4eaSSatish Balay PetscErrorCode PetscDSGetBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType *type, const char **name, const char **labelname, PetscInt *field, PetscInt *numcomps, const PetscInt **comps, void (**func)(void), PetscInt *numids, const PetscInt **ids, void **ctx) 321958ebd649SToby Isaac { 322058ebd649SToby Isaac DSBoundary b = ds->boundary; 322158ebd649SToby Isaac PetscInt n = 0; 322258ebd649SToby Isaac 322358ebd649SToby Isaac PetscFunctionBegin; 322458ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 322558ebd649SToby Isaac while (b) { 322658ebd649SToby Isaac if (n == bd) break; 322758ebd649SToby Isaac b = b->next; 322858ebd649SToby Isaac ++n; 322958ebd649SToby Isaac } 323058ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3231f971fd6bSMatthew G. Knepley if (type) { 3232f971fd6bSMatthew G. Knepley PetscValidPointer(type, 3); 3233f971fd6bSMatthew G. Knepley *type = b->type; 323458ebd649SToby Isaac } 323558ebd649SToby Isaac if (name) { 323658ebd649SToby Isaac PetscValidPointer(name, 4); 323758ebd649SToby Isaac *name = b->name; 323858ebd649SToby Isaac } 323958ebd649SToby Isaac if (labelname) { 324058ebd649SToby Isaac PetscValidPointer(labelname, 5); 324158ebd649SToby Isaac *labelname = b->labelname; 324258ebd649SToby Isaac } 324358ebd649SToby Isaac if (field) { 324458ebd649SToby Isaac PetscValidPointer(field, 6); 324558ebd649SToby Isaac *field = b->field; 324658ebd649SToby Isaac } 324758ebd649SToby Isaac if (numcomps) { 324858ebd649SToby Isaac PetscValidPointer(numcomps, 7); 324958ebd649SToby Isaac *numcomps = b->numcomps; 325058ebd649SToby Isaac } 325158ebd649SToby Isaac if (comps) { 325258ebd649SToby Isaac PetscValidPointer(comps, 8); 325358ebd649SToby Isaac *comps = b->comps; 325458ebd649SToby Isaac } 325558ebd649SToby Isaac if (func) { 325658ebd649SToby Isaac PetscValidPointer(func, 9); 325758ebd649SToby Isaac *func = b->func; 325858ebd649SToby Isaac } 325958ebd649SToby Isaac if (numids) { 326058ebd649SToby Isaac PetscValidPointer(numids, 10); 326158ebd649SToby Isaac *numids = b->numids; 326258ebd649SToby Isaac } 326358ebd649SToby Isaac if (ids) { 326458ebd649SToby Isaac PetscValidPointer(ids, 11); 326558ebd649SToby Isaac *ids = b->ids; 326658ebd649SToby Isaac } 326758ebd649SToby Isaac if (ctx) { 326858ebd649SToby Isaac PetscValidPointer(ctx, 12); 326958ebd649SToby Isaac *ctx = b->ctx; 327058ebd649SToby Isaac } 327158ebd649SToby Isaac PetscFunctionReturn(0); 327258ebd649SToby Isaac } 327358ebd649SToby Isaac 32749252d075SMatthew G. Knepley /*@ 32759252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 32769252d075SMatthew G. Knepley 32779252d075SMatthew G. Knepley Not collective 32789252d075SMatthew G. Knepley 32799252d075SMatthew G. Knepley Input Parameter: 32809252d075SMatthew G. Knepley . prob - The PetscDS object 32819252d075SMatthew G. Knepley 32829252d075SMatthew G. Knepley Output Parameter: 32839252d075SMatthew G. Knepley . newprob - The PetscDS copy 32849252d075SMatthew G. Knepley 32859252d075SMatthew G. Knepley Level: intermediate 32869252d075SMatthew G. Knepley 32879252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 32889252d075SMatthew G. Knepley @*/ 3289dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 3290dff059c6SToby Isaac { 3291dff059c6SToby Isaac DSBoundary b, next, *lastnext; 3292dff059c6SToby Isaac PetscErrorCode ierr; 3293dff059c6SToby Isaac 3294dff059c6SToby Isaac PetscFunctionBegin; 3295dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 3296dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 3297dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 3298dff059c6SToby Isaac next = probB->boundary; 3299dff059c6SToby Isaac while (next) { 3300dff059c6SToby Isaac DSBoundary b = next; 3301dff059c6SToby Isaac 3302dff059c6SToby Isaac next = b->next; 3303dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 3304dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 3305dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 3306dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3307dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 3308dff059c6SToby Isaac } 3309dff059c6SToby Isaac lastnext = &(probB->boundary); 3310dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 3311dff059c6SToby Isaac DSBoundary bNew; 3312dff059c6SToby Isaac 3313459726d8SSatish Balay ierr = PetscNew(&bNew);CHKERRQ(ierr); 3314dff059c6SToby Isaac bNew->numcomps = b->numcomps; 3315dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 3316580bdb30SBarry Smith ierr = PetscArraycpy(bNew->comps, b->comps, bNew->numcomps);CHKERRQ(ierr); 3317dff059c6SToby Isaac bNew->numids = b->numids; 3318dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 3319580bdb30SBarry Smith ierr = PetscArraycpy(bNew->ids, b->ids, bNew->numids);CHKERRQ(ierr); 3320dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 3321dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 3322dff059c6SToby Isaac bNew->ctx = b->ctx; 3323f971fd6bSMatthew G. Knepley bNew->type = b->type; 3324dff059c6SToby Isaac bNew->field = b->field; 3325dff059c6SToby Isaac bNew->func = b->func; 3326dff059c6SToby Isaac 3327dff059c6SToby Isaac *lastnext = bNew; 3328dff059c6SToby Isaac lastnext = &(bNew->next); 3329dff059c6SToby Isaac } 3330dff059c6SToby Isaac PetscFunctionReturn(0); 3331dff059c6SToby Isaac } 3332dff059c6SToby Isaac 33339252d075SMatthew G. Knepley /*@C 33349252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 33359252d075SMatthew G. Knepley 33369252d075SMatthew G. Knepley Not collective 33379252d075SMatthew G. Knepley 33389252d075SMatthew G. Knepley Input Parameter: 33399252d075SMatthew G. Knepley + prob - The PetscDS object 33409252d075SMatthew G. Knepley . numFields - Number of new fields 33419252d075SMatthew G. Knepley - fields - Old field number for each new field 33429252d075SMatthew G. Knepley 33439252d075SMatthew G. Knepley Output Parameter: 33449252d075SMatthew G. Knepley . newprob - The PetscDS copy 33459252d075SMatthew G. Knepley 33469252d075SMatthew G. Knepley Level: intermediate 33479252d075SMatthew G. Knepley 33489252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 33499252d075SMatthew G. Knepley @*/ 33509252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 33519252d075SMatthew G. Knepley { 33529252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 33539252d075SMatthew G. Knepley PetscErrorCode ierr; 33549252d075SMatthew G. Knepley 33559252d075SMatthew G. Knepley PetscFunctionBegin; 33569252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33579252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 33589252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 33599252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 33609252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 33619252d075SMatthew 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); 33629252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 33639252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 33649252d075SMatthew G. Knepley PetscPointFunc obj; 33659252d075SMatthew G. Knepley PetscPointFunc f0, f1; 33669252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 33679252d075SMatthew G. Knepley PetscRiemannFunc r; 33689252d075SMatthew G. Knepley 3369c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 33709252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 33719252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 33729252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 33739252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 33749252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 33759252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 33769252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 33779252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 33789252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 33799252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 33809252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 33819252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 33829252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 33839252d075SMatthew G. Knepley 3384c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 33859252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 33869252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 33879252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 33889252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 33899252d075SMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(prob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 33909252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 33919252d075SMatthew G. Knepley } 33929252d075SMatthew G. Knepley } 33939252d075SMatthew G. Knepley PetscFunctionReturn(0); 33949252d075SMatthew G. Knepley } 33959252d075SMatthew G. Knepley 3396da51fcedSMatthew G. Knepley /*@ 3397da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3398da51fcedSMatthew G. Knepley 3399da51fcedSMatthew G. Knepley Not collective 3400da51fcedSMatthew G. Knepley 3401da51fcedSMatthew G. Knepley Input Parameter: 3402da51fcedSMatthew G. Knepley . prob - The PetscDS object 3403da51fcedSMatthew G. Knepley 3404da51fcedSMatthew G. Knepley Output Parameter: 3405da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3406da51fcedSMatthew G. Knepley 3407da51fcedSMatthew G. Knepley Level: intermediate 3408da51fcedSMatthew G. Knepley 34099252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3410da51fcedSMatthew G. Knepley @*/ 3411da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3412da51fcedSMatthew G. Knepley { 34139252d075SMatthew G. Knepley PetscInt Nf, Ng; 3414da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3415da51fcedSMatthew G. Knepley 3416da51fcedSMatthew G. Knepley PetscFunctionBegin; 3417da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3418da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3419da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3420da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 342113903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 34229252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 34239252d075SMatthew G. Knepley PetscFunctionReturn(0); 34249252d075SMatthew G. Knepley } 34259252d075SMatthew G. Knepley /*@ 34269252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3427da51fcedSMatthew G. Knepley 34289252d075SMatthew G. Knepley Not collective 34299252d075SMatthew G. Knepley 34309252d075SMatthew G. Knepley Input Parameter: 34319252d075SMatthew G. Knepley . prob - The PetscDS object 34329252d075SMatthew G. Knepley 34339252d075SMatthew G. Knepley Output Parameter: 34349252d075SMatthew G. Knepley . newprob - The PetscDS copy 34359252d075SMatthew G. Knepley 34369252d075SMatthew G. Knepley Level: intermediate 34379252d075SMatthew G. Knepley 34389252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 34399252d075SMatthew G. Knepley @*/ 34409252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 34419252d075SMatthew G. Knepley { 34429252d075SMatthew G. Knepley PetscInt Nc; 34439252d075SMatthew G. Knepley const PetscScalar *constants; 34449252d075SMatthew G. Knepley PetscErrorCode ierr; 34459252d075SMatthew G. Knepley 34469252d075SMatthew G. Knepley PetscFunctionBegin; 34479252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 34489252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 34499252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 34509252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3451da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3452da51fcedSMatthew G. Knepley } 3453da51fcedSMatthew G. Knepley 3454b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3455b1353e8eSMatthew G. Knepley { 3456df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3457b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3458b1353e8eSMatthew G. Knepley 3459b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3460b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3461b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3462b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3463b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3464df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3465df3a45bdSMatthew 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); 3466df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3467df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3468b1353e8eSMatthew G. Knepley PetscInt cdim; 3469b1353e8eSMatthew G. Knepley 3470df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3471b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3472df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3473b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3474b1353e8eSMatthew G. Knepley PetscFE subfe; 3475b1353e8eSMatthew G. Knepley PetscObject obj; 3476b1353e8eSMatthew G. Knepley PetscClassId id; 3477b1353e8eSMatthew G. Knepley 3478b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3479b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3480b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3481b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3482df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3483b1353e8eSMatthew G. Knepley } 3484b1353e8eSMatthew G. Knepley } 3485df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3486b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3487b1353e8eSMatthew G. Knepley } 3488b1353e8eSMatthew G. Knepley 3489665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 3490c7bd5f0bSMatthew G. Knepley { 3491c7bd5f0bSMatthew G. Knepley PetscObject obj; 3492c7bd5f0bSMatthew G. Knepley PetscClassId id; 3493c7bd5f0bSMatthew G. Knepley PetscInt Nf; 3494c7bd5f0bSMatthew G. Knepley PetscErrorCode ierr; 3495c7bd5f0bSMatthew G. Knepley 3496c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 3497c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3498665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 3499665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 3500c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 3501c7bd5f0bSMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 3502c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetDiscretization(ds, f, &obj);CHKERRQ(ierr); 3503665f567fSMatthew G. Knepley if (obj) { 3504c7bd5f0bSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3505665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 3506665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 3507665f567fSMatthew G. Knepley } 3508c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 3509c7bd5f0bSMatthew G. Knepley } 3510c7bd5f0bSMatthew G. Knepley 3511bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 35122764a2aaSMatthew G. Knepley { 3513931fb3b8SToby Isaac PetscErrorCode ierr; 3514931fb3b8SToby Isaac 35152764a2aaSMatthew G. Knepley PetscFunctionBegin; 3516931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 35172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 35182764a2aaSMatthew G. Knepley } 35192764a2aaSMatthew G. Knepley 3520bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 35212764a2aaSMatthew G. Knepley { 35222764a2aaSMatthew G. Knepley PetscFunctionBegin; 35232764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 35242764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 35252764a2aaSMatthew G. Knepley prob->ops->view = NULL; 35262764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 35272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 35282764a2aaSMatthew G. Knepley } 35292764a2aaSMatthew G. Knepley 35302764a2aaSMatthew G. Knepley /*MC 35312764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 35322764a2aaSMatthew G. Knepley 35332764a2aaSMatthew G. Knepley Level: intermediate 35342764a2aaSMatthew G. Knepley 35352764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 35362764a2aaSMatthew G. Knepley M*/ 35372764a2aaSMatthew G. Knepley 35382764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 35392764a2aaSMatthew G. Knepley { 35402764a2aaSMatthew G. Knepley PetscDS_Basic *b; 35412764a2aaSMatthew G. Knepley PetscErrorCode ierr; 35422764a2aaSMatthew G. Knepley 35432764a2aaSMatthew G. Knepley PetscFunctionBegin; 3544931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 35452764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 35462764a2aaSMatthew G. Knepley prob->data = b; 35472764a2aaSMatthew G. Knepley 35482764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 35492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 35502764a2aaSMatthew G. Knepley } 3551