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 #undef __FUNCT__ 92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister" 102764a2aaSMatthew G. Knepley /*@C 112764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 122764a2aaSMatthew G. Knepley 132764a2aaSMatthew G. Knepley Not Collective 142764a2aaSMatthew G. Knepley 152764a2aaSMatthew G. Knepley Input Parameters: 162764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 172764a2aaSMatthew G. Knepley - create_func - The creation routine itself 182764a2aaSMatthew G. Knepley 192764a2aaSMatthew G. Knepley Notes: 202764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 212764a2aaSMatthew G. Knepley 222764a2aaSMatthew G. Knepley Sample usage: 232764a2aaSMatthew G. Knepley .vb 242764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 252764a2aaSMatthew G. Knepley .ve 262764a2aaSMatthew G. Knepley 272764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 282764a2aaSMatthew G. Knepley .vb 292764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 302764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 312764a2aaSMatthew G. Knepley .ve 322764a2aaSMatthew G. Knepley or at runtime via the option 332764a2aaSMatthew G. Knepley .vb 342764a2aaSMatthew G. Knepley -petscds_type my_ds 352764a2aaSMatthew G. Knepley .ve 362764a2aaSMatthew G. Knepley 372764a2aaSMatthew G. Knepley Level: advanced 382764a2aaSMatthew G. Knepley 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 #undef __FUNCT__ 532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType" 542764a2aaSMatthew G. Knepley /*@C 552764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 562764a2aaSMatthew G. Knepley 572764a2aaSMatthew G. Knepley Collective on PetscDS 582764a2aaSMatthew G. Knepley 592764a2aaSMatthew G. Knepley Input Parameters: 602764a2aaSMatthew G. Knepley + prob - The PetscDS object 612764a2aaSMatthew G. Knepley - name - The kind of system 622764a2aaSMatthew G. Knepley 632764a2aaSMatthew G. Knepley Options Database Key: 642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 652764a2aaSMatthew G. Knepley 662764a2aaSMatthew G. Knepley Level: intermediate 672764a2aaSMatthew G. Knepley 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 #undef __FUNCT__ 962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetType" 972764a2aaSMatthew G. Knepley /*@C 982764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 992764a2aaSMatthew G. Knepley 1002764a2aaSMatthew G. Knepley Not Collective 1012764a2aaSMatthew G. Knepley 1022764a2aaSMatthew G. Knepley Input Parameter: 1032764a2aaSMatthew G. Knepley . prob - The PetscDS 1042764a2aaSMatthew G. Knepley 1052764a2aaSMatthew G. Knepley Output Parameter: 1062764a2aaSMatthew G. Knepley . name - The PetscDS type name 1072764a2aaSMatthew G. Knepley 1082764a2aaSMatthew G. Knepley Level: intermediate 1092764a2aaSMatthew G. Knepley 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 1252764a2aaSMatthew G. Knepley #undef __FUNCT__ 1267d8a60eaSMatthew G. Knepley #define __FUNCT__ "PetscDSView_Ascii" 1277d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1287d8a60eaSMatthew G. Knepley { 1297d8a60eaSMatthew G. Knepley PetscViewerFormat format; 1307d8a60eaSMatthew G. Knepley PetscInt f; 1317d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1327d8a60eaSMatthew G. Knepley 1337d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1347d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1357d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1367d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1377d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1387d8a60eaSMatthew G. Knepley PetscObject obj; 1397d8a60eaSMatthew G. Knepley PetscClassId id; 1407d8a60eaSMatthew G. Knepley const char *name; 1417d8a60eaSMatthew G. Knepley PetscInt Nc; 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); 1497d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1507d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1517d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 1527d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1537d8a60eaSMatthew G. Knepley } 1547d8a60eaSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 1557d8a60eaSMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%d components", Nc);CHKERRQ(ierr);} 1567d8a60eaSMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, "%d component ", Nc);CHKERRQ(ierr);} 157249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 158249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 159a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+0]) { 160a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);} 161a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);} 162a6cbbb48SMatthew G. Knepley } else { 163a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);} 164a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);} 165a6cbbb48SMatthew G. Knepley } 1667d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1677d8a60eaSMatthew G. Knepley if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) { 1687d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1697d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1707d8a60eaSMatthew G. Knepley } 1717d8a60eaSMatthew G. Knepley } 1727d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1737d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 1747d8a60eaSMatthew G. Knepley } 1757d8a60eaSMatthew G. Knepley 1767d8a60eaSMatthew G. Knepley #undef __FUNCT__ 1772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView" 1782764a2aaSMatthew G. Knepley /*@C 1792764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 1802764a2aaSMatthew G. Knepley 1812764a2aaSMatthew G. Knepley Collective on PetscDS 1822764a2aaSMatthew G. Knepley 1832764a2aaSMatthew G. Knepley Input Parameter: 1842764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 1852764a2aaSMatthew G. Knepley - v - the viewer 1862764a2aaSMatthew G. Knepley 1872764a2aaSMatthew G. Knepley Level: developer 1882764a2aaSMatthew G. Knepley 1892764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 1902764a2aaSMatthew G. Knepley @*/ 1912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 1922764a2aaSMatthew G. Knepley { 1937d8a60eaSMatthew G. Knepley PetscBool iascii; 1942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1952764a2aaSMatthew G. Knepley 1962764a2aaSMatthew G. Knepley PetscFunctionBegin; 1972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1982764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 1997d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2007d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2017d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2022764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2042764a2aaSMatthew G. Knepley } 2052764a2aaSMatthew G. Knepley 2062764a2aaSMatthew G. Knepley #undef __FUNCT__ 2072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions" 2082764a2aaSMatthew G. Knepley /*@ 2092764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2102764a2aaSMatthew G. Knepley 2112764a2aaSMatthew G. Knepley Collective on PetscDS 2122764a2aaSMatthew G. Knepley 2132764a2aaSMatthew G. Knepley Input Parameter: 2142764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2152764a2aaSMatthew G. Knepley 2162764a2aaSMatthew G. Knepley Options Database: 2172764a2aaSMatthew G. Knepley 2182764a2aaSMatthew G. Knepley Level: developer 2192764a2aaSMatthew G. Knepley 2202764a2aaSMatthew G. Knepley .seealso PetscDSView() 2212764a2aaSMatthew G. Knepley @*/ 2222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2232764a2aaSMatthew G. Knepley { 224f1fd5e65SToby Isaac DSBoundary b; 2252764a2aaSMatthew G. Knepley const char *defaultType; 2262764a2aaSMatthew G. Knepley char name[256]; 2272764a2aaSMatthew G. Knepley PetscBool flg; 2282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2292764a2aaSMatthew G. Knepley 2302764a2aaSMatthew G. Knepley PetscFunctionBegin; 2312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2322764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2332764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2342764a2aaSMatthew G. Knepley } else { 2352764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2362764a2aaSMatthew G. Knepley } 2370f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2382764a2aaSMatthew G. Knepley 2392764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 240f1fd5e65SToby Isaac for (b = prob->boundary; b; b = b->next) { 241f1fd5e65SToby Isaac char optname[1024]; 242f1fd5e65SToby Isaac PetscInt ids[1024], len = 1024; 243f1fd5e65SToby Isaac PetscBool flg; 244f1fd5e65SToby Isaac 245f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s", b->name);CHKERRQ(ierr); 246f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 247f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary IDs", "", ids, &len, &flg);CHKERRQ(ierr); 248f1fd5e65SToby Isaac if (flg) { 249f1fd5e65SToby Isaac b->numids = len; 250f1fd5e65SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 251f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->ids);CHKERRQ(ierr); 252f1fd5e65SToby Isaac ierr = PetscMemcpy(b->ids, ids, len*sizeof(PetscInt));CHKERRQ(ierr); 253f1fd5e65SToby Isaac } 254f1fd5e65SToby Isaac ierr = PetscSNPrintf(optname, sizeof(optname), "-bc_%s_comp", b->name);CHKERRQ(ierr); 255f1fd5e65SToby Isaac ierr = PetscMemzero(ids, sizeof(ids));CHKERRQ(ierr); 256f1fd5e65SToby Isaac ierr = PetscOptionsIntArray(optname, "List of boundary field components", "", ids, &len, &flg);CHKERRQ(ierr); 257f1fd5e65SToby Isaac if (flg) { 258f1fd5e65SToby Isaac b->numcomps = len; 259f1fd5e65SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 260f1fd5e65SToby Isaac ierr = PetscMalloc1(len, &b->comps);CHKERRQ(ierr); 261f1fd5e65SToby Isaac ierr = PetscMemcpy(b->comps, ids, len*sizeof(PetscInt));CHKERRQ(ierr); 262f1fd5e65SToby Isaac } 263f1fd5e65SToby Isaac } 2642764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2652764a2aaSMatthew G. Knepley if (flg) { 2662764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2672764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2682764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2692764a2aaSMatthew G. Knepley } 2702764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2712764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2720633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 2732764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2742764a2aaSMatthew G. Knepley ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr); 2752764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2762764a2aaSMatthew G. Knepley } 2772764a2aaSMatthew G. Knepley 2782764a2aaSMatthew G. Knepley #undef __FUNCT__ 2792764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp" 2802764a2aaSMatthew G. Knepley /*@C 2812764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2822764a2aaSMatthew G. Knepley 2832764a2aaSMatthew G. Knepley Collective on PetscDS 2842764a2aaSMatthew G. Knepley 2852764a2aaSMatthew G. Knepley Input Parameter: 2862764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 2872764a2aaSMatthew G. Knepley 2882764a2aaSMatthew G. Knepley Level: developer 2892764a2aaSMatthew G. Knepley 2902764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 2912764a2aaSMatthew G. Knepley @*/ 2922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 2932764a2aaSMatthew G. Knepley { 2942764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 2952764a2aaSMatthew G. Knepley PetscInt dim, work, NcMax = 0, NqMax = 0, f; 2962764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2972764a2aaSMatthew G. Knepley 2982764a2aaSMatthew G. Knepley PetscFunctionBegin; 2992764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3002764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3012764a2aaSMatthew G. Knepley /* Calculate sizes */ 3022764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3032764a2aaSMatthew G. Knepley prob->totDim = prob->totDimBd = prob->totComp = 0; 304194d53e6SMatthew G. Knepley ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr); 3052764a2aaSMatthew G. Knepley ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr); 3062764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3072764a2aaSMatthew G. Knepley PetscFE feBd = (PetscFE) prob->discBd[f]; 3089de99aefSMatthew G. Knepley PetscObject obj; 3099de99aefSMatthew G. Knepley PetscClassId id; 3102764a2aaSMatthew G. Knepley PetscQuadrature q; 3119de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3122764a2aaSMatthew G. Knepley 3139de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3149de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3159de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3169de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3179de99aefSMatthew G. Knepley 3182764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3192764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 3202764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 3212764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 3229de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 3239de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 3249de99aefSMatthew G. Knepley 3259de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3269de99aefSMatthew G. Knepley Nb = 1; 3279de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3286c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 329abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 330194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 331194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 3329de99aefSMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3332764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3342764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3352764a2aaSMatthew G. Knepley prob->totDim += Nb*Nc; 3362764a2aaSMatthew G. Knepley prob->totComp += Nc; 3372764a2aaSMatthew G. Knepley if (feBd) { 3382764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr); 3392764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr); 3402764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr); 3412764a2aaSMatthew G. Knepley prob->totDimBd += Nb*Nc; 342194d53e6SMatthew G. Knepley prob->offBd[f+1] = Nc + prob->offBd[f]; 343194d53e6SMatthew G. Knepley prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f]; 3442764a2aaSMatthew G. Knepley } 3452764a2aaSMatthew G. Knepley } 3462764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3472764a2aaSMatthew G. Knepley /* Allocate works space */ 3482764a2aaSMatthew G. Knepley ierr = PetscMalloc5(prob->totComp,&prob->u,prob->totComp,&prob->u_t,prob->totComp*dim,&prob->u_x,dim,&prob->x,work,&prob->refSpaceDer);CHKERRQ(ierr); 3492764a2aaSMatthew 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); 3502764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3512764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3522764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3532764a2aaSMatthew G. Knepley } 3542764a2aaSMatthew G. Knepley 3552764a2aaSMatthew G. Knepley #undef __FUNCT__ 3562764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static" 3572764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3582764a2aaSMatthew G. Knepley { 3592764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3602764a2aaSMatthew G. Knepley 3612764a2aaSMatthew G. Knepley PetscFunctionBegin; 362194d53e6SMatthew G. Knepley ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr); 3632764a2aaSMatthew G. Knepley ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr); 3642764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3652764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3672764a2aaSMatthew G. Knepley } 3682764a2aaSMatthew G. Knepley 3692764a2aaSMatthew G. Knepley #undef __FUNCT__ 3702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static" 3712764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3722764a2aaSMatthew G. Knepley { 3732764a2aaSMatthew G. Knepley PetscObject *tmpd, *tmpdbd; 374a6cbbb48SMatthew G. Knepley PetscBool *tmpi, *tmpa; 3752aa1fc23SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf; 376b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 3772aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 3782aa1fc23SMatthew G. Knepley PetscBdPointJac *tmpgbd; 379194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 3800c2f2876SMatthew G. Knepley void **tmpctx; 381a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3832764a2aaSMatthew G. Knepley 3842764a2aaSMatthew G. Knepley PetscFunctionBegin; 3852764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3862764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3872764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 388a6cbbb48SMatthew G. Knepley ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 389a6cbbb48SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpdbd[f] = prob->discBd[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];} 390a6cbbb48SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); 391a6cbbb48SMatthew G. Knepley tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 392a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 3932764a2aaSMatthew G. Knepley prob->Nf = NfNew; 3942764a2aaSMatthew G. Knepley prob->disc = tmpd; 395a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 396249df284SMatthew G. Knepley prob->implicit = tmpi; 397a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 398b7e05686SMatthew 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); 3992764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4002764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4012764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 402475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4030c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 4040c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4052764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4062764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4072764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 408475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 409b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4100c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 4110c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 412b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 4132764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4142764a2aaSMatthew G. Knepley prob->f = tmpf; 4152764a2aaSMatthew G. Knepley prob->g = tmpg; 416475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 417b7e05686SMatthew G. Knepley prob->gt = tmpgt; 4180c2f2876SMatthew G. Knepley prob->r = tmpr; 4190c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 4202764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 4212764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4222764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 4232764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4242764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4252764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4262764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4272764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4282764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4292764a2aaSMatthew G. Knepley } 4302764a2aaSMatthew G. Knepley 4312764a2aaSMatthew G. Knepley #undef __FUNCT__ 4322764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4332764a2aaSMatthew G. Knepley /*@ 4342764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4352764a2aaSMatthew G. Knepley 4362764a2aaSMatthew G. Knepley Collective on PetscDS 4372764a2aaSMatthew G. Knepley 4382764a2aaSMatthew G. Knepley Input Parameter: 4392764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4402764a2aaSMatthew G. Knepley 4412764a2aaSMatthew G. Knepley Level: developer 4422764a2aaSMatthew G. Knepley 4432764a2aaSMatthew G. Knepley .seealso PetscDSView() 4442764a2aaSMatthew G. Knepley @*/ 4452764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4462764a2aaSMatthew G. Knepley { 4472764a2aaSMatthew G. Knepley PetscInt f; 44858ebd649SToby Isaac DSBoundary next; 4492764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4502764a2aaSMatthew G. Knepley 4512764a2aaSMatthew G. Knepley PetscFunctionBegin; 4522764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4532764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4542764a2aaSMatthew G. Knepley 4552764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4562764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4572764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4582764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4592764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4602764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4612764a2aaSMatthew G. Knepley } 462a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 463b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4642764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4652764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 46658ebd649SToby Isaac next = (*prob)->boundary; 46758ebd649SToby Isaac while (next) { 46858ebd649SToby Isaac DSBoundary b = next; 46958ebd649SToby Isaac 47058ebd649SToby Isaac next = b->next; 47158ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 47258ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 47358ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 47458ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 47558ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 47658ebd649SToby Isaac } 4772764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4792764a2aaSMatthew G. Knepley } 4802764a2aaSMatthew G. Knepley 4812764a2aaSMatthew G. Knepley #undef __FUNCT__ 4822764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4832764a2aaSMatthew G. Knepley /*@ 4842764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4852764a2aaSMatthew G. Knepley 4862764a2aaSMatthew G. Knepley Collective on MPI_Comm 4872764a2aaSMatthew G. Knepley 4882764a2aaSMatthew G. Knepley Input Parameter: 4892764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4902764a2aaSMatthew G. Knepley 4912764a2aaSMatthew G. Knepley Output Parameter: 4922764a2aaSMatthew G. Knepley . prob - The PetscDS object 4932764a2aaSMatthew G. Knepley 4942764a2aaSMatthew G. Knepley Level: beginner 4952764a2aaSMatthew G. Knepley 4962764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4972764a2aaSMatthew G. Knepley @*/ 4982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4992764a2aaSMatthew G. Knepley { 5002764a2aaSMatthew G. Knepley PetscDS p; 5012764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5022764a2aaSMatthew G. Knepley 5032764a2aaSMatthew G. Knepley PetscFunctionBegin; 5042764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 5052764a2aaSMatthew G. Knepley *prob = NULL; 5062764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5072764a2aaSMatthew G. Knepley 50873107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5092764a2aaSMatthew G. Knepley 5102764a2aaSMatthew G. Knepley p->Nf = 0; 5112764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 5122764a2aaSMatthew G. Knepley 5132764a2aaSMatthew G. Knepley *prob = p; 5142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5152764a2aaSMatthew G. Knepley } 5162764a2aaSMatthew G. Knepley 5172764a2aaSMatthew G. Knepley #undef __FUNCT__ 5182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 519bc4ae4beSMatthew G. Knepley /*@ 520bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 521bc4ae4beSMatthew G. Knepley 522bc4ae4beSMatthew G. Knepley Not collective 523bc4ae4beSMatthew G. Knepley 524bc4ae4beSMatthew G. Knepley Input Parameter: 525bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 526bc4ae4beSMatthew G. Knepley 527bc4ae4beSMatthew G. Knepley Output Parameter: 528bc4ae4beSMatthew G. Knepley . Nf - The number of fields 529bc4ae4beSMatthew G. Knepley 530bc4ae4beSMatthew G. Knepley Level: beginner 531bc4ae4beSMatthew G. Knepley 532bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 533bc4ae4beSMatthew G. Knepley @*/ 5342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5352764a2aaSMatthew G. Knepley { 5362764a2aaSMatthew G. Knepley PetscFunctionBegin; 5372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5382764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5392764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5412764a2aaSMatthew G. Knepley } 5422764a2aaSMatthew G. Knepley 5432764a2aaSMatthew G. Knepley #undef __FUNCT__ 5442764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 545bc4ae4beSMatthew G. Knepley /*@ 546bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 547bc4ae4beSMatthew G. Knepley 548bc4ae4beSMatthew G. Knepley Not collective 549bc4ae4beSMatthew G. Knepley 550bc4ae4beSMatthew G. Knepley Input Parameter: 551bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 552bc4ae4beSMatthew G. Knepley 553bc4ae4beSMatthew G. Knepley Output Parameter: 554bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 555bc4ae4beSMatthew G. Knepley 556bc4ae4beSMatthew G. Knepley Level: beginner 557bc4ae4beSMatthew G. Knepley 558bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 559bc4ae4beSMatthew G. Knepley @*/ 5602764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5612764a2aaSMatthew G. Knepley { 5622764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5632764a2aaSMatthew G. Knepley 5642764a2aaSMatthew G. Knepley PetscFunctionBegin; 5652764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5662764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5672764a2aaSMatthew G. Knepley *dim = 0; 5689de99aefSMatthew G. Knepley if (prob->Nf) { 5699de99aefSMatthew G. Knepley PetscObject obj; 5709de99aefSMatthew G. Knepley PetscClassId id; 5719de99aefSMatthew G. Knepley 5729de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5739de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5749de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5759de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5769de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5779de99aefSMatthew G. Knepley } 5782764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5792764a2aaSMatthew G. Knepley } 5802764a2aaSMatthew G. Knepley 5812764a2aaSMatthew G. Knepley #undef __FUNCT__ 5822764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 583bc4ae4beSMatthew G. Knepley /*@ 584bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 585bc4ae4beSMatthew G. Knepley 586bc4ae4beSMatthew G. Knepley Not collective 587bc4ae4beSMatthew G. Knepley 588bc4ae4beSMatthew G. Knepley Input Parameter: 589bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 590bc4ae4beSMatthew G. Knepley 591bc4ae4beSMatthew G. Knepley Output Parameter: 592bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 593bc4ae4beSMatthew G. Knepley 594bc4ae4beSMatthew G. Knepley Level: beginner 595bc4ae4beSMatthew G. Knepley 596bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 597bc4ae4beSMatthew G. Knepley @*/ 5982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5992764a2aaSMatthew G. Knepley { 6002764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6012764a2aaSMatthew G. Knepley 6022764a2aaSMatthew G. Knepley PetscFunctionBegin; 6032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6042764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6052764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6062764a2aaSMatthew G. Knepley *dim = prob->totDim; 6072764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6082764a2aaSMatthew G. Knepley } 6092764a2aaSMatthew G. Knepley 6102764a2aaSMatthew G. Knepley #undef __FUNCT__ 6112764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 612bc4ae4beSMatthew G. Knepley /*@ 613c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 614bc4ae4beSMatthew G. Knepley 615bc4ae4beSMatthew G. Knepley Not collective 616bc4ae4beSMatthew G. Knepley 617bc4ae4beSMatthew G. Knepley Input Parameter: 618bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 619bc4ae4beSMatthew G. Knepley 620bc4ae4beSMatthew G. Knepley Output Parameter: 621bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 622bc4ae4beSMatthew G. Knepley 623bc4ae4beSMatthew G. Knepley Level: beginner 624bc4ae4beSMatthew G. Knepley 625bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 626bc4ae4beSMatthew G. Knepley @*/ 6272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6282764a2aaSMatthew G. Knepley { 6292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6302764a2aaSMatthew G. Knepley 6312764a2aaSMatthew G. Knepley PetscFunctionBegin; 6322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6332764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6342764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6352764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6362764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6372764a2aaSMatthew G. Knepley } 6382764a2aaSMatthew G. Knepley 6392764a2aaSMatthew G. Knepley #undef __FUNCT__ 6402764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 641bc4ae4beSMatthew G. Knepley /*@ 642bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 643bc4ae4beSMatthew G. Knepley 644bc4ae4beSMatthew G. Knepley Not collective 645bc4ae4beSMatthew G. Knepley 646bc4ae4beSMatthew G. Knepley Input Parameter: 647bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 648bc4ae4beSMatthew G. Knepley 649bc4ae4beSMatthew G. Knepley Output Parameter: 650bc4ae4beSMatthew G. Knepley . dim - The total number of components 651bc4ae4beSMatthew G. Knepley 652bc4ae4beSMatthew G. Knepley Level: beginner 653bc4ae4beSMatthew G. Knepley 654bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 655bc4ae4beSMatthew G. Knepley @*/ 6562764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6572764a2aaSMatthew G. Knepley { 6582764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6592764a2aaSMatthew G. Knepley 6602764a2aaSMatthew G. Knepley PetscFunctionBegin; 6612764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6622764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6632764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6642764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6652764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6662764a2aaSMatthew G. Knepley } 6672764a2aaSMatthew G. Knepley 6682764a2aaSMatthew G. Knepley #undef __FUNCT__ 6692764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 670bc4ae4beSMatthew G. Knepley /*@ 671bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 672bc4ae4beSMatthew G. Knepley 673bc4ae4beSMatthew G. Knepley Not collective 674bc4ae4beSMatthew G. Knepley 675bc4ae4beSMatthew G. Knepley Input Parameters: 676bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 677bc4ae4beSMatthew G. Knepley - f - The field number 678bc4ae4beSMatthew G. Knepley 679bc4ae4beSMatthew G. Knepley Output Parameter: 680bc4ae4beSMatthew G. Knepley . disc - The discretization object 681bc4ae4beSMatthew G. Knepley 682bc4ae4beSMatthew G. Knepley Level: beginner 683bc4ae4beSMatthew G. Knepley 684bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 685bc4ae4beSMatthew G. Knepley @*/ 6862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6872764a2aaSMatthew G. Knepley { 6882764a2aaSMatthew G. Knepley PetscFunctionBegin; 6892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6902764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6912764a2aaSMatthew 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); 6922764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6942764a2aaSMatthew G. Knepley } 6952764a2aaSMatthew G. Knepley 6962764a2aaSMatthew G. Knepley #undef __FUNCT__ 6972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 698bc4ae4beSMatthew G. Knepley /*@ 699bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 700bc4ae4beSMatthew G. Knepley 701bc4ae4beSMatthew G. Knepley Not collective 702bc4ae4beSMatthew G. Knepley 703bc4ae4beSMatthew G. Knepley Input Parameters: 704bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 705bc4ae4beSMatthew G. Knepley - f - The field number 706bc4ae4beSMatthew G. Knepley 707bc4ae4beSMatthew G. Knepley Output Parameter: 708bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 709bc4ae4beSMatthew G. Knepley 710bc4ae4beSMatthew G. Knepley Level: beginner 711bc4ae4beSMatthew G. Knepley 712bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 713bc4ae4beSMatthew G. Knepley @*/ 7142764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7152764a2aaSMatthew G. Knepley { 7162764a2aaSMatthew G. Knepley PetscFunctionBegin; 7172764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7182764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7192764a2aaSMatthew 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); 7202764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 7212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7222764a2aaSMatthew G. Knepley } 7232764a2aaSMatthew G. Knepley 7242764a2aaSMatthew G. Knepley #undef __FUNCT__ 7252764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 726bc4ae4beSMatthew G. Knepley /*@ 727bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 728bc4ae4beSMatthew G. Knepley 729bc4ae4beSMatthew G. Knepley Not collective 730bc4ae4beSMatthew G. Knepley 731bc4ae4beSMatthew G. Knepley Input Parameters: 732bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 733bc4ae4beSMatthew G. Knepley . f - The field number 734bc4ae4beSMatthew G. Knepley - disc - The discretization object 735bc4ae4beSMatthew G. Knepley 736bc4ae4beSMatthew G. Knepley Level: beginner 737bc4ae4beSMatthew G. Knepley 738bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 739bc4ae4beSMatthew G. Knepley @*/ 7402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7412764a2aaSMatthew G. Knepley { 7422764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7432764a2aaSMatthew G. Knepley 7442764a2aaSMatthew G. Knepley PetscFunctionBegin; 7452764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7462764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7472764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7482764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7492764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7502764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7512764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 752249df284SMatthew G. Knepley { 753249df284SMatthew G. Knepley PetscClassId id; 754249df284SMatthew G. Knepley 755249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 756a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 757a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 758a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 759a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 760a6cbbb48SMatthew G. Knepley } 761249df284SMatthew G. Knepley } 7622764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7632764a2aaSMatthew G. Knepley } 7642764a2aaSMatthew G. Knepley 7652764a2aaSMatthew G. Knepley #undef __FUNCT__ 7662764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 767bc4ae4beSMatthew G. Knepley /*@ 768bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 769bc4ae4beSMatthew G. Knepley 770bc4ae4beSMatthew G. Knepley Not collective 771bc4ae4beSMatthew G. Knepley 772bc4ae4beSMatthew G. Knepley Input Parameters: 773bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 774bc4ae4beSMatthew G. Knepley . f - The field number 775bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 776bc4ae4beSMatthew G. Knepley 777bc4ae4beSMatthew G. Knepley Level: beginner 778bc4ae4beSMatthew G. Knepley 779bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 780bc4ae4beSMatthew G. Knepley @*/ 7812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7822764a2aaSMatthew G. Knepley { 7832764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7842764a2aaSMatthew G. Knepley 7852764a2aaSMatthew G. Knepley PetscFunctionBegin; 7862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7872764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7882764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7892764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7902764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7912764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7922764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7942764a2aaSMatthew G. Knepley } 7952764a2aaSMatthew G. Knepley 7962764a2aaSMatthew G. Knepley #undef __FUNCT__ 7972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 798bc4ae4beSMatthew G. Knepley /*@ 799bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 800bc4ae4beSMatthew G. Knepley 801bc4ae4beSMatthew G. Knepley Not collective 802bc4ae4beSMatthew G. Knepley 803bc4ae4beSMatthew G. Knepley Input Parameters: 804bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 805bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 806bc4ae4beSMatthew G. Knepley 807bc4ae4beSMatthew G. Knepley Level: beginner 808bc4ae4beSMatthew G. Knepley 809bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 810bc4ae4beSMatthew G. Knepley @*/ 8112764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8122764a2aaSMatthew G. Knepley { 8132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8142764a2aaSMatthew G. Knepley 8152764a2aaSMatthew G. Knepley PetscFunctionBegin; 8162764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8182764a2aaSMatthew G. Knepley } 8192764a2aaSMatthew G. Knepley 8202764a2aaSMatthew G. Knepley #undef __FUNCT__ 8212764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 822bc4ae4beSMatthew G. Knepley /*@ 823bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley Not collective 826bc4ae4beSMatthew G. Knepley 827bc4ae4beSMatthew G. Knepley Input Parameters: 828bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 829bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 830bc4ae4beSMatthew G. Knepley 831bc4ae4beSMatthew G. Knepley Level: beginner 832bc4ae4beSMatthew G. Knepley 833bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 834bc4ae4beSMatthew G. Knepley @*/ 8352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8362764a2aaSMatthew G. Knepley { 8372764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8382764a2aaSMatthew G. Knepley 8392764a2aaSMatthew G. Knepley PetscFunctionBegin; 8402764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8422764a2aaSMatthew G. Knepley } 8432764a2aaSMatthew G. Knepley 8442764a2aaSMatthew G. Knepley #undef __FUNCT__ 845249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 846249df284SMatthew G. Knepley /*@ 847249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 848249df284SMatthew G. Knepley 849249df284SMatthew G. Knepley Not collective 850249df284SMatthew G. Knepley 851249df284SMatthew G. Knepley Input Parameters: 852249df284SMatthew G. Knepley + prob - The PetscDS object 853249df284SMatthew G. Knepley - f - The field number 854249df284SMatthew G. Knepley 855249df284SMatthew G. Knepley Output Parameter: 856249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 857249df284SMatthew G. Knepley 858249df284SMatthew G. Knepley Level: developer 859249df284SMatthew G. Knepley 860249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 861249df284SMatthew G. Knepley @*/ 862249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 863249df284SMatthew G. Knepley { 864249df284SMatthew G. Knepley PetscFunctionBegin; 865249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 866249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 867249df284SMatthew 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); 868249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 869249df284SMatthew G. Knepley PetscFunctionReturn(0); 870249df284SMatthew G. Knepley } 871249df284SMatthew G. Knepley 872249df284SMatthew G. Knepley #undef __FUNCT__ 873249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 874249df284SMatthew G. Knepley /*@ 875249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 876249df284SMatthew G. Knepley 877249df284SMatthew G. Knepley Not collective 878249df284SMatthew G. Knepley 879249df284SMatthew G. Knepley Input Parameters: 880249df284SMatthew G. Knepley + prob - The PetscDS object 881249df284SMatthew G. Knepley . f - The field number 882249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 883249df284SMatthew G. Knepley 884249df284SMatthew G. Knepley Level: developer 885249df284SMatthew G. Knepley 886249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 887249df284SMatthew G. Knepley @*/ 888249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 889249df284SMatthew G. Knepley { 890249df284SMatthew G. Knepley PetscFunctionBegin; 891249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 892249df284SMatthew 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); 893249df284SMatthew G. Knepley prob->implicit[f] = implicit; 894249df284SMatthew G. Knepley PetscFunctionReturn(0); 895249df284SMatthew G. Knepley } 896249df284SMatthew G. Knepley 897249df284SMatthew G. Knepley #undef __FUNCT__ 898a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 899a6cbbb48SMatthew G. Knepley /*@ 900a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 901a6cbbb48SMatthew G. Knepley 902a6cbbb48SMatthew G. Knepley Not collective 903a6cbbb48SMatthew G. Knepley 904a6cbbb48SMatthew G. Knepley Input Parameters: 905a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 906a6cbbb48SMatthew G. Knepley - f - The field number 907a6cbbb48SMatthew G. Knepley 908a6cbbb48SMatthew G. Knepley Output Parameter: 909a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 910a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 911a6cbbb48SMatthew G. Knepley 912a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 913a6cbbb48SMatthew G. Knepley 914a6cbbb48SMatthew G. Knepley Level: developer 915a6cbbb48SMatthew G. Knepley 916a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 917a6cbbb48SMatthew G. Knepley @*/ 918a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 919a6cbbb48SMatthew G. Knepley { 920a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 921a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 922a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 923a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 924a6cbbb48SMatthew 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); 925a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 926a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 927a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 928a6cbbb48SMatthew G. Knepley } 929a6cbbb48SMatthew G. Knepley 930a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 931a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 932a6cbbb48SMatthew G. Knepley /*@ 933a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 934a6cbbb48SMatthew G. Knepley 935a6cbbb48SMatthew G. Knepley Not collective 936a6cbbb48SMatthew G. Knepley 937a6cbbb48SMatthew G. Knepley Input Parameters: 938a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 939a6cbbb48SMatthew G. Knepley . f - The field number 940a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 941a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 942a6cbbb48SMatthew G. Knepley 943a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 944a6cbbb48SMatthew G. Knepley 945a6cbbb48SMatthew G. Knepley Level: developer 946a6cbbb48SMatthew G. Knepley 947a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 948a6cbbb48SMatthew G. Knepley @*/ 949a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 950a6cbbb48SMatthew G. Knepley { 951a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 952a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 953a6cbbb48SMatthew 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); 954a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 955a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 956a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 957a6cbbb48SMatthew G. Knepley } 958a6cbbb48SMatthew G. Knepley 959a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 96230b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 963194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 964194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 96530b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9662764a2aaSMatthew G. Knepley { 9672764a2aaSMatthew G. Knepley PetscFunctionBegin; 9682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9692764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9702764a2aaSMatthew 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); 9712764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9732764a2aaSMatthew G. Knepley } 9742764a2aaSMatthew G. Knepley 9752764a2aaSMatthew G. Knepley #undef __FUNCT__ 9762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 97830b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 979194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 980194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 98130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9822764a2aaSMatthew G. Knepley { 9832764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9842764a2aaSMatthew G. Knepley 9852764a2aaSMatthew G. Knepley PetscFunctionBegin; 9862764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 987de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9882764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9892764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9902764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9912764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9922764a2aaSMatthew G. Knepley } 9932764a2aaSMatthew G. Knepley 9942764a2aaSMatthew G. Knepley #undef __FUNCT__ 9952764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 996194d53e6SMatthew G. Knepley /*@C 997194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew G. Knepley Not collective 1000194d53e6SMatthew G. Knepley 1001194d53e6SMatthew G. Knepley Input Parameters: 1002194d53e6SMatthew G. Knepley + prob - The PetscDS 1003194d53e6SMatthew G. Knepley - f - The test field number 1004194d53e6SMatthew G. Knepley 1005194d53e6SMatthew G. Knepley Output Parameters: 1006194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1007194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1008194d53e6SMatthew G. Knepley 1009194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1010194d53e6SMatthew G. Knepley 1011194d53e6SMatthew 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) 1012194d53e6SMatthew G. Knepley 1013194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1014194d53e6SMatthew G. Knepley 101530b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1016194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1017194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1019194d53e6SMatthew G. Knepley 1020194d53e6SMatthew G. Knepley + dim - the spatial dimension 1021194d53e6SMatthew G. Knepley . Nf - the number of fields 1022194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1023194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1024194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1025194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1026194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1027194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1028194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1029194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1030194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1031194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1032194d53e6SMatthew G. Knepley . t - current time 1033194d53e6SMatthew G. Knepley . x - coordinates of the current point 1034194d53e6SMatthew G. Knepley - f0 - output values at the current point 1035194d53e6SMatthew G. Knepley 1036194d53e6SMatthew G. Knepley Level: intermediate 1037194d53e6SMatthew G. Knepley 1038194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1039194d53e6SMatthew G. Knepley @*/ 10402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 104130b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1042194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1043194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104430b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 104530b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1046194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1047194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104830b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10492764a2aaSMatthew G. Knepley { 10502764a2aaSMatthew G. Knepley PetscFunctionBegin; 10512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10522764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 10532764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10542764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10562764a2aaSMatthew G. Knepley } 10572764a2aaSMatthew G. Knepley 10582764a2aaSMatthew G. Knepley #undef __FUNCT__ 10592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1060194d53e6SMatthew G. Knepley /*@C 1061194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew G. Knepley Not collective 1064194d53e6SMatthew G. Knepley 1065194d53e6SMatthew G. Knepley Input Parameters: 1066194d53e6SMatthew G. Knepley + prob - The PetscDS 1067194d53e6SMatthew G. Knepley . f - The test field number 1068194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1069194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1070194d53e6SMatthew G. Knepley 1071194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1072194d53e6SMatthew G. Knepley 1073194d53e6SMatthew 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) 1074194d53e6SMatthew G. Knepley 1075194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1076194d53e6SMatthew G. Knepley 107730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1078194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1079194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1081194d53e6SMatthew G. Knepley 1082194d53e6SMatthew G. Knepley + dim - the spatial dimension 1083194d53e6SMatthew G. Knepley . Nf - the number of fields 1084194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1085194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1086194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1087194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1088194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1089194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1090194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1091194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1092194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1093194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1094194d53e6SMatthew G. Knepley . t - current time 1095194d53e6SMatthew G. Knepley . x - coordinates of the current point 1096194d53e6SMatthew G. Knepley - f0 - output values at the current point 1097194d53e6SMatthew G. Knepley 1098194d53e6SMatthew G. Knepley Level: intermediate 1099194d53e6SMatthew G. Knepley 1100194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1101194d53e6SMatthew G. Knepley @*/ 11022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 110330b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1104194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1105194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110630b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 110730b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1108194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1109194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 111030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 11112764a2aaSMatthew G. Knepley { 11122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11132764a2aaSMatthew G. Knepley 11142764a2aaSMatthew G. Knepley PetscFunctionBegin; 11152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1116f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1117f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11182764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11192764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11202764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11212764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11232764a2aaSMatthew G. Knepley } 11242764a2aaSMatthew G. Knepley 11252764a2aaSMatthew G. Knepley #undef __FUNCT__ 11263e75805dSMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobian" 11273e75805dSMatthew G. Knepley /*@C 11283e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11293e75805dSMatthew G. Knepley 11303e75805dSMatthew G. Knepley Not collective 11313e75805dSMatthew G. Knepley 11323e75805dSMatthew G. Knepley Input Parameter: 11333e75805dSMatthew G. Knepley . prob - The PetscDS 11343e75805dSMatthew G. Knepley 11353e75805dSMatthew G. Knepley Output Parameter: 11363e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11373e75805dSMatthew G. Knepley 11383e75805dSMatthew G. Knepley Level: intermediate 11393e75805dSMatthew G. Knepley 11403e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11413e75805dSMatthew G. Knepley @*/ 11423e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11433e75805dSMatthew G. Knepley { 11443e75805dSMatthew G. Knepley PetscInt f, g, h; 11453e75805dSMatthew G. Knepley 11463e75805dSMatthew G. Knepley PetscFunctionBegin; 11473e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11483e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11493e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11503e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11513e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11523e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11533e75805dSMatthew G. Knepley } 11543e75805dSMatthew G. Knepley } 11553e75805dSMatthew G. Knepley } 11563e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11573e75805dSMatthew G. Knepley } 11583e75805dSMatthew G. Knepley 11593e75805dSMatthew G. Knepley #undef __FUNCT__ 11602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1161194d53e6SMatthew G. Knepley /*@C 1162194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1163194d53e6SMatthew G. Knepley 1164194d53e6SMatthew G. Knepley Not collective 1165194d53e6SMatthew G. Knepley 1166194d53e6SMatthew G. Knepley Input Parameters: 1167194d53e6SMatthew G. Knepley + prob - The PetscDS 1168194d53e6SMatthew G. Knepley . f - The test field number 1169194d53e6SMatthew G. Knepley - g - The field number 1170194d53e6SMatthew G. Knepley 1171194d53e6SMatthew G. Knepley Output Parameters: 1172194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1173194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1174194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1175194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1176194d53e6SMatthew G. Knepley 1177194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1178194d53e6SMatthew G. Knepley 1179194d53e6SMatthew 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 1180194d53e6SMatthew G. Knepley 1181194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1182194d53e6SMatthew G. Knepley 118330b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1184194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1185194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 118630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1187194d53e6SMatthew G. Knepley 1188194d53e6SMatthew G. Knepley + dim - the spatial dimension 1189194d53e6SMatthew G. Knepley . Nf - the number of fields 1190194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1191194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1192194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1193194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1194194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1195194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1196194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1197194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1198194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1199194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1200194d53e6SMatthew G. Knepley . t - current time 12012aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1202194d53e6SMatthew G. Knepley . x - coordinates of the current point 1203194d53e6SMatthew G. Knepley - g0 - output values at the current point 1204194d53e6SMatthew G. Knepley 1205194d53e6SMatthew G. Knepley Level: intermediate 1206194d53e6SMatthew G. Knepley 1207194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1208194d53e6SMatthew G. Knepley @*/ 12092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 121030b9ff8bSMatthew G. Knepley void (**g0)(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[], 12132aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 121430b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1215194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1216194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12172aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 121830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1219194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1220194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12212aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 122230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1223194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1224194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12252aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12262764a2aaSMatthew G. Knepley { 12272764a2aaSMatthew G. Knepley PetscFunctionBegin; 12282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12292764a2aaSMatthew 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); 12302764a2aaSMatthew 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); 12312764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12322764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12332764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12342764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12362764a2aaSMatthew G. Knepley } 12372764a2aaSMatthew G. Knepley 12382764a2aaSMatthew G. Knepley #undef __FUNCT__ 12392764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1240194d53e6SMatthew G. Knepley /*@C 1241194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1242194d53e6SMatthew G. Knepley 1243194d53e6SMatthew G. Knepley Not collective 1244194d53e6SMatthew G. Knepley 1245194d53e6SMatthew G. Knepley Input Parameters: 1246194d53e6SMatthew G. Knepley + prob - The PetscDS 1247194d53e6SMatthew G. Knepley . f - The test field number 1248194d53e6SMatthew G. Knepley . g - The field number 1249194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1250194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1251194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1252194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1253194d53e6SMatthew G. Knepley 1254194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1255194d53e6SMatthew G. Knepley 1256194d53e6SMatthew 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 1257194d53e6SMatthew G. Knepley 1258194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1259194d53e6SMatthew G. Knepley 126030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1261194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1262194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 126330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1264194d53e6SMatthew G. Knepley 1265194d53e6SMatthew G. Knepley + dim - the spatial dimension 1266194d53e6SMatthew G. Knepley . Nf - the number of fields 1267194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1268194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1269194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1270194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1271194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1272194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1273194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1274194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1275194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1276194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1277194d53e6SMatthew G. Knepley . t - current time 12782aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1279194d53e6SMatthew G. Knepley . x - coordinates of the current point 1280194d53e6SMatthew G. Knepley - g0 - output values at the current point 1281194d53e6SMatthew G. Knepley 1282194d53e6SMatthew G. Knepley Level: intermediate 1283194d53e6SMatthew G. Knepley 1284194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1285194d53e6SMatthew G. Knepley @*/ 12862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 128730b9ff8bSMatthew G. Knepley void (*g0)(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[], 129030b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 129130b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1292194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1293194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129430b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 129530b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1296194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1297194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129830b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 129930b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1300194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1301194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 130230b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 13032764a2aaSMatthew G. Knepley { 13042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13052764a2aaSMatthew G. Knepley 13062764a2aaSMatthew G. Knepley PetscFunctionBegin; 13072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13082764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 13092764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 13102764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 13112764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13132764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13142764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13152764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13162764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13172764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13182764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13202764a2aaSMatthew G. Knepley } 13212764a2aaSMatthew G. Knepley 13222764a2aaSMatthew G. Knepley #undef __FUNCT__ 1323475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobianPreconditioner" 1324475e0ac9SMatthew G. Knepley /*@C 1325475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1326475e0ac9SMatthew G. Knepley 1327475e0ac9SMatthew G. Knepley Not collective 1328475e0ac9SMatthew G. Knepley 1329475e0ac9SMatthew G. Knepley Input Parameter: 1330475e0ac9SMatthew G. Knepley . prob - The PetscDS 1331475e0ac9SMatthew G. Knepley 1332475e0ac9SMatthew G. Knepley Output Parameter: 1333475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1334475e0ac9SMatthew G. Knepley 1335475e0ac9SMatthew G. Knepley Level: intermediate 1336475e0ac9SMatthew G. Knepley 1337475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1338475e0ac9SMatthew G. Knepley @*/ 1339475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1340475e0ac9SMatthew G. Knepley { 1341475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1342475e0ac9SMatthew G. Knepley 1343475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1344475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1345475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 1346475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1347475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1348475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1349475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1350475e0ac9SMatthew G. Knepley } 1351475e0ac9SMatthew G. Knepley } 1352475e0ac9SMatthew G. Knepley } 1353475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1354475e0ac9SMatthew G. Knepley } 1355475e0ac9SMatthew G. Knepley 1356475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1357475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobianPreconditioner" 1358475e0ac9SMatthew G. Knepley /*@C 1359475e0ac9SMatthew 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. 1360475e0ac9SMatthew G. Knepley 1361475e0ac9SMatthew G. Knepley Not collective 1362475e0ac9SMatthew G. Knepley 1363475e0ac9SMatthew G. Knepley Input Parameters: 1364475e0ac9SMatthew G. Knepley + prob - The PetscDS 1365475e0ac9SMatthew G. Knepley . f - The test field number 1366475e0ac9SMatthew G. Knepley - g - The field number 1367475e0ac9SMatthew G. Knepley 1368475e0ac9SMatthew G. Knepley Output Parameters: 1369475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1370475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1371475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1372475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1373475e0ac9SMatthew G. Knepley 1374475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1375475e0ac9SMatthew G. Knepley 1376475e0ac9SMatthew 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 1377475e0ac9SMatthew G. Knepley 1378475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1379475e0ac9SMatthew G. Knepley 1380475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1381475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1382475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1383475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1384475e0ac9SMatthew G. Knepley 1385475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1386475e0ac9SMatthew G. Knepley . Nf - the number of fields 1387475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1388475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1389475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1390475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1391475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1392475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1393475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1394475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1395475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1396475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1397475e0ac9SMatthew G. Knepley . t - current time 1398475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1399475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1400475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1401475e0ac9SMatthew G. Knepley 1402475e0ac9SMatthew G. Knepley Level: intermediate 1403475e0ac9SMatthew G. Knepley 1404475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1405475e0ac9SMatthew G. Knepley @*/ 1406475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1407475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1408475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1409475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1410475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1411475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1412475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1413475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1414475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1415475e0ac9SMatthew G. Knepley void (**g2)(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[], 1418475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1419475e0ac9SMatthew G. Knepley void (**g3)(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[], 1422475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1423475e0ac9SMatthew G. Knepley { 1424475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1425475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1426475e0ac9SMatthew 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); 1427475e0ac9SMatthew 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); 1428475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1429475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1430475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1431475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1432475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1433475e0ac9SMatthew G. Knepley } 1434475e0ac9SMatthew G. Knepley 1435475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1436475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobianPreconditioner" 1437475e0ac9SMatthew G. Knepley /*@C 1438475e0ac9SMatthew 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. 1439475e0ac9SMatthew G. Knepley 1440475e0ac9SMatthew G. Knepley Not collective 1441475e0ac9SMatthew G. Knepley 1442475e0ac9SMatthew G. Knepley Input Parameters: 1443475e0ac9SMatthew G. Knepley + prob - The PetscDS 1444475e0ac9SMatthew G. Knepley . f - The test field number 1445475e0ac9SMatthew G. Knepley . g - The field number 1446475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1447475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1448475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1449475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1450475e0ac9SMatthew G. Knepley 1451475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1452475e0ac9SMatthew G. Knepley 1453475e0ac9SMatthew 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 1454475e0ac9SMatthew G. Knepley 1455475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1456475e0ac9SMatthew G. Knepley 1457475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1458475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1459475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1460475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1461475e0ac9SMatthew G. Knepley 1462475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1463475e0ac9SMatthew G. Knepley . Nf - the number of fields 1464475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1465475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1466475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1467475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1468475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1469475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1470475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1471475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1472475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1473475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1474475e0ac9SMatthew G. Knepley . t - current time 1475475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1476475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1477475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1478475e0ac9SMatthew G. Knepley 1479475e0ac9SMatthew G. Knepley Level: intermediate 1480475e0ac9SMatthew G. Knepley 1481475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1482475e0ac9SMatthew G. Knepley @*/ 1483475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1484475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1485475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1486475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1487475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1488475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1489475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1490475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1491475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1492475e0ac9SMatthew G. Knepley void (*g2)(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[], 1495475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1496475e0ac9SMatthew G. Knepley void (*g3)(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[], 1499475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1500475e0ac9SMatthew G. Knepley { 1501475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1502475e0ac9SMatthew G. Knepley 1503475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1504475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1505475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1506475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1507475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1508475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1509475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1510475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1511475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1512475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1513475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1514475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1515475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1516475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1517475e0ac9SMatthew G. Knepley } 1518475e0ac9SMatthew G. Knepley 1519475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1520b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSHasDynamicJacobian" 1521b7e05686SMatthew G. Knepley /*@C 1522b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1523b7e05686SMatthew G. Knepley 1524b7e05686SMatthew G. Knepley Not collective 1525b7e05686SMatthew G. Knepley 1526b7e05686SMatthew G. Knepley Input Parameter: 1527b7e05686SMatthew G. Knepley . prob - The PetscDS 1528b7e05686SMatthew G. Knepley 1529b7e05686SMatthew G. Knepley Output Parameter: 1530b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1531b7e05686SMatthew G. Knepley 1532b7e05686SMatthew G. Knepley Level: intermediate 1533b7e05686SMatthew G. Knepley 1534b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1535b7e05686SMatthew G. Knepley @*/ 1536b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1537b7e05686SMatthew G. Knepley { 1538b7e05686SMatthew G. Knepley PetscInt f, g, h; 1539b7e05686SMatthew G. Knepley 1540b7e05686SMatthew G. Knepley PetscFunctionBegin; 1541b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1542b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1543b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1544b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1545b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1546b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1547b7e05686SMatthew G. Knepley } 1548b7e05686SMatthew G. Knepley } 1549b7e05686SMatthew G. Knepley } 1550b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1551b7e05686SMatthew G. Knepley } 1552b7e05686SMatthew G. Knepley 1553b7e05686SMatthew G. Knepley #undef __FUNCT__ 1554b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSGetDynamicJacobian" 1555b7e05686SMatthew G. Knepley /*@C 1556b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1557b7e05686SMatthew G. Knepley 1558b7e05686SMatthew G. Knepley Not collective 1559b7e05686SMatthew G. Knepley 1560b7e05686SMatthew G. Knepley Input Parameters: 1561b7e05686SMatthew G. Knepley + prob - The PetscDS 1562b7e05686SMatthew G. Knepley . f - The test field number 1563b7e05686SMatthew G. Knepley - g - The field number 1564b7e05686SMatthew G. Knepley 1565b7e05686SMatthew G. Knepley Output Parameters: 1566b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1567b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1568b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1569b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1570b7e05686SMatthew G. Knepley 1571b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1572b7e05686SMatthew G. Knepley 1573b7e05686SMatthew 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 1574b7e05686SMatthew G. Knepley 1575b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1576b7e05686SMatthew G. Knepley 1577b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1578b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1579b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1580b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1581b7e05686SMatthew G. Knepley 1582b7e05686SMatthew G. Knepley + dim - the spatial dimension 1583b7e05686SMatthew G. Knepley . Nf - the number of fields 1584b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1585b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1586b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1587b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1588b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1589b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1590b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1591b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1592b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1593b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1594b7e05686SMatthew G. Knepley . t - current time 1595b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1596b7e05686SMatthew G. Knepley . x - coordinates of the current point 1597b7e05686SMatthew G. Knepley - g0 - output values at the current point 1598b7e05686SMatthew G. Knepley 1599b7e05686SMatthew G. Knepley Level: intermediate 1600b7e05686SMatthew G. Knepley 1601b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1602b7e05686SMatthew G. Knepley @*/ 1603b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1604b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1605b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1606b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1607b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1608b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1609b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1610b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1611b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1612b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1613b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1614b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1615b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1616b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1617b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1618b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1619b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1620b7e05686SMatthew G. Knepley { 1621b7e05686SMatthew G. Knepley PetscFunctionBegin; 1622b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1623b7e05686SMatthew 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); 1624b7e05686SMatthew 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); 1625b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1626b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1627b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1628b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1629b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1630b7e05686SMatthew G. Knepley } 1631b7e05686SMatthew G. Knepley 1632b7e05686SMatthew G. Knepley #undef __FUNCT__ 1633b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSSetDynamicJacobian" 1634b7e05686SMatthew G. Knepley /*@C 1635b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1636b7e05686SMatthew G. Knepley 1637b7e05686SMatthew G. Knepley Not collective 1638b7e05686SMatthew G. Knepley 1639b7e05686SMatthew G. Knepley Input Parameters: 1640b7e05686SMatthew G. Knepley + prob - The PetscDS 1641b7e05686SMatthew G. Knepley . f - The test field number 1642b7e05686SMatthew G. Knepley . g - The field number 1643b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1644b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1645b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1646b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1647b7e05686SMatthew G. Knepley 1648b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1649b7e05686SMatthew G. Knepley 1650b7e05686SMatthew 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 1651b7e05686SMatthew G. Knepley 1652b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1653b7e05686SMatthew G. Knepley 1654b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1655b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1656b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1657b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1658b7e05686SMatthew G. Knepley 1659b7e05686SMatthew G. Knepley + dim - the spatial dimension 1660b7e05686SMatthew G. Knepley . Nf - the number of fields 1661b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1662b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1663b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1664b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1665b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1666b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1667b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1668b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1669b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1670b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1671b7e05686SMatthew G. Knepley . t - current time 1672b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1673b7e05686SMatthew G. Knepley . x - coordinates of the current point 1674b7e05686SMatthew G. Knepley - g0 - output values at the current point 1675b7e05686SMatthew G. Knepley 1676b7e05686SMatthew G. Knepley Level: intermediate 1677b7e05686SMatthew G. Knepley 1678b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1679b7e05686SMatthew G. Knepley @*/ 1680b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1681b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1682b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1683b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1684b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1685b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1686b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1687b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1688b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1689b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1690b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1691b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1692b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1693b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1694b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1695b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1696b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1697b7e05686SMatthew G. Knepley { 1698b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1699b7e05686SMatthew G. Knepley 1700b7e05686SMatthew G. Knepley PetscFunctionBegin; 1701b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1702b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1703b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1704b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1705b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1706b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1707b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1708b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1709b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1710b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1711b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1712b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1713b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1714b7e05686SMatthew G. Knepley } 1715b7e05686SMatthew G. Knepley 1716b7e05686SMatthew G. Knepley #undef __FUNCT__ 17170c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 17180c2f2876SMatthew G. Knepley /*@C 17190c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17200c2f2876SMatthew G. Knepley 17210c2f2876SMatthew G. Knepley Not collective 17220c2f2876SMatthew G. Knepley 17230c2f2876SMatthew G. Knepley Input Arguments: 17240c2f2876SMatthew G. Knepley + prob - The PetscDS object 17250c2f2876SMatthew G. Knepley - f - The field number 17260c2f2876SMatthew G. Knepley 17270c2f2876SMatthew G. Knepley Output Argument: 17280c2f2876SMatthew G. Knepley . r - Riemann solver 17290c2f2876SMatthew G. Knepley 17300c2f2876SMatthew G. Knepley Calling sequence for r: 17310c2f2876SMatthew G. Knepley 17325db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17330c2f2876SMatthew G. Knepley 17345db36cf9SMatthew G. Knepley + dim - The spatial dimension 17355db36cf9SMatthew G. Knepley . Nf - The number of fields 17365db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17370c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17380c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17390c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17400c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17410c2f2876SMatthew G. Knepley - ctx - optional user context 17420c2f2876SMatthew G. Knepley 17430c2f2876SMatthew G. Knepley Level: intermediate 17440c2f2876SMatthew G. Knepley 17450c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17460c2f2876SMatthew G. Knepley @*/ 17470c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 17485db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17490c2f2876SMatthew G. Knepley { 17500c2f2876SMatthew G. Knepley PetscFunctionBegin; 17510c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17520c2f2876SMatthew 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); 17530c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17540c2f2876SMatthew G. Knepley *r = prob->r[f]; 17550c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17560c2f2876SMatthew G. Knepley } 17570c2f2876SMatthew G. Knepley 17580c2f2876SMatthew G. Knepley #undef __FUNCT__ 17590c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 17600c2f2876SMatthew G. Knepley /*@C 17610c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17620c2f2876SMatthew G. Knepley 17630c2f2876SMatthew G. Knepley Not collective 17640c2f2876SMatthew G. Knepley 17650c2f2876SMatthew G. Knepley Input Arguments: 17660c2f2876SMatthew G. Knepley + prob - The PetscDS object 17670c2f2876SMatthew G. Knepley . f - The field number 17680c2f2876SMatthew G. Knepley - r - Riemann solver 17690c2f2876SMatthew G. Knepley 17700c2f2876SMatthew G. Knepley Calling sequence for r: 17710c2f2876SMatthew G. Knepley 17725db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17730c2f2876SMatthew G. Knepley 17745db36cf9SMatthew G. Knepley + dim - The spatial dimension 17755db36cf9SMatthew G. Knepley . Nf - The number of fields 17765db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17770c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17780c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17790c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17800c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17810c2f2876SMatthew G. Knepley - ctx - optional user context 17820c2f2876SMatthew G. Knepley 17830c2f2876SMatthew G. Knepley Level: intermediate 17840c2f2876SMatthew G. Knepley 17850c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17860c2f2876SMatthew G. Knepley @*/ 17870c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 17885db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17890c2f2876SMatthew G. Knepley { 17900c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17910c2f2876SMatthew G. Knepley 17920c2f2876SMatthew G. Knepley PetscFunctionBegin; 17930c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1794de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 17950c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17960c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17970c2f2876SMatthew G. Knepley prob->r[f] = r; 17980c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17990c2f2876SMatthew G. Knepley } 18000c2f2876SMatthew G. Knepley 18010c2f2876SMatthew G. Knepley #undef __FUNCT__ 18020c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 18030c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 18040c2f2876SMatthew G. Knepley { 18050c2f2876SMatthew G. Knepley PetscFunctionBegin; 18060c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18070c2f2876SMatthew 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); 18080c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 18090c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 18100c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18110c2f2876SMatthew G. Knepley } 18120c2f2876SMatthew G. Knepley 18130c2f2876SMatthew G. Knepley #undef __FUNCT__ 18140c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 18150c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 18160c2f2876SMatthew G. Knepley { 18170c2f2876SMatthew G. Knepley PetscErrorCode ierr; 18180c2f2876SMatthew G. Knepley 18190c2f2876SMatthew G. Knepley PetscFunctionBegin; 18200c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18210c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18220c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18230c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 18240c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18250c2f2876SMatthew G. Knepley } 18260c2f2876SMatthew G. Knepley 18270c2f2876SMatthew G. Knepley #undef __FUNCT__ 18282764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1829194d53e6SMatthew G. Knepley /*@C 1830194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1831194d53e6SMatthew G. Knepley 1832194d53e6SMatthew G. Knepley Not collective 1833194d53e6SMatthew G. Knepley 1834194d53e6SMatthew G. Knepley Input Parameters: 1835194d53e6SMatthew G. Knepley + prob - The PetscDS 1836194d53e6SMatthew G. Knepley - f - The test field number 1837194d53e6SMatthew G. Knepley 1838194d53e6SMatthew G. Knepley Output Parameters: 1839194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1840194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1841194d53e6SMatthew G. Knepley 1842194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1843194d53e6SMatthew G. Knepley 1844194d53e6SMatthew 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 1845194d53e6SMatthew G. Knepley 1846194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1847194d53e6SMatthew G. Knepley 184830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1849194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1850194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 185130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1852194d53e6SMatthew G. Knepley 1853194d53e6SMatthew G. Knepley + dim - the spatial dimension 1854194d53e6SMatthew G. Knepley . Nf - the number of fields 1855194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1856194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1857194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1858194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1859194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1860194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1861194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1862194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1863194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1864194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1865194d53e6SMatthew G. Knepley . t - current time 1866194d53e6SMatthew G. Knepley . x - coordinates of the current point 1867194d53e6SMatthew G. Knepley . n - unit normal at the current point 1868194d53e6SMatthew G. Knepley - f0 - output values at the current point 1869194d53e6SMatthew G. Knepley 1870194d53e6SMatthew G. Knepley Level: intermediate 1871194d53e6SMatthew G. Knepley 1872194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1873194d53e6SMatthew G. Knepley @*/ 18742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 187530b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1876194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1877194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187830b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 187930b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1880194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1881194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188230b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 18832764a2aaSMatthew G. Knepley { 18842764a2aaSMatthew G. Knepley PetscFunctionBegin; 18852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18862764a2aaSMatthew 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); 18872764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 18882764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 18892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18902764a2aaSMatthew G. Knepley } 18912764a2aaSMatthew G. Knepley 18922764a2aaSMatthew G. Knepley #undef __FUNCT__ 18932764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1894194d53e6SMatthew G. Knepley /*@C 1895194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1896194d53e6SMatthew G. Knepley 1897194d53e6SMatthew G. Knepley Not collective 1898194d53e6SMatthew G. Knepley 1899194d53e6SMatthew G. Knepley Input Parameters: 1900194d53e6SMatthew G. Knepley + prob - The PetscDS 1901194d53e6SMatthew G. Knepley . f - The test field number 1902194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1903194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1904194d53e6SMatthew G. Knepley 1905194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1906194d53e6SMatthew G. Knepley 1907194d53e6SMatthew 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 1908194d53e6SMatthew G. Knepley 1909194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1910194d53e6SMatthew G. Knepley 191130b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1912194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1913194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 191430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1915194d53e6SMatthew G. Knepley 1916194d53e6SMatthew G. Knepley + dim - the spatial dimension 1917194d53e6SMatthew G. Knepley . Nf - the number of fields 1918194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1919194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1920194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1921194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1922194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1923194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1924194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1925194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1926194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1927194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1928194d53e6SMatthew G. Knepley . t - current time 1929194d53e6SMatthew G. Knepley . x - coordinates of the current point 1930194d53e6SMatthew G. Knepley . n - unit normal at the current point 1931194d53e6SMatthew G. Knepley - f0 - output values at the current point 1932194d53e6SMatthew G. Knepley 1933194d53e6SMatthew G. Knepley Level: intermediate 1934194d53e6SMatthew G. Knepley 1935194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1936194d53e6SMatthew G. Knepley @*/ 19372764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 193830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1939194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1940194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 194230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1943194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1944194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194530b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 19462764a2aaSMatthew G. Knepley { 19472764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19482764a2aaSMatthew G. Knepley 19492764a2aaSMatthew G. Knepley PetscFunctionBegin; 19502764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19512764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19522764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19532764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 19542764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 19552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19562764a2aaSMatthew G. Knepley } 19572764a2aaSMatthew G. Knepley 19582764a2aaSMatthew G. Knepley #undef __FUNCT__ 19592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1960194d53e6SMatthew G. Knepley /*@C 1961194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1962194d53e6SMatthew G. Knepley 1963194d53e6SMatthew G. Knepley Not collective 1964194d53e6SMatthew G. Knepley 1965194d53e6SMatthew G. Knepley Input Parameters: 1966194d53e6SMatthew G. Knepley + prob - The PetscDS 1967194d53e6SMatthew G. Knepley . f - The test field number 1968194d53e6SMatthew G. Knepley - g - The field number 1969194d53e6SMatthew G. Knepley 1970194d53e6SMatthew G. Knepley Output Parameters: 1971194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1972194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1973194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1974194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1975194d53e6SMatthew G. Knepley 1976194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1977194d53e6SMatthew G. Knepley 1978194d53e6SMatthew 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 1979194d53e6SMatthew G. Knepley 1980194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1981194d53e6SMatthew G. Knepley 198230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1983194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1984194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1986194d53e6SMatthew G. Knepley 1987194d53e6SMatthew G. Knepley + dim - the spatial dimension 1988194d53e6SMatthew G. Knepley . Nf - the number of fields 1989194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1990194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1991194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1992194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1993194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1994194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1995194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1996194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1997194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1998194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1999194d53e6SMatthew G. Knepley . t - current time 20002aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2001194d53e6SMatthew G. Knepley . x - coordinates of the current point 2002194d53e6SMatthew G. Knepley . n - normal at the current point 2003194d53e6SMatthew G. Knepley - g0 - output values at the current point 2004194d53e6SMatthew G. Knepley 2005194d53e6SMatthew G. Knepley Level: intermediate 2006194d53e6SMatthew G. Knepley 2007194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2008194d53e6SMatthew G. Knepley @*/ 20092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 201030b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2011194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2012194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20132aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 201430b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2015194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2016194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20172aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 201830b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2019194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2020194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20212aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 202230b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2023194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2024194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20252aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 20262764a2aaSMatthew G. Knepley { 20272764a2aaSMatthew G. Knepley PetscFunctionBegin; 20282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20292764a2aaSMatthew 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); 20302764a2aaSMatthew 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); 20312764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 20322764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 20332764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 20342764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 20352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20362764a2aaSMatthew G. Knepley } 20372764a2aaSMatthew G. Knepley 20382764a2aaSMatthew G. Knepley #undef __FUNCT__ 20392764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 2040194d53e6SMatthew G. Knepley /*@C 2041194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2042194d53e6SMatthew G. Knepley 2043194d53e6SMatthew G. Knepley Not collective 2044194d53e6SMatthew G. Knepley 2045194d53e6SMatthew G. Knepley Input Parameters: 2046194d53e6SMatthew G. Knepley + prob - The PetscDS 2047194d53e6SMatthew G. Knepley . f - The test field number 2048194d53e6SMatthew G. Knepley . g - The field number 2049194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2050194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2051194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2052194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2053194d53e6SMatthew G. Knepley 2054194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2055194d53e6SMatthew G. Knepley 2056194d53e6SMatthew 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 2057194d53e6SMatthew G. Knepley 2058194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2059194d53e6SMatthew G. Knepley 206030b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2061194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2062194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 206330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2064194d53e6SMatthew G. Knepley 2065194d53e6SMatthew G. Knepley + dim - the spatial dimension 2066194d53e6SMatthew G. Knepley . Nf - the number of fields 2067194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2068194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2069194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2070194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2071194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2072194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2073194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2074194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2075194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2076194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2077194d53e6SMatthew G. Knepley . t - current time 20782aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2079194d53e6SMatthew G. Knepley . x - coordinates of the current point 2080194d53e6SMatthew G. Knepley . n - normal at the current point 2081194d53e6SMatthew G. Knepley - g0 - output values at the current point 2082194d53e6SMatthew G. Knepley 2083194d53e6SMatthew G. Knepley Level: intermediate 2084194d53e6SMatthew G. Knepley 2085194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2086194d53e6SMatthew G. Knepley @*/ 20872764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 208830b9ff8bSMatthew G. Knepley void (*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[], 20912aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 209230b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2093194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2094194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20952aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 209630b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2097194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2098194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20992aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 210030b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2101194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2102194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21032aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 21042764a2aaSMatthew G. Knepley { 21052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21062764a2aaSMatthew G. Knepley 21072764a2aaSMatthew G. Knepley PetscFunctionBegin; 21082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21092764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 21102764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 21112764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 21122764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 21132764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21142764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 21152764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 21162764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 21172764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 21182764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 21192764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 21202764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21212764a2aaSMatthew G. Knepley } 21222764a2aaSMatthew G. Knepley 21232764a2aaSMatthew G. Knepley #undef __FUNCT__ 21244cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldIndex" 21254cd1e086SMatthew G. Knepley /*@ 21264cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 21274cd1e086SMatthew G. Knepley 21284cd1e086SMatthew G. Knepley Not collective 21294cd1e086SMatthew G. Knepley 21304cd1e086SMatthew G. Knepley Input Parameters: 21314cd1e086SMatthew G. Knepley + prob - The PetscDS object 21324cd1e086SMatthew G. Knepley - disc - The discretization object 21334cd1e086SMatthew G. Knepley 21344cd1e086SMatthew G. Knepley Output Parameter: 21354cd1e086SMatthew G. Knepley . f - The field number 21364cd1e086SMatthew G. Knepley 21374cd1e086SMatthew G. Knepley Level: beginner 21384cd1e086SMatthew G. Knepley 21394cd1e086SMatthew G. Knepley .seealso: PetscGetDiscretization(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21404cd1e086SMatthew G. Knepley @*/ 21414cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 21424cd1e086SMatthew G. Knepley { 21434cd1e086SMatthew G. Knepley PetscInt g; 21444cd1e086SMatthew G. Knepley 21454cd1e086SMatthew G. Knepley PetscFunctionBegin; 21464cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21474cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 21484cd1e086SMatthew G. Knepley *f = -1; 21494cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 21504cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 21514cd1e086SMatthew G. Knepley *f = g; 21524cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21534cd1e086SMatthew G. Knepley } 21544cd1e086SMatthew G. Knepley 21554cd1e086SMatthew G. Knepley #undef __FUNCT__ 21564cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldSize" 21574cd1e086SMatthew G. Knepley /*@ 21584cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 21594cd1e086SMatthew G. Knepley 21604cd1e086SMatthew G. Knepley Not collective 21614cd1e086SMatthew G. Knepley 21624cd1e086SMatthew G. Knepley Input Parameters: 21634cd1e086SMatthew G. Knepley + prob - The PetscDS object 21644cd1e086SMatthew G. Knepley - f - The field number 21654cd1e086SMatthew G. Knepley 21664cd1e086SMatthew G. Knepley Output Parameter: 21674cd1e086SMatthew G. Knepley . size - The size 21684cd1e086SMatthew G. Knepley 21694cd1e086SMatthew G. Knepley Level: beginner 21704cd1e086SMatthew G. Knepley 21714cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21724cd1e086SMatthew G. Knepley @*/ 21734cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 21744cd1e086SMatthew G. Knepley { 21754cd1e086SMatthew G. Knepley PetscClassId id; 21764cd1e086SMatthew G. Knepley PetscInt Nb, Nc; 21774cd1e086SMatthew G. Knepley PetscErrorCode ierr; 21784cd1e086SMatthew G. Knepley 21794cd1e086SMatthew G. Knepley PetscFunctionBegin; 21804cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21814cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 21824cd1e086SMatthew 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); 21834cd1e086SMatthew G. Knepley *size = 0; 21844cd1e086SMatthew G. Knepley ierr = PetscObjectGetClassId(prob->disc[f], &id);CHKERRQ(ierr); 21854cd1e086SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 21864cd1e086SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[f]; 21874cd1e086SMatthew G. Knepley 21884cd1e086SMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 21894cd1e086SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 21904cd1e086SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 21914cd1e086SMatthew G. Knepley PetscFV fv = (PetscFV) prob->disc[f]; 21924cd1e086SMatthew G. Knepley 21934cd1e086SMatthew G. Knepley Nb = 1; 21944cd1e086SMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 21954cd1e086SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 21964cd1e086SMatthew G. Knepley *size = Nb*Nc; 21974cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21984cd1e086SMatthew G. Knepley } 21994cd1e086SMatthew G. Knepley 22004cd1e086SMatthew G. Knepley #undef __FUNCT__ 22012764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 2202bc4ae4beSMatthew G. Knepley /*@ 2203bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2204bc4ae4beSMatthew G. Knepley 2205bc4ae4beSMatthew G. Knepley Not collective 2206bc4ae4beSMatthew G. Knepley 2207bc4ae4beSMatthew G. Knepley Input Parameters: 2208bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2209bc4ae4beSMatthew G. Knepley - f - The field number 2210bc4ae4beSMatthew G. Knepley 2211bc4ae4beSMatthew G. Knepley Output Parameter: 2212bc4ae4beSMatthew G. Knepley . off - The offset 2213bc4ae4beSMatthew G. Knepley 2214bc4ae4beSMatthew G. Knepley Level: beginner 2215bc4ae4beSMatthew G. Knepley 22164cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2217bc4ae4beSMatthew G. Knepley @*/ 22182764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 22192764a2aaSMatthew G. Knepley { 22204cd1e086SMatthew G. Knepley PetscInt size, g; 22212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22222764a2aaSMatthew G. Knepley 22232764a2aaSMatthew G. Knepley PetscFunctionBegin; 22242764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22252764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22262764a2aaSMatthew 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); 22272764a2aaSMatthew G. Knepley *off = 0; 22282764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22294cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 22304cd1e086SMatthew G. Knepley *off += size; 22312764a2aaSMatthew G. Knepley } 22322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22332764a2aaSMatthew G. Knepley } 22342764a2aaSMatthew G. Knepley 22352764a2aaSMatthew G. Knepley #undef __FUNCT__ 22362764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 2237bc4ae4beSMatthew G. Knepley /*@ 2238c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 2239bc4ae4beSMatthew G. Knepley 2240bc4ae4beSMatthew G. Knepley Not collective 2241bc4ae4beSMatthew G. Knepley 2242bc4ae4beSMatthew G. Knepley Input Parameters: 2243bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2244bc4ae4beSMatthew G. Knepley - f - The field number 2245bc4ae4beSMatthew G. Knepley 2246bc4ae4beSMatthew G. Knepley Output Parameter: 2247bc4ae4beSMatthew G. Knepley . off - The boundary offset 2248bc4ae4beSMatthew G. Knepley 2249bc4ae4beSMatthew G. Knepley Level: beginner 2250bc4ae4beSMatthew G. Knepley 2251bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2252bc4ae4beSMatthew G. Knepley @*/ 22532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 22542764a2aaSMatthew G. Knepley { 22552764a2aaSMatthew G. Knepley PetscInt g; 22562764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22572764a2aaSMatthew G. Knepley 22582764a2aaSMatthew G. Knepley PetscFunctionBegin; 22592764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22602764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22612764a2aaSMatthew 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); 22622764a2aaSMatthew G. Knepley *off = 0; 22632764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22642764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 22652764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 22662764a2aaSMatthew G. Knepley 22672764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 22682764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 22692764a2aaSMatthew G. Knepley *off += Nb*Nc; 22706ce16762SMatthew G. Knepley } 22716ce16762SMatthew G. Knepley PetscFunctionReturn(0); 22726ce16762SMatthew G. Knepley } 22736ce16762SMatthew G. Knepley 22746ce16762SMatthew G. Knepley #undef __FUNCT__ 22756ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 22766ce16762SMatthew G. Knepley /*@ 22776ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 22786ce16762SMatthew G. Knepley 22796ce16762SMatthew G. Knepley Not collective 22806ce16762SMatthew G. Knepley 22816ce16762SMatthew G. Knepley Input Parameters: 22826ce16762SMatthew G. Knepley + prob - The PetscDS object 22836ce16762SMatthew G. Knepley - f - The field number 22846ce16762SMatthew G. Knepley 22856ce16762SMatthew G. Knepley Output Parameter: 22866ce16762SMatthew G. Knepley . off - The offset 22876ce16762SMatthew G. Knepley 22886ce16762SMatthew G. Knepley Level: beginner 22896ce16762SMatthew G. Knepley 22906ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 22916ce16762SMatthew G. Knepley @*/ 22926ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 22936ce16762SMatthew G. Knepley { 22946ce16762SMatthew G. Knepley PetscInt g; 22956ce16762SMatthew G. Knepley PetscErrorCode ierr; 22966ce16762SMatthew G. Knepley 22976ce16762SMatthew G. Knepley PetscFunctionBegin; 22986ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22996ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 23006ce16762SMatthew 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); 23016ce16762SMatthew G. Knepley *off = 0; 23026ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 23036ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 23046ce16762SMatthew G. Knepley PetscInt Nc; 23056ce16762SMatthew G. Knepley 23066ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 23076ce16762SMatthew G. Knepley *off += Nc; 23082764a2aaSMatthew G. Knepley } 23092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23102764a2aaSMatthew G. Knepley } 23112764a2aaSMatthew G. Knepley 23122764a2aaSMatthew G. Knepley #undef __FUNCT__ 2313194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 2314194d53e6SMatthew G. Knepley /*@ 2315194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2316194d53e6SMatthew G. Knepley 2317194d53e6SMatthew G. Knepley Not collective 2318194d53e6SMatthew G. Knepley 2319194d53e6SMatthew G. Knepley Input Parameter: 2320194d53e6SMatthew G. Knepley . prob - The PetscDS object 2321194d53e6SMatthew G. Knepley 2322194d53e6SMatthew G. Knepley Output Parameter: 2323194d53e6SMatthew G. Knepley . offsets - The offsets 2324194d53e6SMatthew G. Knepley 2325194d53e6SMatthew G. Knepley Level: beginner 2326194d53e6SMatthew G. Knepley 2327194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2328194d53e6SMatthew G. Knepley @*/ 2329194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2330194d53e6SMatthew G. Knepley { 2331194d53e6SMatthew G. Knepley PetscFunctionBegin; 2332194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2333194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2334194d53e6SMatthew G. Knepley *offsets = prob->off; 2335194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2336194d53e6SMatthew G. Knepley } 2337194d53e6SMatthew G. Knepley 2338194d53e6SMatthew G. Knepley #undef __FUNCT__ 2339194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 2340194d53e6SMatthew G. Knepley /*@ 2341194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2342194d53e6SMatthew G. Knepley 2343194d53e6SMatthew G. Knepley Not collective 2344194d53e6SMatthew G. Knepley 2345194d53e6SMatthew G. Knepley Input Parameter: 2346194d53e6SMatthew G. Knepley . prob - The PetscDS object 2347194d53e6SMatthew G. Knepley 2348194d53e6SMatthew G. Knepley Output Parameter: 2349194d53e6SMatthew G. Knepley . offsets - The offsets 2350194d53e6SMatthew G. Knepley 2351194d53e6SMatthew G. Knepley Level: beginner 2352194d53e6SMatthew G. Knepley 2353194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2354194d53e6SMatthew G. Knepley @*/ 2355194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2356194d53e6SMatthew G. Knepley { 2357194d53e6SMatthew G. Knepley PetscFunctionBegin; 2358194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2359194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2360194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2361194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2362194d53e6SMatthew G. Knepley } 2363194d53e6SMatthew G. Knepley 2364194d53e6SMatthew G. Knepley #undef __FUNCT__ 2365194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets" 2366194d53e6SMatthew G. Knepley /*@ 2367194d53e6SMatthew G. Knepley PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point 2368194d53e6SMatthew G. Knepley 2369194d53e6SMatthew G. Knepley Not collective 2370194d53e6SMatthew G. Knepley 2371194d53e6SMatthew G. Knepley Input Parameter: 2372194d53e6SMatthew G. Knepley . prob - The PetscDS object 2373194d53e6SMatthew G. Knepley 2374194d53e6SMatthew G. Knepley Output Parameter: 2375194d53e6SMatthew G. Knepley . offsets - The offsets 2376194d53e6SMatthew G. Knepley 2377194d53e6SMatthew G. Knepley Level: beginner 2378194d53e6SMatthew G. Knepley 2379194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2380194d53e6SMatthew G. Knepley @*/ 2381194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[]) 2382194d53e6SMatthew G. Knepley { 2383194d53e6SMatthew G. Knepley PetscFunctionBegin; 2384194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2385194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2386194d53e6SMatthew G. Knepley *offsets = prob->offBd; 2387194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2388194d53e6SMatthew G. Knepley } 2389194d53e6SMatthew G. Knepley 2390194d53e6SMatthew G. Knepley #undef __FUNCT__ 2391194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 2392194d53e6SMatthew G. Knepley /*@ 2393194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 2394194d53e6SMatthew G. Knepley 2395194d53e6SMatthew G. Knepley Not collective 2396194d53e6SMatthew G. Knepley 2397194d53e6SMatthew G. Knepley Input Parameter: 2398194d53e6SMatthew G. Knepley . prob - The PetscDS object 2399194d53e6SMatthew G. Knepley 2400194d53e6SMatthew G. Knepley Output Parameter: 2401194d53e6SMatthew G. Knepley . offsets - The offsets 2402194d53e6SMatthew G. Knepley 2403194d53e6SMatthew G. Knepley Level: beginner 2404194d53e6SMatthew G. Knepley 2405194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2406194d53e6SMatthew G. Knepley @*/ 2407194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2408194d53e6SMatthew G. Knepley { 2409194d53e6SMatthew G. Knepley PetscFunctionBegin; 2410194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2411194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2412194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 2413194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2414194d53e6SMatthew G. Knepley } 2415194d53e6SMatthew G. Knepley 2416194d53e6SMatthew G. Knepley #undef __FUNCT__ 24172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 241868c9edb9SMatthew G. Knepley /*@C 241968c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 242068c9edb9SMatthew G. Knepley 242168c9edb9SMatthew G. Knepley Not collective 242268c9edb9SMatthew G. Knepley 242368c9edb9SMatthew G. Knepley Input Parameter: 242468c9edb9SMatthew G. Knepley . prob - The PetscDS object 242568c9edb9SMatthew G. Knepley 242668c9edb9SMatthew G. Knepley Output Parameters: 242768c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 242868c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 242968c9edb9SMatthew G. Knepley 243068c9edb9SMatthew G. Knepley Level: intermediate 243168c9edb9SMatthew G. Knepley 243268c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 243368c9edb9SMatthew G. Knepley @*/ 24342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24352764a2aaSMatthew G. Knepley { 24362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24372764a2aaSMatthew G. Knepley 24382764a2aaSMatthew G. Knepley PetscFunctionBegin; 24392764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24402764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24412764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 24422764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 24432764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24442764a2aaSMatthew G. Knepley } 24452764a2aaSMatthew G. Knepley 24462764a2aaSMatthew G. Knepley #undef __FUNCT__ 24472764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 244868c9edb9SMatthew G. Knepley /*@C 244968c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 245068c9edb9SMatthew G. Knepley 245168c9edb9SMatthew G. Knepley Not collective 245268c9edb9SMatthew G. Knepley 245368c9edb9SMatthew G. Knepley Input Parameter: 245468c9edb9SMatthew G. Knepley . prob - The PetscDS object 245568c9edb9SMatthew G. Knepley 245668c9edb9SMatthew G. Knepley Output Parameters: 245768c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 245868c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 245968c9edb9SMatthew G. Knepley 246068c9edb9SMatthew G. Knepley Level: intermediate 246168c9edb9SMatthew G. Knepley 246268c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 246368c9edb9SMatthew G. Knepley @*/ 24642764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24652764a2aaSMatthew G. Knepley { 24662764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24672764a2aaSMatthew G. Knepley 24682764a2aaSMatthew G. Knepley PetscFunctionBegin; 24692764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24702764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24712764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 24722764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 24732764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24742764a2aaSMatthew G. Knepley } 24752764a2aaSMatthew G. Knepley 24762764a2aaSMatthew G. Knepley #undef __FUNCT__ 24772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 24782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 24792764a2aaSMatthew G. Knepley { 24802764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24812764a2aaSMatthew G. Knepley 24822764a2aaSMatthew G. Knepley PetscFunctionBegin; 24832764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24842764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24852764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 24862764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 24872764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 24882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24892764a2aaSMatthew G. Knepley } 24902764a2aaSMatthew G. Knepley 24912764a2aaSMatthew G. Knepley #undef __FUNCT__ 24922764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 24932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 24942764a2aaSMatthew G. Knepley { 24952764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24962764a2aaSMatthew G. Knepley 24972764a2aaSMatthew G. Knepley PetscFunctionBegin; 24982764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24992764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 25002764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 25012764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 25022764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 25032764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 25042764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 25052764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 25062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25072764a2aaSMatthew G. Knepley } 25082764a2aaSMatthew G. Knepley 25092764a2aaSMatthew G. Knepley #undef __FUNCT__ 25102764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 25112764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 25122764a2aaSMatthew G. Knepley { 25132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25142764a2aaSMatthew G. Knepley 25152764a2aaSMatthew G. Knepley PetscFunctionBegin; 25162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 25172764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 25182764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 25192764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 25202764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25212764a2aaSMatthew G. Knepley } 25222764a2aaSMatthew G. Knepley 25232764a2aaSMatthew G. Knepley #undef __FUNCT__ 252458ebd649SToby Isaac #define __FUNCT__ "PetscDSAddBoundary" 252558ebd649SToby Isaac /*@C 252658ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 252758ebd649SToby Isaac 252858ebd649SToby Isaac Input Parameters: 252958ebd649SToby Isaac + ds - The PetscDS object 253058ebd649SToby Isaac . isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 253158ebd649SToby Isaac . name - The BC name 253258ebd649SToby Isaac . labelname - The label defining constrained points 253358ebd649SToby Isaac . field - The field to constrain 253458ebd649SToby Isaac . numcomps - The number of constrained field components 253558ebd649SToby Isaac . comps - An array of constrained component numbers 253658ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 253758ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 253858ebd649SToby Isaac . ids - An array of ids for constrained points 253958ebd649SToby Isaac - ctx - An optional user context for bcFunc 254058ebd649SToby Isaac 254158ebd649SToby Isaac Options Database Keys: 254258ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 254358ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 254458ebd649SToby Isaac 254558ebd649SToby Isaac Level: developer 254658ebd649SToby Isaac 254758ebd649SToby Isaac .seealso: PetscDSGetBoundary() 254858ebd649SToby Isaac @*/ 254958ebd649SToby Isaac PetscErrorCode PetscDSAddBoundary(PetscDS ds, PetscBool isEssential, const char name[], const char labelname[], PetscInt field, PetscInt numcomps, const PetscInt *comps, void (*bcFunc)(), PetscInt numids, const PetscInt *ids, void *ctx) 255058ebd649SToby Isaac { 255158ebd649SToby Isaac DSBoundary b; 255258ebd649SToby Isaac PetscErrorCode ierr; 255358ebd649SToby Isaac 255458ebd649SToby Isaac PetscFunctionBegin; 255558ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 255658ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 255758ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 255858ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 255958ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 256058ebd649SToby Isaac if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 256158ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 256258ebd649SToby Isaac if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 256358ebd649SToby Isaac b->essential = isEssential; 256458ebd649SToby Isaac b->field = field; 256558ebd649SToby Isaac b->numcomps = numcomps; 256658ebd649SToby Isaac b->func = bcFunc; 256758ebd649SToby Isaac b->numids = numids; 256858ebd649SToby Isaac b->ctx = ctx; 256958ebd649SToby Isaac b->next = ds->boundary; 257058ebd649SToby Isaac ds->boundary = b; 257158ebd649SToby Isaac PetscFunctionReturn(0); 257258ebd649SToby Isaac } 257358ebd649SToby Isaac 257458ebd649SToby Isaac #undef __FUNCT__ 257558ebd649SToby Isaac #define __FUNCT__ "PetscDSGetNumBoundary" 257658ebd649SToby Isaac /*@ 257758ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 257858ebd649SToby Isaac 257958ebd649SToby Isaac Input Parameters: 258058ebd649SToby Isaac . ds - The PetscDS object 258158ebd649SToby Isaac 258258ebd649SToby Isaac Output Parameters: 258358ebd649SToby Isaac . numBd - The number of BC 258458ebd649SToby Isaac 258558ebd649SToby Isaac Level: intermediate 258658ebd649SToby Isaac 258758ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 258858ebd649SToby Isaac @*/ 258958ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 259058ebd649SToby Isaac { 259158ebd649SToby Isaac DSBoundary b = ds->boundary; 259258ebd649SToby Isaac 259358ebd649SToby Isaac PetscFunctionBegin; 259458ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 259558ebd649SToby Isaac PetscValidPointer(numBd, 2); 259658ebd649SToby Isaac *numBd = 0; 259758ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 259858ebd649SToby Isaac PetscFunctionReturn(0); 259958ebd649SToby Isaac } 260058ebd649SToby Isaac 260158ebd649SToby Isaac #undef __FUNCT__ 260258ebd649SToby Isaac #define __FUNCT__ "PetscDSGetBoundary" 260358ebd649SToby Isaac /*@C 260458ebd649SToby Isaac PetscDSGetBoundary - Add a boundary condition to the model 260558ebd649SToby Isaac 260658ebd649SToby Isaac Input Parameters: 260758ebd649SToby Isaac + ds - The PetscDS object 260858ebd649SToby Isaac - bd - The BC number 260958ebd649SToby Isaac 261058ebd649SToby Isaac Output Parameters: 261158ebd649SToby Isaac + isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 261258ebd649SToby Isaac . name - The BC name 261358ebd649SToby Isaac . labelname - The label defining constrained points 261458ebd649SToby Isaac . field - The field to constrain 261558ebd649SToby Isaac . numcomps - The number of constrained field components 261658ebd649SToby Isaac . comps - An array of constrained component numbers 261758ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 261858ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 261958ebd649SToby Isaac . ids - An array of ids for constrained points 262058ebd649SToby Isaac - ctx - An optional user context for bcFunc 262158ebd649SToby Isaac 262258ebd649SToby Isaac Options Database Keys: 262358ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 262458ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 262558ebd649SToby Isaac 262658ebd649SToby Isaac Level: developer 262758ebd649SToby Isaac 262858ebd649SToby Isaac .seealso: PetscDSAddBoundary() 262958ebd649SToby Isaac @*/ 263058ebd649SToby Isaac PetscErrorCode PetscDSGetBoundary(PetscDS ds, PetscInt bd, PetscBool *isEssential, const char **name, const char **labelname, PetscInt *field, PetscInt *numcomps, const PetscInt **comps, void (**func)(), PetscInt *numids, const PetscInt **ids, void **ctx) 263158ebd649SToby Isaac { 263258ebd649SToby Isaac DSBoundary b = ds->boundary; 263358ebd649SToby Isaac PetscInt n = 0; 263458ebd649SToby Isaac 263558ebd649SToby Isaac PetscFunctionBegin; 263658ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 263758ebd649SToby Isaac while (b) { 263858ebd649SToby Isaac if (n == bd) break; 263958ebd649SToby Isaac b = b->next; 264058ebd649SToby Isaac ++n; 264158ebd649SToby Isaac } 264258ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 264358ebd649SToby Isaac if (isEssential) { 264458ebd649SToby Isaac PetscValidPointer(isEssential, 3); 264558ebd649SToby Isaac *isEssential = b->essential; 264658ebd649SToby Isaac } 264758ebd649SToby Isaac if (name) { 264858ebd649SToby Isaac PetscValidPointer(name, 4); 264958ebd649SToby Isaac *name = b->name; 265058ebd649SToby Isaac } 265158ebd649SToby Isaac if (labelname) { 265258ebd649SToby Isaac PetscValidPointer(labelname, 5); 265358ebd649SToby Isaac *labelname = b->labelname; 265458ebd649SToby Isaac } 265558ebd649SToby Isaac if (field) { 265658ebd649SToby Isaac PetscValidPointer(field, 6); 265758ebd649SToby Isaac *field = b->field; 265858ebd649SToby Isaac } 265958ebd649SToby Isaac if (numcomps) { 266058ebd649SToby Isaac PetscValidPointer(numcomps, 7); 266158ebd649SToby Isaac *numcomps = b->numcomps; 266258ebd649SToby Isaac } 266358ebd649SToby Isaac if (comps) { 266458ebd649SToby Isaac PetscValidPointer(comps, 8); 266558ebd649SToby Isaac *comps = b->comps; 266658ebd649SToby Isaac } 266758ebd649SToby Isaac if (func) { 266858ebd649SToby Isaac PetscValidPointer(func, 9); 266958ebd649SToby Isaac *func = b->func; 267058ebd649SToby Isaac } 267158ebd649SToby Isaac if (numids) { 267258ebd649SToby Isaac PetscValidPointer(numids, 10); 267358ebd649SToby Isaac *numids = b->numids; 267458ebd649SToby Isaac } 267558ebd649SToby Isaac if (ids) { 267658ebd649SToby Isaac PetscValidPointer(ids, 11); 267758ebd649SToby Isaac *ids = b->ids; 267858ebd649SToby Isaac } 267958ebd649SToby Isaac if (ctx) { 268058ebd649SToby Isaac PetscValidPointer(ctx, 12); 268158ebd649SToby Isaac *ctx = b->ctx; 268258ebd649SToby Isaac } 268358ebd649SToby Isaac PetscFunctionReturn(0); 268458ebd649SToby Isaac } 268558ebd649SToby Isaac 268658ebd649SToby Isaac #undef __FUNCT__ 2687dff059c6SToby Isaac #define __FUNCT__ "PetscDSCopyBoundary" 2688dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 2689dff059c6SToby Isaac { 2690dff059c6SToby Isaac DSBoundary b, next, *lastnext; 2691dff059c6SToby Isaac PetscErrorCode ierr; 2692dff059c6SToby Isaac 2693dff059c6SToby Isaac PetscFunctionBegin; 2694dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 2695dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 2696dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 2697dff059c6SToby Isaac next = probB->boundary; 2698dff059c6SToby Isaac while (next) { 2699dff059c6SToby Isaac DSBoundary b = next; 2700dff059c6SToby Isaac 2701dff059c6SToby Isaac next = b->next; 2702dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 2703dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 2704dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 2705dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2706dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 2707dff059c6SToby Isaac } 2708dff059c6SToby Isaac lastnext = &(probB->boundary); 2709dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 2710dff059c6SToby Isaac DSBoundary bNew; 2711dff059c6SToby Isaac 2712dff059c6SToby Isaac ierr = PetscNew(&bNew); 2713dff059c6SToby Isaac bNew->numcomps = b->numcomps; 2714dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 2715dff059c6SToby Isaac ierr = PetscMemcpy(bNew->comps, b->comps, bNew->numcomps*sizeof(PetscInt));CHKERRQ(ierr); 2716dff059c6SToby Isaac bNew->numids = b->numids; 2717dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 2718dff059c6SToby Isaac ierr = PetscMemcpy(bNew->ids, b->ids, bNew->numids*sizeof(PetscInt));CHKERRQ(ierr); 2719dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 2720dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 2721dff059c6SToby Isaac bNew->ctx = b->ctx; 2722dff059c6SToby Isaac bNew->essential = b->essential; 2723dff059c6SToby Isaac bNew->field = b->field; 2724dff059c6SToby Isaac bNew->func = b->func; 2725dff059c6SToby Isaac 2726dff059c6SToby Isaac *lastnext = bNew; 2727dff059c6SToby Isaac lastnext = &(bNew->next); 2728dff059c6SToby Isaac } 2729dff059c6SToby Isaac PetscFunctionReturn(0); 2730dff059c6SToby Isaac } 2731dff059c6SToby Isaac 2732dff059c6SToby Isaac #undef __FUNCT__ 2733da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations" 2734da51fcedSMatthew G. Knepley /*@ 2735da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 2736da51fcedSMatthew G. Knepley 2737da51fcedSMatthew G. Knepley Not collective 2738da51fcedSMatthew G. Knepley 2739da51fcedSMatthew G. Knepley Input Parameter: 2740da51fcedSMatthew G. Knepley . prob - The PetscDS object 2741da51fcedSMatthew G. Knepley 2742da51fcedSMatthew G. Knepley Output Parameter: 2743da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 2744da51fcedSMatthew G. Knepley 2745da51fcedSMatthew G. Knepley Level: intermediate 2746da51fcedSMatthew G. Knepley 2747da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 2748da51fcedSMatthew G. Knepley @*/ 2749da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 2750da51fcedSMatthew G. Knepley { 2751da51fcedSMatthew G. Knepley PetscInt Nf, Ng, f, g; 2752da51fcedSMatthew G. Knepley PetscErrorCode ierr; 2753da51fcedSMatthew G. Knepley 2754da51fcedSMatthew G. Knepley PetscFunctionBegin; 2755da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2756da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 2757da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 2758da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 2759da51fcedSMatthew G. Knepley if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr); 2760da51fcedSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2761da51fcedSMatthew G. Knepley PetscPointFunc obj; 2762da51fcedSMatthew G. Knepley PetscPointFunc f0, f1; 2763da51fcedSMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 2764da51fcedSMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 2765da51fcedSMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 2766da51fcedSMatthew G. Knepley PetscRiemannFunc r; 2767da51fcedSMatthew G. Knepley 2768da51fcedSMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 2769da51fcedSMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 2770da51fcedSMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 2771da51fcedSMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 2772da51fcedSMatthew G. Knepley ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr); 2773da51fcedSMatthew G. Knepley ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr); 2774da51fcedSMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr); 2775da51fcedSMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr); 2776da51fcedSMatthew G. Knepley for (g = 0; g < Nf; ++g) { 2777da51fcedSMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 2778da51fcedSMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 2779da51fcedSMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr); 2780da51fcedSMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 2781da51fcedSMatthew G. Knepley } 2782da51fcedSMatthew G. Knepley } 2783da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 2784da51fcedSMatthew G. Knepley } 2785da51fcedSMatthew G. Knepley 2786da51fcedSMatthew G. Knepley #undef __FUNCT__ 27872764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2788bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 27892764a2aaSMatthew G. Knepley { 2790*931fb3b8SToby Isaac PetscErrorCode ierr; 2791*931fb3b8SToby Isaac 27922764a2aaSMatthew G. Knepley PetscFunctionBegin; 2793*931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 27942764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27952764a2aaSMatthew G. Knepley } 27962764a2aaSMatthew G. Knepley 27972764a2aaSMatthew G. Knepley #undef __FUNCT__ 27982764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2799bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 28002764a2aaSMatthew G. Knepley { 28012764a2aaSMatthew G. Knepley PetscFunctionBegin; 28022764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 28032764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 28042764a2aaSMatthew G. Knepley prob->ops->view = NULL; 28052764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 28062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28072764a2aaSMatthew G. Knepley } 28082764a2aaSMatthew G. Knepley 28092764a2aaSMatthew G. Knepley /*MC 28102764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 28112764a2aaSMatthew G. Knepley 28122764a2aaSMatthew G. Knepley Level: intermediate 28132764a2aaSMatthew G. Knepley 28142764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 28152764a2aaSMatthew G. Knepley M*/ 28162764a2aaSMatthew G. Knepley 28172764a2aaSMatthew G. Knepley #undef __FUNCT__ 28182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 28192764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 28202764a2aaSMatthew G. Knepley { 28212764a2aaSMatthew G. Knepley PetscDS_Basic *b; 28222764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28232764a2aaSMatthew G. Knepley 28242764a2aaSMatthew G. Knepley PetscFunctionBegin; 2825*931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28262764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 28272764a2aaSMatthew G. Knepley prob->data = b; 28282764a2aaSMatthew G. Knepley 28292764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 28302764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28312764a2aaSMatthew G. Knepley } 2832