1af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/ 22764a2aaSMatthew G. Knepley 32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0; 42764a2aaSMatthew G. Knepley 52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList = NULL; 62764a2aaSMatthew G. Knepley PetscBool PetscDSRegisterAllCalled = PETSC_FALSE; 72764a2aaSMatthew G. Knepley 894dcdc3fSMatthew G. Knepley /* A PetscDS (Discrete System) encodes a set of equations posed in a discrete space, which represents a set of 994dcdc3fSMatthew G. Knepley nonlinear continuum equations. The equations can have multiple fields, each field having a different 1094dcdc3fSMatthew G. Knepley discretization. In addition, different pieces of the domain can have different field combinations and equations. 1194dcdc3fSMatthew G. Knepley 1294dcdc3fSMatthew G. Knepley The DS provides the user a description of the approximation space on any given cell. It also gives pointwise 1394dcdc3fSMatthew G. Knepley functions representing the equations. 1494dcdc3fSMatthew G. Knepley 1594dcdc3fSMatthew G. Knepley Each field is associated with a label, marking the cells on which it is supported. Note that a field can be 1694dcdc3fSMatthew G. Knepley supported on the closure of a cell not in the label due to overlap of the boundary of neighboring cells. The DM 1794dcdc3fSMatthew G. Knepley then creates a DS for each set of cells with identical approximation spaces. When assembling, the user asks for 1894dcdc3fSMatthew G. Knepley the space associated with a given cell. DMPlex uses the labels associated with each DS in the default integration loop. 1994dcdc3fSMatthew G. Knepley */ 2094dcdc3fSMatthew G. Knepley 212764a2aaSMatthew G. Knepley /*@C 222764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 232764a2aaSMatthew G. Knepley 242764a2aaSMatthew G. Knepley Not Collective 252764a2aaSMatthew G. Knepley 262764a2aaSMatthew G. Knepley Input Parameters: 272764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 282764a2aaSMatthew G. Knepley - create_func - The creation routine itself 292764a2aaSMatthew G. Knepley 302764a2aaSMatthew G. Knepley Notes: 312764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 322764a2aaSMatthew G. Knepley 332764a2aaSMatthew G. Knepley Sample usage: 342764a2aaSMatthew G. Knepley .vb 352764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 362764a2aaSMatthew G. Knepley .ve 372764a2aaSMatthew G. Knepley 382764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 392764a2aaSMatthew G. Knepley .vb 402764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 412764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 422764a2aaSMatthew G. Knepley .ve 432764a2aaSMatthew G. Knepley or at runtime via the option 442764a2aaSMatthew G. Knepley .vb 452764a2aaSMatthew G. Knepley -petscds_type my_ds 462764a2aaSMatthew G. Knepley .ve 472764a2aaSMatthew G. Knepley 482764a2aaSMatthew G. Knepley Level: advanced 492764a2aaSMatthew G. Knepley 50f5f57ec0SBarry Smith Not available from Fortran 51f5f57ec0SBarry Smith 522764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy() 532764a2aaSMatthew G. Knepley 542764a2aaSMatthew G. Knepley @*/ 552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS)) 562764a2aaSMatthew G. Knepley { 572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 582764a2aaSMatthew G. Knepley 592764a2aaSMatthew G. Knepley PetscFunctionBegin; 602764a2aaSMatthew G. Knepley ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr); 612764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 622764a2aaSMatthew G. Knepley } 632764a2aaSMatthew G. Knepley 642764a2aaSMatthew G. Knepley /*@C 652764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 662764a2aaSMatthew G. Knepley 67d083f849SBarry Smith Collective on prob 682764a2aaSMatthew G. Knepley 692764a2aaSMatthew G. Knepley Input Parameters: 702764a2aaSMatthew G. Knepley + prob - The PetscDS object 712764a2aaSMatthew G. Knepley - name - The kind of system 722764a2aaSMatthew G. Knepley 732764a2aaSMatthew G. Knepley Options Database Key: 742764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 752764a2aaSMatthew G. Knepley 762764a2aaSMatthew G. Knepley Level: intermediate 772764a2aaSMatthew G. Knepley 78f5f57ec0SBarry Smith Not available from Fortran 79f5f57ec0SBarry Smith 802764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate() 812764a2aaSMatthew G. Knepley @*/ 822764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 832764a2aaSMatthew G. Knepley { 842764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 852764a2aaSMatthew G. Knepley PetscBool match; 862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 872764a2aaSMatthew G. Knepley 882764a2aaSMatthew G. Knepley PetscFunctionBegin; 892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 902764a2aaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr); 912764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 922764a2aaSMatthew G. Knepley 930f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 942764a2aaSMatthew G. Knepley ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr); 952764a2aaSMatthew G. Knepley if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 962764a2aaSMatthew G. Knepley 972764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 982764a2aaSMatthew G. Knepley ierr = (*prob->ops->destroy)(prob);CHKERRQ(ierr); 992764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 1002764a2aaSMatthew G. Knepley } 1012764a2aaSMatthew G. Knepley ierr = (*r)(prob);CHKERRQ(ierr); 1022764a2aaSMatthew G. Knepley ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr); 1032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1042764a2aaSMatthew G. Knepley } 1052764a2aaSMatthew G. Knepley 1062764a2aaSMatthew G. Knepley /*@C 1072764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 1082764a2aaSMatthew G. Knepley 1092764a2aaSMatthew G. Knepley Not Collective 1102764a2aaSMatthew G. Knepley 1112764a2aaSMatthew G. Knepley Input Parameter: 1122764a2aaSMatthew G. Knepley . prob - The PetscDS 1132764a2aaSMatthew G. Knepley 1142764a2aaSMatthew G. Knepley Output Parameter: 1152764a2aaSMatthew G. Knepley . name - The PetscDS type name 1162764a2aaSMatthew G. Knepley 1172764a2aaSMatthew G. Knepley Level: intermediate 1182764a2aaSMatthew G. Knepley 119f5f57ec0SBarry Smith Not available from Fortran 120f5f57ec0SBarry Smith 1212764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1222764a2aaSMatthew G. Knepley @*/ 1232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1242764a2aaSMatthew G. Knepley { 1252764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1262764a2aaSMatthew G. Knepley 1272764a2aaSMatthew G. Knepley PetscFunctionBegin; 1282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 129c959eef4SJed Brown PetscValidPointer(name, 2); 1300f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 1312764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1332764a2aaSMatthew G. Knepley } 1342764a2aaSMatthew G. Knepley 1357d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1367d8a60eaSMatthew G. Knepley { 1377d8a60eaSMatthew G. Knepley PetscViewerFormat format; 13897b6e6e8SMatthew G. Knepley const PetscScalar *constants; 13997b6e6e8SMatthew G. Knepley PetscInt numConstants, f; 1407d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1417d8a60eaSMatthew G. Knepley 1427d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1437d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1447d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1457d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1464727e194SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " cell total dim %D total comp %D\n", prob->totDim, prob->totComp);CHKERRQ(ierr); 1474727e194SMatthew G. Knepley if (prob->isHybrid) {ierr = PetscViewerASCIIPrintf(viewer, " hybrid cell\n");CHKERRQ(ierr);} 1487d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 14940967b3bSMatthew G. Knepley DSBoundary b; 1507d8a60eaSMatthew G. Knepley PetscObject obj; 1517d8a60eaSMatthew G. Knepley PetscClassId id; 152f35450b9SMatthew G. Knepley PetscQuadrature q; 1537d8a60eaSMatthew G. Knepley const char *name; 154f35450b9SMatthew G. Knepley PetscInt Nc, Nq, Nqc; 1557d8a60eaSMatthew G. Knepley 1567d8a60eaSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 1577d8a60eaSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 1587d8a60eaSMatthew G. Knepley ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr); 1597d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr); 1604727e194SMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 1617d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1627d8a60eaSMatthew G. Knepley ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr); 163f35450b9SMatthew G. Knepley ierr = PetscFEGetQuadrature((PetscFE) obj, &q);CHKERRQ(ierr); 1647d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1657d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1667d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 167f35450b9SMatthew G. Knepley ierr = PetscFVGetQuadrature((PetscFV) obj, &q);CHKERRQ(ierr); 1687d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1697d8a60eaSMatthew G. Knepley } 17097b6e6e8SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %D", f); 17197b6e6e8SMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, " %D components", Nc);CHKERRQ(ierr);} 17297b6e6e8SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " %D component ", Nc);CHKERRQ(ierr);} 173249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 174249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 1753e60c2a6SMatthew G. Knepley if (q) { 176f35450b9SMatthew G. Knepley ierr = PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL);CHKERRQ(ierr); 177f35450b9SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " (Nq %D Nqc %D)", Nq, Nqc);CHKERRQ(ierr); 1783e60c2a6SMatthew G. Knepley } 179f9244615SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " %D-jet", prob->jetDegree[f]);CHKERRQ(ierr); 1807d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1814727e194SMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 1825d160056SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1837d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1847d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1855d160056SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 18640967b3bSMatthew G. Knepley 18740967b3bSMatthew G. Knepley for (b = prob->boundary; b; b = b->next) { 18806ad1575SMatthew G. Knepley char *name; 18940967b3bSMatthew G. Knepley PetscInt c, i; 19040967b3bSMatthew G. Knepley 19140967b3bSMatthew G. Knepley if (b->field != f) continue; 19240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 19345480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Boundary %s (%s) %s\n", b->name, b->lname, DMBoundaryConditionTypes[b->type]);CHKERRQ(ierr); 19445480ffeSMatthew G. Knepley if (!b->Nc) { 19540967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " all components\n");CHKERRQ(ierr); 19640967b3bSMatthew G. Knepley } else { 19740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " components: ");CHKERRQ(ierr); 19840967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 19945480ffeSMatthew G. Knepley for (c = 0; c < b->Nc; ++c) { 20040967b3bSMatthew G. Knepley if (c > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 20140967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->comps[c]);CHKERRQ(ierr); 20240967b3bSMatthew G. Knepley } 20340967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 20440967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 20540967b3bSMatthew G. Knepley } 20645480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " values: ");CHKERRQ(ierr); 20740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr); 20845480ffeSMatthew G. Knepley for (i = 0; i < b->Nv; ++i) { 20940967b3bSMatthew G. Knepley if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);} 21045480ffeSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D", b->values[i]);CHKERRQ(ierr); 21140967b3bSMatthew G. Knepley } 21240967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 21340967b3bSMatthew G. Knepley ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr); 2148e0d8d9cSMatthew G. Knepley if (b->func) { 2158e0d8d9cSMatthew G. Knepley ierr = PetscDLAddr(b->func, &name);CHKERRQ(ierr); 2168e0d8d9cSMatthew G. Knepley if (name) {ierr = PetscViewerASCIIPrintf(viewer, " func: %s\n", name);CHKERRQ(ierr);} 2178e0d8d9cSMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " func: %p\n", b->func);CHKERRQ(ierr);} 21806ad1575SMatthew G. Knepley ierr = PetscFree(name);CHKERRQ(ierr); 2198e0d8d9cSMatthew G. Knepley } 2208e0d8d9cSMatthew G. Knepley if (b->func_t) { 2218e0d8d9cSMatthew G. Knepley ierr = PetscDLAddr(b->func_t, &name);CHKERRQ(ierr); 2222e144d55SMatthew G. Knepley if (name) {ierr = PetscViewerASCIIPrintf(viewer, " func_t: %s\n", name);CHKERRQ(ierr);} 2232e144d55SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " func_t: %p\n", b->func_t);CHKERRQ(ierr);} 22406ad1575SMatthew G. Knepley ierr = PetscFree(name);CHKERRQ(ierr); 2258e0d8d9cSMatthew G. Knepley } 22645480ffeSMatthew G. Knepley ierr = PetscWeakFormView(b->wf, viewer);CHKERRQ(ierr); 22740967b3bSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 22840967b3bSMatthew G. Knepley } 2297d8a60eaSMatthew G. Knepley } 23097b6e6e8SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &numConstants, &constants);CHKERRQ(ierr); 23197b6e6e8SMatthew G. Knepley if (numConstants) { 23297b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D constants\n", numConstants);CHKERRQ(ierr); 23397b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 23457fc01e9SMatthew G. Knepley for (f = 0; f < numConstants; ++f) {ierr = PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]));CHKERRQ(ierr);} 23597b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 23697b6e6e8SMatthew G. Knepley } 2376528b96dSMatthew G. Knepley ierr = PetscWeakFormView(prob->wf, viewer);CHKERRQ(ierr); 2387d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 2397d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 2407d8a60eaSMatthew G. Knepley } 2417d8a60eaSMatthew G. Knepley 2422764a2aaSMatthew G. Knepley /*@C 243fe2efc57SMark PetscDSViewFromOptions - View from Options 244fe2efc57SMark 245fe2efc57SMark Collective on PetscDS 246fe2efc57SMark 247fe2efc57SMark Input Parameters: 248fe2efc57SMark + A - the PetscDS object 249736c3998SJose E. Roman . obj - Optional object 250736c3998SJose E. Roman - name - command line option 251fe2efc57SMark 252fe2efc57SMark Level: intermediate 253fe2efc57SMark .seealso: PetscDS, PetscDSView, PetscObjectViewFromOptions(), PetscDSCreate() 254fe2efc57SMark @*/ 255fe2efc57SMark PetscErrorCode PetscDSViewFromOptions(PetscDS A,PetscObject obj,const char name[]) 256fe2efc57SMark { 257fe2efc57SMark PetscErrorCode ierr; 258fe2efc57SMark 259fe2efc57SMark PetscFunctionBegin; 260fe2efc57SMark PetscValidHeaderSpecific(A,PETSCDS_CLASSID,1); 261fe2efc57SMark ierr = PetscObjectViewFromOptions((PetscObject)A,obj,name);CHKERRQ(ierr); 262fe2efc57SMark PetscFunctionReturn(0); 263fe2efc57SMark } 264fe2efc57SMark 265fe2efc57SMark /*@C 2662764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 2672764a2aaSMatthew G. Knepley 268d083f849SBarry Smith Collective on prob 2692764a2aaSMatthew G. Knepley 2702764a2aaSMatthew G. Knepley Input Parameter: 2712764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 2722764a2aaSMatthew G. Knepley - v - the viewer 2732764a2aaSMatthew G. Knepley 2742764a2aaSMatthew G. Knepley Level: developer 2752764a2aaSMatthew G. Knepley 2762764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 2772764a2aaSMatthew G. Knepley @*/ 2782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2792764a2aaSMatthew G. Knepley { 2807d8a60eaSMatthew G. Knepley PetscBool iascii; 2812764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2822764a2aaSMatthew G. Knepley 2832764a2aaSMatthew G. Knepley PetscFunctionBegin; 2842764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2852764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 2867d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2877d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2887d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2892764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2902764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2912764a2aaSMatthew G. Knepley } 2922764a2aaSMatthew G. Knepley 2932764a2aaSMatthew G. Knepley /*@ 2942764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2952764a2aaSMatthew G. Knepley 296d083f849SBarry Smith Collective on prob 2972764a2aaSMatthew G. Knepley 2982764a2aaSMatthew G. Knepley Input Parameter: 2992764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 3002764a2aaSMatthew G. Knepley 3012764a2aaSMatthew G. Knepley Options Database: 30255c1f793SMatthew G. Knepley + -petscds_type <type> : Set the DS type 30355c1f793SMatthew G. Knepley . -petscds_view <view opt> : View the DS 30455c1f793SMatthew G. Knepley . -petscds_jac_pre : Turn formation of a separate Jacobian preconditioner on and off 30555c1f793SMatthew G. Knepley . -bc_<name> <ids> : Specify a list of label ids for a boundary condition 30655c1f793SMatthew G. Knepley - -bc_<name>_comp <comps> : Specify a list of field components to constrain for a boundary condition 3072764a2aaSMatthew G. Knepley 3082764a2aaSMatthew G. Knepley Level: developer 3092764a2aaSMatthew G. Knepley 3102764a2aaSMatthew G. Knepley .seealso PetscDSView() 3112764a2aaSMatthew G. Knepley @*/ 3122764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 3132764a2aaSMatthew G. Knepley { 314f1fd5e65SToby Isaac DSBoundary b; 3152764a2aaSMatthew G. Knepley const char *defaultType; 3162764a2aaSMatthew G. Knepley char name[256]; 3172764a2aaSMatthew G. Knepley PetscBool flg; 3182764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3192764a2aaSMatthew G. Knepley 3202764a2aaSMatthew G. Knepley PetscFunctionBegin; 3212764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3222764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 3232764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 3242764a2aaSMatthew G. Knepley } else { 3252764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 3262764a2aaSMatthew G. Knepley } 3270f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 3282764a2aaSMatthew G. Knepley 3292764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 330f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 331f1fd5e65SToby Isaac char optname[1024]; 332f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 333f1fd5e65SToby Isaac PetscBool flg; 334f1fd5e65SToby Isaac 335f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name);CHKERRQ(ierr); 336f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 337f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg);CHKERRQ(ierr); 338f1fd5e65SToby Isaac if (flg) { 33945480ffeSMatthew G. Knepley b->Nv = len; 34045480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 34145480ffeSMatthew G. Knepley ierr = PetscMalloc1(len, &b->values);CHKERRQ(ierr); 34245480ffeSMatthew G. Knepley ierr = PetscArraycpy(b->values, ids, len);CHKERRQ(ierr); 34345480ffeSMatthew G. Knepley ierr = PetscWeakFormRewriteKeys(b->wf, b->label, len, b->values);CHKERRQ(ierr); 344f1fd5e65SToby Isaac } 345e7b0402cSSander Arens len = 1024; 346f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name);CHKERRQ(ierr); 347f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 348f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg);CHKERRQ(ierr); 349f1fd5e65SToby Isaac if (flg) { 35045480ffeSMatthew G. Knepley b->Nc = len; 351f1fd5e65SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 352f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->comps);CHKERRQ(ierr); 353580bdb30SBarry Smith ierr = PetscArraycpy(b->comps, ids, len);CHKERRQ(ierr); 354f1fd5e65SToby Isaac } 355f1fd5e65SToby Isaac } 3562764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 3572764a2aaSMatthew G. Knepley if (flg) { 3582764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 3592764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 3602764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 3612764a2aaSMatthew G. Knepley } 36255c1f793SMatthew G. Knepley ierr = PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg);CHKERRQ(ierr); 3632764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 3642764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3650633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 3662764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 3675d160056SMatthew G. Knepley if (prob->Nf) {ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);} 3682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3692764a2aaSMatthew G. Knepley } 3702764a2aaSMatthew G. Knepley 3712764a2aaSMatthew G. Knepley /*@C 3722764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 3732764a2aaSMatthew G. Knepley 374d083f849SBarry Smith Collective on prob 3752764a2aaSMatthew G. Knepley 3762764a2aaSMatthew G. Knepley Input Parameter: 3772764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3782764a2aaSMatthew G. Knepley 3792764a2aaSMatthew G. Knepley Level: developer 3802764a2aaSMatthew G. Knepley 3812764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3822764a2aaSMatthew G. Knepley @*/ 3832764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3842764a2aaSMatthew G. Knepley { 3852764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 386f9244615SMatthew G. Knepley PetscBool hasH = PETSC_FALSE; 3874bee2e38SMatthew G. Knepley PetscInt dim, dimEmbed, NbMax = 0, NcMax = 0, NqMax = 0, NsMax = 1, f; 3882764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3892764a2aaSMatthew G. Knepley 3902764a2aaSMatthew G. Knepley PetscFunctionBegin; 3912764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3922764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3932764a2aaSMatthew G. Knepley /* Calculate sizes */ 3942764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 395d1506c7cSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &dimEmbed);CHKERRQ(ierr); 396f744cafaSSander Arens prob->totDim = prob->totComp = 0; 39747e57110SSander Arens ierr = PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb);CHKERRQ(ierr); 398f744cafaSSander Arens ierr = PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer);CHKERRQ(ierr); 399ef0bb6c7SMatthew G. Knepley ierr = PetscMalloc2(Nf,&prob->T,Nf,&prob->Tf);CHKERRQ(ierr); 4002764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 4019de99aefSMatthew G. Knepley PetscObject obj; 4029de99aefSMatthew G. Knepley PetscClassId id; 403665f567fSMatthew G. Knepley PetscQuadrature q = NULL; 4049de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 4052764a2aaSMatthew G. Knepley 4069de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 407f9244615SMatthew G. Knepley if (prob->jetDegree[f] > 1) hasH = PETSC_TRUE; 408665f567fSMatthew G. Knepley if (!obj) { 409665f567fSMatthew G. Knepley /* Empty mesh */ 410665f567fSMatthew G. Knepley Nb = Nc = 0; 411665f567fSMatthew G. Knepley prob->T[f] = prob->Tf[f] = NULL; 412665f567fSMatthew G. Knepley } else { 4139de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 4149de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 4159de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 4169de99aefSMatthew G. Knepley 4172764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 4182764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 4192764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 420f9244615SMatthew G. Knepley ierr = PetscFEGetCellTabulation(fe, prob->jetDegree[f], &prob->T[f]);CHKERRQ(ierr); 421f9244615SMatthew G. Knepley ierr = PetscFEGetFaceTabulation(fe, prob->jetDegree[f], &prob->Tf[f]);CHKERRQ(ierr); 4229de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 4239de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 4249de99aefSMatthew G. Knepley 4259de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 4269de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 4279c3cf19fSMatthew G. Knepley Nb = Nc; 428ef0bb6c7SMatthew G. Knepley ierr = PetscFVGetCellTabulation(fv, &prob->T[f]);CHKERRQ(ierr); 4294d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 430abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 431665f567fSMatthew G. Knepley } 43247e57110SSander Arens prob->Nc[f] = Nc; 43347e57110SSander Arens prob->Nb[f] = Nb; 434194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 435194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 436a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 4372764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 4384bee2e38SMatthew G. Knepley NbMax = PetscMax(NbMax, Nb); 4392764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 4409c3cf19fSMatthew G. Knepley prob->totDim += Nb; 4412764a2aaSMatthew G. Knepley prob->totComp += Nc; 44294a5e212SMatthew G. Knepley /* There are two faces for all fields but the cohesive field on a hybrid cell */ 44394a5e212SMatthew G. Knepley if (prob->isHybrid && (f < Nf-1)) prob->totDim += Nb; 4442764a2aaSMatthew G. Knepley } 4452764a2aaSMatthew G. Knepley /* Allocate works space */ 446b9d30458SMatthew G. Knepley NsMax = 2; /* Even non-hybrid discretizations can be used in a hybrid integration, so we need this extra workspace */ 447f9244615SMatthew G. Knepley ierr = PetscMalloc3(NsMax*prob->totComp,&prob->u,NsMax*prob->totComp,&prob->u_t,NsMax*prob->totComp*dimEmbed + (hasH ? NsMax*prob->totComp*dimEmbed*dimEmbed : 0),&prob->u_x);CHKERRQ(ierr); 4484bee2e38SMatthew G. Knepley ierr = PetscMalloc5(dimEmbed,&prob->x,NbMax*NcMax,&prob->basisReal,NbMax*NcMax*dimEmbed,&prob->basisDerReal,NbMax*NcMax,&prob->testReal,NbMax*NcMax*dimEmbed,&prob->testDerReal);CHKERRQ(ierr); 44927f02ce8SMatthew G. Knepley ierr = PetscMalloc6(NsMax*NqMax*NcMax,&prob->f0,NsMax*NqMax*NcMax*dimEmbed,&prob->f1, 45027f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax,&prob->g0,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g1, 45127f02ce8SMatthew G. Knepley NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed,&prob->g2,NsMax*NsMax*NqMax*NcMax*NcMax*dimEmbed*dimEmbed,&prob->g3);CHKERRQ(ierr); 4522764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 4532764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 4542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4552764a2aaSMatthew G. Knepley } 4562764a2aaSMatthew G. Knepley 4572764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 4582764a2aaSMatthew G. Knepley { 4592764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4602764a2aaSMatthew G. Knepley 4612764a2aaSMatthew G. Knepley PetscFunctionBegin; 46247e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 463f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 464ef0bb6c7SMatthew G. Knepley ierr = PetscFree2(prob->T,prob->Tf);CHKERRQ(ierr); 4654bee2e38SMatthew G. Knepley ierr = PetscFree3(prob->u,prob->u_t,prob->u_x);CHKERRQ(ierr); 4664bee2e38SMatthew G. Knepley ierr = PetscFree5(prob->x,prob->basisReal, prob->basisDerReal,prob->testReal,prob->testDerReal);CHKERRQ(ierr); 4672764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 4682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4692764a2aaSMatthew G. Knepley } 4702764a2aaSMatthew G. Knepley 4712764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 4722764a2aaSMatthew G. Knepley { 473f744cafaSSander Arens PetscObject *tmpd; 47434aa8a36SMatthew G. Knepley PetscBool *tmpi; 475f9244615SMatthew G. Knepley PetscInt *tmpk; 4766528b96dSMatthew G. Knepley PetscPointFunc *tmpup; 477f2cacb80SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol, *tmpexactSol_t; 478f2cacb80SMatthew G. Knepley void **tmpexactCtx, **tmpexactCtx_t; 4790c2f2876SMatthew G. Knepley void **tmpctx; 48034aa8a36SMatthew G. Knepley PetscInt Nf = prob->Nf, f; 4812764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4822764a2aaSMatthew G. Knepley 4832764a2aaSMatthew G. Knepley PetscFunctionBegin; 4842764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 4852764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 4862764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 487f9244615SMatthew G. Knepley ierr = PetscMalloc3(NfNew, &tmpd, NfNew, &tmpi, NfNew, &tmpk);CHKERRQ(ierr); 488f9244615SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f]; tmpk[f] = prob->jetDegree[f];} 489f9244615SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpk[f] = 1;} 490f9244615SMatthew G. Knepley ierr = PetscFree3(prob->disc, prob->implicit, prob->jetDegree);CHKERRQ(ierr); 4916528b96dSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(prob->wf, NfNew);CHKERRQ(ierr); 4922764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4932764a2aaSMatthew G. Knepley prob->disc = tmpd; 494249df284SMatthew G. Knepley prob->implicit = tmpi; 495f9244615SMatthew G. Knepley prob->jetDegree = tmpk; 4966528b96dSMatthew G. Knepley ierr = PetscCalloc2(NfNew, &tmpup, NfNew, &tmpctx);CHKERRQ(ierr); 49732d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4980c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 49932d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 5000c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 5016528b96dSMatthew G. Knepley ierr = PetscFree2(prob->update, prob->ctx);CHKERRQ(ierr); 50232d2bbc9SMatthew G. Knepley prob->update = tmpup; 5030c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 5046528b96dSMatthew G. Knepley ierr = PetscCalloc4(NfNew, &tmpexactSol, NfNew, &tmpexactCtx, NfNew, &tmpexactSol_t, NfNew, &tmpexactCtx_t);CHKERRQ(ierr); 505c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 50695cbbfd3SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx[f] = prob->exactCtx[f]; 507f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol_t[f] = prob->exactSol_t[f]; 508f2cacb80SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactCtx_t[f] = prob->exactCtx_t[f]; 509c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 51095cbbfd3SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx[f] = NULL; 511f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol_t[f] = NULL; 512f2cacb80SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactCtx_t[f] = NULL; 5136528b96dSMatthew G. Knepley ierr = PetscFree4(prob->exactSol, prob->exactCtx, prob->exactSol_t, prob->exactCtx_t);CHKERRQ(ierr); 514c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 51595cbbfd3SMatthew G. Knepley prob->exactCtx = tmpexactCtx; 516f2cacb80SMatthew G. Knepley prob->exactSol_t = tmpexactSol_t; 517f2cacb80SMatthew G. Knepley prob->exactCtx_t = tmpexactCtx_t; 5182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5192764a2aaSMatthew G. Knepley } 5202764a2aaSMatthew G. Knepley 5212764a2aaSMatthew G. Knepley /*@ 5222764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 5232764a2aaSMatthew G. Knepley 524d083f849SBarry Smith Collective on prob 5252764a2aaSMatthew G. Knepley 5262764a2aaSMatthew G. Knepley Input Parameter: 5272764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 5282764a2aaSMatthew G. Knepley 5292764a2aaSMatthew G. Knepley Level: developer 5302764a2aaSMatthew G. Knepley 5312764a2aaSMatthew G. Knepley .seealso PetscDSView() 5322764a2aaSMatthew G. Knepley @*/ 5336528b96dSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *ds) 5342764a2aaSMatthew G. Knepley { 5352764a2aaSMatthew G. Knepley PetscInt f; 5362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5372764a2aaSMatthew G. Knepley 5382764a2aaSMatthew G. Knepley PetscFunctionBegin; 5396528b96dSMatthew G. Knepley if (!*ds) PetscFunctionReturn(0); 5406528b96dSMatthew G. Knepley PetscValidHeaderSpecific((*ds), PETSCDS_CLASSID, 1); 5412764a2aaSMatthew G. Knepley 5426528b96dSMatthew G. Knepley if (--((PetscObject)(*ds))->refct > 0) {*ds = NULL; PetscFunctionReturn(0);} 5436528b96dSMatthew G. Knepley ((PetscObject) (*ds))->refct = 0; 5446528b96dSMatthew G. Knepley if ((*ds)->subprobs) { 545df3a45bdSMatthew G. Knepley PetscInt dim, d; 546df3a45bdSMatthew G. Knepley 5476528b96dSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*ds, &dim);CHKERRQ(ierr); 5486528b96dSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*ds)->subprobs[d]);CHKERRQ(ierr);} 549df3a45bdSMatthew G. Knepley } 5506528b96dSMatthew G. Knepley ierr = PetscFree((*ds)->subprobs);CHKERRQ(ierr); 5516528b96dSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*ds);CHKERRQ(ierr); 5526528b96dSMatthew G. Knepley for (f = 0; f < (*ds)->Nf; ++f) { 5536528b96dSMatthew G. Knepley ierr = PetscObjectDereference((*ds)->disc[f]);CHKERRQ(ierr); 5542764a2aaSMatthew G. Knepley } 5556528b96dSMatthew G. Knepley ierr = PetscFree3((*ds)->disc, (*ds)->implicit, (*ds)->jetDegree);CHKERRQ(ierr); 5566528b96dSMatthew G. Knepley ierr = PetscWeakFormDestroy(&(*ds)->wf);CHKERRQ(ierr); 5576528b96dSMatthew G. Knepley ierr = PetscFree2((*ds)->update,(*ds)->ctx);CHKERRQ(ierr); 5586528b96dSMatthew G. Knepley ierr = PetscFree4((*ds)->exactSol,(*ds)->exactCtx,(*ds)->exactSol_t,(*ds)->exactCtx_t);CHKERRQ(ierr); 5596528b96dSMatthew G. Knepley if ((*ds)->ops->destroy) {ierr = (*(*ds)->ops->destroy)(*ds);CHKERRQ(ierr);} 56045480ffeSMatthew G. Knepley ierr = PetscDSDestroyBoundary(*ds);CHKERRQ(ierr); 5616528b96dSMatthew G. Knepley ierr = PetscFree((*ds)->constants);CHKERRQ(ierr); 5626528b96dSMatthew G. Knepley ierr = PetscHeaderDestroy(ds);CHKERRQ(ierr); 5632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5642764a2aaSMatthew G. Knepley } 5652764a2aaSMatthew G. Knepley 5662764a2aaSMatthew G. Knepley /*@ 5672764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5682764a2aaSMatthew G. Knepley 569d083f849SBarry Smith Collective 5702764a2aaSMatthew G. Knepley 5712764a2aaSMatthew G. Knepley Input Parameter: 5722764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5732764a2aaSMatthew G. Knepley 5742764a2aaSMatthew G. Knepley Output Parameter: 5756528b96dSMatthew G. Knepley . ds - The PetscDS object 5762764a2aaSMatthew G. Knepley 5772764a2aaSMatthew G. Knepley Level: beginner 5782764a2aaSMatthew G. Knepley 5792764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5802764a2aaSMatthew G. Knepley @*/ 5816528b96dSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *ds) 5822764a2aaSMatthew G. Knepley { 5832764a2aaSMatthew G. Knepley PetscDS p; 5842764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5852764a2aaSMatthew G. Knepley 5862764a2aaSMatthew G. Knepley PetscFunctionBegin; 5876528b96dSMatthew G. Knepley PetscValidPointer(ds, 2); 5886528b96dSMatthew G. Knepley *ds = NULL; 5892764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5902764a2aaSMatthew G. Knepley 59173107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5922764a2aaSMatthew G. Knepley 5932764a2aaSMatthew G. Knepley p->Nf = 0; 5942764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 59597b6e6e8SMatthew G. Knepley p->numConstants = 0; 59697b6e6e8SMatthew G. Knepley p->constants = NULL; 597a859676bSMatthew G. Knepley p->dimEmbed = -1; 59855c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5996528b96dSMatthew G. Knepley ierr = PetscWeakFormCreate(comm, &p->wf);CHKERRQ(ierr); 6002764a2aaSMatthew G. Knepley 6016528b96dSMatthew G. Knepley *ds = p; 6022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6032764a2aaSMatthew G. Knepley } 6042764a2aaSMatthew G. Knepley 605bc4ae4beSMatthew G. Knepley /*@ 606bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 607bc4ae4beSMatthew G. Knepley 608bc4ae4beSMatthew G. Knepley Not collective 609bc4ae4beSMatthew G. Knepley 610bc4ae4beSMatthew G. Knepley Input Parameter: 611bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 612bc4ae4beSMatthew G. Knepley 613bc4ae4beSMatthew G. Knepley Output Parameter: 614bc4ae4beSMatthew G. Knepley . Nf - The number of fields 615bc4ae4beSMatthew G. Knepley 616bc4ae4beSMatthew G. Knepley Level: beginner 617bc4ae4beSMatthew G. Knepley 618bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 619bc4ae4beSMatthew G. Knepley @*/ 6202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 6212764a2aaSMatthew G. Knepley { 6222764a2aaSMatthew G. Knepley PetscFunctionBegin; 6232764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6242764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 6252764a2aaSMatthew G. Knepley *Nf = prob->Nf; 6262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6272764a2aaSMatthew G. Knepley } 6282764a2aaSMatthew G. Knepley 629bc4ae4beSMatthew G. Knepley /*@ 630a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 631bc4ae4beSMatthew G. Knepley 632bc4ae4beSMatthew G. Knepley Not collective 633bc4ae4beSMatthew G. Knepley 634bc4ae4beSMatthew G. Knepley Input Parameter: 635bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 636bc4ae4beSMatthew G. Knepley 637bc4ae4beSMatthew G. Knepley Output Parameter: 638bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 639bc4ae4beSMatthew G. Knepley 640bc4ae4beSMatthew G. Knepley Level: beginner 641bc4ae4beSMatthew G. Knepley 642a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 643bc4ae4beSMatthew G. Knepley @*/ 6442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 6452764a2aaSMatthew G. Knepley { 6462764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6472764a2aaSMatthew G. Knepley 6482764a2aaSMatthew G. Knepley PetscFunctionBegin; 6492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6502764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6512764a2aaSMatthew G. Knepley *dim = 0; 6529de99aefSMatthew G. Knepley if (prob->Nf) { 6539de99aefSMatthew G. Knepley PetscObject obj; 6549de99aefSMatthew G. Knepley PetscClassId id; 6559de99aefSMatthew G. Knepley 6569de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 657665f567fSMatthew G. Knepley if (obj) { 6589de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 6599de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 6609de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 6619de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 6629de99aefSMatthew G. Knepley } 663665f567fSMatthew G. Knepley } 6642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6652764a2aaSMatthew G. Knepley } 6662764a2aaSMatthew G. Knepley 667bc4ae4beSMatthew G. Knepley /*@ 668a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 669a859676bSMatthew G. Knepley 670a859676bSMatthew G. Knepley Not collective 671a859676bSMatthew G. Knepley 672a859676bSMatthew G. Knepley Input Parameter: 673a859676bSMatthew G. Knepley . prob - The PetscDS object 674a859676bSMatthew G. Knepley 675a859676bSMatthew G. Knepley Output Parameter: 676a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 677a859676bSMatthew G. Knepley 678a859676bSMatthew G. Knepley Level: beginner 679a859676bSMatthew G. Knepley 680a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 681a859676bSMatthew G. Knepley @*/ 682a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 683a859676bSMatthew G. Knepley { 684a859676bSMatthew G. Knepley PetscFunctionBegin; 685a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 686a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 687a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 688a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 689a859676bSMatthew G. Knepley PetscFunctionReturn(0); 690a859676bSMatthew G. Knepley } 691a859676bSMatthew G. Knepley 692a859676bSMatthew G. Knepley /*@ 693a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 694a859676bSMatthew G. Knepley 695d083f849SBarry Smith Logically collective on prob 696a859676bSMatthew G. Knepley 697a859676bSMatthew G. Knepley Input Parameters: 698a859676bSMatthew G. Knepley + prob - The PetscDS object 699a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 700a859676bSMatthew G. Knepley 701a859676bSMatthew G. Knepley Level: beginner 702a859676bSMatthew G. Knepley 703a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 704a859676bSMatthew G. Knepley @*/ 705a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 706a859676bSMatthew G. Knepley { 707a859676bSMatthew G. Knepley PetscFunctionBegin; 708a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 709ebfe4b0dSMatthew G. Knepley if (dimEmbed < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Coordinate dimension must be non-negative, not %D", dimEmbed); 710a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 711a859676bSMatthew G. Knepley PetscFunctionReturn(0); 712a859676bSMatthew G. Knepley } 713a859676bSMatthew G. Knepley 714a859676bSMatthew G. Knepley /*@ 7158edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 7168edf6225SMatthew G. Knepley 7178edf6225SMatthew G. Knepley Not collective 7188edf6225SMatthew G. Knepley 7198edf6225SMatthew G. Knepley Input Parameter: 7208edf6225SMatthew G. Knepley . prob - The PetscDS object 7218edf6225SMatthew G. Knepley 7228edf6225SMatthew G. Knepley Output Parameter: 7238edf6225SMatthew G. Knepley . isHybrid - The flag 7248edf6225SMatthew G. Knepley 7258edf6225SMatthew G. Knepley Level: developer 7268edf6225SMatthew G. Knepley 7278edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 7288edf6225SMatthew G. Knepley @*/ 7298edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 7308edf6225SMatthew G. Knepley { 7318edf6225SMatthew G. Knepley PetscFunctionBegin; 7328edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7338edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 7348edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 7358edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7368edf6225SMatthew G. Knepley } 7378edf6225SMatthew G. Knepley 7388edf6225SMatthew G. Knepley /*@ 7398edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 7408edf6225SMatthew G. Knepley 7418edf6225SMatthew G. Knepley Not collective 7428edf6225SMatthew G. Knepley 7438edf6225SMatthew G. Knepley Input Parameters: 7448edf6225SMatthew G. Knepley + prob - The PetscDS object 7458edf6225SMatthew G. Knepley - isHybrid - The flag 7468edf6225SMatthew G. Knepley 7478edf6225SMatthew G. Knepley Level: developer 7488edf6225SMatthew G. Knepley 7498edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 7508edf6225SMatthew G. Knepley @*/ 7518edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 7528edf6225SMatthew G. Knepley { 7538edf6225SMatthew G. Knepley PetscFunctionBegin; 7548edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7558edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 7568edf6225SMatthew G. Knepley PetscFunctionReturn(0); 7578edf6225SMatthew G. Knepley } 7588edf6225SMatthew G. Knepley 7598edf6225SMatthew G. Knepley /*@ 760bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 761bc4ae4beSMatthew G. Knepley 762bc4ae4beSMatthew G. Knepley Not collective 763bc4ae4beSMatthew G. Knepley 764bc4ae4beSMatthew G. Knepley Input Parameter: 765bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 766bc4ae4beSMatthew G. Knepley 767bc4ae4beSMatthew G. Knepley Output Parameter: 768bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 769bc4ae4beSMatthew G. Knepley 770bc4ae4beSMatthew G. Knepley Level: beginner 771bc4ae4beSMatthew G. Knepley 772bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 773bc4ae4beSMatthew G. Knepley @*/ 7742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7752764a2aaSMatthew G. Knepley { 7762764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7772764a2aaSMatthew G. Knepley 7782764a2aaSMatthew G. Knepley PetscFunctionBegin; 7792764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7802764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7812764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 7822764a2aaSMatthew G. Knepley *dim = prob->totDim; 7832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7842764a2aaSMatthew G. Knepley } 7852764a2aaSMatthew G. Knepley 786bc4ae4beSMatthew G. Knepley /*@ 787bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 788bc4ae4beSMatthew G. Knepley 789bc4ae4beSMatthew G. Knepley Not collective 790bc4ae4beSMatthew G. Knepley 791bc4ae4beSMatthew G. Knepley Input Parameter: 792bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 793bc4ae4beSMatthew G. Knepley 794bc4ae4beSMatthew G. Knepley Output Parameter: 795bc4ae4beSMatthew G. Knepley . dim - The total number of components 796bc4ae4beSMatthew G. Knepley 797bc4ae4beSMatthew G. Knepley Level: beginner 798bc4ae4beSMatthew G. Knepley 799bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 800bc4ae4beSMatthew G. Knepley @*/ 8012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 8022764a2aaSMatthew G. Knepley { 8032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8042764a2aaSMatthew G. Knepley 8052764a2aaSMatthew G. Knepley PetscFunctionBegin; 8062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8072764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 8082764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 8092764a2aaSMatthew G. Knepley *Nc = prob->totComp; 8102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8112764a2aaSMatthew G. Knepley } 8122764a2aaSMatthew G. Knepley 813bc4ae4beSMatthew G. Knepley /*@ 814bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 815bc4ae4beSMatthew G. Knepley 816bc4ae4beSMatthew G. Knepley Not collective 817bc4ae4beSMatthew G. Knepley 818bc4ae4beSMatthew G. Knepley Input Parameters: 819bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 820bc4ae4beSMatthew G. Knepley - f - The field number 821bc4ae4beSMatthew G. Knepley 822bc4ae4beSMatthew G. Knepley Output Parameter: 823bc4ae4beSMatthew G. Knepley . disc - The discretization object 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley Level: beginner 826bc4ae4beSMatthew G. Knepley 827f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 828bc4ae4beSMatthew G. Knepley @*/ 8292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 8302764a2aaSMatthew G. Knepley { 8316528b96dSMatthew G. Knepley PetscFunctionBeginHot; 8322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8332764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 8342764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 8352764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 8362764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8372764a2aaSMatthew G. Knepley } 8382764a2aaSMatthew G. Knepley 839bc4ae4beSMatthew G. Knepley /*@ 840bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 841bc4ae4beSMatthew G. Knepley 842bc4ae4beSMatthew G. Knepley Not collective 843bc4ae4beSMatthew G. Knepley 844bc4ae4beSMatthew G. Knepley Input Parameters: 845bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 846bc4ae4beSMatthew G. Knepley . f - The field number 847bc4ae4beSMatthew G. Knepley - disc - The discretization object 848bc4ae4beSMatthew G. Knepley 849bc4ae4beSMatthew G. Knepley Level: beginner 850bc4ae4beSMatthew G. Knepley 851bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 852bc4ae4beSMatthew G. Knepley @*/ 8532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 8542764a2aaSMatthew G. Knepley { 8552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8562764a2aaSMatthew G. Knepley 8572764a2aaSMatthew G. Knepley PetscFunctionBegin; 8582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 859665f567fSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 8602764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 8612764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 862c10f2116SMatthew G. Knepley ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr); 8632764a2aaSMatthew G. Knepley prob->disc[f] = disc; 8642764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 865665f567fSMatthew G. Knepley if (disc) { 866249df284SMatthew G. Knepley PetscClassId id; 867249df284SMatthew G. Knepley 868249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8691cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8701cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8711cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8721cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 873a6cbbb48SMatthew G. Knepley } 874f9244615SMatthew G. Knepley ierr = PetscDSSetJetDegree(prob, f, 1);CHKERRQ(ierr); 875249df284SMatthew G. Knepley } 8762764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8772764a2aaSMatthew G. Knepley } 8782764a2aaSMatthew G. Knepley 879bc4ae4beSMatthew G. Knepley /*@ 8806528b96dSMatthew G. Knepley PetscDSGetWeakForm - Returns the weak form object 8816528b96dSMatthew G. Knepley 8826528b96dSMatthew G. Knepley Not collective 8836528b96dSMatthew G. Knepley 8846528b96dSMatthew G. Knepley Input Parameter: 8856528b96dSMatthew G. Knepley . ds - The PetscDS object 8866528b96dSMatthew G. Knepley 8876528b96dSMatthew G. Knepley Output Parameter: 8886528b96dSMatthew G. Knepley . wf - The weak form object 8896528b96dSMatthew G. Knepley 8906528b96dSMatthew G. Knepley Level: beginner 8916528b96dSMatthew G. Knepley 8926528b96dSMatthew G. Knepley .seealso: PetscDSSetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 8936528b96dSMatthew G. Knepley @*/ 8946528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetWeakForm(PetscDS ds, PetscWeakForm *wf) 8956528b96dSMatthew G. Knepley { 8966528b96dSMatthew G. Knepley PetscFunctionBegin; 8976528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 8986528b96dSMatthew G. Knepley PetscValidPointer(wf, 2); 8996528b96dSMatthew G. Knepley *wf = ds->wf; 9006528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9016528b96dSMatthew G. Knepley } 9026528b96dSMatthew G. Knepley 9036528b96dSMatthew G. Knepley /*@ 9046528b96dSMatthew G. Knepley PetscDSSetWeakForm - Sets the weak form object 9056528b96dSMatthew G. Knepley 9066528b96dSMatthew G. Knepley Not collective 9076528b96dSMatthew G. Knepley 9086528b96dSMatthew G. Knepley Input Parameters: 9096528b96dSMatthew G. Knepley + ds - The PetscDS object 9106528b96dSMatthew G. Knepley - wf - The weak form object 9116528b96dSMatthew G. Knepley 9126528b96dSMatthew G. Knepley Level: beginner 9136528b96dSMatthew G. Knepley 9146528b96dSMatthew G. Knepley .seealso: PetscDSGetWeakForm(), PetscDSGetNumFields(), PetscDSCreate() 9156528b96dSMatthew G. Knepley @*/ 9166528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetWeakForm(PetscDS ds, PetscWeakForm wf) 9176528b96dSMatthew G. Knepley { 9186528b96dSMatthew G. Knepley PetscErrorCode ierr; 9196528b96dSMatthew G. Knepley 9206528b96dSMatthew G. Knepley PetscFunctionBegin; 9216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 9226528b96dSMatthew G. Knepley PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 2); 9236528b96dSMatthew G. Knepley ierr = PetscObjectDereference((PetscObject) ds->wf);CHKERRQ(ierr); 9246528b96dSMatthew G. Knepley ds->wf = wf; 9256528b96dSMatthew G. Knepley ierr = PetscObjectReference((PetscObject) wf);CHKERRQ(ierr); 9266528b96dSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(wf, ds->Nf);CHKERRQ(ierr); 9276528b96dSMatthew G. Knepley PetscFunctionReturn(0); 9286528b96dSMatthew G. Knepley } 9296528b96dSMatthew G. Knepley 9306528b96dSMatthew G. Knepley /*@ 931bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 932bc4ae4beSMatthew G. Knepley 933bc4ae4beSMatthew G. Knepley Not collective 934bc4ae4beSMatthew G. Knepley 935bc4ae4beSMatthew G. Knepley Input Parameters: 936bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 937bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 938bc4ae4beSMatthew G. Knepley 939bc4ae4beSMatthew G. Knepley Level: beginner 940bc4ae4beSMatthew G. Knepley 941bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 942bc4ae4beSMatthew G. Knepley @*/ 9432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 9442764a2aaSMatthew G. Knepley { 9452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9462764a2aaSMatthew G. Knepley 9472764a2aaSMatthew G. Knepley PetscFunctionBegin; 9482764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 9492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9502764a2aaSMatthew G. Knepley } 9512764a2aaSMatthew G. Knepley 952249df284SMatthew G. Knepley /*@ 953083401c6SMatthew G. Knepley PetscDSGetQuadrature - Returns the quadrature, which must agree for all fields in the DS 954083401c6SMatthew G. Knepley 955083401c6SMatthew G. Knepley Not collective 956083401c6SMatthew G. Knepley 957083401c6SMatthew G. Knepley Input Parameter: 958083401c6SMatthew G. Knepley . prob - The PetscDS object 959083401c6SMatthew G. Knepley 960083401c6SMatthew G. Knepley Output Parameter: 961083401c6SMatthew G. Knepley . q - The quadrature object 962083401c6SMatthew G. Knepley 963083401c6SMatthew G. Knepley Level: intermediate 964083401c6SMatthew G. Knepley 965083401c6SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 966083401c6SMatthew G. Knepley @*/ 967083401c6SMatthew G. Knepley PetscErrorCode PetscDSGetQuadrature(PetscDS prob, PetscQuadrature *q) 968083401c6SMatthew G. Knepley { 969083401c6SMatthew G. Knepley PetscObject obj; 970083401c6SMatthew G. Knepley PetscClassId id; 971083401c6SMatthew G. Knepley PetscErrorCode ierr; 972083401c6SMatthew G. Knepley 973083401c6SMatthew G. Knepley PetscFunctionBegin; 974083401c6SMatthew G. Knepley *q = NULL; 975083401c6SMatthew G. Knepley if (!prob->Nf) PetscFunctionReturn(0); 976083401c6SMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 977083401c6SMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 978083401c6SMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetQuadrature((PetscFE) obj, q);CHKERRQ(ierr);} 979083401c6SMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetQuadrature((PetscFV) obj, q);CHKERRQ(ierr);} 980083401c6SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 981083401c6SMatthew G. Knepley PetscFunctionReturn(0); 982083401c6SMatthew G. Knepley } 983083401c6SMatthew G. Knepley 984083401c6SMatthew G. Knepley /*@ 985249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 986249df284SMatthew G. Knepley 987249df284SMatthew G. Knepley Not collective 988249df284SMatthew G. Knepley 989249df284SMatthew G. Knepley Input Parameters: 990249df284SMatthew G. Knepley + prob - The PetscDS object 991249df284SMatthew G. Knepley - f - The field number 992249df284SMatthew G. Knepley 993249df284SMatthew G. Knepley Output Parameter: 994249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 995249df284SMatthew G. Knepley 996249df284SMatthew G. Knepley Level: developer 997249df284SMatthew G. Knepley 998f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 999249df284SMatthew G. Knepley @*/ 1000249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 1001249df284SMatthew G. Knepley { 1002249df284SMatthew G. Knepley PetscFunctionBegin; 1003249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1004249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 1005249df284SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1006249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 1007249df284SMatthew G. Knepley PetscFunctionReturn(0); 1008249df284SMatthew G. Knepley } 1009249df284SMatthew G. Knepley 1010249df284SMatthew G. Knepley /*@ 1011249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 1012249df284SMatthew G. Knepley 1013249df284SMatthew G. Knepley Not collective 1014249df284SMatthew G. Knepley 1015249df284SMatthew G. Knepley Input Parameters: 1016249df284SMatthew G. Knepley + prob - The PetscDS object 1017249df284SMatthew G. Knepley . f - The field number 1018249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 1019249df284SMatthew G. Knepley 1020249df284SMatthew G. Knepley Level: developer 1021249df284SMatthew G. Knepley 1022f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1023249df284SMatthew G. Knepley @*/ 1024249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 1025249df284SMatthew G. Knepley { 1026249df284SMatthew G. Knepley PetscFunctionBegin; 1027249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1028249df284SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 1029249df284SMatthew G. Knepley prob->implicit[f] = implicit; 1030249df284SMatthew G. Knepley PetscFunctionReturn(0); 1031249df284SMatthew G. Knepley } 1032249df284SMatthew G. Knepley 1033f9244615SMatthew G. Knepley /*@ 1034f9244615SMatthew G. Knepley PetscDSGetJetDegree - Returns the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1035f9244615SMatthew G. Knepley 1036f9244615SMatthew G. Knepley Not collective 1037f9244615SMatthew G. Knepley 1038f9244615SMatthew G. Knepley Input Parameters: 1039f9244615SMatthew G. Knepley + ds - The PetscDS object 1040f9244615SMatthew G. Knepley - f - The field number 1041f9244615SMatthew G. Knepley 1042f9244615SMatthew G. Knepley Output Parameter: 1043f9244615SMatthew G. Knepley . k - The highest derivative we need to tabulate 1044f9244615SMatthew G. Knepley 1045f9244615SMatthew G. Knepley Level: developer 1046f9244615SMatthew G. Knepley 1047f9244615SMatthew G. Knepley .seealso: PetscDSSetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1048f9244615SMatthew G. Knepley @*/ 1049f9244615SMatthew G. Knepley PetscErrorCode PetscDSGetJetDegree(PetscDS ds, PetscInt f, PetscInt *k) 1050f9244615SMatthew G. Knepley { 1051f9244615SMatthew G. Knepley PetscFunctionBegin; 1052f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1053f9244615SMatthew G. Knepley PetscValidPointer(k, 3); 1054f9244615SMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1055f9244615SMatthew G. Knepley *k = ds->jetDegree[f]; 1056f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1057f9244615SMatthew G. Knepley } 1058f9244615SMatthew G. Knepley 1059f9244615SMatthew G. Knepley /*@ 1060f9244615SMatthew G. Knepley PetscDSSetJetDegree - Set the highest derivative for this field equation, or the k-jet that the discretization needs to tabulate. 1061f9244615SMatthew G. Knepley 1062f9244615SMatthew G. Knepley Not collective 1063f9244615SMatthew G. Knepley 1064f9244615SMatthew G. Knepley Input Parameters: 1065f9244615SMatthew G. Knepley + ds - The PetscDS object 1066f9244615SMatthew G. Knepley . f - The field number 1067f9244615SMatthew G. Knepley - k - The highest derivative we need to tabulate 1068f9244615SMatthew G. Knepley 1069f9244615SMatthew G. Knepley Level: developer 1070f9244615SMatthew G. Knepley 1071f9244615SMatthew G. Knepley .seealso: PetscDSGetJetDegree(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 1072f9244615SMatthew G. Knepley @*/ 1073f9244615SMatthew G. Knepley PetscErrorCode PetscDSSetJetDegree(PetscDS ds, PetscInt f, PetscInt k) 1074f9244615SMatthew G. Knepley { 1075f9244615SMatthew G. Knepley PetscFunctionBegin; 1076f9244615SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1077f9244615SMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 1078f9244615SMatthew G. Knepley ds->jetDegree[f] = k; 1079f9244615SMatthew G. Knepley PetscFunctionReturn(0); 1080f9244615SMatthew G. Knepley } 1081f9244615SMatthew G. Knepley 10826528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS ds, PetscInt f, 108330b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1084194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1085194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 10872764a2aaSMatthew G. Knepley { 10886528b96dSMatthew G. Knepley PetscPointFunc *tmp; 10896528b96dSMatthew G. Knepley PetscInt n; 10906528b96dSMatthew G. Knepley PetscErrorCode ierr; 10916528b96dSMatthew G. Knepley 10922764a2aaSMatthew G. Knepley PetscFunctionBegin; 10936528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 10946528b96dSMatthew G. Knepley PetscValidPointer(obj, 3); 10956528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 109606ad1575SMatthew G. Knepley ierr = PetscWeakFormGetObjective(ds->wf, NULL, 0, f, 0, &n, &tmp);CHKERRQ(ierr); 10976528b96dSMatthew G. Knepley *obj = tmp ? tmp[0] : NULL; 10982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10992764a2aaSMatthew G. Knepley } 11002764a2aaSMatthew G. Knepley 11016528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS ds, PetscInt f, 110230b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1103194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1104194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 11062764a2aaSMatthew G. Knepley { 11072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11082764a2aaSMatthew G. Knepley 11092764a2aaSMatthew G. Knepley PetscFunctionBegin; 11106528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11116528b96dSMatthew G. Knepley if (obj) PetscValidFunction(obj, 3); 11122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 111306ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexObjective(ds->wf, NULL, 0, f, 0, 0, obj);CHKERRQ(ierr); 11142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11152764a2aaSMatthew G. Knepley } 11162764a2aaSMatthew G. Knepley 1117194d53e6SMatthew G. Knepley /*@C 1118194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 1119194d53e6SMatthew G. Knepley 1120194d53e6SMatthew G. Knepley Not collective 1121194d53e6SMatthew G. Knepley 1122194d53e6SMatthew G. Knepley Input Parameters: 11236528b96dSMatthew G. Knepley + ds - The PetscDS 1124194d53e6SMatthew G. Knepley - f - The test field number 1125194d53e6SMatthew G. Knepley 1126194d53e6SMatthew G. Knepley Output Parameters: 1127194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1128194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1129194d53e6SMatthew G. Knepley 1130194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1131194d53e6SMatthew G. Knepley 1132194d53e6SMatthew G. Knepley \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t) 1133194d53e6SMatthew G. Knepley 1134194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1135194d53e6SMatthew G. Knepley 113630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1137194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1138194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 113930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1140194d53e6SMatthew G. Knepley 1141194d53e6SMatthew G. Knepley + dim - the spatial dimension 1142194d53e6SMatthew G. Knepley . Nf - the number of fields 1143194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1144194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1145194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1146194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1147194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1148194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1149194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1150194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1151194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1152194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1153194d53e6SMatthew G. Knepley . t - current time 1154194d53e6SMatthew G. Knepley . x - coordinates of the current point 115597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 115697b6e6e8SMatthew G. Knepley . constants - constant parameters 1157194d53e6SMatthew G. Knepley - f0 - output values at the current point 1158194d53e6SMatthew G. Knepley 1159194d53e6SMatthew G. Knepley Level: intermediate 1160194d53e6SMatthew G. Knepley 1161194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1162194d53e6SMatthew G. Knepley @*/ 11636528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS ds, PetscInt f, 116430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1165194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1166194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 116830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1169194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1170194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11722764a2aaSMatthew G. Knepley { 11736528b96dSMatthew G. Knepley PetscPointFunc *tmp0, *tmp1; 11746528b96dSMatthew G. Knepley PetscInt n0, n1; 11756528b96dSMatthew G. Knepley PetscErrorCode ierr; 11766528b96dSMatthew G. Knepley 11772764a2aaSMatthew G. Knepley PetscFunctionBegin; 11786528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 11796528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 118006ad1575SMatthew G. Knepley ierr = PetscWeakFormGetResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1);CHKERRQ(ierr); 11816528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 11826528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 11832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11842764a2aaSMatthew G. Knepley } 11852764a2aaSMatthew G. Knepley 1186194d53e6SMatthew G. Knepley /*@C 1187194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1188194d53e6SMatthew G. Knepley 1189194d53e6SMatthew G. Knepley Not collective 1190194d53e6SMatthew G. Knepley 1191194d53e6SMatthew G. Knepley Input Parameters: 11926528b96dSMatthew G. Knepley + ds - The PetscDS 1193194d53e6SMatthew G. Knepley . f - The test field number 1194194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1195194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1196194d53e6SMatthew G. Knepley 1197194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1198194d53e6SMatthew G. Knepley 1199194d53e6SMatthew G. Knepley \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t) 1200194d53e6SMatthew G. Knepley 1201194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1202194d53e6SMatthew G. Knepley 120330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1204194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1205194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1207194d53e6SMatthew G. Knepley 1208194d53e6SMatthew G. Knepley + dim - the spatial dimension 1209194d53e6SMatthew G. Knepley . Nf - the number of fields 1210194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1211194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1212194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1213194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1214194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1215194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1216194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1217194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1218194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1219194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1220194d53e6SMatthew G. Knepley . t - current time 1221194d53e6SMatthew G. Knepley . x - coordinates of the current point 122297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 122397b6e6e8SMatthew G. Knepley . constants - constant parameters 1224194d53e6SMatthew G. Knepley - f0 - output values at the current point 1225194d53e6SMatthew G. Knepley 1226194d53e6SMatthew G. Knepley Level: intermediate 1227194d53e6SMatthew G. Knepley 1228194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1229194d53e6SMatthew G. Knepley @*/ 12306528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS ds, PetscInt f, 123130b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1232194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1233194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 123530b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1236194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1237194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 12392764a2aaSMatthew G. Knepley { 12402764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12412764a2aaSMatthew G. Knepley 12422764a2aaSMatthew G. Knepley PetscFunctionBegin; 12436528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1244f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1245f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 12462764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 124706ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1);CHKERRQ(ierr); 12482764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12492764a2aaSMatthew G. Knepley } 12502764a2aaSMatthew G. Knepley 12513e75805dSMatthew G. Knepley /*@C 12523e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 12533e75805dSMatthew G. Knepley 12543e75805dSMatthew G. Knepley Not collective 12553e75805dSMatthew G. Knepley 12563e75805dSMatthew G. Knepley Input Parameter: 12573e75805dSMatthew G. Knepley . prob - The PetscDS 12583e75805dSMatthew G. Knepley 12593e75805dSMatthew G. Knepley Output Parameter: 12603e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 12613e75805dSMatthew G. Knepley 12623e75805dSMatthew G. Knepley Level: intermediate 12633e75805dSMatthew G. Knepley 12643e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 12653e75805dSMatthew G. Knepley @*/ 12666528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS ds, PetscBool *hasJac) 12673e75805dSMatthew G. Knepley { 12686528b96dSMatthew G. Knepley PetscErrorCode ierr; 12693e75805dSMatthew G. Knepley 12703e75805dSMatthew G. Knepley PetscFunctionBegin; 12716528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 12726528b96dSMatthew G. Knepley ierr = PetscWeakFormHasJacobian(ds->wf, hasJac);CHKERRQ(ierr); 12733e75805dSMatthew G. Knepley PetscFunctionReturn(0); 12743e75805dSMatthew G. Knepley } 12753e75805dSMatthew G. Knepley 1276194d53e6SMatthew G. Knepley /*@C 1277194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1278194d53e6SMatthew G. Knepley 1279194d53e6SMatthew G. Knepley Not collective 1280194d53e6SMatthew G. Knepley 1281194d53e6SMatthew G. Knepley Input Parameters: 12826528b96dSMatthew G. Knepley + ds - The PetscDS 1283194d53e6SMatthew G. Knepley . f - The test field number 1284194d53e6SMatthew G. Knepley - g - The field number 1285194d53e6SMatthew G. Knepley 1286194d53e6SMatthew G. Knepley Output Parameters: 1287194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1288194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1289194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1290194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1291194d53e6SMatthew G. Knepley 1292194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1293194d53e6SMatthew G. Knepley 1294194d53e6SMatthew 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 1295194d53e6SMatthew G. Knepley 1296194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1297194d53e6SMatthew G. Knepley 129830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1299194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1300194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 130130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1302194d53e6SMatthew G. Knepley 1303194d53e6SMatthew G. Knepley + dim - the spatial dimension 1304194d53e6SMatthew G. Knepley . Nf - the number of fields 1305194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1306194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1307194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1308194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1309194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1310194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1311194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1312194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1313194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1314194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1315194d53e6SMatthew G. Knepley . t - current time 13162aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1317194d53e6SMatthew G. Knepley . x - coordinates of the current point 131897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 131997b6e6e8SMatthew G. Knepley . constants - constant parameters 1320194d53e6SMatthew G. Knepley - g0 - output values at the current point 1321194d53e6SMatthew G. Knepley 1322194d53e6SMatthew G. Knepley Level: intermediate 1323194d53e6SMatthew G. Knepley 1324194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1325194d53e6SMatthew G. Knepley @*/ 13266528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS ds, PetscInt f, PetscInt g, 132730b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1328194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1329194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 133130b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1332194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1333194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 133530b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1336194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1337194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 133897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 133930b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1340194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1341194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 134297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 13432764a2aaSMatthew G. Knepley { 13446528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 13456528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 13466528b96dSMatthew G. Knepley PetscErrorCode ierr; 13476528b96dSMatthew G. Knepley 13482764a2aaSMatthew G. Knepley PetscFunctionBegin; 13496528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 13506528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 13516528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 135206ad1575SMatthew G. Knepley ierr = PetscWeakFormGetJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 13536528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 13546528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 13556528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 13566528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 13572764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13582764a2aaSMatthew G. Knepley } 13592764a2aaSMatthew G. Knepley 1360194d53e6SMatthew G. Knepley /*@C 1361194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1362194d53e6SMatthew G. Knepley 1363194d53e6SMatthew G. Knepley Not collective 1364194d53e6SMatthew G. Knepley 1365194d53e6SMatthew G. Knepley Input Parameters: 13666528b96dSMatthew G. Knepley + ds - The PetscDS 1367194d53e6SMatthew G. Knepley . f - The test field number 1368194d53e6SMatthew G. Knepley . g - The field number 1369194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1370194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1371194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1372194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1373194d53e6SMatthew G. Knepley 1374194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1375194d53e6SMatthew G. Knepley 1376194d53e6SMatthew 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 1377194d53e6SMatthew G. Knepley 1378194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1379194d53e6SMatthew G. Knepley 138030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1381194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1382194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 138330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1384194d53e6SMatthew G. Knepley 1385194d53e6SMatthew G. Knepley + dim - the spatial dimension 1386194d53e6SMatthew G. Knepley . Nf - the number of fields 1387194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1388194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1389194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1390194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1391194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1392194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1393194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1394194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1395194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1396194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1397194d53e6SMatthew G. Knepley . t - current time 13982aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1399194d53e6SMatthew G. Knepley . x - coordinates of the current point 140097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 140197b6e6e8SMatthew G. Knepley . constants - constant parameters 1402194d53e6SMatthew G. Knepley - g0 - output values at the current point 1403194d53e6SMatthew G. Knepley 1404194d53e6SMatthew G. Knepley Level: intermediate 1405194d53e6SMatthew G. Knepley 1406194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1407194d53e6SMatthew G. Knepley @*/ 14086528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS ds, PetscInt f, PetscInt g, 140930b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1410194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1411194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 141297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 141330b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1414194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1415194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 141697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 141730b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1418194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1419194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 142130b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1422194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1423194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 14252764a2aaSMatthew G. Knepley { 14262764a2aaSMatthew G. Knepley PetscErrorCode ierr; 14272764a2aaSMatthew G. Knepley 14282764a2aaSMatthew G. Knepley PetscFunctionBegin; 14296528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 14302764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 14312764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 14322764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 14332764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 14342764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 14352764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 143606ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 14372764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14382764a2aaSMatthew G. Knepley } 14392764a2aaSMatthew G. Knepley 1440475e0ac9SMatthew G. Knepley /*@C 144155c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 144255c1f793SMatthew G. Knepley 144355c1f793SMatthew G. Knepley Not collective 144455c1f793SMatthew G. Knepley 144555c1f793SMatthew G. Knepley Input Parameters: 144655c1f793SMatthew G. Knepley + prob - The PetscDS 144755c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 144855c1f793SMatthew G. Knepley 144955c1f793SMatthew G. Knepley Level: intermediate 145055c1f793SMatthew G. Knepley 145155c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 145255c1f793SMatthew G. Knepley @*/ 145355c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 145455c1f793SMatthew G. Knepley { 145555c1f793SMatthew G. Knepley PetscFunctionBegin; 145655c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 145755c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 145855c1f793SMatthew G. Knepley PetscFunctionReturn(0); 145955c1f793SMatthew G. Knepley } 146055c1f793SMatthew G. Knepley 146155c1f793SMatthew G. Knepley /*@C 1462475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1463475e0ac9SMatthew G. Knepley 1464475e0ac9SMatthew G. Knepley Not collective 1465475e0ac9SMatthew G. Knepley 1466475e0ac9SMatthew G. Knepley Input Parameter: 1467475e0ac9SMatthew G. Knepley . prob - The PetscDS 1468475e0ac9SMatthew G. Knepley 1469475e0ac9SMatthew G. Knepley Output Parameter: 1470475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1471475e0ac9SMatthew G. Knepley 1472475e0ac9SMatthew G. Knepley Level: intermediate 1473475e0ac9SMatthew G. Knepley 1474475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1475475e0ac9SMatthew G. Knepley @*/ 14766528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS ds, PetscBool *hasJacPre) 1477475e0ac9SMatthew G. Knepley { 14786528b96dSMatthew G. Knepley PetscErrorCode ierr; 1479475e0ac9SMatthew G. Knepley 1480475e0ac9SMatthew G. Knepley PetscFunctionBegin; 14816528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1482475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 14836528b96dSMatthew G. Knepley if (!ds->useJacPre) PetscFunctionReturn(0); 14846528b96dSMatthew G. Knepley ierr = PetscWeakFormHasJacobianPreconditioner(ds->wf, hasJacPre);CHKERRQ(ierr); 1485475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1486475e0ac9SMatthew G. Knepley } 1487475e0ac9SMatthew G. Knepley 1488475e0ac9SMatthew G. Knepley /*@C 1489475e0ac9SMatthew 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. 1490475e0ac9SMatthew G. Knepley 1491475e0ac9SMatthew G. Knepley Not collective 1492475e0ac9SMatthew G. Knepley 1493475e0ac9SMatthew G. Knepley Input Parameters: 14946528b96dSMatthew G. Knepley + ds - The PetscDS 1495475e0ac9SMatthew G. Knepley . f - The test field number 1496475e0ac9SMatthew G. Knepley - g - The field number 1497475e0ac9SMatthew G. Knepley 1498475e0ac9SMatthew G. Knepley Output Parameters: 1499475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1500475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1501475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1502475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1503475e0ac9SMatthew G. Knepley 1504475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1505475e0ac9SMatthew G. Knepley 1506475e0ac9SMatthew 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 1507475e0ac9SMatthew G. Knepley 1508475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1509475e0ac9SMatthew G. Knepley 1510475e0ac9SMatthew G. Knepley $ g0(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[], 1513475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1514475e0ac9SMatthew G. Knepley 1515475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1516475e0ac9SMatthew G. Knepley . Nf - the number of fields 1517475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1518475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1519475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1520475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1521475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1522475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1523475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1524475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1525475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1526475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1527475e0ac9SMatthew G. Knepley . t - current time 1528475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1529475e0ac9SMatthew G. Knepley . x - coordinates of the current point 153097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 153197b6e6e8SMatthew G. Knepley . constants - constant parameters 1532475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1533475e0ac9SMatthew G. Knepley 1534475e0ac9SMatthew G. Knepley Level: intermediate 1535475e0ac9SMatthew G. Knepley 1536475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1537475e0ac9SMatthew G. Knepley @*/ 15386528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1539475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1540475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1541475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1543475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1544475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1545475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 154697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1547475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1548475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1549475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1551475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1552475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1553475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 155497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1555475e0ac9SMatthew G. Knepley { 15566528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 15576528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 15586528b96dSMatthew G. Knepley PetscErrorCode ierr; 15596528b96dSMatthew G. Knepley 1560475e0ac9SMatthew G. Knepley PetscFunctionBegin; 15616528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 15626528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 15636528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 156406ad1575SMatthew G. Knepley ierr = PetscWeakFormGetJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 15656528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 15666528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 15676528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 15686528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1569475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1570475e0ac9SMatthew G. Knepley } 1571475e0ac9SMatthew G. Knepley 1572475e0ac9SMatthew G. Knepley /*@C 1573475e0ac9SMatthew 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. 1574475e0ac9SMatthew G. Knepley 1575475e0ac9SMatthew G. Knepley Not collective 1576475e0ac9SMatthew G. Knepley 1577475e0ac9SMatthew G. Knepley Input Parameters: 15786528b96dSMatthew G. Knepley + ds - The PetscDS 1579475e0ac9SMatthew G. Knepley . f - The test field number 1580475e0ac9SMatthew G. Knepley . g - The field number 1581475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1582475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1583475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1584475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1585475e0ac9SMatthew G. Knepley 1586475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1587475e0ac9SMatthew G. Knepley 1588475e0ac9SMatthew 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 1589475e0ac9SMatthew G. Knepley 1590475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1591475e0ac9SMatthew G. Knepley 1592475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1593475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1594475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1595475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1596475e0ac9SMatthew G. Knepley 1597475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1598475e0ac9SMatthew G. Knepley . Nf - the number of fields 1599475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1600475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1601475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1602475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1603475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1604475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1605475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1606475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1607475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1608475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1609475e0ac9SMatthew G. Knepley . t - current time 1610475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1611475e0ac9SMatthew G. Knepley . x - coordinates of the current point 161297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 161397b6e6e8SMatthew G. Knepley . constants - constant parameters 1614475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1615475e0ac9SMatthew G. Knepley 1616475e0ac9SMatthew G. Knepley Level: intermediate 1617475e0ac9SMatthew G. Knepley 1618475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1619475e0ac9SMatthew G. Knepley @*/ 16206528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 1621475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1622475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1623475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1625475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1626475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1627475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1629475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1630475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1631475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 163297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1633475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1634475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1635475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 163697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1637475e0ac9SMatthew G. Knepley { 1638475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1639475e0ac9SMatthew G. Knepley 1640475e0ac9SMatthew G. Knepley PetscFunctionBegin; 16416528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1642475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1643475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1644475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1645475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1646475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1647475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 164806ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 1649475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1650475e0ac9SMatthew G. Knepley } 1651475e0ac9SMatthew G. Knepley 1652b7e05686SMatthew G. Knepley /*@C 1653b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1654b7e05686SMatthew G. Knepley 1655b7e05686SMatthew G. Knepley Not collective 1656b7e05686SMatthew G. Knepley 1657b7e05686SMatthew G. Knepley Input Parameter: 16586528b96dSMatthew G. Knepley . ds - The PetscDS 1659b7e05686SMatthew G. Knepley 1660b7e05686SMatthew G. Knepley Output Parameter: 1661b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1662b7e05686SMatthew G. Knepley 1663b7e05686SMatthew G. Knepley Level: intermediate 1664b7e05686SMatthew G. Knepley 1665b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1666b7e05686SMatthew G. Knepley @*/ 16676528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS ds, PetscBool *hasDynJac) 1668b7e05686SMatthew G. Knepley { 16696528b96dSMatthew G. Knepley PetscErrorCode ierr; 1670b7e05686SMatthew G. Knepley 1671b7e05686SMatthew G. Knepley PetscFunctionBegin; 16726528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 16736528b96dSMatthew G. Knepley ierr = PetscWeakFormHasDynamicJacobian(ds->wf, hasDynJac);CHKERRQ(ierr); 1674b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1675b7e05686SMatthew G. Knepley } 1676b7e05686SMatthew G. Knepley 1677b7e05686SMatthew G. Knepley /*@C 1678b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1679b7e05686SMatthew G. Knepley 1680b7e05686SMatthew G. Knepley Not collective 1681b7e05686SMatthew G. Knepley 1682b7e05686SMatthew G. Knepley Input Parameters: 16836528b96dSMatthew G. Knepley + ds - The PetscDS 1684b7e05686SMatthew G. Knepley . f - The test field number 1685b7e05686SMatthew G. Knepley - g - The field number 1686b7e05686SMatthew G. Knepley 1687b7e05686SMatthew G. Knepley Output Parameters: 1688b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1689b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1690b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1691b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1692b7e05686SMatthew G. Knepley 1693b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1694b7e05686SMatthew G. Knepley 1695b7e05686SMatthew 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 1696b7e05686SMatthew G. Knepley 1697b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1698b7e05686SMatthew G. Knepley 1699b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1700b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1701b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1702b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1703b7e05686SMatthew G. Knepley 1704b7e05686SMatthew G. Knepley + dim - the spatial dimension 1705b7e05686SMatthew G. Knepley . Nf - the number of fields 1706b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1707b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1708b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1709b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1710b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1711b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1712b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1713b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1714b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1715b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1716b7e05686SMatthew G. Knepley . t - current time 1717b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1718b7e05686SMatthew G. Knepley . x - coordinates of the current point 171997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 172097b6e6e8SMatthew G. Knepley . constants - constant parameters 1721b7e05686SMatthew G. Knepley - g0 - output values at the current point 1722b7e05686SMatthew G. Knepley 1723b7e05686SMatthew G. Knepley Level: intermediate 1724b7e05686SMatthew G. Knepley 1725b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1726b7e05686SMatthew G. Knepley @*/ 17276528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1728b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1729b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1730b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 173197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1732b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1733b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1734b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 173597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1736b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1737b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1738b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 173997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1740b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1741b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1742b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 174397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1744b7e05686SMatthew G. Knepley { 17456528b96dSMatthew G. Knepley PetscPointJac *tmp0, *tmp1, *tmp2, *tmp3; 17466528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 17476528b96dSMatthew G. Knepley PetscErrorCode ierr; 17486528b96dSMatthew G. Knepley 1749b7e05686SMatthew G. Knepley PetscFunctionBegin; 17506528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 17516528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 17526528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 175306ad1575SMatthew G. Knepley ierr = PetscWeakFormGetDynamicJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 17546528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 17556528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 17566528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 17576528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 1758b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1759b7e05686SMatthew G. Knepley } 1760b7e05686SMatthew G. Knepley 1761b7e05686SMatthew G. Knepley /*@C 1762b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1763b7e05686SMatthew G. Knepley 1764b7e05686SMatthew G. Knepley Not collective 1765b7e05686SMatthew G. Knepley 1766b7e05686SMatthew G. Knepley Input Parameters: 17676528b96dSMatthew G. Knepley + ds - The PetscDS 1768b7e05686SMatthew G. Knepley . f - The test field number 1769b7e05686SMatthew G. Knepley . g - The field number 1770b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1771b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1772b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1773b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1774b7e05686SMatthew G. Knepley 1775b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1776b7e05686SMatthew G. Knepley 1777b7e05686SMatthew 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 1778b7e05686SMatthew G. Knepley 1779b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1780b7e05686SMatthew G. Knepley 1781b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1782b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1783b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1784b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1785b7e05686SMatthew G. Knepley 1786b7e05686SMatthew G. Knepley + dim - the spatial dimension 1787b7e05686SMatthew G. Knepley . Nf - the number of fields 1788b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1789b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1790b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1791b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1792b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1793b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1794b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1795b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1796b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1797b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1798b7e05686SMatthew G. Knepley . t - current time 1799b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1800b7e05686SMatthew G. Knepley . x - coordinates of the current point 180197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 180297b6e6e8SMatthew G. Knepley . constants - constant parameters 1803b7e05686SMatthew G. Knepley - g0 - output values at the current point 1804b7e05686SMatthew G. Knepley 1805b7e05686SMatthew G. Knepley Level: intermediate 1806b7e05686SMatthew G. Knepley 1807b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1808b7e05686SMatthew G. Knepley @*/ 18096528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS ds, PetscInt f, PetscInt g, 1810b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1811b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1812b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 181397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1814b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1815b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1816b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 181797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1818b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1819b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1820b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1822b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1823b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1824b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1826b7e05686SMatthew G. Knepley { 1827b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1828b7e05686SMatthew G. Knepley 1829b7e05686SMatthew G. Knepley PetscFunctionBegin; 18306528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1831b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1832b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1833b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1834b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1835b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1836b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 183706ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexDynamicJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 1838b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1839b7e05686SMatthew G. Knepley } 1840b7e05686SMatthew G. Knepley 18410c2f2876SMatthew G. Knepley /*@C 18420c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 18430c2f2876SMatthew G. Knepley 18440c2f2876SMatthew G. Knepley Not collective 18450c2f2876SMatthew G. Knepley 18460c2f2876SMatthew G. Knepley Input Arguments: 18476528b96dSMatthew G. Knepley + ds - The PetscDS object 18480c2f2876SMatthew G. Knepley - f - The field number 18490c2f2876SMatthew G. Knepley 18500c2f2876SMatthew G. Knepley Output Argument: 18510c2f2876SMatthew G. Knepley . r - Riemann solver 18520c2f2876SMatthew G. Knepley 18530c2f2876SMatthew G. Knepley Calling sequence for r: 18540c2f2876SMatthew G. Knepley 18555db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 18560c2f2876SMatthew G. Knepley 18575db36cf9SMatthew G. Knepley + dim - The spatial dimension 18585db36cf9SMatthew G. Knepley . Nf - The number of fields 18595db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 18600c2f2876SMatthew G. Knepley . n - The normal vector to the interface 18610c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 18620c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 18630c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 186497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 186597b6e6e8SMatthew G. Knepley . constants - constant parameters 18660c2f2876SMatthew G. Knepley - ctx - optional user context 18670c2f2876SMatthew G. Knepley 18680c2f2876SMatthew G. Knepley Level: intermediate 18690c2f2876SMatthew G. Knepley 18700c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 18710c2f2876SMatthew G. Knepley @*/ 18726528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS ds, PetscInt f, 187397b6e6e8SMatthew 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)) 18740c2f2876SMatthew G. Knepley { 18756528b96dSMatthew G. Knepley PetscRiemannFunc *tmp; 18766528b96dSMatthew G. Knepley PetscInt n; 18776528b96dSMatthew G. Knepley PetscErrorCode ierr; 18786528b96dSMatthew G. Knepley 18790c2f2876SMatthew G. Knepley PetscFunctionBegin; 18806528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 18810c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 18826528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 188306ad1575SMatthew G. Knepley ierr = PetscWeakFormGetRiemannSolver(ds->wf, NULL, 0, f, 0, &n, &tmp);CHKERRQ(ierr); 18846528b96dSMatthew G. Knepley *r = tmp ? tmp[0] : NULL; 18850c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18860c2f2876SMatthew G. Knepley } 18870c2f2876SMatthew G. Knepley 18880c2f2876SMatthew G. Knepley /*@C 18890c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 18900c2f2876SMatthew G. Knepley 18910c2f2876SMatthew G. Knepley Not collective 18920c2f2876SMatthew G. Knepley 18930c2f2876SMatthew G. Knepley Input Arguments: 18946528b96dSMatthew G. Knepley + ds - The PetscDS object 18950c2f2876SMatthew G. Knepley . f - The field number 18960c2f2876SMatthew G. Knepley - r - Riemann solver 18970c2f2876SMatthew G. Knepley 18980c2f2876SMatthew G. Knepley Calling sequence for r: 18990c2f2876SMatthew G. Knepley 19005db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 19010c2f2876SMatthew G. Knepley 19025db36cf9SMatthew G. Knepley + dim - The spatial dimension 19035db36cf9SMatthew G. Knepley . Nf - The number of fields 19045db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 19050c2f2876SMatthew G. Knepley . n - The normal vector to the interface 19060c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 19070c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 19080c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 190997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 191097b6e6e8SMatthew G. Knepley . constants - constant parameters 19110c2f2876SMatthew G. Knepley - ctx - optional user context 19120c2f2876SMatthew G. Knepley 19130c2f2876SMatthew G. Knepley Level: intermediate 19140c2f2876SMatthew G. Knepley 19150c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 19160c2f2876SMatthew G. Knepley @*/ 19176528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS ds, PetscInt f, 191897b6e6e8SMatthew 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)) 19190c2f2876SMatthew G. Knepley { 19200c2f2876SMatthew G. Knepley PetscErrorCode ierr; 19210c2f2876SMatthew G. Knepley 19220c2f2876SMatthew G. Knepley PetscFunctionBegin; 19236528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 1924de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 19250c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 192606ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexRiemannSolver(ds->wf, NULL, 0, f, 0, 0, r);CHKERRQ(ierr); 19270c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19280c2f2876SMatthew G. Knepley } 19290c2f2876SMatthew G. Knepley 193032d2bbc9SMatthew G. Knepley /*@C 193132d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 193232d2bbc9SMatthew G. Knepley 193332d2bbc9SMatthew G. Knepley Not collective 193432d2bbc9SMatthew G. Knepley 193532d2bbc9SMatthew G. Knepley Input Parameters: 19366528b96dSMatthew G. Knepley + ds - The PetscDS 193732d2bbc9SMatthew G. Knepley - f - The field number 193832d2bbc9SMatthew G. Knepley 193932d2bbc9SMatthew G. Knepley Output Parameters: 1940a2b725a8SWilliam Gropp . update - update function 194132d2bbc9SMatthew G. Knepley 194232d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 194332d2bbc9SMatthew G. Knepley 194432d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 194532d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 194632d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194732d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 194832d2bbc9SMatthew G. Knepley 194932d2bbc9SMatthew G. Knepley + dim - the spatial dimension 195032d2bbc9SMatthew G. Knepley . Nf - the number of fields 195132d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 195232d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 195332d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 195432d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 195532d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 195632d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 195732d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 195832d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 195932d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 196032d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 196132d2bbc9SMatthew G. Knepley . t - current time 196232d2bbc9SMatthew G. Knepley . x - coordinates of the current point 196332d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 196432d2bbc9SMatthew G. Knepley 196532d2bbc9SMatthew G. Knepley Level: intermediate 196632d2bbc9SMatthew G. Knepley 196732d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 196832d2bbc9SMatthew G. Knepley @*/ 19696528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS ds, PetscInt f, 197032d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 197132d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 197232d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19733fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 197432d2bbc9SMatthew G. Knepley { 197532d2bbc9SMatthew G. Knepley PetscFunctionBegin; 19766528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 19776528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 19786528b96dSMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = ds->update[f];} 197932d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 198032d2bbc9SMatthew G. Knepley } 198132d2bbc9SMatthew G. Knepley 198232d2bbc9SMatthew G. Knepley /*@C 19833fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 198432d2bbc9SMatthew G. Knepley 198532d2bbc9SMatthew G. Knepley Not collective 198632d2bbc9SMatthew G. Knepley 198732d2bbc9SMatthew G. Knepley Input Parameters: 19886528b96dSMatthew G. Knepley + ds - The PetscDS 198932d2bbc9SMatthew G. Knepley . f - The field number 199032d2bbc9SMatthew G. Knepley - update - update function 199132d2bbc9SMatthew G. Knepley 199232d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 199332d2bbc9SMatthew G. Knepley 199432d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 199532d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 199632d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 199732d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 199832d2bbc9SMatthew G. Knepley 199932d2bbc9SMatthew G. Knepley + dim - the spatial dimension 200032d2bbc9SMatthew G. Knepley . Nf - the number of fields 200132d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 200232d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 200332d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 200432d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 200532d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 200632d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 200732d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 200832d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 200932d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 201032d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 201132d2bbc9SMatthew G. Knepley . t - current time 201232d2bbc9SMatthew G. Knepley . x - coordinates of the current point 201332d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 201432d2bbc9SMatthew G. Knepley 201532d2bbc9SMatthew G. Knepley Level: intermediate 201632d2bbc9SMatthew G. Knepley 201732d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 201832d2bbc9SMatthew G. Knepley @*/ 20196528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS ds, PetscInt f, 202032d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 202132d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 202232d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20233fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 202432d2bbc9SMatthew G. Knepley { 202532d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 202632d2bbc9SMatthew G. Knepley 202732d2bbc9SMatthew G. Knepley PetscFunctionBegin; 20286528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 202932d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 203032d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20316528b96dSMatthew G. Knepley ierr = PetscDSEnlarge_Static(ds, f+1);CHKERRQ(ierr); 20326528b96dSMatthew G. Knepley ds->update[f] = update; 203332d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 203432d2bbc9SMatthew G. Knepley } 203532d2bbc9SMatthew G. Knepley 20366528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS ds, PetscInt f, void **ctx) 20370c2f2876SMatthew G. Knepley { 20380c2f2876SMatthew G. Knepley PetscFunctionBegin; 20396528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20406528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 20410c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 20426528b96dSMatthew G. Knepley *ctx = ds->ctx[f]; 20430c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20440c2f2876SMatthew G. Knepley } 20450c2f2876SMatthew G. Knepley 20466528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS ds, PetscInt f, void *ctx) 20470c2f2876SMatthew G. Knepley { 20480c2f2876SMatthew G. Knepley PetscErrorCode ierr; 20490c2f2876SMatthew G. Knepley 20500c2f2876SMatthew G. Knepley PetscFunctionBegin; 20516528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 20520c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20536528b96dSMatthew G. Knepley ierr = PetscDSEnlarge_Static(ds, f+1);CHKERRQ(ierr); 20546528b96dSMatthew G. Knepley ds->ctx[f] = ctx; 20550c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 20560c2f2876SMatthew G. Knepley } 20570c2f2876SMatthew G. Knepley 2058194d53e6SMatthew G. Knepley /*@C 2059194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 2060194d53e6SMatthew G. Knepley 2061194d53e6SMatthew G. Knepley Not collective 2062194d53e6SMatthew G. Knepley 2063194d53e6SMatthew G. Knepley Input Parameters: 20646528b96dSMatthew G. Knepley + ds - The PetscDS 2065194d53e6SMatthew G. Knepley - f - The test field number 2066194d53e6SMatthew G. Knepley 2067194d53e6SMatthew G. Knepley Output Parameters: 2068194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 2069194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2070194d53e6SMatthew G. Knepley 2071194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2072194d53e6SMatthew G. Knepley 2073194d53e6SMatthew 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 2074194d53e6SMatthew G. Knepley 2075194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2076194d53e6SMatthew G. Knepley 207730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2078194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2079194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 208030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2081194d53e6SMatthew G. Knepley 2082194d53e6SMatthew G. Knepley + dim - the spatial dimension 2083194d53e6SMatthew G. Knepley . Nf - the number of fields 2084194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2085194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2086194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2087194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2088194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2089194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2090194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2091194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2092194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2093194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2094194d53e6SMatthew G. Knepley . t - current time 2095194d53e6SMatthew G. Knepley . x - coordinates of the current point 2096194d53e6SMatthew G. Knepley . n - unit normal at the current point 209797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 209897b6e6e8SMatthew G. Knepley . constants - constant parameters 2099194d53e6SMatthew G. Knepley - f0 - output values at the current point 2100194d53e6SMatthew G. Knepley 2101194d53e6SMatthew G. Knepley Level: intermediate 2102194d53e6SMatthew G. Knepley 2103194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 2104194d53e6SMatthew G. Knepley @*/ 21056528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS ds, PetscInt f, 210630b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2107194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2108194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 210997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 211030b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2111194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2112194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 211397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 21142764a2aaSMatthew G. Knepley { 21156528b96dSMatthew G. Knepley PetscBdPointFunc *tmp0, *tmp1; 21166528b96dSMatthew G. Knepley PetscInt n0, n1; 21176528b96dSMatthew G. Knepley PetscErrorCode ierr; 21186528b96dSMatthew G. Knepley 21192764a2aaSMatthew G. Knepley PetscFunctionBegin; 21206528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21216528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 212206ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdResidual(ds->wf, NULL, 0, f, 0, &n0, &tmp0, &n1, &tmp1);CHKERRQ(ierr); 21236528b96dSMatthew G. Knepley *f0 = tmp0 ? tmp0[0] : NULL; 21246528b96dSMatthew G. Knepley *f1 = tmp1 ? tmp1[0] : NULL; 21252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21262764a2aaSMatthew G. Knepley } 21272764a2aaSMatthew G. Knepley 2128194d53e6SMatthew G. Knepley /*@C 2129194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2130194d53e6SMatthew G. Knepley 2131194d53e6SMatthew G. Knepley Not collective 2132194d53e6SMatthew G. Knepley 2133194d53e6SMatthew G. Knepley Input Parameters: 21346528b96dSMatthew G. Knepley + ds - The PetscDS 2135194d53e6SMatthew G. Knepley . f - The test field number 2136194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2137194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2138194d53e6SMatthew G. Knepley 2139194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2140194d53e6SMatthew G. Knepley 2141194d53e6SMatthew 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 2142194d53e6SMatthew G. Knepley 2143194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2144194d53e6SMatthew G. Knepley 214530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2146194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2147194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 214830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2149194d53e6SMatthew G. Knepley 2150194d53e6SMatthew G. Knepley + dim - the spatial dimension 2151194d53e6SMatthew G. Knepley . Nf - the number of fields 2152194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2153194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2154194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2155194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2156194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2157194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2158194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2159194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2160194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2161194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2162194d53e6SMatthew G. Knepley . t - current time 2163194d53e6SMatthew G. Knepley . x - coordinates of the current point 2164194d53e6SMatthew G. Knepley . n - unit normal at the current point 216597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 216697b6e6e8SMatthew G. Knepley . constants - constant parameters 2167194d53e6SMatthew G. Knepley - f0 - output values at the current point 2168194d53e6SMatthew G. Knepley 2169194d53e6SMatthew G. Knepley Level: intermediate 2170194d53e6SMatthew G. Knepley 2171194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2172194d53e6SMatthew G. Knepley @*/ 21736528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS ds, PetscInt f, 217430b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2175194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2176194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 217797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 217830b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2179194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2180194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 218197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 21822764a2aaSMatthew G. Knepley { 21832764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21842764a2aaSMatthew G. Knepley 21852764a2aaSMatthew G. Knepley PetscFunctionBegin; 21866528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 21872764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 218806ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdResidual(ds->wf, NULL, 0, f, 0, 0, f0, 0, f1);CHKERRQ(ierr); 21892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21902764a2aaSMatthew G. Knepley } 21912764a2aaSMatthew G. Knepley 219227f02ce8SMatthew G. Knepley /*@ 219327f02ce8SMatthew G. Knepley PetscDSHasBdJacobian - Signals that boundary Jacobian functions have been set 219427f02ce8SMatthew G. Knepley 219527f02ce8SMatthew G. Knepley Not collective 219627f02ce8SMatthew G. Knepley 219727f02ce8SMatthew G. Knepley Input Parameter: 21986528b96dSMatthew G. Knepley . ds - The PetscDS 219927f02ce8SMatthew G. Knepley 220027f02ce8SMatthew G. Knepley Output Parameter: 220127f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian has been set 220227f02ce8SMatthew G. Knepley 220327f02ce8SMatthew G. Knepley Level: intermediate 220427f02ce8SMatthew G. Knepley 220527f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 220627f02ce8SMatthew G. Knepley @*/ 22076528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobian(PetscDS ds, PetscBool *hasBdJac) 220827f02ce8SMatthew G. Knepley { 22096528b96dSMatthew G. Knepley PetscErrorCode ierr; 221027f02ce8SMatthew G. Knepley 221127f02ce8SMatthew G. Knepley PetscFunctionBegin; 22126528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 22136528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJac, 2); 22146528b96dSMatthew G. Knepley ierr = PetscWeakFormHasBdJacobian(ds->wf, hasBdJac);CHKERRQ(ierr); 221527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 221627f02ce8SMatthew G. Knepley } 221727f02ce8SMatthew G. Knepley 2218194d53e6SMatthew G. Knepley /*@C 2219194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2220194d53e6SMatthew G. Knepley 2221194d53e6SMatthew G. Knepley Not collective 2222194d53e6SMatthew G. Knepley 2223194d53e6SMatthew G. Knepley Input Parameters: 22246528b96dSMatthew G. Knepley + ds - The PetscDS 2225194d53e6SMatthew G. Knepley . f - The test field number 2226194d53e6SMatthew G. Knepley - g - The field number 2227194d53e6SMatthew G. Knepley 2228194d53e6SMatthew G. Knepley Output Parameters: 2229194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2230194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2231194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2232194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2233194d53e6SMatthew G. Knepley 2234194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2235194d53e6SMatthew G. Knepley 2236194d53e6SMatthew 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 2237194d53e6SMatthew G. Knepley 2238194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2239194d53e6SMatthew G. Knepley 224030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2241194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2242194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 224330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2244194d53e6SMatthew G. Knepley 2245194d53e6SMatthew G. Knepley + dim - the spatial dimension 2246194d53e6SMatthew G. Knepley . Nf - the number of fields 2247194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2248194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2249194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2250194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2251194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2252194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2253194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2254194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2255194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2256194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2257194d53e6SMatthew G. Knepley . t - current time 22582aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2259194d53e6SMatthew G. Knepley . x - coordinates of the current point 2260194d53e6SMatthew G. Knepley . n - normal at the current point 226197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 226297b6e6e8SMatthew G. Knepley . constants - constant parameters 2263194d53e6SMatthew G. Knepley - g0 - output values at the current point 2264194d53e6SMatthew G. Knepley 2265194d53e6SMatthew G. Knepley Level: intermediate 2266194d53e6SMatthew G. Knepley 2267194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2268194d53e6SMatthew G. Knepley @*/ 22696528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 227030b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2271194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2272194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 227397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 227430b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2275194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2276194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 227797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 227830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2279194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2280194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 228197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 228230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2283194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2284194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 228597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22862764a2aaSMatthew G. Knepley { 22876528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 22886528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 22896528b96dSMatthew G. Knepley PetscErrorCode ierr; 22906528b96dSMatthew G. Knepley 22912764a2aaSMatthew G. Knepley PetscFunctionBegin; 22926528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 22936528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 22946528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 229506ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdJacobian(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 22966528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 22976528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 22986528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 22996528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 23002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23012764a2aaSMatthew G. Knepley } 23022764a2aaSMatthew G. Knepley 2303194d53e6SMatthew G. Knepley /*@C 2304194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2305194d53e6SMatthew G. Knepley 2306194d53e6SMatthew G. Knepley Not collective 2307194d53e6SMatthew G. Knepley 2308194d53e6SMatthew G. Knepley Input Parameters: 23096528b96dSMatthew G. Knepley + ds - The PetscDS 2310194d53e6SMatthew G. Knepley . f - The test field number 2311194d53e6SMatthew G. Knepley . g - The field number 2312194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2313194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2314194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2315194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2316194d53e6SMatthew G. Knepley 2317194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2318194d53e6SMatthew G. Knepley 2319194d53e6SMatthew 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 2320194d53e6SMatthew G. Knepley 2321194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2322194d53e6SMatthew G. Knepley 232330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2324194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2325194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 232630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2327194d53e6SMatthew G. Knepley 2328194d53e6SMatthew G. Knepley + dim - the spatial dimension 2329194d53e6SMatthew G. Knepley . Nf - the number of fields 2330194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2331194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2332194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2333194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2334194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2335194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2336194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2337194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2338194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2339194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2340194d53e6SMatthew G. Knepley . t - current time 23412aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2342194d53e6SMatthew G. Knepley . x - coordinates of the current point 2343194d53e6SMatthew G. Knepley . n - normal at the current point 234497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 234597b6e6e8SMatthew G. Knepley . constants - constant parameters 2346194d53e6SMatthew G. Knepley - g0 - output values at the current point 2347194d53e6SMatthew G. Knepley 2348194d53e6SMatthew G. Knepley Level: intermediate 2349194d53e6SMatthew G. Knepley 2350194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2351194d53e6SMatthew G. Knepley @*/ 23526528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS ds, PetscInt f, PetscInt g, 235330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2354194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2355194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 235697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 235730b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2358194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2359194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 236130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2362194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2363194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 236530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2366194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2367194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 236897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 23692764a2aaSMatthew G. Knepley { 23702764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23712764a2aaSMatthew G. Knepley 23722764a2aaSMatthew G. Knepley PetscFunctionBegin; 23736528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 23742764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 23752764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 23762764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 23772764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 23782764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 23792764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 238006ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdJacobian(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 23812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23822764a2aaSMatthew G. Knepley } 23832764a2aaSMatthew G. Knepley 238427f02ce8SMatthew G. Knepley /*@ 238527f02ce8SMatthew G. Knepley PetscDSHasBdJacobianPreconditioner - Signals that boundary Jacobian preconditioner functions have been set 238627f02ce8SMatthew G. Knepley 238727f02ce8SMatthew G. Knepley Not collective 238827f02ce8SMatthew G. Knepley 238927f02ce8SMatthew G. Knepley Input Parameter: 23906528b96dSMatthew G. Knepley . ds - The PetscDS 239127f02ce8SMatthew G. Knepley 239227f02ce8SMatthew G. Knepley Output Parameter: 239327f02ce8SMatthew G. Knepley . hasBdJac - flag that pointwise function for the boundary Jacobian preconditioner has been set 239427f02ce8SMatthew G. Knepley 239527f02ce8SMatthew G. Knepley Level: intermediate 239627f02ce8SMatthew G. Knepley 239727f02ce8SMatthew G. Knepley .seealso: PetscDSHasJacobian(), PetscDSSetBdJacobian(), PetscDSGetBdJacobian() 239827f02ce8SMatthew G. Knepley @*/ 23996528b96dSMatthew G. Knepley PetscErrorCode PetscDSHasBdJacobianPreconditioner(PetscDS ds, PetscBool *hasBdJacPre) 240027f02ce8SMatthew G. Knepley { 24016528b96dSMatthew G. Knepley PetscErrorCode ierr; 240227f02ce8SMatthew G. Knepley 240327f02ce8SMatthew G. Knepley PetscFunctionBegin; 24046528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 24056528b96dSMatthew G. Knepley PetscValidBoolPointer(hasBdJacPre, 2); 24066528b96dSMatthew G. Knepley ierr = PetscWeakFormHasBdJacobianPreconditioner(ds->wf, hasBdJacPre);CHKERRQ(ierr); 240727f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 240827f02ce8SMatthew G. Knepley } 240927f02ce8SMatthew G. Knepley 241027f02ce8SMatthew G. Knepley /*@C 241127f02ce8SMatthew G. Knepley PetscDSGetBdJacobianPreconditioner - Get the pointwise boundary Jacobian preconditioner function for given test and basis field 241227f02ce8SMatthew G. Knepley 241327f02ce8SMatthew G. Knepley Not collective 241427f02ce8SMatthew G. Knepley 241527f02ce8SMatthew G. Knepley Input Parameters: 24166528b96dSMatthew G. Knepley + ds - The PetscDS 241727f02ce8SMatthew G. Knepley . f - The test field number 241827f02ce8SMatthew G. Knepley - g - The field number 241927f02ce8SMatthew G. Knepley 242027f02ce8SMatthew G. Knepley Output Parameters: 242127f02ce8SMatthew G. Knepley + g0 - integrand for the test and basis function term 242227f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 242327f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 242427f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 242527f02ce8SMatthew G. Knepley 242627f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 242727f02ce8SMatthew G. Knepley 242827f02ce8SMatthew 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 242927f02ce8SMatthew G. Knepley 243027f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 243127f02ce8SMatthew G. Knepley 243227f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 243327f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 243427f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 243527f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 243627f02ce8SMatthew G. Knepley 243727f02ce8SMatthew G. Knepley + dim - the spatial dimension 243827f02ce8SMatthew G. Knepley . Nf - the number of fields 243927f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 244027f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 244127f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 244227f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 244327f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 244427f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 244527f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 244627f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 244727f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 244827f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 244927f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 245027f02ce8SMatthew G. Knepley . t - current time 245127f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 245227f02ce8SMatthew G. Knepley . x - coordinates of the current point 245327f02ce8SMatthew G. Knepley . n - normal at the current point 245427f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 245527f02ce8SMatthew G. Knepley . constants - constant parameters 245627f02ce8SMatthew G. Knepley - g0 - output values at the current point 245727f02ce8SMatthew G. Knepley 245827f02ce8SMatthew G. Knepley This is not yet available in Fortran. 245927f02ce8SMatthew G. Knepley 246027f02ce8SMatthew G. Knepley Level: intermediate 246127f02ce8SMatthew G. Knepley 246227f02ce8SMatthew G. Knepley .seealso: PetscDSSetBdJacobianPreconditioner() 246327f02ce8SMatthew G. Knepley @*/ 24646528b96dSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 246527f02ce8SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 246627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 246727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 246827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 246927f02ce8SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 247027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 247127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 247227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 247327f02ce8SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 247427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 247527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 247627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 247727f02ce8SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 247827f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 247927f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 248027f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 248127f02ce8SMatthew G. Knepley { 24826528b96dSMatthew G. Knepley PetscBdPointJac *tmp0, *tmp1, *tmp2, *tmp3; 24836528b96dSMatthew G. Knepley PetscInt n0, n1, n2, n3; 24846528b96dSMatthew G. Knepley PetscErrorCode ierr; 24856528b96dSMatthew G. Knepley 248627f02ce8SMatthew G. Knepley PetscFunctionBegin; 24876528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 24886528b96dSMatthew G. Knepley if ((f < 0) || (f >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, ds->Nf); 24896528b96dSMatthew G. Knepley if ((g < 0) || (g >= ds->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, ds->Nf); 249006ad1575SMatthew G. Knepley ierr = PetscWeakFormGetBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, &n0, &tmp0, &n1, &tmp1, &n2, &tmp2, &n3, &tmp3);CHKERRQ(ierr); 24916528b96dSMatthew G. Knepley *g0 = tmp0 ? tmp0[0] : NULL; 24926528b96dSMatthew G. Knepley *g1 = tmp1 ? tmp1[0] : NULL; 24936528b96dSMatthew G. Knepley *g2 = tmp2 ? tmp2[0] : NULL; 24946528b96dSMatthew G. Knepley *g3 = tmp3 ? tmp3[0] : NULL; 249527f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 249627f02ce8SMatthew G. Knepley } 249727f02ce8SMatthew G. Knepley 249827f02ce8SMatthew G. Knepley /*@C 249927f02ce8SMatthew G. Knepley PetscDSSetBdJacobianPreconditioner - Set the pointwise boundary Jacobian preconditioner function for given test and basis field 250027f02ce8SMatthew G. Knepley 250127f02ce8SMatthew G. Knepley Not collective 250227f02ce8SMatthew G. Knepley 250327f02ce8SMatthew G. Knepley Input Parameters: 25046528b96dSMatthew G. Knepley + ds - The PetscDS 250527f02ce8SMatthew G. Knepley . f - The test field number 250627f02ce8SMatthew G. Knepley . g - The field number 250727f02ce8SMatthew G. Knepley . g0 - integrand for the test and basis function term 250827f02ce8SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 250927f02ce8SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 251027f02ce8SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 251127f02ce8SMatthew G. Knepley 251227f02ce8SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 251327f02ce8SMatthew G. Knepley 251427f02ce8SMatthew 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 251527f02ce8SMatthew G. Knepley 251627f02ce8SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 251727f02ce8SMatthew G. Knepley 251827f02ce8SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 251927f02ce8SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 252027f02ce8SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 252127f02ce8SMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]) 252227f02ce8SMatthew G. Knepley 252327f02ce8SMatthew G. Knepley + dim - the spatial dimension 252427f02ce8SMatthew G. Knepley . Nf - the number of fields 252527f02ce8SMatthew G. Knepley . NfAux - the number of auxiliary fields 252627f02ce8SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 252727f02ce8SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 252827f02ce8SMatthew G. Knepley . u - each field evaluated at the current point 252927f02ce8SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 253027f02ce8SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 253127f02ce8SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 253227f02ce8SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 253327f02ce8SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 253427f02ce8SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 253527f02ce8SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 253627f02ce8SMatthew G. Knepley . t - current time 253727f02ce8SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 253827f02ce8SMatthew G. Knepley . x - coordinates of the current point 253927f02ce8SMatthew G. Knepley . n - normal at the current point 254027f02ce8SMatthew G. Knepley . numConstants - number of constant parameters 254127f02ce8SMatthew G. Knepley . constants - constant parameters 254227f02ce8SMatthew G. Knepley - g0 - output values at the current point 254327f02ce8SMatthew G. Knepley 254427f02ce8SMatthew G. Knepley This is not yet available in Fortran. 254527f02ce8SMatthew G. Knepley 254627f02ce8SMatthew G. Knepley Level: intermediate 254727f02ce8SMatthew G. Knepley 254827f02ce8SMatthew G. Knepley .seealso: PetscDSGetBdJacobianPreconditioner() 254927f02ce8SMatthew G. Knepley @*/ 25506528b96dSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobianPreconditioner(PetscDS ds, PetscInt f, PetscInt g, 255127f02ce8SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 255227f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 255327f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 255427f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 255527f02ce8SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 255627f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 255727f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 255827f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 255927f02ce8SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 256027f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 256127f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 256227f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 256327f02ce8SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 256427f02ce8SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 256527f02ce8SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 256627f02ce8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 256727f02ce8SMatthew G. Knepley { 256827f02ce8SMatthew G. Knepley PetscErrorCode ierr; 256927f02ce8SMatthew G. Knepley 257027f02ce8SMatthew G. Knepley PetscFunctionBegin; 25716528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 257227f02ce8SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 257327f02ce8SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 257427f02ce8SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 257527f02ce8SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 257627f02ce8SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 257727f02ce8SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 257806ad1575SMatthew G. Knepley ierr = PetscWeakFormSetIndexBdJacobianPreconditioner(ds->wf, NULL, 0, f, g, 0, 0, g0, 0, g1, 0, g2, 0, g3);CHKERRQ(ierr); 257927f02ce8SMatthew G. Knepley PetscFunctionReturn(0); 258027f02ce8SMatthew G. Knepley } 258127f02ce8SMatthew G. Knepley 25820d3e9b51SMatthew G. Knepley /*@C 2583c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2584c371a6d1SMatthew G. Knepley 2585c371a6d1SMatthew G. Knepley Not collective 2586c371a6d1SMatthew G. Knepley 2587c371a6d1SMatthew G. Knepley Input Parameters: 2588c371a6d1SMatthew G. Knepley + prob - The PetscDS 2589c371a6d1SMatthew G. Knepley - f - The test field number 2590c371a6d1SMatthew G. Knepley 2591c371a6d1SMatthew G. Knepley Output Parameter: 259295cbbfd3SMatthew G. Knepley + exactSol - exact solution for the test field 259395cbbfd3SMatthew G. Knepley - exactCtx - exact solution context 2594c371a6d1SMatthew G. Knepley 2595c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2596c371a6d1SMatthew G. Knepley 2597c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2598c371a6d1SMatthew G. Knepley 2599c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2600c371a6d1SMatthew G. Knepley . t - current time 2601c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2602c371a6d1SMatthew G. Knepley . Nc - the number of field components 2603c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2604c371a6d1SMatthew G. Knepley - ctx - a user context 2605c371a6d1SMatthew G. Knepley 2606c371a6d1SMatthew G. Knepley Level: intermediate 2607c371a6d1SMatthew G. Knepley 2608f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolution(), PetscDSGetExactSolutionTimeDerivative() 2609c371a6d1SMatthew G. Knepley @*/ 261095cbbfd3SMatthew 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) 2611c371a6d1SMatthew G. Knepley { 2612c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2613c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2614c371a6d1SMatthew 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); 2615c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 261695cbbfd3SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx[f];} 2617c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2618c371a6d1SMatthew G. Knepley } 2619c371a6d1SMatthew G. Knepley 2620c371a6d1SMatthew G. Knepley /*@C 2621578a5ef5SMatthew Knepley PetscDSSetExactSolution - Set the pointwise exact solution function for a given test field 2622c371a6d1SMatthew G. Knepley 2623c371a6d1SMatthew G. Knepley Not collective 2624c371a6d1SMatthew G. Knepley 2625c371a6d1SMatthew G. Knepley Input Parameters: 2626c371a6d1SMatthew G. Knepley + prob - The PetscDS 2627c371a6d1SMatthew G. Knepley . f - The test field number 262895cbbfd3SMatthew G. Knepley . sol - solution function for the test fields 262995cbbfd3SMatthew G. Knepley - ctx - solution context or NULL 2630c371a6d1SMatthew G. Knepley 2631c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2632c371a6d1SMatthew G. Knepley 2633c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2634c371a6d1SMatthew G. Knepley 2635c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2636c371a6d1SMatthew G. Knepley . t - current time 2637c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2638c371a6d1SMatthew G. Knepley . Nc - the number of field components 2639c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2640c371a6d1SMatthew G. Knepley - ctx - a user context 2641c371a6d1SMatthew G. Knepley 2642c371a6d1SMatthew G. Knepley Level: intermediate 2643c371a6d1SMatthew G. Knepley 2644c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2645c371a6d1SMatthew G. Knepley @*/ 264695cbbfd3SMatthew 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) 2647c371a6d1SMatthew G. Knepley { 2648c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2649c371a6d1SMatthew G. Knepley 2650c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2651c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2652c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2653c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2654c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 265595cbbfd3SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx[f] = ctx;} 2656c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2657c371a6d1SMatthew G. Knepley } 2658c371a6d1SMatthew G. Knepley 26595638fd0eSMatthew G. Knepley /*@C 2660f2cacb80SMatthew G. Knepley PetscDSGetExactSolutionTimeDerivative - Get the pointwise time derivative of the exact solution function for a given test field 2661f2cacb80SMatthew G. Knepley 2662f2cacb80SMatthew G. Knepley Not collective 2663f2cacb80SMatthew G. Knepley 2664f2cacb80SMatthew G. Knepley Input Parameters: 2665f2cacb80SMatthew G. Knepley + prob - The PetscDS 2666f2cacb80SMatthew G. Knepley - f - The test field number 2667f2cacb80SMatthew G. Knepley 2668f2cacb80SMatthew G. Knepley Output Parameter: 2669f2cacb80SMatthew G. Knepley + exactSol - time derivative of the exact solution for the test field 2670f2cacb80SMatthew G. Knepley - exactCtx - time derivative of the exact solution context 2671f2cacb80SMatthew G. Knepley 2672f2cacb80SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2673f2cacb80SMatthew G. Knepley 2674f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2675f2cacb80SMatthew G. Knepley 2676f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2677f2cacb80SMatthew G. Knepley . t - current time 2678f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2679f2cacb80SMatthew G. Knepley . Nc - the number of field components 2680f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2681f2cacb80SMatthew G. Knepley - ctx - a user context 2682f2cacb80SMatthew G. Knepley 2683f2cacb80SMatthew G. Knepley Level: intermediate 2684f2cacb80SMatthew G. Knepley 2685f2cacb80SMatthew G. Knepley .seealso: PetscDSSetExactSolutionTimeDerivative(), PetscDSGetExactSolution() 2686f2cacb80SMatthew G. Knepley @*/ 2687f2cacb80SMatthew G. Knepley PetscErrorCode PetscDSGetExactSolutionTimeDerivative(PetscDS prob, PetscInt f, PetscErrorCode (**sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void **ctx) 2688f2cacb80SMatthew G. Knepley { 2689f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2690f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2691f2cacb80SMatthew 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); 2692f2cacb80SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol_t[f];} 2693f2cacb80SMatthew G. Knepley if (ctx) {PetscValidPointer(ctx, 4); *ctx = prob->exactCtx_t[f];} 2694f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2695f2cacb80SMatthew G. Knepley } 2696f2cacb80SMatthew G. Knepley 2697f2cacb80SMatthew G. Knepley /*@C 2698f2cacb80SMatthew G. Knepley PetscDSSetExactSolutionTimeDerivative - Set the pointwise time derivative of the exact solution function for a given test field 2699f2cacb80SMatthew G. Knepley 2700f2cacb80SMatthew G. Knepley Not collective 2701f2cacb80SMatthew G. Knepley 2702f2cacb80SMatthew G. Knepley Input Parameters: 2703f2cacb80SMatthew G. Knepley + prob - The PetscDS 2704f2cacb80SMatthew G. Knepley . f - The test field number 2705f2cacb80SMatthew G. Knepley . sol - time derivative of the solution function for the test fields 2706f2cacb80SMatthew G. Knepley - ctx - time derivative of the solution context or NULL 2707f2cacb80SMatthew G. Knepley 2708f2cacb80SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2709f2cacb80SMatthew G. Knepley 2710f2cacb80SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2711f2cacb80SMatthew G. Knepley 2712f2cacb80SMatthew G. Knepley + dim - the spatial dimension 2713f2cacb80SMatthew G. Knepley . t - current time 2714f2cacb80SMatthew G. Knepley . x - coordinates of the current point 2715f2cacb80SMatthew G. Knepley . Nc - the number of field components 2716f2cacb80SMatthew G. Knepley . u - the solution field evaluated at the current point 2717f2cacb80SMatthew G. Knepley - ctx - a user context 2718f2cacb80SMatthew G. Knepley 2719f2cacb80SMatthew G. Knepley Level: intermediate 2720f2cacb80SMatthew G. Knepley 2721f2cacb80SMatthew G. Knepley .seealso: PetscDSGetExactSolutionTimeDerivative(), PetscDSSetExactSolution() 2722f2cacb80SMatthew G. Knepley @*/ 2723f2cacb80SMatthew G. Knepley PetscErrorCode PetscDSSetExactSolutionTimeDerivative(PetscDS prob, PetscInt f, PetscErrorCode (*sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx), void *ctx) 2724f2cacb80SMatthew G. Knepley { 2725f2cacb80SMatthew G. Knepley PetscErrorCode ierr; 2726f2cacb80SMatthew G. Knepley 2727f2cacb80SMatthew G. Knepley PetscFunctionBegin; 2728f2cacb80SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2729f2cacb80SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2730f2cacb80SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2731f2cacb80SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol_t[f] = sol;} 2732f2cacb80SMatthew G. Knepley if (ctx) {PetscValidFunction(ctx, 4); prob->exactCtx_t[f] = ctx;} 2733f2cacb80SMatthew G. Knepley PetscFunctionReturn(0); 2734f2cacb80SMatthew G. Knepley } 2735f2cacb80SMatthew G. Knepley 2736f2cacb80SMatthew G. Knepley /*@C 273797b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 273897b6e6e8SMatthew G. Knepley 273997b6e6e8SMatthew G. Knepley Not collective 274097b6e6e8SMatthew G. Knepley 274197b6e6e8SMatthew G. Knepley Input Parameter: 274297b6e6e8SMatthew G. Knepley . prob - The PetscDS object 274397b6e6e8SMatthew G. Knepley 274497b6e6e8SMatthew G. Knepley Output Parameters: 274597b6e6e8SMatthew G. Knepley + numConstants - The number of constants 274697b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 274797b6e6e8SMatthew G. Knepley 274897b6e6e8SMatthew G. Knepley Level: intermediate 274997b6e6e8SMatthew G. Knepley 275097b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 275197b6e6e8SMatthew G. Knepley @*/ 275297b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 275397b6e6e8SMatthew G. Knepley { 275497b6e6e8SMatthew G. Knepley PetscFunctionBegin; 275597b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 275697b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 275797b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 275897b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 275997b6e6e8SMatthew G. Knepley } 276097b6e6e8SMatthew G. Knepley 27610d3e9b51SMatthew G. Knepley /*@C 276297b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 276397b6e6e8SMatthew G. Knepley 276497b6e6e8SMatthew G. Knepley Not collective 276597b6e6e8SMatthew G. Knepley 276697b6e6e8SMatthew G. Knepley Input Parameters: 276797b6e6e8SMatthew G. Knepley + prob - The PetscDS object 276897b6e6e8SMatthew G. Knepley . numConstants - The number of constants 276997b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 277097b6e6e8SMatthew G. Knepley 277197b6e6e8SMatthew G. Knepley Level: intermediate 277297b6e6e8SMatthew G. Knepley 277397b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 277497b6e6e8SMatthew G. Knepley @*/ 277597b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 277697b6e6e8SMatthew G. Knepley { 277797b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 277897b6e6e8SMatthew G. Knepley 277997b6e6e8SMatthew G. Knepley PetscFunctionBegin; 278097b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 278197b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 278297b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 278397b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 278497b6e6e8SMatthew G. Knepley if (prob->numConstants) { 278597b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 278620be0f5bSMatthew G. Knepley } else { 278720be0f5bSMatthew G. Knepley prob->constants = NULL; 278820be0f5bSMatthew G. Knepley } 278920be0f5bSMatthew G. Knepley } 279020be0f5bSMatthew G. Knepley if (prob->numConstants) { 279120be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 2792580bdb30SBarry Smith ierr = PetscArraycpy(prob->constants, constants, prob->numConstants);CHKERRQ(ierr); 279397b6e6e8SMatthew G. Knepley } 279497b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 279597b6e6e8SMatthew G. Knepley } 279697b6e6e8SMatthew G. Knepley 27974cd1e086SMatthew G. Knepley /*@ 27984cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 27994cd1e086SMatthew G. Knepley 28004cd1e086SMatthew G. Knepley Not collective 28014cd1e086SMatthew G. Knepley 28024cd1e086SMatthew G. Knepley Input Parameters: 28034cd1e086SMatthew G. Knepley + prob - The PetscDS object 28044cd1e086SMatthew G. Knepley - disc - The discretization object 28054cd1e086SMatthew G. Knepley 28064cd1e086SMatthew G. Knepley Output Parameter: 28074cd1e086SMatthew G. Knepley . f - The field number 28084cd1e086SMatthew G. Knepley 28094cd1e086SMatthew G. Knepley Level: beginner 28104cd1e086SMatthew G. Knepley 2811f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 28124cd1e086SMatthew G. Knepley @*/ 28134cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 28144cd1e086SMatthew G. Knepley { 28154cd1e086SMatthew G. Knepley PetscInt g; 28164cd1e086SMatthew G. Knepley 28174cd1e086SMatthew G. Knepley PetscFunctionBegin; 28184cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28194cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 28204cd1e086SMatthew G. Knepley *f = -1; 28214cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 28224cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 28234cd1e086SMatthew G. Knepley *f = g; 28244cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 28254cd1e086SMatthew G. Knepley } 28264cd1e086SMatthew G. Knepley 28274cd1e086SMatthew G. Knepley /*@ 28284cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 28294cd1e086SMatthew G. Knepley 28304cd1e086SMatthew G. Knepley Not collective 28314cd1e086SMatthew G. Knepley 28324cd1e086SMatthew G. Knepley Input Parameters: 28334cd1e086SMatthew G. Knepley + prob - The PetscDS object 28344cd1e086SMatthew G. Knepley - f - The field number 28354cd1e086SMatthew G. Knepley 28364cd1e086SMatthew G. Knepley Output Parameter: 28374cd1e086SMatthew G. Knepley . size - The size 28384cd1e086SMatthew G. Knepley 28394cd1e086SMatthew G. Knepley Level: beginner 28404cd1e086SMatthew G. Knepley 2841f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 28424cd1e086SMatthew G. Knepley @*/ 28434cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 28444cd1e086SMatthew G. Knepley { 28452166fd64SMatthew G. Knepley PetscErrorCode ierr; 28462166fd64SMatthew G. Knepley 28474cd1e086SMatthew G. Knepley PetscFunctionBegin; 28484cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28494cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 28504cd1e086SMatthew 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); 28512166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2852d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 28534cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 28544cd1e086SMatthew G. Knepley } 28554cd1e086SMatthew G. Knepley 2856bc4ae4beSMatthew G. Knepley /*@ 2857bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2858bc4ae4beSMatthew G. Knepley 2859bc4ae4beSMatthew G. Knepley Not collective 2860bc4ae4beSMatthew G. Knepley 2861bc4ae4beSMatthew G. Knepley Input Parameters: 2862bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2863bc4ae4beSMatthew G. Knepley - f - The field number 2864bc4ae4beSMatthew G. Knepley 2865bc4ae4beSMatthew G. Knepley Output Parameter: 2866bc4ae4beSMatthew G. Knepley . off - The offset 2867bc4ae4beSMatthew G. Knepley 2868bc4ae4beSMatthew G. Knepley Level: beginner 2869bc4ae4beSMatthew G. Knepley 2870f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2871bc4ae4beSMatthew G. Knepley @*/ 28722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 28732764a2aaSMatthew G. Knepley { 28744cd1e086SMatthew G. Knepley PetscInt size, g; 28752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28762764a2aaSMatthew G. Knepley 28772764a2aaSMatthew G. Knepley PetscFunctionBegin; 28782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28792764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 28802764a2aaSMatthew 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); 28812764a2aaSMatthew G. Knepley *off = 0; 28822764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 28834cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 28844cd1e086SMatthew G. Knepley *off += size; 28852764a2aaSMatthew G. Knepley } 28862764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28872764a2aaSMatthew G. Knepley } 28882764a2aaSMatthew G. Knepley 2889bc4ae4beSMatthew G. Knepley /*@ 289047e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2891bc4ae4beSMatthew G. Knepley 2892bc4ae4beSMatthew G. Knepley Not collective 2893bc4ae4beSMatthew G. Knepley 289447e57110SSander Arens Input Parameter: 289547e57110SSander Arens . prob - The PetscDS object 2896bc4ae4beSMatthew G. Knepley 2897bc4ae4beSMatthew G. Knepley Output Parameter: 289847e57110SSander Arens . dimensions - The number of dimensions 2899bc4ae4beSMatthew G. Knepley 2900bc4ae4beSMatthew G. Knepley Level: beginner 2901bc4ae4beSMatthew G. Knepley 290247e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2903bc4ae4beSMatthew G. Knepley @*/ 290447e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 29052764a2aaSMatthew G. Knepley { 29062764a2aaSMatthew G. Knepley PetscErrorCode ierr; 29072764a2aaSMatthew G. Knepley 29082764a2aaSMatthew G. Knepley PetscFunctionBegin; 29092764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 291047e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 291147e57110SSander Arens PetscValidPointer(dimensions, 2); 291247e57110SSander Arens *dimensions = prob->Nb; 291347e57110SSander Arens PetscFunctionReturn(0); 29146ce16762SMatthew G. Knepley } 291547e57110SSander Arens 291647e57110SSander Arens /*@ 291747e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 291847e57110SSander Arens 291947e57110SSander Arens Not collective 292047e57110SSander Arens 292147e57110SSander Arens Input Parameter: 292247e57110SSander Arens . prob - The PetscDS object 292347e57110SSander Arens 292447e57110SSander Arens Output Parameter: 292547e57110SSander Arens . components - The number of components 292647e57110SSander Arens 292747e57110SSander Arens Level: beginner 292847e57110SSander Arens 292947e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 293047e57110SSander Arens @*/ 293147e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 293247e57110SSander Arens { 293347e57110SSander Arens PetscErrorCode ierr; 293447e57110SSander Arens 293547e57110SSander Arens PetscFunctionBegin; 293647e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 293747e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 293847e57110SSander Arens PetscValidPointer(components, 2); 293947e57110SSander Arens *components = prob->Nc; 29406ce16762SMatthew G. Knepley PetscFunctionReturn(0); 29416ce16762SMatthew G. Knepley } 29426ce16762SMatthew G. Knepley 29436ce16762SMatthew G. Knepley /*@ 29446ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 29456ce16762SMatthew G. Knepley 29466ce16762SMatthew G. Knepley Not collective 29476ce16762SMatthew G. Knepley 29486ce16762SMatthew G. Knepley Input Parameters: 29496ce16762SMatthew G. Knepley + prob - The PetscDS object 29506ce16762SMatthew G. Knepley - f - The field number 29516ce16762SMatthew G. Knepley 29526ce16762SMatthew G. Knepley Output Parameter: 29536ce16762SMatthew G. Knepley . off - The offset 29546ce16762SMatthew G. Knepley 29556ce16762SMatthew G. Knepley Level: beginner 29566ce16762SMatthew G. Knepley 2957f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 29586ce16762SMatthew G. Knepley @*/ 29596ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 29606ce16762SMatthew G. Knepley { 29616ce16762SMatthew G. Knepley PetscFunctionBegin; 29626ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29636ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 29646ce16762SMatthew 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); 296547e57110SSander Arens *off = prob->off[f]; 29662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 29672764a2aaSMatthew G. Knepley } 29682764a2aaSMatthew G. Knepley 2969194d53e6SMatthew G. Knepley /*@ 2970194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2971194d53e6SMatthew G. Knepley 2972194d53e6SMatthew G. Knepley Not collective 2973194d53e6SMatthew G. Knepley 2974194d53e6SMatthew G. Knepley Input Parameter: 2975194d53e6SMatthew G. Knepley . prob - The PetscDS object 2976194d53e6SMatthew G. Knepley 2977194d53e6SMatthew G. Knepley Output Parameter: 2978194d53e6SMatthew G. Knepley . offsets - The offsets 2979194d53e6SMatthew G. Knepley 2980194d53e6SMatthew G. Knepley Level: beginner 2981194d53e6SMatthew G. Knepley 2982f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2983194d53e6SMatthew G. Knepley @*/ 2984194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2985194d53e6SMatthew G. Knepley { 2986194d53e6SMatthew G. Knepley PetscFunctionBegin; 2987194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2988194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2989194d53e6SMatthew G. Knepley *offsets = prob->off; 2990194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2991194d53e6SMatthew G. Knepley } 2992194d53e6SMatthew G. Knepley 2993194d53e6SMatthew G. Knepley /*@ 2994194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2995194d53e6SMatthew G. Knepley 2996194d53e6SMatthew G. Knepley Not collective 2997194d53e6SMatthew G. Knepley 2998194d53e6SMatthew G. Knepley Input Parameter: 2999194d53e6SMatthew G. Knepley . prob - The PetscDS object 3000194d53e6SMatthew G. Knepley 3001194d53e6SMatthew G. Knepley Output Parameter: 3002194d53e6SMatthew G. Knepley . offsets - The offsets 3003194d53e6SMatthew G. Knepley 3004194d53e6SMatthew G. Knepley Level: beginner 3005194d53e6SMatthew G. Knepley 3006f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 3007194d53e6SMatthew G. Knepley @*/ 3008194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 3009194d53e6SMatthew G. Knepley { 3010194d53e6SMatthew G. Knepley PetscFunctionBegin; 3011194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3012194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 3013194d53e6SMatthew G. Knepley *offsets = prob->offDer; 3014194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 3015194d53e6SMatthew G. Knepley } 3016194d53e6SMatthew G. Knepley 301768c9edb9SMatthew G. Knepley /*@C 301868c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 301968c9edb9SMatthew G. Knepley 302068c9edb9SMatthew G. Knepley Not collective 302168c9edb9SMatthew G. Knepley 302268c9edb9SMatthew G. Knepley Input Parameter: 302368c9edb9SMatthew G. Knepley . prob - The PetscDS object 302468c9edb9SMatthew G. Knepley 3025ef0bb6c7SMatthew G. Knepley Output Parameter: 3026ef0bb6c7SMatthew G. Knepley . T - The basis function and derivatives tabulation at quadrature points for each field 302768c9edb9SMatthew G. Knepley 302868c9edb9SMatthew G. Knepley Level: intermediate 302968c9edb9SMatthew G. Knepley 3030f744cafaSSander Arens .seealso: PetscDSCreate() 303168c9edb9SMatthew G. Knepley @*/ 3032ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscTabulation *T[]) 30332764a2aaSMatthew G. Knepley { 30342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30352764a2aaSMatthew G. Knepley 30362764a2aaSMatthew G. Knepley PetscFunctionBegin; 30372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3038ef0bb6c7SMatthew G. Knepley PetscValidPointer(T, 2); 30392764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3040ef0bb6c7SMatthew G. Knepley *T = prob->T; 30412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30422764a2aaSMatthew G. Knepley } 30432764a2aaSMatthew G. Knepley 304468c9edb9SMatthew G. Knepley /*@C 30454d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 304668c9edb9SMatthew G. Knepley 304768c9edb9SMatthew G. Knepley Not collective 304868c9edb9SMatthew G. Knepley 304968c9edb9SMatthew G. Knepley Input Parameter: 305068c9edb9SMatthew G. Knepley . prob - The PetscDS object 305168c9edb9SMatthew G. Knepley 3052ef0bb6c7SMatthew G. Knepley Output Parameter: 305319815104SMartin Diehl . Tf - The basis function and derviative tabulation on each local face at quadrature points for each and field 305468c9edb9SMatthew G. Knepley 305568c9edb9SMatthew G. Knepley Level: intermediate 305668c9edb9SMatthew G. Knepley 305768c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 305868c9edb9SMatthew G. Knepley @*/ 3059ef0bb6c7SMatthew G. Knepley PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscTabulation *Tf[]) 30602764a2aaSMatthew G. Knepley { 30612764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30622764a2aaSMatthew G. Knepley 30632764a2aaSMatthew G. Knepley PetscFunctionBegin; 30642764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3065ef0bb6c7SMatthew G. Knepley PetscValidPointer(Tf, 2); 30662764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 3067ef0bb6c7SMatthew G. Knepley *Tf = prob->Tf; 30682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30692764a2aaSMatthew G. Knepley } 30702764a2aaSMatthew G. Knepley 30712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 30722764a2aaSMatthew G. Knepley { 30732764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30742764a2aaSMatthew G. Knepley 30752764a2aaSMatthew G. Knepley PetscFunctionBegin; 30762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30772764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 30782764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 30792764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 30802764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 30812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30822764a2aaSMatthew G. Knepley } 30832764a2aaSMatthew G. Knepley 30842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 30852764a2aaSMatthew G. Knepley { 30862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 30872764a2aaSMatthew G. Knepley 30882764a2aaSMatthew G. Knepley PetscFunctionBegin; 30892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30902764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 30912764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 30922764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 30932764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 30942764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 30952764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 30962764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 30972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30982764a2aaSMatthew G. Knepley } 30992764a2aaSMatthew G. Knepley 31004bee2e38SMatthew G. Knepley PetscErrorCode PetscDSGetWorkspace(PetscDS prob, PetscReal **x, PetscScalar **basisReal, PetscScalar **basisDerReal, PetscScalar **testReal, PetscScalar **testDerReal) 31012764a2aaSMatthew G. Knepley { 31022764a2aaSMatthew G. Knepley PetscErrorCode ierr; 31032764a2aaSMatthew G. Knepley 31042764a2aaSMatthew G. Knepley PetscFunctionBegin; 31052764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 31062764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 31072764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 31084bee2e38SMatthew G. Knepley if (basisReal) {PetscValidPointer(basisReal, 3); *basisReal = prob->basisReal;} 31097506b574SStefano Zampini if (basisDerReal) {PetscValidPointer(basisDerReal, 4); *basisDerReal = prob->basisDerReal;} 31107506b574SStefano Zampini if (testReal) {PetscValidPointer(testReal, 5); *testReal = prob->testReal;} 31117506b574SStefano Zampini if (testDerReal) {PetscValidPointer(testDerReal, 6); *testDerReal = prob->testDerReal;} 31122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31132764a2aaSMatthew G. Knepley } 31142764a2aaSMatthew G. Knepley 311558ebd649SToby Isaac /*@C 311656cf3b9cSMatthew G. Knepley PetscDSAddBoundary - Add a boundary condition to the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performaed, using the kernels from PetscDSSetBdResidual(). 311758ebd649SToby Isaac 3118783e2ec8SMatthew G. Knepley Collective on ds 3119783e2ec8SMatthew G. Knepley 312058ebd649SToby Isaac Input Parameters: 312158ebd649SToby Isaac + ds - The PetscDS object 31222d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 312358ebd649SToby Isaac . name - The BC name 312445480ffeSMatthew G. Knepley . label - The label defining constrained points 312545480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 312645480ffeSMatthew G. Knepley . values - An array of label values for constrained points 312758ebd649SToby Isaac . field - The field to constrain 312845480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 312958ebd649SToby Isaac . comps - An array of constrained component numbers 313058ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 313156cf3b9cSMatthew G. Knepley . bcFunc_t - A pointwise function giving the time derviative of the boundary values, or NULL 313258ebd649SToby Isaac - ctx - An optional user context for bcFunc 313358ebd649SToby Isaac 313445480ffeSMatthew G. Knepley Output Parameters: 313545480ffeSMatthew G. Knepley - bd - The boundary number 313645480ffeSMatthew G. Knepley 313758ebd649SToby Isaac Options Database Keys: 313858ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 313958ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 314058ebd649SToby Isaac 314156cf3b9cSMatthew G. Knepley Note: 314256cf3b9cSMatthew G. Knepley Both bcFunc abd bcFunc_t will depend on the boundary condition type. If the type if DM_BC_ESSENTIAL, Then the calling sequence is: 314356cf3b9cSMatthew G. Knepley 314456cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 314556cf3b9cSMatthew G. Knepley 314656cf3b9cSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 314756cf3b9cSMatthew G. Knepley 314856cf3b9cSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 314956cf3b9cSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 315056cf3b9cSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 315156cf3b9cSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 315256cf3b9cSMatthew G. Knepley 315356cf3b9cSMatthew G. Knepley + dim - the spatial dimension 315456cf3b9cSMatthew G. Knepley . Nf - the number of fields 315556cf3b9cSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 315656cf3b9cSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 315756cf3b9cSMatthew G. Knepley . u - each field evaluated at the current point 315856cf3b9cSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 315956cf3b9cSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 316056cf3b9cSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 316156cf3b9cSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 316256cf3b9cSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 316356cf3b9cSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 316456cf3b9cSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 316556cf3b9cSMatthew G. Knepley . t - current time 316656cf3b9cSMatthew G. Knepley . x - coordinates of the current point 316756cf3b9cSMatthew G. Knepley . numConstants - number of constant parameters 316856cf3b9cSMatthew G. Knepley . constants - constant parameters 316956cf3b9cSMatthew G. Knepley - bcval - output values at the current point 317056cf3b9cSMatthew G. Knepley 317158ebd649SToby Isaac Level: developer 317258ebd649SToby Isaac 317345480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundaryByName(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 317458ebd649SToby Isaac @*/ 317545480ffeSMatthew G. Knepley PetscErrorCode PetscDSAddBoundary(PetscDS ds, DMBoundaryConditionType type, const char name[], DMLabel label, PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx, PetscInt *bd) 317658ebd649SToby Isaac { 317745480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 317845480ffeSMatthew G. Knepley PetscInt n = 0; 317945480ffeSMatthew G. Knepley const char *lname; 318058ebd649SToby Isaac PetscErrorCode ierr; 318158ebd649SToby Isaac 318258ebd649SToby Isaac PetscFunctionBegin; 318358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3184783e2ec8SMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 318545480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 318645480ffeSMatthew G. Knepley PetscValidHeaderSpecific(label, DMLABEL_CLASSID, 4); 318745480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 318845480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 318945480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 3190*d57bb9dbSMatthew G. Knepley if (Nc > 0) { 3191*d57bb9dbSMatthew G. Knepley PetscInt *fcomps; 3192*d57bb9dbSMatthew G. Knepley PetscInt c; 3193*d57bb9dbSMatthew G. Knepley 3194*d57bb9dbSMatthew G. Knepley ierr = PetscDSGetComponents(ds, &fcomps);CHKERRQ(ierr); 3195*d57bb9dbSMatthew G. Knepley if (Nc > fcomps[field]) SETERRQ3(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Number of constrained components %D > %D components for field %D", Nc, fcomps[field], field); 3196*d57bb9dbSMatthew G. Knepley for (c = 0; c < Nc; ++c) { 3197*d57bb9dbSMatthew G. Knepley if (comps[c] < 0 || comps[c] >= fcomps[field]) SETERRQ4(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_OUTOFRANGE, "Constrained component[%D] %D not in [0, %D) components for field %D", c, comps[c], fcomps[field], field); 3198*d57bb9dbSMatthew G. Knepley } 3199*d57bb9dbSMatthew G. Knepley } 320058ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 320158ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 320245480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf);CHKERRQ(ierr); 320345480ffeSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(b->wf, ds->Nf);CHKERRQ(ierr); 320445480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 320545480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 320645480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 320745480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 320845480ffeSMatthew G. Knepley ierr = PetscObjectGetName((PetscObject) label, &lname);CHKERRQ(ierr); 320945480ffeSMatthew G. Knepley ierr = PetscStrallocpy(lname, (char **) &b->lname);CHKERRQ(ierr); 3210f971fd6bSMatthew G. Knepley b->type = type; 321145480ffeSMatthew G. Knepley b->label = label; 321245480ffeSMatthew G. Knepley b->Nv = Nv; 321358ebd649SToby Isaac b->field = field; 321445480ffeSMatthew G. Knepley b->Nc = Nc; 321558ebd649SToby Isaac b->func = bcFunc; 321656cf3b9cSMatthew G. Knepley b->func_t = bcFunc_t; 321758ebd649SToby Isaac b->ctx = ctx; 321845480ffeSMatthew G. Knepley b->next = NULL; 321945480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 322045480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 322145480ffeSMatthew G. Knepley while (head) { 322245480ffeSMatthew G. Knepley if (!head->next) { 322345480ffeSMatthew G. Knepley head->next = b; 322445480ffeSMatthew G. Knepley head = b; 322545480ffeSMatthew G. Knepley } 322645480ffeSMatthew G. Knepley head = head->next; 322745480ffeSMatthew G. Knepley ++n; 322845480ffeSMatthew G. Knepley } 3229064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 323045480ffeSMatthew G. Knepley PetscFunctionReturn(0); 323145480ffeSMatthew G. Knepley } 323245480ffeSMatthew G. Knepley 323345480ffeSMatthew G. Knepley /*@C 323445480ffeSMatthew G. Knepley PetscDSAddBoundaryByName - Add a boundary condition to the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performaed, using the kernels from PetscDSSetBdResidual(). 323545480ffeSMatthew G. Knepley 323645480ffeSMatthew G. Knepley Collective on ds 323745480ffeSMatthew G. Knepley 323845480ffeSMatthew G. Knepley Input Parameters: 323945480ffeSMatthew G. Knepley + ds - The PetscDS object 324045480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 324145480ffeSMatthew G. Knepley . name - The BC name 324245480ffeSMatthew G. Knepley . lname - The naem of the label defining constrained points 324345480ffeSMatthew G. Knepley . Nv - The number of DMLabel values for constrained points 324445480ffeSMatthew G. Knepley . values - An array of label values for constrained points 324545480ffeSMatthew G. Knepley . field - The field to constrain 324645480ffeSMatthew G. Knepley . Nc - The number of constrained field components (0 will constrain all fields) 324745480ffeSMatthew G. Knepley . comps - An array of constrained component numbers 324845480ffeSMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 324945480ffeSMatthew G. Knepley . bcFunc_t - A pointwise function giving the time derviative of the boundary values, or NULL 325045480ffeSMatthew G. Knepley - ctx - An optional user context for bcFunc 325145480ffeSMatthew G. Knepley 325245480ffeSMatthew G. Knepley Output Parameters: 325345480ffeSMatthew G. Knepley - bd - The boundary number 325445480ffeSMatthew G. Knepley 325545480ffeSMatthew G. Knepley Options Database Keys: 325645480ffeSMatthew G. Knepley + -bc_<boundary name> <num> - Overrides the boundary ids 325745480ffeSMatthew G. Knepley - -bc_<boundary name>_comp <num> - Overrides the boundary components 325845480ffeSMatthew G. Knepley 325945480ffeSMatthew G. Knepley Note: 326045480ffeSMatthew G. Knepley This function should only be used with DMForest currently, since labels cannot be defined before the underlygin Plex is built. 326145480ffeSMatthew G. Knepley 326245480ffeSMatthew G. Knepley Both bcFunc abd bcFunc_t will depend on the boundary condition type. If the type if DM_BC_ESSENTIAL, Then the calling sequence is: 326345480ffeSMatthew G. Knepley 326445480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar bcval[]) 326545480ffeSMatthew G. Knepley 326645480ffeSMatthew G. Knepley If the type is DM_BC_ESSENTIAL_FIELD or other _FIELD value, then the calling sequence is: 326745480ffeSMatthew G. Knepley 326845480ffeSMatthew G. Knepley $ bcFunc(PetscInt dim, PetscInt Nf, PetscInt NfAux, 326945480ffeSMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 327045480ffeSMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 327145480ffeSMatthew G. Knepley $ PetscReal time, const PetscReal x[], PetscScalar bcval[]) 327245480ffeSMatthew G. Knepley 327345480ffeSMatthew G. Knepley + dim - the spatial dimension 327445480ffeSMatthew G. Knepley . Nf - the number of fields 327545480ffeSMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 327645480ffeSMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 327745480ffeSMatthew G. Knepley . u - each field evaluated at the current point 327845480ffeSMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 327945480ffeSMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 328045480ffeSMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 328145480ffeSMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 328245480ffeSMatthew G. Knepley . a - each auxiliary field evaluated at the current point 328345480ffeSMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 328445480ffeSMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 328545480ffeSMatthew G. Knepley . t - current time 328645480ffeSMatthew G. Knepley . x - coordinates of the current point 328745480ffeSMatthew G. Knepley . numConstants - number of constant parameters 328845480ffeSMatthew G. Knepley . constants - constant parameters 328945480ffeSMatthew G. Knepley - bcval - output values at the current point 329045480ffeSMatthew G. Knepley 329145480ffeSMatthew G. Knepley Level: developer 329245480ffeSMatthew G. Knepley 329345480ffeSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSSetResidual(), PetscDSSetBdResidual() 329445480ffeSMatthew G. Knepley @*/ 329545480ffeSMatthew G. Knepley PetscErrorCode PetscDSAddBoundaryByName(PetscDS ds, DMBoundaryConditionType type, const char name[], const char lname[], PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx, PetscInt *bd) 329645480ffeSMatthew G. Knepley { 329745480ffeSMatthew G. Knepley DSBoundary head = ds->boundary, b; 329845480ffeSMatthew G. Knepley PetscInt n = 0; 329945480ffeSMatthew G. Knepley PetscErrorCode ierr; 330045480ffeSMatthew G. Knepley 330145480ffeSMatthew G. Knepley PetscFunctionBegin; 330245480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 330345480ffeSMatthew G. Knepley PetscValidLogicalCollectiveEnum(ds, type, 2); 330445480ffeSMatthew G. Knepley PetscValidCharPointer(name, 3); 330545480ffeSMatthew G. Knepley PetscValidCharPointer(lname, 4); 330645480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nv, 5); 330745480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, field, 7); 330845480ffeSMatthew G. Knepley PetscValidLogicalCollectiveInt(ds, Nc, 8); 330945480ffeSMatthew G. Knepley ierr = PetscNew(&b);CHKERRQ(ierr); 331045480ffeSMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 331145480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &b->wf);CHKERRQ(ierr); 331245480ffeSMatthew G. Knepley ierr = PetscWeakFormSetNumFields(b->wf, ds->Nf);CHKERRQ(ierr); 331345480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 331445480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 331545480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 331645480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 331745480ffeSMatthew G. Knepley ierr = PetscStrallocpy(lname, (char **) &b->lname);CHKERRQ(ierr); 331845480ffeSMatthew G. Knepley b->type = type; 331945480ffeSMatthew G. Knepley b->label = NULL; 332045480ffeSMatthew G. Knepley b->Nv = Nv; 332145480ffeSMatthew G. Knepley b->field = field; 332245480ffeSMatthew G. Knepley b->Nc = Nc; 332345480ffeSMatthew G. Knepley b->func = bcFunc; 332445480ffeSMatthew G. Knepley b->func_t = bcFunc_t; 332545480ffeSMatthew G. Knepley b->ctx = ctx; 332645480ffeSMatthew G. Knepley b->next = NULL; 332745480ffeSMatthew G. Knepley /* Append to linked list so that we can preserve the order */ 332845480ffeSMatthew G. Knepley if (!head) ds->boundary = b; 332945480ffeSMatthew G. Knepley while (head) { 333045480ffeSMatthew G. Knepley if (!head->next) { 333145480ffeSMatthew G. Knepley head->next = b; 333245480ffeSMatthew G. Knepley head = b; 333345480ffeSMatthew G. Knepley } 333445480ffeSMatthew G. Knepley head = head->next; 333545480ffeSMatthew G. Knepley ++n; 333645480ffeSMatthew G. Knepley } 3337064a246eSJacob Faibussowitsch if (bd) {PetscValidIntPointer(bd, 13); *bd = n;} 333858ebd649SToby Isaac PetscFunctionReturn(0); 333958ebd649SToby Isaac } 334058ebd649SToby Isaac 3341b67eacb3SMatthew G. Knepley /*@C 334256cf3b9cSMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model. The pointwise functions are used to provide boundary values for essential boundary conditions. In FEM, they are acting upon by dual basis functionals to generate FEM coefficients which are fixed. Natural boundary conditions signal to PETSc that boundary integrals should be performaed, using the kernels from PetscDSSetBdResidual(). 3343b67eacb3SMatthew G. Knepley 3344b67eacb3SMatthew G. Knepley Input Parameters: 3345b67eacb3SMatthew G. Knepley + ds - The PetscDS object 3346b67eacb3SMatthew G. Knepley . bd - The boundary condition number 3347b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 3348b67eacb3SMatthew G. Knepley . name - The BC name 334945480ffeSMatthew G. Knepley . label - The label defining constrained points 335045480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 335145480ffeSMatthew G. Knepley . values - An array of ids for constrained points 3352b67eacb3SMatthew G. Knepley . field - The field to constrain 335345480ffeSMatthew G. Knepley . Nc - The number of constrained field components 3354b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 3355b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 335656cf3b9cSMatthew G. Knepley . bcFunc_t - A pointwise function giving the time derviative of the boundary values, or NULL 3357b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 3358b67eacb3SMatthew G. Knepley 335956cf3b9cSMatthew G. Knepley Note: 336056cf3b9cSMatthew G. Knepley The boundary condition number is the order in which it was registered. The user can get the number of boundary conditions from PetscDSGetNumBoundary(). See PetscDSAddBoundary() for a description of the calling sequences for the callbacks. 33619a6efb6aSMatthew G. Knepley 3362b67eacb3SMatthew G. Knepley Level: developer 3363b67eacb3SMatthew G. Knepley 33649a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 3365b67eacb3SMatthew G. Knepley @*/ 336645480ffeSMatthew G. Knepley PetscErrorCode PetscDSUpdateBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType type, const char name[], DMLabel label, PetscInt Nv, const PetscInt values[], PetscInt field, PetscInt Nc, const PetscInt comps[], void (*bcFunc)(void), void (*bcFunc_t)(void), void *ctx) 3367b67eacb3SMatthew G. Knepley { 3368b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 3369b67eacb3SMatthew G. Knepley PetscInt n = 0; 3370b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 3371b67eacb3SMatthew G. Knepley 3372b67eacb3SMatthew G. Knepley PetscFunctionBegin; 3373b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3374b67eacb3SMatthew G. Knepley while (b) { 3375b67eacb3SMatthew G. Knepley if (n == bd) break; 3376b67eacb3SMatthew G. Knepley b = b->next; 3377b67eacb3SMatthew G. Knepley ++n; 3378b67eacb3SMatthew G. Knepley } 3379b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 3380b67eacb3SMatthew G. Knepley if (name) { 3381b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 3382b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 3383b67eacb3SMatthew G. Knepley } 3384b67eacb3SMatthew G. Knepley b->type = type; 338545480ffeSMatthew G. Knepley if (label) { 338645480ffeSMatthew G. Knepley const char *name; 338745480ffeSMatthew G. Knepley 338845480ffeSMatthew G. Knepley b->label = label; 338945480ffeSMatthew G. Knepley ierr = PetscFree(b->lname);CHKERRQ(ierr); 339045480ffeSMatthew G. Knepley ierr = PetscObjectGetName((PetscObject) label, &name);CHKERRQ(ierr); 339145480ffeSMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->lname);CHKERRQ(ierr); 339245480ffeSMatthew G. Knepley } 339345480ffeSMatthew G. Knepley if (Nv >= 0) { 339445480ffeSMatthew G. Knepley b->Nv = Nv; 339545480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 339645480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nv, &b->values);CHKERRQ(ierr); 339745480ffeSMatthew G. Knepley if (Nv) {ierr = PetscArraycpy(b->values, values, Nv);CHKERRQ(ierr);} 339845480ffeSMatthew G. Knepley } 339945480ffeSMatthew G. Knepley if (field >= 0) b->field = field; 340045480ffeSMatthew G. Knepley if (Nc >= 0) { 340145480ffeSMatthew G. Knepley b->Nc = Nc; 340245480ffeSMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 340345480ffeSMatthew G. Knepley ierr = PetscMalloc1(Nc, &b->comps);CHKERRQ(ierr); 340445480ffeSMatthew G. Knepley if (Nc) {ierr = PetscArraycpy(b->comps, comps, Nc);CHKERRQ(ierr);} 340545480ffeSMatthew G. Knepley } 340645480ffeSMatthew G. Knepley if (bcFunc) b->func = bcFunc; 340745480ffeSMatthew G. Knepley if (bcFunc_t) b->func_t = bcFunc_t; 340845480ffeSMatthew G. Knepley if (ctx) b->ctx = ctx; 3409b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 3410b67eacb3SMatthew G. Knepley } 3411b67eacb3SMatthew G. Knepley 341258ebd649SToby Isaac /*@ 341358ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 341458ebd649SToby Isaac 341558ebd649SToby Isaac Input Parameters: 341658ebd649SToby Isaac . ds - The PetscDS object 341758ebd649SToby Isaac 341858ebd649SToby Isaac Output Parameters: 341958ebd649SToby Isaac . numBd - The number of BC 342058ebd649SToby Isaac 342158ebd649SToby Isaac Level: intermediate 342258ebd649SToby Isaac 342358ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 342458ebd649SToby Isaac @*/ 342558ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 342658ebd649SToby Isaac { 342758ebd649SToby Isaac DSBoundary b = ds->boundary; 342858ebd649SToby Isaac 342958ebd649SToby Isaac PetscFunctionBegin; 343058ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 343158ebd649SToby Isaac PetscValidPointer(numBd, 2); 343258ebd649SToby Isaac *numBd = 0; 343358ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 343458ebd649SToby Isaac PetscFunctionReturn(0); 343558ebd649SToby Isaac } 343658ebd649SToby Isaac 343758ebd649SToby Isaac /*@C 34389a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 343958ebd649SToby Isaac 344058ebd649SToby Isaac Input Parameters: 344158ebd649SToby Isaac + ds - The PetscDS object 344258ebd649SToby Isaac - bd - The BC number 344358ebd649SToby Isaac 344458ebd649SToby Isaac Output Parameters: 344545480ffeSMatthew G. Knepley + wf - The PetscWeakForm holding the pointwise functions 344645480ffeSMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 344758ebd649SToby Isaac . name - The BC name 344845480ffeSMatthew G. Knepley . label - The label defining constrained points 344945480ffeSMatthew G. Knepley . Nv - The number of DMLabel ids for constrained points 345045480ffeSMatthew G. Knepley . values - An array of ids for constrained points 345158ebd649SToby Isaac . field - The field to constrain 345245480ffeSMatthew G. Knepley . Nc - The number of constrained field components 345358ebd649SToby Isaac . comps - An array of constrained component numbers 345458ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 345556cf3b9cSMatthew G. Knepley . bcFunc_t - A pointwise function giving the time derviative of the boundary values 345658ebd649SToby Isaac - ctx - An optional user context for bcFunc 345758ebd649SToby Isaac 345858ebd649SToby Isaac Options Database Keys: 345958ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 346058ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 346158ebd649SToby Isaac 346258ebd649SToby Isaac Level: developer 346358ebd649SToby Isaac 346458ebd649SToby Isaac .seealso: PetscDSAddBoundary() 346558ebd649SToby Isaac @*/ 346645480ffeSMatthew G. Knepley PetscErrorCode PetscDSGetBoundary(PetscDS ds, PetscInt bd, PetscWeakForm *wf, DMBoundaryConditionType *type, const char *name[], DMLabel *label, PetscInt *Nv, const PetscInt *values[], PetscInt *field, PetscInt *Nc, const PetscInt *comps[], void (**func)(void), void (**func_t)(void), void **ctx) 346758ebd649SToby Isaac { 346858ebd649SToby Isaac DSBoundary b = ds->boundary; 346958ebd649SToby Isaac PetscInt n = 0; 347058ebd649SToby Isaac 347158ebd649SToby Isaac PetscFunctionBegin; 347258ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 347358ebd649SToby Isaac while (b) { 347458ebd649SToby Isaac if (n == bd) break; 347558ebd649SToby Isaac b = b->next; 347658ebd649SToby Isaac ++n; 347758ebd649SToby Isaac } 347858ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 347945480ffeSMatthew G. Knepley if (wf) { 348045480ffeSMatthew G. Knepley PetscValidPointer(wf, 3); 348145480ffeSMatthew G. Knepley *wf = b->wf; 348245480ffeSMatthew G. Knepley } 3483f971fd6bSMatthew G. Knepley if (type) { 348445480ffeSMatthew G. Knepley PetscValidPointer(type, 4); 3485f971fd6bSMatthew G. Knepley *type = b->type; 348658ebd649SToby Isaac } 348758ebd649SToby Isaac if (name) { 348845480ffeSMatthew G. Knepley PetscValidPointer(name, 5); 348958ebd649SToby Isaac *name = b->name; 349058ebd649SToby Isaac } 349145480ffeSMatthew G. Knepley if (label) { 349245480ffeSMatthew G. Knepley PetscValidPointer(label, 6); 349345480ffeSMatthew G. Knepley *label = b->label; 349445480ffeSMatthew G. Knepley } 349545480ffeSMatthew G. Knepley if (Nv) { 349645480ffeSMatthew G. Knepley PetscValidIntPointer(Nv, 7); 349745480ffeSMatthew G. Knepley *Nv = b->Nv; 349845480ffeSMatthew G. Knepley } 349945480ffeSMatthew G. Knepley if (values) { 350045480ffeSMatthew G. Knepley PetscValidPointer(values, 8); 350145480ffeSMatthew G. Knepley *values = b->values; 350258ebd649SToby Isaac } 350358ebd649SToby Isaac if (field) { 350445480ffeSMatthew G. Knepley PetscValidIntPointer(field, 9); 350558ebd649SToby Isaac *field = b->field; 350658ebd649SToby Isaac } 350745480ffeSMatthew G. Knepley if (Nc) { 350845480ffeSMatthew G. Knepley PetscValidIntPointer(Nc, 10); 350945480ffeSMatthew G. Knepley *Nc = b->Nc; 351058ebd649SToby Isaac } 351158ebd649SToby Isaac if (comps) { 351245480ffeSMatthew G. Knepley PetscValidPointer(comps, 11); 351358ebd649SToby Isaac *comps = b->comps; 351458ebd649SToby Isaac } 351558ebd649SToby Isaac if (func) { 351645480ffeSMatthew G. Knepley PetscValidPointer(func, 12); 351758ebd649SToby Isaac *func = b->func; 351858ebd649SToby Isaac } 351956cf3b9cSMatthew G. Knepley if (func_t) { 352045480ffeSMatthew G. Knepley PetscValidPointer(func_t, 13); 352156cf3b9cSMatthew G. Knepley *func_t = b->func_t; 352256cf3b9cSMatthew G. Knepley } 352358ebd649SToby Isaac if (ctx) { 352445480ffeSMatthew G. Knepley PetscValidPointer(ctx, 14); 352558ebd649SToby Isaac *ctx = b->ctx; 352658ebd649SToby Isaac } 352758ebd649SToby Isaac PetscFunctionReturn(0); 352858ebd649SToby Isaac } 352958ebd649SToby Isaac 353045480ffeSMatthew G. Knepley static PetscErrorCode DSBoundaryDuplicate_Internal(DSBoundary b, DSBoundary *bNew) 353145480ffeSMatthew G. Knepley { 353245480ffeSMatthew G. Knepley PetscErrorCode ierr; 353345480ffeSMatthew G. Knepley 353445480ffeSMatthew G. Knepley PetscFunctionBegin; 353545480ffeSMatthew G. Knepley ierr = PetscNew(bNew);CHKERRQ(ierr); 353645480ffeSMatthew G. Knepley ierr = PetscWeakFormCreate(PETSC_COMM_SELF, &(*bNew)->wf);CHKERRQ(ierr); 353745480ffeSMatthew G. Knepley ierr = PetscWeakFormCopy(b->wf, (*bNew)->wf);CHKERRQ(ierr); 353845480ffeSMatthew G. Knepley ierr = PetscStrallocpy(b->name,(char **) &((*bNew)->name));CHKERRQ(ierr); 353945480ffeSMatthew G. Knepley ierr = PetscStrallocpy(b->lname,(char **) &((*bNew)->lname));CHKERRQ(ierr); 354045480ffeSMatthew G. Knepley (*bNew)->type = b->type; 354145480ffeSMatthew G. Knepley (*bNew)->label = b->label; 354245480ffeSMatthew G. Knepley (*bNew)->Nv = b->Nv; 354345480ffeSMatthew G. Knepley ierr = PetscMalloc1(b->Nv, &(*bNew)->values);CHKERRQ(ierr); 354445480ffeSMatthew G. Knepley ierr = PetscArraycpy((*bNew)->values, b->values, b->Nv);CHKERRQ(ierr); 354545480ffeSMatthew G. Knepley (*bNew)->field = b->field; 354645480ffeSMatthew G. Knepley (*bNew)->Nc = b->Nc; 354745480ffeSMatthew G. Knepley ierr = PetscMalloc1(b->Nc, &(*bNew)->comps);CHKERRQ(ierr); 354845480ffeSMatthew G. Knepley ierr = PetscArraycpy((*bNew)->comps, b->comps, b->Nc);CHKERRQ(ierr); 354945480ffeSMatthew G. Knepley (*bNew)->func = b->func; 355045480ffeSMatthew G. Knepley (*bNew)->func_t = b->func_t; 355145480ffeSMatthew G. Knepley (*bNew)->ctx = b->ctx; 355245480ffeSMatthew G. Knepley PetscFunctionReturn(0); 355345480ffeSMatthew G. Knepley } 355445480ffeSMatthew G. Knepley 35559252d075SMatthew G. Knepley /*@ 35569252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 35579252d075SMatthew G. Knepley 35589252d075SMatthew G. Knepley Not collective 35599252d075SMatthew G. Knepley 356036951cb5SMatthew G. Knepley Input Parameters: 356136951cb5SMatthew G. Knepley + ds - The source PetscDS object 356236951cb5SMatthew G. Knepley . numFields - The number of selected fields, or PETSC_DEFAULT for all fields 356336951cb5SMatthew G. Knepley - fields - The selected fields, or NULL for all fields 35649252d075SMatthew G. Knepley 35659252d075SMatthew G. Knepley Output Parameter: 356636951cb5SMatthew G. Knepley . newds - The target PetscDS, now with a copy of the boundary conditions 35679252d075SMatthew G. Knepley 35689252d075SMatthew G. Knepley Level: intermediate 35699252d075SMatthew G. Knepley 35709252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 35719252d075SMatthew G. Knepley @*/ 357236951cb5SMatthew G. Knepley PetscErrorCode PetscDSCopyBoundary(PetscDS ds, PetscInt numFields, const PetscInt fields[], PetscDS newds) 3573dff059c6SToby Isaac { 357445480ffeSMatthew G. Knepley DSBoundary b, *lastnext; 3575dff059c6SToby Isaac PetscErrorCode ierr; 3576dff059c6SToby Isaac 3577dff059c6SToby Isaac PetscFunctionBegin; 357836951cb5SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 357936951cb5SMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 4); 358036951cb5SMatthew G. Knepley if (ds == newds) PetscFunctionReturn(0); 358145480ffeSMatthew G. Knepley ierr = PetscDSDestroyBoundary(newds);CHKERRQ(ierr); 358236951cb5SMatthew G. Knepley lastnext = &(newds->boundary); 358336951cb5SMatthew G. Knepley for (b = ds->boundary; b; b = b->next) { 3584dff059c6SToby Isaac DSBoundary bNew; 358536951cb5SMatthew G. Knepley PetscInt fieldNew = -1; 3586dff059c6SToby Isaac 358736951cb5SMatthew G. Knepley if (numFields > 0 && fields) { 358836951cb5SMatthew G. Knepley PetscInt f; 358936951cb5SMatthew G. Knepley 359036951cb5SMatthew G. Knepley for (f = 0; f < numFields; ++f) if (b->field == fields[f]) break; 359136951cb5SMatthew G. Knepley if (f == numFields) continue; 359236951cb5SMatthew G. Knepley fieldNew = f; 359336951cb5SMatthew G. Knepley } 359445480ffeSMatthew G. Knepley ierr = DSBoundaryDuplicate_Internal(b, &bNew);CHKERRQ(ierr); 359536951cb5SMatthew G. Knepley bNew->field = fieldNew < 0 ? b->field : fieldNew; 3596dff059c6SToby Isaac *lastnext = bNew; 3597dff059c6SToby Isaac lastnext = &(bNew->next); 3598dff059c6SToby Isaac } 3599dff059c6SToby Isaac PetscFunctionReturn(0); 3600dff059c6SToby Isaac } 3601dff059c6SToby Isaac 36026c1eb96dSMatthew G. Knepley /*@ 360345480ffeSMatthew G. Knepley PetscDSDestroyBoundary - Remove all DMBoundary objects from the PetscDS 360445480ffeSMatthew G. Knepley 360545480ffeSMatthew G. Knepley Not collective 360645480ffeSMatthew G. Knepley 360745480ffeSMatthew G. Knepley Input Parameter: 360845480ffeSMatthew G. Knepley . ds - The PetscDS object 360945480ffeSMatthew G. Knepley 361045480ffeSMatthew G. Knepley Level: intermediate 361145480ffeSMatthew G. Knepley 361245480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations() 361345480ffeSMatthew G. Knepley @*/ 361445480ffeSMatthew G. Knepley PetscErrorCode PetscDSDestroyBoundary(PetscDS ds) 361545480ffeSMatthew G. Knepley { 361645480ffeSMatthew G. Knepley DSBoundary next = ds->boundary; 361745480ffeSMatthew G. Knepley PetscErrorCode ierr; 361845480ffeSMatthew G. Knepley 361945480ffeSMatthew G. Knepley PetscFunctionBegin; 362045480ffeSMatthew G. Knepley while (next) { 362145480ffeSMatthew G. Knepley DSBoundary b = next; 362245480ffeSMatthew G. Knepley 362345480ffeSMatthew G. Knepley next = b->next; 362445480ffeSMatthew G. Knepley ierr = PetscWeakFormDestroy(&b->wf);CHKERRQ(ierr); 362545480ffeSMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 362645480ffeSMatthew G. Knepley ierr = PetscFree(b->lname);CHKERRQ(ierr); 362745480ffeSMatthew G. Knepley ierr = PetscFree(b->values);CHKERRQ(ierr); 362845480ffeSMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 362945480ffeSMatthew G. Knepley ierr = PetscFree(b);CHKERRQ(ierr); 363045480ffeSMatthew G. Knepley } 363145480ffeSMatthew G. Knepley PetscFunctionReturn(0); 363245480ffeSMatthew G. Knepley } 363345480ffeSMatthew G. Knepley 363445480ffeSMatthew G. Knepley /*@ 36356c1eb96dSMatthew G. Knepley PetscDSSelectDiscretizations - Copy discretizations to the new problem with different field layout 36366c1eb96dSMatthew G. Knepley 36376c1eb96dSMatthew G. Knepley Not collective 36386c1eb96dSMatthew G. Knepley 36396c1eb96dSMatthew G. Knepley Input Parameter: 36406c1eb96dSMatthew G. Knepley + prob - The PetscDS object 36416c1eb96dSMatthew G. Knepley . numFields - Number of new fields 36426c1eb96dSMatthew G. Knepley - fields - Old field number for each new field 36436c1eb96dSMatthew G. Knepley 36446c1eb96dSMatthew G. Knepley Output Parameter: 36456c1eb96dSMatthew G. Knepley . newprob - The PetscDS copy 36466c1eb96dSMatthew G. Knepley 36476c1eb96dSMatthew G. Knepley Level: intermediate 36486c1eb96dSMatthew G. Knepley 36496c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectEquations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 36506c1eb96dSMatthew G. Knepley @*/ 36516c1eb96dSMatthew G. Knepley PetscErrorCode PetscDSSelectDiscretizations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 36526c1eb96dSMatthew G. Knepley { 36536c1eb96dSMatthew G. Knepley PetscInt Nf, Nfn, fn; 36546c1eb96dSMatthew G. Knepley PetscErrorCode ierr; 36556c1eb96dSMatthew G. Knepley 36566c1eb96dSMatthew G. Knepley PetscFunctionBegin; 36576c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 36586c1eb96dSMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 36596c1eb96dSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 36606c1eb96dSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 36616c1eb96dSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 366245480ffeSMatthew G. Knepley numFields = numFields < 0 ? Nf : numFields; 36636c1eb96dSMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 36646c1eb96dSMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 36656c1eb96dSMatthew G. Knepley PetscObject disc; 36666c1eb96dSMatthew G. Knepley 36676c1eb96dSMatthew G. Knepley if (f >= Nf) continue; 36686c1eb96dSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &disc);CHKERRQ(ierr); 36696c1eb96dSMatthew G. Knepley ierr = PetscDSSetDiscretization(newprob, fn, disc);CHKERRQ(ierr); 36706c1eb96dSMatthew G. Knepley } 36716c1eb96dSMatthew G. Knepley PetscFunctionReturn(0); 36726c1eb96dSMatthew G. Knepley } 36736c1eb96dSMatthew G. Knepley 36746c1eb96dSMatthew G. Knepley /*@ 36759252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 36769252d075SMatthew G. Knepley 36779252d075SMatthew G. Knepley Not collective 36789252d075SMatthew G. Knepley 36799252d075SMatthew G. Knepley Input Parameter: 36809252d075SMatthew G. Knepley + prob - The PetscDS object 36819252d075SMatthew G. Knepley . numFields - Number of new fields 36829252d075SMatthew G. Knepley - fields - Old field number for each new field 36839252d075SMatthew G. Knepley 36849252d075SMatthew G. Knepley Output Parameter: 36859252d075SMatthew G. Knepley . newprob - The PetscDS copy 36869252d075SMatthew G. Knepley 36879252d075SMatthew G. Knepley Level: intermediate 36889252d075SMatthew G. Knepley 36896c1eb96dSMatthew G. Knepley .seealso: PetscDSSelectDiscretizations(), PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 36909252d075SMatthew G. Knepley @*/ 36919252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 36929252d075SMatthew G. Knepley { 36939252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 36949252d075SMatthew G. Knepley PetscErrorCode ierr; 36959252d075SMatthew G. Knepley 36969252d075SMatthew G. Knepley PetscFunctionBegin; 36979252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 36989252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 36999252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 37009252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 37019252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 37029252d075SMatthew 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); 37039252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 37049252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 37059252d075SMatthew G. Knepley PetscPointFunc obj; 37069252d075SMatthew G. Knepley PetscPointFunc f0, f1; 37079252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 37089252d075SMatthew G. Knepley PetscRiemannFunc r; 37099252d075SMatthew G. Knepley 3710c52f1e13SMatthew G. Knepley if (f >= Nf) continue; 37119252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 37129252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 37139252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 37149252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 37159252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 37169252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 37179252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 37189252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 37199252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 37209252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 37219252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 37229252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 37239252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 37249252d075SMatthew G. Knepley 3725c52f1e13SMatthew G. Knepley if (g >= Nf) continue; 37269252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 37279252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 37289252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 37299252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 37306c1eb96dSMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(newprob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 37319252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 37329252d075SMatthew G. Knepley } 37339252d075SMatthew G. Knepley } 37349252d075SMatthew G. Knepley PetscFunctionReturn(0); 37359252d075SMatthew G. Knepley } 37369252d075SMatthew G. Knepley 3737da51fcedSMatthew G. Knepley /*@ 3738da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3739da51fcedSMatthew G. Knepley 3740da51fcedSMatthew G. Knepley Not collective 3741da51fcedSMatthew G. Knepley 3742da51fcedSMatthew G. Knepley Input Parameter: 3743da51fcedSMatthew G. Knepley . prob - The PetscDS object 3744da51fcedSMatthew G. Knepley 3745da51fcedSMatthew G. Knepley Output Parameter: 3746da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3747da51fcedSMatthew G. Knepley 3748da51fcedSMatthew G. Knepley Level: intermediate 3749da51fcedSMatthew G. Knepley 37509252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3751da51fcedSMatthew G. Knepley @*/ 3752da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3753da51fcedSMatthew G. Knepley { 37549252d075SMatthew G. Knepley PetscInt Nf, Ng; 3755da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3756da51fcedSMatthew G. Knepley 3757da51fcedSMatthew G. Knepley PetscFunctionBegin; 3758da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3759da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3760da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3761da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 376213903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 37639252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 37649252d075SMatthew G. Knepley PetscFunctionReturn(0); 37659252d075SMatthew G. Knepley } 376645480ffeSMatthew G. Knepley 37679252d075SMatthew G. Knepley /*@ 37689252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3769da51fcedSMatthew G. Knepley 37709252d075SMatthew G. Knepley Not collective 37719252d075SMatthew G. Knepley 37729252d075SMatthew G. Knepley Input Parameter: 37739252d075SMatthew G. Knepley . prob - The PetscDS object 37749252d075SMatthew G. Knepley 37759252d075SMatthew G. Knepley Output Parameter: 37769252d075SMatthew G. Knepley . newprob - The PetscDS copy 37779252d075SMatthew G. Knepley 37789252d075SMatthew G. Knepley Level: intermediate 37799252d075SMatthew G. Knepley 37809252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 37819252d075SMatthew G. Knepley @*/ 37829252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 37839252d075SMatthew G. Knepley { 37849252d075SMatthew G. Knepley PetscInt Nc; 37859252d075SMatthew G. Knepley const PetscScalar *constants; 37869252d075SMatthew G. Knepley PetscErrorCode ierr; 37879252d075SMatthew G. Knepley 37889252d075SMatthew G. Knepley PetscFunctionBegin; 37899252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 37909252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 37919252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 37929252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3793da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3794da51fcedSMatthew G. Knepley } 3795da51fcedSMatthew G. Knepley 379645480ffeSMatthew G. Knepley /*@ 379745480ffeSMatthew G. Knepley PetscDSCopyExactSolutions - Copy all exact solutions to the new problem 379845480ffeSMatthew G. Knepley 379945480ffeSMatthew G. Knepley Not collective 380045480ffeSMatthew G. Knepley 380145480ffeSMatthew G. Knepley Input Parameter: 380245480ffeSMatthew G. Knepley . ds - The PetscDS object 380345480ffeSMatthew G. Knepley 380445480ffeSMatthew G. Knepley Output Parameter: 380545480ffeSMatthew G. Knepley . newds - The PetscDS copy 380645480ffeSMatthew G. Knepley 380745480ffeSMatthew G. Knepley Level: intermediate 380845480ffeSMatthew G. Knepley 380945480ffeSMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 381045480ffeSMatthew G. Knepley @*/ 381145480ffeSMatthew G. Knepley PetscErrorCode PetscDSCopyExactSolutions(PetscDS ds, PetscDS newds) 381245480ffeSMatthew G. Knepley { 381345480ffeSMatthew G. Knepley PetscSimplePointFunc sol; 381445480ffeSMatthew G. Knepley void *ctx; 381545480ffeSMatthew G. Knepley PetscInt Nf, f; 381645480ffeSMatthew G. Knepley PetscErrorCode ierr; 381745480ffeSMatthew G. Knepley 381845480ffeSMatthew G. Knepley PetscFunctionBegin; 381945480ffeSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 382045480ffeSMatthew G. Knepley PetscValidHeaderSpecific(newds, PETSCDS_CLASSID, 2); 382145480ffeSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 382245480ffeSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 382345480ffeSMatthew G. Knepley ierr = PetscDSGetExactSolution(ds, f, &sol, &ctx);CHKERRQ(ierr); 382445480ffeSMatthew G. Knepley ierr = PetscDSSetExactSolution(newds, f, sol, ctx);CHKERRQ(ierr); 382545480ffeSMatthew G. Knepley ierr = PetscDSGetExactSolutionTimeDerivative(ds, f, &sol, &ctx);CHKERRQ(ierr); 382645480ffeSMatthew G. Knepley ierr = PetscDSSetExactSolutionTimeDerivative(newds, f, sol, ctx);CHKERRQ(ierr); 382745480ffeSMatthew G. Knepley } 382845480ffeSMatthew G. Knepley PetscFunctionReturn(0); 382945480ffeSMatthew G. Knepley } 383045480ffeSMatthew G. Knepley 3831b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3832b1353e8eSMatthew G. Knepley { 3833df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3834b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3835b1353e8eSMatthew G. Knepley 3836b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3837b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3838b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3839b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3840b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3841df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3842df3a45bdSMatthew 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); 3843df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3844df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3845b1353e8eSMatthew G. Knepley PetscInt cdim; 3846b1353e8eSMatthew G. Knepley 3847df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3848b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3849df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3850b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3851b1353e8eSMatthew G. Knepley PetscFE subfe; 3852b1353e8eSMatthew G. Knepley PetscObject obj; 3853b1353e8eSMatthew G. Knepley PetscClassId id; 3854b1353e8eSMatthew G. Knepley 3855b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3856b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3857b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3858b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3859df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3860b1353e8eSMatthew G. Knepley } 3861b1353e8eSMatthew G. Knepley } 3862df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3863b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3864b1353e8eSMatthew G. Knepley } 3865b1353e8eSMatthew G. Knepley 3866665f567fSMatthew G. Knepley PetscErrorCode PetscDSGetDiscType_Internal(PetscDS ds, PetscInt f, PetscDiscType *disctype) 3867c7bd5f0bSMatthew G. Knepley { 3868c7bd5f0bSMatthew G. Knepley PetscObject obj; 3869c7bd5f0bSMatthew G. Knepley PetscClassId id; 3870c7bd5f0bSMatthew G. Knepley PetscInt Nf; 3871c7bd5f0bSMatthew G. Knepley PetscErrorCode ierr; 3872c7bd5f0bSMatthew G. Knepley 3873c7bd5f0bSMatthew G. Knepley PetscFunctionBegin; 3874c7bd5f0bSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 3875665f567fSMatthew G. Knepley PetscValidPointer(disctype, 3); 3876665f567fSMatthew G. Knepley *disctype = PETSC_DISC_NONE; 3877c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetNumFields(ds, &Nf);CHKERRQ(ierr); 3878c7bd5f0bSMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) ds), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 3879c7bd5f0bSMatthew G. Knepley ierr = PetscDSGetDiscretization(ds, f, &obj);CHKERRQ(ierr); 3880665f567fSMatthew G. Knepley if (obj) { 3881c7bd5f0bSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3882665f567fSMatthew G. Knepley if (id == PETSCFE_CLASSID) *disctype = PETSC_DISC_FE; 3883665f567fSMatthew G. Knepley else *disctype = PETSC_DISC_FV; 3884665f567fSMatthew G. Knepley } 3885c7bd5f0bSMatthew G. Knepley PetscFunctionReturn(0); 3886c7bd5f0bSMatthew G. Knepley } 3887c7bd5f0bSMatthew G. Knepley 38886528b96dSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS ds) 38892764a2aaSMatthew G. Knepley { 3890931fb3b8SToby Isaac PetscErrorCode ierr; 3891931fb3b8SToby Isaac 38922764a2aaSMatthew G. Knepley PetscFunctionBegin; 38936528b96dSMatthew G. Knepley ierr = PetscFree(ds->data);CHKERRQ(ierr); 38942764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 38952764a2aaSMatthew G. Knepley } 38962764a2aaSMatthew G. Knepley 38976528b96dSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS ds) 38982764a2aaSMatthew G. Knepley { 38992764a2aaSMatthew G. Knepley PetscFunctionBegin; 39006528b96dSMatthew G. Knepley ds->ops->setfromoptions = NULL; 39016528b96dSMatthew G. Knepley ds->ops->setup = NULL; 39026528b96dSMatthew G. Knepley ds->ops->view = NULL; 39036528b96dSMatthew G. Knepley ds->ops->destroy = PetscDSDestroy_Basic; 39042764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 39052764a2aaSMatthew G. Knepley } 39062764a2aaSMatthew G. Knepley 39072764a2aaSMatthew G. Knepley /*MC 39082764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 39092764a2aaSMatthew G. Knepley 39102764a2aaSMatthew G. Knepley Level: intermediate 39112764a2aaSMatthew G. Knepley 39122764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 39132764a2aaSMatthew G. Knepley M*/ 39142764a2aaSMatthew G. Knepley 39156528b96dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS ds) 39162764a2aaSMatthew G. Knepley { 39172764a2aaSMatthew G. Knepley PetscDS_Basic *b; 39182764a2aaSMatthew G. Knepley PetscErrorCode ierr; 39192764a2aaSMatthew G. Knepley 39202764a2aaSMatthew G. Knepley PetscFunctionBegin; 39216528b96dSMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 39226528b96dSMatthew G. Knepley ierr = PetscNewLog(ds, &b);CHKERRQ(ierr); 39236528b96dSMatthew G. Knepley ds->data = b; 39242764a2aaSMatthew G. Knepley 39256528b96dSMatthew G. Knepley ierr = PetscDSInitialize_Basic(ds);CHKERRQ(ierr); 39262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 39272764a2aaSMatthew G. Knepley } 3928