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 /*@ 649*8edf6225SMatthew G. Knepley PetscDSGetHybrid - Returns the flag for a hybrid (cohesive) cell 650*8edf6225SMatthew G. Knepley 651*8edf6225SMatthew G. Knepley Not collective 652*8edf6225SMatthew G. Knepley 653*8edf6225SMatthew G. Knepley Input Parameter: 654*8edf6225SMatthew G. Knepley . prob - The PetscDS object 655*8edf6225SMatthew G. Knepley 656*8edf6225SMatthew G. Knepley Output Parameter: 657*8edf6225SMatthew G. Knepley . isHybrid - The flag 658*8edf6225SMatthew G. Knepley 659*8edf6225SMatthew G. Knepley Level: developer 660*8edf6225SMatthew G. Knepley 661*8edf6225SMatthew G. Knepley .seealso: PetscDSSetHybrid(), PetscDSCreate() 662*8edf6225SMatthew G. Knepley @*/ 663*8edf6225SMatthew G. Knepley PetscErrorCode PetscDSGetHybrid(PetscDS prob, PetscBool *isHybrid) 664*8edf6225SMatthew G. Knepley { 665*8edf6225SMatthew G. Knepley PetscFunctionBegin; 666*8edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 667*8edf6225SMatthew G. Knepley PetscValidPointer(isHybrid, 2); 668*8edf6225SMatthew G. Knepley *isHybrid = prob->isHybrid; 669*8edf6225SMatthew G. Knepley PetscFunctionReturn(0); 670*8edf6225SMatthew G. Knepley } 671*8edf6225SMatthew G. Knepley 672*8edf6225SMatthew G. Knepley /*@ 673*8edf6225SMatthew G. Knepley PetscDSSetHybrid - Set the flag for a hybrid (cohesive) cell 674*8edf6225SMatthew G. Knepley 675*8edf6225SMatthew G. Knepley Not collective 676*8edf6225SMatthew G. Knepley 677*8edf6225SMatthew G. Knepley Input Parameters: 678*8edf6225SMatthew G. Knepley + prob - The PetscDS object 679*8edf6225SMatthew G. Knepley - isHybrid - The flag 680*8edf6225SMatthew G. Knepley 681*8edf6225SMatthew G. Knepley Level: developer 682*8edf6225SMatthew G. Knepley 683*8edf6225SMatthew G. Knepley .seealso: PetscDSGetHybrid(), PetscDSCreate() 684*8edf6225SMatthew G. Knepley @*/ 685*8edf6225SMatthew G. Knepley PetscErrorCode PetscDSSetHybrid(PetscDS prob, PetscBool isHybrid) 686*8edf6225SMatthew G. Knepley { 687*8edf6225SMatthew G. Knepley PetscFunctionBegin; 688*8edf6225SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 689*8edf6225SMatthew G. Knepley prob->isHybrid = isHybrid; 690*8edf6225SMatthew G. Knepley PetscFunctionReturn(0); 691*8edf6225SMatthew G. Knepley } 692*8edf6225SMatthew G. Knepley 693*8edf6225SMatthew G. Knepley /*@ 694bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 695bc4ae4beSMatthew G. Knepley 696bc4ae4beSMatthew G. Knepley Not collective 697bc4ae4beSMatthew G. Knepley 698bc4ae4beSMatthew G. Knepley Input Parameter: 699bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 700bc4ae4beSMatthew G. Knepley 701bc4ae4beSMatthew G. Knepley Output Parameter: 702bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 703bc4ae4beSMatthew G. Knepley 704bc4ae4beSMatthew G. Knepley Level: beginner 705bc4ae4beSMatthew G. Knepley 706bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 707bc4ae4beSMatthew G. Knepley @*/ 7082764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 7092764a2aaSMatthew G. Knepley { 7102764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7112764a2aaSMatthew G. Knepley 7122764a2aaSMatthew G. Knepley PetscFunctionBegin; 7132764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7142764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7152764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 7162764a2aaSMatthew G. Knepley *dim = prob->totDim; 7172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7182764a2aaSMatthew G. Knepley } 7192764a2aaSMatthew G. Knepley 720bc4ae4beSMatthew G. Knepley /*@ 721bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 722bc4ae4beSMatthew G. Knepley 723bc4ae4beSMatthew G. Knepley Not collective 724bc4ae4beSMatthew G. Knepley 725bc4ae4beSMatthew G. Knepley Input Parameter: 726bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 727bc4ae4beSMatthew G. Knepley 728bc4ae4beSMatthew G. Knepley Output Parameter: 729bc4ae4beSMatthew G. Knepley . dim - The total number of components 730bc4ae4beSMatthew G. Knepley 731bc4ae4beSMatthew G. Knepley Level: beginner 732bc4ae4beSMatthew G. Knepley 733bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 734bc4ae4beSMatthew G. Knepley @*/ 7352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 7362764a2aaSMatthew G. Knepley { 7372764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7382764a2aaSMatthew G. Knepley 7392764a2aaSMatthew G. Knepley PetscFunctionBegin; 7402764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7412764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 7422764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 7432764a2aaSMatthew G. Knepley *Nc = prob->totComp; 7442764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7452764a2aaSMatthew G. Knepley } 7462764a2aaSMatthew G. Knepley 747bc4ae4beSMatthew G. Knepley /*@ 748bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 749bc4ae4beSMatthew G. Knepley 750bc4ae4beSMatthew G. Knepley Not collective 751bc4ae4beSMatthew G. Knepley 752bc4ae4beSMatthew G. Knepley Input Parameters: 753bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 754bc4ae4beSMatthew G. Knepley - f - The field number 755bc4ae4beSMatthew G. Knepley 756bc4ae4beSMatthew G. Knepley Output Parameter: 757bc4ae4beSMatthew G. Knepley . disc - The discretization object 758bc4ae4beSMatthew G. Knepley 759bc4ae4beSMatthew G. Knepley Level: beginner 760bc4ae4beSMatthew G. Knepley 761f744cafaSSander Arens .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 762bc4ae4beSMatthew G. Knepley @*/ 7632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7642764a2aaSMatthew G. Knepley { 7652764a2aaSMatthew G. Knepley PetscFunctionBegin; 7662764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7672764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7682764a2aaSMatthew 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); 7692764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 7702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7712764a2aaSMatthew G. Knepley } 7722764a2aaSMatthew G. Knepley 773bc4ae4beSMatthew G. Knepley /*@ 774bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 775bc4ae4beSMatthew G. Knepley 776bc4ae4beSMatthew G. Knepley Not collective 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley Input Parameters: 779bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 780bc4ae4beSMatthew G. Knepley . f - The field number 781bc4ae4beSMatthew G. Knepley - disc - The discretization object 782bc4ae4beSMatthew G. Knepley 783bc4ae4beSMatthew G. Knepley Level: beginner 784bc4ae4beSMatthew G. Knepley 785bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 786bc4ae4beSMatthew G. Knepley @*/ 7872764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7882764a2aaSMatthew G. Knepley { 7892764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7902764a2aaSMatthew G. Knepley 7912764a2aaSMatthew G. Knepley PetscFunctionBegin; 7922764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7932764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7942764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7952764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7962764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7972764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7982764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 799249df284SMatthew G. Knepley { 800249df284SMatthew G. Knepley PetscClassId id; 801249df284SMatthew G. Knepley 802249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 8031cf84007SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 8041cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_TRUE);CHKERRQ(ierr); 8051cf84007SMatthew G. Knepley ierr = PetscDSSetAdjacency(prob, f, PETSC_FALSE, PETSC_TRUE);CHKERRQ(ierr); 8061cf84007SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 8071cf84007SMatthew G. Knepley ierr = PetscDSSetImplicit(prob, f, PETSC_FALSE);CHKERRQ(ierr); 8081cf84007SMatthew G. Knepley ierr = PetscDSSetAdjacency(prob, f, PETSC_TRUE, PETSC_FALSE);CHKERRQ(ierr); 809a6cbbb48SMatthew G. Knepley } 810249df284SMatthew G. Knepley } 8112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8122764a2aaSMatthew G. Knepley } 8132764a2aaSMatthew G. Knepley 814bc4ae4beSMatthew G. Knepley /*@ 815bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 816bc4ae4beSMatthew G. Knepley 817bc4ae4beSMatthew G. Knepley Not collective 818bc4ae4beSMatthew G. Knepley 819bc4ae4beSMatthew G. Knepley Input Parameters: 820bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 821bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 822bc4ae4beSMatthew G. Knepley 823bc4ae4beSMatthew G. Knepley Level: beginner 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 826bc4ae4beSMatthew G. Knepley @*/ 8272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8282764a2aaSMatthew G. Knepley { 8292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8302764a2aaSMatthew G. Knepley 8312764a2aaSMatthew G. Knepley PetscFunctionBegin; 8322764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8332764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8342764a2aaSMatthew G. Knepley } 8352764a2aaSMatthew G. Knepley 836249df284SMatthew G. Knepley /*@ 837249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 838249df284SMatthew G. Knepley 839249df284SMatthew G. Knepley Not collective 840249df284SMatthew G. Knepley 841249df284SMatthew G. Knepley Input Parameters: 842249df284SMatthew G. Knepley + prob - The PetscDS object 843249df284SMatthew G. Knepley - f - The field number 844249df284SMatthew G. Knepley 845249df284SMatthew G. Knepley Output Parameter: 846249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 847249df284SMatthew G. Knepley 848249df284SMatthew G. Knepley Level: developer 849249df284SMatthew G. Knepley 850f744cafaSSander Arens .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 851249df284SMatthew G. Knepley @*/ 852249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 853249df284SMatthew G. Knepley { 854249df284SMatthew G. Knepley PetscFunctionBegin; 855249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 856249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 857249df284SMatthew 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); 858249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 859249df284SMatthew G. Knepley PetscFunctionReturn(0); 860249df284SMatthew G. Knepley } 861249df284SMatthew G. Knepley 862249df284SMatthew G. Knepley /*@ 863249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 864249df284SMatthew G. Knepley 865249df284SMatthew G. Knepley Not collective 866249df284SMatthew G. Knepley 867249df284SMatthew G. Knepley Input Parameters: 868249df284SMatthew G. Knepley + prob - The PetscDS object 869249df284SMatthew G. Knepley . f - The field number 870249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 871249df284SMatthew G. Knepley 872249df284SMatthew G. Knepley Level: developer 873249df284SMatthew G. Knepley 874f744cafaSSander Arens .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 875249df284SMatthew G. Knepley @*/ 876249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 877249df284SMatthew G. Knepley { 878249df284SMatthew G. Knepley PetscFunctionBegin; 879249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 880249df284SMatthew 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); 881249df284SMatthew G. Knepley prob->implicit[f] = implicit; 882249df284SMatthew G. Knepley PetscFunctionReturn(0); 883249df284SMatthew G. Knepley } 884249df284SMatthew G. Knepley 885a6cbbb48SMatthew G. Knepley /*@ 886a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 887a6cbbb48SMatthew G. Knepley 888a6cbbb48SMatthew G. Knepley Not collective 889a6cbbb48SMatthew G. Knepley 890a6cbbb48SMatthew G. Knepley Input Parameters: 891a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 892a6cbbb48SMatthew G. Knepley - f - The field number 893a6cbbb48SMatthew G. Knepley 894a6cbbb48SMatthew G. Knepley Output Parameter: 895a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 896a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 897a6cbbb48SMatthew G. Knepley 898a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 899a6cbbb48SMatthew G. Knepley 900a6cbbb48SMatthew G. Knepley Level: developer 901a6cbbb48SMatthew G. Knepley 902f744cafaSSander Arens .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 903a6cbbb48SMatthew G. Knepley @*/ 904a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 905a6cbbb48SMatthew G. Knepley { 906a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 907a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9081cf84007SMatthew G. Knepley if (useCone) PetscValidPointer(useCone, 3); 9091cf84007SMatthew G. Knepley if (useClosure) PetscValidPointer(useClosure, 4); 91006cc46feSMatthew G. Knepley if (f < 0) { 91106cc46feSMatthew G. Knepley if (useCone) *useCone = prob->defaultAdj[0]; 91206cc46feSMatthew G. Knepley if (useClosure) *useClosure = prob->defaultAdj[1]; 91306cc46feSMatthew G. Knepley } else { 91406cc46feSMatthew 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); 9151cf84007SMatthew G. Knepley if (useCone) *useCone = prob->adjacency[f*2+0]; 9161cf84007SMatthew G. Knepley if (useClosure) *useClosure = prob->adjacency[f*2+1]; 91706cc46feSMatthew G. Knepley } 918a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 919a6cbbb48SMatthew G. Knepley } 920a6cbbb48SMatthew G. Knepley 921a6cbbb48SMatthew G. Knepley /*@ 922a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 923a6cbbb48SMatthew G. Knepley 924a6cbbb48SMatthew G. Knepley Not collective 925a6cbbb48SMatthew G. Knepley 926a6cbbb48SMatthew G. Knepley Input Parameters: 927a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 928a6cbbb48SMatthew G. Knepley . f - The field number 929a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 930a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 931a6cbbb48SMatthew G. Knepley 932a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 933a6cbbb48SMatthew G. Knepley 934a6cbbb48SMatthew G. Knepley Level: developer 935a6cbbb48SMatthew G. Knepley 936f744cafaSSander Arens .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 937a6cbbb48SMatthew G. Knepley @*/ 938a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 939a6cbbb48SMatthew G. Knepley { 940a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 941a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 94206cc46feSMatthew G. Knepley if (f < 0) { 94306cc46feSMatthew G. Knepley prob->defaultAdj[0] = useCone; 94406cc46feSMatthew G. Knepley prob->defaultAdj[1] = useClosure; 94506cc46feSMatthew G. Knepley } else { 94606cc46feSMatthew 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); 947a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 948a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 94906cc46feSMatthew G. Knepley } 950a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 951a6cbbb48SMatthew G. Knepley } 952a6cbbb48SMatthew G. Knepley 9532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 95430b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 955194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 956194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 95797b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9582764a2aaSMatthew G. Knepley { 9592764a2aaSMatthew G. Knepley PetscFunctionBegin; 9602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9612764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9622764a2aaSMatthew 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); 9632764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9652764a2aaSMatthew G. Knepley } 9662764a2aaSMatthew G. Knepley 9672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 96830b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 969194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 970194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 97197b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar obj[])) 9722764a2aaSMatthew G. Knepley { 9732764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9742764a2aaSMatthew G. Knepley 9752764a2aaSMatthew G. Knepley PetscFunctionBegin; 9762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 977de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9782764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9792764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9802764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9822764a2aaSMatthew G. Knepley } 9832764a2aaSMatthew G. Knepley 984194d53e6SMatthew G. Knepley /*@C 985194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 986194d53e6SMatthew G. Knepley 987194d53e6SMatthew G. Knepley Not collective 988194d53e6SMatthew G. Knepley 989194d53e6SMatthew G. Knepley Input Parameters: 990194d53e6SMatthew G. Knepley + prob - The PetscDS 991194d53e6SMatthew G. Knepley - f - The test field number 992194d53e6SMatthew G. Knepley 993194d53e6SMatthew G. Knepley Output Parameters: 994194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 995194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 996194d53e6SMatthew G. Knepley 997194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew 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) 1000194d53e6SMatthew G. Knepley 1001194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1002194d53e6SMatthew G. Knepley 100330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1004194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1005194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 100630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1007194d53e6SMatthew G. Knepley 1008194d53e6SMatthew G. Knepley + dim - the spatial dimension 1009194d53e6SMatthew G. Knepley . Nf - the number of fields 1010194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1011194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1012194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1013194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1014194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1015194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1016194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1017194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1018194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1019194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1020194d53e6SMatthew G. Knepley . t - current time 1021194d53e6SMatthew G. Knepley . x - coordinates of the current point 102297b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 102397b6e6e8SMatthew G. Knepley . constants - constant parameters 1024194d53e6SMatthew G. Knepley - f0 - output values at the current point 1025194d53e6SMatthew G. Knepley 1026194d53e6SMatthew G. Knepley Level: intermediate 1027194d53e6SMatthew G. Knepley 1028194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1029194d53e6SMatthew G. Knepley @*/ 10302764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 103130b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1032194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1033194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 103497b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 103530b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1036194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1037194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 103897b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 10392764a2aaSMatthew G. Knepley { 10402764a2aaSMatthew G. Knepley PetscFunctionBegin; 10412764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10422764a2aaSMatthew 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); 10432764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10442764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10452764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10462764a2aaSMatthew G. Knepley } 10472764a2aaSMatthew G. Knepley 1048194d53e6SMatthew G. Knepley /*@C 1049194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1050194d53e6SMatthew G. Knepley 1051194d53e6SMatthew G. Knepley Not collective 1052194d53e6SMatthew G. Knepley 1053194d53e6SMatthew G. Knepley Input Parameters: 1054194d53e6SMatthew G. Knepley + prob - The PetscDS 1055194d53e6SMatthew G. Knepley . f - The test field number 1056194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1057194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1058194d53e6SMatthew G. Knepley 1059194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1060194d53e6SMatthew G. Knepley 1061194d53e6SMatthew 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) 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1064194d53e6SMatthew G. Knepley 106530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1066194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1067194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 106830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1069194d53e6SMatthew G. Knepley 1070194d53e6SMatthew G. Knepley + dim - the spatial dimension 1071194d53e6SMatthew G. Knepley . Nf - the number of fields 1072194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1073194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1074194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1075194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1076194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1077194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1078194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1079194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1080194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1081194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1082194d53e6SMatthew G. Knepley . t - current time 1083194d53e6SMatthew G. Knepley . x - coordinates of the current point 108497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 108597b6e6e8SMatthew G. Knepley . constants - constant parameters 1086194d53e6SMatthew G. Knepley - f0 - output values at the current point 1087194d53e6SMatthew G. Knepley 1088194d53e6SMatthew G. Knepley Level: intermediate 1089194d53e6SMatthew G. Knepley 1090194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1091194d53e6SMatthew G. Knepley @*/ 10922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 109330b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1094194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1095194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 109697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 109730b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1098194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1099194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 11012764a2aaSMatthew G. Knepley { 11022764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11032764a2aaSMatthew G. Knepley 11042764a2aaSMatthew G. Knepley PetscFunctionBegin; 11052764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1106f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1107f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11082764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11092764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11102764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11112764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11132764a2aaSMatthew G. Knepley } 11142764a2aaSMatthew G. Knepley 11153e75805dSMatthew G. Knepley /*@C 11163e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11173e75805dSMatthew G. Knepley 11183e75805dSMatthew G. Knepley Not collective 11193e75805dSMatthew G. Knepley 11203e75805dSMatthew G. Knepley Input Parameter: 11213e75805dSMatthew G. Knepley . prob - The PetscDS 11223e75805dSMatthew G. Knepley 11233e75805dSMatthew G. Knepley Output Parameter: 11243e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11253e75805dSMatthew G. Knepley 11263e75805dSMatthew G. Knepley Level: intermediate 11273e75805dSMatthew G. Knepley 11283e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11293e75805dSMatthew G. Knepley @*/ 11303e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11313e75805dSMatthew G. Knepley { 11323e75805dSMatthew G. Knepley PetscInt f, g, h; 11333e75805dSMatthew G. Knepley 11343e75805dSMatthew G. Knepley PetscFunctionBegin; 11353e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11363e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11373e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11383e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11393e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11403e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11413e75805dSMatthew G. Knepley } 11423e75805dSMatthew G. Knepley } 11433e75805dSMatthew G. Knepley } 11443e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11453e75805dSMatthew G. Knepley } 11463e75805dSMatthew G. Knepley 1147194d53e6SMatthew G. Knepley /*@C 1148194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1149194d53e6SMatthew G. Knepley 1150194d53e6SMatthew G. Knepley Not collective 1151194d53e6SMatthew G. Knepley 1152194d53e6SMatthew G. Knepley Input Parameters: 1153194d53e6SMatthew G. Knepley + prob - The PetscDS 1154194d53e6SMatthew G. Knepley . f - The test field number 1155194d53e6SMatthew G. Knepley - g - The field number 1156194d53e6SMatthew G. Knepley 1157194d53e6SMatthew G. Knepley Output Parameters: 1158194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1159194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1160194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1161194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1162194d53e6SMatthew G. Knepley 1163194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1164194d53e6SMatthew G. Knepley 1165194d53e6SMatthew 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 1166194d53e6SMatthew G. Knepley 1167194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1168194d53e6SMatthew G. Knepley 116930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1170194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1171194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 117230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1173194d53e6SMatthew G. Knepley 1174194d53e6SMatthew G. Knepley + dim - the spatial dimension 1175194d53e6SMatthew G. Knepley . Nf - the number of fields 1176194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1177194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1178194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1179194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1180194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1181194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1182194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1183194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1184194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1185194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1186194d53e6SMatthew G. Knepley . t - current time 11872aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1188194d53e6SMatthew G. Knepley . x - coordinates of the current point 118997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 119097b6e6e8SMatthew G. Knepley . constants - constant parameters 1191194d53e6SMatthew G. Knepley - g0 - output values at the current point 1192194d53e6SMatthew G. Knepley 1193194d53e6SMatthew G. Knepley Level: intermediate 1194194d53e6SMatthew G. Knepley 1195194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1196194d53e6SMatthew G. Knepley @*/ 11972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 119830b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1199194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1200194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 120230b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1203194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1204194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 120630b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1207194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1208194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 120997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 121030b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1211194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1212194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12142764a2aaSMatthew G. Knepley { 12152764a2aaSMatthew G. Knepley PetscFunctionBegin; 12162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12172764a2aaSMatthew 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); 12182764a2aaSMatthew 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); 12192764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12202764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12212764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12222764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12242764a2aaSMatthew G. Knepley } 12252764a2aaSMatthew G. Knepley 1226194d53e6SMatthew G. Knepley /*@C 1227194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1228194d53e6SMatthew G. Knepley 1229194d53e6SMatthew G. Knepley Not collective 1230194d53e6SMatthew G. Knepley 1231194d53e6SMatthew G. Knepley Input Parameters: 1232194d53e6SMatthew G. Knepley + prob - The PetscDS 1233194d53e6SMatthew G. Knepley . f - The test field number 1234194d53e6SMatthew G. Knepley . g - The field number 1235194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1236194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1237194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1238194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1239194d53e6SMatthew G. Knepley 1240194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1241194d53e6SMatthew G. Knepley 1242194d53e6SMatthew 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 1243194d53e6SMatthew G. Knepley 1244194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1245194d53e6SMatthew G. Knepley 124630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1247194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1248194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 124930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1250194d53e6SMatthew G. Knepley 1251194d53e6SMatthew G. Knepley + dim - the spatial dimension 1252194d53e6SMatthew G. Knepley . Nf - the number of fields 1253194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1254194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1255194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1256194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1257194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1258194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1259194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1260194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1261194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1262194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1263194d53e6SMatthew G. Knepley . t - current time 12642aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1265194d53e6SMatthew G. Knepley . x - coordinates of the current point 126697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 126797b6e6e8SMatthew G. Knepley . constants - constant parameters 1268194d53e6SMatthew G. Knepley - g0 - output values at the current point 1269194d53e6SMatthew G. Knepley 1270194d53e6SMatthew G. Knepley Level: intermediate 1271194d53e6SMatthew G. Knepley 1272194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1273194d53e6SMatthew G. Knepley @*/ 12742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 127530b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1276194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1277194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 127930b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1280194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1281194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 128330b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1284194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1285194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 128730b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1288194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1289194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 12912764a2aaSMatthew G. Knepley { 12922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12932764a2aaSMatthew G. Knepley 12942764a2aaSMatthew G. Knepley PetscFunctionBegin; 12952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12962764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12972764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12982764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12992764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13002764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13012764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13022764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13032764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13042764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13052764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13062764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13072764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13082764a2aaSMatthew G. Knepley } 13092764a2aaSMatthew G. Knepley 1310475e0ac9SMatthew G. Knepley /*@C 131155c1f793SMatthew G. Knepley PetscDSUseJacobianPreconditioner - Whether to construct a Jacobian preconditioner 131255c1f793SMatthew G. Knepley 131355c1f793SMatthew G. Knepley Not collective 131455c1f793SMatthew G. Knepley 131555c1f793SMatthew G. Knepley Input Parameters: 131655c1f793SMatthew G. Knepley + prob - The PetscDS 131755c1f793SMatthew G. Knepley - useJacPre - flag that enables construction of a Jacobian preconditioner 131855c1f793SMatthew G. Knepley 131955c1f793SMatthew G. Knepley Level: intermediate 132055c1f793SMatthew G. Knepley 132155c1f793SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 132255c1f793SMatthew G. Knepley @*/ 132355c1f793SMatthew G. Knepley PetscErrorCode PetscDSUseJacobianPreconditioner(PetscDS prob, PetscBool useJacPre) 132455c1f793SMatthew G. Knepley { 132555c1f793SMatthew G. Knepley PetscFunctionBegin; 132655c1f793SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 132755c1f793SMatthew G. Knepley prob->useJacPre = useJacPre; 132855c1f793SMatthew G. Knepley PetscFunctionReturn(0); 132955c1f793SMatthew G. Knepley } 133055c1f793SMatthew G. Knepley 133155c1f793SMatthew G. Knepley /*@C 1332475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1333475e0ac9SMatthew G. Knepley 1334475e0ac9SMatthew G. Knepley Not collective 1335475e0ac9SMatthew G. Knepley 1336475e0ac9SMatthew G. Knepley Input Parameter: 1337475e0ac9SMatthew G. Knepley . prob - The PetscDS 1338475e0ac9SMatthew G. Knepley 1339475e0ac9SMatthew G. Knepley Output Parameter: 1340475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1341475e0ac9SMatthew G. Knepley 1342475e0ac9SMatthew G. Knepley Level: intermediate 1343475e0ac9SMatthew G. Knepley 1344475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1345475e0ac9SMatthew G. Knepley @*/ 1346475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1347475e0ac9SMatthew G. Knepley { 1348475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1349475e0ac9SMatthew G. Knepley 1350475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1351475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1352475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 135355c1f793SMatthew G. Knepley if (!prob->useJacPre) PetscFunctionReturn(0); 1354475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1355475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1356475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1357475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1358475e0ac9SMatthew G. Knepley } 1359475e0ac9SMatthew G. Knepley } 1360475e0ac9SMatthew G. Knepley } 1361475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1362475e0ac9SMatthew G. Knepley } 1363475e0ac9SMatthew G. Knepley 1364475e0ac9SMatthew G. Knepley /*@C 1365475e0ac9SMatthew 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. 1366475e0ac9SMatthew G. Knepley 1367475e0ac9SMatthew G. Knepley Not collective 1368475e0ac9SMatthew G. Knepley 1369475e0ac9SMatthew G. Knepley Input Parameters: 1370475e0ac9SMatthew G. Knepley + prob - The PetscDS 1371475e0ac9SMatthew G. Knepley . f - The test field number 1372475e0ac9SMatthew G. Knepley - g - The field number 1373475e0ac9SMatthew G. Knepley 1374475e0ac9SMatthew G. Knepley Output Parameters: 1375475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1376475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1377475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1378475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1379475e0ac9SMatthew G. Knepley 1380475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1381475e0ac9SMatthew G. Knepley 1382475e0ac9SMatthew 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 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1385475e0ac9SMatthew G. Knepley 1386475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1387475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1388475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1389475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1390475e0ac9SMatthew G. Knepley 1391475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1392475e0ac9SMatthew G. Knepley . Nf - the number of fields 1393475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1394475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1395475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1396475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1397475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1398475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1399475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1400475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1401475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1402475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1403475e0ac9SMatthew G. Knepley . t - current time 1404475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1405475e0ac9SMatthew G. Knepley . x - coordinates of the current point 140697b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 140797b6e6e8SMatthew G. Knepley . constants - constant parameters 1408475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1409475e0ac9SMatthew G. Knepley 1410475e0ac9SMatthew G. Knepley Level: intermediate 1411475e0ac9SMatthew G. Knepley 1412475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1413475e0ac9SMatthew G. Knepley @*/ 1414475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1415475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1416475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1417475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 141897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1419475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1420475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1421475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1423475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1424475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1425475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 142697b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1427475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1428475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1429475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 143097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1431475e0ac9SMatthew G. Knepley { 1432475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1433475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1434475e0ac9SMatthew 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); 1435475e0ac9SMatthew 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); 1436475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1437475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1438475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1439475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1440475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1441475e0ac9SMatthew G. Knepley } 1442475e0ac9SMatthew G. Knepley 1443475e0ac9SMatthew G. Knepley /*@C 1444475e0ac9SMatthew 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. 1445475e0ac9SMatthew G. Knepley 1446475e0ac9SMatthew G. Knepley Not collective 1447475e0ac9SMatthew G. Knepley 1448475e0ac9SMatthew G. Knepley Input Parameters: 1449475e0ac9SMatthew G. Knepley + prob - The PetscDS 1450475e0ac9SMatthew G. Knepley . f - The test field number 1451475e0ac9SMatthew G. Knepley . g - The field number 1452475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1453475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1454475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1455475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1456475e0ac9SMatthew G. Knepley 1457475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1458475e0ac9SMatthew G. Knepley 1459475e0ac9SMatthew 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 1460475e0ac9SMatthew G. Knepley 1461475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1462475e0ac9SMatthew G. Knepley 1463475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1464475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1465475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1466475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1467475e0ac9SMatthew G. Knepley 1468475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1469475e0ac9SMatthew G. Knepley . Nf - the number of fields 1470475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1471475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1472475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1473475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1474475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1475475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1476475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1477475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1478475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1479475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1480475e0ac9SMatthew G. Knepley . t - current time 1481475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1482475e0ac9SMatthew G. Knepley . x - coordinates of the current point 148397b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 148497b6e6e8SMatthew G. Knepley . constants - constant parameters 1485475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1486475e0ac9SMatthew G. Knepley 1487475e0ac9SMatthew G. Knepley Level: intermediate 1488475e0ac9SMatthew G. Knepley 1489475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1490475e0ac9SMatthew G. Knepley @*/ 1491475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1492475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1493475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1494475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1496475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1497475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1498475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 149997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1500475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1501475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1502475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1504475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1505475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1506475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 150797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1508475e0ac9SMatthew G. Knepley { 1509475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1510475e0ac9SMatthew G. Knepley 1511475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1512475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1513475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1514475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1515475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1516475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1517475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1518475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1519475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1520475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1521475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1522475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1523475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1524475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1525475e0ac9SMatthew G. Knepley } 1526475e0ac9SMatthew G. Knepley 1527b7e05686SMatthew G. Knepley /*@C 1528b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1529b7e05686SMatthew G. Knepley 1530b7e05686SMatthew G. Knepley Not collective 1531b7e05686SMatthew G. Knepley 1532b7e05686SMatthew G. Knepley Input Parameter: 1533b7e05686SMatthew G. Knepley . prob - The PetscDS 1534b7e05686SMatthew G. Knepley 1535b7e05686SMatthew G. Knepley Output Parameter: 1536b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1537b7e05686SMatthew G. Knepley 1538b7e05686SMatthew G. Knepley Level: intermediate 1539b7e05686SMatthew G. Knepley 1540b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1541b7e05686SMatthew G. Knepley @*/ 1542b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1543b7e05686SMatthew G. Knepley { 1544b7e05686SMatthew G. Knepley PetscInt f, g, h; 1545b7e05686SMatthew G. Knepley 1546b7e05686SMatthew G. Knepley PetscFunctionBegin; 1547b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1548b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1549b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1550b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1551b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1552b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1553b7e05686SMatthew G. Knepley } 1554b7e05686SMatthew G. Knepley } 1555b7e05686SMatthew G. Knepley } 1556b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1557b7e05686SMatthew G. Knepley } 1558b7e05686SMatthew G. Knepley 1559b7e05686SMatthew G. Knepley /*@C 1560b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1561b7e05686SMatthew G. Knepley 1562b7e05686SMatthew G. Knepley Not collective 1563b7e05686SMatthew G. Knepley 1564b7e05686SMatthew G. Knepley Input Parameters: 1565b7e05686SMatthew G. Knepley + prob - The PetscDS 1566b7e05686SMatthew G. Knepley . f - The test field number 1567b7e05686SMatthew G. Knepley - g - The field number 1568b7e05686SMatthew G. Knepley 1569b7e05686SMatthew G. Knepley Output Parameters: 1570b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1571b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1572b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1573b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1574b7e05686SMatthew G. Knepley 1575b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1576b7e05686SMatthew G. Knepley 1577b7e05686SMatthew 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 1578b7e05686SMatthew G. Knepley 1579b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1580b7e05686SMatthew G. Knepley 1581b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1582b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1583b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1584b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1585b7e05686SMatthew G. Knepley 1586b7e05686SMatthew G. Knepley + dim - the spatial dimension 1587b7e05686SMatthew G. Knepley . Nf - the number of fields 1588b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1589b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1590b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1591b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1592b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1593b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1594b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1595b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1596b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1597b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1598b7e05686SMatthew G. Knepley . t - current time 1599b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1600b7e05686SMatthew G. Knepley . x - coordinates of the current point 160197b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 160297b6e6e8SMatthew G. Knepley . constants - constant parameters 1603b7e05686SMatthew G. Knepley - g0 - output values at the current point 1604b7e05686SMatthew G. Knepley 1605b7e05686SMatthew G. Knepley Level: intermediate 1606b7e05686SMatthew G. Knepley 1607b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1608b7e05686SMatthew G. Knepley @*/ 1609b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1610b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1611b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1612b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 161397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1614b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1615b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1616b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 161797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1618b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1619b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1620b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1622b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1623b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1624b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 162597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1626b7e05686SMatthew G. Knepley { 1627b7e05686SMatthew G. Knepley PetscFunctionBegin; 1628b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1629b7e05686SMatthew 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); 1630b7e05686SMatthew 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); 1631b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1632b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1633b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1634b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1635b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1636b7e05686SMatthew G. Knepley } 1637b7e05686SMatthew G. Knepley 1638b7e05686SMatthew G. Knepley /*@C 1639b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1640b7e05686SMatthew G. Knepley 1641b7e05686SMatthew G. Knepley Not collective 1642b7e05686SMatthew G. Knepley 1643b7e05686SMatthew G. Knepley Input Parameters: 1644b7e05686SMatthew G. Knepley + prob - The PetscDS 1645b7e05686SMatthew G. Knepley . f - The test field number 1646b7e05686SMatthew G. Knepley . g - The field number 1647b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1648b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1649b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1650b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1651b7e05686SMatthew G. Knepley 1652b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1653b7e05686SMatthew G. Knepley 1654b7e05686SMatthew 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 1655b7e05686SMatthew G. Knepley 1656b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1657b7e05686SMatthew G. Knepley 1658b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1659b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1660b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1661b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1662b7e05686SMatthew G. Knepley 1663b7e05686SMatthew G. Knepley + dim - the spatial dimension 1664b7e05686SMatthew G. Knepley . Nf - the number of fields 1665b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1666b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1667b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1668b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1669b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1670b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1671b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1672b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1673b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1674b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1675b7e05686SMatthew G. Knepley . t - current time 1676b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1677b7e05686SMatthew G. Knepley . x - coordinates of the current point 167897b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 167997b6e6e8SMatthew G. Knepley . constants - constant parameters 1680b7e05686SMatthew G. Knepley - g0 - output values at the current point 1681b7e05686SMatthew G. Knepley 1682b7e05686SMatthew G. Knepley Level: intermediate 1683b7e05686SMatthew G. Knepley 1684b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1685b7e05686SMatthew G. Knepley @*/ 1686b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1687b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1688b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1689b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 169097b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 1691b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1692b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1693b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 169497b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 1695b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1696b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1697b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 169897b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 1699b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1700b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1701b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 170297b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 1703b7e05686SMatthew G. Knepley { 1704b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1705b7e05686SMatthew G. Knepley 1706b7e05686SMatthew G. Knepley PetscFunctionBegin; 1707b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1708b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1709b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1710b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1711b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1712b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1713b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1714b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1715b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1716b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1717b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1718b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1719b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1720b7e05686SMatthew G. Knepley } 1721b7e05686SMatthew G. Knepley 17220c2f2876SMatthew G. Knepley /*@C 17230c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17240c2f2876SMatthew G. Knepley 17250c2f2876SMatthew G. Knepley Not collective 17260c2f2876SMatthew G. Knepley 17270c2f2876SMatthew G. Knepley Input Arguments: 17280c2f2876SMatthew G. Knepley + prob - The PetscDS object 17290c2f2876SMatthew G. Knepley - f - The field number 17300c2f2876SMatthew G. Knepley 17310c2f2876SMatthew G. Knepley Output Argument: 17320c2f2876SMatthew G. Knepley . r - Riemann solver 17330c2f2876SMatthew G. Knepley 17340c2f2876SMatthew G. Knepley Calling sequence for r: 17350c2f2876SMatthew G. Knepley 17365db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17370c2f2876SMatthew G. Knepley 17385db36cf9SMatthew G. Knepley + dim - The spatial dimension 17395db36cf9SMatthew G. Knepley . Nf - The number of fields 17405db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17410c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17420c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17430c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17440c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 174597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 174697b6e6e8SMatthew G. Knepley . constants - constant parameters 17470c2f2876SMatthew G. Knepley - ctx - optional user context 17480c2f2876SMatthew G. Knepley 17490c2f2876SMatthew G. Knepley Level: intermediate 17500c2f2876SMatthew G. Knepley 17510c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17520c2f2876SMatthew G. Knepley @*/ 17530c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 175497b6e6e8SMatthew 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)) 17550c2f2876SMatthew G. Knepley { 17560c2f2876SMatthew G. Knepley PetscFunctionBegin; 17570c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17580c2f2876SMatthew 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); 17590c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17600c2f2876SMatthew G. Knepley *r = prob->r[f]; 17610c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17620c2f2876SMatthew G. Knepley } 17630c2f2876SMatthew G. Knepley 17640c2f2876SMatthew G. Knepley /*@C 17650c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17660c2f2876SMatthew G. Knepley 17670c2f2876SMatthew G. Knepley Not collective 17680c2f2876SMatthew G. Knepley 17690c2f2876SMatthew G. Knepley Input Arguments: 17700c2f2876SMatthew G. Knepley + prob - The PetscDS object 17710c2f2876SMatthew G. Knepley . f - The field number 17720c2f2876SMatthew G. Knepley - r - Riemann solver 17730c2f2876SMatthew G. Knepley 17740c2f2876SMatthew G. Knepley Calling sequence for r: 17750c2f2876SMatthew G. Knepley 17765db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17770c2f2876SMatthew G. Knepley 17785db36cf9SMatthew G. Knepley + dim - The spatial dimension 17795db36cf9SMatthew G. Knepley . Nf - The number of fields 17805db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17810c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17820c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17830c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17840c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 178597b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 178697b6e6e8SMatthew G. Knepley . constants - constant parameters 17870c2f2876SMatthew G. Knepley - ctx - optional user context 17880c2f2876SMatthew G. Knepley 17890c2f2876SMatthew G. Knepley Level: intermediate 17900c2f2876SMatthew G. Knepley 17910c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17920c2f2876SMatthew G. Knepley @*/ 17930c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 179497b6e6e8SMatthew 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)) 17950c2f2876SMatthew G. Knepley { 17960c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17970c2f2876SMatthew G. Knepley 17980c2f2876SMatthew G. Knepley PetscFunctionBegin; 17990c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1800de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 18010c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18020c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18030c2f2876SMatthew G. Knepley prob->r[f] = r; 18040c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18050c2f2876SMatthew G. Knepley } 18060c2f2876SMatthew G. Knepley 180732d2bbc9SMatthew G. Knepley /*@C 180832d2bbc9SMatthew G. Knepley PetscDSGetUpdate - Get the pointwise update function for a given field 180932d2bbc9SMatthew G. Knepley 181032d2bbc9SMatthew G. Knepley Not collective 181132d2bbc9SMatthew G. Knepley 181232d2bbc9SMatthew G. Knepley Input Parameters: 181332d2bbc9SMatthew G. Knepley + prob - The PetscDS 181432d2bbc9SMatthew G. Knepley - f - The field number 181532d2bbc9SMatthew G. Knepley 181632d2bbc9SMatthew G. Knepley Output Parameters: 181732d2bbc9SMatthew G. Knepley + update - update function 181832d2bbc9SMatthew G. Knepley 181932d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 182032d2bbc9SMatthew G. Knepley 182132d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 182232d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 182332d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182432d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 182532d2bbc9SMatthew G. Knepley 182632d2bbc9SMatthew G. Knepley + dim - the spatial dimension 182732d2bbc9SMatthew G. Knepley . Nf - the number of fields 182832d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 182932d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 183032d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 183132d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 183232d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 183332d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 183432d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 183532d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 183632d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 183732d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 183832d2bbc9SMatthew G. Knepley . t - current time 183932d2bbc9SMatthew G. Knepley . x - coordinates of the current point 184032d2bbc9SMatthew G. Knepley - uNew - new value for field at the current point 184132d2bbc9SMatthew G. Knepley 184232d2bbc9SMatthew G. Knepley Level: intermediate 184332d2bbc9SMatthew G. Knepley 184432d2bbc9SMatthew G. Knepley .seealso: PetscDSSetUpdate(), PetscDSSetResidual() 184532d2bbc9SMatthew G. Knepley @*/ 184632d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSGetUpdate(PetscDS prob, PetscInt f, 184732d2bbc9SMatthew G. Knepley void (**update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 184832d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 184932d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 18503fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 185132d2bbc9SMatthew G. Knepley { 185232d2bbc9SMatthew G. Knepley PetscFunctionBegin; 185332d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 185432d2bbc9SMatthew 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); 185532d2bbc9SMatthew G. Knepley if (update) {PetscValidPointer(update, 3); *update = prob->update[f];} 185632d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 185732d2bbc9SMatthew G. Knepley } 185832d2bbc9SMatthew G. Knepley 185932d2bbc9SMatthew G. Knepley /*@C 18603fa77dffSMatthew G. Knepley PetscDSSetUpdate - Set the pointwise update function for a given field 186132d2bbc9SMatthew G. Knepley 186232d2bbc9SMatthew G. Knepley Not collective 186332d2bbc9SMatthew G. Knepley 186432d2bbc9SMatthew G. Knepley Input Parameters: 186532d2bbc9SMatthew G. Knepley + prob - The PetscDS 186632d2bbc9SMatthew G. Knepley . f - The field number 186732d2bbc9SMatthew G. Knepley - update - update function 186832d2bbc9SMatthew G. Knepley 186932d2bbc9SMatthew G. Knepley Note: The calling sequence for the callback update is given by: 187032d2bbc9SMatthew G. Knepley 187132d2bbc9SMatthew G. Knepley $ update(PetscInt dim, PetscInt Nf, PetscInt NfAux, 187232d2bbc9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 187332d2bbc9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187432d2bbc9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar uNew[]) 187532d2bbc9SMatthew G. Knepley 187632d2bbc9SMatthew G. Knepley + dim - the spatial dimension 187732d2bbc9SMatthew G. Knepley . Nf - the number of fields 187832d2bbc9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 187932d2bbc9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 188032d2bbc9SMatthew G. Knepley . u - each field evaluated at the current point 188132d2bbc9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 188232d2bbc9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 188332d2bbc9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 188432d2bbc9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 188532d2bbc9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 188632d2bbc9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 188732d2bbc9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 188832d2bbc9SMatthew G. Knepley . t - current time 188932d2bbc9SMatthew G. Knepley . x - coordinates of the current point 189032d2bbc9SMatthew G. Knepley - uNew - new field values at the current point 189132d2bbc9SMatthew G. Knepley 189232d2bbc9SMatthew G. Knepley Level: intermediate 189332d2bbc9SMatthew G. Knepley 189432d2bbc9SMatthew G. Knepley .seealso: PetscDSGetResidual() 189532d2bbc9SMatthew G. Knepley @*/ 189632d2bbc9SMatthew G. Knepley PetscErrorCode PetscDSSetUpdate(PetscDS prob, PetscInt f, 189732d2bbc9SMatthew G. Knepley void (*update)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 189832d2bbc9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 189932d2bbc9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19003fa77dffSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uNew[])) 190132d2bbc9SMatthew G. Knepley { 190232d2bbc9SMatthew G. Knepley PetscErrorCode ierr; 190332d2bbc9SMatthew G. Knepley 190432d2bbc9SMatthew G. Knepley PetscFunctionBegin; 190532d2bbc9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 190632d2bbc9SMatthew G. Knepley if (update) PetscValidFunction(update, 3); 190732d2bbc9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 190832d2bbc9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 190932d2bbc9SMatthew G. Knepley prob->update[f] = update; 191032d2bbc9SMatthew G. Knepley PetscFunctionReturn(0); 191132d2bbc9SMatthew G. Knepley } 191232d2bbc9SMatthew G. Knepley 19130c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 19140c2f2876SMatthew G. Knepley { 19150c2f2876SMatthew G. Knepley PetscFunctionBegin; 19160c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19170c2f2876SMatthew 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); 19180c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 19190c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 19200c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19210c2f2876SMatthew G. Knepley } 19220c2f2876SMatthew G. Knepley 19230c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 19240c2f2876SMatthew G. Knepley { 19250c2f2876SMatthew G. Knepley PetscErrorCode ierr; 19260c2f2876SMatthew G. Knepley 19270c2f2876SMatthew G. Knepley PetscFunctionBegin; 19280c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19290c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19300c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19310c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 19320c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 19330c2f2876SMatthew G. Knepley } 19340c2f2876SMatthew G. Knepley 1935194d53e6SMatthew G. Knepley /*@C 1936194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1937194d53e6SMatthew G. Knepley 1938194d53e6SMatthew G. Knepley Not collective 1939194d53e6SMatthew G. Knepley 1940194d53e6SMatthew G. Knepley Input Parameters: 1941194d53e6SMatthew G. Knepley + prob - The PetscDS 1942194d53e6SMatthew G. Knepley - f - The test field number 1943194d53e6SMatthew G. Knepley 1944194d53e6SMatthew G. Knepley Output Parameters: 1945194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1946194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1947194d53e6SMatthew G. Knepley 1948194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1949194d53e6SMatthew G. Knepley 1950194d53e6SMatthew 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 1951194d53e6SMatthew G. Knepley 1952194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1953194d53e6SMatthew G. Knepley 195430b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1955194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1956194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 195730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1958194d53e6SMatthew G. Knepley 1959194d53e6SMatthew G. Knepley + dim - the spatial dimension 1960194d53e6SMatthew G. Knepley . Nf - the number of fields 1961194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1962194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1963194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1964194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1965194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1966194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1967194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1968194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1969194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1970194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1971194d53e6SMatthew G. Knepley . t - current time 1972194d53e6SMatthew G. Knepley . x - coordinates of the current point 1973194d53e6SMatthew G. Knepley . n - unit normal at the current point 197497b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 197597b6e6e8SMatthew G. Knepley . constants - constant parameters 1976194d53e6SMatthew G. Knepley - f0 - output values at the current point 1977194d53e6SMatthew G. Knepley 1978194d53e6SMatthew G. Knepley Level: intermediate 1979194d53e6SMatthew G. Knepley 1980194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1981194d53e6SMatthew G. Knepley @*/ 19822764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 198330b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1984194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1985194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198697b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 198730b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1988194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1989194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 199097b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 19912764a2aaSMatthew G. Knepley { 19922764a2aaSMatthew G. Knepley PetscFunctionBegin; 19932764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19942764a2aaSMatthew 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); 19952764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 19962764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 19972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19982764a2aaSMatthew G. Knepley } 19992764a2aaSMatthew G. Knepley 2000194d53e6SMatthew G. Knepley /*@C 2001194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 2002194d53e6SMatthew G. Knepley 2003194d53e6SMatthew G. Knepley Not collective 2004194d53e6SMatthew G. Knepley 2005194d53e6SMatthew G. Knepley Input Parameters: 2006194d53e6SMatthew G. Knepley + prob - The PetscDS 2007194d53e6SMatthew G. Knepley . f - The test field number 2008194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 2009194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 2010194d53e6SMatthew G. Knepley 2011194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2012194d53e6SMatthew G. Knepley 2013194d53e6SMatthew 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 2014194d53e6SMatthew G. Knepley 2015194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 2016194d53e6SMatthew G. Knepley 201730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2018194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2019194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 202030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 2021194d53e6SMatthew G. Knepley 2022194d53e6SMatthew G. Knepley + dim - the spatial dimension 2023194d53e6SMatthew G. Knepley . Nf - the number of fields 2024194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2025194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2026194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2027194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2028194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2029194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2030194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2031194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2032194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2033194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2034194d53e6SMatthew G. Knepley . t - current time 2035194d53e6SMatthew G. Knepley . x - coordinates of the current point 2036194d53e6SMatthew G. Knepley . n - unit normal at the current point 203797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 203897b6e6e8SMatthew G. Knepley . constants - constant parameters 2039194d53e6SMatthew G. Knepley - f0 - output values at the current point 2040194d53e6SMatthew G. Knepley 2041194d53e6SMatthew G. Knepley Level: intermediate 2042194d53e6SMatthew G. Knepley 2043194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 2044194d53e6SMatthew G. Knepley @*/ 20452764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 204630b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2047194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2048194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 204997b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[]), 205030b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2051194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2052194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 205397b6e6e8SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])) 20542764a2aaSMatthew G. Knepley { 20552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20562764a2aaSMatthew G. Knepley 20572764a2aaSMatthew G. Knepley PetscFunctionBegin; 20582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20592764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20602764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 20612764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 20622764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 20632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20642764a2aaSMatthew G. Knepley } 20652764a2aaSMatthew G. Knepley 2066194d53e6SMatthew G. Knepley /*@C 2067194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 2068194d53e6SMatthew G. Knepley 2069194d53e6SMatthew G. Knepley Not collective 2070194d53e6SMatthew G. Knepley 2071194d53e6SMatthew G. Knepley Input Parameters: 2072194d53e6SMatthew G. Knepley + prob - The PetscDS 2073194d53e6SMatthew G. Knepley . f - The test field number 2074194d53e6SMatthew G. Knepley - g - The field number 2075194d53e6SMatthew G. Knepley 2076194d53e6SMatthew G. Knepley Output Parameters: 2077194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 2078194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2079194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2080194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2081194d53e6SMatthew G. Knepley 2082194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2083194d53e6SMatthew G. Knepley 2084194d53e6SMatthew 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 2085194d53e6SMatthew G. Knepley 2086194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2087194d53e6SMatthew G. Knepley 208830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2089194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2090194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 209130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2092194d53e6SMatthew G. Knepley 2093194d53e6SMatthew G. Knepley + dim - the spatial dimension 2094194d53e6SMatthew G. Knepley . Nf - the number of fields 2095194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2096194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2097194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2098194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2099194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2100194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2101194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2102194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2103194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2104194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2105194d53e6SMatthew G. Knepley . t - current time 21062aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2107194d53e6SMatthew G. Knepley . x - coordinates of the current point 2108194d53e6SMatthew G. Knepley . n - normal at the current point 210997b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 211097b6e6e8SMatthew G. Knepley . constants - constant parameters 2111194d53e6SMatthew G. Knepley - g0 - output values at the current point 2112194d53e6SMatthew G. Knepley 2113194d53e6SMatthew G. Knepley Level: intermediate 2114194d53e6SMatthew G. Knepley 2115194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2116194d53e6SMatthew G. Knepley @*/ 21172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 211830b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2119194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2120194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 212197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 212230b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2123194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2124194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 212597b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 212630b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2127194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2128194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 212997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 213030b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2131194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2132194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 213397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 21342764a2aaSMatthew G. Knepley { 21352764a2aaSMatthew G. Knepley PetscFunctionBegin; 21362764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21372764a2aaSMatthew 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); 21382764a2aaSMatthew 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); 21392764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 21402764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 21412764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 21422764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 21432764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21442764a2aaSMatthew G. Knepley } 21452764a2aaSMatthew G. Knepley 2146194d53e6SMatthew G. Knepley /*@C 2147194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2148194d53e6SMatthew G. Knepley 2149194d53e6SMatthew G. Knepley Not collective 2150194d53e6SMatthew G. Knepley 2151194d53e6SMatthew G. Knepley Input Parameters: 2152194d53e6SMatthew G. Knepley + prob - The PetscDS 2153194d53e6SMatthew G. Knepley . f - The test field number 2154194d53e6SMatthew G. Knepley . g - The field number 2155194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2156194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2157194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2158194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2159194d53e6SMatthew G. Knepley 2160194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2161194d53e6SMatthew G. Knepley 2162194d53e6SMatthew 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 2163194d53e6SMatthew G. Knepley 2164194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2165194d53e6SMatthew G. Knepley 216630b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2167194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2168194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 216930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2170194d53e6SMatthew G. Knepley 2171194d53e6SMatthew G. Knepley + dim - the spatial dimension 2172194d53e6SMatthew G. Knepley . Nf - the number of fields 2173194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2174194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2175194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2176194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2177194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2178194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2179194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2180194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2181194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2182194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2183194d53e6SMatthew G. Knepley . t - current time 21842aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2185194d53e6SMatthew G. Knepley . x - coordinates of the current point 2186194d53e6SMatthew G. Knepley . n - normal at the current point 218797b6e6e8SMatthew G. Knepley . numConstants - number of constant parameters 218897b6e6e8SMatthew G. Knepley . constants - constant parameters 2189194d53e6SMatthew G. Knepley - g0 - output values at the current point 2190194d53e6SMatthew G. Knepley 2191194d53e6SMatthew G. Knepley Level: intermediate 2192194d53e6SMatthew G. Knepley 2193194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2194194d53e6SMatthew G. Knepley @*/ 21952764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 219630b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2197194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2198194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 219997b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[]), 220030b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2201194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2202194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220397b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[]), 220430b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2205194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2206194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 220797b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[]), 220830b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2209194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2210194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 221197b6e6e8SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])) 22122764a2aaSMatthew G. Knepley { 22132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22142764a2aaSMatthew G. Knepley 22152764a2aaSMatthew G. Knepley PetscFunctionBegin; 22162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22172764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 22182764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 22192764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 22202764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 22212764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 22222764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 22232764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 22242764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 22252764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 22262764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 22272764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 22282764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22292764a2aaSMatthew G. Knepley } 22302764a2aaSMatthew G. Knepley 22310d3e9b51SMatthew G. Knepley /*@C 2232c371a6d1SMatthew G. Knepley PetscDSGetExactSolution - Get the pointwise exact solution function for a given test field 2233c371a6d1SMatthew G. Knepley 2234c371a6d1SMatthew G. Knepley Not collective 2235c371a6d1SMatthew G. Knepley 2236c371a6d1SMatthew G. Knepley Input Parameters: 2237c371a6d1SMatthew G. Knepley + prob - The PetscDS 2238c371a6d1SMatthew G. Knepley - f - The test field number 2239c371a6d1SMatthew G. Knepley 2240c371a6d1SMatthew G. Knepley Output Parameter: 2241c371a6d1SMatthew G. Knepley . exactSol - exact solution for the test field 2242c371a6d1SMatthew G. Knepley 2243c371a6d1SMatthew G. Knepley Note: The calling sequence for the solution functions is given by: 2244c371a6d1SMatthew G. Knepley 2245c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2246c371a6d1SMatthew G. Knepley 2247c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2248c371a6d1SMatthew G. Knepley . t - current time 2249c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2250c371a6d1SMatthew G. Knepley . Nc - the number of field components 2251c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2252c371a6d1SMatthew G. Knepley - ctx - a user context 2253c371a6d1SMatthew G. Knepley 2254c371a6d1SMatthew G. Knepley Level: intermediate 2255c371a6d1SMatthew G. Knepley 2256c371a6d1SMatthew G. Knepley .seealso: PetscDSSetExactSolution() 2257c371a6d1SMatthew G. Knepley @*/ 2258c371a6d1SMatthew G. Knepley PetscErrorCode PetscDSGetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (**sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx)) 2259c371a6d1SMatthew G. Knepley { 2260c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2261c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2262c371a6d1SMatthew 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); 2263c371a6d1SMatthew G. Knepley if (sol) {PetscValidPointer(sol, 3); *sol = prob->exactSol[f];} 2264c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2265c371a6d1SMatthew G. Knepley } 2266c371a6d1SMatthew G. Knepley 2267c371a6d1SMatthew G. Knepley /*@C 2268c371a6d1SMatthew G. Knepley PetscDSSetExactSolution - Get the pointwise exact solution function for a given test field 2269c371a6d1SMatthew G. Knepley 2270c371a6d1SMatthew G. Knepley Not collective 2271c371a6d1SMatthew G. Knepley 2272c371a6d1SMatthew G. Knepley Input Parameters: 2273c371a6d1SMatthew G. Knepley + prob - The PetscDS 2274c371a6d1SMatthew G. Knepley . f - The test field number 2275c371a6d1SMatthew G. Knepley - sol - solution function for the test fields 2276c371a6d1SMatthew G. Knepley 2277c371a6d1SMatthew G. Knepley Note: The calling sequence for solution functions is given by: 2278c371a6d1SMatthew G. Knepley 2279c371a6d1SMatthew G. Knepley $ sol(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) 2280c371a6d1SMatthew G. Knepley 2281c371a6d1SMatthew G. Knepley + dim - the spatial dimension 2282c371a6d1SMatthew G. Knepley . t - current time 2283c371a6d1SMatthew G. Knepley . x - coordinates of the current point 2284c371a6d1SMatthew G. Knepley . Nc - the number of field components 2285c371a6d1SMatthew G. Knepley . u - the solution field evaluated at the current point 2286c371a6d1SMatthew G. Knepley - ctx - a user context 2287c371a6d1SMatthew G. Knepley 2288c371a6d1SMatthew G. Knepley Level: intermediate 2289c371a6d1SMatthew G. Knepley 2290c371a6d1SMatthew G. Knepley .seealso: PetscDSGetExactSolution() 2291c371a6d1SMatthew G. Knepley @*/ 2292c371a6d1SMatthew G. Knepley PetscErrorCode PetscDSSetExactSolution(PetscDS prob, PetscInt f, PetscErrorCode (*sol)(PetscInt dim, PetscReal t, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx)) 2293c371a6d1SMatthew G. Knepley { 2294c371a6d1SMatthew G. Knepley PetscErrorCode ierr; 2295c371a6d1SMatthew G. Knepley 2296c371a6d1SMatthew G. Knepley PetscFunctionBegin; 2297c371a6d1SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2298c371a6d1SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 2299c371a6d1SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 2300c371a6d1SMatthew G. Knepley if (sol) {PetscValidFunction(sol, 3); prob->exactSol[f] = sol;} 2301c371a6d1SMatthew G. Knepley PetscFunctionReturn(0); 2302c371a6d1SMatthew G. Knepley } 2303c371a6d1SMatthew G. Knepley 23045638fd0eSMatthew G. Knepley /*@C 230597b6e6e8SMatthew G. Knepley PetscDSGetConstants - Returns the array of constants passed to point functions 230697b6e6e8SMatthew G. Knepley 230797b6e6e8SMatthew G. Knepley Not collective 230897b6e6e8SMatthew G. Knepley 230997b6e6e8SMatthew G. Knepley Input Parameter: 231097b6e6e8SMatthew G. Knepley . prob - The PetscDS object 231197b6e6e8SMatthew G. Knepley 231297b6e6e8SMatthew G. Knepley Output Parameters: 231397b6e6e8SMatthew G. Knepley + numConstants - The number of constants 231497b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 231597b6e6e8SMatthew G. Knepley 231697b6e6e8SMatthew G. Knepley Level: intermediate 231797b6e6e8SMatthew G. Knepley 231897b6e6e8SMatthew G. Knepley .seealso: PetscDSSetConstants(), PetscDSCreate() 231997b6e6e8SMatthew G. Knepley @*/ 232097b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSGetConstants(PetscDS prob, PetscInt *numConstants, const PetscScalar *constants[]) 232197b6e6e8SMatthew G. Knepley { 232297b6e6e8SMatthew G. Knepley PetscFunctionBegin; 232397b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 232497b6e6e8SMatthew G. Knepley if (numConstants) {PetscValidPointer(numConstants, 2); *numConstants = prob->numConstants;} 232597b6e6e8SMatthew G. Knepley if (constants) {PetscValidPointer(constants, 3); *constants = prob->constants;} 232697b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 232797b6e6e8SMatthew G. Knepley } 232897b6e6e8SMatthew G. Knepley 23290d3e9b51SMatthew G. Knepley /*@C 233097b6e6e8SMatthew G. Knepley PetscDSSetConstants - Set the array of constants passed to point functions 233197b6e6e8SMatthew G. Knepley 233297b6e6e8SMatthew G. Knepley Not collective 233397b6e6e8SMatthew G. Knepley 233497b6e6e8SMatthew G. Knepley Input Parameters: 233597b6e6e8SMatthew G. Knepley + prob - The PetscDS object 233697b6e6e8SMatthew G. Knepley . numConstants - The number of constants 233797b6e6e8SMatthew G. Knepley - constants - The array of constants, NULL if there are none 233897b6e6e8SMatthew G. Knepley 233997b6e6e8SMatthew G. Knepley Level: intermediate 234097b6e6e8SMatthew G. Knepley 234197b6e6e8SMatthew G. Knepley .seealso: PetscDSGetConstants(), PetscDSCreate() 234297b6e6e8SMatthew G. Knepley @*/ 234397b6e6e8SMatthew G. Knepley PetscErrorCode PetscDSSetConstants(PetscDS prob, PetscInt numConstants, PetscScalar constants[]) 234497b6e6e8SMatthew G. Knepley { 234597b6e6e8SMatthew G. Knepley PetscErrorCode ierr; 234697b6e6e8SMatthew G. Knepley 234797b6e6e8SMatthew G. Knepley PetscFunctionBegin; 234897b6e6e8SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 234997b6e6e8SMatthew G. Knepley if (numConstants != prob->numConstants) { 235097b6e6e8SMatthew G. Knepley ierr = PetscFree(prob->constants);CHKERRQ(ierr); 235197b6e6e8SMatthew G. Knepley prob->numConstants = numConstants; 235297b6e6e8SMatthew G. Knepley if (prob->numConstants) { 235397b6e6e8SMatthew G. Knepley ierr = PetscMalloc1(prob->numConstants, &prob->constants);CHKERRQ(ierr); 235420be0f5bSMatthew G. Knepley } else { 235520be0f5bSMatthew G. Knepley prob->constants = NULL; 235620be0f5bSMatthew G. Knepley } 235720be0f5bSMatthew G. Knepley } 235820be0f5bSMatthew G. Knepley if (prob->numConstants) { 235920be0f5bSMatthew G. Knepley PetscValidPointer(constants, 3); 236097b6e6e8SMatthew G. Knepley ierr = PetscMemcpy(prob->constants, constants, prob->numConstants * sizeof(PetscScalar));CHKERRQ(ierr); 236197b6e6e8SMatthew G. Knepley } 236297b6e6e8SMatthew G. Knepley PetscFunctionReturn(0); 236397b6e6e8SMatthew G. Knepley } 236497b6e6e8SMatthew G. Knepley 23654cd1e086SMatthew G. Knepley /*@ 23664cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 23674cd1e086SMatthew G. Knepley 23684cd1e086SMatthew G. Knepley Not collective 23694cd1e086SMatthew G. Knepley 23704cd1e086SMatthew G. Knepley Input Parameters: 23714cd1e086SMatthew G. Knepley + prob - The PetscDS object 23724cd1e086SMatthew G. Knepley - disc - The discretization object 23734cd1e086SMatthew G. Knepley 23744cd1e086SMatthew G. Knepley Output Parameter: 23754cd1e086SMatthew G. Knepley . f - The field number 23764cd1e086SMatthew G. Knepley 23774cd1e086SMatthew G. Knepley Level: beginner 23784cd1e086SMatthew G. Knepley 2379f744cafaSSander Arens .seealso: PetscGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 23804cd1e086SMatthew G. Knepley @*/ 23814cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 23824cd1e086SMatthew G. Knepley { 23834cd1e086SMatthew G. Knepley PetscInt g; 23844cd1e086SMatthew G. Knepley 23854cd1e086SMatthew G. Knepley PetscFunctionBegin; 23864cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23874cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 23884cd1e086SMatthew G. Knepley *f = -1; 23894cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 23904cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 23914cd1e086SMatthew G. Knepley *f = g; 23924cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 23934cd1e086SMatthew G. Knepley } 23944cd1e086SMatthew G. Knepley 23954cd1e086SMatthew G. Knepley /*@ 23964cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 23974cd1e086SMatthew G. Knepley 23984cd1e086SMatthew G. Knepley Not collective 23994cd1e086SMatthew G. Knepley 24004cd1e086SMatthew G. Knepley Input Parameters: 24014cd1e086SMatthew G. Knepley + prob - The PetscDS object 24024cd1e086SMatthew G. Knepley - f - The field number 24034cd1e086SMatthew G. Knepley 24044cd1e086SMatthew G. Knepley Output Parameter: 24054cd1e086SMatthew G. Knepley . size - The size 24064cd1e086SMatthew G. Knepley 24074cd1e086SMatthew G. Knepley Level: beginner 24084cd1e086SMatthew G. Knepley 2409f744cafaSSander Arens .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 24104cd1e086SMatthew G. Knepley @*/ 24114cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 24124cd1e086SMatthew G. Knepley { 24132166fd64SMatthew G. Knepley PetscErrorCode ierr; 24142166fd64SMatthew G. Knepley 24154cd1e086SMatthew G. Knepley PetscFunctionBegin; 24164cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24174cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 24184cd1e086SMatthew 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); 24192166fd64SMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 2420d4742ddaSMatthew G. Knepley *size = prob->Nb[f]; 24214cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 24224cd1e086SMatthew G. Knepley } 24234cd1e086SMatthew G. Knepley 2424bc4ae4beSMatthew G. Knepley /*@ 2425bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2426bc4ae4beSMatthew G. Knepley 2427bc4ae4beSMatthew G. Knepley Not collective 2428bc4ae4beSMatthew G. Knepley 2429bc4ae4beSMatthew G. Knepley Input Parameters: 2430bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2431bc4ae4beSMatthew G. Knepley - f - The field number 2432bc4ae4beSMatthew G. Knepley 2433bc4ae4beSMatthew G. Knepley Output Parameter: 2434bc4ae4beSMatthew G. Knepley . off - The offset 2435bc4ae4beSMatthew G. Knepley 2436bc4ae4beSMatthew G. Knepley Level: beginner 2437bc4ae4beSMatthew G. Knepley 2438f744cafaSSander Arens .seealso: PetscDSGetFieldSize(), PetscDSGetNumFields(), PetscDSCreate() 2439bc4ae4beSMatthew G. Knepley @*/ 24402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 24412764a2aaSMatthew G. Knepley { 24424cd1e086SMatthew G. Knepley PetscInt size, g; 24432764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24442764a2aaSMatthew G. Knepley 24452764a2aaSMatthew G. Knepley PetscFunctionBegin; 24462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24472764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 24482764a2aaSMatthew 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); 24492764a2aaSMatthew G. Knepley *off = 0; 24502764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 24514cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 24524cd1e086SMatthew G. Knepley *off += size; 24532764a2aaSMatthew G. Knepley } 24542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24552764a2aaSMatthew G. Knepley } 24562764a2aaSMatthew G. Knepley 2457bc4ae4beSMatthew G. Knepley /*@ 245847e57110SSander Arens PetscDSGetDimensions - Returns the size of the approximation space for each field on an evaluation point 2459bc4ae4beSMatthew G. Knepley 2460bc4ae4beSMatthew G. Knepley Not collective 2461bc4ae4beSMatthew G. Knepley 246247e57110SSander Arens Input Parameter: 246347e57110SSander Arens . prob - The PetscDS object 2464bc4ae4beSMatthew G. Knepley 2465bc4ae4beSMatthew G. Knepley Output Parameter: 246647e57110SSander Arens . dimensions - The number of dimensions 2467bc4ae4beSMatthew G. Knepley 2468bc4ae4beSMatthew G. Knepley Level: beginner 2469bc4ae4beSMatthew G. Knepley 247047e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 2471bc4ae4beSMatthew G. Knepley @*/ 247247e57110SSander Arens PetscErrorCode PetscDSGetDimensions(PetscDS prob, PetscInt *dimensions[]) 24732764a2aaSMatthew G. Knepley { 24742764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24752764a2aaSMatthew G. Knepley 24762764a2aaSMatthew G. Knepley PetscFunctionBegin; 24772764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 247847e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 247947e57110SSander Arens PetscValidPointer(dimensions, 2); 248047e57110SSander Arens *dimensions = prob->Nb; 248147e57110SSander Arens PetscFunctionReturn(0); 24826ce16762SMatthew G. Knepley } 248347e57110SSander Arens 248447e57110SSander Arens /*@ 248547e57110SSander Arens PetscDSGetComponents - Returns the number of components for each field on an evaluation point 248647e57110SSander Arens 248747e57110SSander Arens Not collective 248847e57110SSander Arens 248947e57110SSander Arens Input Parameter: 249047e57110SSander Arens . prob - The PetscDS object 249147e57110SSander Arens 249247e57110SSander Arens Output Parameter: 249347e57110SSander Arens . components - The number of components 249447e57110SSander Arens 249547e57110SSander Arens Level: beginner 249647e57110SSander Arens 249747e57110SSander Arens .seealso: PetscDSGetComponentOffsets(), PetscDSGetNumFields(), PetscDSCreate() 249847e57110SSander Arens @*/ 249947e57110SSander Arens PetscErrorCode PetscDSGetComponents(PetscDS prob, PetscInt *components[]) 250047e57110SSander Arens { 250147e57110SSander Arens PetscErrorCode ierr; 250247e57110SSander Arens 250347e57110SSander Arens PetscFunctionBegin; 250447e57110SSander Arens PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 250547e57110SSander Arens ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 250647e57110SSander Arens PetscValidPointer(components, 2); 250747e57110SSander Arens *components = prob->Nc; 25086ce16762SMatthew G. Knepley PetscFunctionReturn(0); 25096ce16762SMatthew G. Knepley } 25106ce16762SMatthew G. Knepley 25116ce16762SMatthew G. Knepley /*@ 25126ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 25136ce16762SMatthew G. Knepley 25146ce16762SMatthew G. Knepley Not collective 25156ce16762SMatthew G. Knepley 25166ce16762SMatthew G. Knepley Input Parameters: 25176ce16762SMatthew G. Knepley + prob - The PetscDS object 25186ce16762SMatthew G. Knepley - f - The field number 25196ce16762SMatthew G. Knepley 25206ce16762SMatthew G. Knepley Output Parameter: 25216ce16762SMatthew G. Knepley . off - The offset 25226ce16762SMatthew G. Knepley 25236ce16762SMatthew G. Knepley Level: beginner 25246ce16762SMatthew G. Knepley 2525f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 25266ce16762SMatthew G. Knepley @*/ 25276ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 25286ce16762SMatthew G. Knepley { 25296ce16762SMatthew G. Knepley PetscFunctionBegin; 25306ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 25316ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 25326ce16762SMatthew 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); 253347e57110SSander Arens *off = prob->off[f]; 25342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25352764a2aaSMatthew G. Knepley } 25362764a2aaSMatthew G. Knepley 2537194d53e6SMatthew G. Knepley /*@ 2538194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2539194d53e6SMatthew G. Knepley 2540194d53e6SMatthew G. Knepley Not collective 2541194d53e6SMatthew G. Knepley 2542194d53e6SMatthew G. Knepley Input Parameter: 2543194d53e6SMatthew G. Knepley . prob - The PetscDS object 2544194d53e6SMatthew G. Knepley 2545194d53e6SMatthew G. Knepley Output Parameter: 2546194d53e6SMatthew G. Knepley . offsets - The offsets 2547194d53e6SMatthew G. Knepley 2548194d53e6SMatthew G. Knepley Level: beginner 2549194d53e6SMatthew G. Knepley 2550f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2551194d53e6SMatthew G. Knepley @*/ 2552194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2553194d53e6SMatthew G. Knepley { 2554194d53e6SMatthew G. Knepley PetscFunctionBegin; 2555194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2556194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2557194d53e6SMatthew G. Knepley *offsets = prob->off; 2558194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2559194d53e6SMatthew G. Knepley } 2560194d53e6SMatthew G. Knepley 2561194d53e6SMatthew G. Knepley /*@ 2562194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2563194d53e6SMatthew G. Knepley 2564194d53e6SMatthew G. Knepley Not collective 2565194d53e6SMatthew G. Knepley 2566194d53e6SMatthew G. Knepley Input Parameter: 2567194d53e6SMatthew G. Knepley . prob - The PetscDS object 2568194d53e6SMatthew G. Knepley 2569194d53e6SMatthew G. Knepley Output Parameter: 2570194d53e6SMatthew G. Knepley . offsets - The offsets 2571194d53e6SMatthew G. Knepley 2572194d53e6SMatthew G. Knepley Level: beginner 2573194d53e6SMatthew G. Knepley 2574f744cafaSSander Arens .seealso: PetscDSGetNumFields(), PetscDSCreate() 2575194d53e6SMatthew G. Knepley @*/ 2576194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2577194d53e6SMatthew G. Knepley { 2578194d53e6SMatthew G. Knepley PetscFunctionBegin; 2579194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2580194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2581194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2582194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2583194d53e6SMatthew G. Knepley } 2584194d53e6SMatthew G. Knepley 258568c9edb9SMatthew G. Knepley /*@C 258668c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 258768c9edb9SMatthew G. Knepley 258868c9edb9SMatthew G. Knepley Not collective 258968c9edb9SMatthew G. Knepley 259068c9edb9SMatthew G. Knepley Input Parameter: 259168c9edb9SMatthew G. Knepley . prob - The PetscDS object 259268c9edb9SMatthew G. Knepley 259368c9edb9SMatthew G. Knepley Output Parameters: 259468c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 259568c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 259668c9edb9SMatthew G. Knepley 259768c9edb9SMatthew G. Knepley Level: intermediate 259868c9edb9SMatthew G. Knepley 2599f744cafaSSander Arens .seealso: PetscDSCreate() 260068c9edb9SMatthew G. Knepley @*/ 26012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 26022764a2aaSMatthew G. Knepley { 26032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26042764a2aaSMatthew G. Knepley 26052764a2aaSMatthew G. Knepley PetscFunctionBegin; 26062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26072764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26082764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 26092764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 26102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26112764a2aaSMatthew G. Knepley } 26122764a2aaSMatthew G. Knepley 261368c9edb9SMatthew G. Knepley /*@C 26144d0b9603SSander Arens PetscDSGetFaceTabulation - Return the basis tabulation at quadrature points on the faces 261568c9edb9SMatthew G. Knepley 261668c9edb9SMatthew G. Knepley Not collective 261768c9edb9SMatthew G. Knepley 261868c9edb9SMatthew G. Knepley Input Parameter: 261968c9edb9SMatthew G. Knepley . prob - The PetscDS object 262068c9edb9SMatthew G. Knepley 262168c9edb9SMatthew G. Knepley Output Parameters: 26224d0b9603SSander Arens + basisFace - The basis function tabulation at quadrature points 26234d0b9603SSander Arens - basisDerFace - The basis function derivative tabulation at quadrature points 262468c9edb9SMatthew G. Knepley 262568c9edb9SMatthew G. Knepley Level: intermediate 262668c9edb9SMatthew G. Knepley 262768c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 262868c9edb9SMatthew G. Knepley @*/ 26294d0b9603SSander Arens PetscErrorCode PetscDSGetFaceTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 26302764a2aaSMatthew G. Knepley { 26312764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26322764a2aaSMatthew G. Knepley 26332764a2aaSMatthew G. Knepley PetscFunctionBegin; 26342764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26352764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26364d0b9603SSander Arens if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisFace;} 26374d0b9603SSander Arens if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerFace;} 26382764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26392764a2aaSMatthew G. Knepley } 26402764a2aaSMatthew G. Knepley 26412764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 26422764a2aaSMatthew G. Knepley { 26432764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26442764a2aaSMatthew G. Knepley 26452764a2aaSMatthew G. Knepley PetscFunctionBegin; 26462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26472764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26482764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 26492764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 26502764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 26512764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26522764a2aaSMatthew G. Knepley } 26532764a2aaSMatthew G. Knepley 26542764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 26552764a2aaSMatthew G. Knepley { 26562764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26572764a2aaSMatthew G. Knepley 26582764a2aaSMatthew G. Knepley PetscFunctionBegin; 26592764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26602764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26612764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 26622764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 26632764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 26642764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 26652764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 26662764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 26672764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26682764a2aaSMatthew G. Knepley } 26692764a2aaSMatthew G. Knepley 26702764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 26712764a2aaSMatthew G. Knepley { 26722764a2aaSMatthew G. Knepley PetscErrorCode ierr; 26732764a2aaSMatthew G. Knepley 26742764a2aaSMatthew G. Knepley PetscFunctionBegin; 26752764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 26762764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 26772764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 26782764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 26792764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 26802764a2aaSMatthew G. Knepley } 26812764a2aaSMatthew G. Knepley 268258ebd649SToby Isaac /*@C 268358ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 268458ebd649SToby Isaac 268558ebd649SToby Isaac Input Parameters: 268658ebd649SToby Isaac + ds - The PetscDS object 26872d47a189SJulian Andrej . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 268858ebd649SToby Isaac . name - The BC name 268958ebd649SToby Isaac . labelname - The label defining constrained points 269058ebd649SToby Isaac . field - The field to constrain 2691e8ecbf3fSStefano Zampini . numcomps - The number of constrained field components (0 will constrain all fields) 269258ebd649SToby Isaac . comps - An array of constrained component numbers 269358ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 269458ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 269558ebd649SToby Isaac . ids - An array of ids for constrained points 269658ebd649SToby Isaac - ctx - An optional user context for bcFunc 269758ebd649SToby Isaac 269858ebd649SToby Isaac Options Database Keys: 269958ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 270058ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 270158ebd649SToby Isaac 270258ebd649SToby Isaac Level: developer 270358ebd649SToby Isaac 270458ebd649SToby Isaac .seealso: PetscDSGetBoundary() 270558ebd649SToby Isaac @*/ 2706a30ec4eaSSatish 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) 270758ebd649SToby Isaac { 270858ebd649SToby Isaac DSBoundary b; 270958ebd649SToby Isaac PetscErrorCode ierr; 271058ebd649SToby Isaac 271158ebd649SToby Isaac PetscFunctionBegin; 271258ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 271358ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 271458ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 271558ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 271658ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 271758ebd649SToby Isaac if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 271858ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 271958ebd649SToby Isaac if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 2720f971fd6bSMatthew G. Knepley b->type = type; 272158ebd649SToby Isaac b->field = field; 272258ebd649SToby Isaac b->numcomps = numcomps; 272358ebd649SToby Isaac b->func = bcFunc; 272458ebd649SToby Isaac b->numids = numids; 272558ebd649SToby Isaac b->ctx = ctx; 272658ebd649SToby Isaac b->next = ds->boundary; 272758ebd649SToby Isaac ds->boundary = b; 272858ebd649SToby Isaac PetscFunctionReturn(0); 272958ebd649SToby Isaac } 273058ebd649SToby Isaac 2731b67eacb3SMatthew G. Knepley /*@C 2732b67eacb3SMatthew G. Knepley PetscDSUpdateBoundary - Change a boundary condition for the model 2733b67eacb3SMatthew G. Knepley 2734b67eacb3SMatthew G. Knepley Input Parameters: 2735b67eacb3SMatthew G. Knepley + ds - The PetscDS object 2736b67eacb3SMatthew G. Knepley . bd - The boundary condition number 2737b67eacb3SMatthew G. Knepley . type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 2738b67eacb3SMatthew G. Knepley . name - The BC name 2739b67eacb3SMatthew G. Knepley . labelname - The label defining constrained points 2740b67eacb3SMatthew G. Knepley . field - The field to constrain 2741b67eacb3SMatthew G. Knepley . numcomps - The number of constrained field components 2742b67eacb3SMatthew G. Knepley . comps - An array of constrained component numbers 2743b67eacb3SMatthew G. Knepley . bcFunc - A pointwise function giving boundary values 2744b67eacb3SMatthew G. Knepley . numids - The number of DMLabel ids for constrained points 2745b67eacb3SMatthew G. Knepley . ids - An array of ids for constrained points 2746b67eacb3SMatthew G. Knepley - ctx - An optional user context for bcFunc 2747b67eacb3SMatthew G. Knepley 27489a6efb6aSMatthew 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(). 27499a6efb6aSMatthew G. Knepley 2750b67eacb3SMatthew G. Knepley Level: developer 2751b67eacb3SMatthew G. Knepley 27529a6efb6aSMatthew G. Knepley .seealso: PetscDSAddBoundary(), PetscDSGetBoundary(), PetscDSGetNumBoundary() 2753b67eacb3SMatthew G. Knepley @*/ 2754b67eacb3SMatthew 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) 2755b67eacb3SMatthew G. Knepley { 2756b67eacb3SMatthew G. Knepley DSBoundary b = ds->boundary; 2757b67eacb3SMatthew G. Knepley PetscInt n = 0; 2758b67eacb3SMatthew G. Knepley PetscErrorCode ierr; 2759b67eacb3SMatthew G. Knepley 2760b67eacb3SMatthew G. Knepley PetscFunctionBegin; 2761b67eacb3SMatthew G. Knepley PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2762b67eacb3SMatthew G. Knepley while (b) { 2763b67eacb3SMatthew G. Knepley if (n == bd) break; 2764b67eacb3SMatthew G. Knepley b = b->next; 2765b67eacb3SMatthew G. Knepley ++n; 2766b67eacb3SMatthew G. Knepley } 2767b67eacb3SMatthew G. Knepley if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 2768b67eacb3SMatthew G. Knepley if (name) { 2769b67eacb3SMatthew G. Knepley ierr = PetscFree(b->name);CHKERRQ(ierr); 2770b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 2771b67eacb3SMatthew G. Knepley } 2772b67eacb3SMatthew G. Knepley if (labelname) { 2773b67eacb3SMatthew G. Knepley ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2774b67eacb3SMatthew G. Knepley ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 2775b67eacb3SMatthew G. Knepley } 2776b67eacb3SMatthew G. Knepley if (numcomps >= 0 && numcomps != b->numcomps) { 2777b67eacb3SMatthew G. Knepley b->numcomps = numcomps; 2778b67eacb3SMatthew G. Knepley ierr = PetscFree(b->comps);CHKERRQ(ierr); 2779b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 2780b67eacb3SMatthew G. Knepley if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 2781b67eacb3SMatthew G. Knepley } 2782b67eacb3SMatthew G. Knepley if (numids >= 0 && numids != b->numids) { 2783b67eacb3SMatthew G. Knepley b->numids = numids; 2784b67eacb3SMatthew G. Knepley ierr = PetscFree(b->ids);CHKERRQ(ierr); 2785b67eacb3SMatthew G. Knepley ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 2786b67eacb3SMatthew G. Knepley if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 2787b67eacb3SMatthew G. Knepley } 2788b67eacb3SMatthew G. Knepley b->type = type; 2789b67eacb3SMatthew G. Knepley if (field >= 0) {b->field = field;} 2790b67eacb3SMatthew G. Knepley if (bcFunc) {b->func = bcFunc;} 2791b67eacb3SMatthew G. Knepley if (ctx) {b->ctx = ctx;} 2792b67eacb3SMatthew G. Knepley PetscFunctionReturn(0); 2793b67eacb3SMatthew G. Knepley } 2794b67eacb3SMatthew G. Knepley 279558ebd649SToby Isaac /*@ 279658ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 279758ebd649SToby Isaac 279858ebd649SToby Isaac Input Parameters: 279958ebd649SToby Isaac . ds - The PetscDS object 280058ebd649SToby Isaac 280158ebd649SToby Isaac Output Parameters: 280258ebd649SToby Isaac . numBd - The number of BC 280358ebd649SToby Isaac 280458ebd649SToby Isaac Level: intermediate 280558ebd649SToby Isaac 280658ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 280758ebd649SToby Isaac @*/ 280858ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 280958ebd649SToby Isaac { 281058ebd649SToby Isaac DSBoundary b = ds->boundary; 281158ebd649SToby Isaac 281258ebd649SToby Isaac PetscFunctionBegin; 281358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 281458ebd649SToby Isaac PetscValidPointer(numBd, 2); 281558ebd649SToby Isaac *numBd = 0; 281658ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 281758ebd649SToby Isaac PetscFunctionReturn(0); 281858ebd649SToby Isaac } 281958ebd649SToby Isaac 282058ebd649SToby Isaac /*@C 28219a6efb6aSMatthew G. Knepley PetscDSGetBoundary - Gets a boundary condition to the model 282258ebd649SToby Isaac 282358ebd649SToby Isaac Input Parameters: 282458ebd649SToby Isaac + ds - The PetscDS object 282558ebd649SToby Isaac - bd - The BC number 282658ebd649SToby Isaac 282758ebd649SToby Isaac Output Parameters: 28282d47a189SJulian Andrej + type - The type of condition, e.g. DM_BC_ESSENTIAL/DM_BC_ESSENTIAL_FIELD (Dirichlet), or DM_BC_NATURAL (Neumann) 282958ebd649SToby Isaac . name - The BC name 283058ebd649SToby Isaac . labelname - The label defining constrained points 283158ebd649SToby Isaac . field - The field to constrain 283258ebd649SToby Isaac . numcomps - The number of constrained field components 283358ebd649SToby Isaac . comps - An array of constrained component numbers 283458ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 283558ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 283658ebd649SToby Isaac . ids - An array of ids for constrained points 283758ebd649SToby Isaac - ctx - An optional user context for bcFunc 283858ebd649SToby Isaac 283958ebd649SToby Isaac Options Database Keys: 284058ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 284158ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 284258ebd649SToby Isaac 284358ebd649SToby Isaac Level: developer 284458ebd649SToby Isaac 284558ebd649SToby Isaac .seealso: PetscDSAddBoundary() 284658ebd649SToby Isaac @*/ 2847a30ec4eaSSatish 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) 284858ebd649SToby Isaac { 284958ebd649SToby Isaac DSBoundary b = ds->boundary; 285058ebd649SToby Isaac PetscInt n = 0; 285158ebd649SToby Isaac 285258ebd649SToby Isaac PetscFunctionBegin; 285358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 285458ebd649SToby Isaac while (b) { 285558ebd649SToby Isaac if (n == bd) break; 285658ebd649SToby Isaac b = b->next; 285758ebd649SToby Isaac ++n; 285858ebd649SToby Isaac } 285958ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 2860f971fd6bSMatthew G. Knepley if (type) { 2861f971fd6bSMatthew G. Knepley PetscValidPointer(type, 3); 2862f971fd6bSMatthew G. Knepley *type = b->type; 286358ebd649SToby Isaac } 286458ebd649SToby Isaac if (name) { 286558ebd649SToby Isaac PetscValidPointer(name, 4); 286658ebd649SToby Isaac *name = b->name; 286758ebd649SToby Isaac } 286858ebd649SToby Isaac if (labelname) { 286958ebd649SToby Isaac PetscValidPointer(labelname, 5); 287058ebd649SToby Isaac *labelname = b->labelname; 287158ebd649SToby Isaac } 287258ebd649SToby Isaac if (field) { 287358ebd649SToby Isaac PetscValidPointer(field, 6); 287458ebd649SToby Isaac *field = b->field; 287558ebd649SToby Isaac } 287658ebd649SToby Isaac if (numcomps) { 287758ebd649SToby Isaac PetscValidPointer(numcomps, 7); 287858ebd649SToby Isaac *numcomps = b->numcomps; 287958ebd649SToby Isaac } 288058ebd649SToby Isaac if (comps) { 288158ebd649SToby Isaac PetscValidPointer(comps, 8); 288258ebd649SToby Isaac *comps = b->comps; 288358ebd649SToby Isaac } 288458ebd649SToby Isaac if (func) { 288558ebd649SToby Isaac PetscValidPointer(func, 9); 288658ebd649SToby Isaac *func = b->func; 288758ebd649SToby Isaac } 288858ebd649SToby Isaac if (numids) { 288958ebd649SToby Isaac PetscValidPointer(numids, 10); 289058ebd649SToby Isaac *numids = b->numids; 289158ebd649SToby Isaac } 289258ebd649SToby Isaac if (ids) { 289358ebd649SToby Isaac PetscValidPointer(ids, 11); 289458ebd649SToby Isaac *ids = b->ids; 289558ebd649SToby Isaac } 289658ebd649SToby Isaac if (ctx) { 289758ebd649SToby Isaac PetscValidPointer(ctx, 12); 289858ebd649SToby Isaac *ctx = b->ctx; 289958ebd649SToby Isaac } 290058ebd649SToby Isaac PetscFunctionReturn(0); 290158ebd649SToby Isaac } 290258ebd649SToby Isaac 29039252d075SMatthew G. Knepley /*@ 29049252d075SMatthew G. Knepley PetscDSCopyBoundary - Copy all boundary condition objects to the new problem 29059252d075SMatthew G. Knepley 29069252d075SMatthew G. Knepley Not collective 29079252d075SMatthew G. Knepley 29089252d075SMatthew G. Knepley Input Parameter: 29099252d075SMatthew G. Knepley . prob - The PetscDS object 29109252d075SMatthew G. Knepley 29119252d075SMatthew G. Knepley Output Parameter: 29129252d075SMatthew G. Knepley . newprob - The PetscDS copy 29139252d075SMatthew G. Knepley 29149252d075SMatthew G. Knepley Level: intermediate 29159252d075SMatthew G. Knepley 29169252d075SMatthew G. Knepley .seealso: PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 29179252d075SMatthew G. Knepley @*/ 2918dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 2919dff059c6SToby Isaac { 2920dff059c6SToby Isaac DSBoundary b, next, *lastnext; 2921dff059c6SToby Isaac PetscErrorCode ierr; 2922dff059c6SToby Isaac 2923dff059c6SToby Isaac PetscFunctionBegin; 2924dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 2925dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 2926dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 2927dff059c6SToby Isaac next = probB->boundary; 2928dff059c6SToby Isaac while (next) { 2929dff059c6SToby Isaac DSBoundary b = next; 2930dff059c6SToby Isaac 2931dff059c6SToby Isaac next = b->next; 2932dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 2933dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 2934dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 2935dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2936dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 2937dff059c6SToby Isaac } 2938dff059c6SToby Isaac lastnext = &(probB->boundary); 2939dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 2940dff059c6SToby Isaac DSBoundary bNew; 2941dff059c6SToby Isaac 2942459726d8SSatish Balay ierr = PetscNew(&bNew);CHKERRQ(ierr); 2943dff059c6SToby Isaac bNew->numcomps = b->numcomps; 2944dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 2945dff059c6SToby Isaac ierr = PetscMemcpy(bNew->comps, b->comps, bNew->numcomps*sizeof(PetscInt));CHKERRQ(ierr); 2946dff059c6SToby Isaac bNew->numids = b->numids; 2947dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 2948dff059c6SToby Isaac ierr = PetscMemcpy(bNew->ids, b->ids, bNew->numids*sizeof(PetscInt));CHKERRQ(ierr); 2949dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 2950dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 2951dff059c6SToby Isaac bNew->ctx = b->ctx; 2952f971fd6bSMatthew G. Knepley bNew->type = b->type; 2953dff059c6SToby Isaac bNew->field = b->field; 2954dff059c6SToby Isaac bNew->func = b->func; 2955dff059c6SToby Isaac 2956dff059c6SToby Isaac *lastnext = bNew; 2957dff059c6SToby Isaac lastnext = &(bNew->next); 2958dff059c6SToby Isaac } 2959dff059c6SToby Isaac PetscFunctionReturn(0); 2960dff059c6SToby Isaac } 2961dff059c6SToby Isaac 29629252d075SMatthew G. Knepley /*@C 29639252d075SMatthew G. Knepley PetscDSSelectEquations - Copy pointwise function pointers to the new problem with different field layout 29649252d075SMatthew G. Knepley 29659252d075SMatthew G. Knepley Not collective 29669252d075SMatthew G. Knepley 29679252d075SMatthew G. Knepley Input Parameter: 29689252d075SMatthew G. Knepley + prob - The PetscDS object 29699252d075SMatthew G. Knepley . numFields - Number of new fields 29709252d075SMatthew G. Knepley - fields - Old field number for each new field 29719252d075SMatthew G. Knepley 29729252d075SMatthew G. Knepley Output Parameter: 29739252d075SMatthew G. Knepley . newprob - The PetscDS copy 29749252d075SMatthew G. Knepley 29759252d075SMatthew G. Knepley Level: intermediate 29769252d075SMatthew G. Knepley 29779252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 29789252d075SMatthew G. Knepley @*/ 29799252d075SMatthew G. Knepley PetscErrorCode PetscDSSelectEquations(PetscDS prob, PetscInt numFields, const PetscInt fields[], PetscDS newprob) 29809252d075SMatthew G. Knepley { 29819252d075SMatthew G. Knepley PetscInt Nf, Nfn, fn, gn; 29829252d075SMatthew G. Knepley PetscErrorCode ierr; 29839252d075SMatthew G. Knepley 29849252d075SMatthew G. Knepley PetscFunctionBegin; 29859252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 29869252d075SMatthew G. Knepley if (fields) PetscValidPointer(fields, 3); 29879252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 4); 29889252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 29899252d075SMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Nfn);CHKERRQ(ierr); 29909252d075SMatthew 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); 29919252d075SMatthew G. Knepley for (fn = 0; fn < numFields; ++fn) { 29929252d075SMatthew G. Knepley const PetscInt f = fields ? fields[fn] : fn; 29939252d075SMatthew G. Knepley PetscPointFunc obj; 29949252d075SMatthew G. Knepley PetscPointFunc f0, f1; 29959252d075SMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 29969252d075SMatthew G. Knepley PetscRiemannFunc r; 29979252d075SMatthew G. Knepley 29989252d075SMatthew G. Knepley if (f >= Nf) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", f, Nf); 29999252d075SMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 30009252d075SMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 30019252d075SMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 30029252d075SMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 30039252d075SMatthew G. Knepley ierr = PetscDSSetObjective(newprob, fn, obj);CHKERRQ(ierr); 30049252d075SMatthew G. Knepley ierr = PetscDSSetResidual(newprob, fn, f0, f1);CHKERRQ(ierr); 30059252d075SMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, fn, f0Bd, f1Bd);CHKERRQ(ierr); 30069252d075SMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, fn, r);CHKERRQ(ierr); 30079252d075SMatthew G. Knepley for (gn = 0; gn < numFields; ++gn) { 30089252d075SMatthew G. Knepley const PetscInt g = fields ? fields[gn] : gn; 30099252d075SMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 30109252d075SMatthew G. Knepley PetscPointJac g0p, g1p, g2p, g3p; 30119252d075SMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 30129252d075SMatthew G. Knepley 30139252d075SMatthew G. Knepley if (g >= Nf) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Field %D must be in [0, %D)", g, Nf); 30149252d075SMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 30159252d075SMatthew G. Knepley ierr = PetscDSGetJacobianPreconditioner(prob, f, g, &g0p, &g1p, &g2p, &g3p);CHKERRQ(ierr); 30169252d075SMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 30179252d075SMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, fn, gn, g0, g1, g2, g3);CHKERRQ(ierr); 30189252d075SMatthew G. Knepley ierr = PetscDSSetJacobianPreconditioner(prob, fn, gn, g0p, g1p, g2p, g3p);CHKERRQ(ierr); 30199252d075SMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, fn, gn, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 30209252d075SMatthew G. Knepley } 30219252d075SMatthew G. Knepley } 30229252d075SMatthew G. Knepley PetscFunctionReturn(0); 30239252d075SMatthew G. Knepley } 30249252d075SMatthew G. Knepley 3025da51fcedSMatthew G. Knepley /*@ 3026da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 3027da51fcedSMatthew G. Knepley 3028da51fcedSMatthew G. Knepley Not collective 3029da51fcedSMatthew G. Knepley 3030da51fcedSMatthew G. Knepley Input Parameter: 3031da51fcedSMatthew G. Knepley . prob - The PetscDS object 3032da51fcedSMatthew G. Knepley 3033da51fcedSMatthew G. Knepley Output Parameter: 3034da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 3035da51fcedSMatthew G. Knepley 3036da51fcedSMatthew G. Knepley Level: intermediate 3037da51fcedSMatthew G. Knepley 30389252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 3039da51fcedSMatthew G. Knepley @*/ 3040da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 3041da51fcedSMatthew G. Knepley { 30429252d075SMatthew G. Knepley PetscInt Nf, Ng; 3043da51fcedSMatthew G. Knepley PetscErrorCode ierr; 3044da51fcedSMatthew G. Knepley 3045da51fcedSMatthew G. Knepley PetscFunctionBegin; 3046da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3047da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 3048da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3049da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 305013903a91SSatish Balay if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng); 30519252d075SMatthew G. Knepley ierr = PetscDSSelectEquations(prob, Nf, NULL, newprob);CHKERRQ(ierr); 30529252d075SMatthew G. Knepley PetscFunctionReturn(0); 30539252d075SMatthew G. Knepley } 30549252d075SMatthew G. Knepley /*@ 30559252d075SMatthew G. Knepley PetscDSCopyConstants - Copy all constants to the new problem 3056da51fcedSMatthew G. Knepley 30579252d075SMatthew G. Knepley Not collective 30589252d075SMatthew G. Knepley 30599252d075SMatthew G. Knepley Input Parameter: 30609252d075SMatthew G. Knepley . prob - The PetscDS object 30619252d075SMatthew G. Knepley 30629252d075SMatthew G. Knepley Output Parameter: 30639252d075SMatthew G. Knepley . newprob - The PetscDS copy 30649252d075SMatthew G. Knepley 30659252d075SMatthew G. Knepley Level: intermediate 30669252d075SMatthew G. Knepley 30679252d075SMatthew G. Knepley .seealso: PetscDSCopyBoundary(), PetscDSCopyEquations(), PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 30689252d075SMatthew G. Knepley @*/ 30699252d075SMatthew G. Knepley PetscErrorCode PetscDSCopyConstants(PetscDS prob, PetscDS newprob) 30709252d075SMatthew G. Knepley { 30719252d075SMatthew G. Knepley PetscInt Nc; 30729252d075SMatthew G. Knepley const PetscScalar *constants; 30739252d075SMatthew G. Knepley PetscErrorCode ierr; 30749252d075SMatthew G. Knepley 30759252d075SMatthew G. Knepley PetscFunctionBegin; 30769252d075SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 30779252d075SMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 30789252d075SMatthew G. Knepley ierr = PetscDSGetConstants(prob, &Nc, &constants);CHKERRQ(ierr); 30799252d075SMatthew G. Knepley ierr = PetscDSSetConstants(newprob, Nc, (PetscScalar *) constants);CHKERRQ(ierr); 3080da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 3081da51fcedSMatthew G. Knepley } 3082da51fcedSMatthew G. Knepley 3083b1353e8eSMatthew G. Knepley PetscErrorCode PetscDSGetHeightSubspace(PetscDS prob, PetscInt height, PetscDS *subprob) 3084b1353e8eSMatthew G. Knepley { 3085df3a45bdSMatthew G. Knepley PetscInt dim, Nf, f; 3086b1353e8eSMatthew G. Knepley PetscErrorCode ierr; 3087b1353e8eSMatthew G. Knepley 3088b1353e8eSMatthew G. Knepley PetscFunctionBegin; 3089b1353e8eSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3090b1353e8eSMatthew G. Knepley PetscValidPointer(subprob, 3); 3091b1353e8eSMatthew G. Knepley if (height == 0) {*subprob = prob; PetscFunctionReturn(0);} 3092b1353e8eSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 3093df3a45bdSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3094df3a45bdSMatthew 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); 3095df3a45bdSMatthew G. Knepley if (!prob->subprobs) {ierr = PetscCalloc1(dim, &prob->subprobs);CHKERRQ(ierr);} 3096df3a45bdSMatthew G. Knepley if (!prob->subprobs[height-1]) { 3097b1353e8eSMatthew G. Knepley PetscInt cdim; 3098b1353e8eSMatthew G. Knepley 3099df3a45bdSMatthew G. Knepley ierr = PetscDSCreate(PetscObjectComm((PetscObject) prob), &prob->subprobs[height-1]);CHKERRQ(ierr); 3100b1353e8eSMatthew G. Knepley ierr = PetscDSGetCoordinateDimension(prob, &cdim);CHKERRQ(ierr); 3101df3a45bdSMatthew G. Knepley ierr = PetscDSSetCoordinateDimension(prob->subprobs[height-1], cdim);CHKERRQ(ierr); 3102b1353e8eSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3103b1353e8eSMatthew G. Knepley PetscFE subfe; 3104b1353e8eSMatthew G. Knepley PetscObject obj; 3105b1353e8eSMatthew G. Knepley PetscClassId id; 3106b1353e8eSMatthew G. Knepley 3107b1353e8eSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3108b1353e8eSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3109b1353e8eSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetHeightSubspace((PetscFE) obj, height, &subfe);CHKERRQ(ierr);} 3110b1353e8eSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unsupported discretization type for field %d", f); 3111df3a45bdSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob->subprobs[height-1], f, (PetscObject) subfe);CHKERRQ(ierr); 3112b1353e8eSMatthew G. Knepley } 3113b1353e8eSMatthew G. Knepley } 3114df3a45bdSMatthew G. Knepley *subprob = prob->subprobs[height-1]; 3115b1353e8eSMatthew G. Knepley PetscFunctionReturn(0); 3116b1353e8eSMatthew G. Knepley } 3117b1353e8eSMatthew G. Knepley 3118bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 31192764a2aaSMatthew G. Knepley { 3120931fb3b8SToby Isaac PetscErrorCode ierr; 3121931fb3b8SToby Isaac 31222764a2aaSMatthew G. Knepley PetscFunctionBegin; 3123931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 31242764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31252764a2aaSMatthew G. Knepley } 31262764a2aaSMatthew G. Knepley 3127bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 31282764a2aaSMatthew G. Knepley { 31292764a2aaSMatthew G. Knepley PetscFunctionBegin; 31302764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 31312764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 31322764a2aaSMatthew G. Knepley prob->ops->view = NULL; 31332764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 31342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31352764a2aaSMatthew G. Knepley } 31362764a2aaSMatthew G. Knepley 31372764a2aaSMatthew G. Knepley /*MC 31382764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 31392764a2aaSMatthew G. Knepley 31402764a2aaSMatthew G. Knepley Level: intermediate 31412764a2aaSMatthew G. Knepley 31422764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 31432764a2aaSMatthew G. Knepley M*/ 31442764a2aaSMatthew G. Knepley 31452764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 31462764a2aaSMatthew G. Knepley { 31472764a2aaSMatthew G. Knepley PetscDS_Basic *b; 31482764a2aaSMatthew G. Knepley PetscErrorCode ierr; 31492764a2aaSMatthew G. Knepley 31502764a2aaSMatthew G. Knepley PetscFunctionBegin; 3151931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 31522764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 31532764a2aaSMatthew G. Knepley prob->data = b; 31542764a2aaSMatthew G. Knepley 31552764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 31562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 31572764a2aaSMatthew G. Knepley } 3158