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; 385*665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 3869de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3872764a2aaSMatthew G. Knepley 3889de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 389*665f567fSMatthew G. Knepley if (!obj) { 390*665f567fSMatthew G. Knepley /* Empty mesh */ 391*665f567fSMatthew G. Knepley Nb = Nc = 0; 392*665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 393*665f567fSMatthew G. Knepley } else { 3949de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3959de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3969de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3979de99aefSMatthew G. Knepley 3982764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3992764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 4002764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 401ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetCellTabulation(fe, &prob->T[f]);CHKERRQ(ierr); 402ef0bb6c7SMatthew G. Knepley ierr = PetscFEGetFaceTabulation(fe, &prob->Tf[f]);CHKERRQ(ierr); 4039de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4049de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4059de99aefSMatthew G. Knepley 4069de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 4079de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 4089c3cf19fSMatthew G. Knepley Nb = Nc; 409ef0bb6c7SMatthew G. Knepley ierr = PetscFVGetCellTabulation(fv, &prob->T[f]);CHKERRQ(ierr); 4104d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 411abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 412*665f567fSMatthew G. Knepley } 41347e57110SSander Arens prob->Nc[f] = Nc; 41447e57110SSander Arens prob->Nb[f] = Nb; 415194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 416194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 417a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 4182764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4194bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4202764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4219c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4222764a2aaSMatthew G. Knepley prob->totComp += Nc; 42394a5e212SMatthew G. Knepley /* There are two faces for all fields but the cohesive field on a hybrid cell */ 42494a5e212SMatthew G. Knepley if (prob->isHybrid && (f < Nf-1)) prob->totDim += Nb; 4252764a2aaSMatthew G. Knepley } 4262764a2aaSMatthew G. Knepley /* Allocate works space */ 42794a5e212SMatthew G. Knepley if (prob->isHybrid) NsMax = 2; 4284bee2e38SMatthew G. Knepley ierr = PetscMalloc3(NsMax*prob->totComp,&prob->u,NsMax*prob->totComp,&prob->u_t,NsMax*prob->totComp*dimEmbed,&prob->u_x);CHKERRQ(ierr); 4294bee2e38SMatthew G. Knepley ierr = PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal);CHKERRQ(ierr); 43027f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 43127f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 43227f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4332764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 4342764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4362764a2aaSMatthew G. Knepley } 4372764a2aaSMatthew G. Knepley 4382764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4392764a2aaSMatthew G. Knepley { 4402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4412764a2aaSMatthew G. Knepley 4422764a2aaSMatthew G. Knepley PetscFunctionBegin; 44347e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 444f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 445ef0bb6c7SMatthew G. Knepley ierr = PetscFree2(prob->T,prob->Tf);CHKERRQ(ierr); 4464bee2e38SMatthew G. Knepley ierr = PetscFree3(prob->u,prob->u_t,prob->u_x);CHKERRQ(ierr); 4474bee2e38SMatthew G. Knepley ierr = PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal);CHKERRQ(ierr); 4482764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 4492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4502764a2aaSMatthew G. Knepley } 4512764a2aaSMatthew G. Knepley 4522764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4532764a2aaSMatthew G. Knepley { 454f744cafaSSander Arens PetscObject *tmpd; 45534aa8a36SMatthew G. Knepley PetscBool *tmpi; 45632d2bbc9SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf, *tmpup; 457b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 4582aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 45927f02ce8SMatthew G. Knepley PetscBdPointJac *tmpgbd, *tmpgpbd; 460194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 461c371a6d1SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol; 46295cbbfd3SMatthew G. Knepley void **tmpexactCtx; 4630c2f2876SMatthew G. Knepley void **tmpctx; 46434aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4662764a2aaSMatthew G. Knepley 4672764a2aaSMatthew G. Knepley PetscFunctionBegin; 4682764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4692764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4702764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 47134aa8a36SMatthew G. Knepley ierr = PetscMalloc2(NfNew, &tmpd, NfNew, &tmpi);CHKERRQ(ierr); 47234aa8a36SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f];} 47334aa8a36SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE;} 47434aa8a36SMatthew G. Knepley ierr = PetscFree2(prob->disc, prob->implicit);CHKERRQ(ierr); 4752764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4762764a2aaSMatthew G. Knepley prob->disc = tmpd; 477249df284SMatthew G. Knepley prob->implicit = tmpi; 478b7e05686SMatthew G. Knepley ierr = PetscCalloc7(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew*NfNew*4, &tmpgp, NfNew*NfNew*4, &tmpgt, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 47932d2bbc9SMatthew G. Knepley ierr = PetscCalloc1(NfNew, &tmpup);CHKERRQ(ierr); 4802764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4812764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4822764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 483475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4840c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 48532d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4860c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4872764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4882764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4892764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 490475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 491b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4920c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 49332d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4940c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 495b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 49632d2bbc9SMatthew G. Knepley ierr = PetscFree(prob->update);CHKERRQ(ierr); 4972764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4982764a2aaSMatthew G. Knepley prob->f = tmpf; 4992764a2aaSMatthew G. Knepley prob->g = tmpg; 500475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 501b7e05686SMatthew G. Knepley prob->gt = tmpgt; 5020c2f2876SMatthew G. Knepley prob->r = tmpr; 50332d2bbc9SMatthew G. Knepley prob->update = tmpup; 5040c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 50527f02ce8SMatthew G. Knepley ierr = PetscCalloc5(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd, NfNew*NfNew*4, &tmpgpbd, NfNew, &tmpexactSol, NfNew, &tmpexactCtx);CHKERRQ(ierr); 5062764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 5072764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 50827f02ce8SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgpbd[f] = prob->gpBd[f]; 509c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 51095cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 5112764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 5122764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 51327f02ce8SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgpbd[f] = NULL; 514c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 51595cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 51627f02ce8SMatthew G. Knepley ierr = PetscFree5(prob->fBd, prob->gBd, prob->gpBd, prob->exactSol, prob->exactCtx);CHKERRQ(ierr); 5172764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 5182764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 51927f02ce8SMatthew G. Knepley prob->gpBd = tmpgpbd; 520c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 52195cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 5222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5232764a2aaSMatthew G. Knepley } 5242764a2aaSMatthew G. Knepley 5252764a2aaSMatthew G. Knepley /*@ 5262764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5272764a2aaSMatthew G. Knepley 528d083f849SBarry Smith Collective on prob 5292764a2aaSMatthew G. Knepley 5302764a2aaSMatthew G. Knepley Input Parameter: 5312764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5322764a2aaSMatthew G. Knepley 5332764a2aaSMatthew G. Knepley Level: developer 5342764a2aaSMatthew G. Knepley 5352764a2aaSMatthew G. Knepley .seealso PetscDSView() 5362764a2aaSMatthew G. Knepley @*/ 5372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 5382764a2aaSMatthew G. Knepley { 5392764a2aaSMatthew G. Knepley PetscInt f; 54058ebd649SToby Isaac DSBoundary next; 5412764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5422764a2aaSMatthew G. Knepley 5432764a2aaSMatthew G. Knepley PetscFunctionBegin; 5442764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 5452764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 5462764a2aaSMatthew G. Knepley 5472764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 5482764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 549df3a45bdSMatthew G. Knepley if ((*prob)->subprobs) { 550df3a45bdSMatthew G. Knepley PetscInt dim, d; 551df3a45bdSMatthew G. Knepley 552df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*prob, &dim);CHKERRQ(ierr); 553df3a45bdSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*prob)->subprobs[d]);CHKERRQ(ierr);} 554df3a45bdSMatthew G. Knepley } 555df3a45bdSMatthew G. Knepley ierr = PetscFree((*prob)->subprobs);CHKERRQ(ierr); 5562764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 5572764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 5582764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 5592764a2aaSMatthew G. Knepley } 56034aa8a36SMatthew G. Knepley ierr = PetscFree2((*prob)->disc, (*prob)->implicit);CHKERRQ(ierr); 561b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 56232d2bbc9SMatthew G. Knepley ierr = PetscFree((*prob)->update);CHKERRQ(ierr); 56327f02ce8SMatthew G. Knepley ierr = PetscFree5((*prob)->fBd,(*prob)->gBd,(*prob)->gpBd,(*prob)->exactSol,(*prob)->exactCtx);CHKERRQ(ierr); 5642764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 56558ebd649SToby Isaac next = (*prob)->boundary; 56658ebd649SToby Isaac while (next) { 56758ebd649SToby Isaac DSBoundary b = next; 56858ebd649SToby Isaac 56958ebd649SToby Isaac next = b->next; 57058ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 57158ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 57258ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 57358ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 57458ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 57558ebd649SToby Isaac } 57697b6e6e8SMatthew G. Knepley ierr = PetscFree((*prob)->constants);CHKERRQ(ierr); 5772764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 5782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5792764a2aaSMatthew G. Knepley } 5802764a2aaSMatthew G. Knepley 5812764a2aaSMatthew G. Knepley /*@ 5822764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5832764a2aaSMatthew G. Knepley 584d083f849SBarry Smith Collective 5852764a2aaSMatthew G. Knepley 5862764a2aaSMatthew G. Knepley Input Parameter: 5872764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5882764a2aaSMatthew G. Knepley 5892764a2aaSMatthew G. Knepley Output Parameter: 5902764a2aaSMatthew G. Knepley . prob - The PetscDS object 5912764a2aaSMatthew G. Knepley 5922764a2aaSMatthew G. Knepley Level: beginner 5932764a2aaSMatthew G. Knepley 5942764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5952764a2aaSMatthew G. Knepley @*/ 5962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 5972764a2aaSMatthew G. Knepley { 5982764a2aaSMatthew G. Knepley PetscDS p; 5992764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6002764a2aaSMatthew G. Knepley 6012764a2aaSMatthew G. Knepley PetscFunctionBegin; 6022764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 6032764a2aaSMatthew G. Knepley *prob = NULL; 6042764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 6052764a2aaSMatthew G. Knepley 60673107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 6072764a2aaSMatthew G. Knepley 6082764a2aaSMatthew G. Knepley p->Nf = 0; 6092764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 61097b6e6e8SMatthew G. Knepley p->numConstants = 0; 61197b6e6e8SMatthew G. Knepley p->constants = NULL; 612a859676bSMatthew G. Knepley p->dimEmbed = -1; 61355c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 6142764a2aaSMatthew G. Knepley 6152764a2aaSMatthew G. Knepley *prob = p; 6162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6172764a2aaSMatthew G. Knepley } 6182764a2aaSMatthew G. Knepley 619bc4ae4beSMatthew G. Knepley /*@ 620bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 621bc4ae4beSMatthew G. Knepley 622bc4ae4beSMatthew G. Knepley Not collective 623bc4ae4beSMatthew G. Knepley 624bc4ae4beSMatthew G. Knepley Input Parameter: 625bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 626bc4ae4beSMatthew G. Knepley 627bc4ae4beSMatthew G. Knepley Output Parameter: 628bc4ae4beSMatthew G. Knepley . Nf - The number of fields 629bc4ae4beSMatthew G. Knepley 630bc4ae4beSMatthew G. Knepley Level: beginner 631bc4ae4beSMatthew G. Knepley 632bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 633bc4ae4beSMatthew G. Knepley @*/ 6342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6352764a2aaSMatthew G. Knepley { 6362764a2aaSMatthew G. Knepley PetscFunctionBegin; 6372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6382764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6392764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6412764a2aaSMatthew G. Knepley } 6422764a2aaSMatthew G. Knepley 643bc4ae4beSMatthew G. Knepley /*@ 644a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 645bc4ae4beSMatthew G. Knepley 646bc4ae4beSMatthew G. Knepley Not collective 647bc4ae4beSMatthew G. Knepley 648bc4ae4beSMatthew G. Knepley Input Parameter: 649bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 650bc4ae4beSMatthew G. Knepley 651bc4ae4beSMatthew G. Knepley Output Parameter: 652bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 653bc4ae4beSMatthew G. Knepley 654bc4ae4beSMatthew G. Knepley Level: beginner 655bc4ae4beSMatthew G. Knepley 656a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 657bc4ae4beSMatthew G. Knepley @*/ 6582764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6592764a2aaSMatthew G. Knepley { 6602764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6612764a2aaSMatthew G. Knepley 6622764a2aaSMatthew G. Knepley PetscFunctionBegin; 6632764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6642764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6652764a2aaSMatthew G. Knepley *dim = 0; 6669de99aefSMatthew G. Knepley if (prob->Nf) { 6679de99aefSMatthew G. Knepley PetscObject obj; 6689de99aefSMatthew G. Knepley PetscClassId id; 6699de99aefSMatthew G. Knepley 6709de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 671*665f567fSMatthew G. Knepley if (obj) { 6729de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 6739de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 6749de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 6759de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6769de99aefSMatthew G. Knepley } 677*665f567fSMatthew G. Knepley } 6782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6792764a2aaSMatthew G. Knepley } 6802764a2aaSMatthew G. Knepley 681bc4ae4beSMatthew G. Knepley /*@ 682a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 683a859676bSMatthew G. Knepley 684a859676bSMatthew G. Knepley Not collective 685a859676bSMatthew G. Knepley 686a859676bSMatthew G. Knepley Input Parameter: 687a859676bSMatthew G. Knepley . prob - The PetscDS object 688a859676bSMatthew G. Knepley 689a859676bSMatthew G. Knepley Output Parameter: 690a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 691a859676bSMatthew G. Knepley 692a859676bSMatthew G. Knepley Level: beginner 693a859676bSMatthew G. Knepley 694a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 695a859676bSMatthew G. Knepley @*/ 696a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 697a859676bSMatthew G. Knepley { 698a859676bSMatthew G. Knepley PetscFunctionBegin; 699a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 700a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 701a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 702a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 703a859676bSMatthew G. Knepley PetscFunctionReturn(0); 704a859676bSMatthew G. Knepley } 705a859676bSMatthew G. Knepley 706a859676bSMatthew G. Knepley /*@ 707a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 708a859676bSMatthew G. Knepley 709d083f849SBarry Smith Logically collective on prob 710a859676bSMatthew G. Knepley 711a859676bSMatthew G. Knepley Input Parameters: 712a859676bSMatthew G. Knepley + prob - The PetscDS object 713a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 714a859676bSMatthew G. Knepley 715a859676bSMatthew G. Knepley Level: beginner 716a859676bSMatthew G. Knepley 717a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 718a859676bSMatthew G. Knepley @*/ 719a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 720a859676bSMatthew G. Knepley { 721a859676bSMatthew G. Knepley PetscFunctionBegin; 722a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 723ebfe4b0dSMatthew G. Knepley if (dimEmbed < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 724a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 725a859676bSMatthew G. Knepley PetscFunctionReturn(0); 726a859676bSMatthew G. Knepley } 727a859676bSMatthew G. Knepley 728a859676bSMatthew G. Knepley /*@ 7298edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 7308edf6225SMatthew G. Knepley 7318edf6225SMatthew G. Knepley Not collective 7328edf6225SMatthew G. Knepley 7338edf6225SMatthew G. Knepley Input Parameter: 7348edf6225SMatthew G. Knepley . prob - The PetscDS object 7358edf6225SMatthew G. Knepley 7368edf6225SMatthew G. Knepley Output Parameter: 7378edf6225SMatthew G. Knepley . isHybrid - The flag 7388edf6225SMatthew G. Knepley 7398edf6225SMatthew G. Knepley Level: developer 7408edf6225SMatthew G. Knepley 7418edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 7428edf6225SMatthew G. Knepley @*/ 7438edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 7448edf6225SMatthew G. Knepley { 7458edf6225SMatthew G. Knepley PetscFunctionBegin; 7468edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7478edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 7488edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 7498edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7508edf6225SMatthew G. Knepley } 7518edf6225SMatthew G. Knepley 7528edf6225SMatthew G. Knepley /*@ 7538edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 7548edf6225SMatthew G. Knepley 7558edf6225SMatthew G. Knepley Not collective 7568edf6225SMatthew G. Knepley 7578edf6225SMatthew G. Knepley Input Parameters: 7588edf6225SMatthew G. Knepley + prob - The PetscDS object 7598edf6225SMatthew G. Knepley - isHybrid - The flag 7608edf6225SMatthew G. Knepley 7618edf6225SMatthew G. Knepley Level: developer 7628edf6225SMatthew G. Knepley 7638edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 7648edf6225SMatthew G. Knepley @*/ 7658edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 7668edf6225SMatthew G. Knepley { 7678edf6225SMatthew G. Knepley PetscFunctionBegin; 7688edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7698edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 7708edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7718edf6225SMatthew G. Knepley } 7728edf6225SMatthew G. Knepley 7738edf6225SMatthew G. Knepley /*@ 774bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 775bc4ae4beSMatthew G. Knepley 776bc4ae4beSMatthew G. Knepley Not collective 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley Input Parameter: 779bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 780bc4ae4beSMatthew G. Knepley 781bc4ae4beSMatthew G. Knepley Output Parameter: 782bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 783bc4ae4beSMatthew G. Knepley 784bc4ae4beSMatthew G. Knepley Level: beginner 785bc4ae4beSMatthew G. Knepley 786bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 787bc4ae4beSMatthew G. Knepley @*/ 7882764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7892764a2aaSMatthew G. Knepley { 7902764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7912764a2aaSMatthew G. Knepley 7922764a2aaSMatthew G. Knepley PetscFunctionBegin; 7932764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7942764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7952764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 7962764a2aaSMatthew G. Knepley *dim = prob->totDim; 7972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7982764a2aaSMatthew G. Knepley } 7992764a2aaSMatthew G. Knepley 800bc4ae4beSMatthew G. Knepley /*@ 801bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 802bc4ae4beSMatthew G. Knepley 803bc4ae4beSMatthew G. Knepley Not collective 804bc4ae4beSMatthew G. Knepley 805bc4ae4beSMatthew G. Knepley Input Parameter: 806bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 807bc4ae4beSMatthew G. Knepley 808bc4ae4beSMatthew G. Knepley Output Parameter: 809bc4ae4beSMatthew G. Knepley . dim - The total number of components 810bc4ae4beSMatthew G. Knepley 811bc4ae4beSMatthew G. Knepley Level: beginner 812bc4ae4beSMatthew G. Knepley 813bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 814bc4ae4beSMatthew G. Knepley @*/ 8152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8162764a2aaSMatthew G. Knepley { 8172764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8182764a2aaSMatthew G. Knepley 8192764a2aaSMatthew G. Knepley PetscFunctionBegin; 8202764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8212764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8222764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8232764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8252764a2aaSMatthew G. Knepley } 8262764a2aaSMatthew G. Knepley 827bc4ae4beSMatthew G. Knepley /*@ 828bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 829bc4ae4beSMatthew G. Knepley 830bc4ae4beSMatthew G. Knepley Not collective 831bc4ae4beSMatthew G. Knepley 832bc4ae4beSMatthew G. Knepley Input Parameters: 833bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 834bc4ae4beSMatthew G. Knepley - f - The field number 835bc4ae4beSMatthew G. Knepley 836bc4ae4beSMatthew G. Knepley Output Parameter: 837bc4ae4beSMatthew G. Knepley . disc - The discretization object 838bc4ae4beSMatthew G. Knepley 839bc4ae4beSMatthew G. Knepley Level: beginner 840bc4ae4beSMatthew G. Knepley 841f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 842bc4ae4beSMatthew G. Knepley @*/ 8432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8442764a2aaSMatthew G. Knepley { 8452764a2aaSMatthew G. Knepley PetscFunctionBegin; 8462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8472764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8482764a2aaSMatthew 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); 8492764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8512764a2aaSMatthew G. Knepley } 8522764a2aaSMatthew G. Knepley 853bc4ae4beSMatthew G. Knepley /*@ 854bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 855bc4ae4beSMatthew G. Knepley 856bc4ae4beSMatthew G. Knepley Not collective 857bc4ae4beSMatthew G. Knepley 858bc4ae4beSMatthew G. Knepley Input Parameters: 859bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 860bc4ae4beSMatthew G. Knepley . f - The field number 861bc4ae4beSMatthew G. Knepley - disc - The discretization object 862bc4ae4beSMatthew G. Knepley 863bc4ae4beSMatthew G. Knepley Level: beginner 864bc4ae4beSMatthew G. Knepley 865bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 866bc4ae4beSMatthew G. Knepley @*/ 8672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 8682764a2aaSMatthew G. Knepley { 8692764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8702764a2aaSMatthew G. Knepley 8712764a2aaSMatthew G. Knepley PetscFunctionBegin; 8722764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 873*665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 8742764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 8752764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 876c10f2116SMatthew G. Knepley ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr); 8772764a2aaSMatthew G. Knepley prob->disc[f] = disc; 8782764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 879*665f567fSMatthew G. Knepley if (disc) { 880249df284SMatthew G. Knepley PetscClassId id; 881249df284SMatthew G. Knepley 882249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8831cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8841cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8851cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8861cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 887a6cbbb48SMatthew G. Knepley } 888249df284SMatthew G. Knepley } 8892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8902764a2aaSMatthew G. Knepley } 8912764a2aaSMatthew G. Knepley 892bc4ae4beSMatthew G. Knepley /*@ 893bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 894bc4ae4beSMatthew G. Knepley 895bc4ae4beSMatthew G. Knepley Not collective 896bc4ae4beSMatthew G. Knepley 897bc4ae4beSMatthew G. Knepley Input Parameters: 898bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 899bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 900bc4ae4beSMatthew G. Knepley 901bc4ae4beSMatthew G. Knepley Level: beginner 902bc4ae4beSMatthew G. Knepley 903bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 904bc4ae4beSMatthew G. Knepley @*/ 9052764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9062764a2aaSMatthew G. Knepley { 9072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9082764a2aaSMatthew G. Knepley 9092764a2aaSMatthew G. Knepley PetscFunctionBegin; 9102764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 9112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9122764a2aaSMatthew G. Knepley } 9132764a2aaSMatthew G. Knepley 914249df284SMatthew G. Knepley /*@ 915249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 916249df284SMatthew G. Knepley 917249df284SMatthew G. Knepley Not collective 918249df284SMatthew G. Knepley 919249df284SMatthew G. Knepley Input Parameters: 920249df284SMatthew G. Knepley + prob - The PetscDS object 921249df284SMatthew G. Knepley - f - The field number 922249df284SMatthew G. Knepley 923249df284SMatthew G. Knepley Output Parameter: 924249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 925249df284SMatthew G. Knepley 926249df284SMatthew G. Knepley Level: developer 927249df284SMatthew G. Knepley 928f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 929249df284SMatthew G. Knepley @*/ 930249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 931249df284SMatthew G. Knepley { 932249df284SMatthew G. Knepley PetscFunctionBegin; 933249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 934249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 935249df284SMatthew 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); 936249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 937249df284SMatthew G. Knepley PetscFunctionReturn(0); 938249df284SMatthew G. Knepley } 939249df284SMatthew G. Knepley 940249df284SMatthew G. Knepley /*@ 941249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 942249df284SMatthew G. Knepley 943249df284SMatthew G. Knepley Not collective 944249df284SMatthew G. Knepley 945249df284SMatthew G. Knepley Input Parameters: 946249df284SMatthew G. Knepley + prob - The PetscDS object 947249df284SMatthew G. Knepley . f - The field number 948249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 949249df284SMatthew G. Knepley 950249df284SMatthew G. Knepley Level: developer 951249df284SMatthew G. Knepley 952f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 953249df284SMatthew G. Knepley @*/ 954249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 955249df284SMatthew G. Knepley { 956249df284SMatthew G. Knepley PetscFunctionBegin; 957249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 958249df284SMatthew 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); 959249df284SMatthew G. Knepley prob->implicit[f] = implicit; 960249df284SMatthew G. Knepley PetscFunctionReturn(0); 961249df284SMatthew G. Knepley } 962249df284SMatthew G. Knepley 9632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 96430b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 965194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 966194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 96797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9682764a2aaSMatthew G. Knepley { 9692764a2aaSMatthew G. Knepley PetscFunctionBegin; 9702764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9712764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9722764a2aaSMatthew 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); 9732764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9742764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9752764a2aaSMatthew G. Knepley } 9762764a2aaSMatthew G. Knepley 9772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 97830b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 979194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 980194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 98197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9822764a2aaSMatthew G. Knepley { 9832764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9842764a2aaSMatthew G. Knepley 9852764a2aaSMatthew G. Knepley PetscFunctionBegin; 9862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 987de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9882764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9892764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9902764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9922764a2aaSMatthew G. Knepley } 9932764a2aaSMatthew G. Knepley 994194d53e6SMatthew G. Knepley /*@C 995194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 996194d53e6SMatthew G. Knepley 997194d53e6SMatthew G. Knepley Not collective 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew G. Knepley Input Parameters: 1000194d53e6SMatthew G. Knepley + prob - The PetscDS 1001194d53e6SMatthew G. Knepley - f - The test field number 1002194d53e6SMatthew G. Knepley 1003194d53e6SMatthew G. Knepley Output Parameters: 1004194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1005194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1006194d53e6SMatthew G. Knepley 1007194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1008194d53e6SMatthew G. Knepley 1009194d53e6SMatthew 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) 1010194d53e6SMatthew G. Knepley 1011194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1012194d53e6SMatthew G. Knepley 101330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1014194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1015194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1017194d53e6SMatthew G. Knepley 1018194d53e6SMatthew G. Knepley + dim - the spatial dimension 1019194d53e6SMatthew G. Knepley . Nf - the number of fields 1020194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1021194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1022194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1023194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1024194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1025194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1026194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1027194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1028194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1029194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1030194d53e6SMatthew G. Knepley . t - current time 1031194d53e6SMatthew G. Knepley . x - coordinates of the current point 103297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 103397b6e6e8SMatthew G. Knepley . constants - constant parameters 1034194d53e6SMatthew G. Knepley - f0 - output values at the current point 1035194d53e6SMatthew G. Knepley 1036194d53e6SMatthew G. Knepley Level: intermediate 1037194d53e6SMatthew G. Knepley 1038194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1039194d53e6SMatthew G. Knepley @*/ 10402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 104130b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1042194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1043194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 104530b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1046194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1047194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 10492764a2aaSMatthew G. Knepley { 10502764a2aaSMatthew G. Knepley PetscFunctionBegin; 10512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10522764a2aaSMatthew 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); 10532764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10542764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10562764a2aaSMatthew G. Knepley } 10572764a2aaSMatthew G. Knepley 1058194d53e6SMatthew G. Knepley /*@C 1059194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1060194d53e6SMatthew G. Knepley 1061194d53e6SMatthew G. Knepley Not collective 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew G. Knepley Input Parameters: 1064194d53e6SMatthew G. Knepley + prob - The PetscDS 1065194d53e6SMatthew G. Knepley . f - The test field number 1066194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1067194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1068194d53e6SMatthew G. Knepley 1069194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1070194d53e6SMatthew G. Knepley 1071194d53e6SMatthew 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) 1072194d53e6SMatthew G. Knepley 1073194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1074194d53e6SMatthew G. Knepley 107530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1076194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1077194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 107830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1079194d53e6SMatthew G. Knepley 1080194d53e6SMatthew G. Knepley + dim - the spatial dimension 1081194d53e6SMatthew G. Knepley . Nf - the number of fields 1082194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1083194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1084194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1085194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1086194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1087194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1088194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1089194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1090194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1091194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1092194d53e6SMatthew G. Knepley . t - current time 1093194d53e6SMatthew G. Knepley . x - coordinates of the current point 109497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 109597b6e6e8SMatthew G. Knepley . constants - constant parameters 1096194d53e6SMatthew G. Knepley - f0 - output values at the current point 1097194d53e6SMatthew G. Knepley 1098194d53e6SMatthew G. Knepley Level: intermediate 1099194d53e6SMatthew G. Knepley 1100194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1101194d53e6SMatthew G. Knepley @*/ 11022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 110330b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1104194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1105194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 110730b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1108194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1109194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 111097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11112764a2aaSMatthew G. Knepley { 11122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11132764a2aaSMatthew G. Knepley 11142764a2aaSMatthew G. Knepley PetscFunctionBegin; 11152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1116f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1117f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11182764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11192764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11202764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11212764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11232764a2aaSMatthew G. Knepley } 11242764a2aaSMatthew G. Knepley 11253e75805dSMatthew G. Knepley /*@C 11263e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11273e75805dSMatthew G. Knepley 11283e75805dSMatthew G. Knepley Not collective 11293e75805dSMatthew G. Knepley 11303e75805dSMatthew G. Knepley Input Parameter: 11313e75805dSMatthew G. Knepley . prob - The PetscDS 11323e75805dSMatthew G. Knepley 11333e75805dSMatthew G. Knepley Output Parameter: 11343e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11353e75805dSMatthew G. Knepley 11363e75805dSMatthew G. Knepley Level: intermediate 11373e75805dSMatthew G. Knepley 11383e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11393e75805dSMatthew G. Knepley @*/ 11403e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11413e75805dSMatthew G. Knepley { 11423e75805dSMatthew G. Knepley PetscInt f, g, h; 11433e75805dSMatthew G. Knepley 11443e75805dSMatthew G. Knepley PetscFunctionBegin; 11453e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11463e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11473e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11483e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11493e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11503e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11513e75805dSMatthew G. Knepley } 11523e75805dSMatthew G. Knepley } 11533e75805dSMatthew G. Knepley } 11543e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11553e75805dSMatthew G. Knepley } 11563e75805dSMatthew G. Knepley 1157194d53e6SMatthew G. Knepley /*@C 1158194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1159194d53e6SMatthew G. Knepley 1160194d53e6SMatthew G. Knepley Not collective 1161194d53e6SMatthew G. Knepley 1162194d53e6SMatthew G. Knepley Input Parameters: 1163194d53e6SMatthew G. Knepley + prob - The PetscDS 1164194d53e6SMatthew G. Knepley . f - The test field number 1165194d53e6SMatthew G. Knepley - g - The field number 1166194d53e6SMatthew G. Knepley 1167194d53e6SMatthew G. Knepley Output Parameters: 1168194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1169194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1170194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1171194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1172194d53e6SMatthew G. Knepley 1173194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1174194d53e6SMatthew G. Knepley 1175194d53e6SMatthew 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 1176194d53e6SMatthew G. Knepley 1177194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1178194d53e6SMatthew G. Knepley 117930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1180194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1181194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 118230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1183194d53e6SMatthew G. Knepley 1184194d53e6SMatthew G. Knepley + dim - the spatial dimension 1185194d53e6SMatthew G. Knepley . Nf - the number of fields 1186194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1187194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1188194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1189194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1190194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1191194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1192194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1193194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1194194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1195194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1196194d53e6SMatthew G. Knepley . t - current time 11972aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1198194d53e6SMatthew G. Knepley . x - coordinates of the current point 119997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 120097b6e6e8SMatthew G. Knepley . constants - constant parameters 1201194d53e6SMatthew G. Knepley - g0 - output values at the current point 1202194d53e6SMatthew G. Knepley 1203194d53e6SMatthew G. Knepley Level: intermediate 1204194d53e6SMatthew G. Knepley 1205194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1206194d53e6SMatthew G. Knepley @*/ 12072764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 120830b9ff8bSMatthew G. Knepley void (**g0)(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 g0[]), 121230b9ff8bSMatthew G. Knepley void (**g1)(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 g1[]), 121630b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1217194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1218194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 122030b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1221194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1222194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 122397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12242764a2aaSMatthew G. Knepley { 12252764a2aaSMatthew G. Knepley PetscFunctionBegin; 12262764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12272764a2aaSMatthew 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); 12282764a2aaSMatthew 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); 12292764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12302764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12312764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12322764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12332764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12342764a2aaSMatthew G. Knepley } 12352764a2aaSMatthew G. Knepley 1236194d53e6SMatthew G. Knepley /*@C 1237194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1238194d53e6SMatthew G. Knepley 1239194d53e6SMatthew G. Knepley Not collective 1240194d53e6SMatthew G. Knepley 1241194d53e6SMatthew G. Knepley Input Parameters: 1242194d53e6SMatthew G. Knepley + prob - The PetscDS 1243194d53e6SMatthew G. Knepley . f - The test field number 1244194d53e6SMatthew G. Knepley . g - The field number 1245194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1246194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1247194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1248194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1249194d53e6SMatthew G. Knepley 1250194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1251194d53e6SMatthew G. Knepley 1252194d53e6SMatthew 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 1253194d53e6SMatthew G. Knepley 1254194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1255194d53e6SMatthew G. Knepley 125630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1257194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1258194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 125930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1260194d53e6SMatthew G. Knepley 1261194d53e6SMatthew G. Knepley + dim - the spatial dimension 1262194d53e6SMatthew G. Knepley . Nf - the number of fields 1263194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1264194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1265194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1266194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1267194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1268194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1269194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1270194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1271194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1272194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1273194d53e6SMatthew G. Knepley . t - current time 12742aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1275194d53e6SMatthew G. Knepley . x - coordinates of the current point 127697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 127797b6e6e8SMatthew G. Knepley . constants - constant parameters 1278194d53e6SMatthew G. Knepley - g0 - output values at the current point 1279194d53e6SMatthew G. Knepley 1280194d53e6SMatthew G. Knepley Level: intermediate 1281194d53e6SMatthew G. Knepley 1282194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1283194d53e6SMatthew G. Knepley @*/ 12842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 128530b9ff8bSMatthew G. Knepley void (*g0)(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 g0[]), 128930b9ff8bSMatthew G. Knepley void (*g1)(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 g1[]), 129330b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1294194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1295194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 129730b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1298194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1299194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 130097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 13012764a2aaSMatthew G. Knepley { 13022764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13032764a2aaSMatthew G. Knepley 13042764a2aaSMatthew G. Knepley PetscFunctionBegin; 13052764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13062764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 13072764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 13082764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 13092764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13102764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13112764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13122764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13132764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13142764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13152764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13162764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13182764a2aaSMatthew G. Knepley } 13192764a2aaSMatthew G. Knepley 1320475e0ac9SMatthew G. Knepley /*@C 132155c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 132255c1f793SMatthew G. Knepley 132355c1f793SMatthew G. Knepley Not collective 132455c1f793SMatthew G. Knepley 132555c1f793SMatthew G. Knepley Input Parameters: 132655c1f793SMatthew G. Knepley + prob - The PetscDS 132755c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 132855c1f793SMatthew G. Knepley 132955c1f793SMatthew G. Knepley Level: intermediate 133055c1f793SMatthew G. Knepley 133155c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 133255c1f793SMatthew G. Knepley @*/ 133355c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 133455c1f793SMatthew G. Knepley { 133555c1f793SMatthew G. Knepley PetscFunctionBegin; 133655c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 133755c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 133855c1f793SMatthew G. Knepley PetscFunctionReturn(0); 133955c1f793SMatthew G. Knepley } 134055c1f793SMatthew G. Knepley 134155c1f793SMatthew G. Knepley /*@C 1342475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1343475e0ac9SMatthew G. Knepley 1344475e0ac9SMatthew G. Knepley Not collective 1345475e0ac9SMatthew G. Knepley 1346475e0ac9SMatthew G. Knepley Input Parameter: 1347475e0ac9SMatthew G. Knepley . prob - The PetscDS 1348475e0ac9SMatthew G. Knepley 1349475e0ac9SMatthew G. Knepley Output Parameter: 1350475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1351475e0ac9SMatthew G. Knepley 1352475e0ac9SMatthew G. Knepley Level: intermediate 1353475e0ac9SMatthew G. Knepley 1354475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1355475e0ac9SMatthew G. Knepley @*/ 1356475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1357475e0ac9SMatthew G. Knepley { 1358475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1359475e0ac9SMatthew G. Knepley 1360475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1361475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1362475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 136355c1f793SMatthew G. Knepley if (!prob->useJacPre) PetscFunctionReturn(0); 1364475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1365475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1366475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1367475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1368475e0ac9SMatthew G. Knepley } 1369475e0ac9SMatthew G. Knepley } 1370475e0ac9SMatthew G. Knepley } 1371475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1372475e0ac9SMatthew G. Knepley } 1373475e0ac9SMatthew G. Knepley 1374475e0ac9SMatthew G. Knepley /*@C 1375475e0ac9SMatthew 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. 1376475e0ac9SMatthew G. Knepley 1377475e0ac9SMatthew G. Knepley Not collective 1378475e0ac9SMatthew G. Knepley 1379475e0ac9SMatthew G. Knepley Input Parameters: 1380475e0ac9SMatthew G. Knepley + prob - The PetscDS 1381475e0ac9SMatthew G. Knepley . f - The test field number 1382475e0ac9SMatthew G. Knepley - g - The field number 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew G. Knepley Output Parameters: 1385475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1386475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1387475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1388475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1389475e0ac9SMatthew G. Knepley 1390475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1391475e0ac9SMatthew G. Knepley 1392475e0ac9SMatthew 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 1393475e0ac9SMatthew G. Knepley 1394475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1395475e0ac9SMatthew G. Knepley 1396475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1397475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1398475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1399475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1400475e0ac9SMatthew G. Knepley 1401475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1402475e0ac9SMatthew G. Knepley . Nf - the number of fields 1403475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1404475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1405475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1406475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1407475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1408475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1409475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1410475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1411475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1412475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1413475e0ac9SMatthew G. Knepley . t - current time 1414475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1415475e0ac9SMatthew G. Knepley . x - coordinates of the current point 141697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 141797b6e6e8SMatthew G. Knepley . constants - constant parameters 1418475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1419475e0ac9SMatthew G. Knepley 1420475e0ac9SMatthew G. Knepley Level: intermediate 1421475e0ac9SMatthew G. Knepley 1422475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1423475e0ac9SMatthew G. Knepley @*/ 1424475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1425475e0ac9SMatthew G. Knepley void (**g0)(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 g0[]), 1429475e0ac9SMatthew G. Knepley void (**g1)(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 g1[]), 1433475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1434475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1435475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 143697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1437475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1438475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1439475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 144097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1441475e0ac9SMatthew G. Knepley { 1442475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1443475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1444475e0ac9SMatthew 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); 1445475e0ac9SMatthew 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); 1446475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1447475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1448475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1449475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1450475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1451475e0ac9SMatthew G. Knepley } 1452475e0ac9SMatthew G. Knepley 1453475e0ac9SMatthew G. Knepley /*@C 1454475e0ac9SMatthew 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. 1455475e0ac9SMatthew G. Knepley 1456475e0ac9SMatthew G. Knepley Not collective 1457475e0ac9SMatthew G. Knepley 1458475e0ac9SMatthew G. Knepley Input Parameters: 1459475e0ac9SMatthew G. Knepley + prob - The PetscDS 1460475e0ac9SMatthew G. Knepley . f - The test field number 1461475e0ac9SMatthew G. Knepley . g - The field number 1462475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1463475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1464475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1465475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1466475e0ac9SMatthew G. Knepley 1467475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1468475e0ac9SMatthew G. Knepley 1469475e0ac9SMatthew 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 1470475e0ac9SMatthew G. Knepley 1471475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1472475e0ac9SMatthew G. Knepley 1473475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1474475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1475475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1476475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1477475e0ac9SMatthew G. Knepley 1478475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1479475e0ac9SMatthew G. Knepley . Nf - the number of fields 1480475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1481475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1482475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1483475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1484475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1485475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1486475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1487475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1488475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1489475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1490475e0ac9SMatthew G. Knepley . t - current time 1491475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1492475e0ac9SMatthew G. Knepley . x - coordinates of the current point 149397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 149497b6e6e8SMatthew G. Knepley . constants - constant parameters 1495475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1496475e0ac9SMatthew G. Knepley 1497475e0ac9SMatthew G. Knepley Level: intermediate 1498475e0ac9SMatthew G. Knepley 1499475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1500475e0ac9SMatthew G. Knepley @*/ 1501475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1502475e0ac9SMatthew G. Knepley void (*g0)(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 g0[]), 1506475e0ac9SMatthew G. Knepley void (*g1)(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 g1[]), 1510475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1511475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1512475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 151397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1514475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1515475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1516475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 151797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1518475e0ac9SMatthew G. Knepley { 1519475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1520475e0ac9SMatthew G. Knepley 1521475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1522475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1523475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1524475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1525475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1526475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1527475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1528475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1529475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1530475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1531475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1532475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1533475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1534475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1535475e0ac9SMatthew G. Knepley } 1536475e0ac9SMatthew G. Knepley 1537b7e05686SMatthew G. Knepley /*@C 1538b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1539b7e05686SMatthew G. Knepley 1540b7e05686SMatthew G. Knepley Not collective 1541b7e05686SMatthew G. Knepley 1542b7e05686SMatthew G. Knepley Input Parameter: 1543b7e05686SMatthew G. Knepley . prob - The PetscDS 1544b7e05686SMatthew G. Knepley 1545b7e05686SMatthew G. Knepley Output Parameter: 1546b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1547b7e05686SMatthew G. Knepley 1548b7e05686SMatthew G. Knepley Level: intermediate 1549b7e05686SMatthew G. Knepley 1550b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1551b7e05686SMatthew G. Knepley @*/ 1552b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1553b7e05686SMatthew G. Knepley { 1554b7e05686SMatthew G. Knepley PetscInt f, g, h; 1555b7e05686SMatthew G. Knepley 1556b7e05686SMatthew G. Knepley PetscFunctionBegin; 1557b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1558b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1559b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1560b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1561b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1562b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1563b7e05686SMatthew G. Knepley } 1564b7e05686SMatthew G. Knepley } 1565b7e05686SMatthew G. Knepley } 1566b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1567b7e05686SMatthew G. Knepley } 1568b7e05686SMatthew G. Knepley 1569b7e05686SMatthew G. Knepley /*@C 1570b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1571b7e05686SMatthew G. Knepley 1572b7e05686SMatthew G. Knepley Not collective 1573b7e05686SMatthew G. Knepley 1574b7e05686SMatthew G. Knepley Input Parameters: 1575b7e05686SMatthew G. Knepley + prob - The PetscDS 1576b7e05686SMatthew G. Knepley . f - The test field number 1577b7e05686SMatthew G. Knepley - g - The field number 1578b7e05686SMatthew G. Knepley 1579b7e05686SMatthew G. Knepley Output Parameters: 1580b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1581b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1582b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1583b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1584b7e05686SMatthew G. Knepley 1585b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1586b7e05686SMatthew G. Knepley 1587b7e05686SMatthew 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 1588b7e05686SMatthew G. Knepley 1589b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1590b7e05686SMatthew G. Knepley 1591b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1592b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1593b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1594b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1595b7e05686SMatthew G. Knepley 1596b7e05686SMatthew G. Knepley + dim - the spatial dimension 1597b7e05686SMatthew G. Knepley . Nf - the number of fields 1598b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1599b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1600b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1601b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1602b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1603b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1604b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1605b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1606b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1607b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1608b7e05686SMatthew G. Knepley . t - current time 1609b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1610b7e05686SMatthew G. Knepley . x - coordinates of the current point 161197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 161297b6e6e8SMatthew G. Knepley . constants - constant parameters 1613b7e05686SMatthew G. Knepley - g0 - output values at the current point 1614b7e05686SMatthew G. Knepley 1615b7e05686SMatthew G. Knepley Level: intermediate 1616b7e05686SMatthew G. Knepley 1617b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1618b7e05686SMatthew G. Knepley @*/ 1619b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1620b7e05686SMatthew G. Knepley void (**g0)(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 g0[]), 1624b7e05686SMatthew G. Knepley void (**g1)(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 g1[]), 1628b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1629b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1630b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 163197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1632b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1633b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1634b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 163597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1636b7e05686SMatthew G. Knepley { 1637b7e05686SMatthew G. Knepley PetscFunctionBegin; 1638b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1639b7e05686SMatthew 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); 1640b7e05686SMatthew 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); 1641b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1642b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1643b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1644b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1645b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1646b7e05686SMatthew G. Knepley } 1647b7e05686SMatthew G. Knepley 1648b7e05686SMatthew G. Knepley /*@C 1649b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1650b7e05686SMatthew G. Knepley 1651b7e05686SMatthew G. Knepley Not collective 1652b7e05686SMatthew G. Knepley 1653b7e05686SMatthew G. Knepley Input Parameters: 1654b7e05686SMatthew G. Knepley + prob - The PetscDS 1655b7e05686SMatthew G. Knepley . f - The test field number 1656b7e05686SMatthew G. Knepley . g - The field number 1657b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1658b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1659b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1660b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1661b7e05686SMatthew G. Knepley 1662b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1663b7e05686SMatthew G. Knepley 1664b7e05686SMatthew 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 1665b7e05686SMatthew G. Knepley 1666b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1667b7e05686SMatthew G. Knepley 1668b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1669b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1670b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1671b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1672b7e05686SMatthew G. Knepley 1673b7e05686SMatthew G. Knepley + dim - the spatial dimension 1674b7e05686SMatthew G. Knepley . Nf - the number of fields 1675b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1676b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1677b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1678b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1679b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1680b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1681b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1682b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1683b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1684b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1685b7e05686SMatthew G. Knepley . t - current time 1686b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1687b7e05686SMatthew G. Knepley . x - coordinates of the current point 168897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 168997b6e6e8SMatthew G. Knepley . constants - constant parameters 1690b7e05686SMatthew G. Knepley - g0 - output values at the current point 1691b7e05686SMatthew G. Knepley 1692b7e05686SMatthew G. Knepley Level: intermediate 1693b7e05686SMatthew G. Knepley 1694b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1695b7e05686SMatthew G. Knepley @*/ 1696b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1697b7e05686SMatthew G. Knepley void (*g0)(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 g0[]), 1701b7e05686SMatthew G. Knepley void (*g1)(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 g1[]), 1705b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1706b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1707b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1709b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1710b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1711b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 171297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1713b7e05686SMatthew G. Knepley { 1714b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1715b7e05686SMatthew G. Knepley 1716b7e05686SMatthew G. Knepley PetscFunctionBegin; 1717b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1718b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1719b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1720b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1721b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1722b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1723b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1724b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1725b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1726b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1727b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1728b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1729b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1730b7e05686SMatthew G. Knepley } 1731b7e05686SMatthew G. Knepley 17320c2f2876SMatthew G. Knepley /*@C 17330c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17340c2f2876SMatthew G. Knepley 17350c2f2876SMatthew G. Knepley Not collective 17360c2f2876SMatthew G. Knepley 17370c2f2876SMatthew G. Knepley Input Arguments: 17380c2f2876SMatthew G. Knepley + prob - The PetscDS object 17390c2f2876SMatthew G. Knepley - f - The field number 17400c2f2876SMatthew G. Knepley 17410c2f2876SMatthew G. Knepley Output Argument: 17420c2f2876SMatthew G. Knepley . r - Riemann solver 17430c2f2876SMatthew G. Knepley 17440c2f2876SMatthew G. Knepley Calling sequence for r: 17450c2f2876SMatthew G. Knepley 17465db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17470c2f2876SMatthew G. Knepley 17485db36cf9SMatthew G. Knepley + dim - The spatial dimension 17495db36cf9SMatthew G. Knepley . Nf - The number of fields 17505db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17510c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17520c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17530c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17540c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 175597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 175697b6e6e8SMatthew G. Knepley . constants - constant parameters 17570c2f2876SMatthew G. Knepley - ctx - optional user context 17580c2f2876SMatthew G. Knepley 17590c2f2876SMatthew G. Knepley Level: intermediate 17600c2f2876SMatthew G. Knepley 17610c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17620c2f2876SMatthew G. Knepley @*/ 17630c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 176497b6e6e8SMatthew 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)) 17650c2f2876SMatthew G. Knepley { 17660c2f2876SMatthew G. Knepley PetscFunctionBegin; 17670c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17680c2f2876SMatthew 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); 17690c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17700c2f2876SMatthew G. Knepley *r = prob->r[f]; 17710c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17720c2f2876SMatthew G. Knepley } 17730c2f2876SMatthew G. Knepley 17740c2f2876SMatthew G. Knepley /*@C 17750c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17760c2f2876SMatthew G. Knepley 17770c2f2876SMatthew G. Knepley Not collective 17780c2f2876SMatthew G. Knepley 17790c2f2876SMatthew G. Knepley Input Arguments: 17800c2f2876SMatthew G. Knepley + prob - The PetscDS object 17810c2f2876SMatthew G. Knepley . f - The field number 17820c2f2876SMatthew G. Knepley - r - Riemann solver 17830c2f2876SMatthew G. Knepley 17840c2f2876SMatthew G. Knepley Calling sequence for r: 17850c2f2876SMatthew G. Knepley 17865db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17870c2f2876SMatthew G. Knepley 17885db36cf9SMatthew G. Knepley + dim - The spatial dimension 17895db36cf9SMatthew G. Knepley . Nf - The number of fields 17905db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17910c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17920c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17930c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17940c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 179597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 179697b6e6e8SMatthew G. Knepley . constants - constant parameters 17970c2f2876SMatthew G. Knepley - ctx - optional user context 17980c2f2876SMatthew G. Knepley 17990c2f2876SMatthew G. Knepley Level: intermediate 18000c2f2876SMatthew G. Knepley 18010c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 18020c2f2876SMatthew G. Knepley @*/ 18030c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 180497b6e6e8SMatthew 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)) 18050c2f2876SMatthew G. Knepley { 18060c2f2876SMatthew G. Knepley PetscErrorCode ierr; 18070c2f2876SMatthew G. Knepley 18080c2f2876SMatthew G. Knepley PetscFunctionBegin; 18090c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1810de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 18110c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18120c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18130c2f2876SMatthew G. Knepley prob->r[f] = r; 18140c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18150c2f2876SMatthew G. Knepley } 18160c2f2876SMatthew G. Knepley 181732d2bbc9SMatthew G. Knepley /*@C 181832d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 181932d2bbc9SMatthew G. Knepley 182032d2bbc9SMatthew G. Knepley Not collective 182132d2bbc9SMatthew G. Knepley 182232d2bbc9SMatthew G. Knepley Input Parameters: 182332d2bbc9SMatthew G. Knepley + prob - The PetscDS 182432d2bbc9SMatthew G. Knepley - f - The field number 182532d2bbc9SMatthew G. Knepley 182632d2bbc9SMatthew G. Knepley Output Parameters: 1827a2b725a8SWilliam Gropp . update - update function 182832d2bbc9SMatthew G. Knepley 182932d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 183032d2bbc9SMatthew G. Knepley 183132d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 183232d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 183332d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 183432d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 183532d2bbc9SMatthew G. Knepley 183632d2bbc9SMatthew G. Knepley + dim - the spatial dimension 183732d2bbc9SMatthew G. Knepley . Nf - the number of fields 183832d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 183932d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 184032d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 184132d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 184232d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 184332d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 184432d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 184532d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 184632d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 184732d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 184832d2bbc9SMatthew G. Knepley . t - current time 184932d2bbc9SMatthew G. Knepley . x - coordinates of the current point 185032d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 185132d2bbc9SMatthew G. Knepley 185232d2bbc9SMatthew G. Knepley Level: intermediate 185332d2bbc9SMatthew G. Knepley 185432d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 185532d2bbc9SMatthew G. Knepley @*/ 185632d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS prob, PetscInt f, 185732d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 185832d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 185932d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18603fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 186132d2bbc9SMatthew G. Knepley { 186232d2bbc9SMatthew G. Knepley PetscFunctionBegin; 186332d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 186432d2bbc9SMatthew 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); 186532d2bbc9SMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = prob->update[f];} 186632d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 186732d2bbc9SMatthew G. Knepley } 186832d2bbc9SMatthew G. Knepley 186932d2bbc9SMatthew G. Knepley /*@C 18703fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 187132d2bbc9SMatthew G. Knepley 187232d2bbc9SMatthew G. Knepley Not collective 187332d2bbc9SMatthew G. Knepley 187432d2bbc9SMatthew G. Knepley Input Parameters: 187532d2bbc9SMatthew G. Knepley + prob - The PetscDS 187632d2bbc9SMatthew G. Knepley . f - The field number 187732d2bbc9SMatthew G. Knepley - update - update function 187832d2bbc9SMatthew G. Knepley 187932d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 188032d2bbc9SMatthew G. Knepley 188132d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 188232d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 188332d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188432d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 188532d2bbc9SMatthew G. Knepley 188632d2bbc9SMatthew G. Knepley + dim - the spatial dimension 188732d2bbc9SMatthew G. Knepley . Nf - the number of fields 188832d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 188932d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 189032d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 189132d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 189232d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 189332d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 189432d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 189532d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 189632d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 189732d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 189832d2bbc9SMatthew G. Knepley . t - current time 189932d2bbc9SMatthew G. Knepley . x - coordinates of the current point 190032d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 190132d2bbc9SMatthew G. Knepley 190232d2bbc9SMatthew G. Knepley Level: intermediate 190332d2bbc9SMatthew G. Knepley 190432d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 190532d2bbc9SMatthew G. Knepley @*/ 190632d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS prob, PetscInt f, 190732d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 190832d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 190932d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19103fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 191132d2bbc9SMatthew G. Knepley { 191232d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 191332d2bbc9SMatthew G. Knepley 191432d2bbc9SMatthew G. Knepley PetscFunctionBegin; 191532d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 191632d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 191732d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 191832d2bbc9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 191932d2bbc9SMatthew G. Knepley prob->update[f] = update; 192032d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 192132d2bbc9SMatthew G. Knepley } 192232d2bbc9SMatthew G. Knepley 19230c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 19240c2f2876SMatthew G. Knepley { 19250c2f2876SMatthew G. Knepley PetscFunctionBegin; 19260c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19270c2f2876SMatthew 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); 19280c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 19290c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 19300c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19310c2f2876SMatthew G. Knepley } 19320c2f2876SMatthew G. Knepley 19330c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 19340c2f2876SMatthew G. Knepley { 19350c2f2876SMatthew G. Knepley PetscErrorCode ierr; 19360c2f2876SMatthew G. Knepley 19370c2f2876SMatthew G. Knepley PetscFunctionBegin; 19380c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19390c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19400c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19410c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 19420c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19430c2f2876SMatthew G. Knepley } 19440c2f2876SMatthew G. Knepley 1945194d53e6SMatthew G. Knepley /*@C 1946194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1947194d53e6SMatthew G. Knepley 1948194d53e6SMatthew G. Knepley Not collective 1949194d53e6SMatthew G. Knepley 1950194d53e6SMatthew G. Knepley Input Parameters: 1951194d53e6SMatthew G. Knepley + prob - The PetscDS 1952194d53e6SMatthew G. Knepley - f - The test field number 1953194d53e6SMatthew G. Knepley 1954194d53e6SMatthew G. Knepley Output Parameters: 1955194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1956194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1957194d53e6SMatthew G. Knepley 1958194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1959194d53e6SMatthew G. Knepley 1960194d53e6SMatthew 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 1961194d53e6SMatthew G. Knepley 1962194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1963194d53e6SMatthew G. Knepley 196430b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1965194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1966194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 196730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1968194d53e6SMatthew G. Knepley 1969194d53e6SMatthew G. Knepley + dim - the spatial dimension 1970194d53e6SMatthew G. Knepley . Nf - the number of fields 1971194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1972194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1973194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1974194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1975194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1976194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1977194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1978194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1979194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1980194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1981194d53e6SMatthew G. Knepley . t - current time 1982194d53e6SMatthew G. Knepley . x - coordinates of the current point 1983194d53e6SMatthew G. Knepley . n - unit normal at the current point 198497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 198597b6e6e8SMatthew G. Knepley . constants - constant parameters 1986194d53e6SMatthew G. Knepley - f0 - output values at the current point 1987194d53e6SMatthew G. Knepley 1988194d53e6SMatthew G. Knepley Level: intermediate 1989194d53e6SMatthew G. Knepley 1990194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1991194d53e6SMatthew G. Knepley @*/ 19922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 199330b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1994194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1995194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 199697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 199730b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1998194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1999194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 200097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20012764a2aaSMatthew G. Knepley { 20022764a2aaSMatthew G. Knepley PetscFunctionBegin; 20032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20042764a2aaSMatthew 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); 20052764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 20062764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 20072764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20082764a2aaSMatthew G. Knepley } 20092764a2aaSMatthew G. Knepley 2010194d53e6SMatthew G. Knepley /*@C 2011194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2012194d53e6SMatthew G. Knepley 2013194d53e6SMatthew G. Knepley Not collective 2014194d53e6SMatthew G. Knepley 2015194d53e6SMatthew G. Knepley Input Parameters: 2016194d53e6SMatthew G. Knepley + prob - The PetscDS 2017194d53e6SMatthew G. Knepley . f - The test field number 2018194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2019194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2020194d53e6SMatthew G. Knepley 2021194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2022194d53e6SMatthew G. Knepley 2023194d53e6SMatthew 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 2024194d53e6SMatthew G. Knepley 2025194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2026194d53e6SMatthew G. Knepley 202730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2028194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2029194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 203030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2031194d53e6SMatthew G. Knepley 2032194d53e6SMatthew G. Knepley + dim - the spatial dimension 2033194d53e6SMatthew G. Knepley . Nf - the number of fields 2034194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2035194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2036194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2037194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2038194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2039194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2040194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2041194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2042194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2043194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2044194d53e6SMatthew G. Knepley . t - current time 2045194d53e6SMatthew G. Knepley . x - coordinates of the current point 2046194d53e6SMatthew G. Knepley . n - unit normal at the current point 204797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 204897b6e6e8SMatthew G. Knepley . constants - constant parameters 2049194d53e6SMatthew G. Knepley - f0 - output values at the current point 2050194d53e6SMatthew G. Knepley 2051194d53e6SMatthew G. Knepley Level: intermediate 2052194d53e6SMatthew G. Knepley 2053194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2054194d53e6SMatthew G. Knepley @*/ 20552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 205630b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2057194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2058194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 205997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 206030b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2061194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2062194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 206397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20642764a2aaSMatthew G. Knepley { 20652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20662764a2aaSMatthew G. Knepley 20672764a2aaSMatthew G. Knepley PetscFunctionBegin; 20682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20692764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20702764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 20712764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 20722764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 20732764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20742764a2aaSMatthew G. Knepley } 20752764a2aaSMatthew G. Knepley 207627f02ce8SMatthew G. Knepley /*@ 207727f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 207827f02ce8SMatthew G. Knepley 207927f02ce8SMatthew G. Knepley Not collective 208027f02ce8SMatthew G. Knepley 208127f02ce8SMatthew G. Knepley Input Parameter: 208227f02ce8SMatthew G. Knepley . prob - The PetscDS 208327f02ce8SMatthew G. Knepley 208427f02ce8SMatthew G. Knepley Output Parameter: 208527f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 208627f02ce8SMatthew G. Knepley 208727f02ce8SMatthew G. Knepley Level: intermediate 208827f02ce8SMatthew G. Knepley 208927f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 209027f02ce8SMatthew G. Knepley @*/ 209127f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS prob, PetscBool *hasBdJac) 209227f02ce8SMatthew G. Knepley { 209327f02ce8SMatthew G. Knepley PetscInt f, g, h; 209427f02ce8SMatthew G. Knepley 209527f02ce8SMatthew G. Knepley PetscFunctionBegin; 209627f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 209727f02ce8SMatthew G. Knepley *hasBdJac = PETSC_FALSE; 209827f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 209927f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 210027f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 210127f02ce8SMatthew G. Knepley if (prob->gBd[(f*prob->Nf + g)*4+h]) *hasBdJac = PETSC_TRUE; 210227f02ce8SMatthew G. Knepley } 210327f02ce8SMatthew G. Knepley } 210427f02ce8SMatthew G. Knepley } 210527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 210627f02ce8SMatthew G. Knepley } 210727f02ce8SMatthew G. Knepley 2108194d53e6SMatthew G. Knepley /*@C 2109194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2110194d53e6SMatthew G. Knepley 2111194d53e6SMatthew G. Knepley Not collective 2112194d53e6SMatthew G. Knepley 2113194d53e6SMatthew G. Knepley Input Parameters: 2114194d53e6SMatthew G. Knepley + prob - The PetscDS 2115194d53e6SMatthew G. Knepley . f - The test field number 2116194d53e6SMatthew G. Knepley - g - The field number 2117194d53e6SMatthew G. Knepley 2118194d53e6SMatthew G. Knepley Output Parameters: 2119194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2120194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2121194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2122194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2123194d53e6SMatthew G. Knepley 2124194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2125194d53e6SMatthew G. Knepley 2126194d53e6SMatthew 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 2127194d53e6SMatthew G. Knepley 2128194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2129194d53e6SMatthew G. Knepley 213030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2131194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2132194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 213330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2134194d53e6SMatthew G. Knepley 2135194d53e6SMatthew G. Knepley + dim - the spatial dimension 2136194d53e6SMatthew G. Knepley . Nf - the number of fields 2137194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2138194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2139194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2140194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2141194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2142194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2143194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2144194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2145194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2146194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2147194d53e6SMatthew G. Knepley . t - current time 21482aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2149194d53e6SMatthew G. Knepley . x - coordinates of the current point 2150194d53e6SMatthew G. Knepley . n - normal at the current point 215197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 215297b6e6e8SMatthew G. Knepley . constants - constant parameters 2153194d53e6SMatthew G. Knepley - g0 - output values at the current point 2154194d53e6SMatthew G. Knepley 2155194d53e6SMatthew G. Knepley Level: intermediate 2156194d53e6SMatthew G. Knepley 2157194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2158194d53e6SMatthew G. Knepley @*/ 21592764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 216030b9ff8bSMatthew G. Knepley void (**g0)(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 g0[]), 216430b9ff8bSMatthew G. Knepley void (**g1)(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 g1[]), 216830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2169194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2170194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 217197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 217230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2173194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2174194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 217597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 21762764a2aaSMatthew G. Knepley { 21772764a2aaSMatthew G. Knepley PetscFunctionBegin; 21782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21792764a2aaSMatthew 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); 21802764a2aaSMatthew 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); 21812764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 21822764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 21832764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 21842764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 21852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21862764a2aaSMatthew G. Knepley } 21872764a2aaSMatthew G. Knepley 2188194d53e6SMatthew G. Knepley /*@C 2189194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2190194d53e6SMatthew G. Knepley 2191194d53e6SMatthew G. Knepley Not collective 2192194d53e6SMatthew G. Knepley 2193194d53e6SMatthew G. Knepley Input Parameters: 2194194d53e6SMatthew G. Knepley + prob - The PetscDS 2195194d53e6SMatthew G. Knepley . f - The test field number 2196194d53e6SMatthew G. Knepley . g - The field number 2197194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2198194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2199194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2200194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2201194d53e6SMatthew G. Knepley 2202194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2203194d53e6SMatthew G. Knepley 2204194d53e6SMatthew 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 2205194d53e6SMatthew G. Knepley 2206194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2207194d53e6SMatthew G. Knepley 220830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2209194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2210194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 221130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2212194d53e6SMatthew G. Knepley 2213194d53e6SMatthew G. Knepley + dim - the spatial dimension 2214194d53e6SMatthew G. Knepley . Nf - the number of fields 2215194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2216194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2217194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2218194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2219194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2220194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2221194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2222194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2223194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2224194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2225194d53e6SMatthew G. Knepley . t - current time 22262aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2227194d53e6SMatthew G. Knepley . x - coordinates of the current point 2228194d53e6SMatthew G. Knepley . n - normal at the current point 222997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 223097b6e6e8SMatthew G. Knepley . constants - constant parameters 2231194d53e6SMatthew G. Knepley - g0 - output values at the current point 2232194d53e6SMatthew G. Knepley 2233194d53e6SMatthew G. Knepley Level: intermediate 2234194d53e6SMatthew G. Knepley 2235194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2236194d53e6SMatthew G. Knepley @*/ 22372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 223830b9ff8bSMatthew G. Knepley void (*g0)(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 g0[]), 224230b9ff8bSMatthew G. Knepley void (*g1)(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 g1[]), 224630b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2247194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2248194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 225030b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2251194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2252194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 225397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22542764a2aaSMatthew G. Knepley { 22552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22562764a2aaSMatthew G. Knepley 22572764a2aaSMatthew G. Knepley PetscFunctionBegin; 22582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22592764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 22602764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 22612764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 22622764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 22632764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 22642764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 22652764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 22662764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 22672764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 22682764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 22692764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 22702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22712764a2aaSMatthew G. Knepley } 22722764a2aaSMatthew G. Knepley 227327f02ce8SMatthew G. Knepley /*@ 227427f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 227527f02ce8SMatthew G. Knepley 227627f02ce8SMatthew G. Knepley Not collective 227727f02ce8SMatthew G. Knepley 227827f02ce8SMatthew G. Knepley Input Parameter: 227927f02ce8SMatthew G. Knepley . prob - The PetscDS 228027f02ce8SMatthew G. Knepley 228127f02ce8SMatthew G. Knepley Output Parameter: 228227f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 228327f02ce8SMatthew G. Knepley 228427f02ce8SMatthew G. Knepley Level: intermediate 228527f02ce8SMatthew G. Knepley 228627f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 228727f02ce8SMatthew G. Knepley @*/ 228827f02ce8SMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS prob, PetscBool *hasBdJacPre) 228927f02ce8SMatthew G. Knepley { 229027f02ce8SMatthew G. Knepley PetscInt f, g, h; 229127f02ce8SMatthew G. Knepley 229227f02ce8SMatthew G. Knepley PetscFunctionBegin; 229327f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 229427f02ce8SMatthew G. Knepley *hasBdJacPre = PETSC_FALSE; 229527f02ce8SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 229627f02ce8SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 229727f02ce8SMatthew G. Knepley for (h = 0; h < 4; ++h) { 229827f02ce8SMatthew G. Knepley if (prob->gpBd[(f*prob->Nf + g)*4+h]) *hasBdJacPre = PETSC_TRUE; 229927f02ce8SMatthew G. Knepley } 230027f02ce8SMatthew G. Knepley } 230127f02ce8SMatthew G. Knepley } 230227f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 230327f02ce8SMatthew G. Knepley } 230427f02ce8SMatthew G. Knepley 230527f02ce8SMatthew G. Knepley /*@C 230627f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 230727f02ce8SMatthew G. Knepley 230827f02ce8SMatthew G. Knepley Not collective 230927f02ce8SMatthew G. Knepley 231027f02ce8SMatthew G. Knepley Input Parameters: 231127f02ce8SMatthew G. Knepley + prob - The PetscDS 231227f02ce8SMatthew G. Knepley . f - The test field number 231327f02ce8SMatthew G. Knepley - g - The field number 231427f02ce8SMatthew G. Knepley 231527f02ce8SMatthew G. Knepley Output Parameters: 231627f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 231727f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 231827f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 231927f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 232027f02ce8SMatthew G. Knepley 232127f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 232227f02ce8SMatthew G. Knepley 232327f02ce8SMatthew 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 232427f02ce8SMatthew G. Knepley 232527f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 232627f02ce8SMatthew G. Knepley 232727f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 232827f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 232927f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 233027f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 233127f02ce8SMatthew G. Knepley 233227f02ce8SMatthew G. Knepley + dim - the spatial dimension 233327f02ce8SMatthew G. Knepley . Nf - the number of fields 233427f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 233527f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 233627f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 233727f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 233827f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 233927f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 234027f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 234127f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 234227f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 234327f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 234427f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 234527f02ce8SMatthew G. Knepley . t - current time 234627f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 234727f02ce8SMatthew G. Knepley . x - coordinates of the current point 234827f02ce8SMatthew G. Knepley . n - normal at the current point 234927f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 235027f02ce8SMatthew G. Knepley . constants - constant parameters 235127f02ce8SMatthew G. Knepley - g0 - output values at the current point 235227f02ce8SMatthew G. Knepley 235327f02ce8SMatthew G. Knepley This is not yet available in Fortran. 235427f02ce8SMatthew G. Knepley 235527f02ce8SMatthew G. Knepley Level: intermediate 235627f02ce8SMatthew G. Knepley 235727f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 235827f02ce8SMatthew G. Knepley @*/ 235927f02ce8SMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 236027f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 236127f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 236227f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236327f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 236427f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 236527f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 236627f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236727f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 236827f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 236927f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 237027f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 237127f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 237227f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 237327f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 237427f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 237527f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 237627f02ce8SMatthew G. Knepley { 237727f02ce8SMatthew G. Knepley PetscFunctionBegin; 237827f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 237927f02ce8SMatthew 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); 238027f02ce8SMatthew 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); 238127f02ce8SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gpBd[(f*prob->Nf + g)*4+0];} 238227f02ce8SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gpBd[(f*prob->Nf + g)*4+1];} 238327f02ce8SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gpBd[(f*prob->Nf + g)*4+2];} 238427f02ce8SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gpBd[(f*prob->Nf + g)*4+3];} 238527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 238627f02ce8SMatthew G. Knepley } 238727f02ce8SMatthew G. Knepley 238827f02ce8SMatthew G. Knepley /*@C 238927f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 239027f02ce8SMatthew G. Knepley 239127f02ce8SMatthew G. Knepley Not collective 239227f02ce8SMatthew G. Knepley 239327f02ce8SMatthew G. Knepley Input Parameters: 239427f02ce8SMatthew G. Knepley + prob - The PetscDS 239527f02ce8SMatthew G. Knepley . f - The test field number 239627f02ce8SMatthew G. Knepley . g - The field number 239727f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 239827f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 239927f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 240027f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 240127f02ce8SMatthew G. Knepley 240227f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 240327f02ce8SMatthew G. Knepley 240427f02ce8SMatthew 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 240527f02ce8SMatthew G. Knepley 240627f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 240727f02ce8SMatthew G. Knepley 240827f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 240927f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 241027f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 241127f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 241227f02ce8SMatthew G. Knepley 241327f02ce8SMatthew G. Knepley + dim - the spatial dimension 241427f02ce8SMatthew G. Knepley . Nf - the number of fields 241527f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 241627f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 241727f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 241827f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 241927f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 242027f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 242127f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 242227f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 242327f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 242427f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 242527f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 242627f02ce8SMatthew G. Knepley . t - current time 242727f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 242827f02ce8SMatthew G. Knepley . x - coordinates of the current point 242927f02ce8SMatthew G. Knepley . n - normal at the current point 243027f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 243127f02ce8SMatthew G. Knepley . constants - constant parameters 243227f02ce8SMatthew G. Knepley - g0 - output values at the current point 243327f02ce8SMatthew G. Knepley 243427f02ce8SMatthew G. Knepley This is not yet available in Fortran. 243527f02ce8SMatthew G. Knepley 243627f02ce8SMatthew G. Knepley Level: intermediate 243727f02ce8SMatthew G. Knepley 243827f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 243927f02ce8SMatthew G. Knepley @*/ 244027f02ce8SMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 244127f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 244227f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 244327f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 244427f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 244527f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 244627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 244727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 244827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 244927f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 245027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 245127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 245227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 245327f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 245427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 245527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 245627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 245727f02ce8SMatthew G. Knepley { 245827f02ce8SMatthew G. Knepley PetscErrorCode ierr; 245927f02ce8SMatthew G. Knepley 246027f02ce8SMatthew G. Knepley PetscFunctionBegin; 246127f02ce8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 246227f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 246327f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 246427f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 246527f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 246627f02ce8SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 246727f02ce8SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 246827f02ce8SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 246927f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+0] = g0; 247027f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+1] = g1; 247127f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+2] = g2; 247227f02ce8SMatthew G. Knepley prob->gpBd[(f*prob->Nf + g)*4+3] = g3; 247327f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 247427f02ce8SMatthew G. Knepley } 247527f02ce8SMatthew G. Knepley 24760d3e9b51SMatthew G. Knepley /*@C 2477c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2478c371a6d1SMatthew G. Knepley 2479c371a6d1SMatthew G. Knepley Not collective 2480c371a6d1SMatthew G. Knepley 2481c371a6d1SMatthew G. Knepley Input Parameters: 2482c371a6d1SMatthew G. Knepley + prob - The PetscDS 2483c371a6d1SMatthew G. Knepley - f - The test field number 2484c371a6d1SMatthew G. Knepley 2485c371a6d1SMatthew G. Knepley Output Parameter: 248695cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 248795cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2488c371a6d1SMatthew G. Knepley 2489c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2490c371a6d1SMatthew G. Knepley 2491c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2492c371a6d1SMatthew G. Knepley 2493c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2494c371a6d1SMatthew G. Knepley . t - current time 2495c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2496c371a6d1SMatthew G. Knepley . Nc - the number of field components 2497c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2498c371a6d1SMatthew G. Knepley - ctx - a user context 2499c371a6d1SMatthew G. Knepley 2500c371a6d1SMatthew G. Knepley Level: intermediate 2501c371a6d1SMatthew G. Knepley 2502c371a6d1SMatthew G. Knepley .seealso: PetscDSSetExactSolution() 2503c371a6d1SMatthew G. Knepley @*/ 250495cbbfd3SMatthew 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) 2505c371a6d1SMatthew G. Knepley { 2506c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2507c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2508c371a6d1SMatthew 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); 2509c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 251095cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2511c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2512c371a6d1SMatthew G. Knepley } 2513c371a6d1SMatthew G. Knepley 2514c371a6d1SMatthew G. Knepley /*@C 2515578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2516c371a6d1SMatthew G. Knepley 2517c371a6d1SMatthew G. Knepley Not collective 2518c371a6d1SMatthew G. Knepley 2519c371a6d1SMatthew G. Knepley Input Parameters: 2520c371a6d1SMatthew G. Knepley + prob - The PetscDS 2521c371a6d1SMatthew G. Knepley . f - The test field number 252295cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 252395cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2524c371a6d1SMatthew G. Knepley 2525c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2526c371a6d1SMatthew G. Knepley 2527c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2528c371a6d1SMatthew G. Knepley 2529c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2530c371a6d1SMatthew G. Knepley . t - current time 2531c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2532c371a6d1SMatthew G. Knepley . Nc - the number of field components 2533c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2534c371a6d1SMatthew G. Knepley - ctx - a user context 2535c371a6d1SMatthew G. Knepley 2536c371a6d1SMatthew G. Knepley Level: intermediate 2537c371a6d1SMatthew G. Knepley 2538c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2539c371a6d1SMatthew G. Knepley @*/ 254095cbbfd3SMatthew 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) 2541c371a6d1SMatthew G. Knepley { 2542c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2543c371a6d1SMatthew G. Knepley 2544c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2545c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2546c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2547c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2548c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 254995cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2550c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2551c371a6d1SMatthew G. Knepley } 2552c371a6d1SMatthew G. Knepley 25535638fd0eSMatthew G. Knepley /*@C 255497b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 255597b6e6e8SMatthew G. Knepley 255697b6e6e8SMatthew G. Knepley Not collective 255797b6e6e8SMatthew G. Knepley 255897b6e6e8SMatthew G. Knepley Input Parameter: 255997b6e6e8SMatthew G. Knepley . prob - The PetscDS object 256097b6e6e8SMatthew G. Knepley 256197b6e6e8SMatthew G. Knepley Output Parameters: 256297b6e6e8SMatthew G. Knepley + numConstants - The number of constants 256397b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 256497b6e6e8SMatthew G. Knepley 256597b6e6e8SMatthew G. Knepley Level: intermediate 256697b6e6e8SMatthew G. Knepley 256797b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 256897b6e6e8SMatthew G. Knepley @*/ 256997b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 257097b6e6e8SMatthew G. Knepley { 257197b6e6e8SMatthew G. Knepley PetscFunctionBegin; 257297b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 257397b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 257497b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 257597b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 257697b6e6e8SMatthew G. Knepley } 257797b6e6e8SMatthew G. Knepley 25780d3e9b51SMatthew G. Knepley /*@C 257997b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 258097b6e6e8SMatthew G. Knepley 258197b6e6e8SMatthew G. Knepley Not collective 258297b6e6e8SMatthew G. Knepley 258397b6e6e8SMatthew G. Knepley Input Parameters: 258497b6e6e8SMatthew G. Knepley + prob - The PetscDS object 258597b6e6e8SMatthew G. Knepley . numConstants - The number of constants 258697b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 258797b6e6e8SMatthew G. Knepley 258897b6e6e8SMatthew G. Knepley Level: intermediate 258997b6e6e8SMatthew G. Knepley 259097b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 259197b6e6e8SMatthew G. Knepley @*/ 259297b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 259397b6e6e8SMatthew G. Knepley { 259497b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 259597b6e6e8SMatthew G. Knepley 259697b6e6e8SMatthew G. Knepley PetscFunctionBegin; 259797b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 259897b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 259997b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 260097b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 260197b6e6e8SMatthew G. Knepley if (prob->numConstants) { 260297b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 260320be0f5bSMatthew G. Knepley } else { 260420be0f5bSMatthew G. Knepley prob->constants = NULL; 260520be0f5bSMatthew G. Knepley } 260620be0f5bSMatthew G. Knepley } 260720be0f5bSMatthew G. Knepley if (prob->numConstants) { 260820be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 2609580bdb30SBarry Smith ierr = PetscArraycpy(prob->constants, constants, prob->numConstants);CHKERRQ(ierr); 261097b6e6e8SMatthew G. Knepley } 261197b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 261297b6e6e8SMatthew G. Knepley } 261397b6e6e8SMatthew G. Knepley 26144cd1e086SMatthew G. Knepley /*@ 26154cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 26164cd1e086SMatthew G. Knepley 26174cd1e086SMatthew G. Knepley Not collective 26184cd1e086SMatthew G. Knepley 26194cd1e086SMatthew G. Knepley Input Parameters: 26204cd1e086SMatthew G. Knepley + prob - The PetscDS object 26214cd1e086SMatthew G. Knepley - disc - The discretization object 26224cd1e086SMatthew G. Knepley 26234cd1e086SMatthew G. Knepley Output Parameter: 26244cd1e086SMatthew G. Knepley . f - The field number 26254cd1e086SMatthew G. Knepley 26264cd1e086SMatthew G. Knepley Level: beginner 26274cd1e086SMatthew G. Knepley 2628f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 26294cd1e086SMatthew G. Knepley @*/ 26304cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 26314cd1e086SMatthew G. Knepley { 26324cd1e086SMatthew G. Knepley PetscInt g; 26334cd1e086SMatthew G. Knepley 26344cd1e086SMatthew G. Knepley PetscFunctionBegin; 26354cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26364cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 26374cd1e086SMatthew G. Knepley *f = -1; 26384cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 26394cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 26404cd1e086SMatthew G. Knepley *f = g; 26414cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 26424cd1e086SMatthew G. Knepley } 26434cd1e086SMatthew G. Knepley 26444cd1e086SMatthew G. Knepley /*@ 26454cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 26464cd1e086SMatthew G. Knepley 26474cd1e086SMatthew G. Knepley Not collective 26484cd1e086SMatthew G. Knepley 26494cd1e086SMatthew G. Knepley Input Parameters: 26504cd1e086SMatthew G. Knepley + prob - The PetscDS object 26514cd1e086SMatthew G. Knepley - f - The field number 26524cd1e086SMatthew G. Knepley 26534cd1e086SMatthew G. Knepley Output Parameter: 26544cd1e086SMatthew G. Knepley . size - The size 26554cd1e086SMatthew G. Knepley 26564cd1e086SMatthew G. Knepley Level: beginner 26574cd1e086SMatthew G. Knepley 2658f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 26594cd1e086SMatthew G. Knepley @*/ 26604cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 26614cd1e086SMatthew G. Knepley { 26622166fd64SMatthew G. Knepley PetscErrorCode ierr; 26632166fd64SMatthew G. Knepley 26644cd1e086SMatthew G. Knepley PetscFunctionBegin; 26654cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26664cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 26674cd1e086SMatthew 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); 26682166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2669d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 26704cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 26714cd1e086SMatthew G. Knepley } 26724cd1e086SMatthew G. Knepley 2673bc4ae4beSMatthew G. Knepley /*@ 2674bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2675bc4ae4beSMatthew G. Knepley 2676bc4ae4beSMatthew G. Knepley Not collective 2677bc4ae4beSMatthew G. Knepley 2678bc4ae4beSMatthew G. Knepley Input Parameters: 2679bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2680bc4ae4beSMatthew G. Knepley - f - The field number 2681bc4ae4beSMatthew G. Knepley 2682bc4ae4beSMatthew G. Knepley Output Parameter: 2683bc4ae4beSMatthew G. Knepley . off - The offset 2684bc4ae4beSMatthew G. Knepley 2685bc4ae4beSMatthew G. Knepley Level: beginner 2686bc4ae4beSMatthew G. Knepley 2687f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2688bc4ae4beSMatthew G. Knepley @*/ 26892764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 26902764a2aaSMatthew G. Knepley { 26914cd1e086SMatthew G. Knepley PetscInt size, g; 26922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26932764a2aaSMatthew G. Knepley 26942764a2aaSMatthew G. Knepley PetscFunctionBegin; 26952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26962764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 26972764a2aaSMatthew 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); 26982764a2aaSMatthew G. Knepley *off = 0; 26992764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 27004cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 27014cd1e086SMatthew G. Knepley *off += size; 27022764a2aaSMatthew G. Knepley } 27032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27042764a2aaSMatthew G. Knepley } 27052764a2aaSMatthew G. Knepley 2706bc4ae4beSMatthew G. Knepley /*@ 270747e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2708bc4ae4beSMatthew G. Knepley 2709bc4ae4beSMatthew G. Knepley Not collective 2710bc4ae4beSMatthew G. Knepley 271147e57110SSander Arens Input Parameter: 271247e57110SSander Arens . prob - The PetscDS object 2713bc4ae4beSMatthew G. Knepley 2714bc4ae4beSMatthew G. Knepley Output Parameter: 271547e57110SSander Arens . dimensions - The number of dimensions 2716bc4ae4beSMatthew G. Knepley 2717bc4ae4beSMatthew G. Knepley Level: beginner 2718bc4ae4beSMatthew G. Knepley 271947e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2720bc4ae4beSMatthew G. Knepley @*/ 272147e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 27222764a2aaSMatthew G. Knepley { 27232764a2aaSMatthew G. Knepley PetscErrorCode ierr; 27242764a2aaSMatthew G. Knepley 27252764a2aaSMatthew G. Knepley PetscFunctionBegin; 27262764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 272747e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 272847e57110SSander Arens PetscValidPointer(dimensions, 2); 272947e57110SSander Arens *dimensions = prob->Nb; 273047e57110SSander Arens PetscFunctionReturn(0); 27316ce16762SMatthew G. Knepley } 273247e57110SSander Arens 273347e57110SSander Arens /*@ 273447e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 273547e57110SSander Arens 273647e57110SSander Arens Not collective 273747e57110SSander Arens 273847e57110SSander Arens Input Parameter: 273947e57110SSander Arens . prob - The PetscDS object 274047e57110SSander Arens 274147e57110SSander Arens Output Parameter: 274247e57110SSander Arens . components - The number of components 274347e57110SSander Arens 274447e57110SSander Arens Level: beginner 274547e57110SSander Arens 274647e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 274747e57110SSander Arens @*/ 274847e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 274947e57110SSander Arens { 275047e57110SSander Arens PetscErrorCode ierr; 275147e57110SSander Arens 275247e57110SSander Arens PetscFunctionBegin; 275347e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 275447e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 275547e57110SSander Arens PetscValidPointer(components, 2); 275647e57110SSander Arens *components = prob->Nc; 27576ce16762SMatthew G. Knepley PetscFunctionReturn(0); 27586ce16762SMatthew G. Knepley } 27596ce16762SMatthew G. Knepley 27606ce16762SMatthew G. Knepley /*@ 27616ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 27626ce16762SMatthew G. Knepley 27636ce16762SMatthew G. Knepley Not collective 27646ce16762SMatthew G. Knepley 27656ce16762SMatthew G. Knepley Input Parameters: 27666ce16762SMatthew G. Knepley + prob - The PetscDS object 27676ce16762SMatthew G. Knepley - f - The field number 27686ce16762SMatthew G. Knepley 27696ce16762SMatthew G. Knepley Output Parameter: 27706ce16762SMatthew G. Knepley . off - The offset 27716ce16762SMatthew G. Knepley 27726ce16762SMatthew G. Knepley Level: beginner 27736ce16762SMatthew G. Knepley 2774f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 27756ce16762SMatthew G. Knepley @*/ 27766ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 27776ce16762SMatthew G. Knepley { 27786ce16762SMatthew G. Knepley PetscFunctionBegin; 27796ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 27806ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 27816ce16762SMatthew 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); 278247e57110SSander Arens *off = prob->off[f]; 27832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27842764a2aaSMatthew G. Knepley } 27852764a2aaSMatthew G. Knepley 2786194d53e6SMatthew G. Knepley /*@ 2787194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2788194d53e6SMatthew G. Knepley 2789194d53e6SMatthew G. Knepley Not collective 2790194d53e6SMatthew G. Knepley 2791194d53e6SMatthew G. Knepley Input Parameter: 2792194d53e6SMatthew G. Knepley . prob - The PetscDS object 2793194d53e6SMatthew G. Knepley 2794194d53e6SMatthew G. Knepley Output Parameter: 2795194d53e6SMatthew G. Knepley . offsets - The offsets 2796194d53e6SMatthew G. Knepley 2797194d53e6SMatthew G. Knepley Level: beginner 2798194d53e6SMatthew G. Knepley 2799f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2800194d53e6SMatthew G. Knepley @*/ 2801194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2802194d53e6SMatthew G. Knepley { 2803194d53e6SMatthew G. Knepley PetscFunctionBegin; 2804194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2805194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2806194d53e6SMatthew G. Knepley *offsets = prob->off; 2807194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2808194d53e6SMatthew G. Knepley } 2809194d53e6SMatthew G. Knepley 2810194d53e6SMatthew G. Knepley /*@ 2811194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2812194d53e6SMatthew G. Knepley 2813194d53e6SMatthew G. Knepley Not collective 2814194d53e6SMatthew G. Knepley 2815194d53e6SMatthew G. Knepley Input Parameter: 2816194d53e6SMatthew G. Knepley . prob - The PetscDS object 2817194d53e6SMatthew G. Knepley 2818194d53e6SMatthew G. Knepley Output Parameter: 2819194d53e6SMatthew G. Knepley . offsets - The offsets 2820194d53e6SMatthew G. Knepley 2821194d53e6SMatthew G. Knepley Level: beginner 2822194d53e6SMatthew G. Knepley 2823f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2824194d53e6SMatthew G. Knepley @*/ 2825194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2826194d53e6SMatthew G. Knepley { 2827194d53e6SMatthew G. Knepley PetscFunctionBegin; 2828194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2829194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2830194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2831194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2832194d53e6SMatthew G. Knepley } 2833194d53e6SMatthew G. Knepley 283468c9edb9SMatthew G. Knepley /*@C 283568c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 283668c9edb9SMatthew G. Knepley 283768c9edb9SMatthew G. Knepley Not collective 283868c9edb9SMatthew G. Knepley 283968c9edb9SMatthew G. Knepley Input Parameter: 284068c9edb9SMatthew G. Knepley . prob - The PetscDS object 284168c9edb9SMatthew G. Knepley 2842ef0bb6c7SMatthew G. Knepley Output Parameter: 2843ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 284468c9edb9SMatthew G. Knepley 284568c9edb9SMatthew G. Knepley Level: intermediate 284668c9edb9SMatthew G. Knepley 2847f744cafaSSander Arens .seealso: PetscDSCreate() 284868c9edb9SMatthew G. Knepley @*/ 2849ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 28502764a2aaSMatthew G. Knepley { 28512764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28522764a2aaSMatthew G. Knepley 28532764a2aaSMatthew G. Knepley PetscFunctionBegin; 28542764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2855ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 28562764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2857ef0bb6c7SMatthew G. Knepley *T = prob->T; 28582764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28592764a2aaSMatthew G. Knepley } 28602764a2aaSMatthew G. Knepley 286168c9edb9SMatthew G. Knepley /*@C 28624d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 286368c9edb9SMatthew G. Knepley 286468c9edb9SMatthew G. Knepley Not collective 286568c9edb9SMatthew G. Knepley 286668c9edb9SMatthew G. Knepley Input Parameter: 286768c9edb9SMatthew G. Knepley . prob - The PetscDS object 286868c9edb9SMatthew G. Knepley 2869ef0bb6c7SMatthew G. Knepley Output Parameter: 2870ef0bb6c7SMatthew G. Knepley . Tf - The basis function and derviative tabulation on each lcoal face at quadrature points for each and field 287168c9edb9SMatthew G. Knepley 287268c9edb9SMatthew G. Knepley Level: intermediate 287368c9edb9SMatthew G. Knepley 287468c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 287568c9edb9SMatthew G. Knepley @*/ 2876ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 28772764a2aaSMatthew G. Knepley { 28782764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28792764a2aaSMatthew G. Knepley 28802764a2aaSMatthew G. Knepley PetscFunctionBegin; 28812764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2882ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 28832764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2884ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 28852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28862764a2aaSMatthew G. Knepley } 28872764a2aaSMatthew G. Knepley 28882764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 28892764a2aaSMatthew G. Knepley { 28902764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28912764a2aaSMatthew G. Knepley 28922764a2aaSMatthew G. Knepley PetscFunctionBegin; 28932764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28942764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 28952764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 28962764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 28972764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 28982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28992764a2aaSMatthew G. Knepley } 29002764a2aaSMatthew G. Knepley 29012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 29022764a2aaSMatthew G. Knepley { 29032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29042764a2aaSMatthew G. Knepley 29052764a2aaSMatthew G. Knepley PetscFunctionBegin; 29062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29072764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 29082764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 29092764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 29102764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 29112764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 29122764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 29132764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 29142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29152764a2aaSMatthew G. Knepley } 29162764a2aaSMatthew G. Knepley 29174bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 29182764a2aaSMatthew G. Knepley { 29192764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29202764a2aaSMatthew G. Knepley 29212764a2aaSMatthew G. Knepley PetscFunctionBegin; 29222764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29232764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 29242764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 29254bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 29267506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 29277506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 29287506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 29292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29302764a2aaSMatthew G. Knepley } 29312764a2aaSMatthew G. Knepley 293258ebd649SToby Isaac /*@C 293358ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 293458ebd649SToby Isaac 2935783e2ec8SMatthew G. Knepley Collective on ds 2936783e2ec8SMatthew G. Knepley 293758ebd649SToby Isaac Input Parameters: 293858ebd649SToby Isaac + ds - The PetscDS object 29392d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 294058ebd649SToby Isaac . name - The BC name 294158ebd649SToby Isaac . labelname - The label defining constrained points 294258ebd649SToby Isaac . field - The field to constrain 2943e8ecbf3fSStefano Zampini . numcomps - The number of constrained field components (0 will constrain all fields) 294458ebd649SToby Isaac . comps - An array of constrained component numbers 294558ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 294658ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 294758ebd649SToby Isaac . ids - An array of ids for constrained points 294858ebd649SToby Isaac - ctx - An optional user context for bcFunc 294958ebd649SToby Isaac 295058ebd649SToby Isaac Options Database Keys: 295158ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 295258ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 295358ebd649SToby Isaac 295458ebd649SToby Isaac Level: developer 295558ebd649SToby Isaac 295658ebd649SToby Isaac .seealso: PetscDSGetBoundary() 295758ebd649SToby Isaac @*/ 2958a30ec4eaSSatish 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) 295958ebd649SToby Isaac { 296058ebd649SToby Isaac DSBoundary b; 296158ebd649SToby Isaac PetscErrorCode ierr; 296258ebd649SToby Isaac 296358ebd649SToby Isaac PetscFunctionBegin; 296458ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2965783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 2966783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 5); 2967783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numcomps, 6); 2968783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, numids, 9); 296958ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 297058ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 297158ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 297258ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 2973580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 297458ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 2975580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 2976f971fd6bSMatthew G. Knepley b->type = type; 297758ebd649SToby Isaac b->field = field; 297858ebd649SToby Isaac b->numcomps = numcomps; 297958ebd649SToby Isaac b->func = bcFunc; 298058ebd649SToby Isaac b->numids = numids; 298158ebd649SToby Isaac b->ctx = ctx; 298258ebd649SToby Isaac b->next = ds->boundary; 298358ebd649SToby Isaac ds->boundary = b; 298458ebd649SToby Isaac PetscFunctionReturn(0); 298558ebd649SToby Isaac } 298658ebd649SToby Isaac 2987b67eacb3SMatthew G. Knepley /*@C 2988b67eacb3SMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model 2989b67eacb3SMatthew G. Knepley 2990b67eacb3SMatthew G. Knepley Input Parameters: 2991b67eacb3SMatthew G. Knepley + ds - The PetscDS object 2992b67eacb3SMatthew G. Knepley . bd - The boundary condition number 2993b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 2994b67eacb3SMatthew G. Knepley . name - The BC name 2995b67eacb3SMatthew G. Knepley . labelname - The label defining constrained points 2996b67eacb3SMatthew G. Knepley . field - The field to constrain 2997b67eacb3SMatthew G. Knepley . numcomps - The number of constrained field components 2998b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 2999b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 3000b67eacb3SMatthew G. Knepley . numids - The number of DMLabel ids for constrained points 3001b67eacb3SMatthew G. Knepley . ids - An array of ids for constrained points 3002b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3003b67eacb3SMatthew G. Knepley 30049a6efb6aSMatthew 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(). 30059a6efb6aSMatthew G. Knepley 3006b67eacb3SMatthew G. Knepley Level: developer 3007b67eacb3SMatthew G. Knepley 30089a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3009b67eacb3SMatthew G. Knepley @*/ 3010b67eacb3SMatthew 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) 3011b67eacb3SMatthew G. Knepley { 3012b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3013b67eacb3SMatthew G. Knepley PetscInt n = 0; 3014b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 3015b67eacb3SMatthew G. Knepley 3016b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3017b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3018b67eacb3SMatthew G. Knepley while (b) { 3019b67eacb3SMatthew G. Knepley if (n == bd) break; 3020b67eacb3SMatthew G. Knepley b = b->next; 3021b67eacb3SMatthew G. Knepley ++n; 3022b67eacb3SMatthew G. Knepley } 3023b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3024b67eacb3SMatthew G. Knepley if (name) { 3025b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 3026b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 3027b67eacb3SMatthew G. Knepley } 3028b67eacb3SMatthew G. Knepley if (labelname) { 3029b67eacb3SMatthew G. Knepley ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3030b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 3031b67eacb3SMatthew G. Knepley } 3032b67eacb3SMatthew G. Knepley if (numcomps >= 0 && numcomps != b->numcomps) { 3033b67eacb3SMatthew G. Knepley b->numcomps = numcomps; 3034b67eacb3SMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 3035b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 3036580bdb30SBarry Smith if (numcomps) {ierr = PetscArraycpy(b->comps, comps, numcomps);CHKERRQ(ierr);} 3037b67eacb3SMatthew G. Knepley } 3038b67eacb3SMatthew G. Knepley if (numids >= 0 && numids != b->numids) { 3039b67eacb3SMatthew G. Knepley b->numids = numids; 3040b67eacb3SMatthew G. Knepley ierr = PetscFree(b->ids);CHKERRQ(ierr); 3041b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 3042580bdb30SBarry Smith if (numids) {ierr = PetscArraycpy(b->ids, ids, numids);CHKERRQ(ierr);} 3043b67eacb3SMatthew G. Knepley } 3044b67eacb3SMatthew G. Knepley b->type = type; 3045b67eacb3SMatthew G. Knepley if (field >= 0) {b->field = field;} 3046b67eacb3SMatthew G. Knepley if (bcFunc) {b->func = bcFunc;} 3047b67eacb3SMatthew G. Knepley if (ctx) {b->ctx = ctx;} 3048b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3049b67eacb3SMatthew G. Knepley } 3050b67eacb3SMatthew G. Knepley 305158ebd649SToby Isaac /*@ 305258ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 305358ebd649SToby Isaac 305458ebd649SToby Isaac Input Parameters: 305558ebd649SToby Isaac . ds - The PetscDS object 305658ebd649SToby Isaac 305758ebd649SToby Isaac Output Parameters: 305858ebd649SToby Isaac . numBd - The number of BC 305958ebd649SToby Isaac 306058ebd649SToby Isaac Level: intermediate 306158ebd649SToby Isaac 306258ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 306358ebd649SToby Isaac @*/ 306458ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 306558ebd649SToby Isaac { 306658ebd649SToby Isaac DSBoundary b = ds->boundary; 306758ebd649SToby Isaac 306858ebd649SToby Isaac PetscFunctionBegin; 306958ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 307058ebd649SToby Isaac PetscValidPointer(numBd, 2); 307158ebd649SToby Isaac *numBd = 0; 307258ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 307358ebd649SToby Isaac PetscFunctionReturn(0); 307458ebd649SToby Isaac } 307558ebd649SToby Isaac 307658ebd649SToby Isaac /*@C 30779a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 307858ebd649SToby Isaac 307958ebd649SToby Isaac Input Parameters: 308058ebd649SToby Isaac + ds - The PetscDS object 308158ebd649SToby Isaac - bd - The BC number 308258ebd649SToby Isaac 308358ebd649SToby Isaac Output Parameters: 30842d47a189SJulian Andrej + type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 308558ebd649SToby Isaac . name - The BC name 308658ebd649SToby Isaac . labelname - The label defining constrained points 308758ebd649SToby Isaac . field - The field to constrain 308858ebd649SToby Isaac . numcomps - The number of constrained field components 308958ebd649SToby Isaac . comps - An array of constrained component numbers 309058ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 309158ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 309258ebd649SToby Isaac . ids - An array of ids for constrained points 309358ebd649SToby Isaac - ctx - An optional user context for bcFunc 309458ebd649SToby Isaac 309558ebd649SToby Isaac Options Database Keys: 309658ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 309758ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 309858ebd649SToby Isaac 309958ebd649SToby Isaac Level: developer 310058ebd649SToby Isaac 310158ebd649SToby Isaac .seealso: PetscDSAddBoundary() 310258ebd649SToby Isaac @*/ 3103a30ec4eaSSatish 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) 310458ebd649SToby Isaac { 310558ebd649SToby Isaac DSBoundary b = ds->boundary; 310658ebd649SToby Isaac PetscInt n = 0; 310758ebd649SToby Isaac 310858ebd649SToby Isaac PetscFunctionBegin; 310958ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 311058ebd649SToby Isaac while (b) { 311158ebd649SToby Isaac if (n == bd) break; 311258ebd649SToby Isaac b = b->next; 311358ebd649SToby Isaac ++n; 311458ebd649SToby Isaac } 311558ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3116f971fd6bSMatthew G. Knepley if (type) { 3117f971fd6bSMatthew G. Knepley PetscValidPointer(type, 3); 3118f971fd6bSMatthew G. Knepley *type = b->type; 311958ebd649SToby Isaac } 312058ebd649SToby Isaac if (name) { 312158ebd649SToby Isaac PetscValidPointer(name, 4); 312258ebd649SToby Isaac *name = b->name; 312358ebd649SToby Isaac } 312458ebd649SToby Isaac if (labelname) { 312558ebd649SToby Isaac PetscValidPointer(labelname, 5); 312658ebd649SToby Isaac *labelname = b->labelname; 312758ebd649SToby Isaac } 312858ebd649SToby Isaac if (field) { 312958ebd649SToby Isaac PetscValidPointer(field, 6); 313058ebd649SToby Isaac *field = b->field; 313158ebd649SToby Isaac } 313258ebd649SToby Isaac if (numcomps) { 313358ebd649SToby Isaac PetscValidPointer(numcomps, 7); 313458ebd649SToby Isaac *numcomps = b->numcomps; 313558ebd649SToby Isaac } 313658ebd649SToby Isaac if (comps) { 313758ebd649SToby Isaac PetscValidPointer(comps, 8); 313858ebd649SToby Isaac *comps = b->comps; 313958ebd649SToby Isaac } 314058ebd649SToby Isaac if (func) { 314158ebd649SToby Isaac PetscValidPointer(func, 9); 314258ebd649SToby Isaac *func = b->func; 314358ebd649SToby Isaac } 314458ebd649SToby Isaac if (numids) { 314558ebd649SToby Isaac PetscValidPointer(numids, 10); 314658ebd649SToby Isaac *numids = b->numids; 314758ebd649SToby Isaac } 314858ebd649SToby Isaac if (ids) { 314958ebd649SToby Isaac PetscValidPointer(ids, 11); 315058ebd649SToby Isaac *ids = b->ids; 315158ebd649SToby Isaac } 315258ebd649SToby Isaac if (ctx) { 315358ebd649SToby Isaac PetscValidPointer(ctx, 12); 315458ebd649SToby Isaac *ctx = b->ctx; 315558ebd649SToby Isaac } 315658ebd649SToby Isaac PetscFunctionReturn(0); 315758ebd649SToby Isaac } 315858ebd649SToby Isaac 31599252d075SMatthew G. Knepley /*@ 31609252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 31619252d075SMatthew G. Knepley 31629252d075SMatthew G. Knepley Not collective 31639252d075SMatthew G. Knepley 31649252d075SMatthew G. Knepley Input Parameter: 31659252d075SMatthew G. Knepley . prob - The PetscDS object 31669252d075SMatthew G. Knepley 31679252d075SMatthew G. Knepley Output Parameter: 31689252d075SMatthew G. Knepley . newprob - The PetscDS copy 31699252d075SMatthew G. Knepley 31709252d075SMatthew G. Knepley Level: intermediate 31719252d075SMatthew G. Knepley 31729252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 31739252d075SMatthew G. Knepley @*/ 3174dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 3175dff059c6SToby Isaac { 3176dff059c6SToby Isaac DSBoundary b, next, *lastnext; 3177dff059c6SToby Isaac PetscErrorCode ierr; 3178dff059c6SToby Isaac 3179dff059c6SToby Isaac PetscFunctionBegin; 3180dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 3181dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 3182dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 3183dff059c6SToby Isaac next = probB->boundary; 3184dff059c6SToby Isaac while (next) { 3185dff059c6SToby Isaac DSBoundary b = next; 3186dff059c6SToby Isaac 3187dff059c6SToby Isaac next = b->next; 3188dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 3189dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 3190dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 3191dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 3192dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 3193dff059c6SToby Isaac } 3194dff059c6SToby Isaac lastnext = &(probB->boundary); 3195dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 3196dff059c6SToby Isaac DSBoundary bNew; 3197dff059c6SToby Isaac 3198459726d8SSatish Balay ierr = PetscNew(&bNew);CHKERRQ(ierr); 3199dff059c6SToby Isaac bNew->numcomps = b->numcomps; 3200dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 3201580bdb30SBarry Smith ierr = PetscArraycpy(bNew->comps, b->comps, bNew->numcomps);CHKERRQ(ierr); 3202dff059c6SToby Isaac bNew->numids = b->numids; 3203dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 3204580bdb30SBarry Smith ierr = PetscArraycpy(bNew->ids, b->ids, bNew->numids);CHKERRQ(ierr); 3205dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 3206dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 3207dff059c6SToby Isaac bNew->ctx = b->ctx; 3208f971fd6bSMatthew G. Knepley bNew->type = b->type; 3209dff059c6SToby Isaac bNew->field = b->field; 3210dff059c6SToby Isaac bNew->func = b->func; 3211dff059c6SToby Isaac 3212dff059c6SToby Isaac *lastnext = bNew; 3213dff059c6SToby Isaac lastnext = &(bNew->next); 3214dff059c6SToby Isaac } 3215dff059c6SToby Isaac PetscFunctionReturn(0); 3216dff059c6SToby Isaac } 3217dff059c6SToby Isaac 32189252d075SMatthew G. Knepley /*@C 32199252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 32209252d075SMatthew G. Knepley 32219252d075SMatthew G. Knepley Not collective 32229252d075SMatthew G. Knepley 32239252d075SMatthew G. Knepley Input Parameter: 32249252d075SMatthew G. Knepley + prob - The PetscDS object 32259252d075SMatthew G. Knepley . numFields - Number of new fields 32269252d075SMatthew G. Knepley - fields - Old field number for each new field 32279252d075SMatthew G. Knepley 32289252d075SMatthew G. Knepley Output Parameter: 32299252d075SMatthew G. Knepley . newprob - The PetscDS copy 32309252d075SMatthew G. Knepley 32319252d075SMatthew G. Knepley Level: intermediate 32329252d075SMatthew G. Knepley 32339252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 32349252d075SMatthew G. Knepley @*/ 32359252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 32369252d075SMatthew G. Knepley { 32379252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 32389252d075SMatthew G. Knepley PetscErrorCode ierr; 32399252d075SMatthew G. Knepley 32409252d075SMatthew G. Knepley PetscFunctionBegin; 32419252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 32429252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 32439252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 32449252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 32459252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 32469252d075SMatthew 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); 32479252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 32489252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 32499252d075SMatthew G. Knepley PetscPointFunc obj; 32509252d075SMatthew G. Knepley PetscPointFunc f0, f1; 32519252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 32529252d075SMatthew G. Knepley PetscRiemannFunc r; 32539252d075SMatthew G. Knepley 3254c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 32559252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 32569252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 32579252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 32589252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 32599252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 32609252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 32619252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 32629252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 32639252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 32649252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 32659252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 32669252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 32679252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 32689252d075SMatthew G. Knepley 3269c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 32709252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 32719252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 32729252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 32739252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 32749252d075SMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(prob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 32759252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 32769252d075SMatthew G. Knepley } 32779252d075SMatthew G. Knepley } 32789252d075SMatthew G. Knepley PetscFunctionReturn(0); 32799252d075SMatthew G. Knepley } 32809252d075SMatthew G. Knepley 3281da51fcedSMatthew G. Knepley /*@ 3282da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3283da51fcedSMatthew G. Knepley 3284da51fcedSMatthew G. Knepley Not collective 3285da51fcedSMatthew G. Knepley 3286da51fcedSMatthew G. Knepley Input Parameter: 3287da51fcedSMatthew G. Knepley . prob - The PetscDS object 3288da51fcedSMatthew G. Knepley 3289da51fcedSMatthew G. Knepley Output Parameter: 3290da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3291da51fcedSMatthew G. Knepley 3292da51fcedSMatthew G. Knepley Level: intermediate 3293da51fcedSMatthew G. Knepley 32949252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3295da51fcedSMatthew G. Knepley @*/ 3296da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3297da51fcedSMatthew G. Knepley { 32989252d075SMatthew G. Knepley PetscInt Nf, Ng; 3299da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3300da51fcedSMatthew G. Knepley 3301da51fcedSMatthew G. Knepley PetscFunctionBegin; 3302da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3303da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3304da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3305da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 330613903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 33079252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 33089252d075SMatthew G. Knepley PetscFunctionReturn(0); 33099252d075SMatthew G. Knepley } 33109252d075SMatthew G. Knepley /*@ 33119252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3312da51fcedSMatthew G. Knepley 33139252d075SMatthew G. Knepley Not collective 33149252d075SMatthew G. Knepley 33159252d075SMatthew G. Knepley Input Parameter: 33169252d075SMatthew G. Knepley . prob - The PetscDS object 33179252d075SMatthew G. Knepley 33189252d075SMatthew G. Knepley Output Parameter: 33199252d075SMatthew G. Knepley . newprob - The PetscDS copy 33209252d075SMatthew G. Knepley 33219252d075SMatthew G. Knepley Level: intermediate 33229252d075SMatthew G. Knepley 33239252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 33249252d075SMatthew G. Knepley @*/ 33259252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 33269252d075SMatthew G. Knepley { 33279252d075SMatthew G. Knepley PetscInt Nc; 33289252d075SMatthew G. Knepley const PetscScalar *constants; 33299252d075SMatthew G. Knepley PetscErrorCode ierr; 33309252d075SMatthew G. Knepley 33319252d075SMatthew G. Knepley PetscFunctionBegin; 33329252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 33339252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 33349252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 33359252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3336da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3337da51fcedSMatthew G. Knepley } 3338da51fcedSMatthew G. Knepley 3339b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3340b1353e8eSMatthew G. Knepley { 3341df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3342b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3343b1353e8eSMatthew G. Knepley 3344b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3345b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3346b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3347b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3348b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3349df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3350df3a45bdSMatthew 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); 3351df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3352df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3353b1353e8eSMatthew G. Knepley PetscInt cdim; 3354b1353e8eSMatthew G. Knepley 3355df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3356b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3357df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3358b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3359b1353e8eSMatthew G. Knepley PetscFE subfe; 3360b1353e8eSMatthew G. Knepley PetscObject obj; 3361b1353e8eSMatthew G. Knepley PetscClassId id; 3362b1353e8eSMatthew G. Knepley 3363b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3364b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3365b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3366b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3367df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3368b1353e8eSMatthew G. Knepley } 3369b1353e8eSMatthew G. Knepley } 3370df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3371b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3372b1353e8eSMatthew G. Knepley } 3373b1353e8eSMatthew G. Knepley 3374*665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 3375c7bd5f0bSMatthew G. Knepley { 3376c7bd5f0bSMatthew G. Knepley PetscObject obj; 3377c7bd5f0bSMatthew G. Knepley PetscClassId id; 3378c7bd5f0bSMatthew G. Knepley PetscInt Nf; 3379c7bd5f0bSMatthew G. Knepley PetscErrorCode ierr; 3380c7bd5f0bSMatthew G. Knepley 3381c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 3382c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3383*665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 3384*665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 3385c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 3386c7bd5f0bSMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 3387c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetDiscretization(ds, f, &obj);CHKERRQ(ierr); 3388*665f567fSMatthew G. Knepley if (obj) { 3389c7bd5f0bSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3390*665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 3391*665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 3392*665f567fSMatthew G. Knepley } 3393c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 3394c7bd5f0bSMatthew G. Knepley } 3395c7bd5f0bSMatthew G. Knepley 3396bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 33972764a2aaSMatthew G. Knepley { 3398931fb3b8SToby Isaac PetscErrorCode ierr; 3399931fb3b8SToby Isaac 34002764a2aaSMatthew G. Knepley PetscFunctionBegin; 3401931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 34022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 34032764a2aaSMatthew G. Knepley } 34042764a2aaSMatthew G. Knepley 3405bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 34062764a2aaSMatthew G. Knepley { 34072764a2aaSMatthew G. Knepley PetscFunctionBegin; 34082764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 34092764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 34102764a2aaSMatthew G. Knepley prob->ops->view = NULL; 34112764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 34122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 34132764a2aaSMatthew G. Knepley } 34142764a2aaSMatthew G. Knepley 34152764a2aaSMatthew G. Knepley /*MC 34162764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 34172764a2aaSMatthew G. Knepley 34182764a2aaSMatthew G. Knepley Level: intermediate 34192764a2aaSMatthew G. Knepley 34202764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 34212764a2aaSMatthew G. Knepley M*/ 34222764a2aaSMatthew G. Knepley 34232764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 34242764a2aaSMatthew G. Knepley { 34252764a2aaSMatthew G. Knepley PetscDS_Basic *b; 34262764a2aaSMatthew G. Knepley PetscErrorCode ierr; 34272764a2aaSMatthew G. Knepley 34282764a2aaSMatthew G. Knepley PetscFunctionBegin; 3429931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 34302764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 34312764a2aaSMatthew G. Knepley prob->data = b; 34322764a2aaSMatthew G. Knepley 34332764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 34342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 34352764a2aaSMatthew G. Knepley } 3436