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 82764a2aaSMatthew G. Knepley /*@C 92764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 102764a2aaSMatthew G. Knepley 112764a2aaSMatthew G. Knepley Not Collective 122764a2aaSMatthew G. Knepley 132764a2aaSMatthew G. Knepley Input Parameters: 142764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 152764a2aaSMatthew G. Knepley - create_func - The creation routine itself 162764a2aaSMatthew G. Knepley 172764a2aaSMatthew G. Knepley Notes: 182764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 192764a2aaSMatthew G. Knepley 202764a2aaSMatthew G. Knepley Sample usage: 212764a2aaSMatthew G. Knepley .vb 222764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 232764a2aaSMatthew G. Knepley .ve 242764a2aaSMatthew G. Knepley 252764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 262764a2aaSMatthew G. Knepley .vb 272764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 282764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 292764a2aaSMatthew G. Knepley .ve 302764a2aaSMatthew G. Knepley or at runtime via the option 312764a2aaSMatthew G. Knepley .vb 322764a2aaSMatthew G. Knepley -petscds_type my_ds 332764a2aaSMatthew G. Knepley .ve 342764a2aaSMatthew G. Knepley 352764a2aaSMatthew G. Knepley Level: advanced 362764a2aaSMatthew G. Knepley 37f5f57ec0SBarry Smith Not available from Fortran 38f5f57ec0SBarry Smith 392764a2aaSMatthew G. Knepley .keywords: PetscDS, register 402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy() 412764a2aaSMatthew G. Knepley 422764a2aaSMatthew G. Knepley @*/ 432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS)) 442764a2aaSMatthew G. Knepley { 452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 462764a2aaSMatthew G. Knepley 472764a2aaSMatthew G. Knepley PetscFunctionBegin; 482764a2aaSMatthew G. Knepley ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr); 492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 502764a2aaSMatthew G. Knepley } 512764a2aaSMatthew G. Knepley 522764a2aaSMatthew G. Knepley /*@C 532764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 542764a2aaSMatthew G. Knepley 552764a2aaSMatthew G. Knepley Collective on PetscDS 562764a2aaSMatthew G. Knepley 572764a2aaSMatthew G. Knepley Input Parameters: 582764a2aaSMatthew G. Knepley + prob - The PetscDS object 592764a2aaSMatthew G. Knepley - name - The kind of system 602764a2aaSMatthew G. Knepley 612764a2aaSMatthew G. Knepley Options Database Key: 622764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 632764a2aaSMatthew G. Knepley 642764a2aaSMatthew G. Knepley Level: intermediate 652764a2aaSMatthew G. Knepley 66f5f57ec0SBarry Smith Not available from Fortran 67f5f57ec0SBarry Smith 682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type 692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate() 702764a2aaSMatthew G. Knepley @*/ 712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 722764a2aaSMatthew G. Knepley { 732764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 742764a2aaSMatthew G. Knepley PetscBool match; 752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 762764a2aaSMatthew G. Knepley 772764a2aaSMatthew G. Knepley PetscFunctionBegin; 782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 792764a2aaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr); 802764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 812764a2aaSMatthew G. Knepley 820f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 832764a2aaSMatthew G. Knepley ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr); 842764a2aaSMatthew G. Knepley if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 852764a2aaSMatthew G. Knepley 862764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 872764a2aaSMatthew G. Knepley ierr = (*prob->ops->destroy)(prob);CHKERRQ(ierr); 882764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 892764a2aaSMatthew G. Knepley } 902764a2aaSMatthew G. Knepley ierr = (*r)(prob);CHKERRQ(ierr); 912764a2aaSMatthew G. Knepley ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr); 922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 932764a2aaSMatthew G. Knepley } 942764a2aaSMatthew G. Knepley 952764a2aaSMatthew G. Knepley /*@C 962764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 972764a2aaSMatthew G. Knepley 982764a2aaSMatthew G. Knepley Not Collective 992764a2aaSMatthew G. Knepley 1002764a2aaSMatthew G. Knepley Input Parameter: 1012764a2aaSMatthew G. Knepley . prob - The PetscDS 1022764a2aaSMatthew G. Knepley 1032764a2aaSMatthew G. Knepley Output Parameter: 1042764a2aaSMatthew G. Knepley . name - The PetscDS type name 1052764a2aaSMatthew G. Knepley 1062764a2aaSMatthew G. Knepley Level: intermediate 1072764a2aaSMatthew G. Knepley 108f5f57ec0SBarry Smith Not available from Fortran 109f5f57ec0SBarry Smith 1102764a2aaSMatthew G. Knepley .keywords: PetscDS, get, type, name 1112764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1122764a2aaSMatthew G. Knepley @*/ 1132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1142764a2aaSMatthew G. Knepley { 1152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1162764a2aaSMatthew G. Knepley 1172764a2aaSMatthew G. Knepley PetscFunctionBegin; 1182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 119c959eef4SJed Brown PetscValidPointer(name, 2); 1200f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 1212764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1232764a2aaSMatthew G. Knepley } 1242764a2aaSMatthew G. Knepley 1257d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1267d8a60eaSMatthew G. Knepley { 1277d8a60eaSMatthew G. Knepley PetscViewerFormat format; 12897b6e6e8SMatthew G. Knepley const PetscScalar *constants; 12997b6e6e8SMatthew G. Knepley PetscInt numConstants, f; 1307d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1317d8a60eaSMatthew G. Knepley 1327d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1337d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1347d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1357d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1367d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1377d8a60eaSMatthew G. Knepley PetscObject obj; 1387d8a60eaSMatthew G. Knepley PetscClassId id; 139f35450b9SMatthew G. Knepley PetscQuadrature q; 1407d8a60eaSMatthew G. Knepley const char *name; 141f35450b9SMatthew G. Knepley PetscInt Nc, Nq, Nqc; 1427d8a60eaSMatthew G. Knepley 1437d8a60eaSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 1447d8a60eaSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 1457d8a60eaSMatthew G. Knepley ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr); 1467d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr); 1477d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1487d8a60eaSMatthew G. Knepley ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr); 149f35450b9SMatthew G. Knepley ierr = PetscFEGetQuadrature((PetscFE) obj, &q);CHKERRQ(ierr); 1507d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1517d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1527d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 153f35450b9SMatthew G. Knepley ierr = PetscFVGetQuadrature((PetscFV) obj, &q);CHKERRQ(ierr); 1547d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1557d8a60eaSMatthew G. Knepley } 15697b6e6e8SMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %D", f); 15797b6e6e8SMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%D components", Nc);CHKERRQ(ierr);} 15897b6e6e8SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, "%D component ", Nc);CHKERRQ(ierr);} 159249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 160249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 161a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+0]) { 162a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);} 163a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);} 164a6cbbb48SMatthew G. Knepley } else { 165a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);} 166a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);} 167a6cbbb48SMatthew G. Knepley } 1683e60c2a6SMatthew G. Knepley if (q) { 169f35450b9SMatthew G. Knepley ierr = PetscQuadratureGetData(q, NULL, &Nqc, &Nq, NULL, NULL);CHKERRQ(ierr); 170f35450b9SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " (Nq %D Nqc %D)", Nq, Nqc);CHKERRQ(ierr); 1713e60c2a6SMatthew G. Knepley } 1727d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1735d160056SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1747d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1757d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1765d160056SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1777d8a60eaSMatthew G. Knepley } 17897b6e6e8SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &numConstants, &constants);CHKERRQ(ierr); 17997b6e6e8SMatthew G. Knepley if (numConstants) { 18097b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "%D constants\n", numConstants);CHKERRQ(ierr); 18197b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 18257fc01e9SMatthew G. Knepley for (f = 0; f < numConstants; ++f) {ierr = PetscViewerASCIIPrintf(viewer, "%g\n", (double) PetscRealPart(constants[f]));CHKERRQ(ierr);} 18397b6e6e8SMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 18497b6e6e8SMatthew G. Knepley } 1857d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1867d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 1877d8a60eaSMatthew G. Knepley } 1887d8a60eaSMatthew G. Knepley 1892764a2aaSMatthew G. Knepley /*@C 1902764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 1912764a2aaSMatthew G. Knepley 1922764a2aaSMatthew G. Knepley Collective on PetscDS 1932764a2aaSMatthew G. Knepley 1942764a2aaSMatthew G. Knepley Input Parameter: 1952764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 1962764a2aaSMatthew G. Knepley - v - the viewer 1972764a2aaSMatthew G. Knepley 1982764a2aaSMatthew G. Knepley Level: developer 1992764a2aaSMatthew G. Knepley 2002764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 2012764a2aaSMatthew G. Knepley @*/ 2022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 2032764a2aaSMatthew G. Knepley { 2047d8a60eaSMatthew G. Knepley PetscBool iascii; 2052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2062764a2aaSMatthew G. Knepley 2072764a2aaSMatthew G. Knepley PetscFunctionBegin; 2082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2092764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 2107d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2117d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2127d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2132764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2152764a2aaSMatthew G. Knepley } 2162764a2aaSMatthew G. Knepley 2172764a2aaSMatthew G. Knepley /*@ 2182764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2192764a2aaSMatthew G. Knepley 2202764a2aaSMatthew G. Knepley Collective on PetscDS 2212764a2aaSMatthew G. Knepley 2222764a2aaSMatthew G. Knepley Input Parameter: 2232764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2242764a2aaSMatthew G. Knepley 2252764a2aaSMatthew G. Knepley Options Database: 22655c1f793SMatthew G. Knepley + -petscds_type <type> : Set the DS type 22755c1f793SMatthew G. Knepley . -petscds_view <view opt> : View the DS 22855c1f793SMatthew G. Knepley . -petscds_jac_pre : Turn formation of a separate Jacobian preconditioner on and off 22955c1f793SMatthew G. Knepley . -bc_<name> <ids> : Specify a list of label ids for a boundary condition 23055c1f793SMatthew G. Knepley - -bc_<name>_comp <comps> : Specify a list of field components to constrain for a boundary condition 2312764a2aaSMatthew G. Knepley 2322764a2aaSMatthew G. Knepley Level: developer 2332764a2aaSMatthew G. Knepley 2342764a2aaSMatthew G. Knepley .seealso PetscDSView() 2352764a2aaSMatthew G. Knepley @*/ 2362764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2372764a2aaSMatthew G. Knepley { 238f1fd5e65SToby Isaac DSBoundary b; 2392764a2aaSMatthew G. Knepley const char *defaultType; 2402764a2aaSMatthew G. Knepley char name[256]; 2412764a2aaSMatthew G. Knepley PetscBool flg; 2422764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2432764a2aaSMatthew G. Knepley 2442764a2aaSMatthew G. Knepley PetscFunctionBegin; 2452764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2462764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2472764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2482764a2aaSMatthew G. Knepley } else { 2492764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2502764a2aaSMatthew G. Knepley } 2510f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2522764a2aaSMatthew G. Knepley 2532764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 254f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 255f1fd5e65SToby Isaac char optname[1024]; 256f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 257f1fd5e65SToby Isaac PetscBool flg; 258f1fd5e65SToby Isaac 259f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name);CHKERRQ(ierr); 260f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 261f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg);CHKERRQ(ierr); 262f1fd5e65SToby Isaac if (flg) { 263f1fd5e65SToby Isaac b->numids = len; 264f1fd5e65SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 265f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->ids);CHKERRQ(ierr); 266f1fd5e65SToby Isaac ierr = PetscMemcpy(b->ids, ids, len*sizeof(PetscInt));CHKERRQ(ierr); 267f1fd5e65SToby Isaac } 268e7b0402cSSander Arens len = 1024; 269f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name);CHKERRQ(ierr); 270f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 271f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg);CHKERRQ(ierr); 272f1fd5e65SToby Isaac if (flg) { 273f1fd5e65SToby Isaac b->numcomps = len; 274f1fd5e65SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 275f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->comps);CHKERRQ(ierr); 276f1fd5e65SToby Isaac ierr = PetscMemcpy(b->comps, ids, len*sizeof(PetscInt));CHKERRQ(ierr); 277f1fd5e65SToby Isaac } 278f1fd5e65SToby Isaac } 2792764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2802764a2aaSMatthew G. Knepley if (flg) { 2812764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2822764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2832764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2842764a2aaSMatthew G. Knepley } 28555c1f793SMatthew G. Knepley ierr = PetscOptionsBool("-petscds_jac_pre", "Discrete System", "PetscDSUseJacobianPreconditioner", prob->useJacPre, &prob->useJacPre, &flg);CHKERRQ(ierr); 2862764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2872764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2880633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 2892764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2905d160056SMatthew G. Knepley if (prob->Nf) {ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);} 2912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2922764a2aaSMatthew G. Knepley } 2932764a2aaSMatthew G. Knepley 2942764a2aaSMatthew G. Knepley /*@C 2952764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2962764a2aaSMatthew G. Knepley 2972764a2aaSMatthew G. Knepley Collective on PetscDS 2982764a2aaSMatthew G. Knepley 2992764a2aaSMatthew G. Knepley Input Parameter: 3002764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 3012764a2aaSMatthew G. Knepley 3022764a2aaSMatthew G. Knepley Level: developer 3032764a2aaSMatthew G. Knepley 3042764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3052764a2aaSMatthew G. Knepley @*/ 3062764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3072764a2aaSMatthew G. Knepley { 3082764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 309d1506c7cSMatthew G. Knepley PetscInt dim, dimEmbed, work, NcMax = 0, NqMax = 0, f; 3102764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3112764a2aaSMatthew G. Knepley 3122764a2aaSMatthew G. Knepley PetscFunctionBegin; 3132764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3142764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3152764a2aaSMatthew G. Knepley /* Calculate sizes */ 3162764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 317d1506c7cSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &dimEmbed);CHKERRQ(ierr); 318f744cafaSSander Arens prob->totDim = prob->totComp = 0; 31947e57110SSander Arens ierr = PetscMalloc2(Nf,&prob->Nc,Nf,&prob->Nb);CHKERRQ(ierr); 320f744cafaSSander Arens ierr = PetscCalloc2(Nf+1,&prob->off,Nf+1,&prob->offDer);CHKERRQ(ierr); 321f744cafaSSander Arens ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisFace,Nf,&prob->basisDerFace);CHKERRQ(ierr); 3222764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3239de99aefSMatthew G. Knepley PetscObject obj; 3249de99aefSMatthew G. Knepley PetscClassId id; 3252764a2aaSMatthew G. Knepley PetscQuadrature q; 3269de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3272764a2aaSMatthew G. Knepley 3289de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3299de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3309de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3319de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3329de99aefSMatthew G. Knepley 3332764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3342764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 3352764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 3362764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 3374d0b9603SSander Arens ierr = PetscFEGetFaceTabulation(fe, &prob->basisFace[f], &prob->basisDerFace[f], NULL);CHKERRQ(ierr); 3389de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 3399de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 3409de99aefSMatthew G. Knepley 3419de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3429de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3439c3cf19fSMatthew G. Knepley Nb = Nc; 3446c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 3454d0b9603SSander Arens /* TODO: should PetscFV also have face tabulation? Otherwise there will be a null pointer in prob->basisFace */ 346abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 34747e57110SSander Arens prob->Nc[f] = Nc; 34847e57110SSander Arens prob->Nb[f] = Nb; 349194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 350194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 351a6b92713SMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3522764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3532764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3549c3cf19fSMatthew G. Knepley prob->totDim += Nb; 3552764a2aaSMatthew G. Knepley prob->totComp += Nc; 3562764a2aaSMatthew G. Knepley } 3572764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3582764a2aaSMatthew G. Knepley /* Allocate works space */ 359fd558bbcSMatthew G. Knepley ierr = PetscMalloc5(prob->totComp,&prob->u,prob->totComp,&prob->u_t,prob->totComp*dimEmbed,&prob->u_x,dimEmbed,&prob->x,work,&prob->refSpaceDer);CHKERRQ(ierr); 3602764a2aaSMatthew G. Knepley ierr = PetscMalloc6(NqMax*NcMax,&prob->f0,NqMax*NcMax*dim,&prob->f1,NqMax*NcMax*NcMax,&prob->g0,NqMax*NcMax*NcMax*dim,&prob->g1,NqMax*NcMax*NcMax*dim,&prob->g2,NqMax*NcMax*NcMax*dim*dim,&prob->g3);CHKERRQ(ierr); 3612764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3622764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3642764a2aaSMatthew G. Knepley } 3652764a2aaSMatthew G. Knepley 3662764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3672764a2aaSMatthew G. Knepley { 3682764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3692764a2aaSMatthew G. Knepley 3702764a2aaSMatthew G. Knepley PetscFunctionBegin; 37147e57110SSander Arens ierr = PetscFree2(prob->Nc,prob->Nb);CHKERRQ(ierr); 372f744cafaSSander Arens ierr = PetscFree2(prob->off,prob->offDer);CHKERRQ(ierr); 373f744cafaSSander Arens ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisFace,prob->basisDerFace);CHKERRQ(ierr); 3742764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3752764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3762764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3772764a2aaSMatthew G. Knepley } 3782764a2aaSMatthew G. Knepley 3792764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3802764a2aaSMatthew G. Knepley { 381f744cafaSSander Arens PetscObject *tmpd; 382a6cbbb48SMatthew G. Knepley PetscBool *tmpi, *tmpa; 38332d2bbc9SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf, *tmpup; 384b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 3852aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 3862aa1fc23SMatthew G. Knepley PetscBdPointJac *tmpgbd; 387194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 388c371a6d1SMatthew G. Knepley PetscSimplePointFunc *tmpexactSol; 3890c2f2876SMatthew G. Knepley void **tmpctx; 390a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3912764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3922764a2aaSMatthew G. Knepley 3932764a2aaSMatthew G. Knepley PetscFunctionBegin; 3942764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3952764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3962764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 397f744cafaSSander Arens ierr = PetscMalloc3(NfNew, &tmpd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 398f744cafaSSander Arens for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];} 399f744cafaSSander Arens for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 400f744cafaSSander Arens ierr = PetscFree3(prob->disc, prob->implicit, prob->adjacency);CHKERRQ(ierr); 4012764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4022764a2aaSMatthew G. Knepley prob->disc = tmpd; 403249df284SMatthew G. Knepley prob->implicit = tmpi; 404a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 405b7e05686SMatthew G. Knepley ierr = PetscCalloc7(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew*NfNew*4, &tmpgp, NfNew*NfNew*4, &tmpgt, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 40632d2bbc9SMatthew G. Knepley ierr = PetscCalloc1(NfNew, &tmpup);CHKERRQ(ierr); 4072764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4082764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4092764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 410475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4110c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 41232d2bbc9SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpup[f] = prob->update[f]; 4130c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4142764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4152764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4162764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 417475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 418b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4190c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 42032d2bbc9SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpup[f] = NULL; 4210c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 422b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 42332d2bbc9SMatthew G. Knepley ierr = PetscFree(prob->update);CHKERRQ(ierr); 4242764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4252764a2aaSMatthew G. Knepley prob->f = tmpf; 4262764a2aaSMatthew G. Knepley prob->g = tmpg; 427475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 428b7e05686SMatthew G. Knepley prob->gt = tmpgt; 4290c2f2876SMatthew G. Knepley prob->r = tmpr; 43032d2bbc9SMatthew G. Knepley prob->update = tmpup; 4310c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 432c371a6d1SMatthew G. Knepley ierr = PetscCalloc3(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd, NfNew, &tmpexactSol);CHKERRQ(ierr); 4332764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4342764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 435c371a6d1SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpexactSol[f] = prob->exactSol[f]; 4362764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4372764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 438c371a6d1SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpexactSol[f] = NULL; 439c371a6d1SMatthew G. Knepley ierr = PetscFree3(prob->fBd, prob->gBd, prob->exactSol);CHKERRQ(ierr); 4402764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4412764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 442c371a6d1SMatthew G. Knepley prob->exactSol = tmpexactSol; 4432764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4442764a2aaSMatthew G. Knepley } 4452764a2aaSMatthew G. Knepley 4462764a2aaSMatthew G. Knepley /*@ 4472764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4482764a2aaSMatthew G. Knepley 4492764a2aaSMatthew G. Knepley Collective on PetscDS 4502764a2aaSMatthew G. Knepley 4512764a2aaSMatthew G. Knepley Input Parameter: 4522764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4532764a2aaSMatthew G. Knepley 4542764a2aaSMatthew G. Knepley Level: developer 4552764a2aaSMatthew G. Knepley 4562764a2aaSMatthew G. Knepley .seealso PetscDSView() 4572764a2aaSMatthew G. Knepley @*/ 4582764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4592764a2aaSMatthew G. Knepley { 4602764a2aaSMatthew G. Knepley PetscInt f; 46158ebd649SToby Isaac DSBoundary next; 4622764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4632764a2aaSMatthew G. Knepley 4642764a2aaSMatthew G. Knepley PetscFunctionBegin; 4652764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4662764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4672764a2aaSMatthew G. Knepley 4682764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4692764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 470df3a45bdSMatthew G. Knepley if ((*prob)->subprobs) { 471df3a45bdSMatthew G. Knepley PetscInt dim, d; 472df3a45bdSMatthew G. Knepley 473df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(*prob, &dim);CHKERRQ(ierr); 474df3a45bdSMatthew G. Knepley for (d = 0; d < dim; ++d) {ierr = PetscDSDestroy(&(*prob)->subprobs[d]);CHKERRQ(ierr);} 475df3a45bdSMatthew G. Knepley } 476df3a45bdSMatthew G. Knepley ierr = PetscFree((*prob)->subprobs);CHKERRQ(ierr); 4772764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4782764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4792764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4802764a2aaSMatthew G. Knepley } 481f744cafaSSander Arens ierr = PetscFree3((*prob)->disc, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 482b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 48332d2bbc9SMatthew G. Knepley ierr = PetscFree((*prob)->update);CHKERRQ(ierr); 484c371a6d1SMatthew G. Knepley ierr = PetscFree3((*prob)->fBd,(*prob)->gBd,(*prob)->exactSol);CHKERRQ(ierr); 4852764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 48658ebd649SToby Isaac next = (*prob)->boundary; 48758ebd649SToby Isaac while (next) { 48858ebd649SToby Isaac DSBoundary b = next; 48958ebd649SToby Isaac 49058ebd649SToby Isaac next = b->next; 49158ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 49258ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 49358ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 49458ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 49558ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 49658ebd649SToby Isaac } 49797b6e6e8SMatthew G. Knepley ierr = PetscFree((*prob)->constants);CHKERRQ(ierr); 4982764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5002764a2aaSMatthew G. Knepley } 5012764a2aaSMatthew G. Knepley 5022764a2aaSMatthew G. Knepley /*@ 5032764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 5042764a2aaSMatthew G. Knepley 5052764a2aaSMatthew G. Knepley Collective on MPI_Comm 5062764a2aaSMatthew G. Knepley 5072764a2aaSMatthew G. Knepley Input Parameter: 5082764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 5092764a2aaSMatthew G. Knepley 5102764a2aaSMatthew G. Knepley Output Parameter: 5112764a2aaSMatthew G. Knepley . prob - The PetscDS object 5122764a2aaSMatthew G. Knepley 5132764a2aaSMatthew G. Knepley Level: beginner 5142764a2aaSMatthew G. Knepley 5152764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 5162764a2aaSMatthew G. Knepley @*/ 5172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 5182764a2aaSMatthew G. Knepley { 5192764a2aaSMatthew G. Knepley PetscDS p; 5202764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5212764a2aaSMatthew G. Knepley 5222764a2aaSMatthew G. Knepley PetscFunctionBegin; 5232764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 5242764a2aaSMatthew G. Knepley *prob = NULL; 5252764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5262764a2aaSMatthew G. Knepley 52773107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5282764a2aaSMatthew G. Knepley 5292764a2aaSMatthew G. Knepley p->Nf = 0; 5302764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 53197b6e6e8SMatthew G. Knepley p->numConstants = 0; 53297b6e6e8SMatthew G. Knepley p->constants = NULL; 533a859676bSMatthew G. Knepley p->dimEmbed = -1; 53403d90f89SMatthew G. Knepley p->defaultAdj[0] = PETSC_FALSE; 53503d90f89SMatthew G. Knepley p->defaultAdj[1] = PETSC_TRUE; 53655c1f793SMatthew G. Knepley p->useJacPre = PETSC_TRUE; 5372764a2aaSMatthew G. Knepley 5382764a2aaSMatthew G. Knepley *prob = p; 5392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5402764a2aaSMatthew G. Knepley } 5412764a2aaSMatthew G. Knepley 542bc4ae4beSMatthew G. Knepley /*@ 543bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 544bc4ae4beSMatthew G. Knepley 545bc4ae4beSMatthew G. Knepley Not collective 546bc4ae4beSMatthew G. Knepley 547bc4ae4beSMatthew G. Knepley Input Parameter: 548bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 549bc4ae4beSMatthew G. Knepley 550bc4ae4beSMatthew G. Knepley Output Parameter: 551bc4ae4beSMatthew G. Knepley . Nf - The number of fields 552bc4ae4beSMatthew G. Knepley 553bc4ae4beSMatthew G. Knepley Level: beginner 554bc4ae4beSMatthew G. Knepley 555bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 556bc4ae4beSMatthew G. Knepley @*/ 5572764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5582764a2aaSMatthew G. Knepley { 5592764a2aaSMatthew G. Knepley PetscFunctionBegin; 5602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5612764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5622764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5642764a2aaSMatthew G. Knepley } 5652764a2aaSMatthew G. Knepley 566bc4ae4beSMatthew G. Knepley /*@ 567a859676bSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS, meaning the topological dimension of the discretizations 568bc4ae4beSMatthew G. Knepley 569bc4ae4beSMatthew G. Knepley Not collective 570bc4ae4beSMatthew G. Knepley 571bc4ae4beSMatthew G. Knepley Input Parameter: 572bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 573bc4ae4beSMatthew G. Knepley 574bc4ae4beSMatthew G. Knepley Output Parameter: 575bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 576bc4ae4beSMatthew G. Knepley 577bc4ae4beSMatthew G. Knepley Level: beginner 578bc4ae4beSMatthew G. Knepley 579a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetNumFields(), PetscDSCreate() 580bc4ae4beSMatthew G. Knepley @*/ 5812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5822764a2aaSMatthew G. Knepley { 5832764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5842764a2aaSMatthew G. Knepley 5852764a2aaSMatthew G. Knepley PetscFunctionBegin; 5862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5872764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5882764a2aaSMatthew G. Knepley *dim = 0; 5899de99aefSMatthew G. Knepley if (prob->Nf) { 5909de99aefSMatthew G. Knepley PetscObject obj; 5919de99aefSMatthew G. Knepley PetscClassId id; 5929de99aefSMatthew G. Knepley 5939de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5949de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5959de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5969de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5979de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5989de99aefSMatthew G. Knepley } 5992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6002764a2aaSMatthew G. Knepley } 6012764a2aaSMatthew G. Knepley 602bc4ae4beSMatthew G. Knepley /*@ 603a859676bSMatthew G. Knepley PetscDSGetCoordinateDimension - Returns the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 604a859676bSMatthew G. Knepley 605a859676bSMatthew G. Knepley Not collective 606a859676bSMatthew G. Knepley 607a859676bSMatthew G. Knepley Input Parameter: 608a859676bSMatthew G. Knepley . prob - The PetscDS object 609a859676bSMatthew G. Knepley 610a859676bSMatthew G. Knepley Output Parameter: 611a859676bSMatthew G. Knepley . dimEmbed - The coordinate dimension 612a859676bSMatthew G. Knepley 613a859676bSMatthew G. Knepley Level: beginner 614a859676bSMatthew G. Knepley 615a859676bSMatthew G. Knepley .seealso: PetscDSSetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 616a859676bSMatthew G. Knepley @*/ 617a859676bSMatthew G. Knepley PetscErrorCode PetscDSGetCoordinateDimension(PetscDS prob, PetscInt *dimEmbed) 618a859676bSMatthew G. Knepley { 619a859676bSMatthew G. Knepley PetscFunctionBegin; 620a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 621a859676bSMatthew G. Knepley PetscValidPointer(dimEmbed, 2); 622a859676bSMatthew G. Knepley if (prob->dimEmbed < 0) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONGSTATE, "No coordinate dimension set for this DS"); 623a859676bSMatthew G. Knepley *dimEmbed = prob->dimEmbed; 624a859676bSMatthew G. Knepley PetscFunctionReturn(0); 625a859676bSMatthew G. Knepley } 626a859676bSMatthew G. Knepley 627a859676bSMatthew G. Knepley /*@ 628a859676bSMatthew G. Knepley PetscDSSetCoordinateDimension - Set the coordinate dimension of the DS, meaning the dimension of the space into which the discretiaztions are embedded 629a859676bSMatthew G. Knepley 630a859676bSMatthew G. Knepley Not collective 631a859676bSMatthew G. Knepley 632a859676bSMatthew G. Knepley Input Parameters: 633a859676bSMatthew G. Knepley + prob - The PetscDS object 634a859676bSMatthew G. Knepley - dimEmbed - The coordinate dimension 635a859676bSMatthew G. Knepley 636a859676bSMatthew G. Knepley Level: beginner 637a859676bSMatthew G. Knepley 638a859676bSMatthew G. Knepley .seealso: PetscDSGetCoordinateDimension(), PetscDSGetSpatialDimension(), PetscDSGetNumFields(), PetscDSCreate() 639a859676bSMatthew G. Knepley @*/ 640a859676bSMatthew G. Knepley PetscErrorCode PetscDSSetCoordinateDimension(PetscDS prob, PetscInt dimEmbed) 641a859676bSMatthew G. Knepley { 642a859676bSMatthew G. Knepley PetscFunctionBegin; 643a859676bSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 644a859676bSMatthew G. Knepley prob->dimEmbed = dimEmbed; 645a859676bSMatthew G. Knepley PetscFunctionReturn(0); 646a859676bSMatthew G. Knepley } 647a859676bSMatthew G. Knepley 648a859676bSMatthew G. Knepley /*@ 649bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 650bc4ae4beSMatthew G. Knepley 651bc4ae4beSMatthew G. Knepley Not collective 652bc4ae4beSMatthew G. Knepley 653bc4ae4beSMatthew G. Knepley Input Parameter: 654bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 655bc4ae4beSMatthew G. Knepley 656bc4ae4beSMatthew G. Knepley Output Parameter: 657bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 658bc4ae4beSMatthew G. Knepley 659bc4ae4beSMatthew G. Knepley Level: beginner 660bc4ae4beSMatthew G. Knepley 661bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 662bc4ae4beSMatthew G. Knepley @*/ 6632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 6642764a2aaSMatthew G. Knepley { 6652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6662764a2aaSMatthew G. Knepley 6672764a2aaSMatthew G. Knepley PetscFunctionBegin; 6682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6692764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6702764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6712764a2aaSMatthew G. Knepley *dim = prob->totDim; 6722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6732764a2aaSMatthew G. Knepley } 6742764a2aaSMatthew G. Knepley 675bc4ae4beSMatthew G. Knepley /*@ 676bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 677bc4ae4beSMatthew G. Knepley 678bc4ae4beSMatthew G. Knepley Not collective 679bc4ae4beSMatthew G. Knepley 680bc4ae4beSMatthew G. Knepley Input Parameter: 681bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 682bc4ae4beSMatthew G. Knepley 683bc4ae4beSMatthew G. Knepley Output Parameter: 684bc4ae4beSMatthew G. Knepley . dim - The total number of components 685bc4ae4beSMatthew G. Knepley 686bc4ae4beSMatthew G. Knepley Level: beginner 687bc4ae4beSMatthew G. Knepley 688bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 689bc4ae4beSMatthew G. Knepley @*/ 6902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6912764a2aaSMatthew G. Knepley { 6922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6932764a2aaSMatthew G. Knepley 6942764a2aaSMatthew G. Knepley PetscFunctionBegin; 6952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6962764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6972764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6982764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7002764a2aaSMatthew G. Knepley } 7012764a2aaSMatthew G. Knepley 702bc4ae4beSMatthew G. Knepley /*@ 703bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 704bc4ae4beSMatthew G. Knepley 705bc4ae4beSMatthew G. Knepley Not collective 706bc4ae4beSMatthew G. Knepley 707bc4ae4beSMatthew G. Knepley Input Parameters: 708bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 709bc4ae4beSMatthew G. Knepley - f - The field number 710bc4ae4beSMatthew G. Knepley 711bc4ae4beSMatthew G. Knepley Output Parameter: 712bc4ae4beSMatthew G. Knepley . disc - The discretization object 713bc4ae4beSMatthew G. Knepley 714bc4ae4beSMatthew G. Knepley Level: beginner 715bc4ae4beSMatthew G. Knepley 716f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 717bc4ae4beSMatthew G. Knepley @*/ 7182764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7192764a2aaSMatthew G. Knepley { 7202764a2aaSMatthew G. Knepley PetscFunctionBegin; 7212764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7222764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7232764a2aaSMatthew 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); 7242764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 7252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7262764a2aaSMatthew G. Knepley } 7272764a2aaSMatthew G. Knepley 728bc4ae4beSMatthew G. Knepley /*@ 729bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 730bc4ae4beSMatthew G. Knepley 731bc4ae4beSMatthew G. Knepley Not collective 732bc4ae4beSMatthew G. Knepley 733bc4ae4beSMatthew G. Knepley Input Parameters: 734bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 735bc4ae4beSMatthew G. Knepley . f - The field number 736bc4ae4beSMatthew G. Knepley - disc - The discretization object 737bc4ae4beSMatthew G. Knepley 738bc4ae4beSMatthew G. Knepley Level: beginner 739bc4ae4beSMatthew G. Knepley 740bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 741bc4ae4beSMatthew G. Knepley @*/ 7422764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7432764a2aaSMatthew G. Knepley { 7442764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7452764a2aaSMatthew G. Knepley 7462764a2aaSMatthew G. Knepley PetscFunctionBegin; 7472764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7482764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7492764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7502764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7512764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7522764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7532764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 754249df284SMatthew G. Knepley { 755249df284SMatthew G. Knepley PetscClassId id; 756249df284SMatthew G. Knepley 757249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 7581cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 7591cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 7601cf84007SMatthew G. Knepley ierr = PetscDSSetAdjacency(prob, f, PETSC_FALSE, PETSC_TRUE);CHKERRQ(ierr); 7611cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 7621cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 7631cf84007SMatthew G. Knepley ierr = PetscDSSetAdjacency(prob, f, PETSC_TRUE, PETSC_FALSE);CHKERRQ(ierr); 764a6cbbb48SMatthew G. Knepley } 765249df284SMatthew G. Knepley } 7662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7672764a2aaSMatthew G. Knepley } 7682764a2aaSMatthew G. Knepley 769bc4ae4beSMatthew G. Knepley /*@ 770bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 771bc4ae4beSMatthew G. Knepley 772bc4ae4beSMatthew G. Knepley Not collective 773bc4ae4beSMatthew G. Knepley 774bc4ae4beSMatthew G. Knepley Input Parameters: 775bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 776bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley Level: beginner 779bc4ae4beSMatthew G. Knepley 780bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 781bc4ae4beSMatthew G. Knepley @*/ 7822764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 7832764a2aaSMatthew G. Knepley { 7842764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7852764a2aaSMatthew G. Knepley 7862764a2aaSMatthew G. Knepley PetscFunctionBegin; 7872764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 7882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7892764a2aaSMatthew G. Knepley } 7902764a2aaSMatthew G. Knepley 791249df284SMatthew G. Knepley /*@ 792249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 793249df284SMatthew G. Knepley 794249df284SMatthew G. Knepley Not collective 795249df284SMatthew G. Knepley 796249df284SMatthew G. Knepley Input Parameters: 797249df284SMatthew G. Knepley + prob - The PetscDS object 798249df284SMatthew G. Knepley - f - The field number 799249df284SMatthew G. Knepley 800249df284SMatthew G. Knepley Output Parameter: 801249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 802249df284SMatthew G. Knepley 803249df284SMatthew G. Knepley Level: developer 804249df284SMatthew G. Knepley 805f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 806249df284SMatthew G. Knepley @*/ 807249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 808249df284SMatthew G. Knepley { 809249df284SMatthew G. Knepley PetscFunctionBegin; 810249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 811249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 812249df284SMatthew 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); 813249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 814249df284SMatthew G. Knepley PetscFunctionReturn(0); 815249df284SMatthew G. Knepley } 816249df284SMatthew G. Knepley 817249df284SMatthew G. Knepley /*@ 818249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 819249df284SMatthew G. Knepley 820249df284SMatthew G. Knepley Not collective 821249df284SMatthew G. Knepley 822249df284SMatthew G. Knepley Input Parameters: 823249df284SMatthew G. Knepley + prob - The PetscDS object 824249df284SMatthew G. Knepley . f - The field number 825249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 826249df284SMatthew G. Knepley 827249df284SMatthew G. Knepley Level: developer 828249df284SMatthew G. Knepley 829f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 830249df284SMatthew G. Knepley @*/ 831249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 832249df284SMatthew G. Knepley { 833249df284SMatthew G. Knepley PetscFunctionBegin; 834249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 835249df284SMatthew 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); 836249df284SMatthew G. Knepley prob->implicit[f] = implicit; 837249df284SMatthew G. Knepley PetscFunctionReturn(0); 838249df284SMatthew G. Knepley } 839249df284SMatthew G. Knepley 840a6cbbb48SMatthew G. Knepley /*@ 841a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 842a6cbbb48SMatthew G. Knepley 843a6cbbb48SMatthew G. Knepley Not collective 844a6cbbb48SMatthew G. Knepley 845a6cbbb48SMatthew G. Knepley Input Parameters: 846a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 847a6cbbb48SMatthew G. Knepley - f - The field number 848a6cbbb48SMatthew G. Knepley 849a6cbbb48SMatthew G. Knepley Output Parameter: 850a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 851a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 852a6cbbb48SMatthew G. Knepley 853a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 854a6cbbb48SMatthew G. Knepley 855a6cbbb48SMatthew G. Knepley Level: developer 856a6cbbb48SMatthew G. Knepley 857f744cafaSSander Arens .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 858a6cbbb48SMatthew G. Knepley @*/ 859a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 860a6cbbb48SMatthew G. Knepley { 861a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 862a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8631cf84007SMatthew G. Knepley if (useCone) PetscValidPointer(useCone, 3); 8641cf84007SMatthew G. Knepley if (useClosure) PetscValidPointer(useClosure, 4); 86506cc46feSMatthew G. Knepley if (f < 0) { 86606cc46feSMatthew G. Knepley if (useCone) *useCone = prob->defaultAdj[0]; 86706cc46feSMatthew G. Knepley if (useClosure) *useClosure = prob->defaultAdj[1]; 86806cc46feSMatthew G. Knepley } else { 86906cc46feSMatthew G. Knepley if (f >= prob->Nf) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 8701cf84007SMatthew G. Knepley if (useCone) *useCone = prob->adjacency[f*2+0]; 8711cf84007SMatthew G. Knepley if (useClosure) *useClosure = prob->adjacency[f*2+1]; 87206cc46feSMatthew G. Knepley } 873a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 874a6cbbb48SMatthew G. Knepley } 875a6cbbb48SMatthew G. Knepley 876a6cbbb48SMatthew G. Knepley /*@ 877a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 878a6cbbb48SMatthew G. Knepley 879a6cbbb48SMatthew G. Knepley Not collective 880a6cbbb48SMatthew G. Knepley 881a6cbbb48SMatthew G. Knepley Input Parameters: 882a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 883a6cbbb48SMatthew G. Knepley . f - The field number 884a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 885a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 886a6cbbb48SMatthew G. Knepley 887a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 888a6cbbb48SMatthew G. Knepley 889a6cbbb48SMatthew G. Knepley Level: developer 890a6cbbb48SMatthew G. Knepley 891f744cafaSSander Arens .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 892a6cbbb48SMatthew G. Knepley @*/ 893a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 894a6cbbb48SMatthew G. Knepley { 895a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 896a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 89706cc46feSMatthew G. Knepley if (f < 0) { 89806cc46feSMatthew G. Knepley prob->defaultAdj[0] = useCone; 89906cc46feSMatthew G. Knepley prob->defaultAdj[1] = useClosure; 90006cc46feSMatthew G. Knepley } else { 90106cc46feSMatthew G. Knepley if (f >= prob->Nf) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 902a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 903a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 90406cc46feSMatthew G. Knepley } 905a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 906a6cbbb48SMatthew G. Knepley } 907a6cbbb48SMatthew G. Knepley 9082764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 90930b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 910194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 911194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 91297b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9132764a2aaSMatthew G. Knepley { 9142764a2aaSMatthew G. Knepley PetscFunctionBegin; 9152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9162764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9172764a2aaSMatthew 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); 9182764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9202764a2aaSMatthew G. Knepley } 9212764a2aaSMatthew G. Knepley 9222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 92330b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 924194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 925194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 92697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9272764a2aaSMatthew G. Knepley { 9282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9292764a2aaSMatthew G. Knepley 9302764a2aaSMatthew G. Knepley PetscFunctionBegin; 9312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 932de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9332764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9342764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9352764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9362764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9372764a2aaSMatthew G. Knepley } 9382764a2aaSMatthew G. Knepley 939194d53e6SMatthew G. Knepley /*@C 940194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 941194d53e6SMatthew G. Knepley 942194d53e6SMatthew G. Knepley Not collective 943194d53e6SMatthew G. Knepley 944194d53e6SMatthew G. Knepley Input Parameters: 945194d53e6SMatthew G. Knepley + prob - The PetscDS 946194d53e6SMatthew G. Knepley - f - The test field number 947194d53e6SMatthew G. Knepley 948194d53e6SMatthew G. Knepley Output Parameters: 949194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 950194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 951194d53e6SMatthew G. Knepley 952194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 953194d53e6SMatthew G. Knepley 954194d53e6SMatthew 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) 955194d53e6SMatthew G. Knepley 956194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 957194d53e6SMatthew G. Knepley 95830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 959194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 960194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 96130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 962194d53e6SMatthew G. Knepley 963194d53e6SMatthew G. Knepley + dim - the spatial dimension 964194d53e6SMatthew G. Knepley . Nf - the number of fields 965194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 966194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 967194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 968194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 969194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 970194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 971194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 972194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 973194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 974194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 975194d53e6SMatthew G. Knepley . t - current time 976194d53e6SMatthew G. Knepley . x - coordinates of the current point 97797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 97897b6e6e8SMatthew G. Knepley . constants - constant parameters 979194d53e6SMatthew G. Knepley - f0 - output values at the current point 980194d53e6SMatthew G. Knepley 981194d53e6SMatthew G. Knepley Level: intermediate 982194d53e6SMatthew G. Knepley 983194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 984194d53e6SMatthew G. Knepley @*/ 9852764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 98630b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 987194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 988194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 98997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 99030b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 991194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 992194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 99397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 9942764a2aaSMatthew G. Knepley { 9952764a2aaSMatthew G. Knepley PetscFunctionBegin; 9962764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9972764a2aaSMatthew 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); 9982764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 9992764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10012764a2aaSMatthew G. Knepley } 10022764a2aaSMatthew G. Knepley 1003194d53e6SMatthew G. Knepley /*@C 1004194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1005194d53e6SMatthew G. Knepley 1006194d53e6SMatthew G. Knepley Not collective 1007194d53e6SMatthew G. Knepley 1008194d53e6SMatthew G. Knepley Input Parameters: 1009194d53e6SMatthew G. Knepley + prob - The PetscDS 1010194d53e6SMatthew G. Knepley . f - The test field number 1011194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1012194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1013194d53e6SMatthew G. Knepley 1014194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1015194d53e6SMatthew G. Knepley 1016194d53e6SMatthew 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) 1017194d53e6SMatthew G. Knepley 1018194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1019194d53e6SMatthew G. Knepley 102030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1021194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1022194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 102330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1024194d53e6SMatthew G. Knepley 1025194d53e6SMatthew G. Knepley + dim - the spatial dimension 1026194d53e6SMatthew G. Knepley . Nf - the number of fields 1027194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1028194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1029194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1030194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1031194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1032194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1033194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1034194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1035194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1036194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1037194d53e6SMatthew G. Knepley . t - current time 1038194d53e6SMatthew G. Knepley . x - coordinates of the current point 103997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 104097b6e6e8SMatthew G. Knepley . constants - constant parameters 1041194d53e6SMatthew G. Knepley - f0 - output values at the current point 1042194d53e6SMatthew G. Knepley 1043194d53e6SMatthew G. Knepley Level: intermediate 1044194d53e6SMatthew G. Knepley 1045194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1046194d53e6SMatthew G. Knepley @*/ 10472764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 104830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1049194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1050194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 105197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 105230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1053194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1054194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 105597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 10562764a2aaSMatthew G. Knepley { 10572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 10582764a2aaSMatthew G. Knepley 10592764a2aaSMatthew G. Knepley PetscFunctionBegin; 10602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1061f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1062f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 10632764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10642764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10652764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 10662764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 10672764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10682764a2aaSMatthew G. Knepley } 10692764a2aaSMatthew G. Knepley 10703e75805dSMatthew G. Knepley /*@C 10713e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 10723e75805dSMatthew G. Knepley 10733e75805dSMatthew G. Knepley Not collective 10743e75805dSMatthew G. Knepley 10753e75805dSMatthew G. Knepley Input Parameter: 10763e75805dSMatthew G. Knepley . prob - The PetscDS 10773e75805dSMatthew G. Knepley 10783e75805dSMatthew G. Knepley Output Parameter: 10793e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 10803e75805dSMatthew G. Knepley 10813e75805dSMatthew G. Knepley Level: intermediate 10823e75805dSMatthew G. Knepley 10833e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 10843e75805dSMatthew G. Knepley @*/ 10853e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 10863e75805dSMatthew G. Knepley { 10873e75805dSMatthew G. Knepley PetscInt f, g, h; 10883e75805dSMatthew G. Knepley 10893e75805dSMatthew G. Knepley PetscFunctionBegin; 10903e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10913e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 10923e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 10933e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 10943e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 10953e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 10963e75805dSMatthew G. Knepley } 10973e75805dSMatthew G. Knepley } 10983e75805dSMatthew G. Knepley } 10993e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11003e75805dSMatthew G. Knepley } 11013e75805dSMatthew G. Knepley 1102194d53e6SMatthew G. Knepley /*@C 1103194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1104194d53e6SMatthew G. Knepley 1105194d53e6SMatthew G. Knepley Not collective 1106194d53e6SMatthew G. Knepley 1107194d53e6SMatthew G. Knepley Input Parameters: 1108194d53e6SMatthew G. Knepley + prob - The PetscDS 1109194d53e6SMatthew G. Knepley . f - The test field number 1110194d53e6SMatthew G. Knepley - g - The field number 1111194d53e6SMatthew G. Knepley 1112194d53e6SMatthew G. Knepley Output Parameters: 1113194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1114194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1115194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1116194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1117194d53e6SMatthew G. Knepley 1118194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1119194d53e6SMatthew G. Knepley 1120194d53e6SMatthew 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 1121194d53e6SMatthew G. Knepley 1122194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1123194d53e6SMatthew G. Knepley 112430b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1125194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1126194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 112730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1128194d53e6SMatthew G. Knepley 1129194d53e6SMatthew G. Knepley + dim - the spatial dimension 1130194d53e6SMatthew G. Knepley . Nf - the number of fields 1131194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1132194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1133194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1134194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1135194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1136194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1137194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1138194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1139194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1140194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1141194d53e6SMatthew G. Knepley . t - current time 11422aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1143194d53e6SMatthew G. Knepley . x - coordinates of the current point 114497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 114597b6e6e8SMatthew G. Knepley . constants - constant parameters 1146194d53e6SMatthew G. Knepley - g0 - output values at the current point 1147194d53e6SMatthew G. Knepley 1148194d53e6SMatthew G. Knepley Level: intermediate 1149194d53e6SMatthew G. Knepley 1150194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1151194d53e6SMatthew G. Knepley @*/ 11522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 115330b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1154194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1155194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 115697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 115730b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1158194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1159194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 116130b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1162194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1163194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 116530b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1166194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1167194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 11692764a2aaSMatthew G. Knepley { 11702764a2aaSMatthew G. Knepley PetscFunctionBegin; 11712764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11722764a2aaSMatthew 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); 11732764a2aaSMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 11742764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 11752764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 11762764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 11772764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 11782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11792764a2aaSMatthew G. Knepley } 11802764a2aaSMatthew G. Knepley 1181194d53e6SMatthew G. Knepley /*@C 1182194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1183194d53e6SMatthew G. Knepley 1184194d53e6SMatthew G. Knepley Not collective 1185194d53e6SMatthew G. Knepley 1186194d53e6SMatthew G. Knepley Input Parameters: 1187194d53e6SMatthew G. Knepley + prob - The PetscDS 1188194d53e6SMatthew G. Knepley . f - The test field number 1189194d53e6SMatthew G. Knepley . g - The field number 1190194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1191194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1192194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1193194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1194194d53e6SMatthew G. Knepley 1195194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1196194d53e6SMatthew G. Knepley 1197194d53e6SMatthew 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 1198194d53e6SMatthew G. Knepley 1199194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1200194d53e6SMatthew G. Knepley 120130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1202194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1203194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1205194d53e6SMatthew G. Knepley 1206194d53e6SMatthew G. Knepley + dim - the spatial dimension 1207194d53e6SMatthew G. Knepley . Nf - the number of fields 1208194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1209194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1210194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1211194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1212194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1213194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1214194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1215194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1216194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1217194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1218194d53e6SMatthew G. Knepley . t - current time 12192aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1220194d53e6SMatthew G. Knepley . x - coordinates of the current point 122197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 122297b6e6e8SMatthew G. Knepley . constants - constant parameters 1223194d53e6SMatthew G. Knepley - g0 - output values at the current point 1224194d53e6SMatthew G. Knepley 1225194d53e6SMatthew G. Knepley Level: intermediate 1226194d53e6SMatthew G. Knepley 1227194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1228194d53e6SMatthew G. Knepley @*/ 12292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 123030b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1231194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1232194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 123430b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1235194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1236194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 123830b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1239194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1240194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 124230b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1243194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1244194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12462764a2aaSMatthew G. Knepley { 12472764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12482764a2aaSMatthew G. Knepley 12492764a2aaSMatthew G. Knepley PetscFunctionBegin; 12502764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12512764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12522764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12532764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12542764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 12552764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12562764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 12572764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 12582764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 12592764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 12602764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 12612764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 12622764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12632764a2aaSMatthew G. Knepley } 12642764a2aaSMatthew G. Knepley 1265475e0ac9SMatthew G. Knepley /*@C 126655c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 126755c1f793SMatthew G. Knepley 126855c1f793SMatthew G. Knepley Not collective 126955c1f793SMatthew G. Knepley 127055c1f793SMatthew G. Knepley Input Parameters: 127155c1f793SMatthew G. Knepley + prob - The PetscDS 127255c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 127355c1f793SMatthew G. Knepley 127455c1f793SMatthew G. Knepley Level: intermediate 127555c1f793SMatthew G. Knepley 127655c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 127755c1f793SMatthew G. Knepley @*/ 127855c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 127955c1f793SMatthew G. Knepley { 128055c1f793SMatthew G. Knepley PetscFunctionBegin; 128155c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 128255c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 128355c1f793SMatthew G. Knepley PetscFunctionReturn(0); 128455c1f793SMatthew G. Knepley } 128555c1f793SMatthew G. Knepley 128655c1f793SMatthew G. Knepley /*@C 1287475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1288475e0ac9SMatthew G. Knepley 1289475e0ac9SMatthew G. Knepley Not collective 1290475e0ac9SMatthew G. Knepley 1291475e0ac9SMatthew G. Knepley Input Parameter: 1292475e0ac9SMatthew G. Knepley . prob - The PetscDS 1293475e0ac9SMatthew G. Knepley 1294475e0ac9SMatthew G. Knepley Output Parameter: 1295475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1296475e0ac9SMatthew G. Knepley 1297475e0ac9SMatthew G. Knepley Level: intermediate 1298475e0ac9SMatthew G. Knepley 1299475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1300475e0ac9SMatthew G. Knepley @*/ 1301475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1302475e0ac9SMatthew G. Knepley { 1303475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1304475e0ac9SMatthew G. Knepley 1305475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1306475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1307475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 130855c1f793SMatthew G. Knepley if (!prob->useJacPre) PetscFunctionReturn(0); 1309475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1310475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1311475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1312475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1313475e0ac9SMatthew G. Knepley } 1314475e0ac9SMatthew G. Knepley } 1315475e0ac9SMatthew G. Knepley } 1316475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1317475e0ac9SMatthew G. Knepley } 1318475e0ac9SMatthew G. Knepley 1319475e0ac9SMatthew G. Knepley /*@C 1320475e0ac9SMatthew 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. 1321475e0ac9SMatthew G. Knepley 1322475e0ac9SMatthew G. Knepley Not collective 1323475e0ac9SMatthew G. Knepley 1324475e0ac9SMatthew G. Knepley Input Parameters: 1325475e0ac9SMatthew G. Knepley + prob - The PetscDS 1326475e0ac9SMatthew G. Knepley . f - The test field number 1327475e0ac9SMatthew G. Knepley - g - The field number 1328475e0ac9SMatthew G. Knepley 1329475e0ac9SMatthew G. Knepley Output Parameters: 1330475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1331475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1332475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1333475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1334475e0ac9SMatthew G. Knepley 1335475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1336475e0ac9SMatthew G. Knepley 1337475e0ac9SMatthew 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 1338475e0ac9SMatthew G. Knepley 1339475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1340475e0ac9SMatthew G. Knepley 1341475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1342475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1343475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1344475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1345475e0ac9SMatthew G. Knepley 1346475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1347475e0ac9SMatthew G. Knepley . Nf - the number of fields 1348475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1349475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1350475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1351475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1352475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1353475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1354475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1355475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1356475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1357475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1358475e0ac9SMatthew G. Knepley . t - current time 1359475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1360475e0ac9SMatthew G. Knepley . x - coordinates of the current point 136197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 136297b6e6e8SMatthew G. Knepley . constants - constant parameters 1363475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1364475e0ac9SMatthew G. Knepley 1365475e0ac9SMatthew G. Knepley Level: intermediate 1366475e0ac9SMatthew G. Knepley 1367475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1368475e0ac9SMatthew G. Knepley @*/ 1369475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1370475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1371475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1372475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 137397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1374475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1375475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1376475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 137797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1378475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1379475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1380475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 138197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1382475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1383475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1384475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 138597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1386475e0ac9SMatthew G. Knepley { 1387475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1388475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1389475e0ac9SMatthew 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); 1390475e0ac9SMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 1391475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1392475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1393475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1394475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1395475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1396475e0ac9SMatthew G. Knepley } 1397475e0ac9SMatthew G. Knepley 1398475e0ac9SMatthew G. Knepley /*@C 1399475e0ac9SMatthew 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. 1400475e0ac9SMatthew G. Knepley 1401475e0ac9SMatthew G. Knepley Not collective 1402475e0ac9SMatthew G. Knepley 1403475e0ac9SMatthew G. Knepley Input Parameters: 1404475e0ac9SMatthew G. Knepley + prob - The PetscDS 1405475e0ac9SMatthew G. Knepley . f - The test field number 1406475e0ac9SMatthew G. Knepley . g - The field number 1407475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1408475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1409475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1410475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1411475e0ac9SMatthew G. Knepley 1412475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1413475e0ac9SMatthew G. Knepley 1414475e0ac9SMatthew 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 1415475e0ac9SMatthew G. Knepley 1416475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1417475e0ac9SMatthew G. Knepley 1418475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1419475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1420475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1421475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1422475e0ac9SMatthew G. Knepley 1423475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1424475e0ac9SMatthew G. Knepley . Nf - the number of fields 1425475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1426475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1427475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1428475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1429475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1430475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1431475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1432475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1433475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1434475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1435475e0ac9SMatthew G. Knepley . t - current time 1436475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1437475e0ac9SMatthew G. Knepley . x - coordinates of the current point 143897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 143997b6e6e8SMatthew G. Knepley . constants - constant parameters 1440475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1441475e0ac9SMatthew G. Knepley 1442475e0ac9SMatthew G. Knepley Level: intermediate 1443475e0ac9SMatthew G. Knepley 1444475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1445475e0ac9SMatthew G. Knepley @*/ 1446475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1447475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1448475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1449475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 145097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1451475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1452475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1453475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 145497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1455475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1456475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1457475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 145897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1459475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1460475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1461475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 146297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1463475e0ac9SMatthew G. Knepley { 1464475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1465475e0ac9SMatthew G. Knepley 1466475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1467475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1468475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1469475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1470475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1471475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1472475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1473475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1474475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1475475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1476475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1477475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1478475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1479475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1480475e0ac9SMatthew G. Knepley } 1481475e0ac9SMatthew G. Knepley 1482b7e05686SMatthew G. Knepley /*@C 1483b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1484b7e05686SMatthew G. Knepley 1485b7e05686SMatthew G. Knepley Not collective 1486b7e05686SMatthew G. Knepley 1487b7e05686SMatthew G. Knepley Input Parameter: 1488b7e05686SMatthew G. Knepley . prob - The PetscDS 1489b7e05686SMatthew G. Knepley 1490b7e05686SMatthew G. Knepley Output Parameter: 1491b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1492b7e05686SMatthew G. Knepley 1493b7e05686SMatthew G. Knepley Level: intermediate 1494b7e05686SMatthew G. Knepley 1495b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1496b7e05686SMatthew G. Knepley @*/ 1497b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1498b7e05686SMatthew G. Knepley { 1499b7e05686SMatthew G. Knepley PetscInt f, g, h; 1500b7e05686SMatthew G. Knepley 1501b7e05686SMatthew G. Knepley PetscFunctionBegin; 1502b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1503b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1504b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1505b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1506b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1507b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1508b7e05686SMatthew G. Knepley } 1509b7e05686SMatthew G. Knepley } 1510b7e05686SMatthew G. Knepley } 1511b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1512b7e05686SMatthew G. Knepley } 1513b7e05686SMatthew G. Knepley 1514b7e05686SMatthew G. Knepley /*@C 1515b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1516b7e05686SMatthew G. Knepley 1517b7e05686SMatthew G. Knepley Not collective 1518b7e05686SMatthew G. Knepley 1519b7e05686SMatthew G. Knepley Input Parameters: 1520b7e05686SMatthew G. Knepley + prob - The PetscDS 1521b7e05686SMatthew G. Knepley . f - The test field number 1522b7e05686SMatthew G. Knepley - g - The field number 1523b7e05686SMatthew G. Knepley 1524b7e05686SMatthew G. Knepley Output Parameters: 1525b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1526b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1527b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1528b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1529b7e05686SMatthew G. Knepley 1530b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1531b7e05686SMatthew G. Knepley 1532b7e05686SMatthew 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 1533b7e05686SMatthew G. Knepley 1534b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1535b7e05686SMatthew G. Knepley 1536b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1537b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1538b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1539b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1540b7e05686SMatthew G. Knepley 1541b7e05686SMatthew G. Knepley + dim - the spatial dimension 1542b7e05686SMatthew G. Knepley . Nf - the number of fields 1543b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1544b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1545b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1546b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1547b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1548b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1549b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1550b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1551b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1552b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1553b7e05686SMatthew G. Knepley . t - current time 1554b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1555b7e05686SMatthew G. Knepley . x - coordinates of the current point 155697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 155797b6e6e8SMatthew G. Knepley . constants - constant parameters 1558b7e05686SMatthew G. Knepley - g0 - output values at the current point 1559b7e05686SMatthew G. Knepley 1560b7e05686SMatthew G. Knepley Level: intermediate 1561b7e05686SMatthew G. Knepley 1562b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1563b7e05686SMatthew G. Knepley @*/ 1564b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1565b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1566b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1567b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 156897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1569b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1570b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1571b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 157297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1573b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1574b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1575b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 157697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1577b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1578b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1579b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 158097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1581b7e05686SMatthew G. Knepley { 1582b7e05686SMatthew G. Knepley PetscFunctionBegin; 1583b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1584b7e05686SMatthew 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); 1585b7e05686SMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 1586b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1587b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1588b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1589b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1590b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1591b7e05686SMatthew G. Knepley } 1592b7e05686SMatthew G. Knepley 1593b7e05686SMatthew G. Knepley /*@C 1594b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1595b7e05686SMatthew G. Knepley 1596b7e05686SMatthew G. Knepley Not collective 1597b7e05686SMatthew G. Knepley 1598b7e05686SMatthew G. Knepley Input Parameters: 1599b7e05686SMatthew G. Knepley + prob - The PetscDS 1600b7e05686SMatthew G. Knepley . f - The test field number 1601b7e05686SMatthew G. Knepley . g - The field number 1602b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1603b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1604b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1605b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1606b7e05686SMatthew G. Knepley 1607b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1608b7e05686SMatthew G. Knepley 1609b7e05686SMatthew 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 1610b7e05686SMatthew G. Knepley 1611b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1612b7e05686SMatthew G. Knepley 1613b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1614b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1615b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1616b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1617b7e05686SMatthew G. Knepley 1618b7e05686SMatthew G. Knepley + dim - the spatial dimension 1619b7e05686SMatthew G. Knepley . Nf - the number of fields 1620b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1621b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1622b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1623b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1624b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1625b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1626b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1627b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1628b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1629b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1630b7e05686SMatthew G. Knepley . t - current time 1631b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1632b7e05686SMatthew G. Knepley . x - coordinates of the current point 163397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 163497b6e6e8SMatthew G. Knepley . constants - constant parameters 1635b7e05686SMatthew G. Knepley - g0 - output values at the current point 1636b7e05686SMatthew G. Knepley 1637b7e05686SMatthew G. Knepley Level: intermediate 1638b7e05686SMatthew G. Knepley 1639b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1640b7e05686SMatthew G. Knepley @*/ 1641b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1642b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1643b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1644b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 164597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1646b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1647b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1648b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 164997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1650b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1651b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1652b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 165397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1654b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1655b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1656b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 165797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1658b7e05686SMatthew G. Knepley { 1659b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1660b7e05686SMatthew G. Knepley 1661b7e05686SMatthew G. Knepley PetscFunctionBegin; 1662b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1663b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1664b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1665b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1666b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1667b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1668b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1669b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1670b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1671b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1672b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1673b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1674b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1675b7e05686SMatthew G. Knepley } 1676b7e05686SMatthew G. Knepley 16770c2f2876SMatthew G. Knepley /*@C 16780c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 16790c2f2876SMatthew G. Knepley 16800c2f2876SMatthew G. Knepley Not collective 16810c2f2876SMatthew G. Knepley 16820c2f2876SMatthew G. Knepley Input Arguments: 16830c2f2876SMatthew G. Knepley + prob - The PetscDS object 16840c2f2876SMatthew G. Knepley - f - The field number 16850c2f2876SMatthew G. Knepley 16860c2f2876SMatthew G. Knepley Output Argument: 16870c2f2876SMatthew G. Knepley . r - Riemann solver 16880c2f2876SMatthew G. Knepley 16890c2f2876SMatthew G. Knepley Calling sequence for r: 16900c2f2876SMatthew G. Knepley 16915db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 16920c2f2876SMatthew G. Knepley 16935db36cf9SMatthew G. Knepley + dim - The spatial dimension 16945db36cf9SMatthew G. Knepley . Nf - The number of fields 16955db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 16960c2f2876SMatthew G. Knepley . n - The normal vector to the interface 16970c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 16980c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 16990c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 170097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 170197b6e6e8SMatthew G. Knepley . constants - constant parameters 17020c2f2876SMatthew G. Knepley - ctx - optional user context 17030c2f2876SMatthew G. Knepley 17040c2f2876SMatthew G. Knepley Level: intermediate 17050c2f2876SMatthew G. Knepley 17060c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17070c2f2876SMatthew G. Knepley @*/ 17080c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 170997b6e6e8SMatthew 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)) 17100c2f2876SMatthew G. Knepley { 17110c2f2876SMatthew G. Knepley PetscFunctionBegin; 17120c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17130c2f2876SMatthew 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); 17140c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17150c2f2876SMatthew G. Knepley *r = prob->r[f]; 17160c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17170c2f2876SMatthew G. Knepley } 17180c2f2876SMatthew G. Knepley 17190c2f2876SMatthew G. Knepley /*@C 17200c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17210c2f2876SMatthew G. Knepley 17220c2f2876SMatthew G. Knepley Not collective 17230c2f2876SMatthew G. Knepley 17240c2f2876SMatthew G. Knepley Input Arguments: 17250c2f2876SMatthew G. Knepley + prob - The PetscDS object 17260c2f2876SMatthew G. Knepley . f - The field number 17270c2f2876SMatthew G. Knepley - r - Riemann solver 17280c2f2876SMatthew G. Knepley 17290c2f2876SMatthew G. Knepley Calling sequence for r: 17300c2f2876SMatthew G. Knepley 17315db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17320c2f2876SMatthew G. Knepley 17335db36cf9SMatthew G. Knepley + dim - The spatial dimension 17345db36cf9SMatthew G. Knepley . Nf - The number of fields 17355db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17360c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17370c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17380c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17390c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 174097b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 174197b6e6e8SMatthew G. Knepley . constants - constant parameters 17420c2f2876SMatthew G. Knepley - ctx - optional user context 17430c2f2876SMatthew G. Knepley 17440c2f2876SMatthew G. Knepley Level: intermediate 17450c2f2876SMatthew G. Knepley 17460c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17470c2f2876SMatthew G. Knepley @*/ 17480c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 174997b6e6e8SMatthew 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)) 17500c2f2876SMatthew G. Knepley { 17510c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17520c2f2876SMatthew G. Knepley 17530c2f2876SMatthew G. Knepley PetscFunctionBegin; 17540c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1755de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 17560c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17570c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17580c2f2876SMatthew G. Knepley prob->r[f] = r; 17590c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17600c2f2876SMatthew G. Knepley } 17610c2f2876SMatthew G. Knepley 176232d2bbc9SMatthew G. Knepley /*@C 176332d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 176432d2bbc9SMatthew G. Knepley 176532d2bbc9SMatthew G. Knepley Not collective 176632d2bbc9SMatthew G. Knepley 176732d2bbc9SMatthew G. Knepley Input Parameters: 176832d2bbc9SMatthew G. Knepley + prob - The PetscDS 176932d2bbc9SMatthew G. Knepley - f - The field number 177032d2bbc9SMatthew G. Knepley 177132d2bbc9SMatthew G. Knepley Output Parameters: 177232d2bbc9SMatthew G. Knepley + update - update function 177332d2bbc9SMatthew G. Knepley 177432d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 177532d2bbc9SMatthew G. Knepley 177632d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 177732d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 177832d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 177932d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 178032d2bbc9SMatthew G. Knepley 178132d2bbc9SMatthew G. Knepley + dim - the spatial dimension 178232d2bbc9SMatthew G. Knepley . Nf - the number of fields 178332d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 178432d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 178532d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 178632d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 178732d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 178832d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 178932d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 179032d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 179132d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 179232d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 179332d2bbc9SMatthew G. Knepley . t - current time 179432d2bbc9SMatthew G. Knepley . x - coordinates of the current point 179532d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 179632d2bbc9SMatthew G. Knepley 179732d2bbc9SMatthew G. Knepley Level: intermediate 179832d2bbc9SMatthew G. Knepley 179932d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 180032d2bbc9SMatthew G. Knepley @*/ 180132d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS prob, PetscInt f, 180232d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 180332d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 180432d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18053fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 180632d2bbc9SMatthew G. Knepley { 180732d2bbc9SMatthew G. Knepley PetscFunctionBegin; 180832d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 180932d2bbc9SMatthew 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); 181032d2bbc9SMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = prob->update[f];} 181132d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 181232d2bbc9SMatthew G. Knepley } 181332d2bbc9SMatthew G. Knepley 181432d2bbc9SMatthew G. Knepley /*@C 18153fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 181632d2bbc9SMatthew G. Knepley 181732d2bbc9SMatthew G. Knepley Not collective 181832d2bbc9SMatthew G. Knepley 181932d2bbc9SMatthew G. Knepley Input Parameters: 182032d2bbc9SMatthew G. Knepley + prob - The PetscDS 182132d2bbc9SMatthew G. Knepley . f - The field number 182232d2bbc9SMatthew G. Knepley - update - update function 182332d2bbc9SMatthew G. Knepley 182432d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 182532d2bbc9SMatthew G. Knepley 182632d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 182732d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 182832d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182932d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 183032d2bbc9SMatthew G. Knepley 183132d2bbc9SMatthew G. Knepley + dim - the spatial dimension 183232d2bbc9SMatthew G. Knepley . Nf - the number of fields 183332d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 183432d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 183532d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 183632d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 183732d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 183832d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 183932d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 184032d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 184132d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 184232d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 184332d2bbc9SMatthew G. Knepley . t - current time 184432d2bbc9SMatthew G. Knepley . x - coordinates of the current point 184532d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 184632d2bbc9SMatthew G. Knepley 184732d2bbc9SMatthew G. Knepley Level: intermediate 184832d2bbc9SMatthew G. Knepley 184932d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 185032d2bbc9SMatthew G. Knepley @*/ 185132d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS prob, PetscInt f, 185232d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 185332d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 185432d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18553fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 185632d2bbc9SMatthew G. Knepley { 185732d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 185832d2bbc9SMatthew G. Knepley 185932d2bbc9SMatthew G. Knepley PetscFunctionBegin; 186032d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 186132d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 186232d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 186332d2bbc9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 186432d2bbc9SMatthew G. Knepley prob->update[f] = update; 186532d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 186632d2bbc9SMatthew G. Knepley } 186732d2bbc9SMatthew G. Knepley 18680c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 18690c2f2876SMatthew G. Knepley { 18700c2f2876SMatthew G. Knepley PetscFunctionBegin; 18710c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18720c2f2876SMatthew 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); 18730c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 18740c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 18750c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18760c2f2876SMatthew G. Knepley } 18770c2f2876SMatthew G. Knepley 18780c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 18790c2f2876SMatthew G. Knepley { 18800c2f2876SMatthew G. Knepley PetscErrorCode ierr; 18810c2f2876SMatthew G. Knepley 18820c2f2876SMatthew G. Knepley PetscFunctionBegin; 18830c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18840c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18850c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18860c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 18870c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18880c2f2876SMatthew G. Knepley } 18890c2f2876SMatthew G. Knepley 1890194d53e6SMatthew G. Knepley /*@C 1891194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1892194d53e6SMatthew G. Knepley 1893194d53e6SMatthew G. Knepley Not collective 1894194d53e6SMatthew G. Knepley 1895194d53e6SMatthew G. Knepley Input Parameters: 1896194d53e6SMatthew G. Knepley + prob - The PetscDS 1897194d53e6SMatthew G. Knepley - f - The test field number 1898194d53e6SMatthew G. Knepley 1899194d53e6SMatthew G. Knepley Output Parameters: 1900194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1901194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1902194d53e6SMatthew G. Knepley 1903194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1904194d53e6SMatthew G. Knepley 1905194d53e6SMatthew 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 1906194d53e6SMatthew G. Knepley 1907194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1908194d53e6SMatthew G. Knepley 190930b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1910194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1911194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 191230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1913194d53e6SMatthew G. Knepley 1914194d53e6SMatthew G. Knepley + dim - the spatial dimension 1915194d53e6SMatthew G. Knepley . Nf - the number of fields 1916194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1917194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1918194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1919194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1920194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1921194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1922194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1923194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1924194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1925194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1926194d53e6SMatthew G. Knepley . t - current time 1927194d53e6SMatthew G. Knepley . x - coordinates of the current point 1928194d53e6SMatthew G. Knepley . n - unit normal at the current point 192997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 193097b6e6e8SMatthew G. Knepley . constants - constant parameters 1931194d53e6SMatthew G. Knepley - f0 - output values at the current point 1932194d53e6SMatthew G. Knepley 1933194d53e6SMatthew G. Knepley Level: intermediate 1934194d53e6SMatthew G. Knepley 1935194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1936194d53e6SMatthew G. Knepley @*/ 19372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 193830b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1939194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1940194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 194230b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1943194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1944194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194597b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 19462764a2aaSMatthew G. Knepley { 19472764a2aaSMatthew G. Knepley PetscFunctionBegin; 19482764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19492764a2aaSMatthew 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); 19502764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 19512764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 19522764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19532764a2aaSMatthew G. Knepley } 19542764a2aaSMatthew G. Knepley 1955194d53e6SMatthew G. Knepley /*@C 1956194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1957194d53e6SMatthew G. Knepley 1958194d53e6SMatthew G. Knepley Not collective 1959194d53e6SMatthew G. Knepley 1960194d53e6SMatthew G. Knepley Input Parameters: 1961194d53e6SMatthew G. Knepley + prob - The PetscDS 1962194d53e6SMatthew G. Knepley . f - The test field number 1963194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1964194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1965194d53e6SMatthew G. Knepley 1966194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1967194d53e6SMatthew G. Knepley 1968194d53e6SMatthew 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 1969194d53e6SMatthew G. Knepley 1970194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1971194d53e6SMatthew G. Knepley 197230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1973194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1974194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 197530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1976194d53e6SMatthew G. Knepley 1977194d53e6SMatthew G. Knepley + dim - the spatial dimension 1978194d53e6SMatthew G. Knepley . Nf - the number of fields 1979194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1980194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1981194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1982194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1983194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1984194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1985194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1986194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1987194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1988194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1989194d53e6SMatthew G. Knepley . t - current time 1990194d53e6SMatthew G. Knepley . x - coordinates of the current point 1991194d53e6SMatthew G. Knepley . n - unit normal at the current point 199297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 199397b6e6e8SMatthew G. Knepley . constants - constant parameters 1994194d53e6SMatthew G. Knepley - f0 - output values at the current point 1995194d53e6SMatthew G. Knepley 1996194d53e6SMatthew G. Knepley Level: intermediate 1997194d53e6SMatthew G. Knepley 1998194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1999194d53e6SMatthew G. Knepley @*/ 20002764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 200130b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2002194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2003194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 200497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 200530b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2006194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2007194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 200897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20092764a2aaSMatthew G. Knepley { 20102764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20112764a2aaSMatthew G. Knepley 20122764a2aaSMatthew G. Knepley PetscFunctionBegin; 20132764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20142764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20152764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 20162764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 20172764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 20182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20192764a2aaSMatthew G. Knepley } 20202764a2aaSMatthew G. Knepley 2021194d53e6SMatthew G. Knepley /*@C 2022194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2023194d53e6SMatthew G. Knepley 2024194d53e6SMatthew G. Knepley Not collective 2025194d53e6SMatthew G. Knepley 2026194d53e6SMatthew G. Knepley Input Parameters: 2027194d53e6SMatthew G. Knepley + prob - The PetscDS 2028194d53e6SMatthew G. Knepley . f - The test field number 2029194d53e6SMatthew G. Knepley - g - The field number 2030194d53e6SMatthew G. Knepley 2031194d53e6SMatthew G. Knepley Output Parameters: 2032194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2033194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2034194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2035194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2036194d53e6SMatthew G. Knepley 2037194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2038194d53e6SMatthew G. Knepley 2039194d53e6SMatthew 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 2040194d53e6SMatthew G. Knepley 2041194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2042194d53e6SMatthew G. Knepley 204330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2044194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2045194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 204630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2047194d53e6SMatthew G. Knepley 2048194d53e6SMatthew G. Knepley + dim - the spatial dimension 2049194d53e6SMatthew G. Knepley . Nf - the number of fields 2050194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2051194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2052194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2053194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2054194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2055194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2056194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2057194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2058194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2059194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2060194d53e6SMatthew G. Knepley . t - current time 20612aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2062194d53e6SMatthew G. Knepley . x - coordinates of the current point 2063194d53e6SMatthew G. Knepley . n - normal at the current point 206497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 206597b6e6e8SMatthew G. Knepley . constants - constant parameters 2066194d53e6SMatthew G. Knepley - g0 - output values at the current point 2067194d53e6SMatthew G. Knepley 2068194d53e6SMatthew G. Knepley Level: intermediate 2069194d53e6SMatthew G. Knepley 2070194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2071194d53e6SMatthew G. Knepley @*/ 20722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 207330b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2074194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2075194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 207697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 207730b9ff8bSMatthew G. Knepley void (**g1)(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[], 208097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 208130b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2082194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2083194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 208497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 208530b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2086194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2087194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 208897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 20892764a2aaSMatthew G. Knepley { 20902764a2aaSMatthew G. Knepley PetscFunctionBegin; 20912764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20922764a2aaSMatthew 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); 20932764a2aaSMatthew G. Knepley if ((g < 0) || (g >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", g, prob->Nf); 20942764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 20952764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 20962764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 20972764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 20982764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20992764a2aaSMatthew G. Knepley } 21002764a2aaSMatthew G. Knepley 2101194d53e6SMatthew G. Knepley /*@C 2102194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2103194d53e6SMatthew G. Knepley 2104194d53e6SMatthew G. Knepley Not collective 2105194d53e6SMatthew G. Knepley 2106194d53e6SMatthew G. Knepley Input Parameters: 2107194d53e6SMatthew G. Knepley + prob - The PetscDS 2108194d53e6SMatthew G. Knepley . f - The test field number 2109194d53e6SMatthew G. Knepley . g - The field number 2110194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2111194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2112194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2113194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2114194d53e6SMatthew G. Knepley 2115194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2116194d53e6SMatthew G. Knepley 2117194d53e6SMatthew 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 2118194d53e6SMatthew G. Knepley 2119194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2120194d53e6SMatthew G. Knepley 212130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2122194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2123194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 212430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2125194d53e6SMatthew G. Knepley 2126194d53e6SMatthew G. Knepley + dim - the spatial dimension 2127194d53e6SMatthew G. Knepley . Nf - the number of fields 2128194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2129194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2130194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2131194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2132194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2133194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2134194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2135194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2136194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2137194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2138194d53e6SMatthew G. Knepley . t - current time 21392aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2140194d53e6SMatthew G. Knepley . x - coordinates of the current point 2141194d53e6SMatthew G. Knepley . n - normal at the current point 214297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 214397b6e6e8SMatthew G. Knepley . constants - constant parameters 2144194d53e6SMatthew G. Knepley - g0 - output values at the current point 2145194d53e6SMatthew G. Knepley 2146194d53e6SMatthew G. Knepley Level: intermediate 2147194d53e6SMatthew G. Knepley 2148194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2149194d53e6SMatthew G. Knepley @*/ 21502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 215130b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2152194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2153194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 215497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 215530b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2156194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2157194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 215897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 215930b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2160194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2161194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 216297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 216330b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2164194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2165194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 216697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 21672764a2aaSMatthew G. Knepley { 21682764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21692764a2aaSMatthew G. Knepley 21702764a2aaSMatthew G. Knepley PetscFunctionBegin; 21712764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21722764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 21732764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 21742764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 21752764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 21762764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21772764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 21782764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 21792764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 21802764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 21812764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 21822764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 21832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21842764a2aaSMatthew G. Knepley } 21852764a2aaSMatthew G. Knepley 21860d3e9b51SMatthew G. Knepley /*@C 2187c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2188c371a6d1SMatthew G. Knepley 2189c371a6d1SMatthew G. Knepley Not collective 2190c371a6d1SMatthew G. Knepley 2191c371a6d1SMatthew G. Knepley Input Parameters: 2192c371a6d1SMatthew G. Knepley + prob - The PetscDS 2193c371a6d1SMatthew G. Knepley - f - The test field number 2194c371a6d1SMatthew G. Knepley 2195c371a6d1SMatthew G. Knepley Output Parameter: 2196c371a6d1SMatthew G. Knepley . exactSol - exact solution for the test field 2197c371a6d1SMatthew G. Knepley 2198c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2199c371a6d1SMatthew G. Knepley 2200c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2201c371a6d1SMatthew G. Knepley 2202c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2203c371a6d1SMatthew G. Knepley . t - current time 2204c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2205c371a6d1SMatthew G. Knepley . Nc - the number of field components 2206c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2207c371a6d1SMatthew G. Knepley - ctx - a user context 2208c371a6d1SMatthew G. Knepley 2209c371a6d1SMatthew G. Knepley Level: intermediate 2210c371a6d1SMatthew G. Knepley 2211c371a6d1SMatthew G. Knepley .seealso: PetscDSSetExactSolution() 2212c371a6d1SMatthew G. Knepley @*/ 2213c371a6d1SMatthew G. Knepley PetscErrorCode PetscDSGetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (**sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx)) 2214c371a6d1SMatthew G. Knepley { 2215c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2216c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2217c371a6d1SMatthew 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); 2218c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 2219c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2220c371a6d1SMatthew G. Knepley } 2221c371a6d1SMatthew G. Knepley 2222c371a6d1SMatthew G. Knepley /*@C 2223c371a6d1SMatthew G. Knepley PetscDSSetExactSolution - Get the pointwise exact solution function for a given test field 2224c371a6d1SMatthew G. Knepley 2225c371a6d1SMatthew G. Knepley Not collective 2226c371a6d1SMatthew G. Knepley 2227c371a6d1SMatthew G. Knepley Input Parameters: 2228c371a6d1SMatthew G. Knepley + prob - The PetscDS 2229c371a6d1SMatthew G. Knepley . f - The test field number 2230c371a6d1SMatthew G. Knepley - sol - solution function for the test fields 2231c371a6d1SMatthew G. Knepley 2232c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2233c371a6d1SMatthew G. Knepley 2234c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2235c371a6d1SMatthew G. Knepley 2236c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2237c371a6d1SMatthew G. Knepley . t - current time 2238c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2239c371a6d1SMatthew G. Knepley . Nc - the number of field components 2240c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2241c371a6d1SMatthew G. Knepley - ctx - a user context 2242c371a6d1SMatthew G. Knepley 2243c371a6d1SMatthew G. Knepley Level: intermediate 2244c371a6d1SMatthew G. Knepley 2245c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2246c371a6d1SMatthew G. Knepley @*/ 2247c371a6d1SMatthew G. Knepley PetscErrorCode PetscDSSetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (*sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx)) 2248c371a6d1SMatthew G. Knepley { 2249c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2250c371a6d1SMatthew G. Knepley 2251c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2252c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2253c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2254c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2255c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 2256c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2257c371a6d1SMatthew G. Knepley } 2258c371a6d1SMatthew G. Knepley 22595638fd0eSMatthew G. Knepley /*@C 226097b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 226197b6e6e8SMatthew G. Knepley 226297b6e6e8SMatthew G. Knepley Not collective 226397b6e6e8SMatthew G. Knepley 226497b6e6e8SMatthew G. Knepley Input Parameter: 226597b6e6e8SMatthew G. Knepley . prob - The PetscDS object 226697b6e6e8SMatthew G. Knepley 226797b6e6e8SMatthew G. Knepley Output Parameters: 226897b6e6e8SMatthew G. Knepley + numConstants - The number of constants 226997b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 227097b6e6e8SMatthew G. Knepley 227197b6e6e8SMatthew G. Knepley Level: intermediate 227297b6e6e8SMatthew G. Knepley 227397b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 227497b6e6e8SMatthew G. Knepley @*/ 227597b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 227697b6e6e8SMatthew G. Knepley { 227797b6e6e8SMatthew G. Knepley PetscFunctionBegin; 227897b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 227997b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 228097b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 228197b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 228297b6e6e8SMatthew G. Knepley } 228397b6e6e8SMatthew G. Knepley 22840d3e9b51SMatthew G. Knepley /*@C 228597b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 228697b6e6e8SMatthew G. Knepley 228797b6e6e8SMatthew G. Knepley Not collective 228897b6e6e8SMatthew G. Knepley 228997b6e6e8SMatthew G. Knepley Input Parameters: 229097b6e6e8SMatthew G. Knepley + prob - The PetscDS object 229197b6e6e8SMatthew G. Knepley . numConstants - The number of constants 229297b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 229397b6e6e8SMatthew G. Knepley 229497b6e6e8SMatthew G. Knepley Level: intermediate 229597b6e6e8SMatthew G. Knepley 229697b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 229797b6e6e8SMatthew G. Knepley @*/ 229897b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 229997b6e6e8SMatthew G. Knepley { 230097b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 230197b6e6e8SMatthew G. Knepley 230297b6e6e8SMatthew G. Knepley PetscFunctionBegin; 230397b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 230497b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 230597b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 230697b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 230797b6e6e8SMatthew G. Knepley if (prob->numConstants) { 230897b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 230920be0f5bSMatthew G. Knepley } else { 231020be0f5bSMatthew G. Knepley prob->constants = NULL; 231120be0f5bSMatthew G. Knepley } 231220be0f5bSMatthew G. Knepley } 231320be0f5bSMatthew G. Knepley if (prob->numConstants) { 231420be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 231597b6e6e8SMatthew G. Knepley ierr = PetscMemcpy(prob->constants, constants, prob->numConstants * sizeof(PetscScalar));CHKERRQ(ierr); 231697b6e6e8SMatthew G. Knepley } 231797b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 231897b6e6e8SMatthew G. Knepley } 231997b6e6e8SMatthew G. Knepley 23204cd1e086SMatthew G. Knepley /*@ 23214cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 23224cd1e086SMatthew G. Knepley 23234cd1e086SMatthew G. Knepley Not collective 23244cd1e086SMatthew G. Knepley 23254cd1e086SMatthew G. Knepley Input Parameters: 23264cd1e086SMatthew G. Knepley + prob - The PetscDS object 23274cd1e086SMatthew G. Knepley - disc - The discretization object 23284cd1e086SMatthew G. Knepley 23294cd1e086SMatthew G. Knepley Output Parameter: 23304cd1e086SMatthew G. Knepley . f - The field number 23314cd1e086SMatthew G. Knepley 23324cd1e086SMatthew G. Knepley Level: beginner 23334cd1e086SMatthew G. Knepley 2334f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 23354cd1e086SMatthew G. Knepley @*/ 23364cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 23374cd1e086SMatthew G. Knepley { 23384cd1e086SMatthew G. Knepley PetscInt g; 23394cd1e086SMatthew G. Knepley 23404cd1e086SMatthew G. Knepley PetscFunctionBegin; 23414cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23424cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 23434cd1e086SMatthew G. Knepley *f = -1; 23444cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 23454cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 23464cd1e086SMatthew G. Knepley *f = g; 23474cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 23484cd1e086SMatthew G. Knepley } 23494cd1e086SMatthew G. Knepley 23504cd1e086SMatthew G. Knepley /*@ 23514cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 23524cd1e086SMatthew G. Knepley 23534cd1e086SMatthew G. Knepley Not collective 23544cd1e086SMatthew G. Knepley 23554cd1e086SMatthew G. Knepley Input Parameters: 23564cd1e086SMatthew G. Knepley + prob - The PetscDS object 23574cd1e086SMatthew G. Knepley - f - The field number 23584cd1e086SMatthew G. Knepley 23594cd1e086SMatthew G. Knepley Output Parameter: 23604cd1e086SMatthew G. Knepley . size - The size 23614cd1e086SMatthew G. Knepley 23624cd1e086SMatthew G. Knepley Level: beginner 23634cd1e086SMatthew G. Knepley 2364f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 23654cd1e086SMatthew G. Knepley @*/ 23664cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 23674cd1e086SMatthew G. Knepley { 23682166fd64SMatthew G. Knepley PetscErrorCode ierr; 23692166fd64SMatthew G. Knepley 23704cd1e086SMatthew G. Knepley PetscFunctionBegin; 23714cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23724cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 23734cd1e086SMatthew 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); 23742166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2375d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 23764cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 23774cd1e086SMatthew G. Knepley } 23784cd1e086SMatthew G. Knepley 2379bc4ae4beSMatthew G. Knepley /*@ 2380bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2381bc4ae4beSMatthew G. Knepley 2382bc4ae4beSMatthew G. Knepley Not collective 2383bc4ae4beSMatthew G. Knepley 2384bc4ae4beSMatthew G. Knepley Input Parameters: 2385bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2386bc4ae4beSMatthew G. Knepley - f - The field number 2387bc4ae4beSMatthew G. Knepley 2388bc4ae4beSMatthew G. Knepley Output Parameter: 2389bc4ae4beSMatthew G. Knepley . off - The offset 2390bc4ae4beSMatthew G. Knepley 2391bc4ae4beSMatthew G. Knepley Level: beginner 2392bc4ae4beSMatthew G. Knepley 2393f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2394bc4ae4beSMatthew G. Knepley @*/ 23952764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 23962764a2aaSMatthew G. Knepley { 23974cd1e086SMatthew G. Knepley PetscInt size, g; 23982764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23992764a2aaSMatthew G. Knepley 24002764a2aaSMatthew G. Knepley PetscFunctionBegin; 24012764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24022764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 24032764a2aaSMatthew 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); 24042764a2aaSMatthew G. Knepley *off = 0; 24052764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 24064cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 24074cd1e086SMatthew G. Knepley *off += size; 24082764a2aaSMatthew G. Knepley } 24092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24102764a2aaSMatthew G. Knepley } 24112764a2aaSMatthew G. Knepley 2412bc4ae4beSMatthew G. Knepley /*@ 241347e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2414bc4ae4beSMatthew G. Knepley 2415bc4ae4beSMatthew G. Knepley Not collective 2416bc4ae4beSMatthew G. Knepley 241747e57110SSander Arens Input Parameter: 241847e57110SSander Arens . prob - The PetscDS object 2419bc4ae4beSMatthew G. Knepley 2420bc4ae4beSMatthew G. Knepley Output Parameter: 242147e57110SSander Arens . dimensions - The number of dimensions 2422bc4ae4beSMatthew G. Knepley 2423bc4ae4beSMatthew G. Knepley Level: beginner 2424bc4ae4beSMatthew G. Knepley 242547e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2426bc4ae4beSMatthew G. Knepley @*/ 242747e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 24282764a2aaSMatthew G. Knepley { 24292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24302764a2aaSMatthew G. Knepley 24312764a2aaSMatthew G. Knepley PetscFunctionBegin; 24322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 243347e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 243447e57110SSander Arens PetscValidPointer(dimensions, 2); 243547e57110SSander Arens *dimensions = prob->Nb; 243647e57110SSander Arens PetscFunctionReturn(0); 24376ce16762SMatthew G. Knepley } 243847e57110SSander Arens 243947e57110SSander Arens /*@ 244047e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 244147e57110SSander Arens 244247e57110SSander Arens Not collective 244347e57110SSander Arens 244447e57110SSander Arens Input Parameter: 244547e57110SSander Arens . prob - The PetscDS object 244647e57110SSander Arens 244747e57110SSander Arens Output Parameter: 244847e57110SSander Arens . components - The number of components 244947e57110SSander Arens 245047e57110SSander Arens Level: beginner 245147e57110SSander Arens 245247e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 245347e57110SSander Arens @*/ 245447e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 245547e57110SSander Arens { 245647e57110SSander Arens PetscErrorCode ierr; 245747e57110SSander Arens 245847e57110SSander Arens PetscFunctionBegin; 245947e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 246047e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 246147e57110SSander Arens PetscValidPointer(components, 2); 246247e57110SSander Arens *components = prob->Nc; 24636ce16762SMatthew G. Knepley PetscFunctionReturn(0); 24646ce16762SMatthew G. Knepley } 24656ce16762SMatthew G. Knepley 24666ce16762SMatthew G. Knepley /*@ 24676ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 24686ce16762SMatthew G. Knepley 24696ce16762SMatthew G. Knepley Not collective 24706ce16762SMatthew G. Knepley 24716ce16762SMatthew G. Knepley Input Parameters: 24726ce16762SMatthew G. Knepley + prob - The PetscDS object 24736ce16762SMatthew G. Knepley - f - The field number 24746ce16762SMatthew G. Knepley 24756ce16762SMatthew G. Knepley Output Parameter: 24766ce16762SMatthew G. Knepley . off - The offset 24776ce16762SMatthew G. Knepley 24786ce16762SMatthew G. Knepley Level: beginner 24796ce16762SMatthew G. Knepley 2480f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 24816ce16762SMatthew G. Knepley @*/ 24826ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 24836ce16762SMatthew G. Knepley { 24846ce16762SMatthew G. Knepley PetscFunctionBegin; 24856ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24866ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 24876ce16762SMatthew 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); 248847e57110SSander Arens *off = prob->off[f]; 24892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24902764a2aaSMatthew G. Knepley } 24912764a2aaSMatthew G. Knepley 2492194d53e6SMatthew G. Knepley /*@ 2493194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2494194d53e6SMatthew G. Knepley 2495194d53e6SMatthew G. Knepley Not collective 2496194d53e6SMatthew G. Knepley 2497194d53e6SMatthew G. Knepley Input Parameter: 2498194d53e6SMatthew G. Knepley . prob - The PetscDS object 2499194d53e6SMatthew G. Knepley 2500194d53e6SMatthew G. Knepley Output Parameter: 2501194d53e6SMatthew G. Knepley . offsets - The offsets 2502194d53e6SMatthew G. Knepley 2503194d53e6SMatthew G. Knepley Level: beginner 2504194d53e6SMatthew G. Knepley 2505f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2506194d53e6SMatthew G. Knepley @*/ 2507194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2508194d53e6SMatthew G. Knepley { 2509194d53e6SMatthew G. Knepley PetscFunctionBegin; 2510194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2511194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2512194d53e6SMatthew G. Knepley *offsets = prob->off; 2513194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2514194d53e6SMatthew G. Knepley } 2515194d53e6SMatthew G. Knepley 2516194d53e6SMatthew G. Knepley /*@ 2517194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2518194d53e6SMatthew G. Knepley 2519194d53e6SMatthew G. Knepley Not collective 2520194d53e6SMatthew G. Knepley 2521194d53e6SMatthew G. Knepley Input Parameter: 2522194d53e6SMatthew G. Knepley . prob - The PetscDS object 2523194d53e6SMatthew G. Knepley 2524194d53e6SMatthew G. Knepley Output Parameter: 2525194d53e6SMatthew G. Knepley . offsets - The offsets 2526194d53e6SMatthew G. Knepley 2527194d53e6SMatthew G. Knepley Level: beginner 2528194d53e6SMatthew G. Knepley 2529f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2530194d53e6SMatthew G. Knepley @*/ 2531194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2532194d53e6SMatthew G. Knepley { 2533194d53e6SMatthew G. Knepley PetscFunctionBegin; 2534194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2535194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2536194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2537194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2538194d53e6SMatthew G. Knepley } 2539194d53e6SMatthew G. Knepley 254068c9edb9SMatthew G. Knepley /*@C 254168c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 254268c9edb9SMatthew G. Knepley 254368c9edb9SMatthew G. Knepley Not collective 254468c9edb9SMatthew G. Knepley 254568c9edb9SMatthew G. Knepley Input Parameter: 254668c9edb9SMatthew G. Knepley . prob - The PetscDS object 254768c9edb9SMatthew G. Knepley 254868c9edb9SMatthew G. Knepley Output Parameters: 254968c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 255068c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 255168c9edb9SMatthew G. Knepley 255268c9edb9SMatthew G. Knepley Level: intermediate 255368c9edb9SMatthew G. Knepley 2554f744cafaSSander Arens .seealso: PetscDSCreate() 255568c9edb9SMatthew G. Knepley @*/ 25562764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 25572764a2aaSMatthew G. Knepley { 25582764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25592764a2aaSMatthew G. Knepley 25602764a2aaSMatthew G. Knepley PetscFunctionBegin; 25612764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 25622764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 25632764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 25642764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 25652764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25662764a2aaSMatthew G. Knepley } 25672764a2aaSMatthew G. Knepley 256868c9edb9SMatthew G. Knepley /*@C 25694d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 257068c9edb9SMatthew G. Knepley 257168c9edb9SMatthew G. Knepley Not collective 257268c9edb9SMatthew G. Knepley 257368c9edb9SMatthew G. Knepley Input Parameter: 257468c9edb9SMatthew G. Knepley . prob - The PetscDS object 257568c9edb9SMatthew G. Knepley 257668c9edb9SMatthew G. Knepley Output Parameters: 25774d0b9603SSander Arens + basisFace - The basis function tabulation at quadrature points 25784d0b9603SSander Arens - basisDerFace - The basis function derivative tabulation at quadrature points 257968c9edb9SMatthew G. Knepley 258068c9edb9SMatthew G. Knepley Level: intermediate 258168c9edb9SMatthew G. Knepley 258268c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 258368c9edb9SMatthew G. Knepley @*/ 25844d0b9603SSander Arens PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 25852764a2aaSMatthew G. Knepley { 25862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25872764a2aaSMatthew G. Knepley 25882764a2aaSMatthew G. Knepley PetscFunctionBegin; 25892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 25902764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 25914d0b9603SSander Arens if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisFace;} 25924d0b9603SSander Arens if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerFace;} 25932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25942764a2aaSMatthew G. Knepley } 25952764a2aaSMatthew G. Knepley 25962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 25972764a2aaSMatthew G. Knepley { 25982764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25992764a2aaSMatthew G. Knepley 26002764a2aaSMatthew G. Knepley PetscFunctionBegin; 26012764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26022764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26032764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 26042764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 26052764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 26062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26072764a2aaSMatthew G. Knepley } 26082764a2aaSMatthew G. Knepley 26092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 26102764a2aaSMatthew G. Knepley { 26112764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26122764a2aaSMatthew G. Knepley 26132764a2aaSMatthew G. Knepley PetscFunctionBegin; 26142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26152764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26162764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 26172764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 26182764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 26192764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 26202764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 26212764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 26222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26232764a2aaSMatthew G. Knepley } 26242764a2aaSMatthew G. Knepley 26252764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 26262764a2aaSMatthew G. Knepley { 26272764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26282764a2aaSMatthew G. Knepley 26292764a2aaSMatthew G. Knepley PetscFunctionBegin; 26302764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26312764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26322764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 26332764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 26342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26352764a2aaSMatthew G. Knepley } 26362764a2aaSMatthew G. Knepley 263758ebd649SToby Isaac /*@C 263858ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 263958ebd649SToby Isaac 264058ebd649SToby Isaac Input Parameters: 264158ebd649SToby Isaac + ds - The PetscDS object 26422d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 264358ebd649SToby Isaac . name - The BC name 264458ebd649SToby Isaac . labelname - The label defining constrained points 264558ebd649SToby Isaac . field - The field to constrain 2646*e8ecbf3fSStefano Zampini . numcomps - The number of constrained field components (0 will constrain all fields) 264758ebd649SToby Isaac . comps - An array of constrained component numbers 264858ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 264958ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 265058ebd649SToby Isaac . ids - An array of ids for constrained points 265158ebd649SToby Isaac - ctx - An optional user context for bcFunc 265258ebd649SToby Isaac 265358ebd649SToby Isaac Options Database Keys: 265458ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 265558ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 265658ebd649SToby Isaac 265758ebd649SToby Isaac Level: developer 265858ebd649SToby Isaac 265958ebd649SToby Isaac .seealso: PetscDSGetBoundary() 266058ebd649SToby Isaac @*/ 2661a30ec4eaSSatish Balay PetscErrorCode PetscDSAddBoundary(PetscDS ds, DMBoundaryConditionType type, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(void), PetscInt numids, const PetscInt *ids, void *ctx) 266258ebd649SToby Isaac { 266358ebd649SToby Isaac DSBoundary b; 266458ebd649SToby Isaac PetscErrorCode ierr; 266558ebd649SToby Isaac 266658ebd649SToby Isaac PetscFunctionBegin; 266758ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 266858ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 266958ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 267058ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 267158ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 267258ebd649SToby Isaac if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 267358ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 267458ebd649SToby Isaac if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 2675f971fd6bSMatthew G. Knepley b->type = type; 267658ebd649SToby Isaac b->field = field; 267758ebd649SToby Isaac b->numcomps = numcomps; 267858ebd649SToby Isaac b->func = bcFunc; 267958ebd649SToby Isaac b->numids = numids; 268058ebd649SToby Isaac b->ctx = ctx; 268158ebd649SToby Isaac b->next = ds->boundary; 268258ebd649SToby Isaac ds->boundary = b; 268358ebd649SToby Isaac PetscFunctionReturn(0); 268458ebd649SToby Isaac } 268558ebd649SToby Isaac 2686b67eacb3SMatthew G. Knepley /*@C 2687b67eacb3SMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model 2688b67eacb3SMatthew G. Knepley 2689b67eacb3SMatthew G. Knepley Input Parameters: 2690b67eacb3SMatthew G. Knepley + ds - The PetscDS object 2691b67eacb3SMatthew G. Knepley . bd - The boundary condition number 2692b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 2693b67eacb3SMatthew G. Knepley . name - The BC name 2694b67eacb3SMatthew G. Knepley . labelname - The label defining constrained points 2695b67eacb3SMatthew G. Knepley . field - The field to constrain 2696b67eacb3SMatthew G. Knepley . numcomps - The number of constrained field components 2697b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 2698b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 2699b67eacb3SMatthew G. Knepley . numids - The number of DMLabel ids for constrained points 2700b67eacb3SMatthew G. Knepley . ids - An array of ids for constrained points 2701b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 2702b67eacb3SMatthew G. Knepley 27039a6efb6aSMatthew G. Knepley Note: The boundary condition number is the order in which it was registered. The user can get the number of boundary conditions from PetscDSGetNumBoundary(). 27049a6efb6aSMatthew G. Knepley 2705b67eacb3SMatthew G. Knepley Level: developer 2706b67eacb3SMatthew G. Knepley 27079a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 2708b67eacb3SMatthew G. Knepley @*/ 2709b67eacb3SMatthew G. Knepley PetscErrorCode PetscDSUpdateBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType type, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(void), PetscInt numids, const PetscInt *ids, void *ctx) 2710b67eacb3SMatthew G. Knepley { 2711b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 2712b67eacb3SMatthew G. Knepley PetscInt n = 0; 2713b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 2714b67eacb3SMatthew G. Knepley 2715b67eacb3SMatthew G. Knepley PetscFunctionBegin; 2716b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2717b67eacb3SMatthew G. Knepley while (b) { 2718b67eacb3SMatthew G. Knepley if (n == bd) break; 2719b67eacb3SMatthew G. Knepley b = b->next; 2720b67eacb3SMatthew G. Knepley ++n; 2721b67eacb3SMatthew G. Knepley } 2722b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 2723b67eacb3SMatthew G. Knepley if (name) { 2724b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 2725b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 2726b67eacb3SMatthew G. Knepley } 2727b67eacb3SMatthew G. Knepley if (labelname) { 2728b67eacb3SMatthew G. Knepley ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2729b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 2730b67eacb3SMatthew G. Knepley } 2731b67eacb3SMatthew G. Knepley if (numcomps >= 0 && numcomps != b->numcomps) { 2732b67eacb3SMatthew G. Knepley b->numcomps = numcomps; 2733b67eacb3SMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 2734b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 2735b67eacb3SMatthew G. Knepley if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 2736b67eacb3SMatthew G. Knepley } 2737b67eacb3SMatthew G. Knepley if (numids >= 0 && numids != b->numids) { 2738b67eacb3SMatthew G. Knepley b->numids = numids; 2739b67eacb3SMatthew G. Knepley ierr = PetscFree(b->ids);CHKERRQ(ierr); 2740b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 2741b67eacb3SMatthew G. Knepley if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 2742b67eacb3SMatthew G. Knepley } 2743b67eacb3SMatthew G. Knepley b->type = type; 2744b67eacb3SMatthew G. Knepley if (field >= 0) {b->field = field;} 2745b67eacb3SMatthew G. Knepley if (bcFunc) {b->func = bcFunc;} 2746b67eacb3SMatthew G. Knepley if (ctx) {b->ctx = ctx;} 2747b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 2748b67eacb3SMatthew G. Knepley } 2749b67eacb3SMatthew G. Knepley 275058ebd649SToby Isaac /*@ 275158ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 275258ebd649SToby Isaac 275358ebd649SToby Isaac Input Parameters: 275458ebd649SToby Isaac . ds - The PetscDS object 275558ebd649SToby Isaac 275658ebd649SToby Isaac Output Parameters: 275758ebd649SToby Isaac . numBd - The number of BC 275858ebd649SToby Isaac 275958ebd649SToby Isaac Level: intermediate 276058ebd649SToby Isaac 276158ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 276258ebd649SToby Isaac @*/ 276358ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 276458ebd649SToby Isaac { 276558ebd649SToby Isaac DSBoundary b = ds->boundary; 276658ebd649SToby Isaac 276758ebd649SToby Isaac PetscFunctionBegin; 276858ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 276958ebd649SToby Isaac PetscValidPointer(numBd, 2); 277058ebd649SToby Isaac *numBd = 0; 277158ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 277258ebd649SToby Isaac PetscFunctionReturn(0); 277358ebd649SToby Isaac } 277458ebd649SToby Isaac 277558ebd649SToby Isaac /*@C 27769a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 277758ebd649SToby Isaac 277858ebd649SToby Isaac Input Parameters: 277958ebd649SToby Isaac + ds - The PetscDS object 278058ebd649SToby Isaac - bd - The BC number 278158ebd649SToby Isaac 278258ebd649SToby Isaac Output Parameters: 27832d47a189SJulian Andrej + type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 278458ebd649SToby Isaac . name - The BC name 278558ebd649SToby Isaac . labelname - The label defining constrained points 278658ebd649SToby Isaac . field - The field to constrain 278758ebd649SToby Isaac . numcomps - The number of constrained field components 278858ebd649SToby Isaac . comps - An array of constrained component numbers 278958ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 279058ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 279158ebd649SToby Isaac . ids - An array of ids for constrained points 279258ebd649SToby Isaac - ctx - An optional user context for bcFunc 279358ebd649SToby Isaac 279458ebd649SToby Isaac Options Database Keys: 279558ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 279658ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 279758ebd649SToby Isaac 279858ebd649SToby Isaac Level: developer 279958ebd649SToby Isaac 280058ebd649SToby Isaac .seealso: PetscDSAddBoundary() 280158ebd649SToby Isaac @*/ 2802a30ec4eaSSatish Balay PetscErrorCode PetscDSGetBoundary(PetscDS ds, PetscInt bd, DMBoundaryConditionType *type, const char **name, const char **labelname, PetscInt *field, PetscInt *numcomps, const PetscInt **comps, void (**func)(void), PetscInt *numids, const PetscInt **ids, void **ctx) 280358ebd649SToby Isaac { 280458ebd649SToby Isaac DSBoundary b = ds->boundary; 280558ebd649SToby Isaac PetscInt n = 0; 280658ebd649SToby Isaac 280758ebd649SToby Isaac PetscFunctionBegin; 280858ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 280958ebd649SToby Isaac while (b) { 281058ebd649SToby Isaac if (n == bd) break; 281158ebd649SToby Isaac b = b->next; 281258ebd649SToby Isaac ++n; 281358ebd649SToby Isaac } 281458ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 2815f971fd6bSMatthew G. Knepley if (type) { 2816f971fd6bSMatthew G. Knepley PetscValidPointer(type, 3); 2817f971fd6bSMatthew G. Knepley *type = b->type; 281858ebd649SToby Isaac } 281958ebd649SToby Isaac if (name) { 282058ebd649SToby Isaac PetscValidPointer(name, 4); 282158ebd649SToby Isaac *name = b->name; 282258ebd649SToby Isaac } 282358ebd649SToby Isaac if (labelname) { 282458ebd649SToby Isaac PetscValidPointer(labelname, 5); 282558ebd649SToby Isaac *labelname = b->labelname; 282658ebd649SToby Isaac } 282758ebd649SToby Isaac if (field) { 282858ebd649SToby Isaac PetscValidPointer(field, 6); 282958ebd649SToby Isaac *field = b->field; 283058ebd649SToby Isaac } 283158ebd649SToby Isaac if (numcomps) { 283258ebd649SToby Isaac PetscValidPointer(numcomps, 7); 283358ebd649SToby Isaac *numcomps = b->numcomps; 283458ebd649SToby Isaac } 283558ebd649SToby Isaac if (comps) { 283658ebd649SToby Isaac PetscValidPointer(comps, 8); 283758ebd649SToby Isaac *comps = b->comps; 283858ebd649SToby Isaac } 283958ebd649SToby Isaac if (func) { 284058ebd649SToby Isaac PetscValidPointer(func, 9); 284158ebd649SToby Isaac *func = b->func; 284258ebd649SToby Isaac } 284358ebd649SToby Isaac if (numids) { 284458ebd649SToby Isaac PetscValidPointer(numids, 10); 284558ebd649SToby Isaac *numids = b->numids; 284658ebd649SToby Isaac } 284758ebd649SToby Isaac if (ids) { 284858ebd649SToby Isaac PetscValidPointer(ids, 11); 284958ebd649SToby Isaac *ids = b->ids; 285058ebd649SToby Isaac } 285158ebd649SToby Isaac if (ctx) { 285258ebd649SToby Isaac PetscValidPointer(ctx, 12); 285358ebd649SToby Isaac *ctx = b->ctx; 285458ebd649SToby Isaac } 285558ebd649SToby Isaac PetscFunctionReturn(0); 285658ebd649SToby Isaac } 285758ebd649SToby Isaac 28589252d075SMatthew G. Knepley /*@ 28599252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 28609252d075SMatthew G. Knepley 28619252d075SMatthew G. Knepley Not collective 28629252d075SMatthew G. Knepley 28639252d075SMatthew G. Knepley Input Parameter: 28649252d075SMatthew G. Knepley . prob - The PetscDS object 28659252d075SMatthew G. Knepley 28669252d075SMatthew G. Knepley Output Parameter: 28679252d075SMatthew G. Knepley . newprob - The PetscDS copy 28689252d075SMatthew G. Knepley 28699252d075SMatthew G. Knepley Level: intermediate 28709252d075SMatthew G. Knepley 28719252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 28729252d075SMatthew G. Knepley @*/ 2873dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 2874dff059c6SToby Isaac { 2875dff059c6SToby Isaac DSBoundary b, next, *lastnext; 2876dff059c6SToby Isaac PetscErrorCode ierr; 2877dff059c6SToby Isaac 2878dff059c6SToby Isaac PetscFunctionBegin; 2879dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 2880dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 2881dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 2882dff059c6SToby Isaac next = probB->boundary; 2883dff059c6SToby Isaac while (next) { 2884dff059c6SToby Isaac DSBoundary b = next; 2885dff059c6SToby Isaac 2886dff059c6SToby Isaac next = b->next; 2887dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 2888dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 2889dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 2890dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2891dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 2892dff059c6SToby Isaac } 2893dff059c6SToby Isaac lastnext = &(probB->boundary); 2894dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 2895dff059c6SToby Isaac DSBoundary bNew; 2896dff059c6SToby Isaac 2897459726d8SSatish Balay ierr = PetscNew(&bNew);CHKERRQ(ierr); 2898dff059c6SToby Isaac bNew->numcomps = b->numcomps; 2899dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 2900dff059c6SToby Isaac ierr = PetscMemcpy(bNew->comps, b->comps, bNew->numcomps*sizeof(PetscInt));CHKERRQ(ierr); 2901dff059c6SToby Isaac bNew->numids = b->numids; 2902dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 2903dff059c6SToby Isaac ierr = PetscMemcpy(bNew->ids, b->ids, bNew->numids*sizeof(PetscInt));CHKERRQ(ierr); 2904dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 2905dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 2906dff059c6SToby Isaac bNew->ctx = b->ctx; 2907f971fd6bSMatthew G. Knepley bNew->type = b->type; 2908dff059c6SToby Isaac bNew->field = b->field; 2909dff059c6SToby Isaac bNew->func = b->func; 2910dff059c6SToby Isaac 2911dff059c6SToby Isaac *lastnext = bNew; 2912dff059c6SToby Isaac lastnext = &(bNew->next); 2913dff059c6SToby Isaac } 2914dff059c6SToby Isaac PetscFunctionReturn(0); 2915dff059c6SToby Isaac } 2916dff059c6SToby Isaac 29179252d075SMatthew G. Knepley /*@C 29189252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 29199252d075SMatthew G. Knepley 29209252d075SMatthew G. Knepley Not collective 29219252d075SMatthew G. Knepley 29229252d075SMatthew G. Knepley Input Parameter: 29239252d075SMatthew G. Knepley + prob - The PetscDS object 29249252d075SMatthew G. Knepley . numFields - Number of new fields 29259252d075SMatthew G. Knepley - fields - Old field number for each new field 29269252d075SMatthew G. Knepley 29279252d075SMatthew G. Knepley Output Parameter: 29289252d075SMatthew G. Knepley . newprob - The PetscDS copy 29299252d075SMatthew G. Knepley 29309252d075SMatthew G. Knepley Level: intermediate 29319252d075SMatthew G. Knepley 29329252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 29339252d075SMatthew G. Knepley @*/ 29349252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 29359252d075SMatthew G. Knepley { 29369252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 29379252d075SMatthew G. Knepley PetscErrorCode ierr; 29389252d075SMatthew G. Knepley 29399252d075SMatthew G. Knepley PetscFunctionBegin; 29409252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29419252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 29429252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 29439252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 29449252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 29459252d075SMatthew 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); 29469252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 29479252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 29489252d075SMatthew G. Knepley PetscPointFunc obj; 29499252d075SMatthew G. Knepley PetscPointFunc f0, f1; 29509252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 29519252d075SMatthew G. Knepley PetscRiemannFunc r; 29529252d075SMatthew G. Knepley 29539252d075SMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 29549252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 29559252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 29569252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 29579252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 29589252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 29599252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 29609252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 29619252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 29629252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 29639252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 29649252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 29659252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 29669252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 29679252d075SMatthew G. Knepley 29689252d075SMatthew G. Knepley if (g >= Nf) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", g, Nf); 29699252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 29709252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 29719252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 29729252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 29739252d075SMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(prob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 29749252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 29759252d075SMatthew G. Knepley } 29769252d075SMatthew G. Knepley } 29779252d075SMatthew G. Knepley PetscFunctionReturn(0); 29789252d075SMatthew G. Knepley } 29799252d075SMatthew G. Knepley 2980da51fcedSMatthew G. Knepley /*@ 2981da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 2982da51fcedSMatthew G. Knepley 2983da51fcedSMatthew G. Knepley Not collective 2984da51fcedSMatthew G. Knepley 2985da51fcedSMatthew G. Knepley Input Parameter: 2986da51fcedSMatthew G. Knepley . prob - The PetscDS object 2987da51fcedSMatthew G. Knepley 2988da51fcedSMatthew G. Knepley Output Parameter: 2989da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 2990da51fcedSMatthew G. Knepley 2991da51fcedSMatthew G. Knepley Level: intermediate 2992da51fcedSMatthew G. Knepley 29939252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 2994da51fcedSMatthew G. Knepley @*/ 2995da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 2996da51fcedSMatthew G. Knepley { 29979252d075SMatthew G. Knepley PetscInt Nf, Ng; 2998da51fcedSMatthew G. Knepley PetscErrorCode ierr; 2999da51fcedSMatthew G. Knepley 3000da51fcedSMatthew G. Knepley PetscFunctionBegin; 3001da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3002da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3003da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3004da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 300513903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 30069252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 30079252d075SMatthew G. Knepley PetscFunctionReturn(0); 30089252d075SMatthew G. Knepley } 30099252d075SMatthew G. Knepley /*@ 30109252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3011da51fcedSMatthew G. Knepley 30129252d075SMatthew G. Knepley Not collective 30139252d075SMatthew G. Knepley 30149252d075SMatthew G. Knepley Input Parameter: 30159252d075SMatthew G. Knepley . prob - The PetscDS object 30169252d075SMatthew G. Knepley 30179252d075SMatthew G. Knepley Output Parameter: 30189252d075SMatthew G. Knepley . newprob - The PetscDS copy 30199252d075SMatthew G. Knepley 30209252d075SMatthew G. Knepley Level: intermediate 30219252d075SMatthew G. Knepley 30229252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 30239252d075SMatthew G. Knepley @*/ 30249252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 30259252d075SMatthew G. Knepley { 30269252d075SMatthew G. Knepley PetscInt Nc; 30279252d075SMatthew G. Knepley const PetscScalar *constants; 30289252d075SMatthew G. Knepley PetscErrorCode ierr; 30299252d075SMatthew G. Knepley 30309252d075SMatthew G. Knepley PetscFunctionBegin; 30319252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30329252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 30339252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 30349252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3035da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3036da51fcedSMatthew G. Knepley } 3037da51fcedSMatthew G. Knepley 3038b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3039b1353e8eSMatthew G. Knepley { 3040df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3041b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3042b1353e8eSMatthew G. Knepley 3043b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3044b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3045b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3046b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3047b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3048df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3049df3a45bdSMatthew 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); 3050df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3051df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3052b1353e8eSMatthew G. Knepley PetscInt cdim; 3053b1353e8eSMatthew G. Knepley 3054df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3055b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3056df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3057b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3058b1353e8eSMatthew G. Knepley PetscFE subfe; 3059b1353e8eSMatthew G. Knepley PetscObject obj; 3060b1353e8eSMatthew G. Knepley PetscClassId id; 3061b1353e8eSMatthew G. Knepley 3062b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3063b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3064b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3065b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3066df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3067b1353e8eSMatthew G. Knepley } 3068b1353e8eSMatthew G. Knepley } 3069df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3070b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3071b1353e8eSMatthew G. Knepley } 3072b1353e8eSMatthew G. Knepley 3073bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 30742764a2aaSMatthew G. Knepley { 3075931fb3b8SToby Isaac PetscErrorCode ierr; 3076931fb3b8SToby Isaac 30772764a2aaSMatthew G. Knepley PetscFunctionBegin; 3078931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 30792764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30802764a2aaSMatthew G. Knepley } 30812764a2aaSMatthew G. Knepley 3082bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 30832764a2aaSMatthew G. Knepley { 30842764a2aaSMatthew G. Knepley PetscFunctionBegin; 30852764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 30862764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 30872764a2aaSMatthew G. Knepley prob->ops->view = NULL; 30882764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 30892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 30902764a2aaSMatthew G. Knepley } 30912764a2aaSMatthew G. Knepley 30922764a2aaSMatthew G. Knepley /*MC 30932764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 30942764a2aaSMatthew G. Knepley 30952764a2aaSMatthew G. Knepley Level: intermediate 30962764a2aaSMatthew G. Knepley 30972764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 30982764a2aaSMatthew G. Knepley M*/ 30992764a2aaSMatthew G. Knepley 31002764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 31012764a2aaSMatthew G. Knepley { 31022764a2aaSMatthew G. Knepley PetscDS_Basic *b; 31032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 31042764a2aaSMatthew G. Knepley 31052764a2aaSMatthew G. Knepley PetscFunctionBegin; 3106931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 31072764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 31082764a2aaSMatthew G. Knepley prob->data = b; 31092764a2aaSMatthew G. Knepley 31102764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 31112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31122764a2aaSMatthew G. Knepley } 3113