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; 3852764a2aaSMatthew G. Knepley PetscQuadrature q; 3869de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3872764a2aaSMatthew G. Knepley 3889de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3899de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3909de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3919de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3929de99aefSMatthew G. Knepley 3932764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3942764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 3952764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 396ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetCellTabulation(fe, &prob->T[f]);CHKERRQ(ierr); 397ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetFaceTabulation(fe, &prob->Tf[f]);CHKERRQ(ierr); 3989de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 3999de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4009de99aefSMatthew G. Knepley 4019de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 4029de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 4039c3cf19fSMatthew G. Knepley Nb = Nc; 404ef0bb6c7SMatthew G. Knepley ierr = PetscFVGetCellTabulation(fv, &prob->T[f]);CHKERRQ(ierr); 4054d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 406abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 40747e57110SSander Arens prob->Nc[f] = Nc; 40847e57110SSander Arens prob->Nb[f] = Nb; 409194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 410194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 411a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 4122764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4134bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4142764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4159c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4162764a2aaSMatthew G. Knepley prob->totComp += Nc; 41794a5e212SMatthew G. Knepley /* There are two faces for all fields but the cohesive field on a hybrid cell */ 41894a5e212SMatthew G. Knepley if (prob->isHybrid && (f < Nf-1)) prob->totDim += Nb; 4192764a2aaSMatthew G. Knepley } 4202764a2aaSMatthew G. Knepley /* Allocate works space */ 42194a5e212SMatthew G. Knepley if (prob->isHybrid) NsMax = 2; 4224bee2e38SMatthew G. Knepley ierr = PetscMalloc3(NsMax*prob->totComp,&prob->u,NsMax*prob->totComp,&prob->u_t,NsMax*prob->totComp*dimEmbed,&prob->u_x);CHKERRQ(ierr); 4234bee2e38SMatthew 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); 424*27f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 425*27f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 426*27f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4272764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 4282764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4302764a2aaSMatthew G. Knepley } 4312764a2aaSMatthew G. Knepley 4322764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4332764a2aaSMatthew G. Knepley { 4342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4352764a2aaSMatthew G. Knepley 4362764a2aaSMatthew G. Knepley PetscFunctionBegin; 43747e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 438f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 439ef0bb6c7SMatthew G. Knepley ierr = PetscFree2(prob->T,prob->Tf);CHKERRQ(ierr); 4404bee2e38SMatthew G. Knepley ierr = PetscFree3(prob->u,prob->u_t,prob->u_x);CHKERRQ(ierr); 4414bee2e38SMatthew G. Knepley ierr = PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal);CHKERRQ(ierr); 4422764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 4432764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4442764a2aaSMatthew G. Knepley } 4452764a2aaSMatthew G. Knepley 4462764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4472764a2aaSMatthew G. Knepley { 448f744cafaSSander Arens PetscObject *tmpd; 44934aa8a36SMatthew G. Knepley PetscBool *tmpi; 45032d2bbc9SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf, *tmpup; 451b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 4522aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 453*27f02ce8SMatthew G. Knepley PetscBdPointJac *tmpgbd, *tmpgpbd; 454194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 455c371a6d1SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol; 45695cbbfd3SMatthew G. Knepley void **tmpexactCtx; 4570c2f2876SMatthew G. Knepley void **tmpctx; 45834aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4592764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4602764a2aaSMatthew G. Knepley 4612764a2aaSMatthew G. Knepley PetscFunctionBegin; 4622764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4632764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4642764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 46534aa8a36SMatthew G. Knepley ierr = PetscMalloc2(NfNew, &tmpd, NfNew, &tmpi);CHKERRQ(ierr); 46634aa8a36SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f];} 46734aa8a36SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE;} 46834aa8a36SMatthew G. Knepley ierr = PetscFree2(prob->disc, prob->implicit);CHKERRQ(ierr); 4692764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4702764a2aaSMatthew G. Knepley prob->disc = tmpd; 471249df284SMatthew G. Knepley prob->implicit = tmpi; 472b7e05686SMatthew 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); 47332d2bbc9SMatthew G. Knepley ierr = PetscCalloc1(NfNew, &tmpup);CHKERRQ(ierr); 4742764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4752764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4762764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 477475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4780c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 47932d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4800c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4812764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4822764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4832764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 484475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 485b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4860c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 48732d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4880c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 489b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 49032d2bbc9SMatthew G. Knepley ierr = PetscFree(prob->update);CHKERRQ(ierr); 4912764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4922764a2aaSMatthew G. Knepley prob->f = tmpf; 4932764a2aaSMatthew G. Knepley prob->g = tmpg; 494475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 495b7e05686SMatthew G. Knepley prob->gt = tmpgt; 4960c2f2876SMatthew G. Knepley prob->r = tmpr; 49732d2bbc9SMatthew G. Knepley prob->update = tmpup; 4980c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 499*27f02ce8SMatthew G. Knepley ierr = PetscCalloc5(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd, NfNew*NfNew*4, &tmpgpbd, NfNew, &tmpexactSol, NfNew, &tmpexactCtx);CHKERRQ(ierr); 5002764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 5012764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 502*27f02ce8SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgpbd[f] = prob->gpBd[f]; 503c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50495cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 5052764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 5062764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 507*27f02ce8SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgpbd[f] = NULL; 508c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 50995cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 510*27f02ce8SMatthew G. Knepley ierr = PetscFree5(prob->fBd, prob->gBd, prob->gpBd, prob->exactSol, prob->exactCtx);CHKERRQ(ierr); 5112764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 5122764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 513*27f02ce8SMatthew G. Knepley prob->gpBd = tmpgpbd; 514c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51595cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 5162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5172764a2aaSMatthew G. Knepley } 5182764a2aaSMatthew G. Knepley 5192764a2aaSMatthew G. Knepley /*@ 5202764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5212764a2aaSMatthew G. Knepley 522d083f849SBarry Smith Collective on prob 5232764a2aaSMatthew G. Knepley 5242764a2aaSMatthew G. Knepley Input Parameter: 5252764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5262764a2aaSMatthew G. Knepley 5272764a2aaSMatthew G. Knepley Level: developer 5282764a2aaSMatthew G. Knepley 5292764a2aaSMatthew G. Knepley .seealso PetscDSView() 5302764a2aaSMatthew G. Knepley @*/ 5312764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 5322764a2aaSMatthew G. Knepley { 5332764a2aaSMatthew G. Knepley PetscInt f; 53458ebd649SToby Isaac DSBoundary next; 5352764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5362764a2aaSMatthew G. Knepley 5372764a2aaSMatthew G. Knepley PetscFunctionBegin; 5382764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 5392764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 5402764a2aaSMatthew G. Knepley 5412764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 5422764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 543df3a45bdSMatthew G. Knepley if ((*prob)->subprobs) { 544df3a45bdSMatthew G. Knepley PetscInt dim, d; 545df3a45bdSMatthew G. Knepley 546df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*prob, &dim);CHKERRQ(ierr); 547df3a45bdSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*prob)->subprobs[d]);CHKERRQ(ierr);} 548df3a45bdSMatthew G. Knepley } 549df3a45bdSMatthew G. Knepley ierr = PetscFree((*prob)->subprobs);CHKERRQ(ierr); 5502764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 5512764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 5522764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 5532764a2aaSMatthew G. Knepley } 55434aa8a36SMatthew G. Knepley ierr = PetscFree2((*prob)->disc, (*prob)->implicit);CHKERRQ(ierr); 555b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 55632d2bbc9SMatthew G. Knepley ierr = PetscFree((*prob)->update);CHKERRQ(ierr); 557*27f02ce8SMatthew G. Knepley ierr = PetscFree5((*prob)->fBd,(*prob)->gBd,(*prob)->gpBd,(*prob)->exactSol,(*prob)->exactCtx);CHKERRQ(ierr); 5582764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 55958ebd649SToby Isaac next = (*prob)->boundary; 56058ebd649SToby Isaac while (next) { 56158ebd649SToby Isaac DSBoundary b = next; 56258ebd649SToby Isaac 56358ebd649SToby Isaac next = b->next; 56458ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 56558ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 56658ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 56758ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 56858ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 56958ebd649SToby Isaac } 57097b6e6e8SMatthew G. Knepley ierr = PetscFree((*prob)->constants);CHKERRQ(ierr); 5712764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 5722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5732764a2aaSMatthew G. Knepley } 5742764a2aaSMatthew G. Knepley 5752764a2aaSMatthew G. Knepley /*@ 5762764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5772764a2aaSMatthew G. Knepley 578d083f849SBarry Smith Collective 5792764a2aaSMatthew G. Knepley 5802764a2aaSMatthew G. Knepley Input Parameter: 5812764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5822764a2aaSMatthew G. Knepley 5832764a2aaSMatthew G. Knepley Output Parameter: 5842764a2aaSMatthew G. Knepley . prob - The PetscDS object 5852764a2aaSMatthew G. Knepley 5862764a2aaSMatthew G. Knepley Level: beginner 5872764a2aaSMatthew G. Knepley 5882764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5892764a2aaSMatthew G. Knepley @*/ 5902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 5912764a2aaSMatthew G. Knepley { 5922764a2aaSMatthew G. Knepley PetscDS p; 5932764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5942764a2aaSMatthew G. Knepley 5952764a2aaSMatthew G. Knepley PetscFunctionBegin; 5962764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 5972764a2aaSMatthew G. Knepley *prob = NULL; 5982764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5992764a2aaSMatthew G. Knepley 60073107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 6012764a2aaSMatthew G. Knepley 6022764a2aaSMatthew G. Knepley p->Nf = 0; 6032764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 60497b6e6e8SMatthew G. Knepley p->numConstants = 0; 60597b6e6e8SMatthew G. Knepley p->constants = NULL; 606a859676bSMatthew G. Knepley p->dimEmbed = -1; 60755c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 6082764a2aaSMatthew G. Knepley 6092764a2aaSMatthew G. Knepley *prob = p; 6102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6112764a2aaSMatthew G. Knepley } 6122764a2aaSMatthew G. Knepley 613bc4ae4beSMatthew G. Knepley /*@ 614bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 615bc4ae4beSMatthew G. Knepley 616bc4ae4beSMatthew G. Knepley Not collective 617bc4ae4beSMatthew G. Knepley 618bc4ae4beSMatthew G. Knepley Input Parameter: 619bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 620bc4ae4beSMatthew G. Knepley 621bc4ae4beSMatthew G. Knepley Output Parameter: 622bc4ae4beSMatthew G. Knepley . Nf - The number of fields 623bc4ae4beSMatthew G. Knepley 624bc4ae4beSMatthew G. Knepley Level: beginner 625bc4ae4beSMatthew G. Knepley 626bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 627bc4ae4beSMatthew G. Knepley @*/ 6282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6292764a2aaSMatthew G. Knepley { 6302764a2aaSMatthew G. Knepley PetscFunctionBegin; 6312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6322764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6332764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6352764a2aaSMatthew G. Knepley } 6362764a2aaSMatthew G. Knepley 637bc4ae4beSMatthew G. Knepley /*@ 638a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 639bc4ae4beSMatthew G. Knepley 640bc4ae4beSMatthew G. Knepley Not collective 641bc4ae4beSMatthew G. Knepley 642bc4ae4beSMatthew G. Knepley Input Parameter: 643bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 644bc4ae4beSMatthew G. Knepley 645bc4ae4beSMatthew G. Knepley Output Parameter: 646bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 647bc4ae4beSMatthew G. Knepley 648bc4ae4beSMatthew G. Knepley Level: beginner 649bc4ae4beSMatthew G. Knepley 650a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 651bc4ae4beSMatthew G. Knepley @*/ 6522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6532764a2aaSMatthew G. Knepley { 6542764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6552764a2aaSMatthew G. Knepley 6562764a2aaSMatthew G. Knepley PetscFunctionBegin; 6572764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6582764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6592764a2aaSMatthew G. Knepley *dim = 0; 6609de99aefSMatthew G. Knepley if (prob->Nf) { 6619de99aefSMatthew G. Knepley PetscObject obj; 6629de99aefSMatthew G. Knepley PetscClassId id; 6639de99aefSMatthew G. Knepley 6649de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 6659de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 6669de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 6679de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 6689de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6699de99aefSMatthew G. Knepley } 6702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6712764a2aaSMatthew G. Knepley } 6722764a2aaSMatthew G. Knepley 673bc4ae4beSMatthew G. Knepley /*@ 674a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 675a859676bSMatthew G. Knepley 676a859676bSMatthew G. Knepley Not collective 677a859676bSMatthew G. Knepley 678a859676bSMatthew G. Knepley Input Parameter: 679a859676bSMatthew G. Knepley . prob - The PetscDS object 680a859676bSMatthew G. Knepley 681a859676bSMatthew G. Knepley Output Parameter: 682a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 683a859676bSMatthew G. Knepley 684a859676bSMatthew G. Knepley Level: beginner 685a859676bSMatthew G. Knepley 686a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 687a859676bSMatthew G. Knepley @*/ 688a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 689a859676bSMatthew G. Knepley { 690a859676bSMatthew G. Knepley PetscFunctionBegin; 691a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 692a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 693a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 694a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 695a859676bSMatthew G. Knepley PetscFunctionReturn(0); 696a859676bSMatthew G. Knepley } 697a859676bSMatthew G. Knepley 698a859676bSMatthew G. Knepley /*@ 699a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 700a859676bSMatthew G. Knepley 701d083f849SBarry Smith Logically collective on prob 702a859676bSMatthew G. Knepley 703a859676bSMatthew G. Knepley Input Parameters: 704a859676bSMatthew G. Knepley + prob - The PetscDS object 705a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 706a859676bSMatthew G. Knepley 707a859676bSMatthew G. Knepley Level: beginner 708a859676bSMatthew G. Knepley 709a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 710a859676bSMatthew G. Knepley @*/ 711a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 712a859676bSMatthew G. Knepley { 713a859676bSMatthew G. Knepley PetscFunctionBegin; 714a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 715ebfe4b0dSMatthew G. Knepley if (dimEmbed < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 716a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 717a859676bSMatthew G. Knepley PetscFunctionReturn(0); 718a859676bSMatthew G. Knepley } 719a859676bSMatthew G. Knepley 720a859676bSMatthew G. Knepley /*@ 7218edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 7228edf6225SMatthew G. Knepley 7238edf6225SMatthew G. Knepley Not collective 7248edf6225SMatthew G. Knepley 7258edf6225SMatthew G. Knepley Input Parameter: 7268edf6225SMatthew G. Knepley . prob - The PetscDS object 7278edf6225SMatthew G. Knepley 7288edf6225SMatthew G. Knepley Output Parameter: 7298edf6225SMatthew G. Knepley . isHybrid - The flag 7308edf6225SMatthew G. Knepley 7318edf6225SMatthew G. Knepley Level: developer 7328edf6225SMatthew G. Knepley 7338edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 7348edf6225SMatthew G. Knepley @*/ 7358edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 7368edf6225SMatthew G. Knepley { 7378edf6225SMatthew G. Knepley PetscFunctionBegin; 7388edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7398edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 7408edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 7418edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7428edf6225SMatthew G. Knepley } 7438edf6225SMatthew G. Knepley 7448edf6225SMatthew G. Knepley /*@ 7458edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 7468edf6225SMatthew G. Knepley 7478edf6225SMatthew G. Knepley Not collective 7488edf6225SMatthew G. Knepley 7498edf6225SMatthew G. Knepley Input Parameters: 7508edf6225SMatthew G. Knepley + prob - The PetscDS object 7518edf6225SMatthew G. Knepley - isHybrid - The flag 7528edf6225SMatthew G. Knepley 7538edf6225SMatthew G. Knepley Level: developer 7548edf6225SMatthew G. Knepley 7558edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 7568edf6225SMatthew G. Knepley @*/ 7578edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 7588edf6225SMatthew G. Knepley { 7598edf6225SMatthew G. Knepley PetscFunctionBegin; 7608edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7618edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 7628edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7638edf6225SMatthew G. Knepley } 7648edf6225SMatthew G. Knepley 7658edf6225SMatthew G. Knepley /*@ 766bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 767bc4ae4beSMatthew G. Knepley 768bc4ae4beSMatthew G. Knepley Not collective 769bc4ae4beSMatthew G. Knepley 770bc4ae4beSMatthew G. Knepley Input Parameter: 771bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 772bc4ae4beSMatthew G. Knepley 773bc4ae4beSMatthew G. Knepley Output Parameter: 774bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 775bc4ae4beSMatthew G. Knepley 776bc4ae4beSMatthew G. Knepley Level: beginner 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 779bc4ae4beSMatthew G. Knepley @*/ 7802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7812764a2aaSMatthew G. Knepley { 7822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7832764a2aaSMatthew G. Knepley 7842764a2aaSMatthew G. Knepley PetscFunctionBegin; 7852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7862764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7872764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 7882764a2aaSMatthew G. Knepley *dim = prob->totDim; 7892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7902764a2aaSMatthew G. Knepley } 7912764a2aaSMatthew G. Knepley 792bc4ae4beSMatthew G. Knepley /*@ 793bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 794bc4ae4beSMatthew G. Knepley 795bc4ae4beSMatthew G. Knepley Not collective 796bc4ae4beSMatthew G. Knepley 797bc4ae4beSMatthew G. Knepley Input Parameter: 798bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 799bc4ae4beSMatthew G. Knepley 800bc4ae4beSMatthew G. Knepley Output Parameter: 801bc4ae4beSMatthew G. Knepley . dim - The total number of components 802bc4ae4beSMatthew G. Knepley 803bc4ae4beSMatthew G. Knepley Level: beginner 804bc4ae4beSMatthew G. Knepley 805bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 806bc4ae4beSMatthew G. Knepley @*/ 8072764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8082764a2aaSMatthew G. Knepley { 8092764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8102764a2aaSMatthew G. Knepley 8112764a2aaSMatthew G. Knepley PetscFunctionBegin; 8122764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8132764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8142764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8152764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8172764a2aaSMatthew G. Knepley } 8182764a2aaSMatthew G. Knepley 819bc4ae4beSMatthew G. Knepley /*@ 820bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 821bc4ae4beSMatthew G. Knepley 822bc4ae4beSMatthew G. Knepley Not collective 823bc4ae4beSMatthew G. Knepley 824bc4ae4beSMatthew G. Knepley Input Parameters: 825bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 826bc4ae4beSMatthew G. Knepley - f - The field number 827bc4ae4beSMatthew G. Knepley 828bc4ae4beSMatthew G. Knepley Output Parameter: 829bc4ae4beSMatthew G. Knepley . disc - The discretization object 830bc4ae4beSMatthew G. Knepley 831bc4ae4beSMatthew G. Knepley Level: beginner 832bc4ae4beSMatthew G. Knepley 833f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 834bc4ae4beSMatthew G. Knepley @*/ 8352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8362764a2aaSMatthew G. Knepley { 8372764a2aaSMatthew G. Knepley PetscFunctionBegin; 8382764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8392764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8402764a2aaSMatthew 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); 8412764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8432764a2aaSMatthew G. Knepley } 8442764a2aaSMatthew G. Knepley 845bc4ae4beSMatthew G. Knepley /*@ 846bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 847bc4ae4beSMatthew G. Knepley 848bc4ae4beSMatthew G. Knepley Not collective 849bc4ae4beSMatthew G. Knepley 850bc4ae4beSMatthew G. Knepley Input Parameters: 851bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 852bc4ae4beSMatthew G. Knepley . f - The field number 853bc4ae4beSMatthew G. Knepley - disc - The discretization object 854bc4ae4beSMatthew G. Knepley 855bc4ae4beSMatthew G. Knepley Level: beginner 856bc4ae4beSMatthew G. Knepley 857bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 858bc4ae4beSMatthew G. Knepley @*/ 8592764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 8602764a2aaSMatthew G. Knepley { 8612764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8622764a2aaSMatthew G. Knepley 8632764a2aaSMatthew G. Knepley PetscFunctionBegin; 8642764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8652764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8662764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 8672764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 868c10f2116SMatthew G. Knepley ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr); 8692764a2aaSMatthew G. Knepley prob->disc[f] = disc; 8702764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 871249df284SMatthew G. Knepley { 872249df284SMatthew G. Knepley PetscClassId id; 873249df284SMatthew G. Knepley 874249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8751cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8761cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8771cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8781cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 879a6cbbb48SMatthew G. Knepley } 880249df284SMatthew G. Knepley } 8812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8822764a2aaSMatthew G. Knepley } 8832764a2aaSMatthew G. Knepley 884bc4ae4beSMatthew G. Knepley /*@ 885bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 886bc4ae4beSMatthew G. Knepley 887bc4ae4beSMatthew G. Knepley Not collective 888bc4ae4beSMatthew G. Knepley 889bc4ae4beSMatthew G. Knepley Input Parameters: 890bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 891bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 892bc4ae4beSMatthew G. Knepley 893bc4ae4beSMatthew G. Knepley Level: beginner 894bc4ae4beSMatthew G. Knepley 895bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 896bc4ae4beSMatthew G. Knepley @*/ 8972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8982764a2aaSMatthew G. Knepley { 8992764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9002764a2aaSMatthew G. Knepley 9012764a2aaSMatthew G. Knepley PetscFunctionBegin; 9022764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 9032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9042764a2aaSMatthew G. Knepley } 9052764a2aaSMatthew G. Knepley 906249df284SMatthew G. Knepley /*@ 907249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 908249df284SMatthew G. Knepley 909249df284SMatthew G. Knepley Not collective 910249df284SMatthew G. Knepley 911249df284SMatthew G. Knepley Input Parameters: 912249df284SMatthew G. Knepley + prob - The PetscDS object 913249df284SMatthew G. Knepley - f - The field number 914249df284SMatthew G. Knepley 915249df284SMatthew G. Knepley Output Parameter: 916249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 917249df284SMatthew G. Knepley 918249df284SMatthew G. Knepley Level: developer 919249df284SMatthew G. Knepley 920f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 921249df284SMatthew G. Knepley @*/ 922249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 923249df284SMatthew G. Knepley { 924249df284SMatthew G. Knepley PetscFunctionBegin; 925249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 926249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 927249df284SMatthew 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); 928249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 929249df284SMatthew G. Knepley PetscFunctionReturn(0); 930249df284SMatthew G. Knepley } 931249df284SMatthew G. Knepley 932249df284SMatthew G. Knepley /*@ 933249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 934249df284SMatthew G. Knepley 935249df284SMatthew G. Knepley Not collective 936249df284SMatthew G. Knepley 937249df284SMatthew G. Knepley Input Parameters: 938249df284SMatthew G. Knepley + prob - The PetscDS object 939249df284SMatthew G. Knepley . f - The field number 940249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 941249df284SMatthew G. Knepley 942249df284SMatthew G. Knepley Level: developer 943249df284SMatthew G. Knepley 944f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 945249df284SMatthew G. Knepley @*/ 946249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 947249df284SMatthew G. Knepley { 948249df284SMatthew G. Knepley PetscFunctionBegin; 949249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 950249df284SMatthew 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); 951249df284SMatthew G. Knepley prob->implicit[f] = implicit; 952249df284SMatthew G. Knepley PetscFunctionReturn(0); 953249df284SMatthew G. Knepley } 954249df284SMatthew G. Knepley 9552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 95630b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 957194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 958194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 95997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9602764a2aaSMatthew G. Knepley { 9612764a2aaSMatthew G. Knepley PetscFunctionBegin; 9622764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9632764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9642764a2aaSMatthew 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); 9652764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9672764a2aaSMatthew G. Knepley } 9682764a2aaSMatthew G. Knepley 9692764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 97030b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 971194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 972194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 97397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9742764a2aaSMatthew G. Knepley { 9752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9762764a2aaSMatthew G. Knepley 9772764a2aaSMatthew G. Knepley PetscFunctionBegin; 9782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 979de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9802764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9822764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9842764a2aaSMatthew G. Knepley } 9852764a2aaSMatthew G. Knepley 986194d53e6SMatthew G. Knepley /*@C 987194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 988194d53e6SMatthew G. Knepley 989194d53e6SMatthew G. Knepley Not collective 990194d53e6SMatthew G. Knepley 991194d53e6SMatthew G. Knepley Input Parameters: 992194d53e6SMatthew G. Knepley + prob - The PetscDS 993194d53e6SMatthew G. Knepley - f - The test field number 994194d53e6SMatthew G. Knepley 995194d53e6SMatthew G. Knepley Output Parameters: 996194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 997194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1000194d53e6SMatthew G. Knepley 1001194d53e6SMatthew 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) 1002194d53e6SMatthew G. Knepley 1003194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1004194d53e6SMatthew G. Knepley 100530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1006194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1007194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 100830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1009194d53e6SMatthew G. Knepley 1010194d53e6SMatthew G. Knepley + dim - the spatial dimension 1011194d53e6SMatthew G. Knepley . Nf - the number of fields 1012194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1013194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1014194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1015194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1016194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1017194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1018194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1019194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1020194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1021194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1022194d53e6SMatthew G. Knepley . t - current time 1023194d53e6SMatthew G. Knepley . x - coordinates of the current point 102497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 102597b6e6e8SMatthew G. Knepley . constants - constant parameters 1026194d53e6SMatthew G. Knepley - f0 - output values at the current point 1027194d53e6SMatthew G. Knepley 1028194d53e6SMatthew G. Knepley Level: intermediate 1029194d53e6SMatthew G. Knepley 1030194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1031194d53e6SMatthew G. Knepley @*/ 10322764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 103330b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1034194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1035194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 103697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 103730b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1038194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1039194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 10412764a2aaSMatthew G. Knepley { 10422764a2aaSMatthew G. Knepley PetscFunctionBegin; 10432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10442764a2aaSMatthew 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); 10452764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10462764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10472764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10482764a2aaSMatthew G. Knepley } 10492764a2aaSMatthew G. Knepley 1050194d53e6SMatthew G. Knepley /*@C 1051194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1052194d53e6SMatthew G. Knepley 1053194d53e6SMatthew G. Knepley Not collective 1054194d53e6SMatthew G. Knepley 1055194d53e6SMatthew G. Knepley Input Parameters: 1056194d53e6SMatthew G. Knepley + prob - The PetscDS 1057194d53e6SMatthew G. Knepley . f - The test field number 1058194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1059194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1060194d53e6SMatthew G. Knepley 1061194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew 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) 1064194d53e6SMatthew G. Knepley 1065194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1066194d53e6SMatthew G. Knepley 106730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1068194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1069194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 107030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1071194d53e6SMatthew G. Knepley 1072194d53e6SMatthew G. Knepley + dim - the spatial dimension 1073194d53e6SMatthew G. Knepley . Nf - the number of fields 1074194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1075194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1076194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1077194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1078194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1079194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1080194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1081194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1082194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1083194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1084194d53e6SMatthew G. Knepley . t - current time 1085194d53e6SMatthew G. Knepley . x - coordinates of the current point 108697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 108797b6e6e8SMatthew G. Knepley . constants - constant parameters 1088194d53e6SMatthew G. Knepley - f0 - output values at the current point 1089194d53e6SMatthew G. Knepley 1090194d53e6SMatthew G. Knepley Level: intermediate 1091194d53e6SMatthew G. Knepley 1092194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1093194d53e6SMatthew G. Knepley @*/ 10942764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 109530b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1096194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1097194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 109897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 109930b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1100194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1101194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11032764a2aaSMatthew G. Knepley { 11042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11052764a2aaSMatthew G. Knepley 11062764a2aaSMatthew G. Knepley PetscFunctionBegin; 11072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1108f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1109f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11102764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11112764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11122764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11132764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11152764a2aaSMatthew G. Knepley } 11162764a2aaSMatthew G. Knepley 11173e75805dSMatthew G. Knepley /*@C 11183e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11193e75805dSMatthew G. Knepley 11203e75805dSMatthew G. Knepley Not collective 11213e75805dSMatthew G. Knepley 11223e75805dSMatthew G. Knepley Input Parameter: 11233e75805dSMatthew G. Knepley . prob - The PetscDS 11243e75805dSMatthew G. Knepley 11253e75805dSMatthew G. Knepley Output Parameter: 11263e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11273e75805dSMatthew G. Knepley 11283e75805dSMatthew G. Knepley Level: intermediate 11293e75805dSMatthew G. Knepley 11303e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11313e75805dSMatthew G. Knepley @*/ 11323e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11333e75805dSMatthew G. Knepley { 11343e75805dSMatthew G. Knepley PetscInt f, g, h; 11353e75805dSMatthew G. Knepley 11363e75805dSMatthew G. Knepley PetscFunctionBegin; 11373e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11383e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11393e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11403e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11413e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11423e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11433e75805dSMatthew G. Knepley } 11443e75805dSMatthew G. Knepley } 11453e75805dSMatthew G. Knepley } 11463e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11473e75805dSMatthew G. Knepley } 11483e75805dSMatthew G. Knepley 1149194d53e6SMatthew G. Knepley /*@C 1150194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1151194d53e6SMatthew G. Knepley 1152194d53e6SMatthew G. Knepley Not collective 1153194d53e6SMatthew G. Knepley 1154194d53e6SMatthew G. Knepley Input Parameters: 1155194d53e6SMatthew G. Knepley + prob - The PetscDS 1156194d53e6SMatthew G. Knepley . f - The test field number 1157194d53e6SMatthew G. Knepley - g - The field number 1158194d53e6SMatthew G. Knepley 1159194d53e6SMatthew G. Knepley Output Parameters: 1160194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1161194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1162194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1163194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1164194d53e6SMatthew G. Knepley 1165194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1166194d53e6SMatthew G. Knepley 1167194d53e6SMatthew 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 1168194d53e6SMatthew G. Knepley 1169194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1170194d53e6SMatthew G. Knepley 117130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1172194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1173194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1175194d53e6SMatthew G. Knepley 1176194d53e6SMatthew G. Knepley + dim - the spatial dimension 1177194d53e6SMatthew G. Knepley . Nf - the number of fields 1178194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1179194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1180194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1181194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1182194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1183194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1184194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1185194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1186194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1187194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1188194d53e6SMatthew G. Knepley . t - current time 11892aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1190194d53e6SMatthew G. Knepley . x - coordinates of the current point 119197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 119297b6e6e8SMatthew G. Knepley . constants - constant parameters 1193194d53e6SMatthew G. Knepley - g0 - output values at the current point 1194194d53e6SMatthew G. Knepley 1195194d53e6SMatthew G. Knepley Level: intermediate 1196194d53e6SMatthew G. Knepley 1197194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1198194d53e6SMatthew G. Knepley @*/ 11992764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 120030b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1201194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1202194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 120430b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1205194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1206194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 120830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1209194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1210194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 121230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1213194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1214194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12162764a2aaSMatthew G. Knepley { 12172764a2aaSMatthew G. Knepley PetscFunctionBegin; 12182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12192764a2aaSMatthew 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); 12202764a2aaSMatthew 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); 12212764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12222764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12232764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12242764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12262764a2aaSMatthew G. Knepley } 12272764a2aaSMatthew G. Knepley 1228194d53e6SMatthew G. Knepley /*@C 1229194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1230194d53e6SMatthew G. Knepley 1231194d53e6SMatthew G. Knepley Not collective 1232194d53e6SMatthew G. Knepley 1233194d53e6SMatthew G. Knepley Input Parameters: 1234194d53e6SMatthew G. Knepley + prob - The PetscDS 1235194d53e6SMatthew G. Knepley . f - The test field number 1236194d53e6SMatthew G. Knepley . g - The field number 1237194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1238194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1239194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1240194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1241194d53e6SMatthew G. Knepley 1242194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1243194d53e6SMatthew G. Knepley 1244194d53e6SMatthew 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 1245194d53e6SMatthew G. Knepley 1246194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1247194d53e6SMatthew G. Knepley 124830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1249194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1250194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 125130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1252194d53e6SMatthew G. Knepley 1253194d53e6SMatthew G. Knepley + dim - the spatial dimension 1254194d53e6SMatthew G. Knepley . Nf - the number of fields 1255194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1256194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1257194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1258194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1259194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1260194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1261194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1262194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1263194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1264194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1265194d53e6SMatthew G. Knepley . t - current time 12662aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1267194d53e6SMatthew G. Knepley . x - coordinates of the current point 126897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 126997b6e6e8SMatthew G. Knepley . constants - constant parameters 1270194d53e6SMatthew G. Knepley - g0 - output values at the current point 1271194d53e6SMatthew G. Knepley 1272194d53e6SMatthew G. Knepley Level: intermediate 1273194d53e6SMatthew G. Knepley 1274194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1275194d53e6SMatthew G. Knepley @*/ 12762764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 127730b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1278194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1279194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 128130b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1282194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1283194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 128530b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1286194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1287194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 128930b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1290194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1291194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12932764a2aaSMatthew G. Knepley { 12942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12952764a2aaSMatthew G. Knepley 12962764a2aaSMatthew G. Knepley PetscFunctionBegin; 12972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12982764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12992764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 13002764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 13012764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13022764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13032764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13042764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13052764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13062764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13072764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13082764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13102764a2aaSMatthew G. Knepley } 13112764a2aaSMatthew G. Knepley 1312475e0ac9SMatthew G. Knepley /*@C 131355c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 131455c1f793SMatthew G. Knepley 131555c1f793SMatthew G. Knepley Not collective 131655c1f793SMatthew G. Knepley 131755c1f793SMatthew G. Knepley Input Parameters: 131855c1f793SMatthew G. Knepley + prob - The PetscDS 131955c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 132055c1f793SMatthew G. Knepley 132155c1f793SMatthew G. Knepley Level: intermediate 132255c1f793SMatthew G. Knepley 132355c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 132455c1f793SMatthew G. Knepley @*/ 132555c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 132655c1f793SMatthew G. Knepley { 132755c1f793SMatthew G. Knepley PetscFunctionBegin; 132855c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 132955c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 133055c1f793SMatthew G. Knepley PetscFunctionReturn(0); 133155c1f793SMatthew G. Knepley } 133255c1f793SMatthew G. Knepley 133355c1f793SMatthew G. Knepley /*@C 1334475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1335475e0ac9SMatthew G. Knepley 1336475e0ac9SMatthew G. Knepley Not collective 1337475e0ac9SMatthew G. Knepley 1338475e0ac9SMatthew G. Knepley Input Parameter: 1339475e0ac9SMatthew G. Knepley . prob - The PetscDS 1340475e0ac9SMatthew G. Knepley 1341475e0ac9SMatthew G. Knepley Output Parameter: 1342475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1343475e0ac9SMatthew G. Knepley 1344475e0ac9SMatthew G. Knepley Level: intermediate 1345475e0ac9SMatthew G. Knepley 1346475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1347475e0ac9SMatthew G. Knepley @*/ 1348475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1349475e0ac9SMatthew G. Knepley { 1350475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1351475e0ac9SMatthew G. Knepley 1352475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1353475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1354475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 135555c1f793SMatthew G. Knepley if (!prob->useJacPre) PetscFunctionReturn(0); 1356475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1357475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1358475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1359475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1360475e0ac9SMatthew G. Knepley } 1361475e0ac9SMatthew G. Knepley } 1362475e0ac9SMatthew G. Knepley } 1363475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1364475e0ac9SMatthew G. Knepley } 1365475e0ac9SMatthew G. Knepley 1366475e0ac9SMatthew G. Knepley /*@C 1367475e0ac9SMatthew 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. 1368475e0ac9SMatthew G. Knepley 1369475e0ac9SMatthew G. Knepley Not collective 1370475e0ac9SMatthew G. Knepley 1371475e0ac9SMatthew G. Knepley Input Parameters: 1372475e0ac9SMatthew G. Knepley + prob - The PetscDS 1373475e0ac9SMatthew G. Knepley . f - The test field number 1374475e0ac9SMatthew G. Knepley - g - The field number 1375475e0ac9SMatthew G. Knepley 1376475e0ac9SMatthew G. Knepley Output Parameters: 1377475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1378475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1379475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1380475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1381475e0ac9SMatthew G. Knepley 1382475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew 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 1385475e0ac9SMatthew G. Knepley 1386475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1387475e0ac9SMatthew G. Knepley 1388475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1389475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1390475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1391475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1392475e0ac9SMatthew G. Knepley 1393475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1394475e0ac9SMatthew G. Knepley . Nf - the number of fields 1395475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1396475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1397475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1398475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1399475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1400475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1401475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1402475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1403475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1404475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1405475e0ac9SMatthew G. Knepley . t - current time 1406475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1407475e0ac9SMatthew G. Knepley . x - coordinates of the current point 140897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 140997b6e6e8SMatthew G. Knepley . constants - constant parameters 1410475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1411475e0ac9SMatthew G. Knepley 1412475e0ac9SMatthew G. Knepley Level: intermediate 1413475e0ac9SMatthew G. Knepley 1414475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1415475e0ac9SMatthew G. Knepley @*/ 1416475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1417475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1418475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1419475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1421475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1422475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1423475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1425475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1426475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1427475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1429475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1430475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1431475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 143297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1433475e0ac9SMatthew G. Knepley { 1434475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1435475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1436475e0ac9SMatthew 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); 1437475e0ac9SMatthew 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); 1438475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1439475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1440475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1441475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1442475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1443475e0ac9SMatthew G. Knepley } 1444475e0ac9SMatthew G. Knepley 1445475e0ac9SMatthew G. Knepley /*@C 1446475e0ac9SMatthew 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. 1447475e0ac9SMatthew G. Knepley 1448475e0ac9SMatthew G. Knepley Not collective 1449475e0ac9SMatthew G. Knepley 1450475e0ac9SMatthew G. Knepley Input Parameters: 1451475e0ac9SMatthew G. Knepley + prob - The PetscDS 1452475e0ac9SMatthew G. Knepley . f - The test field number 1453475e0ac9SMatthew G. Knepley . g - The field number 1454475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1455475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1456475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1457475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1458475e0ac9SMatthew G. Knepley 1459475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1460475e0ac9SMatthew G. Knepley 1461475e0ac9SMatthew 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 1462475e0ac9SMatthew G. Knepley 1463475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1464475e0ac9SMatthew G. Knepley 1465475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1466475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1467475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1468475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1469475e0ac9SMatthew G. Knepley 1470475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1471475e0ac9SMatthew G. Knepley . Nf - the number of fields 1472475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1473475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1474475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1475475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1476475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1477475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1478475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1479475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1480475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1481475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1482475e0ac9SMatthew G. Knepley . t - current time 1483475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1484475e0ac9SMatthew G. Knepley . x - coordinates of the current point 148597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 148697b6e6e8SMatthew G. Knepley . constants - constant parameters 1487475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1488475e0ac9SMatthew G. Knepley 1489475e0ac9SMatthew G. Knepley Level: intermediate 1490475e0ac9SMatthew G. Knepley 1491475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1492475e0ac9SMatthew G. Knepley @*/ 1493475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1494475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1495475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1496475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1498475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1499475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1500475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1502475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1503475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1504475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1506475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1507475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1508475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1510475e0ac9SMatthew G. Knepley { 1511475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1512475e0ac9SMatthew G. Knepley 1513475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1514475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1515475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1516475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1517475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1518475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1519475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1520475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1521475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1522475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1523475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1524475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1525475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1526475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1527475e0ac9SMatthew G. Knepley } 1528475e0ac9SMatthew G. Knepley 1529b7e05686SMatthew G. Knepley /*@C 1530b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1531b7e05686SMatthew G. Knepley 1532b7e05686SMatthew G. Knepley Not collective 1533b7e05686SMatthew G. Knepley 1534b7e05686SMatthew G. Knepley Input Parameter: 1535b7e05686SMatthew G. Knepley . prob - The PetscDS 1536b7e05686SMatthew G. Knepley 1537b7e05686SMatthew G. Knepley Output Parameter: 1538b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1539b7e05686SMatthew G. Knepley 1540b7e05686SMatthew G. Knepley Level: intermediate 1541b7e05686SMatthew G. Knepley 1542b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1543b7e05686SMatthew G. Knepley @*/ 1544b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1545b7e05686SMatthew G. Knepley { 1546b7e05686SMatthew G. Knepley PetscInt f, g, h; 1547b7e05686SMatthew G. Knepley 1548b7e05686SMatthew G. Knepley PetscFunctionBegin; 1549b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1550b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1551b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1552b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1553b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1554b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1555b7e05686SMatthew G. Knepley } 1556b7e05686SMatthew G. Knepley } 1557b7e05686SMatthew G. Knepley } 1558b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1559b7e05686SMatthew G. Knepley } 1560b7e05686SMatthew G. Knepley 1561b7e05686SMatthew G. Knepley /*@C 1562b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1563b7e05686SMatthew G. Knepley 1564b7e05686SMatthew G. Knepley Not collective 1565b7e05686SMatthew G. Knepley 1566b7e05686SMatthew G. Knepley Input Parameters: 1567b7e05686SMatthew G. Knepley + prob - The PetscDS 1568b7e05686SMatthew G. Knepley . f - The test field number 1569b7e05686SMatthew G. Knepley - g - The field number 1570b7e05686SMatthew G. Knepley 1571b7e05686SMatthew G. Knepley Output Parameters: 1572b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1573b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1574b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1575b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1576b7e05686SMatthew G. Knepley 1577b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1578b7e05686SMatthew G. Knepley 1579b7e05686SMatthew 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 1580b7e05686SMatthew G. Knepley 1581b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1582b7e05686SMatthew G. Knepley 1583b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1584b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1585b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1586b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1587b7e05686SMatthew G. Knepley 1588b7e05686SMatthew G. Knepley + dim - the spatial dimension 1589b7e05686SMatthew G. Knepley . Nf - the number of fields 1590b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1591b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1592b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1593b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1594b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1595b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1596b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1597b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1598b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1599b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1600b7e05686SMatthew G. Knepley . t - current time 1601b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1602b7e05686SMatthew G. Knepley . x - coordinates of the current point 160397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 160497b6e6e8SMatthew G. Knepley . constants - constant parameters 1605b7e05686SMatthew G. Knepley - g0 - output values at the current point 1606b7e05686SMatthew G. Knepley 1607b7e05686SMatthew G. Knepley Level: intermediate 1608b7e05686SMatthew G. Knepley 1609b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1610b7e05686SMatthew G. Knepley @*/ 1611b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1612b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1613b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1614b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 161597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1616b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1617b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1618b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 161997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1620b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1621b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1622b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1624b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1625b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1626b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1628b7e05686SMatthew G. Knepley { 1629b7e05686SMatthew G. Knepley PetscFunctionBegin; 1630b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1631b7e05686SMatthew 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); 1632b7e05686SMatthew 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); 1633b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1634b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1635b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1636b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1637b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1638b7e05686SMatthew G. Knepley } 1639b7e05686SMatthew G. Knepley 1640b7e05686SMatthew G. Knepley /*@C 1641b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1642b7e05686SMatthew G. Knepley 1643b7e05686SMatthew G. Knepley Not collective 1644b7e05686SMatthew G. Knepley 1645b7e05686SMatthew G. Knepley Input Parameters: 1646b7e05686SMatthew G. Knepley + prob - The PetscDS 1647b7e05686SMatthew G. Knepley . f - The test field number 1648b7e05686SMatthew G. Knepley . g - The field number 1649b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1650b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1651b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1652b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1653b7e05686SMatthew G. Knepley 1654b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1655b7e05686SMatthew G. Knepley 1656b7e05686SMatthew 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 1657b7e05686SMatthew G. Knepley 1658b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1659b7e05686SMatthew G. Knepley 1660b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1661b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1662b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1663b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1664b7e05686SMatthew G. Knepley 1665b7e05686SMatthew G. Knepley + dim - the spatial dimension 1666b7e05686SMatthew G. Knepley . Nf - the number of fields 1667b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1668b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1669b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1670b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1671b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1672b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1673b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1674b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1675b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1676b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1677b7e05686SMatthew G. Knepley . t - current time 1678b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1679b7e05686SMatthew G. Knepley . x - coordinates of the current point 168097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 168197b6e6e8SMatthew G. Knepley . constants - constant parameters 1682b7e05686SMatthew G. Knepley - g0 - output values at the current point 1683b7e05686SMatthew G. Knepley 1684b7e05686SMatthew G. Knepley Level: intermediate 1685b7e05686SMatthew G. Knepley 1686b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1687b7e05686SMatthew G. Knepley @*/ 1688b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1689b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1690b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1691b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 169297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1693b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1694b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1695b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 169697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1697b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1698b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1699b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1701b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1702b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1703b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1705b7e05686SMatthew G. Knepley { 1706b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1707b7e05686SMatthew G. Knepley 1708b7e05686SMatthew G. Knepley PetscFunctionBegin; 1709b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1710b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1711b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1712b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1713b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1714b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1715b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1716b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1717b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1718b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1719b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1720b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1721b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1722b7e05686SMatthew G. Knepley } 1723b7e05686SMatthew G. Knepley 17240c2f2876SMatthew G. Knepley /*@C 17250c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17260c2f2876SMatthew G. Knepley 17270c2f2876SMatthew G. Knepley Not collective 17280c2f2876SMatthew G. Knepley 17290c2f2876SMatthew G. Knepley Input Arguments: 17300c2f2876SMatthew G. Knepley + prob - The PetscDS object 17310c2f2876SMatthew G. Knepley - f - The field number 17320c2f2876SMatthew G. Knepley 17330c2f2876SMatthew G. Knepley Output Argument: 17340c2f2876SMatthew G. Knepley . r - Riemann solver 17350c2f2876SMatthew G. Knepley 17360c2f2876SMatthew G. Knepley Calling sequence for r: 17370c2f2876SMatthew G. Knepley 17385db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17390c2f2876SMatthew G. Knepley 17405db36cf9SMatthew G. Knepley + dim - The spatial dimension 17415db36cf9SMatthew G. Knepley . Nf - The number of fields 17425db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17430c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17440c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17450c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17460c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 174797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 174897b6e6e8SMatthew G. Knepley . constants - constant parameters 17490c2f2876SMatthew G. Knepley - ctx - optional user context 17500c2f2876SMatthew G. Knepley 17510c2f2876SMatthew G. Knepley Level: intermediate 17520c2f2876SMatthew G. Knepley 17530c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17540c2f2876SMatthew G. Knepley @*/ 17550c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 175697b6e6e8SMatthew 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)) 17570c2f2876SMatthew G. Knepley { 17580c2f2876SMatthew G. Knepley PetscFunctionBegin; 17590c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17600c2f2876SMatthew 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); 17610c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17620c2f2876SMatthew G. Knepley *r = prob->r[f]; 17630c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17640c2f2876SMatthew G. Knepley } 17650c2f2876SMatthew G. Knepley 17660c2f2876SMatthew G. Knepley /*@C 17670c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17680c2f2876SMatthew G. Knepley 17690c2f2876SMatthew G. Knepley Not collective 17700c2f2876SMatthew G. Knepley 17710c2f2876SMatthew G. Knepley Input Arguments: 17720c2f2876SMatthew G. Knepley + prob - The PetscDS object 17730c2f2876SMatthew G. Knepley . f - The field number 17740c2f2876SMatthew G. Knepley - r - Riemann solver 17750c2f2876SMatthew G. Knepley 17760c2f2876SMatthew G. Knepley Calling sequence for r: 17770c2f2876SMatthew G. Knepley 17785db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17790c2f2876SMatthew G. Knepley 17805db36cf9SMatthew G. Knepley + dim - The spatial dimension 17815db36cf9SMatthew G. Knepley . Nf - The number of fields 17825db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17830c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17840c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17850c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17860c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 178797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 178897b6e6e8SMatthew G. Knepley . constants - constant parameters 17890c2f2876SMatthew G. Knepley - ctx - optional user context 17900c2f2876SMatthew G. Knepley 17910c2f2876SMatthew G. Knepley Level: intermediate 17920c2f2876SMatthew G. Knepley 17930c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17940c2f2876SMatthew G. Knepley @*/ 17950c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 179697b6e6e8SMatthew 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)) 17970c2f2876SMatthew G. Knepley { 17980c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17990c2f2876SMatthew G. Knepley 18000c2f2876SMatthew G. Knepley PetscFunctionBegin; 18010c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1802de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 18030c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18040c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18050c2f2876SMatthew G. Knepley prob->r[f] = r; 18060c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18070c2f2876SMatthew G. Knepley } 18080c2f2876SMatthew G. Knepley 180932d2bbc9SMatthew G. Knepley /*@C 181032d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 181132d2bbc9SMatthew G. Knepley 181232d2bbc9SMatthew G. Knepley Not collective 181332d2bbc9SMatthew G. Knepley 181432d2bbc9SMatthew G. Knepley Input Parameters: 181532d2bbc9SMatthew G. Knepley + prob - The PetscDS 181632d2bbc9SMatthew G. Knepley - f - The field number 181732d2bbc9SMatthew G. Knepley 181832d2bbc9SMatthew G. Knepley Output Parameters: 1819a2b725a8SWilliam Gropp . update - update function 182032d2bbc9SMatthew G. Knepley 182132d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 182232d2bbc9SMatthew G. Knepley 182332d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 182432d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 182532d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182632d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 182732d2bbc9SMatthew G. Knepley 182832d2bbc9SMatthew G. Knepley + dim - the spatial dimension 182932d2bbc9SMatthew G. Knepley . Nf - the number of fields 183032d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 183132d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 183232d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 183332d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 183432d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 183532d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 183632d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 183732d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 183832d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 183932d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 184032d2bbc9SMatthew G. Knepley . t - current time 184132d2bbc9SMatthew G. Knepley . x - coordinates of the current point 184232d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 184332d2bbc9SMatthew G. Knepley 184432d2bbc9SMatthew G. Knepley Level: intermediate 184532d2bbc9SMatthew G. Knepley 184632d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 184732d2bbc9SMatthew G. Knepley @*/ 184832d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS prob, PetscInt f, 184932d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 185032d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 185132d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18523fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 185332d2bbc9SMatthew G. Knepley { 185432d2bbc9SMatthew G. Knepley PetscFunctionBegin; 185532d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 185632d2bbc9SMatthew 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); 185732d2bbc9SMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = prob->update[f];} 185832d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 185932d2bbc9SMatthew G. Knepley } 186032d2bbc9SMatthew G. Knepley 186132d2bbc9SMatthew G. Knepley /*@C 18623fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 186332d2bbc9SMatthew G. Knepley 186432d2bbc9SMatthew G. Knepley Not collective 186532d2bbc9SMatthew G. Knepley 186632d2bbc9SMatthew G. Knepley Input Parameters: 186732d2bbc9SMatthew G. Knepley + prob - The PetscDS 186832d2bbc9SMatthew G. Knepley . f - The field number 186932d2bbc9SMatthew G. Knepley - update - update function 187032d2bbc9SMatthew G. Knepley 187132d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 187232d2bbc9SMatthew G. Knepley 187332d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 187432d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 187532d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187632d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 187732d2bbc9SMatthew G. Knepley 187832d2bbc9SMatthew G. Knepley + dim - the spatial dimension 187932d2bbc9SMatthew G. Knepley . Nf - the number of fields 188032d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 188132d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 188232d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 188332d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 188432d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 188532d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 188632d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 188732d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 188832d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 188932d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 189032d2bbc9SMatthew G. Knepley . t - current time 189132d2bbc9SMatthew G. Knepley . x - coordinates of the current point 189232d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 189332d2bbc9SMatthew G. Knepley 189432d2bbc9SMatthew G. Knepley Level: intermediate 189532d2bbc9SMatthew G. Knepley 189632d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 189732d2bbc9SMatthew G. Knepley @*/ 189832d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS prob, PetscInt f, 189932d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 190032d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 190132d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19023fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 190332d2bbc9SMatthew G. Knepley { 190432d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 190532d2bbc9SMatthew G. Knepley 190632d2bbc9SMatthew G. Knepley PetscFunctionBegin; 190732d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 190832d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 190932d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 191032d2bbc9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 191132d2bbc9SMatthew G. Knepley prob->update[f] = update; 191232d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 191332d2bbc9SMatthew G. Knepley } 191432d2bbc9SMatthew G. Knepley 19150c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 19160c2f2876SMatthew G. Knepley { 19170c2f2876SMatthew G. Knepley PetscFunctionBegin; 19180c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19190c2f2876SMatthew 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); 19200c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 19210c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 19220c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19230c2f2876SMatthew G. Knepley } 19240c2f2876SMatthew G. Knepley 19250c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 19260c2f2876SMatthew G. Knepley { 19270c2f2876SMatthew G. Knepley PetscErrorCode ierr; 19280c2f2876SMatthew G. Knepley 19290c2f2876SMatthew G. Knepley PetscFunctionBegin; 19300c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19310c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19320c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19330c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 19340c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19350c2f2876SMatthew G. Knepley } 19360c2f2876SMatthew G. Knepley 1937194d53e6SMatthew G. Knepley /*@C 1938194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1939194d53e6SMatthew G. Knepley 1940194d53e6SMatthew G. Knepley Not collective 1941194d53e6SMatthew G. Knepley 1942194d53e6SMatthew G. Knepley Input Parameters: 1943194d53e6SMatthew G. Knepley + prob - The PetscDS 1944194d53e6SMatthew G. Knepley - f - The test field number 1945194d53e6SMatthew G. Knepley 1946194d53e6SMatthew G. Knepley Output Parameters: 1947194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1948194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1949194d53e6SMatthew G. Knepley 1950194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1951194d53e6SMatthew G. Knepley 1952194d53e6SMatthew 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 1953194d53e6SMatthew G. Knepley 1954194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1955194d53e6SMatthew G. Knepley 195630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1957194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1958194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 195930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1960194d53e6SMatthew G. Knepley 1961194d53e6SMatthew G. Knepley + dim - the spatial dimension 1962194d53e6SMatthew G. Knepley . Nf - the number of fields 1963194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1964194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1965194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1966194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1967194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1968194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1969194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1970194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1971194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1972194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1973194d53e6SMatthew G. Knepley . t - current time 1974194d53e6SMatthew G. Knepley . x - coordinates of the current point 1975194d53e6SMatthew G. Knepley . n - unit normal at the current point 197697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 197797b6e6e8SMatthew G. Knepley . constants - constant parameters 1978194d53e6SMatthew G. Knepley - f0 - output values at the current point 1979194d53e6SMatthew G. Knepley 1980194d53e6SMatthew G. Knepley Level: intermediate 1981194d53e6SMatthew G. Knepley 1982194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1983194d53e6SMatthew G. Knepley @*/ 19842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 198530b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1986194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1987194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 198930b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1990194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1991194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 199297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 19932764a2aaSMatthew G. Knepley { 19942764a2aaSMatthew G. Knepley PetscFunctionBegin; 19952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19962764a2aaSMatthew 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); 19972764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 19982764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 19992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20002764a2aaSMatthew G. Knepley } 20012764a2aaSMatthew G. Knepley 2002194d53e6SMatthew G. Knepley /*@C 2003194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2004194d53e6SMatthew G. Knepley 2005194d53e6SMatthew G. Knepley Not collective 2006194d53e6SMatthew G. Knepley 2007194d53e6SMatthew G. Knepley Input Parameters: 2008194d53e6SMatthew G. Knepley + prob - The PetscDS 2009194d53e6SMatthew G. Knepley . f - The test field number 2010194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2011194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2012194d53e6SMatthew G. Knepley 2013194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2014194d53e6SMatthew G. Knepley 2015194d53e6SMatthew 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 2016194d53e6SMatthew G. Knepley 2017194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2018194d53e6SMatthew G. Knepley 201930b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2020194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2021194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 202230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2023194d53e6SMatthew G. Knepley 2024194d53e6SMatthew G. Knepley + dim - the spatial dimension 2025194d53e6SMatthew G. Knepley . Nf - the number of fields 2026194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2027194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2028194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2029194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2030194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2031194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2032194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2033194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2034194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2035194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2036194d53e6SMatthew G. Knepley . t - current time 2037194d53e6SMatthew G. Knepley . x - coordinates of the current point 2038194d53e6SMatthew G. Knepley . n - unit normal at the current point 203997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 204097b6e6e8SMatthew G. Knepley . constants - constant parameters 2041194d53e6SMatthew G. Knepley - f0 - output values at the current point 2042194d53e6SMatthew G. Knepley 2043194d53e6SMatthew G. Knepley Level: intermediate 2044194d53e6SMatthew G. Knepley 2045194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2046194d53e6SMatthew G. Knepley @*/ 20472764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 204830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2049194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2050194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 205197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 205230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2053194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2054194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 205597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20562764a2aaSMatthew G. Knepley { 20572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20582764a2aaSMatthew G. Knepley 20592764a2aaSMatthew G. Knepley PetscFunctionBegin; 20602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20612764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20622764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 20632764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 20642764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 20652764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20662764a2aaSMatthew G. Knepley } 20672764a2aaSMatthew G. Knepley 2068*27f02ce8SMatthew G. Knepley /*@ 2069*27f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 2070*27f02ce8SMatthew G. Knepley 2071*27f02ce8SMatthew G. Knepley Not collective 2072*27f02ce8SMatthew G. Knepley 2073*27f02ce8SMatthew G. Knepley Input Parameter: 2074*27f02ce8SMatthew G. Knepley . prob - The PetscDS 2075*27f02ce8SMatthew G. Knepley 2076*27f02ce8SMatthew G. Knepley Output Parameter: 2077*27f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 2078*27f02ce8SMatthew G. Knepley 2079*27f02ce8SMatthew G. Knepley Level: intermediate 2080*27f02ce8SMatthew G. Knepley 2081*27f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 2082*27f02ce8SMatthew G. Knepley @*/ 2083*27f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS prob, PetscBool *hasBdJac) 2084*27f02ce8SMatthew G. Knepley { 2085*27f02ce8SMatthew G. Knepley PetscInt f, g, h; 2086*27f02ce8SMatthew G. Knepley 2087*27f02ce8SMatthew G. Knepley PetscFunctionBegin; 2088*27f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2089*27f02ce8SMatthew G. Knepley *hasBdJac = PETSC_FALSE; 2090*27f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 2091*27f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 2092*27f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 2093*27f02ce8SMatthew G. Knepley if (prob->gBd[(f*prob->Nf + g)*4+h]) *hasBdJac = PETSC_TRUE; 2094*27f02ce8SMatthew G. Knepley } 2095*27f02ce8SMatthew G. Knepley } 2096*27f02ce8SMatthew G. Knepley } 2097*27f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 2098*27f02ce8SMatthew G. Knepley } 2099*27f02ce8SMatthew G. Knepley 2100194d53e6SMatthew G. Knepley /*@C 2101194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2102194d53e6SMatthew G. Knepley 2103194d53e6SMatthew G. Knepley Not collective 2104194d53e6SMatthew G. Knepley 2105194d53e6SMatthew G. Knepley Input Parameters: 2106194d53e6SMatthew G. Knepley + prob - The PetscDS 2107194d53e6SMatthew G. Knepley . f - The test field number 2108194d53e6SMatthew G. Knepley - g - The field number 2109194d53e6SMatthew G. Knepley 2110194d53e6SMatthew G. Knepley Output Parameters: 2111194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2112194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2113194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2114194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2115194d53e6SMatthew G. Knepley 2116194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2117194d53e6SMatthew G. Knepley 2118194d53e6SMatthew 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 2119194d53e6SMatthew G. Knepley 2120194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2121194d53e6SMatthew G. Knepley 212230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2123194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2124194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 212530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2126194d53e6SMatthew G. Knepley 2127194d53e6SMatthew G. Knepley + dim - the spatial dimension 2128194d53e6SMatthew G. Knepley . Nf - the number of fields 2129194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2130194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2131194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2132194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2133194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2134194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2135194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2136194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2137194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2138194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2139194d53e6SMatthew G. Knepley . t - current time 21402aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2141194d53e6SMatthew G. Knepley . x - coordinates of the current point 2142194d53e6SMatthew G. Knepley . n - normal at the current point 214397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 214497b6e6e8SMatthew G. Knepley . constants - constant parameters 2145194d53e6SMatthew G. Knepley - g0 - output values at the current point 2146194d53e6SMatthew G. Knepley 2147194d53e6SMatthew G. Knepley Level: intermediate 2148194d53e6SMatthew G. Knepley 2149194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2150194d53e6SMatthew G. Knepley @*/ 21512764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 215230b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2153194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2154194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 215597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 215630b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2157194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2158194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 215997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 216030b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2161194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2162194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 216397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 216430b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2165194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2166194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 216797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 21682764a2aaSMatthew G. Knepley { 21692764a2aaSMatthew G. Knepley PetscFunctionBegin; 21702764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21712764a2aaSMatthew 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); 21722764a2aaSMatthew 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); 21732764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 21742764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 21752764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 21762764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 21772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21782764a2aaSMatthew G. Knepley } 21792764a2aaSMatthew G. Knepley 2180194d53e6SMatthew G. Knepley /*@C 2181194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2182194d53e6SMatthew G. Knepley 2183194d53e6SMatthew G. Knepley Not collective 2184194d53e6SMatthew G. Knepley 2185194d53e6SMatthew G. Knepley Input Parameters: 2186194d53e6SMatthew G. Knepley + prob - The PetscDS 2187194d53e6SMatthew G. Knepley . f - The test field number 2188194d53e6SMatthew G. Knepley . g - The field number 2189194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2190194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2191194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2192194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2193194d53e6SMatthew G. Knepley 2194194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2195194d53e6SMatthew G. Knepley 2196194d53e6SMatthew 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 2197194d53e6SMatthew G. Knepley 2198194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2199194d53e6SMatthew G. Knepley 220030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2201194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2202194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2204194d53e6SMatthew G. Knepley 2205194d53e6SMatthew G. Knepley + dim - the spatial dimension 2206194d53e6SMatthew G. Knepley . Nf - the number of fields 2207194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2208194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2209194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2210194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2211194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2212194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2213194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2214194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2215194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2216194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2217194d53e6SMatthew G. Knepley . t - current time 22182aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2219194d53e6SMatthew G. Knepley . x - coordinates of the current point 2220194d53e6SMatthew G. Knepley . n - normal at the current point 222197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 222297b6e6e8SMatthew G. Knepley . constants - constant parameters 2223194d53e6SMatthew G. Knepley - g0 - output values at the current point 2224194d53e6SMatthew G. Knepley 2225194d53e6SMatthew G. Knepley Level: intermediate 2226194d53e6SMatthew G. Knepley 2227194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2228194d53e6SMatthew G. Knepley @*/ 22292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 223030b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2231194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2232194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 223397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 223430b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2235194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2236194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 223797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 223830b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2239194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2240194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 224230b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2243194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2244194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22462764a2aaSMatthew G. Knepley { 22472764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22482764a2aaSMatthew G. Knepley 22492764a2aaSMatthew G. Knepley PetscFunctionBegin; 22502764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22512764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 22522764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 22532764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 22542764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 22552764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 22562764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 22572764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 22582764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 22592764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 22602764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 22612764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 22622764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22632764a2aaSMatthew G. Knepley } 22642764a2aaSMatthew G. Knepley 2265*27f02ce8SMatthew G. Knepley /*@ 2266*27f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 2267*27f02ce8SMatthew G. Knepley 2268*27f02ce8SMatthew G. Knepley Not collective 2269*27f02ce8SMatthew G. Knepley 2270*27f02ce8SMatthew G. Knepley Input Parameter: 2271*27f02ce8SMatthew G. Knepley . prob - The PetscDS 2272*27f02ce8SMatthew G. Knepley 2273*27f02ce8SMatthew G. Knepley Output Parameter: 2274*27f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 2275*27f02ce8SMatthew G. Knepley 2276*27f02ce8SMatthew G. Knepley Level: intermediate 2277*27f02ce8SMatthew G. Knepley 2278*27f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 2279*27f02ce8SMatthew G. Knepley @*/ 2280*27f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS prob, PetscBool *hasBdJacPre) 2281*27f02ce8SMatthew G. Knepley { 2282*27f02ce8SMatthew G. Knepley PetscInt f, g, h; 2283*27f02ce8SMatthew G. Knepley 2284*27f02ce8SMatthew G. Knepley PetscFunctionBegin; 2285*27f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2286*27f02ce8SMatthew G. Knepley *hasBdJacPre = PETSC_FALSE; 2287*27f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 2288*27f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 2289*27f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 2290*27f02ce8SMatthew G. Knepley if (prob->gpBd[(f*prob->Nf + g)*4+h]) *hasBdJacPre = PETSC_TRUE; 2291*27f02ce8SMatthew G. Knepley } 2292*27f02ce8SMatthew G. Knepley } 2293*27f02ce8SMatthew G. Knepley } 2294*27f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 2295*27f02ce8SMatthew G. Knepley } 2296*27f02ce8SMatthew G. Knepley 2297*27f02ce8SMatthew G. Knepley /*@C 2298*27f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 2299*27f02ce8SMatthew G. Knepley 2300*27f02ce8SMatthew G. Knepley Not collective 2301*27f02ce8SMatthew G. Knepley 2302*27f02ce8SMatthew G. Knepley Input Parameters: 2303*27f02ce8SMatthew G. Knepley + prob - The PetscDS 2304*27f02ce8SMatthew G. Knepley . f - The test field number 2305*27f02ce8SMatthew G. Knepley - g - The field number 2306*27f02ce8SMatthew G. Knepley 2307*27f02ce8SMatthew G. Knepley Output Parameters: 2308*27f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 2309*27f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2310*27f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2311*27f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2312*27f02ce8SMatthew G. Knepley 2313*27f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2314*27f02ce8SMatthew G. Knepley 2315*27f02ce8SMatthew 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 2316*27f02ce8SMatthew G. Knepley 2317*27f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2318*27f02ce8SMatthew G. Knepley 2319*27f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2320*27f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2321*27f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2322*27f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 2323*27f02ce8SMatthew G. Knepley 2324*27f02ce8SMatthew G. Knepley + dim - the spatial dimension 2325*27f02ce8SMatthew G. Knepley . Nf - the number of fields 2326*27f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 2327*27f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2328*27f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2329*27f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 2330*27f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2331*27f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2332*27f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2333*27f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2334*27f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2335*27f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2336*27f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2337*27f02ce8SMatthew G. Knepley . t - current time 2338*27f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2339*27f02ce8SMatthew G. Knepley . x - coordinates of the current point 2340*27f02ce8SMatthew G. Knepley . n - normal at the current point 2341*27f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 2342*27f02ce8SMatthew G. Knepley . constants - constant parameters 2343*27f02ce8SMatthew G. Knepley - g0 - output values at the current point 2344*27f02ce8SMatthew G. Knepley 2345*27f02ce8SMatthew G. Knepley This is not yet available in Fortran. 2346*27f02ce8SMatthew G. Knepley 2347*27f02ce8SMatthew G. Knepley Level: intermediate 2348*27f02ce8SMatthew G. Knepley 2349*27f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 2350*27f02ce8SMatthew G. Knepley @*/ 2351*27f02ce8SMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 2352*27f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2353*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2354*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2355*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 2356*27f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2357*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2358*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2359*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 2360*27f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2361*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2362*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2363*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 2364*27f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2365*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2366*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2367*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 2368*27f02ce8SMatthew G. Knepley { 2369*27f02ce8SMatthew G. Knepley PetscFunctionBegin; 2370*27f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2371*27f02ce8SMatthew 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); 2372*27f02ce8SMatthew 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); 2373*27f02ce8SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gpBd[(f*prob->Nf + g)*4+0];} 2374*27f02ce8SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gpBd[(f*prob->Nf + g)*4+1];} 2375*27f02ce8SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gpBd[(f*prob->Nf + g)*4+2];} 2376*27f02ce8SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gpBd[(f*prob->Nf + g)*4+3];} 2377*27f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 2378*27f02ce8SMatthew G. Knepley } 2379*27f02ce8SMatthew G. Knepley 2380*27f02ce8SMatthew G. Knepley /*@C 2381*27f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 2382*27f02ce8SMatthew G. Knepley 2383*27f02ce8SMatthew G. Knepley Not collective 2384*27f02ce8SMatthew G. Knepley 2385*27f02ce8SMatthew G. Knepley Input Parameters: 2386*27f02ce8SMatthew G. Knepley + prob - The PetscDS 2387*27f02ce8SMatthew G. Knepley . f - The test field number 2388*27f02ce8SMatthew G. Knepley . g - The field number 2389*27f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 2390*27f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2391*27f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2392*27f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2393*27f02ce8SMatthew G. Knepley 2394*27f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2395*27f02ce8SMatthew G. Knepley 2396*27f02ce8SMatthew 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 2397*27f02ce8SMatthew G. Knepley 2398*27f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2399*27f02ce8SMatthew G. Knepley 2400*27f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2401*27f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2402*27f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2403*27f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 2404*27f02ce8SMatthew G. Knepley 2405*27f02ce8SMatthew G. Knepley + dim - the spatial dimension 2406*27f02ce8SMatthew G. Knepley . Nf - the number of fields 2407*27f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 2408*27f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2409*27f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2410*27f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 2411*27f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2412*27f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2413*27f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2414*27f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2415*27f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2416*27f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2417*27f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2418*27f02ce8SMatthew G. Knepley . t - current time 2419*27f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2420*27f02ce8SMatthew G. Knepley . x - coordinates of the current point 2421*27f02ce8SMatthew G. Knepley . n - normal at the current point 2422*27f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 2423*27f02ce8SMatthew G. Knepley . constants - constant parameters 2424*27f02ce8SMatthew G. Knepley - g0 - output values at the current point 2425*27f02ce8SMatthew G. Knepley 2426*27f02ce8SMatthew G. Knepley This is not yet available in Fortran. 2427*27f02ce8SMatthew G. Knepley 2428*27f02ce8SMatthew G. Knepley Level: intermediate 2429*27f02ce8SMatthew G. Knepley 2430*27f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 2431*27f02ce8SMatthew G. Knepley @*/ 2432*27f02ce8SMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 2433*27f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2434*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2435*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2436*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 2437*27f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2438*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2439*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2440*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 2441*27f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2442*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2443*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2444*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 2445*27f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2446*27f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2447*27f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 2448*27f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 2449*27f02ce8SMatthew G. Knepley { 2450*27f02ce8SMatthew G. Knepley PetscErrorCode ierr; 2451*27f02ce8SMatthew G. Knepley 2452*27f02ce8SMatthew G. Knepley PetscFunctionBegin; 2453*27f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2454*27f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 2455*27f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 2456*27f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 2457*27f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 2458*27f02ce8SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2459*27f02ce8SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 2460*27f02ce8SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 2461*27f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+0] = g0; 2462*27f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+1] = g1; 2463*27f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+2] = g2; 2464*27f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+3] = g3; 2465*27f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 2466*27f02ce8SMatthew G. Knepley } 2467*27f02ce8SMatthew G. Knepley 24680d3e9b51SMatthew G. Knepley /*@C 2469c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2470c371a6d1SMatthew G. Knepley 2471c371a6d1SMatthew G. Knepley Not collective 2472c371a6d1SMatthew G. Knepley 2473c371a6d1SMatthew G. Knepley Input Parameters: 2474c371a6d1SMatthew G. Knepley + prob - The PetscDS 2475c371a6d1SMatthew G. Knepley - f - The test field number 2476c371a6d1SMatthew G. Knepley 2477c371a6d1SMatthew G. Knepley Output Parameter: 247895cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 247995cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2480c371a6d1SMatthew G. Knepley 2481c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2482c371a6d1SMatthew G. Knepley 2483c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2484c371a6d1SMatthew G. Knepley 2485c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2486c371a6d1SMatthew G. Knepley . t - current time 2487c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2488c371a6d1SMatthew G. Knepley . Nc - the number of field components 2489c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2490c371a6d1SMatthew G. Knepley - ctx - a user context 2491c371a6d1SMatthew G. Knepley 2492c371a6d1SMatthew G. Knepley Level: intermediate 2493c371a6d1SMatthew G. Knepley 2494c371a6d1SMatthew G. Knepley .seealso: PetscDSSetExactSolution() 2495c371a6d1SMatthew G. Knepley @*/ 249695cbbfd3SMatthew 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) 2497c371a6d1SMatthew G. Knepley { 2498c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2499c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2500c371a6d1SMatthew 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); 2501c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 250295cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2503c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2504c371a6d1SMatthew G. Knepley } 2505c371a6d1SMatthew G. Knepley 2506c371a6d1SMatthew G. Knepley /*@C 2507578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2508c371a6d1SMatthew G. Knepley 2509c371a6d1SMatthew G. Knepley Not collective 2510c371a6d1SMatthew G. Knepley 2511c371a6d1SMatthew G. Knepley Input Parameters: 2512c371a6d1SMatthew G. Knepley + prob - The PetscDS 2513c371a6d1SMatthew G. Knepley . f - The test field number 251495cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 251595cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2516c371a6d1SMatthew G. Knepley 2517c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2518c371a6d1SMatthew G. Knepley 2519c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2520c371a6d1SMatthew G. Knepley 2521c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2522c371a6d1SMatthew G. Knepley . t - current time 2523c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2524c371a6d1SMatthew G. Knepley . Nc - the number of field components 2525c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2526c371a6d1SMatthew G. Knepley - ctx - a user context 2527c371a6d1SMatthew G. Knepley 2528c371a6d1SMatthew G. Knepley Level: intermediate 2529c371a6d1SMatthew G. Knepley 2530c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2531c371a6d1SMatthew G. Knepley @*/ 253295cbbfd3SMatthew 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) 2533c371a6d1SMatthew G. Knepley { 2534c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2535c371a6d1SMatthew G. Knepley 2536c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2537c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2538c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2539c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2540c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 254195cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2542c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2543c371a6d1SMatthew G. Knepley } 2544c371a6d1SMatthew G. Knepley 25455638fd0eSMatthew G. Knepley /*@C 254697b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 254797b6e6e8SMatthew G. Knepley 254897b6e6e8SMatthew G. Knepley Not collective 254997b6e6e8SMatthew G. Knepley 255097b6e6e8SMatthew G. Knepley Input Parameter: 255197b6e6e8SMatthew G. Knepley . prob - The PetscDS object 255297b6e6e8SMatthew G. Knepley 255397b6e6e8SMatthew G. Knepley Output Parameters: 255497b6e6e8SMatthew G. Knepley + numConstants - The number of constants 255597b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 255697b6e6e8SMatthew G. Knepley 255797b6e6e8SMatthew G. Knepley Level: intermediate 255897b6e6e8SMatthew G. Knepley 255997b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 256097b6e6e8SMatthew G. Knepley @*/ 256197b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 256297b6e6e8SMatthew G. Knepley { 256397b6e6e8SMatthew G. Knepley PetscFunctionBegin; 256497b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 256597b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 256697b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 256797b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 256897b6e6e8SMatthew G. Knepley } 256997b6e6e8SMatthew G. Knepley 25700d3e9b51SMatthew G. Knepley /*@C 257197b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 257297b6e6e8SMatthew G. Knepley 257397b6e6e8SMatthew G. Knepley Not collective 257497b6e6e8SMatthew G. Knepley 257597b6e6e8SMatthew G. Knepley Input Parameters: 257697b6e6e8SMatthew G. Knepley + prob - The PetscDS object 257797b6e6e8SMatthew G. Knepley . numConstants - The number of constants 257897b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 257997b6e6e8SMatthew G. Knepley 258097b6e6e8SMatthew G. Knepley Level: intermediate 258197b6e6e8SMatthew G. Knepley 258297b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 258397b6e6e8SMatthew G. Knepley @*/ 258497b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 258597b6e6e8SMatthew G. Knepley { 258697b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 258797b6e6e8SMatthew G. Knepley 258897b6e6e8SMatthew G. Knepley PetscFunctionBegin; 258997b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 259097b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 259197b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 259297b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 259397b6e6e8SMatthew G. Knepley if (prob->numConstants) { 259497b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 259520be0f5bSMatthew G. Knepley } else { 259620be0f5bSMatthew G. Knepley prob->constants = NULL; 259720be0f5bSMatthew G. Knepley } 259820be0f5bSMatthew G. Knepley } 259920be0f5bSMatthew G. Knepley if (prob->numConstants) { 260020be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 2601580bdb30SBarry Smith ierr = PetscArraycpy(prob->constants, constants, prob->numConstants);CHKERRQ(ierr); 260297b6e6e8SMatthew G. Knepley } 260397b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 260497b6e6e8SMatthew G. Knepley } 260597b6e6e8SMatthew G. Knepley 26064cd1e086SMatthew G. Knepley /*@ 26074cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 26084cd1e086SMatthew G. Knepley 26094cd1e086SMatthew G. Knepley Not collective 26104cd1e086SMatthew G. Knepley 26114cd1e086SMatthew G. Knepley Input Parameters: 26124cd1e086SMatthew G. Knepley + prob - The PetscDS object 26134cd1e086SMatthew G. Knepley - disc - The discretization object 26144cd1e086SMatthew G. Knepley 26154cd1e086SMatthew G. Knepley Output Parameter: 26164cd1e086SMatthew G. Knepley . f - The field number 26174cd1e086SMatthew G. Knepley 26184cd1e086SMatthew G. Knepley Level: beginner 26194cd1e086SMatthew G. Knepley 2620f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 26214cd1e086SMatthew G. Knepley @*/ 26224cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 26234cd1e086SMatthew G. Knepley { 26244cd1e086SMatthew G. Knepley PetscInt g; 26254cd1e086SMatthew G. Knepley 26264cd1e086SMatthew G. Knepley PetscFunctionBegin; 26274cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26284cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 26294cd1e086SMatthew G. Knepley *f = -1; 26304cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 26314cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 26324cd1e086SMatthew G. Knepley *f = g; 26334cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 26344cd1e086SMatthew G. Knepley } 26354cd1e086SMatthew G. Knepley 26364cd1e086SMatthew G. Knepley /*@ 26374cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 26384cd1e086SMatthew G. Knepley 26394cd1e086SMatthew G. Knepley Not collective 26404cd1e086SMatthew G. Knepley 26414cd1e086SMatthew G. Knepley Input Parameters: 26424cd1e086SMatthew G. Knepley + prob - The PetscDS object 26434cd1e086SMatthew G. Knepley - f - The field number 26444cd1e086SMatthew G. Knepley 26454cd1e086SMatthew G. Knepley Output Parameter: 26464cd1e086SMatthew G. Knepley . size - The size 26474cd1e086SMatthew G. Knepley 26484cd1e086SMatthew G. Knepley Level: beginner 26494cd1e086SMatthew G. Knepley 2650f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 26514cd1e086SMatthew G. Knepley @*/ 26524cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 26534cd1e086SMatthew G. Knepley { 26542166fd64SMatthew G. Knepley PetscErrorCode ierr; 26552166fd64SMatthew G. Knepley 26564cd1e086SMatthew G. Knepley PetscFunctionBegin; 26574cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26584cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 26594cd1e086SMatthew 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); 26602166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2661d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 26624cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 26634cd1e086SMatthew G. Knepley } 26644cd1e086SMatthew G. Knepley 2665bc4ae4beSMatthew G. Knepley /*@ 2666bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2667bc4ae4beSMatthew G. Knepley 2668bc4ae4beSMatthew G. Knepley Not collective 2669bc4ae4beSMatthew G. Knepley 2670bc4ae4beSMatthew G. Knepley Input Parameters: 2671bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2672bc4ae4beSMatthew G. Knepley - f - The field number 2673bc4ae4beSMatthew G. Knepley 2674bc4ae4beSMatthew G. Knepley Output Parameter: 2675bc4ae4beSMatthew G. Knepley . off - The offset 2676bc4ae4beSMatthew G. Knepley 2677bc4ae4beSMatthew G. Knepley Level: beginner 2678bc4ae4beSMatthew G. Knepley 2679f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2680bc4ae4beSMatthew G. Knepley @*/ 26812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 26822764a2aaSMatthew G. Knepley { 26834cd1e086SMatthew G. Knepley PetscInt size, g; 26842764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26852764a2aaSMatthew G. Knepley 26862764a2aaSMatthew G. Knepley PetscFunctionBegin; 26872764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26882764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 26892764a2aaSMatthew 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); 26902764a2aaSMatthew G. Knepley *off = 0; 26912764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 26924cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 26934cd1e086SMatthew G. Knepley *off += size; 26942764a2aaSMatthew G. Knepley } 26952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26962764a2aaSMatthew G. Knepley } 26972764a2aaSMatthew G. Knepley 2698bc4ae4beSMatthew G. Knepley /*@ 269947e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2700bc4ae4beSMatthew G. Knepley 2701bc4ae4beSMatthew G. Knepley Not collective 2702bc4ae4beSMatthew G. Knepley 270347e57110SSander Arens Input Parameter: 270447e57110SSander Arens . prob - The PetscDS object 2705bc4ae4beSMatthew G. Knepley 2706bc4ae4beSMatthew G. Knepley Output Parameter: 270747e57110SSander Arens . dimensions - The number of dimensions 2708bc4ae4beSMatthew G. Knepley 2709bc4ae4beSMatthew G. Knepley Level: beginner 2710bc4ae4beSMatthew G. Knepley 271147e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2712bc4ae4beSMatthew G. Knepley @*/ 271347e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 27142764a2aaSMatthew G. Knepley { 27152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 27162764a2aaSMatthew G. Knepley 27172764a2aaSMatthew G. Knepley PetscFunctionBegin; 27182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 271947e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 272047e57110SSander Arens PetscValidPointer(dimensions, 2); 272147e57110SSander Arens *dimensions = prob->Nb; 272247e57110SSander Arens PetscFunctionReturn(0); 27236ce16762SMatthew G. Knepley } 272447e57110SSander Arens 272547e57110SSander Arens /*@ 272647e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 272747e57110SSander Arens 272847e57110SSander Arens Not collective 272947e57110SSander Arens 273047e57110SSander Arens Input Parameter: 273147e57110SSander Arens . prob - The PetscDS object 273247e57110SSander Arens 273347e57110SSander Arens Output Parameter: 273447e57110SSander Arens . components - The number of components 273547e57110SSander Arens 273647e57110SSander Arens Level: beginner 273747e57110SSander Arens 273847e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 273947e57110SSander Arens @*/ 274047e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 274147e57110SSander Arens { 274247e57110SSander Arens PetscErrorCode ierr; 274347e57110SSander Arens 274447e57110SSander Arens PetscFunctionBegin; 274547e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 274647e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 274747e57110SSander Arens PetscValidPointer(components, 2); 274847e57110SSander Arens *components = prob->Nc; 27496ce16762SMatthew G. Knepley PetscFunctionReturn(0); 27506ce16762SMatthew G. Knepley } 27516ce16762SMatthew G. Knepley 27526ce16762SMatthew G. Knepley /*@ 27536ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 27546ce16762SMatthew G. Knepley 27556ce16762SMatthew G. Knepley Not collective 27566ce16762SMatthew G. Knepley 27576ce16762SMatthew G. Knepley Input Parameters: 27586ce16762SMatthew G. Knepley + prob - The PetscDS object 27596ce16762SMatthew G. Knepley - f - The field number 27606ce16762SMatthew G. Knepley 27616ce16762SMatthew G. Knepley Output Parameter: 27626ce16762SMatthew G. Knepley . off - The offset 27636ce16762SMatthew G. Knepley 27646ce16762SMatthew G. Knepley Level: beginner 27656ce16762SMatthew G. Knepley 2766f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 27676ce16762SMatthew G. Knepley @*/ 27686ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 27696ce16762SMatthew G. Knepley { 27706ce16762SMatthew G. Knepley PetscFunctionBegin; 27716ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27726ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 27736ce16762SMatthew 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); 277447e57110SSander Arens *off = prob->off[f]; 27752764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27762764a2aaSMatthew G. Knepley } 27772764a2aaSMatthew G. Knepley 2778194d53e6SMatthew G. Knepley /*@ 2779194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2780194d53e6SMatthew G. Knepley 2781194d53e6SMatthew G. Knepley Not collective 2782194d53e6SMatthew G. Knepley 2783194d53e6SMatthew G. Knepley Input Parameter: 2784194d53e6SMatthew G. Knepley . prob - The PetscDS object 2785194d53e6SMatthew G. Knepley 2786194d53e6SMatthew G. Knepley Output Parameter: 2787194d53e6SMatthew G. Knepley . offsets - The offsets 2788194d53e6SMatthew G. Knepley 2789194d53e6SMatthew G. Knepley Level: beginner 2790194d53e6SMatthew G. Knepley 2791f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2792194d53e6SMatthew G. Knepley @*/ 2793194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2794194d53e6SMatthew G. Knepley { 2795194d53e6SMatthew G. Knepley PetscFunctionBegin; 2796194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2797194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2798194d53e6SMatthew G. Knepley *offsets = prob->off; 2799194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2800194d53e6SMatthew G. Knepley } 2801194d53e6SMatthew G. Knepley 2802194d53e6SMatthew G. Knepley /*@ 2803194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2804194d53e6SMatthew G. Knepley 2805194d53e6SMatthew G. Knepley Not collective 2806194d53e6SMatthew G. Knepley 2807194d53e6SMatthew G. Knepley Input Parameter: 2808194d53e6SMatthew G. Knepley . prob - The PetscDS object 2809194d53e6SMatthew G. Knepley 2810194d53e6SMatthew G. Knepley Output Parameter: 2811194d53e6SMatthew G. Knepley . offsets - The offsets 2812194d53e6SMatthew G. Knepley 2813194d53e6SMatthew G. Knepley Level: beginner 2814194d53e6SMatthew G. Knepley 2815f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2816194d53e6SMatthew G. Knepley @*/ 2817194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2818194d53e6SMatthew G. Knepley { 2819194d53e6SMatthew G. Knepley PetscFunctionBegin; 2820194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2821194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2822194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2823194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2824194d53e6SMatthew G. Knepley } 2825194d53e6SMatthew G. Knepley 282668c9edb9SMatthew G. Knepley /*@C 282768c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 282868c9edb9SMatthew G. Knepley 282968c9edb9SMatthew G. Knepley Not collective 283068c9edb9SMatthew G. Knepley 283168c9edb9SMatthew G. Knepley Input Parameter: 283268c9edb9SMatthew G. Knepley . prob - The PetscDS object 283368c9edb9SMatthew G. Knepley 2834ef0bb6c7SMatthew G. Knepley Output Parameter: 2835ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 283668c9edb9SMatthew G. Knepley 283768c9edb9SMatthew G. Knepley Level: intermediate 283868c9edb9SMatthew G. Knepley 2839f744cafaSSander Arens .seealso: PetscDSCreate() 284068c9edb9SMatthew G. Knepley @*/ 2841ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 28422764a2aaSMatthew G. Knepley { 28432764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28442764a2aaSMatthew G. Knepley 28452764a2aaSMatthew G. Knepley PetscFunctionBegin; 28462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2847ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 28482764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2849ef0bb6c7SMatthew G. Knepley *T = prob->T; 28502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28512764a2aaSMatthew G. Knepley } 28522764a2aaSMatthew G. Knepley 285368c9edb9SMatthew G. Knepley /*@C 28544d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 285568c9edb9SMatthew G. Knepley 285668c9edb9SMatthew G. Knepley Not collective 285768c9edb9SMatthew G. Knepley 285868c9edb9SMatthew G. Knepley Input Parameter: 285968c9edb9SMatthew G. Knepley . prob - The PetscDS object 286068c9edb9SMatthew G. Knepley 2861ef0bb6c7SMatthew G. Knepley Output Parameter: 2862ef0bb6c7SMatthew G. Knepley . Tf - The basis function and derviative tabulation on each lcoal face at quadrature points for each and field 286368c9edb9SMatthew G. Knepley 286468c9edb9SMatthew G. Knepley Level: intermediate 286568c9edb9SMatthew G. Knepley 286668c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 286768c9edb9SMatthew G. Knepley @*/ 2868ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 28692764a2aaSMatthew G. Knepley { 28702764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28712764a2aaSMatthew G. Knepley 28722764a2aaSMatthew G. Knepley PetscFunctionBegin; 28732764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2874ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 28752764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2876ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 28772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28782764a2aaSMatthew G. Knepley } 28792764a2aaSMatthew G. Knepley 28802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 28812764a2aaSMatthew G. Knepley { 28822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28832764a2aaSMatthew G. Knepley 28842764a2aaSMatthew G. Knepley PetscFunctionBegin; 28852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28862764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 28872764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 28882764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 28892764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 28902764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28912764a2aaSMatthew G. Knepley } 28922764a2aaSMatthew G. Knepley 28932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 28942764a2aaSMatthew G. Knepley { 28952764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28962764a2aaSMatthew G. Knepley 28972764a2aaSMatthew G. Knepley PetscFunctionBegin; 28982764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28992764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 29002764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 29012764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 29022764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 29032764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 29042764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 29052764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 29062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29072764a2aaSMatthew G. Knepley } 29082764a2aaSMatthew G. Knepley 29094bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 29102764a2aaSMatthew G. Knepley { 29112764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29122764a2aaSMatthew G. Knepley 29132764a2aaSMatthew G. Knepley PetscFunctionBegin; 29142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29152764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 29162764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 29174bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 29187506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 29197506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 29207506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 29212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29222764a2aaSMatthew G. Knepley } 29232764a2aaSMatthew G. Knepley 292458ebd649SToby Isaac /*@C 292558ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 292658ebd649SToby Isaac 2927783e2ec8SMatthew G. Knepley Collective on ds 2928783e2ec8SMatthew G. Knepley 292958ebd649SToby Isaac Input Parameters: 293058ebd649SToby Isaac + ds - The PetscDS object 29312d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 293258ebd649SToby Isaac . name - The BC name 293358ebd649SToby Isaac . labelname - The label defining constrained points 293458ebd649SToby Isaac . field - The field to constrain 2935e8ecbf3fSStefano Zampini . numcomps - The number of constrained field components (0 will constrain all fields) 293658ebd649SToby Isaac . comps - An array of constrained component numbers 293758ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 293858ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 293958ebd649SToby Isaac . ids - An array of ids for constrained points 294058ebd649SToby Isaac - ctx - An optional user context for bcFunc 294158ebd649SToby Isaac 294258ebd649SToby Isaac Options Database Keys: 294358ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 294458ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 294558ebd649SToby Isaac 294658ebd649SToby Isaac Level: developer 294758ebd649SToby Isaac 294858ebd649SToby Isaac .seealso: PetscDSGetBoundary() 294958ebd649SToby Isaac @*/ 2950a30ec4eaSSatish 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) 295158ebd649SToby Isaac { 295258ebd649SToby Isaac DSBoundary b; 295358ebd649SToby Isaac PetscErrorCode ierr; 295458ebd649SToby Isaac 295558ebd649SToby Isaac PetscFunctionBegin; 295658ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2957783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 2958783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 5); 2959783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numcomps, 6); 2960783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numids, 9); 296158ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 296258ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 296358ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 296458ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 2965580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 296658ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 2967580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 2968f971fd6bSMatthew G. Knepley b->type = type; 296958ebd649SToby Isaac b->field = field; 297058ebd649SToby Isaac b->numcomps = numcomps; 297158ebd649SToby Isaac b->func = bcFunc; 297258ebd649SToby Isaac b->numids = numids; 297358ebd649SToby Isaac b->ctx = ctx; 297458ebd649SToby Isaac b->next = ds->boundary; 297558ebd649SToby Isaac ds->boundary = b; 297658ebd649SToby Isaac PetscFunctionReturn(0); 297758ebd649SToby Isaac } 297858ebd649SToby Isaac 2979b67eacb3SMatthew G. Knepley /*@C 2980b67eacb3SMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model 2981b67eacb3SMatthew G. Knepley 2982b67eacb3SMatthew G. Knepley Input Parameters: 2983b67eacb3SMatthew G. Knepley + ds - The PetscDS object 2984b67eacb3SMatthew G. Knepley . bd - The boundary condition number 2985b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 2986b67eacb3SMatthew G. Knepley . name - The BC name 2987b67eacb3SMatthew G. Knepley . labelname - The label defining constrained points 2988b67eacb3SMatthew G. Knepley . field - The field to constrain 2989b67eacb3SMatthew G. Knepley . numcomps - The number of constrained field components 2990b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 2991b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 2992b67eacb3SMatthew G. Knepley . numids - The number of DMLabel ids for constrained points 2993b67eacb3SMatthew G. Knepley . ids - An array of ids for constrained points 2994b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 2995b67eacb3SMatthew G. Knepley 29969a6efb6aSMatthew 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(). 29979a6efb6aSMatthew G. Knepley 2998b67eacb3SMatthew G. Knepley Level: developer 2999b67eacb3SMatthew G. Knepley 30009a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3001b67eacb3SMatthew G. Knepley @*/ 3002b67eacb3SMatthew 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) 3003b67eacb3SMatthew G. Knepley { 3004b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3005b67eacb3SMatthew G. Knepley PetscInt n = 0; 3006b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 3007b67eacb3SMatthew G. Knepley 3008b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3009b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3010b67eacb3SMatthew G. Knepley while (b) { 3011b67eacb3SMatthew G. Knepley if (n == bd) break; 3012b67eacb3SMatthew G. Knepley b = b->next; 3013b67eacb3SMatthew G. Knepley ++n; 3014b67eacb3SMatthew G. Knepley } 3015b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3016b67eacb3SMatthew G. Knepley if (name) { 3017b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 3018b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 3019b67eacb3SMatthew G. Knepley } 3020b67eacb3SMatthew G. Knepley if (labelname) { 3021b67eacb3SMatthew G. Knepley ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3022b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 3023b67eacb3SMatthew G. Knepley } 3024b67eacb3SMatthew G. Knepley if (numcomps >= 0 && numcomps != b->numcomps) { 3025b67eacb3SMatthew G. Knepley b->numcomps = numcomps; 3026b67eacb3SMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 3027b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 3028580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 3029b67eacb3SMatthew G. Knepley } 3030b67eacb3SMatthew G. Knepley if (numids >= 0 && numids != b->numids) { 3031b67eacb3SMatthew G. Knepley b->numids = numids; 3032b67eacb3SMatthew G. Knepley ierr = PetscFree(b->ids);CHKERRQ(ierr); 3033b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 3034580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 3035b67eacb3SMatthew G. Knepley } 3036b67eacb3SMatthew G. Knepley b->type = type; 3037b67eacb3SMatthew G. Knepley if (field >= 0) {b->field = field;} 3038b67eacb3SMatthew G. Knepley if (bcFunc) {b->func = bcFunc;} 3039b67eacb3SMatthew G. Knepley if (ctx) {b->ctx = ctx;} 3040b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3041b67eacb3SMatthew G. Knepley } 3042b67eacb3SMatthew G. Knepley 304358ebd649SToby Isaac /*@ 304458ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 304558ebd649SToby Isaac 304658ebd649SToby Isaac Input Parameters: 304758ebd649SToby Isaac . ds - The PetscDS object 304858ebd649SToby Isaac 304958ebd649SToby Isaac Output Parameters: 305058ebd649SToby Isaac . numBd - The number of BC 305158ebd649SToby Isaac 305258ebd649SToby Isaac Level: intermediate 305358ebd649SToby Isaac 305458ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 305558ebd649SToby Isaac @*/ 305658ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 305758ebd649SToby Isaac { 305858ebd649SToby Isaac DSBoundary b = ds->boundary; 305958ebd649SToby Isaac 306058ebd649SToby Isaac PetscFunctionBegin; 306158ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 306258ebd649SToby Isaac PetscValidPointer(numBd, 2); 306358ebd649SToby Isaac *numBd = 0; 306458ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 306558ebd649SToby Isaac PetscFunctionReturn(0); 306658ebd649SToby Isaac } 306758ebd649SToby Isaac 306858ebd649SToby Isaac /*@C 30699a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 307058ebd649SToby Isaac 307158ebd649SToby Isaac Input Parameters: 307258ebd649SToby Isaac + ds - The PetscDS object 307358ebd649SToby Isaac - bd - The BC number 307458ebd649SToby Isaac 307558ebd649SToby Isaac Output Parameters: 30762d47a189SJulian Andrej + type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 307758ebd649SToby Isaac . name - The BC name 307858ebd649SToby Isaac . labelname - The label defining constrained points 307958ebd649SToby Isaac . field - The field to constrain 308058ebd649SToby Isaac . numcomps - The number of constrained field components 308158ebd649SToby Isaac . comps - An array of constrained component numbers 308258ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 308358ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 308458ebd649SToby Isaac . ids - An array of ids for constrained points 308558ebd649SToby Isaac - ctx - An optional user context for bcFunc 308658ebd649SToby Isaac 308758ebd649SToby Isaac Options Database Keys: 308858ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 308958ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 309058ebd649SToby Isaac 309158ebd649SToby Isaac Level: developer 309258ebd649SToby Isaac 309358ebd649SToby Isaac .seealso: PetscDSAddBoundary() 309458ebd649SToby Isaac @*/ 3095a30ec4eaSSatish 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) 309658ebd649SToby Isaac { 309758ebd649SToby Isaac DSBoundary b = ds->boundary; 309858ebd649SToby Isaac PetscInt n = 0; 309958ebd649SToby Isaac 310058ebd649SToby Isaac PetscFunctionBegin; 310158ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 310258ebd649SToby Isaac while (b) { 310358ebd649SToby Isaac if (n == bd) break; 310458ebd649SToby Isaac b = b->next; 310558ebd649SToby Isaac ++n; 310658ebd649SToby Isaac } 310758ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3108f971fd6bSMatthew G. Knepley if (type) { 3109f971fd6bSMatthew G. Knepley PetscValidPointer(type, 3); 3110f971fd6bSMatthew G. Knepley *type = b->type; 311158ebd649SToby Isaac } 311258ebd649SToby Isaac if (name) { 311358ebd649SToby Isaac PetscValidPointer(name, 4); 311458ebd649SToby Isaac *name = b->name; 311558ebd649SToby Isaac } 311658ebd649SToby Isaac if (labelname) { 311758ebd649SToby Isaac PetscValidPointer(labelname, 5); 311858ebd649SToby Isaac *labelname = b->labelname; 311958ebd649SToby Isaac } 312058ebd649SToby Isaac if (field) { 312158ebd649SToby Isaac PetscValidPointer(field, 6); 312258ebd649SToby Isaac *field = b->field; 312358ebd649SToby Isaac } 312458ebd649SToby Isaac if (numcomps) { 312558ebd649SToby Isaac PetscValidPointer(numcomps, 7); 312658ebd649SToby Isaac *numcomps = b->numcomps; 312758ebd649SToby Isaac } 312858ebd649SToby Isaac if (comps) { 312958ebd649SToby Isaac PetscValidPointer(comps, 8); 313058ebd649SToby Isaac *comps = b->comps; 313158ebd649SToby Isaac } 313258ebd649SToby Isaac if (func) { 313358ebd649SToby Isaac PetscValidPointer(func, 9); 313458ebd649SToby Isaac *func = b->func; 313558ebd649SToby Isaac } 313658ebd649SToby Isaac if (numids) { 313758ebd649SToby Isaac PetscValidPointer(numids, 10); 313858ebd649SToby Isaac *numids = b->numids; 313958ebd649SToby Isaac } 314058ebd649SToby Isaac if (ids) { 314158ebd649SToby Isaac PetscValidPointer(ids, 11); 314258ebd649SToby Isaac *ids = b->ids; 314358ebd649SToby Isaac } 314458ebd649SToby Isaac if (ctx) { 314558ebd649SToby Isaac PetscValidPointer(ctx, 12); 314658ebd649SToby Isaac *ctx = b->ctx; 314758ebd649SToby Isaac } 314858ebd649SToby Isaac PetscFunctionReturn(0); 314958ebd649SToby Isaac } 315058ebd649SToby Isaac 31519252d075SMatthew G. Knepley /*@ 31529252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 31539252d075SMatthew G. Knepley 31549252d075SMatthew G. Knepley Not collective 31559252d075SMatthew G. Knepley 31569252d075SMatthew G. Knepley Input Parameter: 31579252d075SMatthew G. Knepley . prob - The PetscDS object 31589252d075SMatthew G. Knepley 31599252d075SMatthew G. Knepley Output Parameter: 31609252d075SMatthew G. Knepley . newprob - The PetscDS copy 31619252d075SMatthew G. Knepley 31629252d075SMatthew G. Knepley Level: intermediate 31639252d075SMatthew G. Knepley 31649252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 31659252d075SMatthew G. Knepley @*/ 3166dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 3167dff059c6SToby Isaac { 3168dff059c6SToby Isaac DSBoundary b, next, *lastnext; 3169dff059c6SToby Isaac PetscErrorCode ierr; 3170dff059c6SToby Isaac 3171dff059c6SToby Isaac PetscFunctionBegin; 3172dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 3173dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 3174dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 3175dff059c6SToby Isaac next = probB->boundary; 3176dff059c6SToby Isaac while (next) { 3177dff059c6SToby Isaac DSBoundary b = next; 3178dff059c6SToby Isaac 3179dff059c6SToby Isaac next = b->next; 3180dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 3181dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 3182dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 3183dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3184dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 3185dff059c6SToby Isaac } 3186dff059c6SToby Isaac lastnext = &(probB->boundary); 3187dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 3188dff059c6SToby Isaac DSBoundary bNew; 3189dff059c6SToby Isaac 3190459726d8SSatish Balay ierr = PetscNew(&bNew);CHKERRQ(ierr); 3191dff059c6SToby Isaac bNew->numcomps = b->numcomps; 3192dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 3193580bdb30SBarry Smith ierr = PetscArraycpy(bNew->comps, b->comps, bNew->numcomps);CHKERRQ(ierr); 3194dff059c6SToby Isaac bNew->numids = b->numids; 3195dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 3196580bdb30SBarry Smith ierr = PetscArraycpy(bNew->ids, b->ids, bNew->numids);CHKERRQ(ierr); 3197dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 3198dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 3199dff059c6SToby Isaac bNew->ctx = b->ctx; 3200f971fd6bSMatthew G. Knepley bNew->type = b->type; 3201dff059c6SToby Isaac bNew->field = b->field; 3202dff059c6SToby Isaac bNew->func = b->func; 3203dff059c6SToby Isaac 3204dff059c6SToby Isaac *lastnext = bNew; 3205dff059c6SToby Isaac lastnext = &(bNew->next); 3206dff059c6SToby Isaac } 3207dff059c6SToby Isaac PetscFunctionReturn(0); 3208dff059c6SToby Isaac } 3209dff059c6SToby Isaac 32109252d075SMatthew G. Knepley /*@C 32119252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 32129252d075SMatthew G. Knepley 32139252d075SMatthew G. Knepley Not collective 32149252d075SMatthew G. Knepley 32159252d075SMatthew G. Knepley Input Parameter: 32169252d075SMatthew G. Knepley + prob - The PetscDS object 32179252d075SMatthew G. Knepley . numFields - Number of new fields 32189252d075SMatthew G. Knepley - fields - Old field number for each new field 32199252d075SMatthew G. Knepley 32209252d075SMatthew G. Knepley Output Parameter: 32219252d075SMatthew G. Knepley . newprob - The PetscDS copy 32229252d075SMatthew G. Knepley 32239252d075SMatthew G. Knepley Level: intermediate 32249252d075SMatthew G. Knepley 32259252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 32269252d075SMatthew G. Knepley @*/ 32279252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 32289252d075SMatthew G. Knepley { 32299252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 32309252d075SMatthew G. Knepley PetscErrorCode ierr; 32319252d075SMatthew G. Knepley 32329252d075SMatthew G. Knepley PetscFunctionBegin; 32339252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32349252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 32359252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 32369252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 32379252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 32389252d075SMatthew 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); 32399252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 32409252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 32419252d075SMatthew G. Knepley PetscPointFunc obj; 32429252d075SMatthew G. Knepley PetscPointFunc f0, f1; 32439252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 32449252d075SMatthew G. Knepley PetscRiemannFunc r; 32459252d075SMatthew G. Knepley 3246c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 32479252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 32489252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 32499252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 32509252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 32519252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 32529252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 32539252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 32549252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 32559252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 32569252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 32579252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 32589252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 32599252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 32609252d075SMatthew G. Knepley 3261c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 32629252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 32639252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 32649252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 32659252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 32669252d075SMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(prob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 32679252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 32689252d075SMatthew G. Knepley } 32699252d075SMatthew G. Knepley } 32709252d075SMatthew G. Knepley PetscFunctionReturn(0); 32719252d075SMatthew G. Knepley } 32729252d075SMatthew G. Knepley 3273da51fcedSMatthew G. Knepley /*@ 3274da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3275da51fcedSMatthew G. Knepley 3276da51fcedSMatthew G. Knepley Not collective 3277da51fcedSMatthew G. Knepley 3278da51fcedSMatthew G. Knepley Input Parameter: 3279da51fcedSMatthew G. Knepley . prob - The PetscDS object 3280da51fcedSMatthew G. Knepley 3281da51fcedSMatthew G. Knepley Output Parameter: 3282da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3283da51fcedSMatthew G. Knepley 3284da51fcedSMatthew G. Knepley Level: intermediate 3285da51fcedSMatthew G. Knepley 32869252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3287da51fcedSMatthew G. Knepley @*/ 3288da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3289da51fcedSMatthew G. Knepley { 32909252d075SMatthew G. Knepley PetscInt Nf, Ng; 3291da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3292da51fcedSMatthew G. Knepley 3293da51fcedSMatthew G. Knepley PetscFunctionBegin; 3294da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3295da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3296da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3297da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 329813903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 32999252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 33009252d075SMatthew G. Knepley PetscFunctionReturn(0); 33019252d075SMatthew G. Knepley } 33029252d075SMatthew G. Knepley /*@ 33039252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3304da51fcedSMatthew G. Knepley 33059252d075SMatthew G. Knepley Not collective 33069252d075SMatthew G. Knepley 33079252d075SMatthew G. Knepley Input Parameter: 33089252d075SMatthew G. Knepley . prob - The PetscDS object 33099252d075SMatthew G. Knepley 33109252d075SMatthew G. Knepley Output Parameter: 33119252d075SMatthew G. Knepley . newprob - The PetscDS copy 33129252d075SMatthew G. Knepley 33139252d075SMatthew G. Knepley Level: intermediate 33149252d075SMatthew G. Knepley 33159252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 33169252d075SMatthew G. Knepley @*/ 33179252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 33189252d075SMatthew G. Knepley { 33199252d075SMatthew G. Knepley PetscInt Nc; 33209252d075SMatthew G. Knepley const PetscScalar *constants; 33219252d075SMatthew G. Knepley PetscErrorCode ierr; 33229252d075SMatthew G. Knepley 33239252d075SMatthew G. Knepley PetscFunctionBegin; 33249252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33259252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 33269252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 33279252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3328da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3329da51fcedSMatthew G. Knepley } 3330da51fcedSMatthew G. Knepley 3331b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3332b1353e8eSMatthew G. Knepley { 3333df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3334b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3335b1353e8eSMatthew G. Knepley 3336b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3337b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3338b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3339b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3340b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3341df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3342df3a45bdSMatthew 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); 3343df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3344df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3345b1353e8eSMatthew G. Knepley PetscInt cdim; 3346b1353e8eSMatthew G. Knepley 3347df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3348b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3349df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3350b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3351b1353e8eSMatthew G. Knepley PetscFE subfe; 3352b1353e8eSMatthew G. Knepley PetscObject obj; 3353b1353e8eSMatthew G. Knepley PetscClassId id; 3354b1353e8eSMatthew G. Knepley 3355b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3356b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3357b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3358b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3359df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3360b1353e8eSMatthew G. Knepley } 3361b1353e8eSMatthew G. Knepley } 3362df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3363b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3364b1353e8eSMatthew G. Knepley } 3365b1353e8eSMatthew G. Knepley 3366c7bd5f0bSMatthew G. Knepley PetscErrorCode PetscDSIsFE_Internal(PetscDS ds, PetscInt f, PetscBool *isFE) 3367c7bd5f0bSMatthew G. Knepley { 3368c7bd5f0bSMatthew G. Knepley PetscObject obj; 3369c7bd5f0bSMatthew G. Knepley PetscClassId id; 3370c7bd5f0bSMatthew G. Knepley PetscInt Nf; 3371c7bd5f0bSMatthew G. Knepley PetscErrorCode ierr; 3372c7bd5f0bSMatthew G. Knepley 3373c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 3374c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3375c7bd5f0bSMatthew G. Knepley PetscValidPointer(isFE, 3); 3376c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 3377c7bd5f0bSMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 3378c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetDiscretization(ds, f, &obj);CHKERRQ(ierr); 3379c7bd5f0bSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3380c7bd5f0bSMatthew G. Knepley if (id == PETSCFE_CLASSID) *isFE = PETSC_TRUE; 3381c7bd5f0bSMatthew G. Knepley else *isFE = PETSC_FALSE; 3382c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 3383c7bd5f0bSMatthew G. Knepley } 3384c7bd5f0bSMatthew G. Knepley 3385bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 33862764a2aaSMatthew G. Knepley { 3387931fb3b8SToby Isaac PetscErrorCode ierr; 3388931fb3b8SToby Isaac 33892764a2aaSMatthew G. Knepley PetscFunctionBegin; 3390931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 33912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 33922764a2aaSMatthew G. Knepley } 33932764a2aaSMatthew G. Knepley 3394bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 33952764a2aaSMatthew G. Knepley { 33962764a2aaSMatthew G. Knepley PetscFunctionBegin; 33972764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 33982764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 33992764a2aaSMatthew G. Knepley prob->ops->view = NULL; 34002764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 34012764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 34022764a2aaSMatthew G. Knepley } 34032764a2aaSMatthew G. Knepley 34042764a2aaSMatthew G. Knepley /*MC 34052764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 34062764a2aaSMatthew G. Knepley 34072764a2aaSMatthew G. Knepley Level: intermediate 34082764a2aaSMatthew G. Knepley 34092764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 34102764a2aaSMatthew G. Knepley M*/ 34112764a2aaSMatthew G. Knepley 34122764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 34132764a2aaSMatthew G. Knepley { 34142764a2aaSMatthew G. Knepley PetscDS_Basic *b; 34152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 34162764a2aaSMatthew G. Knepley 34172764a2aaSMatthew G. Knepley PetscFunctionBegin; 3418931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 34192764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 34202764a2aaSMatthew G. Knepley prob->data = b; 34212764a2aaSMatthew G. Knepley 34222764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 34232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 34242764a2aaSMatthew G. Knepley } 3425